Merge pull request 'Changed logic for slowness downloading pdf in bulk sticker pdf' (#1264) from ranjith-dev into master
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 30s
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 30s
Reviewed-on: #1264
This commit was merged in pull request #1264.
This commit is contained in:
@@ -914,7 +914,7 @@ class BulkStickerPrinting extends Page implements HasForms
|
|||||||
Notification::make()
|
Notification::make()
|
||||||
->danger()
|
->danger()
|
||||||
->title('Duplicate Sticker')
|
->title('Duplicate Sticker')
|
||||||
->body("Serial Number '$fromSerNo' or '$toSerNo' already exists in a generated sticker for Production Order '$pOrder' and plant '$plantName'.")
|
->body("Serial Number '$fromSerNo' or '$toSerNo' already exists in a generated sticker '$stickerId' for Production Order '$pOrder' and plant '$plantName'.")
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -932,51 +932,118 @@ class BulkStickerPrinting extends Page implements HasForms
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$stickerMappingMasterItems = StickerMappingMaster::where('plant_id', $plantId)->get();
|
// $stickerMappingMasterItems = StickerMappingMaster::where('plant_id', $plantId)->get();
|
||||||
|
|
||||||
if (!$stickerMappingMasterItems) {
|
// if (!$stickerMappingMasterItems) {
|
||||||
|
|
||||||
|
// Notification::make()
|
||||||
|
// ->danger()
|
||||||
|
// ->title('Sticker Mapping Not Found')
|
||||||
|
// ->body("No sticker mapping found for plant ID '{$plantId}'.")
|
||||||
|
// ->send();
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// foreach ($stickerMappingMasterItems as $mapping) {
|
||||||
|
|
||||||
|
// for ($i = 1; $i <= 8; $i++) {
|
||||||
|
|
||||||
|
// $column = "sticker_structure{$i}_id";
|
||||||
|
|
||||||
|
// $structureId = $mapping->{$column};
|
||||||
|
|
||||||
|
// if (empty($structureId)) {
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// $detail = StickerStructureDetail::find($structureId);
|
||||||
|
|
||||||
|
// if (!$detail) {
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if ((string) $detail->sticker_id === (string) $stickerId) {
|
||||||
|
|
||||||
|
// $structure = $detail;
|
||||||
|
|
||||||
|
// $stickerMappingMasterItem = $mapping;
|
||||||
|
|
||||||
|
// break 2;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
//.New Logic
|
||||||
|
|
||||||
|
$stickerMappingMasterItems = StickerMappingMaster::where('plant_id', $plantId)->get();
|
||||||
|
|
||||||
|
if ($stickerMappingMasterItems->isEmpty()) {
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->danger()
|
->danger()
|
||||||
->title('Sticker Mapping Not Found')
|
->title('Sticker Mapping Not Found')
|
||||||
->body("No sticker mapping found for plant ID '{$plantId}'.")
|
->body("No sticker mapping found for plant ID '{$plantId}'.")
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$structureIds = $stickerMappingMasterItems
|
||||||
|
->flatMap(function ($mapping) {
|
||||||
|
$ids = [];
|
||||||
|
|
||||||
|
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) {
|
foreach ($stickerMappingMasterItems as $mapping) {
|
||||||
|
|
||||||
// Check sticker_structure1_id to sticker_structure8_id
|
|
||||||
for ($i = 1; $i <= 8; $i++) {
|
for ($i = 1; $i <= 8; $i++) {
|
||||||
|
|
||||||
$column = "sticker_structure{$i}_id";
|
$column = "sticker_structure{$i}_id";
|
||||||
|
|
||||||
$structureId = $mapping->{$column};
|
$structureId = $mapping->{$column};
|
||||||
|
|
||||||
if (empty($structureId)) {
|
if (empty($structureId)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find structure detail
|
$detail = $detailsById->get($structureId);
|
||||||
$detail = StickerStructureDetail::find($structureId);
|
|
||||||
|
|
||||||
if (!$detail) {
|
if (!$detail) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check whether this structure belongs to selected sticker
|
|
||||||
if ((string) $detail->sticker_id === (string) $stickerId) {
|
if ((string) $detail->sticker_id === (string) $stickerId) {
|
||||||
|
|
||||||
$structure = $detail;
|
$structure = $detail;
|
||||||
|
|
||||||
// Keep the mapping record also
|
|
||||||
$stickerMappingMasterItem = $mapping;
|
$stickerMappingMasterItem = $mapping;
|
||||||
|
|
||||||
break 2;
|
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();
|
// $checkItem = StickerMappingMaster::where('plant_id', $plantId)->where('item_id', $pOrderExist->item_id)->where('sticker_structure1_id', $structure->id)->first();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user