Merge pull request 'Added sticker order logic in bulk sticker print page' (#1027) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled

Reviewed-on: #1027
This commit was merged in pull request #1027.
This commit is contained in:
2026-09-14 10:05:17 +00:00

View File

@@ -8,6 +8,7 @@ use App\Models\Machine;
use App\Models\Plant;
use App\Models\ProductionOrder;
use App\Models\StickerDetail;
use App\Models\StickerOrder;
use App\Models\StickerMappingMaster;
use App\Models\StickerStructureDetail;
use App\Models\StickerValidation;
@@ -83,7 +84,7 @@ class BulkStickerPrinting extends Page implements HasForms
->label('Production Order')
->reactive()
->required()
->afterStateUpdated(function ($state, callable $set, $get) {
->afterStateUpdated(function ($state, callable $set, $get) {
for ($i = 1; $i <= 8; $i++) {
$set("sticker_structure{$i}_id", null);
@@ -105,7 +106,7 @@ class BulkStickerPrinting extends Page implements HasForms
return;
}
$productionOrder = ProductionOrder::where('production_order', $state)
$productionOrder = StickerOrder::where('production_order', $state)
->first();
if (! $productionOrder) {
@@ -155,7 +156,6 @@ class BulkStickerPrinting extends Page implements HasForms
->body("No item characteristic found for item '{$itemCode}'.")
->danger()
->send();
return;
}
@@ -847,7 +847,7 @@ class BulkStickerPrinting extends Page implements HasForms
return;
}
$pOrderEx = ProductionOrder::where('production_order', $pOrder)->first();
$pOrderEx = StickerOrder::where('production_order', $pOrder)->first();
if(!$pOrderEx){
Notification::make()
@@ -858,7 +858,7 @@ class BulkStickerPrinting extends Page implements HasForms
return;
}
$pOrderExist = ProductionOrder::where('plant_id', $plantId)->where('production_order', $pOrder)->first();
$pOrderExist = StickerOrder::where('plant_id', $plantId)->where('production_order', $pOrder)->first();
if(!$pOrderExist){
Notification::make()
@@ -879,16 +879,16 @@ class BulkStickerPrinting extends Page implements HasForms
}
}
// $updatePrintStatusCompleted = ProductionOrder::where('plant_id', $plantId)->where('production_order', $pOrder)->where('from_serial_number', $fromSerNo)->where('to_serial_number', $toSerNo)->where('print_status', 'Printed')->first();
$updatePrintStatusCompleted = StickerOrder::where('plant_id', $plantId)->where('production_order', $pOrder)->where('from_serial_number', $fromSerNo)->where('to_serial_number', $toSerNo)->where('sticker_id', $stickerId)->where('print_status', 'Printed')->first();
// if ($updatePrintStatusCompleted) {
// Notification::make()
// ->danger()
// ->title('Duplicate Sticker')
// ->body("Already Sticker generated successfully for Production Order '$pOrder' and plant '$plantName'.")
// ->send();
// return;
// }
if ($updatePrintStatusCompleted) {
Notification::make()
->danger()
->title('Duplicate Sticker')
->body("Already StickerId '$stickerId' generated successfully for Production Order '$pOrder' and plant '$plantName'.")
->send();
return;
}
$structure = StickerStructureDetail::where('sticker_id',$stickerId)->first();
@@ -1047,10 +1047,24 @@ class BulkStickerPrinting extends Page implements HasForms
$totalStickers = ($toSerNo - $fromSerNo) + 1;
$updatePrintStatus = ProductionOrder::where('plant_id', $plantId)->where('production_order', $pOrder)->where('from_serial_number', $fromSerNo)->where('to_serial_number', $toSerNo)->first();
$item = Item::where('id', $itemCharacteristic->item_id)->where('plant_id', $plantId)->first();
if ($updatePrintStatus) {
$updatePrintStatus = StickerOrder::where('plant_id', $plantId)->where('production_order', $pOrder)->where('from_serial_number', $fromSerNo)->where('to_serial_number', $toSerNo)->first();
if ($updatePrintStatus->sticker_id == '' || $updatePrintStatus->sticker_id == null) {
$updatePrintStatus->update([
'sticker_id' => $stickerId,
'print_status' => 'Printed',
]);
}
else {
StickerOrder::create([
'plant_id' => $plantId,
'item_id' => $item->id,
'production_order' => $pOrder,
'from_serial_number' => $fromSerNo,
'to_serial_number' => $toSerNo,
'sticker_id' => $stickerId,
'print_status' => 'Printed',
]);
}