From 5134470f4b896eb013463e4fb74b4e1590b3039d Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Fri, 18 Sep 2026 17:13:58 +0530 Subject: [PATCH] Added machine name in get api logic of process order --- app/Http/Controllers/PdfController.php | 27 ++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/PdfController.php b/app/Http/Controllers/PdfController.php index a3a8ed2..423062a 100644 --- a/app/Http/Controllers/PdfController.php +++ b/app/Http/Controllers/PdfController.php @@ -535,6 +535,8 @@ class PdfController extends Controller $processOrder = $request->header('process-order'); + $machineName = $request->header('machine-name'); + if (! $plantCode) { return response()->json([ 'status_code' => 'ERROR', @@ -546,6 +548,12 @@ class PdfController extends Controller 'status_description' => 'Process Order cannot be empty!', ], 404); } + elseif (! $machineName) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => 'Machine Name cannot be empty!', + ], 404); + } $plant = Plant::where('code', $plantCode)->first(); $plantId = $plant->id; @@ -566,14 +574,26 @@ class PdfController extends Controller ], 404); } + $proOrdAgPlan = ProcessOrder::where('plant_id', $plantId) + ->where('process_order', $processOrder) + ->first(); + + if (! $proOrdAgPlan) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => 'Process order not found for this plant!', + ], 404); + } + $proOrdAgPlant = ProcessOrder::where('plant_id', $plantId) ->where('process_order', $processOrder) + ->where('machine_name', $machineName) ->first(); if (! $proOrdAgPlant) { return response()->json([ 'status_code' => 'ERROR', - 'status_description' => 'Process order not found for this plant!', + 'status_description' => 'Process order not found for this plant and machine name!', ], 404); } @@ -582,17 +602,20 @@ class PdfController extends Controller $processOrderRecords = ProcessOrder::with('item') ->where('plant_id', $plant->id) ->where('process_order', $processOrder) + ->where('machine_name', $machineName) ->get(); $lastRecord = ProcessOrder::with('item') ->where('plant_id', $plant->id) ->where('process_order', $processOrder) + ->where('machine_name', $machineName) ->orderBy('id', 'desc') ->first(); $lastRecord1 = ProcessOrder::with('item') ->where('plant_id', $plant->id) ->where('process_order', $processOrder) + ->where('machine_name', $machineName) ->where('rework_status', 0) ->orderBy('id', 'desc') ->first(); @@ -604,7 +627,7 @@ class PdfController extends Controller if ($totalReceivedQty == $proOrdAgPlant->order_quantity) { return response()->json([ 'status_code' => 'ERROR', - 'status_description' => "Process order '{$processOrder}' for plant '{$plantCode}' has already reached its order quantity.", + 'status_description' => "Process order '{$processOrder}' for plant '{$plantCode}' and machine name '{$machineName}' has already reached its order quantity.", ], 404); } -- 2.49.1