diff --git a/app/Filament/Resources/RequestCharacteristicResource.php b/app/Filament/Resources/RequestCharacteristicResource.php index 79cde89..2cb0915 100644 --- a/app/Filament/Resources/RequestCharacteristicResource.php +++ b/app/Filament/Resources/RequestCharacteristicResource.php @@ -832,8 +832,8 @@ class RequestCharacteristicResource extends Resource $prefix = "WF-{$year}{$month}{$date}-"; $lastWorkflow = RequestCharacteristic::where('work_flow_id', 'like', "{$prefix}%") + // ->where('plant_id', $plantId) // ->where('machine_id', $MachineId) - ->where('work_flow_id', 'like', "{$prefix}%") ->orderByDesc('work_flow_id') ->first(); diff --git a/app/Http/Controllers/CharacteristicApprovalController.php b/app/Http/Controllers/CharacteristicApprovalController.php index f1b412b..a8ee45f 100644 --- a/app/Http/Controllers/CharacteristicApprovalController.php +++ b/app/Http/Controllers/CharacteristicApprovalController.php @@ -58,23 +58,24 @@ class CharacteristicApprovalController extends Controller } } - // foreach ($levels as $lvl => $column) { - // if ($record->$column == 'Hold') { + foreach ($levels as $lvl => $column) + { + if ($record->$column == 'Hold') { - // if ($lvl == $level) { - // return view('approval.already-processed', [ - // 'status' => 'On Hold', - // ]); - // } - // else - // { - // return view('approval.already-processed', [ - // 'status' => 'Hold', - // 'message' => 'On Hold', - // ]); - // } - // } - // } + if ($lvl == $level) { + return view('approval.already-processed', [ + 'status' => 'On Hold', + ]); + } + // else + // { + // return view('approval.already-processed', [ + // 'status' => 'Hold', + // 'message' => 'On Hold', + // ]); + // } + } + } $allowedMailStatusByLevel = [ 1 => 'Sent', @@ -355,8 +356,6 @@ class CharacteristicApprovalController extends Controller ], 403); } - - $workflowRecords = RequestCharacteristic::where('plant_id', $record->plant_id) ->where('machine_id', $record->machine_id) ->where('aufnr', $record->aufnr) @@ -369,6 +368,10 @@ class CharacteristicApprovalController extends Controller $approvedAtColumn => Carbon::now(), ]; + if (in_array($status, ['Approved', 'Rejected'])) { + $updateData['trigger_at'] = null; + } + foreach ($pendingRecords as $rec) { $rec->update($updateData); } diff --git a/app/Http/Controllers/CharacteristicsController.php b/app/Http/Controllers/CharacteristicsController.php index 7e0c61a..c14d522 100644 --- a/app/Http/Controllers/CharacteristicsController.php +++ b/app/Http/Controllers/CharacteristicsController.php @@ -2841,7 +2841,7 @@ class CharacteristicsController extends Controller $app2 = $pendingExists->approver_status2 ?? null; $app3 = $pendingExists->approver_status3 ?? null; - if ($app1 != 'Rejected' && $app2 != 'Rejected' && $app3 != 'Rejected' && $app1 != 'Approved' && $app2 != 'Approved' && $app3 != 'Approved') { + if ($app1 != 'Approved' && $app2 != 'Approved' && $app3 != 'Approved' && $app1 != 'Rejected' && $app2 != 'Rejected' && $app3 != 'Rejected') { $pendingCharacteristics[] = strtoupper($charNameUpp); } } @@ -2887,7 +2887,6 @@ class CharacteristicsController extends Controller $lastWorkflow = RequestCharacteristic::where('work_flow_id', 'like', "{$prefix}%") // ->where('plant_id', $plantId) // ->where('machine_id', $MachineId) - ->where('work_flow_id', 'like', "{$prefix}%") ->orderByDesc('work_flow_id') ->first(); @@ -2999,10 +2998,11 @@ class CharacteristicsController extends Controller $app2 = $pendingExists->approver_status2 ?? null; $app3 = $pendingExists->approver_status3 ?? null; - if ($app1 != 'Approved' && $app2 != 'Approved' && $app3 != 'Approved') {// $app1 != 'Rejected' && $app2 != 'Rejected' && $app3 != 'Rejected' && + if ($app1 != 'Approved' && $app2 != 'Approved' && $app3 != 'Approved' && $app1 != 'Rejected' && $app2 != 'Rejected' && $app3 != 'Rejected') { return response()->json([ 'status_code' => 'ERROR', 'status_description' => "Quality Approval is already pending for the Job Number : '{$jobNo}'", + // 'status_error' => $pendingExists, ], 404); } } @@ -3014,7 +3014,6 @@ class CharacteristicsController extends Controller $prefix = "WF-{$year}{$month}{$date}-"; $lastWorkflow = RequestCharacteristic::where('work_flow_id', 'like', "{$prefix}%") - ->where('work_flow_id', 'like', "{$prefix}%") ->orderByDesc('work_flow_id') ->first(); @@ -3583,15 +3582,9 @@ class CharacteristicsController extends Controller 'requested_characteristics' => $response, ], 200); } else { - $filePath = ''; - $filename = ''; - if ($requestType == 'Characteristic') { - $filePath = "uploads/LaserDocs/{$workFlowId}.pdf"; - $filename = "{$workFlowId}.pdf"; - } else { - $filePath = "uploads/LaserDocs/{$workFlowId}.png"; - $filename = "{$workFlowId}.png"; - } + $extension = ($requestType == 'Characteristic') ? 'pdf' : 'png'; + $filePath = "uploads/LaserDocs/{$workFlowId}.{$extension}"; + $filename = "{$workFlowId}.{$extension}"; $workFlowIdExist = RequestCharacteristic::where('work_flow_id', $workFlowId)->first();