Changed logic in bulk sticker printing page against serial number its fetch job order
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 13s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 18s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 14s
Laravel Pint / pint (pull_request) Successful in 4m37s
Laravel Larastan / larastan (pull_request) Failing after 5m9s
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 13s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 18s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 14s
Laravel Pint / pint (pull_request) Successful in 4m37s
Laravel Larastan / larastan (pull_request) Failing after 5m9s
This commit is contained in:
@@ -85,21 +85,212 @@ class BulkStickerPrinting extends Page implements HasForms
|
|||||||
TextInput::make('production_order')
|
TextInput::make('production_order')
|
||||||
->label('Production Order')
|
->label('Production Order')
|
||||||
->reactive()
|
->reactive()
|
||||||
->required()
|
->readOnly()
|
||||||
->afterStateUpdated(function ($state, callable $set, $get) {
|
->required(),
|
||||||
|
// ->afterStateUpdated(function ($state, callable $set, $get) {
|
||||||
|
|
||||||
for ($i = 1; $i <= 8; $i++) {
|
// for ($i = 1; $i <= 8; $i++) {
|
||||||
$set("sticker_structure{$i}_id", null);
|
// $set("sticker_structure{$i}_id", null);
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
// if (blank($state)) {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// $plantid = $get('plant_id');
|
||||||
|
// $machineId = $get('machine_id');
|
||||||
|
|
||||||
|
// $plantName = Plant::where('id', $plantid)->value('name');
|
||||||
|
|
||||||
|
// $workCenter = Machine::where('id', $machineId)->value('work_center');
|
||||||
|
|
||||||
|
// if (empty($machineId)) {
|
||||||
|
// Notification::make()
|
||||||
|
// ->title('Work Center not selected')
|
||||||
|
// ->body('Please select a Work Center first.')
|
||||||
|
// ->warning()
|
||||||
|
// ->send();
|
||||||
|
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// $productionOrder = ClassCharacteristic::where('plant_id', $plantid)->where('machine_id', $machineId)->where('aufnr', $state)->first();
|
||||||
|
|
||||||
|
// if (! $productionOrder) {
|
||||||
|
// Notification::make()
|
||||||
|
// ->title('Production Order not found')
|
||||||
|
// ->body("Production Order '{$state}' was not found against machine '$workCenter' and plant '$plantName'.")
|
||||||
|
// ->danger()
|
||||||
|
// ->send();
|
||||||
|
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// $plantId = $productionOrder->plant_id;
|
||||||
|
// $itemId = $productionOrder->item_id;
|
||||||
|
|
||||||
|
// $item = Item::find($itemId);
|
||||||
|
|
||||||
|
// if (! $item) {
|
||||||
|
// Notification::make()
|
||||||
|
// ->title('Item not found')
|
||||||
|
// ->body("Item code '{$itemId}' was not found in item master.")
|
||||||
|
// ->danger()
|
||||||
|
// ->send();
|
||||||
|
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// $itemCode = $item->code;
|
||||||
|
|
||||||
|
// $item = Item::where('code', $itemCode)->where('plant_id', $plantId)->first();
|
||||||
|
|
||||||
|
// if (! $item) {
|
||||||
|
// Notification::make()
|
||||||
|
// ->title('Item not found')
|
||||||
|
// ->body("Item '{$itemCode}' was not found for the selected plant.")
|
||||||
|
// ->danger()
|
||||||
|
// ->send();
|
||||||
|
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// $itemCharacteristic = ClassCharacteristic::where('plant_id', $plantId)->where('item_id', $item->id)->first();
|
||||||
|
|
||||||
|
// if (! $itemCharacteristic) {
|
||||||
|
// Notification::make()
|
||||||
|
// ->title('Class characteristic not found')
|
||||||
|
// ->body("No class characteristic found for item '{$itemCode}'.")
|
||||||
|
// ->danger()
|
||||||
|
// ->send();
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// $itemCharacteristicId = $itemCharacteristic->id;
|
||||||
|
|
||||||
|
// $stickerMappings = StickerMappingMaster::where('plant_id', $plantId)
|
||||||
|
// ->where('item_id', $item->id)
|
||||||
|
// ->get();
|
||||||
|
|
||||||
|
// if ($stickerMappings->isEmpty()) {
|
||||||
|
// Notification::make()
|
||||||
|
// ->title('Sticker mapping not found')
|
||||||
|
// ->body("No sticker mapping found for item '$itemCode' and plant '$plantName'.")
|
||||||
|
// ->danger()
|
||||||
|
// ->send();
|
||||||
|
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// $stickerOptions = [];
|
||||||
|
|
||||||
|
// // foreach ($stickerMappings as $stickerMapping) {
|
||||||
|
|
||||||
|
// // for ($i = 1; $i <= 8; $i++) {
|
||||||
|
|
||||||
|
// // $stickerStructureId = $stickerMapping->{"sticker_structure{$i}_id"};
|
||||||
|
|
||||||
|
// // if ($stickerStructureId) {
|
||||||
|
|
||||||
|
// // $detail = StickerStructureDetail::where('id', $stickerStructureId)
|
||||||
|
// // ->first();
|
||||||
|
|
||||||
|
// // if ($detail && $detail->sticker_id) {
|
||||||
|
// // $stickerOptions[$detail->sticker_id] = $detail->sticker_id;
|
||||||
|
// // }
|
||||||
|
// // }
|
||||||
|
// // }
|
||||||
|
// // }
|
||||||
|
|
||||||
|
// foreach ($stickerMappings as $stickerMapping) {
|
||||||
|
|
||||||
|
// for ($i = 1; $i <= 8; $i++) {
|
||||||
|
|
||||||
|
// $machineColumn = "sticker{$i}_machine_id";
|
||||||
|
|
||||||
|
// $stickerMachineId = $stickerMapping->$machineColumn;
|
||||||
|
|
||||||
|
// if ((string) $stickerMachineId != (string) $machineId) {
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// $structureColumn = "sticker_structure{$i}_id";
|
||||||
|
|
||||||
|
// $stickerStructureId = $stickerMapping->$structureColumn;
|
||||||
|
|
||||||
|
// if (empty($stickerStructureId)) {
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// $detail = StickerStructureDetail::find($stickerStructureId);
|
||||||
|
|
||||||
|
// if ($detail && $detail->sticker_id) {
|
||||||
|
|
||||||
|
// $stickerOptions[$detail->sticker_id] =
|
||||||
|
// $detail->sticker_id;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// $set("sticker_structure{$i}_id", $stickerStructureId);
|
||||||
|
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// $set('sticker_options', $stickerOptions);
|
||||||
|
// }),
|
||||||
|
|
||||||
|
Select::make('sticker_id')
|
||||||
|
->label('Sticker ID')
|
||||||
|
->options(fn (callable $get) => $get('sticker_options') ?? [])
|
||||||
|
->reactive()
|
||||||
|
->afterStateUpdated(function ($state, callable $set) {
|
||||||
|
|
||||||
if (blank($state)) {
|
if (blank($state)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$plantid = $get('plant_id');
|
$sticker = StickerStructureDetail::where('sticker_id', $state)->first();
|
||||||
|
|
||||||
|
if (! $sticker) {
|
||||||
|
Notification::make()
|
||||||
|
->title('Sticker not found')
|
||||||
|
->body("Sticker ID '{$state}' was not found.")
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$set('sticker_code', $state);
|
||||||
|
|
||||||
|
}),
|
||||||
|
Hidden::make('sticker_options')
|
||||||
|
->default([]),
|
||||||
|
TextInput::make('from_serial_number')
|
||||||
|
->label('From Serial Number')
|
||||||
|
->reactive()
|
||||||
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
if (blank($state)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$plantId = $get('plant_id');
|
||||||
$machineId = $get('machine_id');
|
$machineId = $get('machine_id');
|
||||||
|
|
||||||
$plantName = Plant::where('id', $plantid)->value('name');
|
$record = ClassCharacteristic::where('plant_id', $plantId)->where('machine_id', $machineId)->where('gernr', $state)->first();
|
||||||
|
|
||||||
|
if (! $record) {
|
||||||
|
$plantName = Plant::find($plantId)?->name;
|
||||||
|
$machineName = Machine::find($machineId)?->work_center;
|
||||||
|
Notification::make()
|
||||||
|
->title('Serial Number Not Found')
|
||||||
|
->body("Serial number '{$state}' was not found against work center '$machineName' and plant '$plantName'.")
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$plantName = Plant::where('id', $plantId)->value('name');
|
||||||
|
|
||||||
$workCenter = Machine::where('id', $machineId)->value('work_center');
|
$workCenter = Machine::where('id', $machineId)->value('work_center');
|
||||||
|
|
||||||
@@ -113,12 +304,12 @@ class BulkStickerPrinting extends Page implements HasForms
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$productionOrder = ClassCharacteristic::where('plant_id', $plantid)->where('machine_id', $machineId)->where('aufnr', $state)->first();
|
$productionOrder = ClassCharacteristic::where('plant_id', $plantId)->where('machine_id', $machineId)->where('gernr', $state)->first();
|
||||||
|
|
||||||
if (! $productionOrder) {
|
if (! $productionOrder) {
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Production Order not found')
|
->title('Production Order not found')
|
||||||
->body("Production Order '{$state}' was not found against machine '$workCenter' and plant '$plantName'.")
|
->body("Production Order '{$state}' was not found against machine '$workCenter', Serial Number '$state' and plant '$plantName'.")
|
||||||
->danger()
|
->danger()
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
@@ -165,16 +356,16 @@ class BulkStickerPrinting extends Page implements HasForms
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$itemCharacteristicId = $itemCharacteristic->id;
|
// $itemCharacteristicId = $itemCharacteristic->id;
|
||||||
|
|
||||||
$stickerMappings = StickerMappingMaster::where('plant_id', $plantId)
|
$stickerMappings = StickerMappingMaster::where('plant_id', $plantId)
|
||||||
->where('item_id', $item->id)
|
->where('item_id', $item->id)
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
if ($stickerMappings->isEmpty()) {
|
if (! $stickerMappings) {
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Sticker mapping not found')
|
->title('Sticker mapping not found')
|
||||||
->body("No sticker mapping found for item '$itemCode' and plant '$plantName'.")
|
->body("No sticker mapping found for this plant and class characteristic.")
|
||||||
->danger()
|
->danger()
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
@@ -183,24 +374,6 @@ class BulkStickerPrinting extends Page implements HasForms
|
|||||||
|
|
||||||
$stickerOptions = [];
|
$stickerOptions = [];
|
||||||
|
|
||||||
// foreach ($stickerMappings as $stickerMapping) {
|
|
||||||
|
|
||||||
// for ($i = 1; $i <= 8; $i++) {
|
|
||||||
|
|
||||||
// $stickerStructureId = $stickerMapping->{"sticker_structure{$i}_id"};
|
|
||||||
|
|
||||||
// if ($stickerStructureId) {
|
|
||||||
|
|
||||||
// $detail = StickerStructureDetail::where('id', $stickerStructureId)
|
|
||||||
// ->first();
|
|
||||||
|
|
||||||
// if ($detail && $detail->sticker_id) {
|
|
||||||
// $stickerOptions[$detail->sticker_id] = $detail->sticker_id;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
foreach ($stickerMappings as $stickerMapping) {
|
foreach ($stickerMappings as $stickerMapping) {
|
||||||
|
|
||||||
for ($i = 1; $i <= 8; $i++) {
|
for ($i = 1; $i <= 8; $i++) {
|
||||||
@@ -235,40 +408,48 @@ class BulkStickerPrinting extends Page implements HasForms
|
|||||||
}
|
}
|
||||||
|
|
||||||
$set('sticker_options', $stickerOptions);
|
$set('sticker_options', $stickerOptions);
|
||||||
|
$set('production_order', $record->aufnr);
|
||||||
}),
|
}),
|
||||||
Select::make('sticker_id')
|
TextInput::make('to_serial_number')
|
||||||
->label('Sticker ID')
|
->label('To Serial Number')
|
||||||
->options(fn (callable $get) => $get('sticker_options') ?? [])
|
|
||||||
->reactive()
|
->reactive()
|
||||||
->afterStateUpdated(function ($state, callable $set) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
|
||||||
if (blank($state)) {
|
if (blank($state)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sticker = StickerStructureDetail::where('sticker_id', $state)->first();
|
$productionOrder = $get('production_order');
|
||||||
|
$plantId = $get('plant_id');
|
||||||
|
$machineId = $get('machine_id');
|
||||||
|
|
||||||
if (! $sticker) {
|
$toSerialRecord = ClassCharacteristic::where('plant_id', $plantId)->where('machine_id', $machineId)->where('gernr', $state)->first();
|
||||||
|
|
||||||
|
if (! $toSerialRecord) {
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Sticker not found')
|
->title('Serial Number Not Found')
|
||||||
->body("Sticker ID '{$state}' was not found.")
|
->body("To Serial Number '{$state}' was not found.")
|
||||||
->danger()
|
->danger()
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
|
$set('to_serial_number', null);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$set('sticker_code', $state);
|
if ((string) $toSerialRecord->aufnr != (string) $productionOrder) {
|
||||||
|
Notification::make()
|
||||||
|
->title('Production Order Mismatch')
|
||||||
|
->body("To Serial Number '{$state}' does not belong to Production Order '{$productionOrder}'.")
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
|
||||||
|
$set('to_serial_number', null);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
}),
|
}),
|
||||||
Hidden::make('sticker_options')
|
|
||||||
->default([]),
|
|
||||||
TextInput::make('from_serial_number')
|
|
||||||
->label('From Serial Number')
|
|
||||||
->reactive(),
|
|
||||||
TextInput::make('to_serial_number')
|
|
||||||
->label('To Serial Number')
|
|
||||||
->reactive(),
|
|
||||||
])
|
])
|
||||||
->columns(6),
|
->columns(6),
|
||||||
]);
|
]);
|
||||||
|
|||||||
Reference in New Issue
Block a user