diff --git a/app/Filament/Pages/BulkStickerPrinting.php b/app/Filament/Pages/BulkStickerPrinting.php index daae2a46..8d2a17fe 100644 --- a/app/Filament/Pages/BulkStickerPrinting.php +++ b/app/Filament/Pages/BulkStickerPrinting.php @@ -1077,25 +1077,54 @@ class BulkStickerPrinting extends Page implements HasForms $matchedMachineId = null; + // for ($i = 1; $i <= 8; $i++) { + + // $structureColumn = "sticker_structure{$i}_id"; + + // if ( + // (string) $stickerMappingMasterItem->{$structureColumn} + // == (string) $structure->id + // ) { + // $machineColumn = "sticker{$i}_machine_id"; + + // $matchedMachineId = $stickerMappingMasterItem->{$machineColumn}; + + // break; + // } + // } + + // if ($matchedMachineId == null || (string) $matchedMachineId != (string) $machineId) + // { + // Notification::make() + // ->danger() + // ->title('Machine Mapping Mismatch') + // ->body("Selected machine '{$machineId}' does not match the machine mapped to the selected sticker.") + // ->send(); + + // return; + // } + + //..New + for ($i = 1; $i <= 8; $i++) { $structureColumn = "sticker_structure{$i}_id"; + $machineColumn = "sticker{$i}_machine_id"; + + $mappedStructureId = $stickerMappingMasterItem->{$structureColumn} ?? null; if ( - (string) $stickerMappingMasterItem->{$structureColumn} - == (string) $structure->id + $mappedStructureId !== null && + (string) $mappedStructureId === (string) $structure->id ) { - $machineColumn = "sticker{$i}_machine_id"; - - $matchedMachineId = $stickerMappingMasterItem->{$machineColumn}; - + $matchedMachineId = $stickerMappingMasterItem->{$machineColumn} ?? null; break; } } if ( - $matchedMachineId == null || - (string) $matchedMachineId != (string) $machineId + $matchedMachineId === null || + trim((string) $matchedMachineId) !== trim((string) $machineId) ) { Notification::make() ->danger() @@ -1106,25 +1135,11 @@ class BulkStickerPrinting extends Page implements HasForms return; } - if ((string) $matchedMachineId != (string) $machineId) { - Notification::make() - ->danger() - ->title('Machine Not Found') - ->body("Machine '{$machineId}' is not mapped for Item Code '{$itemCode}' against sticker '$stickerId' in sticker mapping master.") - ->send(); - - return; - } - - - // $matchedMachineId = StickerMappingMaster::where('plant_id', $plantId)->where('item_id', $pOrderExist->item_id)->where('sticker_structure1_id', $structure->id)->where('sticker1_machine_id', $machineId)->first(); - - // if (!$matchedMachineId) { - + // if ((string) $matchedMachineId != (string) $machineId) { // Notification::make() // ->danger() // ->title('Machine Not Found') - // ->body("Machine '{$machineId}' is not mapped for Item Code '{$itemCode}' in sticker mapping master.") + // ->body("Machine '{$machineId}' is not mapped for Item Code '{$itemCode}' against sticker '$stickerId' in sticker mapping master.") // ->send(); // return;