Changed logic in bulk sticker printing page
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 13s
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 13s
This commit is contained in:
@@ -94,157 +94,167 @@ class BulkStickerPrinting extends Page implements HasForms
|
||||
TextInput::make('production_order')
|
||||
->label('Production Order')
|
||||
->reactive()
|
||||
->readOnly(),
|
||||
// ->afterStateUpdated(function ($state, callable $set, $get) {
|
||||
->afterStateUpdated(function ($state, callable $set, $get) {
|
||||
|
||||
// for ($i = 1; $i <= 8; $i++) {
|
||||
// $set("sticker_structure{$i}_id", null);
|
||||
// }
|
||||
for ($i = 1; $i <= 8; $i++) {
|
||||
$set("sticker_structure{$i}_id", null);
|
||||
}
|
||||
|
||||
// if (blank($state)) {
|
||||
// return;
|
||||
// }
|
||||
if (blank($state)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// $plantid = $get('plant_id');
|
||||
// $machineId = $get('machine_id');
|
||||
$plantid = $get('plant_id');
|
||||
$machineId = $get('machine_id');
|
||||
|
||||
// $plantName = Plant::where('id', $plantid)->value('name');
|
||||
$plantName = Plant::where('id', $plantid)->value('name');
|
||||
|
||||
// $workCenter = Machine::where('id', $machineId)->value('work_center');
|
||||
$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();
|
||||
if (empty($machineId)) {
|
||||
Notification::make()
|
||||
->title('Work Center not selected')
|
||||
->body('Please select a Work Center first.')
|
||||
->warning()
|
||||
->send();
|
||||
|
||||
// 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('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();
|
||||
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;
|
||||
// }
|
||||
return;
|
||||
}
|
||||
|
||||
// $plantId = $productionOrder->plant_id;
|
||||
// $itemId = $productionOrder->item_id;
|
||||
$plantId = $productionOrder->plant_id;
|
||||
$itemId = $productionOrder->item_id;
|
||||
|
||||
// $item = Item::find($itemId);
|
||||
$item = Item::find($itemId);
|
||||
|
||||
// if (! $item) {
|
||||
// Notification::make()
|
||||
// ->title('Item not found')
|
||||
// ->body("Item code '{$itemId}' was not found in item master.")
|
||||
// ->danger()
|
||||
// ->send();
|
||||
if (! $item) {
|
||||
Notification::make()
|
||||
->title('Item not found')
|
||||
->body("Item code '{$itemId}' was not found in item master.")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
// return;
|
||||
// }
|
||||
return;
|
||||
}
|
||||
|
||||
// $itemCode = $item->code;
|
||||
$itemCode = $item->code;
|
||||
|
||||
// $item = Item::where('code', $itemCode)->where('plant_id', $plantId)->first();
|
||||
$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();
|
||||
if (! $item) {
|
||||
Notification::make()
|
||||
->title('Item not found')
|
||||
->body("Item '{$itemCode}' was not found for the selected plant.")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
// return;
|
||||
// }
|
||||
return;
|
||||
}
|
||||
|
||||
// $itemCharacteristic = ClassCharacteristic::where('plant_id', $plantId)->where('item_id', $item->id)->first();
|
||||
$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;
|
||||
// }
|
||||
if (! $itemCharacteristic) {
|
||||
Notification::make()
|
||||
->title('Class characteristic not found')
|
||||
->body("No class characteristic found for item '{$itemCode}'.")
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
// $itemCharacteristicId = $itemCharacteristic->id;
|
||||
$itemCharacteristicId = $itemCharacteristic->id;
|
||||
|
||||
// $stickerMappings = StickerMappingMaster::where('plant_id', $plantId)
|
||||
// ->where('item_id', $item->id)
|
||||
// ->get();
|
||||
$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();
|
||||
if ($stickerMappings->isEmpty()) {
|
||||
Notification::make()
|
||||
->title('Sticker mapping not found')
|
||||
->body("No sticker mapping found for item '$itemCode' and plant '$plantName'.")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
// return;
|
||||
// }
|
||||
return;
|
||||
}
|
||||
|
||||
// $stickerOptions = [];
|
||||
$stickerOptions = [];
|
||||
|
||||
// // foreach ($stickerMappings as $stickerMapping) {
|
||||
// foreach ($stickerMappings as $stickerMapping) {
|
||||
|
||||
// // for ($i = 1; $i <= 8; $i++) {
|
||||
// for ($i = 1; $i <= 8; $i++) {
|
||||
|
||||
// // $stickerStructureId = $stickerMapping->{"sticker_structure{$i}_id"};
|
||||
// $stickerStructureId = $stickerMapping->{"sticker_structure{$i}_id"};
|
||||
|
||||
// // if ($stickerStructureId) {
|
||||
// if ($stickerStructureId) {
|
||||
|
||||
// // $detail = StickerStructureDetail::where('id', $stickerStructureId)
|
||||
// // ->first();
|
||||
// $detail = StickerStructureDetail::where('id', $stickerStructureId)
|
||||
// ->first();
|
||||
|
||||
// // if ($detail && $detail->sticker_id) {
|
||||
// // $stickerOptions[$detail->sticker_id] = $detail->sticker_id;
|
||||
// // }
|
||||
// // }
|
||||
// // }
|
||||
// // }
|
||||
// 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++) {
|
||||
|
||||
// $machineColumn = "sticker{$i}_machine_id";
|
||||
$machineColumn = "sticker{$i}_machine_id";
|
||||
|
||||
// $stickerMachineId = $stickerMapping->$machineColumn;
|
||||
$stickerMachineId = $stickerMapping->$machineColumn;
|
||||
|
||||
// if ((string) $stickerMachineId != (string) $machineId) {
|
||||
// continue;
|
||||
// }
|
||||
if ((string) $stickerMachineId != (string) $machineId) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// $structureColumn = "sticker_structure{$i}_id";
|
||||
$structureColumn = "sticker_structure{$i}_id";
|
||||
|
||||
// $stickerStructureId = $stickerMapping->$structureColumn;
|
||||
$stickerStructureId = $stickerMapping->$structureColumn;
|
||||
|
||||
// if (empty($stickerStructureId)) {
|
||||
// continue;
|
||||
// }
|
||||
if (empty($stickerStructureId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// $detail = StickerStructureDetail::find($stickerStructureId);
|
||||
$detail = StickerStructureDetail::find($stickerStructureId);
|
||||
|
||||
// if ($detail && $detail->sticker_id) {
|
||||
if ($detail && $detail->sticker_id) {
|
||||
|
||||
// $stickerOptions[$detail->sticker_id] =
|
||||
// $detail->sticker_id;
|
||||
// }
|
||||
$stickerOptions[$detail->sticker_id] =
|
||||
$detail->sticker_id;
|
||||
}
|
||||
|
||||
// $set("sticker_structure{$i}_id", $stickerStructureId);
|
||||
$set("sticker_structure{$i}_id", $stickerStructureId);
|
||||
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
// $set('sticker_options', $stickerOptions);
|
||||
// }),
|
||||
$set('sticker_options', $stickerOptions);
|
||||
|
||||
$serialNumbers = ClassCharacteristic::query()
|
||||
->where('plant_id', $plantId)
|
||||
->where('aufnr', $state)
|
||||
->pluck('gernr')
|
||||
->filter()
|
||||
->values()
|
||||
->all();
|
||||
|
||||
$this->dispatch('load-serial-numbers',serialNumbers: $serialNumbers);
|
||||
|
||||
}),
|
||||
|
||||
Select::make('sticker_id')
|
||||
->label('Sticker ID')
|
||||
|
||||
Reference in New Issue
Block a user