From f0141c4f7e2c3e965beea1edf6984901432e7496 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Wed, 31 Dec 2025 09:20:15 +0530 Subject: [PATCH] removed logic submerisible motor and pump in sticker reprint --- app/Filament/Pages/StickerReprint.php | 280 +++++++++--------- .../ProductionStickerReprintController.php | 26 +- 2 files changed, 159 insertions(+), 147 deletions(-) diff --git a/app/Filament/Pages/StickerReprint.php b/app/Filament/Pages/StickerReprint.php index 627798a..9ff489a 100644 --- a/app/Filament/Pages/StickerReprint.php +++ b/app/Filament/Pages/StickerReprint.php @@ -641,77 +641,77 @@ class StickerReprint extends Page implements HasForms // ******************************** - $exists = \App\Models\ProductionPlan::where('plant_id', $this->pId) - ->where('shift_id', $this->sId) - ->where('line_id', $this->lId) - ->whereDate('created_at', today()) - ->latest() - ->exists(); + // $exists = \App\Models\ProductionPlan::where('plant_id', $this->pId) + // ->where('shift_id', $this->sId) + // ->where('line_id', $this->lId) + // ->whereDate('created_at', today()) + // ->latest() + // ->exists(); - if ($exists) - { - $currentDate = date('Y-m-d'); + // if ($exists) + // { + // $currentDate = date('Y-m-d'); - $shiftId = Shift::where('id', $this->sId) - ->first(); + // $shiftId = Shift::where('id', $this->sId) + // ->first(); - [$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0]; - $hRs = (int) $hRs; - //$miNs = (int) $miNs;-*/ + // [$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0]; + // $hRs = (int) $hRs; + // //$miNs = (int) $miNs;-*/ - $totalMinutes = $hRs * 60 + $miNs; + // $totalMinutes = $hRs * 60 + $miNs; - $from_dt = $currentDate . ' ' . $shiftId->start_time; + // $from_dt = $currentDate . ' ' . $shiftId->start_time; - $to_dt = date('Y-m-d H:i:s', strtotime($from_dt . " + $totalMinutes minutes")); + // $to_dt = date('Y-m-d H:i:s', strtotime($from_dt . " + $totalMinutes minutes")); - $currentDateTime = date('Y-m-d H:i:s'); + // $currentDateTime = date('Y-m-d H:i:s'); - // Check if current date time is within the range - if (!($currentDateTime >= $from_dt && $currentDateTime < $to_dt)) { - //echo "Choosed a valid shift..."; - // $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')'); + // // Check if current date time is within the range + // if (!($currentDateTime >= $from_dt && $currentDateTime < $to_dt)) { + // //echo "Choosed a valid shift..."; + // // $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')'); - $this->form->fill([ - 'plant_id'=> $this->pId, - 'block_name'=> $this->bId, - 'shift_id'=> $this->sId, - 'line_id'=> $this->lId, - 'item_id'=> null, - 'serial_number'=> null, - 'success_msg'=> null, - 'production_order'=> $this->prodOrder, - 'sap_msg_status' => null, - 'sap_msg_description' => null, - 'operator_id'=> $operatorName, - 'recent_qr' => $this->recQr, - ]); - Notification::make() - ->title('Invalid Shift') - ->body("Please select a valid shift.") - ->danger() - ->send(); - //$set('validationError', 'Curr.'.$currentDateTime.' (From: '.$from_dt.', To: '.$to_dt.')'); - return; - } - else - { - $this->form->fill([ - 'plant_id'=> $this->pId, - 'block_name'=> $this->bId, - 'shift_id'=> $this->sId, - 'line_id'=> $this->lId, - 'item_id'=> null, - 'serial_number'=> null, - 'success_msg'=> null, - 'production_order'=> $this->prodOrder, - 'sap_msg_status' => null, - 'sap_msg_description' => null, - 'operator_id'=> $operatorName, - 'recent_qr' => $this->recQr, - ]); - } - } + // $this->form->fill([ + // 'plant_id'=> $this->pId, + // 'block_name'=> $this->bId, + // 'shift_id'=> $this->sId, + // 'line_id'=> $this->lId, + // 'item_id'=> null, + // 'serial_number'=> null, + // 'success_msg'=> null, + // 'production_order'=> $this->prodOrder, + // 'sap_msg_status' => null, + // 'sap_msg_description' => null, + // 'operator_id'=> $operatorName, + // 'recent_qr' => $this->recQr, + // ]); + // Notification::make() + // ->title('Invalid Shift') + // ->body("Please select a valid shift.") + // ->danger() + // ->send(); + // //$set('validationError', 'Curr.'.$currentDateTime.' (From: '.$from_dt.', To: '.$to_dt.')'); + // return; + // } + // else + // { + // $this->form->fill([ + // 'plant_id'=> $this->pId, + // 'block_name'=> $this->bId, + // 'shift_id'=> $this->sId, + // 'line_id'=> $this->lId, + // 'item_id'=> null, + // 'serial_number'=> null, + // 'success_msg'=> null, + // 'production_order'=> $this->prodOrder, + // 'sap_msg_status' => null, + // 'sap_msg_description' => null, + // 'operator_id'=> $operatorName, + // 'recent_qr' => $this->recQr, + // ]); + // } + // } // else // { // $existShifts = \App\Models\ProductionPlan::where('plant_id', $this->pId) @@ -1284,86 +1284,86 @@ class StickerReprint extends Page implements HasForms return; } - $line = Line::find($this->lId); - $lineName = $line ? $line->name : null; + //$line = Line::find($this->lId); + //$lineName = $line ? $line->name : null; - $categoryName = (Str::length($item->category) > 0) ? $item->category : ""; + // $categoryName = (Str::length($item->category) > 0) ? $item->category : ""; - if ($categoryName == 'Submersible Motor') - { - if ($lineName != '6 inch motor line') - { - $this->form->fill([ - 'plant_id'=> $this->pId, - 'block_name'=> $this->bId, - 'shift_id'=> $this->sId, - 'line_id'=> $this->lId, - 'item_id'=> null, - 'serial_number'=> null, - 'success_msg'=> null, - 'production_order'=> $this->prodOrder, - 'sap_msg_status' => null, - 'sap_msg_description' => null, - 'operator_id'=> $operatorName, - 'recent_qr' => $this->recQr, - ]); - Notification::make() - ->title('Invalid Line Found') - ->body("Choose '6 inch motor line' to proceed..!") - ->danger() - ->send(); - return; - } - } - else if ($categoryName == 'Submersible Pump') - { - if ($lineName != '6 inch pump line') - { - $this->form->fill([ - 'plant_id'=> $this->pId, - 'block_name'=> $this->bId, - 'shift_id'=> $this->sId, - 'line_id'=> $this->lId, - 'item_id'=> null, - 'serial_number'=> null, - 'success_msg'=> null, - 'production_order'=> $this->prodOrder, - 'sap_msg_status' => null, - 'sap_msg_description' => null, - 'operator_id'=> $operatorName, - 'recent_qr' => $this->recQr, - ]); - Notification::make() - ->title('Invalid Line Found') - ->body("Choose '6 inch pump line' to proceed..!") - ->danger() - ->send(); - return; - } - } - else - { - $this->form->fill([ - 'plant_id'=> $this->pId, - 'block_name'=> $this->bId, - 'shift_id'=> $this->sId, - 'line_id'=> $this->lId, - 'item_id'=> null, - 'serial_number'=> null, - 'success_msg'=> null, - 'production_order'=> $this->prodOrder, - 'sap_msg_status' => null, - 'sap_msg_description' => null, - 'operator_id'=> $operatorName, - 'recent_qr' => $this->recQr, - ]); - Notification::make() - ->title('Invalid Category Found') - ->body("Set proper category to proceed..!") - ->danger() - ->send(); - return; - } + // if ($categoryName == 'Submersible Motor') + // { + // if ($lineName != '6 inch motor line') + // { + // $this->form->fill([ + // 'plant_id'=> $this->pId, + // 'block_name'=> $this->bId, + // 'shift_id'=> $this->sId, + // 'line_id'=> $this->lId, + // 'item_id'=> null, + // 'serial_number'=> null, + // 'success_msg'=> null, + // 'production_order'=> $this->prodOrder, + // 'sap_msg_status' => null, + // 'sap_msg_description' => null, + // 'operator_id'=> $operatorName, + // 'recent_qr' => $this->recQr, + // ]); + // Notification::make() + // ->title('Invalid Line Found') + // ->body("Choose '6 inch motor line' to proceed..!") + // ->danger() + // ->send(); + // return; + // } + // } + // else if ($categoryName == 'Submersible Pump') + // { + // if ($lineName != '6 inch pump line') + // { + // $this->form->fill([ + // 'plant_id'=> $this->pId, + // 'block_name'=> $this->bId, + // 'shift_id'=> $this->sId, + // 'line_id'=> $this->lId, + // 'item_id'=> null, + // 'serial_number'=> null, + // 'success_msg'=> null, + // 'production_order'=> $this->prodOrder, + // 'sap_msg_status' => null, + // 'sap_msg_description' => null, + // 'operator_id'=> $operatorName, + // 'recent_qr' => $this->recQr, + // ]); + // Notification::make() + // ->title('Invalid Line Found') + // ->body("Choose '6 inch pump line' to proceed..!") + // ->danger() + // ->send(); + // return; + // } + // } + // else + // { + // $this->form->fill([ + // 'plant_id'=> $this->pId, + // 'block_name'=> $this->bId, + // 'shift_id'=> $this->sId, + // 'line_id'=> $this->lId, + // 'item_id'=> null, + // 'serial_number'=> null, + // 'success_msg'=> null, + // 'production_order'=> $this->prodOrder, + // 'sap_msg_status' => null, + // 'sap_msg_description' => null, + // 'operator_id'=> $operatorName, + // 'recent_qr' => $this->recQr, + // ]); + // Notification::make() + // ->title('Invalid Category Found') + // ->body("Set proper category to proceed..!") + // ->danger() + // ->send(); + // return; + // } if ($this->succId == null) { $this->form->fill([ diff --git a/app/Http/Controllers/ProductionStickerReprintController.php b/app/Http/Controllers/ProductionStickerReprintController.php index cc875b8..b7ad435 100644 --- a/app/Http/Controllers/ProductionStickerReprintController.php +++ b/app/Http/Controllers/ProductionStickerReprintController.php @@ -73,13 +73,25 @@ class ProductionStickerReprintController extends Controller } else { - if ($item->category == 'Submersible Motor') - { - $copies = 1; - } - elseif ($item->category == 'Submersible Pump') - { - $copies = 1; + // if ($item->category == 'Submersible Motor') + // { + // $copies = 1; + // } + // elseif ($item->category == 'Submersible Pump') + // { + // $copies = 1; + // } + $copies = 1; + + if ($serialNumberRaw) { + // Check if serial ends with /m or /M, optionally followed by | + if (preg_match('/\/[mM](\|)?$/', $serialNumberRaw)) { + $copies = 1; + } + // Check if serial ends with /p or /P, optionally followed by | + elseif (preg_match('/\/[pP](\|)?$/', $serialNumberRaw)) { + $copies = 1; + } } }