From b9e164725e4a1bb6d3a1cb510d08b7d8a0de38d3 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Wed, 13 May 2026 10:01:00 +0530 Subject: [PATCH] Updated has_work_flow_id column value in TempClassCharacteristic table while request approval get api --- .../Controllers/CharacteristicsController.php | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/app/Http/Controllers/CharacteristicsController.php b/app/Http/Controllers/CharacteristicsController.php index 81f4acb..2ec331f 100644 --- a/app/Http/Controllers/CharacteristicsController.php +++ b/app/Http/Controllers/CharacteristicsController.php @@ -3856,6 +3856,21 @@ class CharacteristicsController extends Controller $query->where('approver_type', 'Characteristic'); })->where('machine_id', $machineId)->where('plant_id', $plantId)->get(); + $requestQual = RequestCharacteristic::where('aufnr', $jobNo)->where('item_id', $itemId)->where('model_type', $modelType) + ->whereHas('approver', function ($query) { + $query->where('approver_type', 'Quality'); + })->where('machine_id', $machineId)->where('plant_id', $plantId)->orderBy('id')->get(); + + foreach ($requestQual as $row) { + $workFlowStatus = ($row->approver_status1 == 'Approved' || $row->approver_status2 == 'Approved' || $row->approver_status3 == 'Approved') ? '0' : '1'; + + TempClassCharacteristic::where('aufnr', $jobNo)->where('model_type', $modelType)->where('machine_id', $machineId)->where('plant_id', $plantId) + ->update([ + 'has_work_flow_id' => $workFlowStatus, + 'updated_by' => $userName, + ]); + } + $tempClassChars = TempClassCharacteristic::where('aufnr', $jobNo)->where('machine_id', $machineId)->where('plant_id', $plantId)->get(); if (! $requestChars->isEmpty()) { @@ -3966,6 +3981,21 @@ class CharacteristicsController extends Controller $query->where('approver_type', 'Characteristic'); })->where('machine_id', $machineId)->where('plant_id', $plantId)->get(); + $requestQual = RequestCharacteristic::where('aufnr', $jobNo)->where('item_id', $itemId)->where('model_type', $modelType) + ->whereHas('approver', function ($query) { + $query->where('approver_type', 'Quality'); + })->where('machine_id', $machineId)->where('plant_id', $plantId)->orderBy('id')->get(); + + foreach ($requestQual as $row) { + $workFlowStatus = ($row->approver_status1 == 'Approved' || $row->approver_status2 == 'Approved' || $row->approver_status3 == 'Approved') ? '0' : '1'; + + TempClassCharacteristic::where('aufnr', $jobNo)->where('model_type', $modelType)->where('machine_id', $machineId)->where('plant_id', $plantId) + ->update([ + 'has_work_flow_id' => $workFlowStatus, + 'updated_by' => $userName, + ]); + } + if (! $requestChars->isEmpty()) { $hasCharPending = false; @@ -4980,6 +5010,21 @@ class CharacteristicsController extends Controller $query->where('approver_type', 'Characteristic'); })->where('machine_id', $machineId)->where('plant_id', $plantId)->get(); + $requestQual = RequestCharacteristic::where('aufnr', $jobNo)->where('item_id', $itemId)->where('model_type', $modelType) + ->whereHas('approver', function ($query) { + $query->where('approver_type', 'Quality'); + })->where('machine_id', $machineId)->where('plant_id', $plantId)->orderBy('id')->get(); + + foreach ($requestQual as $row) { + $workFlowStatus = ($row->approver_status1 == 'Approved' || $row->approver_status2 == 'Approved' || $row->approver_status3 == 'Approved') ? '0' : '1'; + + TempClassCharacteristic::where('aufnr', $jobNo)->where('model_type', $modelType)->where('machine_id', $machineId)->where('plant_id', $plantId) + ->update([ + 'has_work_flow_id' => $workFlowStatus, + 'updated_by' => $userName, + ]); + } + $tempClassChars = TempClassCharacteristic::where('aufnr', $jobNo)->where('machine_id', $machineId)->where('plant_id', $plantId)->get(); if (! $requestChars->isEmpty()) { @@ -5084,6 +5129,21 @@ class CharacteristicsController extends Controller $query->where('approver_type', 'Characteristic'); })->where('machine_id', $machineId)->where('plant_id', $plantId)->get(); + $requestQual = RequestCharacteristic::where('aufnr', $jobNo)->where('item_id', $itemId)->where('model_type', $modelType) + ->whereHas('approver', function ($query) { + $query->where('approver_type', 'Quality'); + })->where('machine_id', $machineId)->where('plant_id', $plantId)->orderBy('id')->get(); + + foreach ($requestQual as $row) { + $workFlowStatus = ($row->approver_status1 == 'Approved' || $row->approver_status2 == 'Approved' || $row->approver_status3 == 'Approved') ? '0' : '1'; + + TempClassCharacteristic::where('aufnr', $jobNo)->where('model_type', $modelType)->where('machine_id', $machineId)->where('plant_id', $plantId) + ->update([ + 'has_work_flow_id' => $workFlowStatus, + 'updated_by' => $userName, + ]); + } + if (! $requestChars->isEmpty()) { $hasCharPending = false; @@ -5168,6 +5228,12 @@ class CharacteristicsController extends Controller } else { $workFlowStatus = ($row->approver_status1 == 'Approved' || $row->approver_status2 == 'Approved' || $row->approver_status3 == 'Approved') ? '0' : '1'; + // / TempClassCharacteristic::where('aufnr', $jobNo)->where('model_type', $modelType)->where('machine_id', $machineId)->where('plant_id', $plantId) + // / ->update([ + // / 'has_work_flow_id' => $workFlowStatus, + // / 'updated_by' => $userName, + // / ]); + if ($workFlowStatus == '1') { $workFlowStatus = ($row->approver_status1 == 'Rejected' || $row->approver_status2 == 'Rejected' || $row->approver_status3 == 'Rejected') ? '2' : '1'; } -- 2.49.1