Updated validation for hasWorkFlow ID updation logic on storeLaserRequestChar and Added hasWorkFlow ID updation logic on getLaserRequestChar #504
@@ -3618,20 +3618,19 @@ class CharacteristicsController extends Controller
|
|||||||
$row->approver_status3 == 'Approved' || $row->approver_status2 == 'Rejected'
|
$row->approver_status3 == 'Approved' || $row->approver_status2 == 'Rejected'
|
||||||
);
|
);
|
||||||
|
|
||||||
$isPending = ! empty($row->mail_status) &&
|
if (! $isApproved) {
|
||||||
|
$isPending = ! empty($row->mail_status) &&
|
||||||
(
|
(
|
||||||
empty($row->approver_status1) || $row->approver_status1 == 'Hold' ||
|
empty($row->approver_status1) || $row->approver_status1 == 'Hold' ||
|
||||||
empty($row->approver_status2) || $row->approver_status2 == 'Hold' ||
|
empty($row->approver_status2) || $row->approver_status2 == 'Hold' ||
|
||||||
empty($row->approver_status3) || $row->approver_status3 == 'Hold'
|
empty($row->approver_status3) || $row->approver_status3 == 'Hold'
|
||||||
);
|
);
|
||||||
|
if ($isPending) {
|
||||||
|
$hasPending = true;
|
||||||
|
$allApproved = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if ($isPending) {
|
|
||||||
$hasPending = true;
|
|
||||||
$allApproved = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! $isApproved) {
|
|
||||||
$allApproved = false;
|
$allApproved = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3920,29 +3919,13 @@ class CharacteristicsController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($hasWorkFlowId == '0') {
|
if ($hasWorkFlowId == '0') {
|
||||||
if ($requestType == 'Characteristic') {
|
$updatedWorkId = '1';
|
||||||
$updatedWorkId = '1';
|
|
||||||
} elseif ($requestType == 'Quality') {
|
|
||||||
$updatedWorkId = '2';
|
|
||||||
}
|
|
||||||
} elseif ($hasWorkFlowId == '1') {
|
} elseif ($hasWorkFlowId == '1') {
|
||||||
if ($requestType == 'Characteristic') {
|
$updatedWorkId = '1';
|
||||||
$updatedWorkId = '1';
|
|
||||||
} elseif ($requestType == 'Quality') {
|
|
||||||
$updatedWorkId = '3';
|
|
||||||
}
|
|
||||||
} elseif ($hasWorkFlowId == '2') {
|
} elseif ($hasWorkFlowId == '2') {
|
||||||
if ($requestType == 'Characteristic') {
|
$updatedWorkId = '3';
|
||||||
$updatedWorkId = '3';
|
|
||||||
} elseif ($requestType == 'Quality') {
|
|
||||||
$updatedWorkId = '2';
|
|
||||||
}
|
|
||||||
} elseif ($hasWorkFlowId == '3') {
|
} elseif ($hasWorkFlowId == '3') {
|
||||||
if ($requestType == 'Characteristic') {
|
$updatedWorkId = '3';
|
||||||
$updatedWorkId = '3';
|
|
||||||
} elseif ($requestType == 'Quality') {
|
|
||||||
$updatedWorkId = '3';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ClassCharacteristic::where('plant_id', $plantId)
|
ClassCharacteristic::where('plant_id', $plantId)
|
||||||
@@ -4093,29 +4076,21 @@ class CharacteristicsController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($hasWorkFlowId == '0') {
|
if ($hasWorkFlowId == '0') {
|
||||||
if ($requestType == 'Characteristic') {
|
|
||||||
$updatedWorkId = '1';
|
$updatedWorkId = '2';
|
||||||
} elseif ($requestType == 'Quality') {
|
|
||||||
$updatedWorkId = '2';
|
|
||||||
}
|
|
||||||
} elseif ($hasWorkFlowId == '1') {
|
} elseif ($hasWorkFlowId == '1') {
|
||||||
if ($requestType == 'Characteristic') {
|
|
||||||
$updatedWorkId = '1';
|
$updatedWorkId = '3';
|
||||||
} elseif ($requestType == 'Quality') {
|
|
||||||
$updatedWorkId = '3';
|
|
||||||
}
|
|
||||||
} elseif ($hasWorkFlowId == '2') {
|
} elseif ($hasWorkFlowId == '2') {
|
||||||
if ($requestType == 'Characteristic') {
|
|
||||||
$updatedWorkId = '3';
|
$updatedWorkId = '2';
|
||||||
} elseif ($requestType == 'Quality') {
|
|
||||||
$updatedWorkId = '2';
|
|
||||||
}
|
|
||||||
} elseif ($hasWorkFlowId == '3') {
|
} elseif ($hasWorkFlowId == '3') {
|
||||||
if ($requestType == 'Characteristic') {
|
|
||||||
$updatedWorkId = '3';
|
$updatedWorkId = '3';
|
||||||
} elseif ($requestType == 'Quality') {
|
|
||||||
$updatedWorkId = '3';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ClassCharacteristic::where('plant_id', $plantId)
|
ClassCharacteristic::where('plant_id', $plantId)
|
||||||
@@ -4546,6 +4521,137 @@ class CharacteristicsController extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ..
|
||||||
|
|
||||||
|
$classRow = ClassCharacteristic::where('plant_id', $plantId)
|
||||||
|
->where('machine_id', $MachineId)
|
||||||
|
->where('aufnr', $jobNo)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if ($classRow) {
|
||||||
|
if ($requestType == 'Characteristic') {
|
||||||
|
$requestChars = RequestCharacteristic::where('plant_id', $plantId)
|
||||||
|
->where('machine_id', $MachineId)
|
||||||
|
->where('aufnr', $jobNo)
|
||||||
|
->get();
|
||||||
|
|
||||||
|
if (! $requestChars->isEmpty()) {
|
||||||
|
$hasPending = false;
|
||||||
|
$allApproved = true;
|
||||||
|
|
||||||
|
foreach ($requestChars as $row) {
|
||||||
|
|
||||||
|
$isApproved = (
|
||||||
|
$row->approver_status1 == 'Approved' || $row->approver_status1 == 'Rejected' ||
|
||||||
|
$row->approver_status2 == 'Approved' || $row->approver_status2 == 'Rejected' ||
|
||||||
|
$row->approver_status3 == 'Approved' || $row->approver_status2 == 'Rejected'
|
||||||
|
);
|
||||||
|
|
||||||
|
if (! $isApproved) {
|
||||||
|
$isPending = ! empty($row->mail_status) &&
|
||||||
|
(
|
||||||
|
empty($row->approver_status1) || $row->approver_status1 == 'Hold' ||
|
||||||
|
empty($row->approver_status2) || $row->approver_status2 == 'Hold' ||
|
||||||
|
empty($row->approver_status3) || $row->approver_status3 == 'Hold'
|
||||||
|
);
|
||||||
|
if ($isPending) {
|
||||||
|
$hasPending = true;
|
||||||
|
$allApproved = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$allApproved = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$current = $classRow->has_work_flow_id ?? '0';
|
||||||
|
|
||||||
|
if ($hasPending) {
|
||||||
|
if ($current == '0') {
|
||||||
|
$newValue = '1';
|
||||||
|
} elseif ($current == '1') {
|
||||||
|
$newValue = '1';
|
||||||
|
} elseif ($current == '2') {
|
||||||
|
$newValue = '3';
|
||||||
|
} elseif ($current == '3') {
|
||||||
|
$newValue = '3';
|
||||||
|
}
|
||||||
|
} elseif ($allApproved) {
|
||||||
|
if ($current == '0') {
|
||||||
|
$newValue = '0';
|
||||||
|
} elseif ($current == '1') {
|
||||||
|
$newValue = '0';
|
||||||
|
} elseif ($current == '2') {
|
||||||
|
$newValue = '2';
|
||||||
|
} elseif ($current == '3') {
|
||||||
|
$newValue = '2';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ClassCharacteristic::where('plant_id', $plantId)
|
||||||
|
->where('machine_id', $MachineId)
|
||||||
|
->where('aufnr', $jobNo)
|
||||||
|
->update([
|
||||||
|
'has_work_flow_id' => $newValue,
|
||||||
|
'updated_at' => now(),
|
||||||
|
'updated_by' => $userName,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
} elseif ($requestType == 'Quality') {
|
||||||
|
|
||||||
|
$requestChar = RequestCharacteristic::where('plant_id', $plantId)
|
||||||
|
->where('machine_id', $MachineId)
|
||||||
|
->where('aufnr', $jobNo)
|
||||||
|
->latest()
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if ($requestChar) {
|
||||||
|
|
||||||
|
$current = $requestChar->has_work_flow_id ?? '0';
|
||||||
|
|
||||||
|
$isApproved =
|
||||||
|
$requestChar->approver_status1 == 'Approved' ||
|
||||||
|
$requestChar->approver_status2 == 'Approved' ||
|
||||||
|
$requestChar->approver_status3 == 'Approved';
|
||||||
|
|
||||||
|
if ($isApproved) {
|
||||||
|
if ($current == '0') {
|
||||||
|
$newValue = '0';
|
||||||
|
} elseif ($current == '1') {
|
||||||
|
$newValue = '1';
|
||||||
|
} elseif ($current == '2') {
|
||||||
|
$newValue = '0';
|
||||||
|
} elseif ($current == '3') {
|
||||||
|
$newValue = '1';
|
||||||
|
}
|
||||||
|
} elseif (
|
||||||
|
$requestChar->approver_status1 == 'Hold' || $requestChar->approver_status1 == 'Rejected' || $requestChar->approver_status1 == null || $requestChar->approver_status1 == '' ||
|
||||||
|
$requestChar->approver_status2 == 'Hold' || $requestChar->approver_status2 == 'Rejected' || $requestChar->approver_status2 == null || $requestChar->approver_status2 == '' ||
|
||||||
|
$requestChar->approver_status3 == 'Hold' || $requestChar->approver_status3 == 'Rejected' || $requestChar->approver_status3 == null || $requestChar->approver_status3 == ''
|
||||||
|
) {
|
||||||
|
if ($current == '0') {
|
||||||
|
$newValue = '2';
|
||||||
|
} elseif ($current == '1') {
|
||||||
|
$newValue = '3';
|
||||||
|
} elseif ($current == '2') {
|
||||||
|
$newValue = '2';
|
||||||
|
} elseif ($current == '3') {
|
||||||
|
$newValue = '3';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ClassCharacteristic::where('plant_id', $plantId)
|
||||||
|
->where('machine_id', $MachineId)
|
||||||
|
->where('aufnr', $jobNo)
|
||||||
|
->update([
|
||||||
|
'has_work_flow_id' => $newValue,
|
||||||
|
'updated_at' => now(),
|
||||||
|
'updated_by' => $userName,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (! $workFlowId) {
|
if (! $workFlowId) {
|
||||||
$records = RequestCharacteristic::with('approver')->where('aufnr', $jobNo)->where('plant_id', $plantId)->where('item_id', $ItemId)->where('machine_id', $MachineId)->whereHas('approver', function ($query) use ($requestType) {
|
$records = RequestCharacteristic::with('approver')->where('aufnr', $jobNo)->where('plant_id', $plantId)->where('item_id', $ItemId)->where('machine_id', $MachineId)->whereHas('approver', function ($query) use ($requestType) {
|
||||||
$query->where('approver_type', $requestType);
|
$query->where('approver_type', $requestType);
|
||||||
|
|||||||
Reference in New Issue
Block a user