Updated validations and success durations and added serial_number maximum length should be 20 digit and clear field if invalid input

This commit is contained in:
dhanabalan
2025-07-11 18:23:52 +05:30
parent 9fa4c0dd49
commit 27524c4d62
11 changed files with 360 additions and 291 deletions

View File

@@ -3,6 +3,7 @@
namespace App\Filament\Pages;
use App\Models\Locator;
use App\Models\LocatorInvoiceValidation;
use App\Models\PalletValidation;
use App\Models\Plant;
use Filament\Facades\Filament;
@@ -399,7 +400,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()
->duration(1000)
->duration(500)
->send();
$this->dispatch('loadData', $this->records, $plantId);
@@ -422,7 +423,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()
->duration(1000)
->duration(500)
->send();
$this->dispatch('loadData', $this->records, $plantId);
@@ -461,7 +462,7 @@ class PalletFromLocator extends Page implements HasForms
->title('Add: Locator Serial Numbers')
->body("Scanned locator number '$locatorNo' has '$serialLocator' locator serial numbers!<br>Successfully added into 'PALLET DATA' table.")
->success()
->duration(1000)
->duration(500)
->send();
$this->dispatch('loadData', $this->records, $plantId);
@@ -567,11 +568,11 @@ class PalletFromLocator extends Page implements HasForms
]);
return;
}
else if (strlen($serialNo) < 9)
else if (strlen($serialNo) < 9 || strlen($serialNo) > 20)
{
Notification::make()
->title('Invalid: Serial Number')
->body("Serial number '$serialNo' must be at least 9 digits.")
->body("Serial number should contain minimum 9 digits and maximum 20 digits.")
->danger()
->duration(1200)
->send();
@@ -619,23 +620,53 @@ class PalletFromLocator extends Page implements HasForms
if ($serialLocator == '' || $serialLocator == null)
{
Notification::make()
->title('Unknown: Serial Number')
->body("Scanned serial number: '$serialNo' doesn't exist in pallet table.<br>Scan the valid exist locator-serial number to proceed..!")
->danger()
->duration(1200)
->send();
$invoicesnoexists = LocatorInvoiceValidation::where('plant_id', $plantId)
->where('serial_number', $serialNo)
->where('scanned_status', '=','Scanned')
->first();
$this->dispatch('loadData', $this->records, $plantId);
$this->form->fill([
'plant_id' => $plantId,
'plant' => $plantId,
'scan_locator_number' => null,
'scan_serial_number' => null,
'scan_remove_sno' => null,
'sno_quantity' => null,
]);
return;
$invoiceNo = $invoicesnoexists?->invoice_number;
if ($invoicesnoexists)
{
Notification::make()
->title('Invalid: Serial Number')
->body("Serial number '$serialNo' already exists in invoice number '$invoiceNo' and completed the scanning process..!")
->danger()
->duration(1200)
->send();
$this->dispatch('loadData', $this->records, $plantId);
$this->form->fill([
'plant_id' => $plantId,
'plant' => $plantId,
'scan_locator_number' => null,
'scan_serial_number' => null,
'scan_remove_sno' => null,
'sno_quantity' => $count,
]);
return;
}
else
{
Notification::make()
->title('Unknown: Serial Number')
->body("Scanned serial number: '$serialNo' doesn't exist in pallet table.<br>Scan the valid exist locator-serial number to proceed..!")
->danger()
->duration(1200)
->send();
$this->dispatch('loadData', $this->records, $plantId);
$this->form->fill([
'plant_id' => $plantId,
'plant' => $plantId,
'scan_locator_number' => null,
'scan_serial_number' => null,
'scan_remove_sno' => null,
'sno_quantity' => $count,
]);
return;
}
}
elseif ($serialLocator->pallet_number != '' && $serialLocator->pallet_number != null)
{
@@ -653,7 +684,7 @@ class PalletFromLocator extends Page implements HasForms
'scan_locator_number' => null,
'scan_serial_number' => null,
'scan_remove_sno' => null,
'sno_quantity' => null,
'sno_quantity' => $count,
]);
return;
}
@@ -770,16 +801,16 @@ class PalletFromLocator extends Page implements HasForms
->title('Success: Pallet Generated')
->body("Pallet number '$newPalletNumber' completed the master packing successfully!")
->success()
->duration(1000)
->duration(600)
->send();
$this->dispatch('loadData', $this->records, $plantId);
$this->form->fill([
'plant_id' => $plantId,
'plant' => $plantId,
'scan_locator_number' => $locatorNo,
'scan_serial_number' => $serialNo,
'scan_remove_sno' => $removeSerial,
'scan_locator_number' => null,
'scan_serial_number' => null,
'scan_remove_sno' => null,
'sno_quantity' => 0,
]);
return;
@@ -798,9 +829,9 @@ class PalletFromLocator extends Page implements HasForms
$this->form->fill([
'plant_id' => $plantId,
'plant' => $plantId,
'scan_locator_number' => $locatorNo,
'scan_serial_number' => $serialNo,
'scan_remove_sno' => $removeSerial,
'scan_locator_number' => null,
'scan_serial_number' => null,
'scan_remove_sno' => null,
'sno_quantity' => 0,
]);
return;
@@ -905,11 +936,11 @@ class PalletFromLocator extends Page implements HasForms
]);
return;
}
else if (strlen($removeSno) < 9)
else if (strlen($removeSno) < 9 || strlen($removeSno) > 20)
{
Notification::make()
->title('Invalid: Serial Number')
->body("Serial number '$removeSno' must be at least 9 digits.")
->body("Serial number should contain minimum 9 digits and maximum 20 digits.")
->danger()
->duration(1200)
->send();