Merge pull request 'Changed logic in sticker order reprint againt serial number fetch production order' (#1271) from ranjith-dev into master
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 22s
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 22s
Reviewed-on: #1271
This commit was merged in pull request #1271.
This commit is contained in:
@@ -79,24 +79,220 @@ class StickerOrderReprint extends Page implements HasForms
|
||||
$set('sticker_options', []);
|
||||
})
|
||||
->required(),
|
||||
|
||||
TextInput::make('production_order')
|
||||
->label('Production Order')
|
||||
->reactive()
|
||||
->required()
|
||||
->afterStateUpdated(function ($state, callable $set, $get) {
|
||||
->readOnly()
|
||||
->required(),
|
||||
// TextInput::make('production_order')
|
||||
// ->label('Production Order')
|
||||
// ->reactive()
|
||||
// ->required()
|
||||
// ->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;
|
||||
// }
|
||||
|
||||
// $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) {
|
||||
// Notification::make()
|
||||
// ->title('Sticker mapping not found')
|
||||
// ->body("No sticker mapping found for this plant and class characteristic.")
|
||||
// ->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)) {
|
||||
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');
|
||||
|
||||
$plantName = Plant::where('id', $plantid)->value('name');
|
||||
$record = ClassCharacteristic::where('plant_id', $plantId)
|
||||
->where('machine_id', $machineId)
|
||||
->where('gernr', $state)
|
||||
->first();
|
||||
|
||||
if (! $record) {
|
||||
Notification::make()
|
||||
->title('Serial Number Not Found')
|
||||
->body("Serial number '{$state}' was not found.")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$plantName = Plant::where('id', $plantId)->value('name');
|
||||
|
||||
$workCenter = Machine::where('id', $machineId)->value('work_center');
|
||||
|
||||
@@ -110,12 +306,12 @@ class StickerOrderReprint extends Page implements HasForms
|
||||
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) {
|
||||
Notification::make()
|
||||
->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()
|
||||
->send();
|
||||
|
||||
@@ -180,24 +376,6 @@ class StickerOrderReprint extends Page implements HasForms
|
||||
|
||||
$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++) {
|
||||
@@ -232,40 +410,49 @@ class StickerOrderReprint extends Page implements HasForms
|
||||
}
|
||||
|
||||
$set('sticker_options', $stickerOptions);
|
||||
$set('production_order', $record->aufnr);
|
||||
}),
|
||||
Select::make('sticker_id')
|
||||
->label('Sticker ID')
|
||||
->options(fn (callable $get) => $get('sticker_options') ?? [])
|
||||
TextInput::make('to_serial_number')
|
||||
->label('To Serial Number')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
|
||||
if (blank($state)) {
|
||||
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()
|
||||
->title('Sticker not found')
|
||||
->body("Sticker ID '{$state}' was not found.")
|
||||
->title('Serial Number Not Found')
|
||||
->body("To Serial Number '{$state}' was not found.")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
$set('to_serial_number', null);
|
||||
|
||||
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),
|
||||
]);
|
||||
@@ -1056,21 +1243,6 @@ class StickerOrderReprint extends Page implements HasForms
|
||||
return;
|
||||
}
|
||||
|
||||
// $matchedMachineId = null;
|
||||
|
||||
// $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) {
|
||||
|
||||
// Notification::make()
|
||||
// ->danger()
|
||||
// ->title('Machine Not Found')
|
||||
// ->body("Machine '{$machineId}' is not mapped for Item Code '{$itemCode}' in sticker mapping master.")
|
||||
// ->send();
|
||||
|
||||
// return;
|
||||
// }
|
||||
|
||||
$itemCharacteristic = ClassCharacteristic::where('plant_id', $plantId)
|
||||
->where('item_id', $pOrderExist->item_id)
|
||||
->where('machine_id', $machineId)
|
||||
|
||||
Reference in New Issue
Block a user