changed logic in sticker order reprint gaint class characteristics
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 16s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 12s
Laravel Larastan / larastan (pull_request) Failing after 40s
Laravel Pint / pint (pull_request) Failing after 33s

This commit is contained in:
dhanabalan
2026-09-21 18:20:37 +05:30
parent 2950008d71
commit a4092b47b5

View File

@@ -10,6 +10,7 @@ use App\Models\Plant;
use App\Models\ProductionOrder;
use App\Models\StickerDetail;
use App\Models\StickerOrder;
use App\Models\ClassCharacteristic;
use App\Models\StickerMappingMaster;
use App\Models\StickerStructureDetail;
use App\Models\StickerValidation;
@@ -92,8 +93,13 @@ class StickerOrderReprint extends Page implements HasForms
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')
@@ -104,13 +110,12 @@ class StickerOrderReprint extends Page implements HasForms
return;
}
$productionOrder = StickerOrder::where('production_order', $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.")
->body("Production Order '{$state}' was not found against machine '$workCenter' and plant '$plantName'.")
->danger()
->send();
@@ -125,7 +130,7 @@ class StickerOrderReprint extends Page implements HasForms
if (! $item) {
Notification::make()
->title('Item not found')
->body("Item ID '{$itemId}' was not found in item master.")
->body("Item code '{$itemId}' was not found in item master.")
->danger()
->send();
@@ -146,27 +151,27 @@ class StickerOrderReprint extends Page implements HasForms
return;
}
$itemCharacteristic = ItemCharacteristic::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('Item characteristic not found')
->body("No item characteristic found for item '{$itemCode}'.")
->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_characteristic_id', $itemCharacteristicId)
->where('item_id', $item->id)
->get();
if (! $stickerMappings) {
Notification::make()
->title('Sticker mapping not found')
->body("No sticker mapping found for this plant and item characteristic.")
->body("No sticker mapping found for this plant and class characteristic.")
->danger()
->send();
@@ -845,49 +850,47 @@ class StickerOrderReprint extends Page implements HasForms
return;
}
$pOrderEx = StickerOrder::where('production_order', $pOrder)->first();
$pOrderEx = ClassCharacteristic::where('aufnr', $pOrder)->first();
if(!$pOrderEx){
Notification::make()
->danger()
->title('Unknown Production Order')
->body("Production Order '$pOrder' not found.")
->body("Production Order '$pOrder' not found in Class Characteristic.")
->send();
return;
}
$pOrderExist = StickerOrder::where('plant_id', $plantId)->where('production_order', $pOrder)->first();
$pOrderExist = ClassCharacteristic::where('plant_id', $plantId)->where('aufnr', $pOrder)->first();
if(!$pOrderExist){
Notification::make()
->danger()
->title('Unknown Production Order')
->body("Production Order '$pOrder' not found against plant $plantName.")
->body("Production Order '$pOrder' not found against plant $plantName in class characteristic")
->send();
return;
}
if($pOrderExist){
if((int) $pOrderExist->from_serial_number != $fromSerNo || (int) $pOrderExist->to_serial_number != $toSerNo){
$pOrderExistData = ClassCharacteristic::where('plant_id', $plantId)
->where('aufnr', $pOrder)
->pluck('gernr')
->map(fn ($value) => (int) $value)
->toArray();
if (!in_array((int) $fromSerNo, $pOrderExistData, true) || !in_array((int) $toSerNo, $pOrderExistData, true))
{
Notification::make()
->danger()
->title('Unknown Serial Number')
->body("The entered serial number range does not match Production Order '$pOrder' for plant '$plantName'.")
->body("The entered serial number range does not match Production Order '$pOrder' for plant '$plantName' in class characteristic.")
->send();
return;
}
}
// $updatePrintStatusCompleted = StickerOrder::where('plant_id', $plantId)->where('production_order', $pOrder)->where('from_serial_number', $fromSerNo)->where('to_serial_number', $toSerNo)->where('sticker_id', $stickerId)->where('print_status', 'Printed')->first();
// if ($updatePrintStatusCompleted) {
// Notification::make()
// ->danger()
// ->title('Duplicate Sticker')
// ->body("Already StickerId '$stickerId' generated successfully for Production Order '$pOrder' and plant '$plantName'.")
// ->send();
// return;
// }
$structure = StickerStructureDetail::where('sticker_id',$stickerId)->first();
@@ -959,7 +962,7 @@ class StickerOrderReprint extends Page implements HasForms
return;
}
$itemCharacteristicId = $stickerMappingMasterItem->item_characteristic_id;
$itemCharacteristicId = $stickerMappingMasterItem->item_id;
if (!$itemCharacteristicId) {
@@ -971,19 +974,19 @@ class StickerOrderReprint extends Page implements HasForms
return;
}
$itemCharacteristic = ItemCharacteristic::where('plant_id', $plantId)->where('id',$itemCharacteristicId)->first();
$itemCharacteristic1 = ClassCharacteristic::where('plant_id', $plantId)->where('item_id',$itemCharacteristicId)->first();
if (!$itemCharacteristic) {
if (!$itemCharacteristic1) {
Notification::make()
->danger()
->title('Item Characteristic Not Found')
->body("Item characteristic '{$itemCharacteristicId}' was not found.")
->title('Class Characteristic Not Found')
->body("Class characteristic '{$itemCharacteristicId}' was not found.")
->send();
return;
}
$itemCode = Item::where('id',$itemCharacteristic->item_id)->where('plant_id',$plantId)->value('code');
$itemCode = Item::where('id',$itemCharacteristicId)->where('plant_id',$plantId)->value('code');
if (!$itemCode) {
@@ -1008,6 +1011,51 @@ class StickerOrderReprint extends Page implements HasForms
return;
}
//..
$matchedMachineId = null;
for ($i = 1; $i <= 8; $i++) {
$machineColumn = "sticker{$i}_machine_id";
if ((string) $stickerMappingMasterItem->{$machineColumn} == (string) $machineId) {
$matchedMachineId = $stickerMappingMasterItem->{$machineColumn};
break;
}
}
if (!$matchedMachineId) {
Notification::make()
->danger()
->title('Machine Not Found')
->body("Machine '{$machineId}' is not mapped for Item Code '{$itemCode}' in the selected sticker mapping.")
->send();
return;
}
// if($matchedMachineId != $machineId){
// Notification::make()
// ->danger()
// ->title('Machine Not Found')
// ->body("Machine '{$machineId}' is not mapped for Item Code '{$itemCode}' in the selected sticker mapping.")
// ->send();
// return;
// }
$itemCharacteristic = ClassCharacteristic::where('plant_id', $plantId)
->where('item_id', $itemCharacteristicId)
->where('machine_id', $matchedMachineId)
->where('aufnr', $pOrder)
->first();
// dd($itemCharacteristic);
$stickerService = new StickerPdfService();
$template = $stickerService->generateTemplate(