Removed to serial number logic and added serial number in sticker order reprint #1200
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user