Added Request Stop Characteristics create logic and updated warning message and variables
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 14s

This commit is contained in:
dhanabalan
2026-09-18 14:43:00 +05:30
parent c0eab3e989
commit 40f417193c

View File

@@ -756,7 +756,7 @@ class CharacteristicsController extends Controller
$isAuto = false;
$machineName = null;
if ($stopAlert && $markedStatus == 'Stopped') {
if ($jobNo != null && $jobNo != '' && $jobNo && $stopAlert && $markedStatus == 'Stopped') {
foreach ($data['characteristics'] as $char) {
if ($modelType == 'MOTOR') { // empty($char['motor_machine_name'])
$machineName = $char['motor_machine_name'];
@@ -771,7 +771,7 @@ class CharacteristicsController extends Controller
if (! $pCode) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Plant code '{$plantCode}' not found in approver master!",
'status_description' => "Plant code '{$plantCode}' not found in stop approver master!",
], 404);
}
@@ -779,7 +779,7 @@ class CharacteristicsController extends Controller
if (! $wCenter) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Work center '{$workCenter}' not found in approver master!",
'status_description' => "Work center '{$workCenter}' not found in stop approver master!",
], 404);
}
@@ -787,7 +787,7 @@ class CharacteristicsController extends Controller
if (! $wCenterAgaPlant) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Work center '{$workCenter}' not found for the plant code '{$plantCode}' in approver master!",
'status_description' => "Work center '{$workCenter}' not found for the plant code '{$plantCode}' in stop approver master!",
], 404);
}
@@ -795,7 +795,7 @@ class CharacteristicsController extends Controller
if (! $mName) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Machine name '{$machineName}' not found in approver master!",
'status_description' => "Machine name '{$machineName}' not found in stop approver master!",
], 404);
}
@@ -803,7 +803,7 @@ class CharacteristicsController extends Controller
if (! $mNameAgaPlant) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Machine name '{$machineName}' not found for the plant code '{$plantCode}' in approver master!",
'status_description' => "Machine name '{$machineName}' not found for the plant code '{$plantCode}' in stop approver master!",
], 404);
}
@@ -811,16 +811,16 @@ class CharacteristicsController extends Controller
if (! $cField) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Master characteristic field value '{$charField}' not found in approver master!",
'status_description' => "Master characteristic field value '{$charField}' not found in stop approver master!",
], 404);
}
// Master characteristic field value 'NIL' not found in approver master!
// Master characteristic field value 'NIL' not found in stop approver master!
$cFieldAgaPlant = CharacteristicApproverMaster::where('characteristic_field', $charField)->where('plant_id', $plantId)->first();
if (! $cFieldAgaPlant) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Master characteristic field value '{$charField}' not found for the plant code '{$plantCode}' in approver master!",
'status_description' => "Master characteristic field value '{$charField}' not found for the plant code '{$plantCode}' in stop approver master!",
], 404);
}
@@ -828,7 +828,7 @@ class CharacteristicsController extends Controller
if (! $mNameAndWorkCenter) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Machine name '{$machineName}' and work center '{$workCenter}' not found in approver master!",
'status_description' => "Machine name '{$machineName}' and work center '{$workCenter}' not found in stop approver master!",
], 404);
}
@@ -836,7 +836,7 @@ class CharacteristicsController extends Controller
if (! $mNameAndWorkCenterAgaPlant) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Machine name '{$machineName}' and work center '{$workCenter}' not found for the plant code '{$plantCode}' in approver master!",
'status_description' => "Machine name '{$machineName}' and work center '{$workCenter}' not found for the plant code '{$plantCode}' in stop approver master!",
], 404);
}
@@ -844,7 +844,7 @@ class CharacteristicsController extends Controller
if (! $cFieldAndWorkCent) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Master characteristic field value '{$charField}' not found for the work center '{$workCenter}' in approver master!",
'status_description' => "Master characteristic field value '{$charField}' not found for the work center '{$workCenter}' in stop approver master!",
], 404);
}
@@ -852,7 +852,7 @@ class CharacteristicsController extends Controller
if (! $cFieldAndWorkCentAgaPlant) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Master characteristic field value '{$charField}' and work center '{$workCenter}' not found for the plant code '{$plantCode}' in approver master!",
'status_description' => "Master characteristic field value '{$charField}' and work center '{$workCenter}' not found for the plant code '{$plantCode}' in stop approver master!",
], 404);
}
@@ -860,7 +860,7 @@ class CharacteristicsController extends Controller
if (! $cFieldAndMach) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Master characteristic field value '{$charField}' not found for the machine name '{$machineName}' in approver master!",
'status_description' => "Master characteristic field value '{$charField}' not found for the machine name '{$machineName}' in stop approver master!",
], 404);
}
@@ -868,7 +868,7 @@ class CharacteristicsController extends Controller
if (! $cFieldAndMachAgaPlant) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Master characteristic field value '{$charField}' and machine name '{$machineName}' not found for the plant code '{$plantCode}' in approver master!",
'status_description' => "Master characteristic field value '{$charField}' and machine name '{$machineName}' not found for the plant code '{$plantCode}' in stop approver master!",
], 404);
}
@@ -876,7 +876,7 @@ class CharacteristicsController extends Controller
if (! $cFieldAndWorkCentAndMachAgaPlant) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Master characteristic field value '{$charField}', work center '{$workCenter}', and machine name '{$machineName}' not found for the plant code '{$plantCode}' in approver master!",
'status_description' => "Master characteristic field value '{$charField}', work center '{$workCenter}', and machine name '{$machineName}' not found for the plant code '{$plantCode}' in stop approver master!",
], 404);
}
@@ -884,9 +884,11 @@ class CharacteristicsController extends Controller
if (! $appTypExist) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Master characteristic field value '{$charField}', work center '{$workCenter}', machine name '{$machineName}', and plant code '{$plantCode}' not found for the approver type 'Stop' in approver master!",
'status_description' => "Master characteristic field value '{$charField}', work center '{$workCenter}', machine name '{$machineName}', and plant code '{$plantCode}' not found for the approver type 'Stop' in stop approver master!",
], 404);
}
$charId = $appTypExist->id;
}
foreach ($data['characteristics'] as $char) {
@@ -937,6 +939,33 @@ class CharacteristicsController extends Controller
// ], 404);
}
if ($stopAlert && $markedStatus == 'Stopped') {
$requestStop = RequestCharacteristic::where('gernr', $serialNumber)->where('aufnr', $jobNo)->where('item_id', $itemId)->where('model_type', $modelType)
->whereHas('approver', function ($query) {
$query->where('approver_type', 'Stop');
})->where('machine_id', $machineId)->where('plant_id', $plantId)->latest()->first();
if ($requestStop) {
$stopFlowStatus = ($requestStop->approver_status1 == 'Approved' || $requestStop->approver_status2 == 'Approved' || $requestStop->approver_status3 == 'Approved') ? '0' : '1';
TempStopCharacteristic::where('gernr', $serialNumber)->where('aufnr', $jobNo)->where('model_type', $modelType)->where('machine_id', $machineId)->where('plant_id', $plantId)
->update([
'has_stop_flow_id' => $stopFlowStatus,
'updated_by' => $userName,
]);
$classModelType = strtolower($modelType).'_stop_flow_id';
$classStopFlowStatus = ($stopFlowStatus == '0') ? '1' : '2';
ClassCharacteristic::where('gernr', $serialNumber)->where('aufnr', $jobNo)->where('machine_id', $machineId)->where('plant_id', $plantId)
->update([
$classModelType => $classStopFlowStatus,
'updated_at' => now(),
'updated_by' => $userName,
]);
}
}
$physiCnt = (intval($curStat->marked_physical_count ?? 0) ?: 0) + 1;
// $physiCnt = (($curStat->marked_physical_count == null || $curStat->marked_physical_count == '' || $curStat->marked_physical_count == '0') ? 0 : (int) $curStat->marked_physical_count) + 1;
// marked_expected_time
@@ -1468,6 +1497,210 @@ class CharacteristicsController extends Controller
$affected = ClassCharacteristic::where('gernr', $serialNumber)->where('item_id', $itemId)->where('aufnr', $jobNo)->where('machine_id', $machineId)->where('plant_id', $plantId)->update($values);
$updatedRows += $affected;
if ($stopAlert && $markedStatus == 'Stopped') {
$requestStop = RequestCharacteristic::where('gernr', $serialNumber)->where('aufnr', $jobNo)->where('item_id', $itemId)->where('model_type', $modelType)
->whereHas('approver', function ($query) {
$query->where('approver_type', 'Stop');
})->where('machine_id', $machineId)->where('plant_id', $plantId)->latest()->first();
if ($requestStop) {
$stopFlowStatus = ($requestStop->approver_status1 == 'Approved' || $requestStop->approver_status2 == 'Approved' || $requestStop->approver_status3 == 'Approved') ? '0' : '1';
$tempCharacteristics = TempStopCharacteristic::where('gernr', $serialNumber)->where('aufnr', $jobNo)->where('model_type', $modelType)->where('machine_id', $machineId)->where('plant_id', $plantId)->latest()->first();
if ($stopFlowStatus == '0') {
if ($tempCharacteristics) {
$tempCharacteristics->update([
'has_stop_flow_id' => $stopFlowStatus,
'updated_by' => $userName,
]);
}
try {
$approvalId = [];
$year = now()->format('y');
$month = now()->format('m');
$date = now()->format('d');
$prefix = "WF-{$year}{$month}{$date}-";
$lastWorkflow = RequestCharacteristic::where('work_flow_id', 'like', "{$prefix}%")
->orderByDesc('work_flow_id')
->first();
if ($lastWorkflow) {
$lastSerial = substr($lastWorkflow->work_flow_id, strlen($prefix));
$nextSerial = str_pad(
intval($lastSerial) + 1,
4,
'0',
STR_PAD_LEFT
);
} else {
$nextSerial = '0001';
}
$workflowId = "{$prefix}{$nextSerial}";
RequestCharacteristic::create([
'plant_id' => $plantId,
'machine_id' => $machineId,
'item_id' => $itemId,
'model_type' => $modelType,
'characteristic_approver_master_id' => $charId,
'aufnr' => $jobNo,
'gernr' => $serialNumber,
'characteristic_name' => '',
'current_value' => '',
'update_value' => '',
'created_by' => $userName,
'work_flow_id' => $workflowId,
]);
TempStopCharacteristic::create([
'plant_id' => $plantId,
'machine_id' => $machineId,
'item_id' => $itemId,
'machine_name' => $machineName,
'aufnr' => $jobNo,
'gernr' => $serialNumber,
'zmm_heading' => $curHead,
'model_type' => $modelType,
'characteristic_field' => $charField,
'samlight_logged_name' => empty($char['samlight_logged_name']) ? $slUser : $char['samlight_logged_name'],
'stopped_at' => empty($char['marked_datetime']) ? now() : $char['marked_datetime'],
'stopped_by' => ($char['marked_by'] == 'jothi') ? 'Admin' : $char['marked_by'] ?? $userName,
'has_stop_flow_id' => '1',
'created_by' => $userName,
'updated_by' => $userName,
]);
$classModelType = strtolower($modelType).'_stop_flow_id';
ClassCharacteristic::where('gernr', $serialNumber)->where('aufnr', $jobNo)->where('machine_id', $machineId)->where('plant_id', $plantId)
->update([
$classModelType => '2',
'updated_at' => now(),
'updated_by' => $userName,
]);
} catch (\Exception $e) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => $e->getMessage(),
], 500);
}
} elseif ($stopFlowStatus == '1') {
if (! $tempCharacteristics) {
TempStopCharacteristic::create([
'plant_id' => $plantId,
'machine_id' => $machineId,
'item_id' => $itemId,
'machine_name' => $machineName,
'aufnr' => $jobNo,
'gernr' => $serialNumber,
'zmm_heading' => $curHead,
'model_type' => $modelType,
'characteristic_field' => $charField,
'samlight_logged_name' => empty($char['samlight_logged_name']) ? $slUser : $char['samlight_logged_name'],
'stopped_at' => empty($char['marked_datetime']) ? now() : $char['marked_datetime'],
'stopped_by' => ($char['marked_by'] == 'jothi') ? 'Admin' : $char['marked_by'] ?? $userName,
'has_stop_flow_id' => '1',
'created_by' => $userName,
'updated_by' => $userName,
]);
} elseif ($tempCharacteristics) {
$tempCharacteristics->update([
'has_stop_flow_id' => $stopFlowStatus,
'updated_by' => $userName,
]);
}
$classModelType = strtolower($modelType).'_stop_flow_id';
ClassCharacteristic::where('gernr', $serialNumber)->where('aufnr', $jobNo)->where('machine_id', $machineId)->where('plant_id', $plantId)
->update([
$classModelType => '2',
'updated_at' => now(),
'updated_by' => $userName,
]);
}
} else {
try {
$approvalId = [];
$year = now()->format('y');
$month = now()->format('m');
$date = now()->format('d');
$prefix = "WF-{$year}{$month}{$date}-";
$lastWorkflow = RequestCharacteristic::where('work_flow_id', 'like', "{$prefix}%")
->orderByDesc('work_flow_id')
->first();
if ($lastWorkflow) {
$lastSerial = substr($lastWorkflow->work_flow_id, strlen($prefix));
$nextSerial = str_pad(
intval($lastSerial) + 1,
4,
'0',
STR_PAD_LEFT
);
} else {
$nextSerial = '0001';
}
$workflowId = "{$prefix}{$nextSerial}";
RequestCharacteristic::create([
'plant_id' => $plantId,
'machine_id' => $machineId,
'item_id' => $itemId,
'model_type' => $modelType,
'characteristic_approver_master_id' => $charId,
'aufnr' => $jobNo,
'gernr' => $serialNumber,
'characteristic_name' => '',
'current_value' => '',
'update_value' => '',
'created_by' => $userName,
'work_flow_id' => $workflowId,
]);
TempStopCharacteristic::create([
'plant_id' => $plantId,
'machine_id' => $machineId,
'item_id' => $itemId,
'machine_name' => $machineName,
'aufnr' => $jobNo,
'gernr' => $serialNumber,
'zmm_heading' => $curHead,
'model_type' => $modelType,
'characteristic_field' => $charField,
'samlight_logged_name' => empty($char['samlight_logged_name']) ? $slUser : $char['samlight_logged_name'],
'stopped_at' => empty($char['marked_datetime']) ? now() : $char['marked_datetime'],
'stopped_by' => ($char['marked_by'] == 'jothi') ? 'Admin' : $char['marked_by'] ?? $userName,
'has_stop_flow_id' => '1',
'created_by' => $userName,
'updated_by' => $userName,
]);
$classModelType = strtolower($modelType).'_stop_flow_id';
ClassCharacteristic::where('gernr', $serialNumber)->where('aufnr', $jobNo)->where('machine_id', $machineId)->where('plant_id', $plantId)
->update([
$classModelType => '2',
'updated_at' => now(),
'updated_by' => $userName,
]);
} catch (\Exception $e) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => $e->getMessage(),
], 500);
}
}
}
} else {
// $curStat = ClassCharacteristic::where('plant_id', $plantId)->where('machine_id', $machineId)->where('gernr', $serialNumber)->where('item_id', $itemId)->first();
if ($modelType == 'MOTOR' && $curMarkStat != 'Marked' && $curMotorMarkStat != 'Marked') {
@@ -5669,7 +5902,7 @@ class CharacteristicsController extends Controller
$workCenter = $request->header('work-center');
$machineName = $request->header('machine-name');
$jobNo = $request->header('aufnr');
$serialNo = $request->header('gernr');
$serialNumber = $request->header('gernr');
$itemCode = $request->header('item-code');
$workFlowId = $request->header('work-flow-id');
$workFlowId = strtoupper($workFlowId);
@@ -5677,7 +5910,7 @@ class CharacteristicsController extends Controller
$modelHeading = $request->header('model-heading');
$requestType = $request->header('request-type');
Log::info("Request {$requestType} POST API >>", ['user-name' => $userName, 'characteristic-field' => $charField, 'plant-code' => $plantCode, 'work-center' => $workCenter, 'machine-name' => $machineName, 'aufnr' => $jobNo, 'gernr' => $serialNo, 'item-code' => $itemCode, 'work-flow-id' => $workFlowId]);
Log::info("Request {$requestType} POST API >>", ['user-name' => $userName, 'characteristic-field' => $charField, 'plant-code' => $plantCode, 'work-center' => $workCenter, 'machine-name' => $machineName, 'aufnr' => $jobNo, 'gernr' => $serialNumber, 'item-code' => $itemCode, 'work-flow-id' => $workFlowId]);
if (! $userName || $userName == null || $userName == '') {
return response()->json([
@@ -5718,7 +5951,7 @@ class CharacteristicsController extends Controller
'status_code' => 'ERROR',
'status_description' => "Job number can't be empty!",
], 404);
} elseif ($requestType == 'Stop' && (! $serialNo || $serialNo == null || $serialNo == '')) {
} elseif ($requestType == 'Stop' && (! $serialNumber || $serialNumber == null || $serialNumber == '')) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Serial number can't be empty!",
@@ -5803,20 +6036,20 @@ class CharacteristicsController extends Controller
}
if ($requestType == 'Stop') {
if (Str::length($serialNo) < 9) {
if (Str::length($serialNumber) < 9) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Serial number '{$serialNo}' should contain minimum 9 digits!",
'status_description' => "Serial number '{$serialNumber}' should contain minimum 9 digits!",
], 404);
} elseif (! ctype_alnum($serialNo)) {
} elseif (! ctype_alnum($serialNumber)) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Serial number '{$serialNo}' should contain only alpha-numeric values!",
'status_description' => "Serial number '{$serialNumber}' should contain only alpha-numeric values!",
], 404);
} elseif (! preg_match('/^[1-9][a-zA-Z0-9]{8,}$/', $serialNo)) {
} elseif (! preg_match('/^[1-9][a-zA-Z0-9]{8,}$/', $serialNumber)) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Serial number '{$serialNo}' should not begin with '0' or letter!",
'status_description' => "Serial number '{$serialNumber}' should not begin with '0' or letter!",
], 404);
}
}
@@ -6067,43 +6300,43 @@ class CharacteristicsController extends Controller
}
if ($requestType == 'Stop') {
$serial = RequestCharacteristic::where('gernr', $serialNo)->first();
$serial = RequestCharacteristic::where('gernr', $serialNumber)->first();
if (! $serial) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Serial number '{$serialNo}' not found in request approval table!",
'status_description' => "Serial number '{$serialNumber}' not found in request approval table!",
], 404);
}
$serAgaJob = RequestCharacteristic::where('gernr', $serialNo)->where('plant_id', $plantId)->first();
$serAgaJob = RequestCharacteristic::where('gernr', $serialNumber)->where('plant_id', $plantId)->first();
if (! $serAgaJob) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Serial number '{$serialNo}' not found for the plant code '{$plantCode}' in request approval table!",
'status_description' => "Serial number '{$serialNumber}' not found for the plant code '{$plantCode}' in request approval table!",
], 404);
}
$serAgaPlant = RequestCharacteristic::where('gernr', $serialNo)->where('aufnr', $jobNo)->where('plant_id', $plantId)->first();
$serAgaPlant = RequestCharacteristic::where('gernr', $serialNumber)->where('aufnr', $jobNo)->where('plant_id', $plantId)->first();
if (! $serAgaPlant) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Serial number '{$serialNo}' not found with the job number '{$jobNo}' in request approval table!",
'status_description' => "Serial number '{$serialNumber}' not found with the job number '{$jobNo}' in request approval table!",
], 404);
}
$serAgaPlantItem = RequestCharacteristic::where('gernr', $serialNo)->where('aufnr', $jobNo)->where('item_id', $itemId)->where('plant_id', $plantId)->first();
$serAgaPlantItem = RequestCharacteristic::where('gernr', $serialNumber)->where('aufnr', $jobNo)->where('item_id', $itemId)->where('plant_id', $plantId)->first();
if (! $serAgaPlantItem) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Serial number '{$serialNo}' not found with the item code '{$itemCode}' in request approval table!",
'status_description' => "Serial number '{$serialNumber}' not found with the item code '{$itemCode}' in request approval table!",
], 404);
}
$serAgaPlantMachine = RequestCharacteristic::where('gernr', $serialNo)->where('aufnr', $jobNo)->where('item_id', $itemId)->where('machine_id', $machineId)->where('plant_id', $plantId)->first();
$serAgaPlantMachine = RequestCharacteristic::where('gernr', $serialNumber)->where('aufnr', $jobNo)->where('item_id', $itemId)->where('machine_id', $machineId)->where('plant_id', $plantId)->first();
if (! $serAgaPlantMachine) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Job number '$jobNo' not found for the work center '$workCenter' in request approval table!",
'status_description' => "Serial number '{$serialNumber}' not found for the work center '$workCenter' in request approval table!",
], 404);
}
}
@@ -6196,7 +6429,7 @@ class CharacteristicsController extends Controller
], 404);
}
}
} else {
} elseif ($requestType == 'Stop') {
$appTypExist = CharacteristicApproverMaster::where('characteristic_field', $charField)->where('approver_type', $requestType)->where('machine_name', $machineName)->where('machine_id', $machineId)->where('plant_id', $plantId)->first();
if (! $appTypExist) {
return response()->json([
@@ -6205,7 +6438,7 @@ class CharacteristicsController extends Controller
], 404);
}
$reqCharExist = RequestCharacteristic::where('gernr', $serialNo)->where('aufnr', $jobNo)->where('item_id', $itemId)->where('model_type', $modelType)
$reqCharExist = RequestCharacteristic::where('gernr', $serialNumber)->where('aufnr', $jobNo)->where('item_id', $itemId)->where('model_type', $modelType)
->whereHas('approver', function ($query) use ($requestType) {
$query->where('approver_type', $requestType);
})->where('machine_id', $machineId)->where('plant_id', $plantId)->first();
@@ -6213,7 +6446,7 @@ class CharacteristicsController extends Controller
if (! $reqCharExist) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Request stop approvals not found for the Job number '{$jobNo}', item code '{$itemCode}', work center '{$workCenter}', model type '{$modelType}' and plant code '{$plantCode}'!",
'status_description' => "Request stop approvals not found for the Serial number '{$serialNumber}', Job number '{$jobNo}', item code '{$itemCode}', work center '{$workCenter}', model type '{$modelType}' and plant code '{$plantCode}'!",
], 404);
}
@@ -6245,12 +6478,12 @@ class CharacteristicsController extends Controller
$classRow = ClassCharacteristic::where('aufnr', $jobNo)->where('machine_id', $machineId)->where('plant_id', $plantId)->latest()->first();
if ($requestType == 'Stop') {
$classRow = ClassCharacteristic::where('gernr', $serialNo)->where('aufnr', $jobNo)->where('machine_id', $machineId)->where('plant_id', $plantId)->latest()->first();
$classRow = ClassCharacteristic::where('gernr', $serialNumber)->where('aufnr', $jobNo)->where('machine_id', $machineId)->where('plant_id', $plantId)->latest()->first();
}
if ($classRow) {
if ($requestType == 'Stop') {
$requestStop = RequestCharacteristic::where('gernr', $serialNo)->where('aufnr', $jobNo)->where('item_id', $itemId)->where('model_type', $modelType)
$requestStop = RequestCharacteristic::where('gernr', $serialNumber)->where('aufnr', $jobNo)->where('item_id', $itemId)->where('model_type', $modelType)
->whereHas('approver', function ($query) {
$query->where('approver_type', 'Stop');
})->where('machine_id', $machineId)->where('plant_id', $plantId)->latest()->first();
@@ -6260,7 +6493,7 @@ class CharacteristicsController extends Controller
$classModelType = strtolower($modelType).'_stop_flow_id';
TempStopCharacteristic::where('gernr', $serialNo)->where('aufnr', $jobNo)->where('model_type', $modelType)->where('machine_id', $machineId)->where('plant_id', $plantId)
TempStopCharacteristic::where('gernr', $serialNumber)->where('aufnr', $jobNo)->where('model_type', $modelType)->where('machine_id', $machineId)->where('plant_id', $plantId)
->update([
'has_stop_flow_id' => $stopFlowStatus,
'updated_by' => $userName,
@@ -6268,7 +6501,7 @@ class CharacteristicsController extends Controller
$classStopFlowStatus = ($stopFlowStatus == '0') ? '1' : '2';
ClassCharacteristic::where('gernr', $serialNo)->where('aufnr', $jobNo)->where('machine_id', $machineId)->where('plant_id', $plantId)
ClassCharacteristic::where('gernr', $serialNumber)->where('aufnr', $jobNo)->where('machine_id', $machineId)->where('plant_id', $plantId)
->update([
$classModelType => $classStopFlowStatus,
'updated_at' => now(),
@@ -6397,7 +6630,7 @@ class CharacteristicsController extends Controller
}
} else {
if ($requestType == 'Stop') {
$requestStop = RequestCharacteristic::where('gernr', $serialNo)->where('aufnr', $jobNo)->where('item_id', $itemId)->where('model_type', $modelType)
$requestStop = RequestCharacteristic::where('gernr', $serialNumber)->where('aufnr', $jobNo)->where('item_id', $itemId)->where('model_type', $modelType)
->whereHas('approver', function ($query) {
$query->where('approver_type', 'Stop');
})->where('machine_id', $machineId)->where('plant_id', $plantId)->latest()->first();
@@ -6405,7 +6638,7 @@ class CharacteristicsController extends Controller
if ($requestStop) {
$stopFlowStatus = ($requestStop->approver_status1 == 'Approved' || $requestStop->approver_status2 == 'Approved' || $requestStop->approver_status3 == 'Approved') ? '0' : '1';
TempStopCharacteristic::where('gernr', $serialNo)->where('aufnr', $jobNo)->where('model_type', $modelType)->where('machine_id', $machineId)->where('plant_id', $plantId)
TempStopCharacteristic::where('gernr', $serialNumber)->where('aufnr', $jobNo)->where('model_type', $modelType)->where('machine_id', $machineId)->where('plant_id', $plantId)
->update([
'has_stop_flow_id' => $stopFlowStatus,
'updated_by' => $userName,
@@ -6479,13 +6712,13 @@ class CharacteristicsController extends Controller
})->where('machine_id', $machineId)->where('plant_id', $plantId)->orderBy('id')->get();
} elseif ($requestType == 'Stop') {
if ($workFlowId == 'FINAL') {
$records = RequestCharacteristic::where('gernr', $serialNo)->where('aufnr', $jobNo)->where('item_id', $itemId)->where('model_type', $modelType)
$records = RequestCharacteristic::where('gernr', $serialNumber)->where('aufnr', $jobNo)->where('item_id', $itemId)->where('model_type', $modelType)
->whereHas('approver', function ($query) use ($requestType) {
$query->where('approver_type', $requestType);
})->where('machine_id', $machineId)->where('plant_id', $plantId)->latest()
->first();
} else {
$records = RequestCharacteristic::where('gernr', $serialNo)->where('aufnr', $jobNo)->where('item_id', $itemId)->where('model_type', $modelType)
$records = RequestCharacteristic::where('gernr', $serialNumber)->where('aufnr', $jobNo)->where('item_id', $itemId)->where('model_type', $modelType)
->whereHas('approver', function ($query) use ($requestType) {
$query->where('approver_type', $requestType);
})->where('machine_id', $machineId)->where('plant_id', $plantId)->orderBy('id')->get();
@@ -6592,7 +6825,7 @@ class CharacteristicsController extends Controller
'requested_by' => ($row->created_by == 'Admin') ? 'jothi' : $row->created_by ?? '',
'requested_at' => $row->created_at ? $row->created_at->format('Y-m-d H:i:s') : '',
];
} else {
} elseif ($requestType == 'Stop') {
$workFlowStatus = ($row->approver_status1 == 'Approved' || $row->approver_status2 == 'Approved' || $row->approver_status3 == 'Approved') ? '0' : '1';
$response[] = [
@@ -6845,7 +7078,7 @@ class CharacteristicsController extends Controller
if (! $pCode) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Plant code '{$plantCode}' not found in approver master!",
'status_description' => "Plant code '{$plantCode}' not found in stop approver master!",
], 404);
}
@@ -6853,7 +7086,7 @@ class CharacteristicsController extends Controller
if (! $wCenter) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Work center '{$workCenter}' not found in approver master!",
'status_description' => "Work center '{$workCenter}' not found in stop approver master!",
], 404);
}
@@ -6861,7 +7094,7 @@ class CharacteristicsController extends Controller
if (! $wCenterAgaPlant) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Work center '{$workCenter}' not found for the plant code '{$plantCode}' in approver master!",
'status_description' => "Work center '{$workCenter}' not found for the plant code '{$plantCode}' in stop approver master!",
], 404);
}
@@ -6869,7 +7102,7 @@ class CharacteristicsController extends Controller
if (! $mName) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Machine name '{$machineName}' not found in approver master!",
'status_description' => "Machine name '{$machineName}' not found in stop approver master!",
], 404);
}
@@ -6877,7 +7110,7 @@ class CharacteristicsController extends Controller
if (! $mNameAgaPlant) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Machine name '{$machineName}' not found for the plant code '{$plantCode}' in approver master!",
'status_description' => "Machine name '{$machineName}' not found for the plant code '{$plantCode}' in stop approver master!",
], 404);
}
@@ -6885,16 +7118,16 @@ class CharacteristicsController extends Controller
if (! $cField) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Master characteristic field value '{$charField}' not found in approver master!",
'status_description' => "Master characteristic field value '{$charField}' not found in stop approver master!",
], 404);
}
// Master characteristic field value 'NIL' not found in approver master!
// Master characteristic field value 'NIL' not found in stop approver master!
$cFieldAgaPlant = CharacteristicApproverMaster::where('characteristic_field', $charField)->where('plant_id', $plantId)->first();
if (! $cFieldAgaPlant) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Master characteristic field value '{$charField}' not found for the plant code '{$plantCode}' in approver master!",
'status_description' => "Master characteristic field value '{$charField}' not found for the plant code '{$plantCode}' in stop approver master!",
], 404);
}
@@ -6902,7 +7135,7 @@ class CharacteristicsController extends Controller
if (! $mNameAndWorkCenter) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Machine name '{$machineName}' and work center '{$workCenter}' not found in approver master!",
'status_description' => "Machine name '{$machineName}' and work center '{$workCenter}' not found in stop approver master!",
], 404);
}
@@ -6910,7 +7143,7 @@ class CharacteristicsController extends Controller
if (! $mNameAndWorkCenterAgaPlant) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Machine name '{$machineName}' and work center '{$workCenter}' not found for the plant code '{$plantCode}' in approver master!",
'status_description' => "Machine name '{$machineName}' and work center '{$workCenter}' not found for the plant code '{$plantCode}' in stop approver master!",
], 404);
}
@@ -6918,7 +7151,7 @@ class CharacteristicsController extends Controller
if (! $cFieldAndWorkCent) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Master characteristic field value '{$charField}' not found for the work center '{$workCenter}' in approver master!",
'status_description' => "Master characteristic field value '{$charField}' not found for the work center '{$workCenter}' in stop approver master!",
], 404);
}
@@ -6926,7 +7159,7 @@ class CharacteristicsController extends Controller
if (! $cFieldAndWorkCentAgaPlant) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Master characteristic field value '{$charField}' and work center '{$workCenter}' not found for the plant code '{$plantCode}' in approver master!",
'status_description' => "Master characteristic field value '{$charField}' and work center '{$workCenter}' not found for the plant code '{$plantCode}' in stop approver master!",
], 404);
}
@@ -6934,7 +7167,7 @@ class CharacteristicsController extends Controller
if (! $cFieldAndMach) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Master characteristic field value '{$charField}' not found for the machine name '{$machineName}' in approver master!",
'status_description' => "Master characteristic field value '{$charField}' not found for the machine name '{$machineName}' in stop approver master!",
], 404);
}
@@ -6942,7 +7175,7 @@ class CharacteristicsController extends Controller
if (! $cFieldAndMachAgaPlant) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Master characteristic field value '{$charField}' and machine name '{$machineName}' not found for the plant code '{$plantCode}' in approver master!",
'status_description' => "Master characteristic field value '{$charField}' and machine name '{$machineName}' not found for the plant code '{$plantCode}' in stop approver master!",
], 404);
}
@@ -6950,7 +7183,7 @@ class CharacteristicsController extends Controller
if (! $cFieldAndWorkCentAndMachAgaPlant) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Master characteristic field value '{$charField}', work center '{$workCenter}', and machine name '{$machineName}' not found for the plant code '{$plantCode}' in approver master!",
'status_description' => "Master characteristic field value '{$charField}', work center '{$workCenter}', and machine name '{$machineName}' not found for the plant code '{$plantCode}' in stop approver master!",
], 404);
}
@@ -6958,7 +7191,7 @@ class CharacteristicsController extends Controller
if (! $appTypExist) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Master characteristic field value '{$charField}', work center '{$workCenter}', machine name '{$machineName}', and plant code '{$plantCode}' not found for the approver type 'Stop' in approver master!",
'status_description' => "Master characteristic field value '{$charField}', work center '{$workCenter}', machine name '{$machineName}', and plant code '{$plantCode}' not found for the approver type 'Stop' in stop approver master!",
], 404);
}