Merge pull request 'Changed logic in sticker order reprint' (#1269) from ranjith-dev into master
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 14s
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 14s
Reviewed-on: #1269
This commit was merged in pull request #1269.
This commit is contained in:
@@ -904,34 +904,90 @@ class StickerOrderReprint extends Page implements HasForms
|
||||
return;
|
||||
}
|
||||
|
||||
$stickerMappingMasterItem = StickerMappingMaster::where('plant_id', $plantId)->first();
|
||||
|
||||
if (!$stickerMappingMasterItem) {
|
||||
$stickerMappingMasterItems = StickerMappingMaster::where('plant_id', $plantId)->get();
|
||||
|
||||
if ($stickerMappingMasterItems->isEmpty()) {
|
||||
Notification::make()
|
||||
->danger()
|
||||
->title('Sticker Mapping Not Found')
|
||||
->body("No sticker mapping found for plant ID '{$plantId}'.")
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$structureIds = $stickerMappingMasterItems
|
||||
->flatMap(function ($mapping) {
|
||||
$ids = [];
|
||||
|
||||
$checkItem = StickerMappingMaster::where('plant_id', $plantId)->where('item_id', $pOrderExist->item_id)->where('sticker_structure1_id', $structure->id)->first();
|
||||
for ($i = 1; $i <= 8; $i++) {
|
||||
$column = "sticker_structure{$i}_id";
|
||||
|
||||
if (!empty($mapping->{$column})) {
|
||||
$ids[] = $mapping->{$column};
|
||||
}
|
||||
}
|
||||
|
||||
return $ids;
|
||||
})
|
||||
->unique()
|
||||
->values();
|
||||
|
||||
$detailsById = StickerStructureDetail::whereIn('id', $structureIds)
|
||||
->get()
|
||||
->keyBy('id');
|
||||
|
||||
$structure = null;
|
||||
$stickerMappingMasterItem = null;
|
||||
|
||||
foreach ($stickerMappingMasterItems as $mapping) {
|
||||
for ($i = 1; $i <= 8; $i++) {
|
||||
$column = "sticker_structure{$i}_id";
|
||||
$structureId = $mapping->{$column};
|
||||
|
||||
if (empty($structureId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$detail = $detailsById->get($structureId);
|
||||
|
||||
if (!$detail) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((string) $detail->sticker_id === (string) $stickerId) {
|
||||
$structure = $detail;
|
||||
$stickerMappingMasterItem = $mapping;
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$structure) {
|
||||
Notification::make()
|
||||
->danger()
|
||||
->title('Sticker Mapping Not Found')
|
||||
->body("No mapping found for sticker ID '{$stickerId}' and plant ID '{$plantId}'.")
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//$checkItem = StickerMappingMaster::where('plant_id', $plantId)->where('item_id', $pOrderExist->item_id)->where('sticker_structure1_id', $structure->id)->first();
|
||||
|
||||
$itemCode = Item::where('id', $pOrderExist->item_id)->value('code');
|
||||
|
||||
$plantCode = Plant::where('id', $plantId)->value('code');
|
||||
|
||||
if (!$checkItem) {
|
||||
// if (!$checkItem) {
|
||||
|
||||
Notification::make()
|
||||
->danger()
|
||||
->title('Item Not Found')
|
||||
->body("Item code '$itemCode' not found in sticker mapping master for selected sticker ID '{$stickerId}'.")
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
// Notification::make()
|
||||
// ->danger()
|
||||
// ->title('Item Not Found')
|
||||
// ->body("Item code '$itemCode' not found in sticker mapping master for selected sticker ID '{$stickerId}'.")
|
||||
// ->send();
|
||||
// return;
|
||||
// }
|
||||
|
||||
$itemCharacteristic1 = ClassCharacteristic::where('plant_id', $plantId)->where('aufnr', $pOrder)->where('item_id', $pOrderExist->item_id)->first();
|
||||
|
||||
@@ -963,21 +1019,60 @@ class StickerOrderReprint extends Page implements HasForms
|
||||
|
||||
$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();
|
||||
for ($i = 1; $i <= 8; $i++) {
|
||||
|
||||
if (!$matchedMachineId) {
|
||||
$structureColumn = "sticker_structure{$i}_id";
|
||||
|
||||
if (
|
||||
(string) $stickerMappingMasterItem->{$structureColumn}
|
||||
== (string) $structure->id
|
||||
) {
|
||||
$machineColumn = "sticker{$i}_machine_id";
|
||||
|
||||
$matchedMachineId = $stickerMappingMasterItem->{$machineColumn};
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($matchedMachineId == null || (string) $matchedMachineId != (string) $machineId)
|
||||
{
|
||||
Notification::make()
|
||||
->danger()
|
||||
->title('Machine Not Found')
|
||||
->body("Machine '{$machineId}' is not mapped for Item Code '{$itemCode}' in sticker mapping master.")
|
||||
->title('Machine Mapping Mismatch')
|
||||
->body("Selected machine '{$machineId}' does not match the machine mapped to the selected sticker.")
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ((string) $matchedMachineId != (string) $machineId) {
|
||||
Notification::make()
|
||||
->danger()
|
||||
->title('Machine Not Found')
|
||||
->body("Machine '{$machineId}' is not mapped for Item Code '{$itemCode}' against sticker '$stickerId' in sticker mapping master.")
|
||||
->send();
|
||||
|
||||
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', $checkItem->item_id)
|
||||
->where('item_id', $pOrderExist->item_id)
|
||||
->where('machine_id', $machineId)
|
||||
->where('aufnr', $pOrder)
|
||||
->first();
|
||||
|
||||
Reference in New Issue
Block a user