From 053d3d61328090df3a69eb3cf96b9974aa972737 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Wed, 7 Oct 2026 15:20:35 +0530 Subject: [PATCH] Removed to serial number logic and added serial number in sticker order reprint --- app/Filament/Pages/StickerOrderReprint.php | 50 ++++++++++++++++++---- 1 file changed, 41 insertions(+), 9 deletions(-) diff --git a/app/Filament/Pages/StickerOrderReprint.php b/app/Filament/Pages/StickerOrderReprint.php index 14a7975b..f3ba48a4 100644 --- a/app/Filament/Pages/StickerOrderReprint.php +++ b/app/Filament/Pages/StickerOrderReprint.php @@ -1054,16 +1054,39 @@ class StickerOrderReprint extends Page implements HasForms return; } - // if($matchedMachineId != $machineId){ + // $updatePrintStatusExist = StickerOrder::where('plant_id', $plantId)->where('sticker_id',$stickerId)->where('production_order', $pOrder)->where('from_serial_number', '<=', $fromSerNo)->where('to_serial_number', '>=', $toSerNo)->first(); + + // if ($updatePrintStatusExist) { // Notification::make() // ->danger() - // ->title('Machine Not Found') - // ->body("Machine '{$machineId}' is not mapped for Item Code '{$itemCode}' in the selected sticker mapping.") + // ->title('Invalid Sticker Reprint') + // ->body("Sticker reprint is invalid not found in sticker order.") // ->send(); // return; // } + $expectedSerialNumbers = range($fromSerNo, $toSerNo); + + $existingSerialNumbers = StickerOrder::where('plant_id', $plantId) + ->where('sticker_id', $stickerId) + ->where('production_order', $pOrder) + ->whereIn('serial_number', $expectedSerialNumbers) + ->pluck('serial_number') + ->toArray(); + + $missingSerialNumbers = array_diff($expectedSerialNumbers,$existingSerialNumbers); + + if (!empty($missingSerialNumbers)) { + Notification::make() + ->danger() + ->title('Invalid Sticker Reprint') + ->body("Missing Serial number ' ($missingSerialNumbers) . ' does not exist in sticker order to atke sticker reprint.") + ->send(); + + return; + } + $itemCharacteristic = ClassCharacteristic::where('plant_id', $plantId) ->where('item_id', $itemCharacteristicId) ->where('machine_id', $matchedMachineId) @@ -1108,13 +1131,22 @@ class StickerOrderReprint extends Page implements HasForms $this->dispatch('open-sticker-pdf',urls: [$pdfUrl]); - $updatePrintStatus = StickerOrder::where('plant_id', $plantId)->where('production_order', $pOrder)->where('from_serial_number', $fromSerNo)->where('to_serial_number', $toSerNo)->where('sticker_id',$stickerId)->first(); + for ($serialNo = $fromSerNo; $serialNo <= $toSerNo; $serialNo++) { - if ($updatePrintStatus) { - $count = (int) $updatePrintStatus->reprint_count ?? 0; - $updatePrintStatus->update([ - 'reprint_count' => $count + 1, - ]); + $updatePrintStatus = StickerOrder::where('plant_id', $plantId) + ->where('sticker_id', $stickerId) + ->where('production_order', $pOrder) + ->where('serial_number', $serialNo) + ->first(); + + if ($updatePrintStatus) { + + $count = (int) ($updatePrintStatus->reprint_count ?? 0); + + $updatePrintStatus->update([ + 'reprint_count' => $count + 1, + ]); + } } Notification::make()