From b8738a2f6ae14f25ec2fcbf6d85796061ecf9921 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Wed, 9 Jul 2025 20:57:06 +0530 Subject: [PATCH] Added serial_number minimum length should be 9 digit and notification display duration and updated validations --- app/Filament/Pages/InvoiceFinder.php | 37 +- app/Filament/Pages/LocatorValidation.php | 661 +++++++++++++-------- app/Filament/Pages/PalletFromLocator.php | 91 ++- app/Filament/Pages/UploadSerialLocator.php | 598 +++++++++++-------- 4 files changed, 845 insertions(+), 542 deletions(-) diff --git a/app/Filament/Pages/InvoiceFinder.php b/app/Filament/Pages/InvoiceFinder.php index 09a1dfd83..2d86eef36 100644 --- a/app/Filament/Pages/InvoiceFinder.php +++ b/app/Filament/Pages/InvoiceFinder.php @@ -77,9 +77,10 @@ class InvoiceFinder extends Page implements HasForms if(!$invoiceNo) { Notification::make() - ->title("Invoice number '$invoiceNo' can't be empty!") - ->danger() - ->send(); + ->title("Invoice number '$invoiceNo' can't be empty!") + ->danger() + ->duration(1200) + ->send(); $this->dispatch('loadData', '', [], [], [], [], $plantId); $this->form->fill([ 'plant_id' => $plantId, @@ -98,13 +99,14 @@ class InvoiceFinder extends Page implements HasForms if(!$invoiceExists) { Notification::make() - ->title("Invoice number '$invoiceNo' does not exist in locator invoice table!") - ->danger() - ->send(); + ->title("Invoice number '$invoiceNo' does not exist in locator invoice table!") + ->danger() + ->duration(2000) + ->send(); $this->dispatch('loadData', '', [], [], [], [], $plantId); $this->form->fill([ 'plant_id' => $plantId, - 'scan_invoice' => $invoiceNo, + 'scan_invoice' => null,//$invoiceNo, 'total_sno_quantity' => 0, 'pending_quantity' => 0, 'scan_quantity' => 0 @@ -120,21 +122,22 @@ class InvoiceFinder extends Page implements HasForms if(!$invoiceCompleted) { - $count = LocatorInvoiceValidation::where('invoice_number', $invoiceNo) - ->where('plant_id', $plantId) - ->count(); + // $count = LocatorInvoiceValidation::where('invoice_number', $invoiceNo) + // ->where('plant_id', $plantId) + // ->count(); Notification::make() - ->title("Invoice number '$invoiceNo' already completed the scanning process...") - ->success() - ->send(); + ->title("Invoice number '$invoiceNo' already completed the scanning process..!") + ->success() + ->duration(2000) + ->send(); $this->dispatch('loadData', '', [], [], [], [], $plantId); $this->form->fill([ 'plant_id' => $plantId, - 'scan_invoice' => $invoiceNo, - 'total_sno_quantity' => $count, - 'pending_quantity' => 0, - 'scan_quantity' => $count + 'scan_invoice' => null,//$invoiceNo, + 'total_sno_quantity' => 0,//$count, + 'pending_quantity' => 0,//0, + 'scan_quantity' => 0//$count ]); return; } diff --git a/app/Filament/Pages/LocatorValidation.php b/app/Filament/Pages/LocatorValidation.php index e7b26d229..203939df7 100644 --- a/app/Filament/Pages/LocatorValidation.php +++ b/app/Filament/Pages/LocatorValidation.php @@ -46,6 +46,7 @@ class LocatorValidation extends Page implements HasForms public $plantId; public $scanLocator; + public $locators; public array $filters = []; @@ -66,12 +67,13 @@ class LocatorValidation extends Page implements HasForms Section::make('') ->schema([ Select::make('plant_id') - ->options(Plant::pluck('name', 'id')) ->label('Plant') ->reactive() + ->options(Plant::pluck('name', 'id')) ->required(), TextInput::make('scan_pallet_no') ->label('Scan Pallet No') + ->minLength(10) ->reactive() // ->readonly(fn () => $this->disablePalletNo) ->readOnly(fn (callable $get) => !$get('plant_id') || !empty($get('scan_serial_no')) || !empty($get('scan_locator_no'))) @@ -80,14 +82,16 @@ class LocatorValidation extends Page implements HasForms ]), TextInput::make('scan_serial_no') ->label('Scan Serial No') + ->minLength(9) + ->reactive() // ->readOnly(fn () => $this->disableSerialNo) ->readOnly(fn (callable $get) => !$get('plant_id') || !empty($get('scan_pallet_no')) || !empty($get('scan_locator_no'))) - ->reactive() ->extraAttributes([ 'wire:keydown.enter' => 'processSerialNo($event.target.value)', ]), TextInput::make('scan_locator_no') ->label('Scan Locator No') + ->minLength(7) ->reactive() ->readOnly(fn (callable $get) => !$get('plant_id') || (!$get('scan_pallet_no') && !$get('scan_serial_no'))) ->extraAttributes([ @@ -132,9 +136,11 @@ class LocatorValidation extends Page implements HasForms if ($palletNo == null || $palletNo == '') { Notification::make() - ->title("Pallet number cannot be empty!") + ->title("Pallet number can't be empty!") ->danger() + ->duration(1200) ->send(); + $this->dispatch('loadLocator' ,'',$plantId); $this->form->fill ([ @@ -148,13 +154,14 @@ class LocatorValidation extends Page implements HasForms ]); return; } - - if (strlen($palletNo) < 10) + else if (strlen($palletNo) < 10) { Notification::make() ->title("Pallet number '$palletNo' must be at least 10 digits.") ->danger() + ->duration(1200) ->send(); + $this->dispatch('loadLocator' ,'',$plantId); $this->form->fill ([ @@ -174,9 +181,11 @@ class LocatorValidation extends Page implements HasForms if(!$Palletexists) { Notification::make() - ->title("Pallet number '$palletNo' does not found in pallet table.") - ->danger() - ->send(); + ->title("Pallet number '$palletNo' does not found in pallet table.") + ->danger() + ->duration(1200) + ->send(); + $this->dispatch('loadLocator' ,'',$plantId); $this->form->fill ([ @@ -256,9 +265,10 @@ class LocatorValidation extends Page implements HasForms if($notAlreadyCompleted) { Notification::make() - ->title("Pallet number '{$palletNo}' does not completed the master packing.") - ->danger() - ->send(); + ->title("Pallet number '{$palletNo}' does not completed the master packing.") + ->danger() + ->duration(1200) + ->send(); $this->dispatch('loadLocator' ,'',$plantId); $this->form->fill @@ -300,6 +310,7 @@ class LocatorValidation extends Page implements HasForms Notification::make() ->title("Press 'Remove Pallet' button to remove Pallet number : '$palletNo' from Locator number : '$locatorNumber'..!") ->info() + ->duration(2000) ->send(); } @@ -309,7 +320,6 @@ class LocatorValidation extends Page implements HasForms public function processSerialNo($serialNo) { - $plantId = $this->form->getState()['plant_id']; $plantId = trim($plantId) ?? null; @@ -329,12 +339,14 @@ class LocatorValidation extends Page implements HasForms return; } - if (strlen($serialNo) < 13) + if ($serialNo == null || $serialNo == '') { Notification::make() - ->title("Serial number '$serialNo' must be at least 13 digits.") + ->title("Serial number can't be empty!") ->danger() + ->duration(1200) ->send(); + $this->dispatch('loadLocator' ,'',$plantId); $this->form->fill ([ @@ -348,12 +360,33 @@ class LocatorValidation extends Page implements HasForms ]); return; } + else if (strlen($serialNo) < 9) + { + Notification::make() + ->title("Serial number '$serialNo' must be at least 9 digits.") + ->danger() + ->duration(1200) + ->send(); - if (!ctype_alnum($serialNo)) + $this->dispatch('loadLocator' ,'',$plantId); + $this->form->fill + ([ + 'plant_id' => $plantId, + 'scan_serial_no' => $serialNo, + 'scan_pallet_no' => null, + 'scan_locator_no' => $scanLocator, + 'pallet_quantity' => 0, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, + ]); + return; + } + else if (!ctype_alnum($serialNo)) { Notification::make() ->title("Serial number '$serialNo' must contain alpha-numeric values only.") ->danger() + ->duration(1200) ->send(); $this->dispatch('loadLocator' ,'',$plantId); $this->form->fill @@ -381,6 +414,7 @@ class LocatorValidation extends Page implements HasForms Notification::make() ->title("Serial number '$serialNo' already exists in invoice number '$invoiceNo' and completed the scanning process.") ->danger() + ->duration(1200) ->send(); $this->dispatch('loadLocator' ,'',$plantId); $this->form->fill @@ -417,6 +451,7 @@ class LocatorValidation extends Page implements HasForms Notification::make() ->title("Scanned serial number '$serialNo' already exist in pallet number '$palletnumber'!
Scan the valid new serial number to proceed...") ->danger() + ->duration(1200) ->send(); // $this->form->fill([ @@ -449,6 +484,7 @@ class LocatorValidation extends Page implements HasForms Notification::make() ->title("Press 'Remove Serial Number' button to remove Serial number : '$serialNo' from Locator number : '$locatorNo'..!") ->info() + ->duration(2000) ->send(); } @@ -497,15 +533,38 @@ class LocatorValidation extends Page implements HasForms $operatorName = Filament::auth()->user()->name; $this->locators = PalletValidation::where('plant_id', $plantId) - ->where('locator_number', $scanLocator) + ->where('locator_number', '11111') ->get(); - if (strlen($scanLocator) < 7) + if ($scanLocator == null || $scanLocator == '') + { + Notification::make() + ->title("Locator number can't be empty!") + ->danger() + ->duration(1200) + ->send(); + + $this->dispatch('loadLocator' ,'',$plantId); + $this->form->fill + ([ + 'plant_id' => $plantId, + 'scan_serial_no' => $serialNo, + 'scan_pallet_no' => $palletNo, + 'scan_locator_no' => $scanLocator, + 'pallet_quantity' => 0, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, + ]); + return; + } + else if (strlen($scanLocator) < 7) { Notification::make() ->title("Locator number '$scanLocator' must be at least 7 digits.") ->danger() + ->duration(1200) ->send(); + $this->dispatch('loadLocator' ,'',$plantId); $this->form->fill ([ @@ -527,9 +586,10 @@ class LocatorValidation extends Page implements HasForms if(!$exists) { Notification::make() - ->title("Locator number '{$scanLocator}' does not exist in the master.") - ->danger() - ->send(); + ->title("Locator number '{$scanLocator}' does not exist in the master.") + ->danger() + ->duration(1200) + ->send(); // $this->form->fill([ // 'plant_id' => $plantId, @@ -561,22 +621,28 @@ class LocatorValidation extends Page implements HasForms Notification::make() ->title("No space available for locator number '{$scanLocator}'.") ->danger() + ->duration(1200) ->send(); - $this->dispatch('loadLocator' ,'',$plantId); - $this->form->fill - ([ - 'plant_id' => $plantId, - 'scan_serial_no' => $serialNo, - 'scan_pallet_no' => $palletNo, - 'scan_locator_no' => $scanLocator, - 'pallet_quantity' => 0, - 'created_by' => $operatorName, - 'scanned_by' => $operatorName, - ]); + $this->dispatch('loadLocator' ,'',$plantId); + + $this->form->fill + ([ + 'plant_id' => $plantId, + 'scan_serial_no' => $serialNo, + 'scan_pallet_no' => $palletNo, + 'scan_locator_no' => $scanLocator, + 'pallet_quantity' => 0, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, + ]); return; } + $this->locators = PalletValidation::where('plant_id', $plantId) + ->where('locator_number', $scanLocator) + ->get(); + if ($palletNo) { if (strlen($palletNo) < 10) @@ -584,7 +650,9 @@ class LocatorValidation extends Page implements HasForms Notification::make() ->title("Pallet number '$palletNo' must be at least 10 digits.") ->danger() + ->duration(1200) ->send(); + $this->dispatch('loadLocator' ,'',$plantId); $this->form->fill ([ @@ -609,11 +677,12 @@ class LocatorValidation extends Page implements HasForms if($notAlreadyCompleted) { Notification::make() - ->title("Pallet number '{$palletNo}' does not completed the master packing.") - ->danger() - ->send(); - $this->dispatch('loadLocator' ,'',$plantId); + ->title("Pallet number '{$palletNo}' does not completed the master packing.") + ->danger() + ->duration(1200) + ->send(); + $this->dispatch('loadLocator' ,'',$plantId); $this->form->fill ([ 'plant_id' => $plantId, @@ -636,19 +705,20 @@ class LocatorValidation extends Page implements HasForms Notification::make() ->title("Pallet number '$palletNo' is already assigned to locator number '{$locatorExist->locator_number}'.") ->danger() + ->duration(1200) ->send(); - $this->dispatch('loadLocator' ,'',$plantId); - $this->form->fill - ([ - 'plant_id' => $plantId, - 'scan_serial_no' => null, - 'scan_pallet_no' => $palletNo, - 'scan_locator_no' => $scanLocator, - 'pallet_quantity' => 0, - 'created_by' => $operatorName, - 'scanned_by' => $operatorName, - ]); + $this->dispatch('loadLocator' ,'',$plantId); + $this->form->fill + ([ + 'plant_id' => $plantId, + 'scan_serial_no' => null, + 'scan_pallet_no' => $palletNo, + 'scan_locator_no' => $scanLocator, + 'pallet_quantity' => 0, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, + ]); return; } @@ -658,6 +728,7 @@ class LocatorValidation extends Page implements HasForms Notification::make() ->title("Press 'Remove Pallet' button to remove Pallet number : '$palletNo' from Locator number : '$scanLocator'..!") ->info() + ->duration(2000) ->send(); } else @@ -665,6 +736,7 @@ class LocatorValidation extends Page implements HasForms Notification::make() ->title("Press 'Add Pallet' button to add Pallet number : '$palletNo' into Locator number : '$scanLocator'..!") ->info() + ->duration(2000) ->send(); } } @@ -674,7 +746,9 @@ class LocatorValidation extends Page implements HasForms Notification::make() ->title("Serial number is required to add or remove when pallet number is empty.") ->danger() + ->duration(1200) ->send(); + $this->dispatch('loadLocator' ,'',$plantId); $this->form->fill ([ @@ -688,13 +762,14 @@ class LocatorValidation extends Page implements HasForms ]); return; } - - if (strlen($serialNo) < 13) + else if (strlen($serialNo) < 9) { Notification::make() - ->title("Serial number '$serialNo' must be at least 13 digits.") + ->title("Serial number '$serialNo' must be at least 9 digits.") ->danger() + ->duration(1200) ->send(); + $this->dispatch('loadLocator' ,'',$plantId); $this->form->fill ([ @@ -708,13 +783,14 @@ class LocatorValidation extends Page implements HasForms ]); return; } - - if (!ctype_alnum($serialNo)) + else if (!ctype_alnum($serialNo)) { Notification::make() ->title("Serial number '$serialNo' must contain alpha-numeric values only.") ->danger() + ->duration(1200) ->send(); + $this->dispatch('loadLocator' ,'',$plantId); $this->form->fill ([ @@ -730,9 +806,9 @@ class LocatorValidation extends Page implements HasForms } $invoicesnoexists = LocatorInvoiceValidation::where('plant_id', $plantId) - ->where('serial_number', $serialNo) - ->where('scanned_status', '=','Scanned') - ->first(); + ->where('serial_number', $serialNo) + ->where('scanned_status', '=','Scanned') + ->first(); $invoiceNo = $invoicesnoexists?->invoice_number; @@ -741,21 +817,22 @@ class LocatorValidation extends Page implements HasForms Notification::make() ->title("Serial number '$serialNo' already exists in invoice number '$invoiceNo' and completed the scanning process.") ->danger() + ->duration(1200) ->send(); - $this->dispatch('loadLocator' ,'',$plantId); - $this->form->fill - ([ - 'plant_id' => $plantId, - 'scan_serial_no' => $serialNo, - 'scan_pallet_no' => null, - 'scan_locator_no' => $scanLocator, - 'pallet_quantity' => 0, - 'created_by' => $operatorName, - 'scanned_by' => $operatorName, - ]); + $this->dispatch('loadLocator' ,'',$plantId); + $this->form->fill + ([ + 'plant_id' => $plantId, + 'scan_serial_no' => $serialNo, + 'scan_pallet_no' => null, + 'scan_locator_no' => $scanLocator, + 'pallet_quantity' => 0, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, + ]); - return; + return; } $serialExist = PalletValidation::where('serial_number', $serialNo) @@ -767,18 +844,20 @@ class LocatorValidation extends Page implements HasForms Notification::make() ->title("Serial number '$serialNo' is already assigned to locator number '{$serialExist->locator_number}'.") ->danger() + ->duration(1200) ->send(); - $this->dispatch('loadLocator' ,'',$plantId); - $this->form->fill - ([ - 'plant_id' => $plantId, - 'scan_serial_no' => $serialNo, - 'scan_pallet_no' => null, - 'scan_locator_no' => $scanLocator, - 'pallet_quantity' => 0, - 'created_by' => $operatorName, - 'scanned_by' => $operatorName, - ]); + + $this->dispatch('loadLocator' ,'',$plantId); + $this->form->fill + ([ + 'plant_id' => $plantId, + 'scan_serial_no' => $serialNo, + 'scan_pallet_no' => null, + 'scan_locator_no' => $scanLocator, + 'pallet_quantity' => 0, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, + ]); return; } @@ -787,6 +866,7 @@ class LocatorValidation extends Page implements HasForms Notification::make() ->title("Press 'Remove Serial Number' button to remove Serial number : '$serialNo' from Locator number : '$scanLocator'..!") ->info() + ->duration(2000) ->send(); } else @@ -794,13 +874,14 @@ class LocatorValidation extends Page implements HasForms Notification::make() ->title("Press 'Add Serial Number' button to add Serial number : '$serialNo' into Locator number : '$scanLocator'..!") ->info() + ->duration(2000) ->send(); } } $count = PalletValidation::where('plant_id', $plantId) - ->where('locator_number', $scanLocator) - ->count('locator_number'); + ->where('locator_number', $scanLocator) + ->count('locator_number'); $this->form->fill([ 'plant_id' => $plantId, @@ -839,9 +920,11 @@ class LocatorValidation extends Page implements HasForms if ($scanLocator == null || $scanLocator == '') { Notification::make() - ->title("Locator number cannot be empty!") + ->title("Locator number can't be empty!") ->danger() + ->duration(1200) ->send(); + $this->dispatch('loadLocator' ,'',$plantId); $this->form->fill ([ @@ -855,13 +938,14 @@ class LocatorValidation extends Page implements HasForms ]); return; } - - if (strlen($scanLocator) < 7) + else if (strlen($scanLocator) < 7) { Notification::make() ->title("Locator number '$scanLocator' must be at least 7 digits.") ->danger() + ->duration(1200) ->send(); + $this->dispatch('loadLocator' ,'',$plantId); $this->form->fill ([ @@ -885,18 +969,20 @@ class LocatorValidation extends Page implements HasForms Notification::make() ->title("Locator number '{$scanLocator}' does not exist in the master.") ->danger() + ->duration(1200) ->send(); - $this->dispatch('loadLocator' ,'',$plantId); - $this->form->fill - ([ - 'plant_id' => $plantId, - 'scan_serial_no' => $serialNo, - 'scan_pallet_no' => $palletNo, - 'scan_locator_no' => $scanLocator, - 'pallet_quantity' => 0, - 'created_by' => $operatorName, - 'scanned_by' => $operatorName, - ]); + + $this->dispatch('loadLocator' ,'',$plantId); + $this->form->fill + ([ + 'plant_id' => $plantId, + 'scan_serial_no' => $serialNo, + 'scan_pallet_no' => $palletNo, + 'scan_locator_no' => $scanLocator, + 'pallet_quantity' => 0, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, + ]); return; } @@ -908,9 +994,10 @@ class LocatorValidation extends Page implements HasForms Notification::make() ->title("No space available for locator number '{$scanLocator}'.") ->danger() + ->duration(1200) ->send(); - $this->dispatch('loadLocator' ,'',$plantId); + $this->dispatch('loadLocator' ,'',$plantId); $this->form->fill ([ 'plant_id' => $plantId, @@ -931,9 +1018,10 @@ class LocatorValidation extends Page implements HasForms Notification::make() ->title("Pallet number '$palletNo' must be at least 10 digits.") ->danger() + ->duration(1200) ->send(); - $this->dispatch('loadLocator' ,'',$plantId); + $this->dispatch('loadLocator' ,'',$plantId); $this->form->fill ([ 'plant_id' => $plantId, @@ -952,11 +1040,12 @@ class LocatorValidation extends Page implements HasForms if(!$Palletexists) { Notification::make() - ->title("Pallet number '$palletNo' does not found in pallet table.") - ->danger() - ->send(); - $this->dispatch('loadLocator' ,'',$plantId); + ->title("Pallet number '$palletNo' does not found in pallet table.") + ->danger() + ->duration(1200) + ->send(); + $this->dispatch('loadLocator' ,'',$plantId); $this->form->fill ([ 'plant_id' => $plantId, @@ -980,11 +1069,12 @@ class LocatorValidation extends Page implements HasForms if($notAlreadyCompleted) { Notification::make() - ->title("Pallet number '{$palletNo}' does not completed the master packing.") - ->danger() - ->send(); - $this->dispatch('loadLocator' ,'',$plantId); + ->title("Pallet number '{$palletNo}' does not completed the master packing.") + ->danger() + ->duration(1200) + ->send(); + $this->dispatch('loadLocator' ,'',$plantId); $this->form->fill ([ 'plant_id' => $plantId, @@ -999,20 +1089,21 @@ class LocatorValidation extends Page implements HasForms } $alreadyAssigned = PalletValidation::where('plant_id', $plantId) - ->where('pallet_number', $palletNo) - ->where('locator_number', '!=', '') - ->where('locator_number', '!=', null) - // ->where('locator_number', $this->scanLocator) - ->first(); + ->where('pallet_number', $palletNo) + ->where('locator_number', '!=', '') + ->where('locator_number', '!=', null) + // ->where('locator_number', $this->scanLocator) + ->first(); if ($alreadyAssigned) { Notification::make() ->title("Pallet number '{$palletNo}' is already added into locator number '{$alreadyAssigned->locator_number}'.") ->danger() + ->duration(1200) ->send(); - $this->dispatch('loadLocator' ,'',$plantId); + $this->dispatch('loadLocator' ,'',$plantId); $this->form->fill([ 'plant_id' => $plantId, 'scan_serial_no' => null, @@ -1031,16 +1122,18 @@ class LocatorValidation extends Page implements HasForms 'locator_number' => $scanLocator, ]); - $count = PalletValidation::where('plant_id', $plantId) - ->where('locator_number', $scanLocator) - ->count('locator_number'); + // $count = PalletValidation::where('plant_id', $plantId) + // ->where('locator_number', $scanLocator) + // ->count('locator_number'); if ($updatedRows > 0) { Notification::make() - ->title("Scanned pallet number '$palletNo' added into locator number '$scanLocator' successfully.") - ->success() - ->send(); + ->title("Scanned pallet number '$palletNo' added into locator number '$scanLocator' successfully.") + ->success() + ->duration(1000) + ->send(); + $locator = Locator::where('locator_number', $scanLocator) ->where('plant_id', $plantId)->first(); $locator->increment('locator_quantity'); @@ -1073,9 +1166,10 @@ class LocatorValidation extends Page implements HasForms else { Notification::make() - ->title("pallet number failed to add into locator number '$scanLocator'") - ->danger() - ->send(); + ->title("pallet number failed to add into locator number '$scanLocator'") + ->danger() + ->duration(1200) + ->send(); $this->dispatch('loadLocator' ,'',$plantId); $this->form->fill ([ @@ -1097,7 +1191,9 @@ class LocatorValidation extends Page implements HasForms Notification::make() ->title("Serial number is required to add when pallet number is empty.") ->danger() + ->duration(1200) ->send(); + $this->dispatch('loadLocator' ,'',$plantId); $this->form->fill ([ @@ -1111,13 +1207,14 @@ class LocatorValidation extends Page implements HasForms ]); return; } - - if (strlen($serialNo) < 13) + else if (strlen($serialNo) < 9) { Notification::make() - ->title("Serial number '$serialNo' must be at least 13 digits.") + ->title("Serial number '$serialNo' must be at least 9 digits.") ->danger() + ->duration(1200) ->send(); + $this->dispatch('loadLocator' ,'',$plantId); $this->form->fill ([ @@ -1131,13 +1228,14 @@ class LocatorValidation extends Page implements HasForms ]); return; } - - if (!ctype_alnum($serialNo)) + else if (!ctype_alnum($serialNo)) { Notification::make() ->title("Serial number '$serialNo' must contain alpha-numeric values only.") ->danger() + ->duration(1200) ->send(); + $this->dispatch('loadLocator' ,'',$plantId); $this->form->fill ([ @@ -1164,19 +1262,21 @@ class LocatorValidation extends Page implements HasForms Notification::make() ->title("Serial number '$serialNo' already exists in invoice number '$invoiceNo' and completed the scanning process.") ->danger() + ->duration(1200) ->send(); - $this->dispatch('loadLocator' ,'',$plantId); - $this->form->fill - ([ - 'plant_id' => $plantId, - 'scan_serial_no' => $serialNo, - 'scan_pallet_no' => null, - 'scan_locator_no' => $scanLocator, - 'pallet_quantity' => 0, - 'created_by' => $operatorName, - 'scanned_by' => $operatorName, - ]); - return; + + $this->dispatch('loadLocator' ,'',$plantId); + $this->form->fill + ([ + 'plant_id' => $plantId, + 'scan_serial_no' => $serialNo, + 'scan_pallet_no' => null, + 'scan_locator_no' => $scanLocator, + 'pallet_quantity' => 0, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, + ]); + return; } $palletexists = PalletValidation::where('plant_id', $plantId) @@ -1188,9 +1288,11 @@ class LocatorValidation extends Page implements HasForms if($palletexists) { Notification::make() - ->title("Serial number '$serialNo' already exists in pallet number '{$palletexists->pallet_number}'.") - ->danger() - ->send(); + ->title("Serial number '$serialNo' already exists in pallet number '{$palletexists->pallet_number}'.") + ->danger() + ->duration(1200) + ->send(); + $this->dispatch('loadLocator' ,'',$plantId); $this->form->fill ([ @@ -1206,28 +1308,30 @@ class LocatorValidation extends Page implements HasForms } $exists = PalletValidation::where('plant_id', $plantId) - ->where('serial_number', $serialNo) - ->where('locator_number', '!=', '') - ->where('locator_number', '!=', null) - ->first(); + ->where('serial_number', $serialNo) + ->where('locator_number', '!=', '') + ->where('locator_number', '!=', null) + ->first(); if ($exists) { Notification::make() ->title("Serial number '$serialNo' already exists in locator number '{$exists->locator_number}'.") ->danger() + ->duration(1200) ->send(); - $this->dispatch('loadLocator' ,'',$plantId); - $this->form->fill - ([ - 'plant_id' => $plantId, - 'scan_serial_no' => $serialNo, - 'scan_pallet_no' => null, - 'scan_locator_no' => $scanLocator, - 'pallet_quantity' => 0, - 'created_by' => $operatorName, - 'scanned_by' => $operatorName, - ]); + + $this->dispatch('loadLocator' ,'',$plantId); + $this->form->fill + ([ + 'plant_id' => $plantId, + 'scan_serial_no' => $serialNo, + 'scan_pallet_no' => null, + 'scan_locator_no' => $scanLocator, + 'pallet_quantity' => 0, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, + ]); return; } @@ -1256,6 +1360,7 @@ class LocatorValidation extends Page implements HasForms Notification::make() ->title("Scanned serial number '$serialNo' added into locator number '$scanLocator' successfully.") ->success() + ->duration(1000) ->send(); // $count = PalletValidation::where('plant_id', $plantId) @@ -1303,9 +1408,11 @@ class LocatorValidation extends Page implements HasForms if ($scanLocator == null || $scanLocator == '') { Notification::make() - ->title("Locator number cannot be empty!") + ->title("Locator number can't be empty!") ->danger() + ->duration(1200) ->send(); + $this->dispatch('loadLocator' ,'',$plantId); $this->form->fill ([ @@ -1319,13 +1426,14 @@ class LocatorValidation extends Page implements HasForms ]); return; } - - if (strlen($scanLocator) < 7) + else if (strlen($scanLocator) < 7) { Notification::make() ->title("Locator number '$scanLocator' must be at least 7 digits.") ->danger() + ->duration(1200) ->send(); + $this->dispatch('loadLocator' ,'',$plantId); $this->form->fill ([ @@ -1349,7 +1457,9 @@ class LocatorValidation extends Page implements HasForms Notification::make() ->title("Locator number '{$scanLocator}' does not exist in the master.") ->danger() + ->duration(1200) ->send(); + $this->dispatch('loadLocator' ,'',$plantId); $this->form->fill ([ @@ -1371,7 +1481,9 @@ class LocatorValidation extends Page implements HasForms Notification::make() ->title("Pallet number '$palletNo' must be at least 10 digits.") ->danger() + ->duration(1200) ->send(); + $this->dispatch('loadLocator' ,'',$plantId); $this->form->fill ([ @@ -1391,9 +1503,11 @@ class LocatorValidation extends Page implements HasForms if(!$Palletexists) { Notification::make() - ->title("Pallet number '$palletNo' does not found in pallet table.") - ->danger() - ->send(); + ->title("Pallet number '$palletNo' does not found in pallet table.") + ->danger() + ->duration(1200) + ->send(); + $this->dispatch('loadLocator' ,'',$plantId); $this->form->fill ([ @@ -1405,7 +1519,7 @@ class LocatorValidation extends Page implements HasForms 'created_by' => $operatorName, 'scanned_by' => $operatorName, ]); - return; + return; } $notAlreadyCompleted = PalletValidation::where('plant_id', $plantId) @@ -1418,11 +1532,12 @@ class LocatorValidation extends Page implements HasForms if($notAlreadyCompleted) { Notification::make() - ->title("Pallet number '{$palletNo}' does not completed the master packing.") - ->danger() - ->send(); - $this->dispatch('loadLocator' ,'',$plantId); + ->title("Pallet number '{$palletNo}' does not completed the master packing.") + ->danger() + ->duration(1200) + ->send(); + $this->dispatch('loadLocator' ,'',$plantId); $this->form->fill ([ 'plant_id' => $plantId, @@ -1447,9 +1562,10 @@ class LocatorValidation extends Page implements HasForms Notification::make() ->title("Pallet number '$palletNo' is exists in locator number '$palletValidation->locator_number'
Scan the valid locator number to remove pallet number.") ->danger() + ->duration(1200) ->send(); - $this->dispatch('loadLocator', '', $plantId); + $this->dispatch('loadLocator', '', $plantId); $this->form->fill ([ 'plant_id' => $plantId, @@ -1474,7 +1590,9 @@ class LocatorValidation extends Page implements HasForms Notification::make() ->title("Pallet number '{$palletNo}' doesn't exist in locator number.
Add locator number to proceed...") ->danger() + ->duration(1200) ->send(); + $this->dispatch('loadLocator' ,'',$plantId); $this->form->fill ([ @@ -1547,67 +1665,75 @@ class LocatorValidation extends Page implements HasForms Notification::make() ->title("Scanned pallet number '{$palletNo}' removed from locator number '$scanLocator' successfully.") ->success() + ->duration(1000) ->send(); - $this->dispatch('loadLocator' ,$scanLocator,$plantId); - $this->form->fill([ - 'plant_id' => $plantId, - 'scan_serial_no' => null, - 'scan_pallet_no' => null, - 'scan_locator_no' => null, - 'pallet_quantity' => null, - 'created_by' => $operatorName, - 'updated_by' => $operatorName, - ]); + + $this->dispatch('loadLocator' ,$scanLocator,$plantId); + $this->form->fill([ + 'plant_id' => $plantId, + 'scan_serial_no' => null, + 'scan_pallet_no' => null, + 'scan_locator_no' => null, + 'pallet_quantity' => null, + 'created_by' => $operatorName, + 'updated_by' => $operatorName, + ]); } else { Notification::make() ->title("No matching pallet found or locator number already empty.") ->danger() + ->duration(1200) ->send(); - $this->dispatch('loadLocator' ,'',$plantId); - $this->form->fill - ([ - 'plant_id' => $plantId, - 'scan_serial_no' => null, - 'scan_pallet_no' => $palletNo, - 'scan_locator_no' => $scanLocator, - 'pallet_quantity' => 0, - 'created_by' => $operatorName, - 'scanned_by' => $operatorName, - ]); - return; + + $this->dispatch('loadLocator' ,'',$plantId); + $this->form->fill + ([ + 'plant_id' => $plantId, + 'scan_serial_no' => null, + 'scan_pallet_no' => $palletNo, + 'scan_locator_no' => $scanLocator, + 'pallet_quantity' => 0, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, + ]); + return; } } else { - if ($serialNo == '' || $serialNo == null) { + if ($serialNo == '' || $serialNo == null) + { Notification::make() ->title("Serial number is required to remove when pallet number is empty.") ->danger() + ->duration(1200) ->send(); - $this->dispatch('loadLocator' ,'',$plantId); - $this->form->fill - ([ - 'plant_id' => $plantId, - 'scan_serial_no' => $serialNo, - 'scan_pallet_no' => null, - 'scan_locator_no' => $scanLocator, - 'pallet_quantity' => 0, - 'created_by' => $operatorName, - 'scanned_by' => $operatorName, - ]); + + $this->dispatch('loadLocator' ,'',$plantId); + $this->form->fill + ([ + 'plant_id' => $plantId, + 'scan_serial_no' => $serialNo, + 'scan_pallet_no' => null, + 'scan_locator_no' => $scanLocator, + 'pallet_quantity' => 0, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, + ]); return; } - - if (strlen($serialNo) < 13) + else if (strlen($serialNo) < 9) { Notification::make() - ->title("Serial number '$serialNo' must be at least 13 digits.") + ->title("Serial number '$serialNo' must be at least 9 digits.") ->danger() + ->duration(1200) ->send(); + $this->dispatch('loadLocator' ,'',$plantId); $this->form->fill ([ @@ -1621,13 +1747,14 @@ class LocatorValidation extends Page implements HasForms ]); return; } - - if (!ctype_alnum($serialNo)) + else if (!ctype_alnum($serialNo)) { Notification::make() ->title("Serial number '$serialNo' must contain alpha-numeric values only.") ->danger() + ->duration(1200) ->send(); + $this->dispatch('loadLocator' ,'',$plantId); $this->form->fill ([ @@ -1654,19 +1781,21 @@ class LocatorValidation extends Page implements HasForms Notification::make() ->title("Serial number '$serialNo' already exists in invoice number '$invoiceNo' and completed the scanning process.") ->danger() + ->duration(1200) ->send(); - $this->dispatch('loadLocator' ,'',$plantId); - $this->form->fill - ([ - 'plant_id' => $plantId, - 'scan_serial_no' => $serialNo, - 'scan_pallet_no' => null, - 'scan_locator_no' => $scanLocator, - 'pallet_quantity' => 0, - 'created_by' => $operatorName, - 'scanned_by' => $operatorName, - ]); - return; + + $this->dispatch('loadLocator' ,'',$plantId); + $this->form->fill + ([ + 'plant_id' => $plantId, + 'scan_serial_no' => $serialNo, + 'scan_pallet_no' => null, + 'scan_locator_no' => $scanLocator, + 'pallet_quantity' => 0, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, + ]); + return; } $exists = PalletValidation::where('serial_number', $serialNo) @@ -1677,18 +1806,20 @@ class LocatorValidation extends Page implements HasForms Notification::make() ->title("Serial number '{$serialNo}' does not exist in the pallet table to remove.") ->danger() + ->duration(1200) ->send(); - $this->dispatch('loadLocator' ,'',$plantId); - $this->form->fill - ([ - 'plant_id' => $plantId, - 'scan_serial_no' => $serialNo, - 'scan_pallet_no' => null, - 'scan_locator_no' => $scanLocator, - 'pallet_quantity' => 0, - 'created_by' => $operatorName, - 'scanned_by' => $operatorName, - ]); + + $this->dispatch('loadLocator' ,'',$plantId); + $this->form->fill + ([ + 'plant_id' => $plantId, + 'scan_serial_no' => $serialNo, + 'scan_pallet_no' => null, + 'scan_locator_no' => $scanLocator, + 'pallet_quantity' => 0, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, + ]); return; } @@ -1702,18 +1833,20 @@ class LocatorValidation extends Page implements HasForms Notification::make() ->title("Serial number '{$serialNo}' already exists in pallet number '$existsInPallet->pallet_number'.") ->danger() + ->duration(1200) ->send(); - $this->dispatch('loadLocator' ,'',$plantId); - $this->form->fill - ([ - 'plant_id' => $plantId, - 'scan_serial_no' => $serialNo, - 'scan_pallet_no' => null, - 'scan_locator_no' => $scanLocator, - 'pallet_quantity' => 0, - 'created_by' => $operatorName, - 'scanned_by' => $operatorName, - ]); + + $this->dispatch('loadLocator' ,'',$plantId); + $this->form->fill + ([ + 'plant_id' => $plantId, + 'scan_serial_no' => $serialNo, + 'scan_pallet_no' => null, + 'scan_locator_no' => $scanLocator, + 'pallet_quantity' => 0, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, + ]); return; } @@ -1727,18 +1860,20 @@ class LocatorValidation extends Page implements HasForms Notification::make() ->title("Serial number '{$serialNo}' exist in the locator number '$existsInPallet->locator_number'.
Scan the valid locator number to remove serial number.") ->danger() + ->duration(1200) ->send(); - $this->dispatch('loadLocator' ,'',$plantId); - $this->form->fill - ([ - 'plant_id' => $plantId, - 'scan_serial_no' => $serialNo, - 'scan_pallet_no' => null, - 'scan_locator_no' => $scanLocator, - 'pallet_quantity' => 0, - 'created_by' => $operatorName, - 'scanned_by' => $operatorName, - ]); + + $this->dispatch('loadLocator' ,'',$plantId); + $this->form->fill + ([ + 'plant_id' => $plantId, + 'scan_serial_no' => $serialNo, + 'scan_pallet_no' => null, + 'scan_locator_no' => $scanLocator, + 'pallet_quantity' => 0, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, + ]); return; } @@ -1755,6 +1890,7 @@ class LocatorValidation extends Page implements HasForms Notification::make() ->title("Scanned serial number '{$serialNo}' removed from locator number '$scanLocator' successfully.") ->success() + ->duration(1000) ->send(); $this->dispatch('loadLocator', $scanLocator, $plantId); @@ -1773,19 +1909,21 @@ class LocatorValidation extends Page implements HasForms Notification::make() ->title("No matching record found for serial number '{$serialNo}'.") ->danger() + ->duration(1200) ->send(); - $this->dispatch('loadLocator' ,'',$plantId); - $this->form->fill - ([ - 'plant_id' => $plantId, - 'scan_serial_no' => $serialNo, - 'scan_pallet_no' => null, - 'scan_locator_no' => $scanLocator, - 'pallet_quantity' => 0, - 'created_by' => $operatorName, - 'scanned_by' => $operatorName, - ]); - return; + + $this->dispatch('loadLocator' ,'',$plantId); + $this->form->fill + ([ + 'plant_id' => $plantId, + 'scan_serial_no' => $serialNo, + 'scan_pallet_no' => null, + 'scan_locator_no' => $scanLocator, + 'pallet_quantity' => 0, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, + ]); + return; } } } @@ -1799,5 +1937,4 @@ class LocatorValidation extends Page implements HasForms { return Auth::check() && Auth::user()->can('create locator validation page'); } - } diff --git a/app/Filament/Pages/PalletFromLocator.php b/app/Filament/Pages/PalletFromLocator.php index cdf825f9a..391006c89 100644 --- a/app/Filament/Pages/PalletFromLocator.php +++ b/app/Filament/Pages/PalletFromLocator.php @@ -93,6 +93,7 @@ class PalletFromLocator extends Page implements HasForms TextInput::make('scan_locator_number') ->label('Scan Locator Number') ->reactive() + ->minLength(7) ->columnSpan(1) ->readOnly(fn (callable $get) => !$get('plant') || $get('scan_serial_number') || $get('scan_remove_sno')) ->extraAttributes([ @@ -101,6 +102,7 @@ class PalletFromLocator extends Page implements HasForms TextInput::make('scan_serial_number') ->label('Scan Serial Number') ->reactive() + ->minLength(9) ->columnSpan(1) ->readOnly(fn (callable $get) => !$get('plant') || $get('scan_locator_number') || $get('scan_remove_sno')) ->extraAttributes([ @@ -109,6 +111,7 @@ class PalletFromLocator extends Page implements HasForms TextInput::make('scan_remove_sno') ->label('Remove Serial Number') ->reactive() + ->minLength(9) ->columnSpan(1) ->readOnly(fn (callable $get) => !$get('plant') || $get('scan_locator_number') || $get('scan_serial_number') || count($this->records) <= 0) ->extraAttributes([ @@ -141,8 +144,9 @@ class PalletFromLocator extends Page implements HasForms Notification::make() ->title('Press enter on "Scan Serial Number" field to proceed..!') ->danger() - ->seconds(2) + ->duration(1200) ->send(); + $this->dispatch('loadData', $this->records, $plantId); $this->form->fill([ 'plant_id' => $plantId, @@ -159,8 +163,9 @@ class PalletFromLocator extends Page implements HasForms Notification::make() ->title('Press enter on "Remove Serial Number" field to proceed..!') ->danger() - ->seconds(2) + ->duration(1200) ->send(); + $this->dispatch('loadData', $this->records, $plantId); $this->form->fill([ 'plant_id' => $plantId, @@ -179,8 +184,9 @@ class PalletFromLocator extends Page implements HasForms ->title('Invalid: Locator Number') ->body("Locator number can't be empty!") ->danger() - ->seconds(3) + ->duration(1200) ->send(); + $this->dispatch('loadData', $this->records, $plantId); $this->form->fill([ 'plant_id' => $plantId, @@ -198,8 +204,9 @@ class PalletFromLocator extends Page implements HasForms ->title('Invalid: Locator Number') ->body("Locator number '$locatorNo' must be at least 7 digits.") ->danger() - ->seconds(3) + ->duration(1200) ->send(); + $this->dispatch('loadData', $this->records, $plantId); $this->form->fill([ 'plant_id' => $plantId, @@ -222,8 +229,9 @@ class PalletFromLocator extends Page implements HasForms ->title('Unknown: Locator Number') ->body("Locator number '$locatorNo' does not exist in the master.") ->danger() - ->seconds(3) + ->duration(1200) ->send(); + $this->dispatch('loadData', $this->records, $plantId); $this->form->fill([ 'plant_id' => $plantId, @@ -254,8 +262,9 @@ class PalletFromLocator extends Page implements HasForms ->body("Scanned locator number '$locatorNo' does not have any locator serial numbers to store into the pallet.
Please scan a valid stored locator number to proceed.") ->danger() - ->seconds(3) + ->duration(1200) ->send(); + $this->dispatch('loadData', $this->records, $plantId); $this->form->fill([ 'plant_id' => $plantId, @@ -273,8 +282,9 @@ class PalletFromLocator extends Page implements HasForms ->title('Add: Locator Serial Numbers') ->body("Scanned locator number '$locatorNo' has '".$serialLocator->count()."' locator serial numbers!
Do you want to store it into 'PALLET DATA' table?") ->info() - ->seconds(2) + ->duration(2000) ->send(); + $this->dispatch('open-confirm-modal', locatorNo: $locatorNo, plantId: $plantId); } } @@ -389,7 +399,7 @@ class PalletFromLocator extends Page implements HasForms ->title('Add: Locator Serial Number') ->body("Scanned locator serial number '$serialNo' successfully added into 'PALLET DATA' table.") ->success() - ->seconds(3) + ->duration(1000) ->send(); $this->dispatch('loadData', $this->records, $plantId); @@ -412,7 +422,7 @@ class PalletFromLocator extends Page implements HasForms ->title('Remove: Locator Serial Number') ->body("Scanned locator serial number '$removeserial' removed successfully from 'PALLET DATA' table.") ->success() - ->seconds(3) + ->duration(1000) ->send(); $this->dispatch('loadData', $this->records, $plantId); @@ -451,8 +461,9 @@ class PalletFromLocator extends Page implements HasForms ->title('Add: Locator Serial Numbers') ->body("Scanned locator number '$locatorNo' has '$serialLocator' locator serial numbers!
Successfully added into 'PALLET DATA' table.") ->success() - ->seconds(3) + ->duration(1000) ->send(); + $this->dispatch('loadData', $this->records, $plantId); $this->form->fill([ 'plant_id' => $plantId, @@ -471,8 +482,9 @@ class PalletFromLocator extends Page implements HasForms ->title('Skipped: Locator Number') ->body('Scan the new locator number to proceed..!') ->info() - ->seconds(3) + ->duration(2000) ->send(); + $this->dispatch('loadData', $this->records, $plantId); $this->form->fill([ 'plant_id' => $plantId, @@ -501,8 +513,9 @@ class PalletFromLocator extends Page implements HasForms Notification::make() ->title('Press enter on "Scan Locator Number" field to proceed..!') ->danger() - ->seconds(2) + ->duration(1200) ->send(); + $this->dispatch('loadData', $this->records, $plantId); $this->form->fill([ 'plant_id' => $plantId, @@ -519,8 +532,9 @@ class PalletFromLocator extends Page implements HasForms Notification::make() ->title('Press enter on "Remove Serial Number" field to proceed..!') ->danger() - ->seconds(2) + ->duration(1200) ->send(); + $this->dispatch('loadData', $this->records, $plantId); $this->form->fill([ 'plant_id' => $plantId, @@ -539,8 +553,9 @@ class PalletFromLocator extends Page implements HasForms ->title('Invalid: Serial Number') ->body("Serial number can't be empty!") ->danger() - ->seconds(3) + ->duration(1200) ->send(); + $this->dispatch('loadData', $this->records, $plantId); $this->form->fill([ 'plant_id' => $plantId, @@ -552,14 +567,15 @@ class PalletFromLocator extends Page implements HasForms ]); return; } - else if (strlen($serialNo) < 13) + else if (strlen($serialNo) < 9) { Notification::make() ->title('Invalid: Serial Number') - ->body("Serial number '$serialNo' must be at least 13 digits.") + ->body("Serial number '$serialNo' must be at least 9 digits.") ->danger() - ->seconds(3) + ->duration(1200) ->send(); + $this->dispatch('loadData', $this->records, $plantId); $this->form->fill([ 'plant_id' => $plantId, @@ -577,8 +593,9 @@ class PalletFromLocator extends Page implements HasForms ->title('Invalid: Serial Number') ->body("Serial number '$serialNo' must contain alpha-numeric values only.") ->danger() - ->seconds(3) + ->duration(1200) ->send(); + $this->dispatch('loadData', $this->records, $plantId); $this->form->fill([ 'plant_id' => $plantId, @@ -606,8 +623,9 @@ class PalletFromLocator extends Page implements HasForms ->title('Unknown: Serial Number') ->body("Scanned serial number: '$serialNo' doesn't exist in pallet table.
Scan the valid exist locator-serial number to proceed..!") ->danger() - ->seconds(3) + ->duration(1200) ->send(); + $this->dispatch('loadData', $this->records, $plantId); $this->form->fill([ 'plant_id' => $plantId, @@ -625,8 +643,9 @@ class PalletFromLocator extends Page implements HasForms ->title('Invalid: Serial Number') ->body("Scanned serial number: '$serialNo' already exist in pallet number '".$serialLocator->pallet_number."'.
Scan the valid locator-serial number to proceed..!") ->danger() - ->seconds(3) + ->duration(1200) ->send(); + $this->dispatch('loadData', $this->records, $plantId); $this->form->fill([ 'plant_id' => $plantId, @@ -657,8 +676,9 @@ class PalletFromLocator extends Page implements HasForms ->title('Locator Serials Not Found') ->body("Add some locator serial numbers to proceed generate pallet..!") ->danger() - ->seconds(3) + ->duration(1200) ->send(); + $this->dispatch('loadData', $this->records, $plantId); $this->form->fill([ 'plant_id' => $plantId, @@ -750,8 +770,9 @@ class PalletFromLocator extends Page implements HasForms ->title('Success: Pallet Generated') ->body("Pallet number '$newPalletNumber' completed the master packing successfully!") ->success() - ->seconds(3) + ->duration(1000) ->send(); + $this->dispatch('loadData', $this->records, $plantId); $this->form->fill([ 'plant_id' => $plantId, @@ -770,8 +791,9 @@ class PalletFromLocator extends Page implements HasForms ->title('Failed: Pallet Generated') ->body("No locator serial number records found to generate pallet..!") ->danger() - ->seconds(3) + ->duration(1200) ->send(); + $this->dispatch('loadData', $this->records, $plantId); $this->form->fill([ 'plant_id' => $plantId, @@ -800,6 +822,7 @@ class PalletFromLocator extends Page implements HasForms // ->title('Pallet Generated') // ->body("Pallet number {$this->latestPalletNumber} assigned to all serials for locator {$locatorNo}") // ->success() + // ->duration(1000) // ->send(); // $this->dispatch('loadData', $this->records, $plantId); // $this->form->fill([ @@ -828,8 +851,9 @@ class PalletFromLocator extends Page implements HasForms Notification::make() ->title('Press enter on "Scan Locator Number" field to proceed..!') ->danger() - ->seconds(2) + ->duration(1200) ->send(); + $this->dispatch('loadData', $this->records, $plantId); $this->form->fill([ 'plant_id' => $plantId, @@ -846,8 +870,9 @@ class PalletFromLocator extends Page implements HasForms Notification::make() ->title('Press enter on "Scan Serial Number" field to proceed..!') ->danger() - ->seconds(2) + ->duration(1200) ->send(); + $this->dispatch('loadData', $this->records, $plantId); $this->form->fill([ 'plant_id' => $plantId, @@ -866,8 +891,9 @@ class PalletFromLocator extends Page implements HasForms ->title('Invalid: Serial Number') ->body("Serial number can't be empty!") ->danger() - ->seconds(3) + ->duration(1200) ->send(); + $this->dispatch('loadData', $this->records, $plantId); $this->form->fill([ 'plant_id' => $plantId, @@ -879,14 +905,15 @@ class PalletFromLocator extends Page implements HasForms ]); return; } - else if (strlen($removeSno) < 13) + else if (strlen($removeSno) < 9) { Notification::make() ->title('Invalid: Serial Number') - ->body("Serial number '$removeSno' must be at least 13 digits.") + ->body("Serial number '$removeSno' must be at least 9 digits.") ->danger() - ->seconds(3) + ->duration(1200) ->send(); + $this->dispatch('loadData', $this->records, $plantId); $this->form->fill([ 'plant_id' => $plantId, @@ -904,8 +931,9 @@ class PalletFromLocator extends Page implements HasForms ->title('Invalid: Serial Number') ->body("Serial number '$removeSno' must contain alpha-numeric values only.") ->danger() - ->seconds(3) + ->duration(1200) ->send(); + $this->dispatch('loadData', $this->records, $plantId); $this->form->fill([ 'plant_id' => $plantId, @@ -936,8 +964,9 @@ class PalletFromLocator extends Page implements HasForms ->title('Unknown: Serial Number') ->body("Scanned serial number: '$removeSno' doesn't exist in 'PALLET DATA' table.
Scan the valid exist locator-serial number to proceed..!") ->danger() - ->seconds(3) + ->duration(1200) ->send(); + $this->dispatch('loadData', $this->records, $plantId); $this->form->fill([ 'plant_id' => $plantId, diff --git a/app/Filament/Pages/UploadSerialLocator.php b/app/Filament/Pages/UploadSerialLocator.php index 95b1a791b..add0fd9b8 100644 --- a/app/Filament/Pages/UploadSerialLocator.php +++ b/app/Filament/Pages/UploadSerialLocator.php @@ -69,6 +69,7 @@ class UploadSerialLocator extends Page implements HasForms TextInput::make('scan_serial_number') ->label('Scan Serial Number') ->reactive() + ->minLength(9) ->readOnly(fn (callable $get) => !$get('plant_id')) ->afterStateUpdated(function ($state, callable $set, callable $get) { $plantId = $get('plant_id'); @@ -82,6 +83,7 @@ class UploadSerialLocator extends Page implements HasForms TextInput::make('scan_locator') ->label('Scan Locator Number') ->reactive() + ->minLength(7) ->readOnly(fn (callable $get) => !$get('plant_id')) ->afterStateUpdated(function ($state, callable $set, callable $get) { $plantId = $get('plant_id'); @@ -122,12 +124,13 @@ class UploadSerialLocator extends Page implements HasForms $userName = Filament::auth()->user()->name; - if($plantId == '' || $plantId == null) + if ($plantId == '' || $plantId == null) { Notification::make() - ->title('Please select a plant first.') - ->danger() - ->send(); + ->title('Please select a plant first.') + ->danger() + ->duration(1200) + ->send(); $this->dispatch('loadData', '', '', 0); $this->form->fill @@ -148,7 +151,9 @@ class UploadSerialLocator extends Page implements HasForms Notification::make() ->title('Please upload a file!') ->danger() + ->duration(1200) ->send(); + $this->dispatch('loadData', '', '', 0); $this->form->fill ([ @@ -168,9 +173,11 @@ class UploadSerialLocator extends Page implements HasForms { Notification::make() ->title('Choose a proper Excel file') - ->danger() ->body('The file must be an Excel file (xlsx, xls, csv).') + ->danger() + ->duration(1200) ->send(); + $this->dispatch('loadData', '', '', 0); $this->form->fill ([ @@ -190,7 +197,9 @@ class UploadSerialLocator extends Page implements HasForms Notification::make() ->title('File not found after upload!') ->danger() + ->duration(1200) ->send(); + $this->dispatch('loadData', '', '', 0); $this->form->fill ([ @@ -218,64 +227,67 @@ class UploadSerialLocator extends Page implements HasForms $invalidSerial = []; $invalidLocator = []; - foreach (array_slice($rows, 1) as $row) { - $serialNumber = $row[0] ?? null; - $locator = $row[1] ?? null; + foreach (array_slice($rows, 1) as $row) { + $serialNumber = $row[0] ?? null; + $locator = $row[1] ?? null; - if ($serialNumber) - { - $excelSerials[] = $serialNumber; - if (strlen($serialNumber) < 13) { - $invalidSerial[] = $serialNumber; - } elseif (!ctype_alnum($serialNumber)) { - $invalidSerial[] = $serialNumber; - } - } - - if ($locator) { - $excelLocators[] = $locator; - if (strlen($locator) > 7) { - $invalidLocator[] = $locator; - } + if ($serialNumber) + { + $excelSerials[] = $serialNumber; + if (strlen($serialNumber) < 9) { + $invalidSerial[] = $serialNumber; + } elseif (!ctype_alnum($serialNumber)) { + $invalidSerial[] = $serialNumber; } } - $uniqueInvalidSerial = array_unique($invalidSerial); - $uniqueInvalidLocator = array_unique($invalidLocator); - - if (count($uniqueInvalidSerial) > 0) { - Notification::make() - ->title('Invalid Serial Numbers Found') - ->body('The following serial numbers are invalid, length should contain minimum of 13 digits alpha numeric values:
' . implode(', ', $uniqueInvalidSerial)) - ->danger() - ->send(); - $this->dispatch('loadData', '', '', 0); - $this->form->fill - ([ - 'plant_id' => $plantId, - 'scan_serial_number' => null, - 'scan_locator' => null, - 'upload_serial_locator' => null, - ]); - return; + if ($locator) { + $excelLocators[] = $locator; + if (strlen($locator) < 7) { + $invalidLocator[] = $locator; + } } + } - if (count($uniqueInvalidLocator) > 0) { - Notification::make() - ->title('Invalid Locator Numbers Found') - ->body('The following locator numbers are invalid, length should contain minimum of 13 digits alpha numeric values:
' . implode(', ', $uniqueInvalidLocator)) - ->danger() - ->send(); - $this->dispatch('loadData', '', '', 0); - $this->form->fill - ([ - 'plant_id' => $plantId, - 'scan_serial_number' => null, - 'scan_locator' => null, - 'upload_serial_locator' => null, - ]); - return; - } + $uniqueInvalidSerial = array_unique($invalidSerial); + if (count($uniqueInvalidSerial) > 0) { + Notification::make() + ->title('Invalid Serial Numbers Found') + ->body('The following serial numbers are invalid, length should contain minimum of 9 digits alpha numeric values:
' . implode(', ', $uniqueInvalidSerial)) + ->danger() + ->duration(1200) + ->send(); + + $this->dispatch('loadData', '', '', 0); + $this->form->fill + ([ + 'plant_id' => $plantId, + 'scan_serial_number' => null, + 'scan_locator' => null, + 'upload_serial_locator' => null, + ]); + return; + } + + $uniqueInvalidLocator = array_unique($invalidLocator); + if (count($uniqueInvalidLocator) > 0) { + Notification::make() + ->title('Invalid Locator Numbers Found') + ->body('The following locator numbers are invalid, length should contain minimum of 7 digits alpha numeric values:
' . implode(', ', $uniqueInvalidLocator)) + ->danger() + ->duration(1200) + ->send(); + + $this->dispatch('loadData', '', '', 0); + $this->form->fill + ([ + 'plant_id' => $plantId, + 'scan_serial_number' => null, + 'scan_locator' => null, + 'upload_serial_locator' => null, + ]); + return; + } // foreach (array_slice($rows, 1) as $row) // { @@ -298,7 +310,9 @@ class UploadSerialLocator extends Page implements HasForms ->title('Duplicate Serial Numbers in Excel') ->body('The following serial numbers are duplicated in the file:
' . implode(', ', $duplicates)) ->danger() + ->duration(1200) ->send(); + $this->dispatch('loadData', '', '', 0); $this->form->fill ([ @@ -310,8 +324,6 @@ class UploadSerialLocator extends Page implements HasForms return; } - - $excelLocators = array_unique($excelLocators); $locatorsWithQuantityTwo = Locator::whereIn('locator_number', $excelLocators) ->where('plant_id',$plantId) @@ -324,7 +336,9 @@ class UploadSerialLocator extends Page implements HasForms ->title('Locators with Insufficient Space') ->body('The following locators does not have space:
' . implode(', ', $locatorsWithQuantityTwo)) ->warning() + ->duration(1200) ->send(); + $this->dispatch('open-confirm-modal', locatorNo: $locator, plantId: $plantId); return; } @@ -342,7 +356,9 @@ class UploadSerialLocator extends Page implements HasForms ->title('Duplicate Serial Numbers Found') ->body('The following serial numbers already exist and cannot be imported:
' . implode(', ', $existingSerials)) ->danger() + ->duration(1200) ->send(); + $this->dispatch('open-confirm-serial', locatorNo: $locator, plantId: $plantId); return; } @@ -384,7 +400,9 @@ class UploadSerialLocator extends Page implements HasForms ->title('Serial Locators imported successfully!') ->body("{$insertedCount} locator serial number(s) have been imported.") ->success() + ->duration(1000) ->send(); + $this->dispatch('loadData', '', '', 0); $this->form->fill ([ @@ -401,7 +419,9 @@ class UploadSerialLocator extends Page implements HasForms ->title('Serial Locators imported Failed!') ->body('No new serial number(s) found in the uploaded excel file..!') ->danger() + ->duration(1200) ->send(); + $this->dispatch('loadData', '', '', 0); $this->form->fill ([ @@ -420,12 +440,13 @@ class UploadSerialLocator extends Page implements HasForms $userName = Filament::auth()->user()->name; - if($plantId == '' || $plantId == null) + if ($plantId == '' || $plantId == null) { Notification::make() - ->title('Please select a plant first.') - ->danger() - ->send(); + ->title('Please select a plant first.') + ->danger() + ->duration(1200) + ->send(); $this->dispatch('loadData', '', '', 0); $this->form->fill @@ -446,7 +467,9 @@ class UploadSerialLocator extends Page implements HasForms Notification::make() ->title('Please upload a file!') ->danger() + ->duration(1200) ->send(); + $this->dispatch('loadData', '', '', 0); $this->form->fill ([ @@ -466,9 +489,11 @@ class UploadSerialLocator extends Page implements HasForms { Notification::make() ->title('Choose a proper Excel file') - ->danger() ->body('The file must be an Excel file (xlsx, xls, csv).') + ->danger() + ->duration(1200) ->send(); + $this->dispatch('loadData', '', '', 0); $this->form->fill ([ @@ -488,15 +513,17 @@ class UploadSerialLocator extends Page implements HasForms Notification::make() ->title('File not found after upload!') ->danger() + ->duration(1200) ->send(); + $this->dispatch('loadData', '', '', 0); $this->form->fill - ([ - 'plant_id' => $plantId, - 'scan_serial_number' => null, - 'scan_locator' => null, - 'upload_serial_locator' => null, - ]); + ([ + 'plant_id' => $plantId, + 'scan_serial_number' => null, + 'scan_locator' => null, + 'upload_serial_locator' => null, + ]); return; } @@ -544,8 +571,9 @@ class UploadSerialLocator extends Page implements HasForms ->title('Duplicate Serial Numbers Found') ->body('The following serial numbers already exist and cannot be imported: ' . implode(', ', $existingSerials)) ->danger() - ->seconds(10) + ->duration(1200) ->send(); + $this->dispatch('open-confirm-serial', locatorNo: $locator, plantId: $plantId); return; } @@ -587,7 +615,9 @@ class UploadSerialLocator extends Page implements HasForms ->title('Serial Locators imported successfully!') ->body("{$insertedCount} locator serial number(s) have been imported.") ->success() + ->duration(1000) ->send(); + $this->dispatch('loadData', '', '', 0); $this->form->fill ([ @@ -604,7 +634,9 @@ class UploadSerialLocator extends Page implements HasForms ->title('Serial Locators imported Failed!') ->body('No new serial number(s) found in the uploaded excel file..!') ->danger() + ->duration(1200) ->send(); + $this->dispatch('loadData', '', '', 0); $this->form->fill ([ @@ -636,12 +668,13 @@ class UploadSerialLocator extends Page implements HasForms $userName = Filament::auth()->user()->name; - if($plantId == '' || $plantId == null) + if ($plantId == '' || $plantId == null) { Notification::make() - ->title('Please select a plant first.') - ->danger() - ->send(); + ->title('Please select a plant first.') + ->danger() + ->duration(1200) + ->send(); $this->dispatch('loadData', '', '', 0); $this->form->fill @@ -662,7 +695,9 @@ class UploadSerialLocator extends Page implements HasForms Notification::make() ->title('Please upload a file!') ->danger() + ->duration(1200) ->send(); + $this->dispatch('loadData', '', '', 0); $this->form->fill ([ @@ -682,9 +717,11 @@ class UploadSerialLocator extends Page implements HasForms { Notification::make() ->title('Choose a proper Excel file') - ->danger() ->body('The file must be an Excel file (xlsx, xls, csv).') + ->danger() + ->duration(1200) ->send(); + $this->dispatch('loadData', '', '', 0); $this->form->fill ([ @@ -704,7 +741,9 @@ class UploadSerialLocator extends Page implements HasForms Notification::make() ->title('File not found after upload!') ->danger() + ->duration(1200) ->send(); + $this->dispatch('loadData', '', '', 0); $this->form->fill ([ @@ -789,7 +828,9 @@ class UploadSerialLocator extends Page implements HasForms ->title('Serial Locators imported successfully!') ->body("{$insertedCount} locator serial number(s) have been imported.") ->success() + ->duration(1000) ->send(); + $this->dispatch('loadData', '', '', 0); $this->form->fill ([ @@ -804,7 +845,9 @@ class UploadSerialLocator extends Page implements HasForms ->title('Serial Locators imported Failed!') ->body('No new serial number(s) found in the uploaded excel file..!') ->danger() + ->duration(1200) ->send(); + $this->dispatch('loadData', '', '', 0); $this->form->fill ([ @@ -822,12 +865,12 @@ class UploadSerialLocator extends Page implements HasForms $plantId = $this->filters['plant_id'] ?? null; $this->dispatch('loadData', '', '', 0); $this->form->fill - ([ - 'plant_id' => $plantId, - 'scan_serial_number' => null, - 'scan_locator' => null, - 'upload_serial_locator' => null, - ]); + ([ + 'plant_id' => $plantId, + 'scan_serial_number' => null, + 'scan_locator' => null, + 'upload_serial_locator' => null, + ]); } public function addLocator() @@ -839,9 +882,10 @@ class UploadSerialLocator extends Page implements HasForms if ($plantId == '' || $plantId == null) { Notification::make() - ->title('Please select a plant first.') - ->danger() - ->send(); + ->title('Please select a plant first.') + ->danger() + ->duration(1200) + ->send(); $this->dispatch('loadData', '', '', 0); $this->form->fill @@ -854,12 +898,14 @@ class UploadSerialLocator extends Page implements HasForms return; } - if(!$scanSno && !$scanLocator) + if (!$scanSno && !$scanLocator) { Notification::make() - ->title('Please enter serial number and locator number to add data.') - ->danger() - ->send(); + ->title('Please enter serial number and locator number to add data.') + ->danger() + ->duration(1200) + ->send(); + $this->dispatch('loadData', $scanLocator, $scanSno, $plantId); $this->form->fill ([ @@ -871,12 +917,50 @@ class UploadSerialLocator extends Page implements HasForms return; } - if(!$scanSno) + if (!$scanSno) { Notification::make() - ->title('Please enter serial number to add data.') - ->danger() - ->send(); + ->title('Please enter serial number to add data.') + ->danger() + ->duration(1200) + ->send(); + + $this->dispatch('loadData', $scanLocator, $scanSno, $plantId); + $this->form->fill + ([ + 'plant_id' => $plantId, + 'scan_serial_number' => $scanSno, + 'scan_locator' => $scanLocator, + 'upload_serial_locator' => null, + ]); + return; + } + else if (strlen($scanSno) < 9) + { + Notification::make() + ->title("Serial number '$scanSno' must be at least 9 digits.") + ->danger() + ->duration(1200) + ->send(); + + $this->dispatch('loadData', $scanLocator, $scanSno, $plantId); + $this->form->fill + ([ + 'plant_id' => $plantId, + 'scan_serial_number' => $scanSno, + 'scan_locator' => $scanLocator, + 'upload_serial_locator' => null, + ]); + return; + } + else if (!ctype_alnum($scanSno)) + { + Notification::make() + ->title('Serial number must contain alpha-numeric values only.') + ->danger() + ->duration(1200) + ->send(); + $this->dispatch('loadData', $scanLocator, $scanSno, $plantId); $this->form->fill ([ @@ -888,45 +972,14 @@ class UploadSerialLocator extends Page implements HasForms return; } - if (strlen($scanSno) < 13) + if (!$scanLocator) { Notification::make() - ->title("Serial number '$scanSno' must be at least 13 digits.") - ->danger() - ->send(); - $this->dispatch('loadData', $scanLocator, $scanSno, $plantId); - $this->form->fill - ([ - 'plant_id' => $plantId, - 'scan_serial_number' => $scanSno, - 'scan_locator' => $scanLocator, - 'upload_serial_locator' => null, - ]); - return; - } - if (!ctype_alnum($scanSno)) - { - Notification::make() - ->title('Serial number must contain alpha-numeric values only.') - ->danger() - ->send(); - $this->dispatch('loadData', $scanLocator, $scanSno, $plantId); - $this->form->fill - ([ - 'plant_id' => $plantId, - 'scan_serial_number' => $scanSno, - 'scan_locator' => $scanLocator, - 'upload_serial_locator' => null, - ]); - return; - } + ->title('Please enter locator number to add data.') + ->danger() + ->duration(1200) + ->send(); - if(!$scanLocator) - { - Notification::make() - ->title('Please enter locator number to add data.') - ->danger() - ->send(); $this->dispatch('loadData', $scanLocator, $scanSno, $plantId); $this->form->fill ([ @@ -937,12 +990,13 @@ class UploadSerialLocator extends Page implements HasForms ]); return; } - - if (strlen($scanLocator) < 7) { + else if (strlen($scanLocator) < 7) { Notification::make() - ->title("Locator number '$scanLocator' must be at least 7 digits.") - ->danger() - ->send(); + ->title("Locator number '$scanLocator' must be at least 7 digits.") + ->danger() + ->duration(1200) + ->send(); + $this->dispatch('loadData', $scanLocator, $scanSno, $plantId); $this->form->fill ([ @@ -955,15 +1009,17 @@ class UploadSerialLocator extends Page implements HasForms } $locator = Locator::where('locator_number', $scanLocator) - ->where('plant_id', $plantId) - ->first(); + ->where('plant_id', $plantId) + ->first(); if (!$locator) { Notification::make() ->title("Locator number '$scanLocator' does not exist in the master.") ->danger() + ->duration(1200) ->send(); + $this->dispatch('loadData', $scanLocator, $scanSno, $plantId); $this->form->fill ([ @@ -980,7 +1036,9 @@ class UploadSerialLocator extends Page implements HasForms Notification::make() ->title("No space available for locator number '{$scanLocator}'.") ->danger() + ->duration(1200) ->send(); + $this->dispatch('loadData', $scanLocator, $scanSno, $plantId); $this->form->fill ([ @@ -992,7 +1050,7 @@ class UploadSerialLocator extends Page implements HasForms return; } - if($scanSno && $scanLocator) + if ($scanSno && $scanLocator) { $palletRecord = PalletValidation::where('serial_number', $scanSno) ->where('plant_id', $plantId) @@ -1005,7 +1063,9 @@ class UploadSerialLocator extends Page implements HasForms Notification::make() ->title("Serial number '$scanSno' already exists in locator number '$palletRecord->locator_number'.") ->danger() + ->duration(1200) ->send(); + $this->dispatch('loadData', $scanLocator, $scanSno, $plantId); $this->form->fill ([ @@ -1021,7 +1081,9 @@ class UploadSerialLocator extends Page implements HasForms Notification::make() ->title("Serial number '$scanSno' already exists in pallet number '$palletRecord->pallet_number'.") ->danger() + ->duration(1200) ->send(); + $this->dispatch('loadData', $scanLocator, $scanSno, $plantId); $this->form->fill ([ @@ -1037,7 +1099,9 @@ class UploadSerialLocator extends Page implements HasForms Notification::make() ->title("Serial number '$scanSno' already exists in pallet number '$palletRecord->pallet_number' with locator number '$palletRecord->locator_number'.") ->warning() + ->duration(1200) ->send(); + $this->dispatch('loadData', $scanLocator, $scanSno, $plantId); $this->form->fill ([ @@ -1063,7 +1127,9 @@ class UploadSerialLocator extends Page implements HasForms Notification::make() ->title("Serial number '$scanSno' already exists in invoice number '$invoiceNo' and completed the scanning process.") ->danger() + ->duration(1200) ->send(); + $this->dispatch('loadData', $scanLocator, $scanSno, $plantId); $this->form->fill ([ @@ -1098,28 +1164,32 @@ class UploadSerialLocator extends Page implements HasForms Notification::make() ->title("Serial number '$scanSno' added into locator number '$scanLocator' successfully!") ->success() + ->duration(1000) ->send(); + $this->form->fill - ([ - 'plant_id' => $plantId, - 'scan_serial_number' => $scanSno, - 'scan_locator' => $scanLocator, - 'upload_serial_locator' => null, - ]); + ([ + 'plant_id' => $plantId, + 'scan_serial_number' => $scanSno, + 'scan_locator' => $scanLocator, + 'upload_serial_locator' => null, + ]); } else { Notification::make() ->title("Failed to add serial number '$scanSno' into locator number '$scanLocator'!") ->danger() + ->duration(1200) ->send(); + $this->form->fill - ([ - 'plant_id' => $plantId, - 'scan_serial_number' => $scanSno, - 'scan_locator' => $scanLocator, - 'upload_serial_locator' => null, - ]); + ([ + 'plant_id' => $plantId, + 'scan_serial_number' => $scanSno, + 'scan_locator' => $scanLocator, + 'upload_serial_locator' => null, + ]); } // Refresh the table to show the new record @@ -1137,9 +1207,10 @@ class UploadSerialLocator extends Page implements HasForms if ($plantId == '' || $plantId == null) { Notification::make() - ->title('Please select a plant first.') - ->danger() - ->send(); + ->title('Please select a plant first.') + ->danger() + ->duration(1200) + ->send(); $this->dispatch('loadData', '', '', 0); $this->form->fill @@ -1152,12 +1223,14 @@ class UploadSerialLocator extends Page implements HasForms return; } - if(!$scanSno && !$scanLocator) + if (!$scanSno && !$scanLocator) { Notification::make() - ->title('Please enter atleast a serial number or locator number to view data.') - ->danger() - ->send(); + ->title('Please enter atleast a serial number or locator number to view data.') + ->danger() + ->duration(1200) + ->send(); + $this->dispatch('loadData', $scanLocator, $scanSno, $plantId); $this->form->fill ([ @@ -1168,13 +1241,15 @@ class UploadSerialLocator extends Page implements HasForms ]); return; } - if($scanSno && $scanLocator) + else if ($scanSno && $scanLocator) { - if (strlen($scanSno) < 13) { + if (strlen($scanSno) < 9) { Notification::make() - ->title("Serial number '$scanSno' must be at least 13 digits.") + ->title("Serial number '$scanSno' must be at least 9 digits.") ->danger() + ->duration(1200) ->send(); + $this->dispatch('loadData', $scanLocator, $scanSno, $plantId); $this->form->fill ([ @@ -1185,13 +1260,32 @@ class UploadSerialLocator extends Page implements HasForms ]); return; } - - if (!ctype_alnum($scanSno)) + else if (!ctype_alnum($scanSno)) { Notification::make() ->title('Serial number must contain alpha-numeric values only.') ->danger() + ->duration(1200) ->send(); + + $this->dispatch('loadData', $scanLocator, $scanSno, $plantId); + $this->form->fill + ([ + 'plant_id' => $plantId, + 'scan_serial_number' => $scanSno, + 'scan_locator' => $scanLocator, + 'upload_serial_locator' => null, + ]); + return; + } + else if (strlen($scanLocator) < 7) + { + Notification::make() + ->title("Locator number '$scanLocator' must be at least 7 digits.") + ->danger() + ->duration(1200) + ->send(); + $this->dispatch('loadData', $scanLocator, $scanSno, $plantId); $this->form->fill ([ @@ -1203,24 +1297,17 @@ class UploadSerialLocator extends Page implements HasForms return; } - if (strlen($scanLocator) < 7) { - Notification::make() - ->title("Locator number '$scanLocator' must be at least 7 digits.") - ->danger() - ->send(); - $this->dispatch('loadData', $scanLocator, $scanSno, $plantId); - return; - } - $locator = Locator::where('locator_number', $scanLocator) - ->where('plant_id', $plantId) - ->first(); + ->where('plant_id', $plantId) + ->first(); if (!$locator) { Notification::make() ->title("Locator number '$scanLocator' does not exist in the master.") ->danger() + ->duration(1200) ->send(); + $this->dispatch('loadData', $scanLocator, $scanSno, $plantId); $this->form->fill ([ @@ -1244,7 +1331,9 @@ class UploadSerialLocator extends Page implements HasForms Notification::make() ->title("Serial number '$scanSno' exists in invoice number '$invoiceNo' and completed the scanning process.") ->danger() + ->duration(1200) ->send(); + $this->dispatch('loadData', $scanLocator, $scanSno, $plantId); $this->form->fill ([ @@ -1265,7 +1354,9 @@ class UploadSerialLocator extends Page implements HasForms Notification::make() ->title("Serial number '$scanSno' and locator number '$scanLocator' does not exist in pallet table.") ->danger() + ->duration(1200) ->send(); + $this->dispatch('loadData', $scanLocator, $scanSno, $plantId); $this->form->fill ([ @@ -1283,7 +1374,9 @@ class UploadSerialLocator extends Page implements HasForms Notification::make() ->title("Serial number '$scanSno' already exists in pallet number '$serialNumberExists->pallet_number' with locator number '$serialNumberExists->locator_number'.") ->danger() + ->duration(1200) ->send(); + $this->dispatch('loadData', $scanLocator, $scanSno, $plantId); $this->form->fill ([ @@ -1297,9 +1390,11 @@ class UploadSerialLocator extends Page implements HasForms else { Notification::make() - ->title("Serial number '$scanSno' exists in locator number '$serialNumberExists->locator_number'.") - ->success() - ->send(); + ->title("Serial number '$scanSno' exists in locator number '$serialNumberExists->locator_number'.") + ->success() + ->duration(1000) + ->send(); + $this->dispatch('loadData', $scanLocator, $scanSno, $plantId); $this->form->fill ([ @@ -1312,13 +1407,15 @@ class UploadSerialLocator extends Page implements HasForms } } } - else if($scanSno) + else if ($scanSno) { - if (strlen($scanSno) < 13) { + if (strlen($scanSno) < 9) { Notification::make() - ->title("Serial number '$scanSno' must be at least 13 digits.") + ->title("Serial number '$scanSno' must be at least 9 digits.") ->danger() + ->duration(1200) ->send(); + $this->dispatch('loadData', $scanLocator, $scanSno, $plantId); $this->form->fill ([ @@ -1329,13 +1426,14 @@ class UploadSerialLocator extends Page implements HasForms ]); return; } - - if (!ctype_alnum($scanSno)) + else if (!ctype_alnum($scanSno)) { Notification::make() ->title('Serial number must contain alpha-numeric values only.') ->danger() + ->duration(1200) ->send(); + $this->dispatch('loadData', $scanLocator, $scanSno, $plantId); $this->form->fill ([ @@ -1359,7 +1457,9 @@ class UploadSerialLocator extends Page implements HasForms Notification::make() ->title("Serial number '$scanSno' exists in locator number '$palletRecord->locator_number'.") ->success() + ->duration(1000) ->send(); + $this->dispatch('loadData', $scanLocator, $scanSno, $plantId); $this->form->fill ([ @@ -1375,7 +1475,9 @@ class UploadSerialLocator extends Page implements HasForms Notification::make() ->title("Serial number '$scanSno' already exists in pallet number '$palletRecord->pallet_number'.") ->danger() + ->duration(1200) ->send(); + $this->dispatch('loadData', $scanLocator, $scanSno, $plantId); $this->form->fill ([ @@ -1391,7 +1493,9 @@ class UploadSerialLocator extends Page implements HasForms Notification::make() ->title("Serial number '$scanSno' already exists in pallet number '$palletRecord->pallet_number' with locator number '$palletRecord->locator_number'.") ->danger() + ->duration(1200) ->send(); + $this->dispatch('loadData', $scanLocator, $scanSno, $plantId); $this->form->fill ([ @@ -1417,7 +1521,9 @@ class UploadSerialLocator extends Page implements HasForms Notification::make() ->title("Serial number '$scanSno' exists in invoice number '$invoiceNo' and completed the scanning process.") ->danger() + ->duration(1200) ->send(); + $this->dispatch('loadData', $scanLocator, $scanSno, $plantId); $this->form->fill ([ @@ -1433,7 +1539,9 @@ class UploadSerialLocator extends Page implements HasForms Notification::make() ->title("Serial number '$scanSno' does not exist in pallet table.") ->danger() + ->duration(1200) ->send(); + $this->dispatch('loadData', $scanLocator, $scanSno, $plantId); $this->form->fill ([ @@ -1446,13 +1554,15 @@ class UploadSerialLocator extends Page implements HasForms } } } - else if($scanLocator) + else if ($scanLocator) { if (strlen($scanLocator) < 7) { Notification::make() - ->title("Locator number '$scanLocator' must be at least 7 digits.") - ->danger() - ->send(); + ->title("Locator number '$scanLocator' must be at least 7 digits.") + ->danger() + ->duration(1200) + ->send(); + $this->dispatch('loadData', $scanLocator, $scanSno, $plantId); $this->form->fill ([ @@ -1465,14 +1575,16 @@ class UploadSerialLocator extends Page implements HasForms } $locator = Locator::where('locator_number', $scanLocator) - ->where('plant_id', $plantId) - ->first(); + ->where('plant_id', $plantId) + ->first(); if (!$locator) { Notification::make() ->title("Locator number '$scanLocator' does not exist in the master.") ->danger() + ->duration(1200) ->send(); + $this->dispatch('loadData', $scanLocator, $scanSno, $plantId); $this->form->fill ([ @@ -1485,13 +1597,15 @@ class UploadSerialLocator extends Page implements HasForms } $serialNumbernExists = PalletValidation::where('locator_number', $scanLocator) - ->where('plant_id', $plantId) - ->first(); + ->where('plant_id', $plantId) + ->first(); if (!$serialNumbernExists) { Notification::make() ->title("Locator number '$scanLocator' does not exist in pallet table.") ->danger() + ->duration(1200) ->send(); + $this->dispatch('loadData', $scanLocator, $scanSno, $plantId); $this->form->fill ([ @@ -1507,7 +1621,9 @@ class UploadSerialLocator extends Page implements HasForms Notification::make() ->title("Locator number '$scanLocator' exist in pallet table.") ->danger() + ->duration(1200) ->send(); + $this->dispatch('loadData', $scanLocator, $scanSno, $plantId); $this->form->fill ([ @@ -1531,9 +1647,10 @@ class UploadSerialLocator extends Page implements HasForms if ($plantId == '' || $plantId == null) { Notification::make() - ->title('Please select a plant first.') - ->danger() - ->send(); + ->title('Please select a plant first.') + ->danger() + ->duration(1200) + ->send(); $this->dispatch('loadData', '', '', 0); $this->form->fill @@ -1546,12 +1663,14 @@ class UploadSerialLocator extends Page implements HasForms return; } - if(!$scanSno && !$scanLocator) + if (!$scanSno && !$scanLocator) { Notification::make() - ->title('Please enter serial number and locator number to delete data.') - ->danger() - ->send(); + ->title('Please enter serial number and locator number to delete data.') + ->danger() + ->duration(1200) + ->send(); + $this->dispatch('loadData', $scanLocator, $scanSno, $plantId); $this->form->fill ([ @@ -1562,13 +1681,14 @@ class UploadSerialLocator extends Page implements HasForms ]); return; } - - if(!$scanSno) + else if (!$scanSno) { Notification::make() ->title('Please enter serial number to delete data.') ->danger() + ->duration(1200) ->send(); + $this->dispatch('loadData', $scanLocator, $scanSno, $plantId); $this->form->fill ([ @@ -1579,12 +1699,13 @@ class UploadSerialLocator extends Page implements HasForms ]); return; } - - if (strlen($scanSno) < 13) { + else if (strlen($scanSno) < 9) { Notification::make() - ->title("Serial number '$scanSno' must be at least 13 digits.") - ->danger() - ->send(); + ->title("Serial number '$scanSno' must be at least 9 digits.") + ->danger() + ->duration(1200) + ->send(); + $this->dispatch('loadData', $scanLocator, $scanSno, $plantId); $this->form->fill ([ @@ -1595,13 +1716,14 @@ class UploadSerialLocator extends Page implements HasForms ]); return; } - - if (!ctype_alnum($scanSno)) + else if (!ctype_alnum($scanSno)) { Notification::make() - ->title('Serial number must contain alpha-numeric values only.') - ->danger() - ->send(); + ->title('Serial number must contain alpha-numeric values only.') + ->danger() + ->duration(1200) + ->send(); + $this->dispatch('loadData', $scanLocator, $scanSno, $plantId); $this->form->fill ([ @@ -1612,13 +1734,14 @@ class UploadSerialLocator extends Page implements HasForms ]); return; } - - if(!$scanLocator) + else if (!$scanLocator) { Notification::make() - ->title('Please enter locator number to delete data.') - ->danger() - ->send(); + ->title('Please enter locator number to delete data.') + ->danger() + ->duration(1200) + ->send(); + $this->dispatch('loadData', $scanLocator, $scanSno, $plantId); $this->form->fill ([ @@ -1629,12 +1752,14 @@ class UploadSerialLocator extends Page implements HasForms ]); return; } - - if (strlen($scanLocator) < 7) { + else if (strlen($scanLocator) < 7) + { Notification::make() - ->title("Locator number '$scanLocator' must be at least 7 digits.") - ->danger() - ->send(); + ->title("Locator number '$scanLocator' must be at least 7 digits.") + ->danger() + ->duration(1200) + ->send(); + $this->dispatch('loadData', $scanLocator, $scanSno, $plantId); $this->form->fill ([ @@ -1647,13 +1772,14 @@ class UploadSerialLocator extends Page implements HasForms } $locator = Locator::where('locator_number', $scanLocator)->where('plant_id',$plantId)->first(); - if (!$locator) { Notification::make() ->title("Locator number '$scanLocator' does not exist in the master.") ->danger() + ->duration(1200) ->send(); + $this->dispatch('loadData', $scanLocator, $scanSno, $plantId); $this->form->fill ([ @@ -1666,9 +1792,9 @@ class UploadSerialLocator extends Page implements HasForms } $invoicesnoexists = LocatorInvoiceValidation::where('plant_id', $plantId) - ->where('serial_number', $scanSno) - ->where('scanned_status', '=','Scanned') - ->first(); + ->where('serial_number', $scanSno) + ->where('scanned_status', '=','Scanned') + ->first(); $invoiceNo = $invoicesnoexists?->invoice_number; @@ -1677,7 +1803,9 @@ class UploadSerialLocator extends Page implements HasForms Notification::make() ->title("Serial number '$scanSno' exists in invoice number '$invoiceNo' and completed the scanning process.") ->danger() + ->duration(1200) ->send(); + $this->dispatch('loadData', $scanLocator, $scanSno, $plantId); $this->form->fill ([ @@ -1696,12 +1824,14 @@ class UploadSerialLocator extends Page implements HasForms ->where('pallet_number', '!=',null) ->first(); - if($palletExists) + if ($palletExists) { Notification::make() - ->title("Serial number '$scanSno' already exists in pallet number '$palletExists->pallet_number'!
Please enter locator serial number to remove data.") - ->danger() - ->send(); + ->title("Serial number '$scanSno' already exists in pallet number '$palletExists->pallet_number'!
Please enter locator serial number to remove data.") + ->danger() + ->duration(1200) + ->send(); + $this->dispatch('loadData', $scanLocator, $scanSno, $plantId); $this->form->fill ([ @@ -1720,9 +1850,11 @@ class UploadSerialLocator extends Page implements HasForms if ($deleted) { Notification::make() - ->title("Serial number '$scanSno' removed from locator number '$scanLocator' successfully.") - ->success() - ->send(); + ->title("Serial number '$scanSno' removed from locator number '$scanLocator' successfully.") + ->success() + ->duration(1000) + ->send(); + $this->dispatch('loadData', '', '', $plantId); $this->form->fill ([ @@ -1736,10 +1868,12 @@ class UploadSerialLocator extends Page implements HasForms else { Notification::make() - ->title("Failed to remove serial number '$scanSno' from locator number '$scanLocator'!") - //->title("Serial number '{$scanSno}' and Locator number '{$scanLocator}' does not exist in pallet table.") - ->danger() - ->send(); + ->title("Failed to remove serial number '$scanSno' from locator number '$scanLocator'!") + //->title("Serial number '{$scanSno}' and Locator number '{$scanLocator}' does not exist in pallet table.") + ->danger() + ->duration(1200) + ->send(); + $this->dispatch('loadData', $scanLocator, $scanSno, $plantId); $this->form->fill ([