From 2e1291820397a588d3b53dd1f4711896edc6592e Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Fri, 16 Oct 2026 11:29:08 +0530 Subject: [PATCH] Changed logic in bulk sticker prinitng page --- app/Filament/Pages/BulkStickerPrinting.php | 86 +++++++++++----------- 1 file changed, 44 insertions(+), 42 deletions(-) diff --git a/app/Filament/Pages/BulkStickerPrinting.php b/app/Filament/Pages/BulkStickerPrinting.php index a0ba5bb5..0bab3964 100644 --- a/app/Filament/Pages/BulkStickerPrinting.php +++ b/app/Filament/Pages/BulkStickerPrinting.php @@ -932,9 +932,9 @@ class BulkStickerPrinting extends Page implements HasForms return; } - $stickerMappingMasterItem = StickerMappingMaster::where('plant_id', $plantId)->first(); + $stickerMappingMasterItems = StickerMappingMaster::where('plant_id', $plantId)->get(); - if (!$stickerMappingMasterItem) { + if (!$stickerMappingMasterItems) { Notification::make() ->danger() @@ -944,55 +944,55 @@ class BulkStickerPrinting extends Page implements HasForms return; } - // foreach ($stickerMappingMasterItems as $mapping) { + foreach ($stickerMappingMasterItems as $mapping) { - // // Check sticker_structure1_id to sticker_structure8_id - // for ($i = 1; $i <= 8; $i++) { + // Check sticker_structure1_id to sticker_structure8_id + for ($i = 1; $i <= 8; $i++) { - // $column = "sticker_structure{$i}_id"; + $column = "sticker_structure{$i}_id"; - // $structureId = $mapping->{$column}; + $structureId = $mapping->{$column}; - // if (empty($structureId)) { - // continue; - // } + if (empty($structureId)) { + continue; + } - // // Find structure detail - // $detail = StickerStructureDetail::find($structureId); + // Find structure detail + $detail = StickerStructureDetail::find($structureId); - // if (!$detail) { - // continue; - // } + if (!$detail) { + continue; + } - // // Check whether this structure belongs to selected sticker - // if ((string) $detail->sticker_id === (string) $stickerId) { + // Check whether this structure belongs to selected sticker + if ((string) $detail->sticker_id === (string) $stickerId) { - // $structure = $detail; + $structure = $detail; - // // Keep the mapping record also - // $stickerMappingMasterItem = $mapping; + // Keep the mapping record also + $stickerMappingMasterItem = $mapping; - // break 2; - // } - // } - // } + break 2; + } + } + } - $checkItem = StickerMappingMaster::where('plant_id', $plantId)->where('item_id', $pOrderExist->item_id)->where('sticker_structure1_id', $structure->id)->first(); + // $checkItem = StickerMappingMaster::where('plant_id', $plantId)->where('item_id', $pOrderExist->item_id)->where('sticker_structure1_id', $structure->id)->first(); $itemCode = Item::where('id', $pOrderExist->item_id)->value('code'); $plantCode = Plant::where('id', $plantId)->value('code'); - if (!$checkItem) { + // if (!$checkItem) { - Notification::make() - ->danger() - ->title('Item Not Found') - ->body("Item code '$itemCode' not found in sticker mapping master for selected sticker ID '{$stickerId}'.") - ->send(); - return; - } + // Notification::make() + // ->danger() + // ->title('Item Not Found') + // ->body("Item code '$itemCode' not found in sticker mapping master for selected sticker ID '{$stickerId}'.") + // ->send(); + // return; + // } $itemCharacteristic1 = ClassCharacteristic::where('plant_id', $plantId)->where('aufnr', $pOrder)->where('item_id', $pOrderExist->item_id)->first(); @@ -1010,17 +1010,19 @@ class BulkStickerPrinting extends Page implements HasForms $matchedMachineId = null; - // for ($i = 1; $i <= 8; $i++) { + for ($i = 1; $i <= 8; $i++) { - // $machineColumn = "sticker{$i}_machine_id"; + $machineColumn = "sticker{$i}_machine_id"; - // if ((string) $stickerMappingMasterItem->{$machineColumn} == (string) $machineId) { + if ((string) $stickerMappingMasterItem->{$machineColumn} == (string) $machineId) { + + $matchedMachineId = $stickerMappingMasterItem->{$machineColumn}; + + break; + } + } - // $matchedMachineId = $stickerMappingMasterItem->{$machineColumn}; - // break; - // } - // } $matchedMachineId = StickerMappingMaster::where('plant_id', $plantId)->where('item_id', $pOrderExist->item_id)->where('sticker_structure1_id', $structure->id)->where('sticker1_machine_id', $machineId)->first(); @@ -1036,7 +1038,7 @@ class BulkStickerPrinting extends Page implements HasForms } $itemCharacteristic = ClassCharacteristic::where('plant_id', $plantId) - ->where('item_id', $checkItem->item_id) + ->where('item_id', $pOrderExist->item_id) ->where('machine_id', $machineId) ->where('aufnr', $pOrder) ->first(); @@ -1102,7 +1104,7 @@ class BulkStickerPrinting extends Page implements HasForms $totalStickers = ($toSerNo - $fromSerNo) + 1; - $item = Item::where('id', $checkItem->item_id)->where('plant_id', $plantId)->first(); + $item = Item::where('id', $pOrderExist->item_id)->where('plant_id', $plantId)->first(); $from = (int) $fromSerNo; $to = (int) $toSerNo;