Added serial_number minimum length should be 9 digit and notification display duration

This commit is contained in:
dhanabalan
2025-07-09 17:27:41 +05:30
parent 49d2f1088f
commit 693e3a23a4
2 changed files with 172 additions and 69 deletions

View File

@@ -104,6 +104,7 @@ class LocatorInvoiceValidationResource extends Resource
Forms\Components\TextInput::make('pallet_number')
->label('Scan Pallet No')
->reactive()
->minLength(10)
// ->readOnly(fn (callable $get) => !$get('plant') || !$get('invoice_number') || $get('serial_number'))
->readOnly(function (callable $get) {
$invoiceNumber = $get('invoice_number');
@@ -145,6 +146,7 @@ class LocatorInvoiceValidationResource extends Resource
Forms\Components\TextInput::make('serial_number')
->label('Scan Serial No')
->reactive()
->minLength(9)
// ->readOnly(fn (callable $get) => !$get('plant') || !$get('invoice_number') || $get('pallet_number'))
->readOnly(function (callable $get) {
$invoiceNumber = $get('invoice_number');
@@ -264,9 +266,10 @@ class LocatorInvoiceValidationResource extends Resource
if (!$palletRecord)
{
Notification::make()
->title("Pallet number '{$palletNumber}' does not exist.")
->danger()
->send();
->title("Pallet number '{$palletNumber}' does not exist.")
->danger()
->duration(1200)
->send();
return;
}
@@ -287,8 +290,9 @@ class LocatorInvoiceValidationResource extends Resource
Notification::make()
->title("Pallet number '{$palletNumber}' is not completed in masters")
->danger()
->duration(1200)
->send();
return;
return;
}
// if ($allCompleted)
@@ -331,6 +335,7 @@ class LocatorInvoiceValidationResource extends Resource
// Notification::make()
// ->title("Pallet number '{$palletNumber}' scanned successfully")
// ->success()
// ->duration(800)
// ->send();
// }
@@ -362,6 +367,7 @@ class LocatorInvoiceValidationResource extends Resource
// Notification::make()
// ->title("Pallet number '{$palletNumber}' scanned successfully")
// ->success()
// ->duration(800)
// ->send();
// }
@@ -522,6 +528,7 @@ class LocatorInvoiceValidationResource extends Resource
->title('Invalid Locator Invoice Found')
->body('Uploaded excel sheet is empty or<br>contains no valid data.')
->danger()
->duration(1200)
->send();
if ($disk->exists($path)) {
@@ -547,7 +554,7 @@ class LocatorInvoiceValidationResource extends Resource
}
else
{
if(Str::length($serialNumber) < 13 || !ctype_alnum($serialNumber))
if(Str::length($serialNumber) < 9 || !ctype_alnum($serialNumber))
{
$invalidSerialCodes[] = $serialNumber;
}
@@ -569,10 +576,12 @@ class LocatorInvoiceValidationResource extends Resource
if (!empty($uniqueSerialCodes)) {
Notification::make()
->title('Invalid Serial Numbers Found')
->body('The following serial numbers should contain minimum 13 digit alpha numeric values:<br>' . implode(', ', $uniqueSerialCodes))
->danger()
->send();
->title('Invalid Serial Numbers Found')
->body('The following serial numbers should contain minimum 9 digit alpha numeric values:<br>' . implode(', ', $uniqueSerialCodes))
->danger()
->duration(1200)
->send();
if ($disk->exists($path)) {
$disk->delete($path);
}
@@ -586,7 +595,9 @@ class LocatorInvoiceValidationResource extends Resource
->title('Duplicate Serial Numbers Found')
->body('The following serial numbers are already exist in imported excel:<br>' . implode(', ', $duplicateSerialCodes))
->danger()
->duration(1200)
->send();
if ($disk->exists($path)) {
$disk->delete($path);
}
@@ -598,10 +609,12 @@ class LocatorInvoiceValidationResource extends Resource
->title('Invalid Locator Invoice Found')
->body('Uploaded excel sheet is empty or<br>contains no valid data.')
->danger()
->duration(1200)
->send();
if ($disk->exists($path)) {
$disk->delete($path);
}
if ($disk->exists($path)) {
$disk->delete($path);
}
return;
}
@@ -618,20 +631,22 @@ class LocatorInvoiceValidationResource extends Resource
->title('Duplicate Serial Numbers Found')
->body('The following serial numbers already exist with a different invoice number:<br>' . implode(', ', $existingSerials))
->danger()
->duration(1200)
->send();
if ($disk->exists($path))
{
if ($disk->exists($path)) {
$disk->delete($path);
}
return;
}
else
{
// Save full file path to session
// Save full file path to session
session(['uploaded_invoice_path' => $fullPath]);
Notification::make()
->title('Success: Invoice imported successfully.')
->success()
->duration(800)
->send();
}
}

View File

@@ -59,10 +59,11 @@ class CreateLocatorInvoiceValidation extends CreateRecord
if(!$plantId)
{
Notification::make()
->title('Plant Not Found')
->body("Plant can't be empty!")
->danger()
->send();
->title('Plant Not Found')
->body("Plant can't be empty!")
->danger()
->duration(1200)
->send();
$this->dispatch('loadData', '', $plantId);
$this->form->fill([
'plant_id' => $plantId,
@@ -103,6 +104,7 @@ class CreateLocatorInvoiceValidation extends CreateRecord
->title('Completed: Locator Invoice')
->body("Locator invoice '$invoiceNumber' completed the scanning process.<br>Scan the next 'Locator Invoice' to proceed..!")
->info()
->duration(1000)
->send();
$this->dispatch('loadData', '', $plantId);
$this->form->fill([
@@ -147,7 +149,7 @@ class CreateLocatorInvoiceValidation extends CreateRecord
->title('Invoice File Not Found')
->body("Import the scanned 'Invoice' file to proceed..!")
->danger()
->seconds(2)
->duration(1200)
->send();
$this->form->fill([
'plant_id' => $plantId,
@@ -175,6 +177,7 @@ class CreateLocatorInvoiceValidation extends CreateRecord
->title('Invalid Locator Invoice Found')
->body('Uploaded excel sheet is empty or<br>contains no valid data.')
->danger()
->duration(1200)
->send();
if ($disk->exists($filePath))
@@ -212,7 +215,7 @@ class CreateLocatorInvoiceValidation extends CreateRecord
}
else
{
if(Str::length($serialNumber) < 13 || !ctype_alnum($serialNumber))
if(Str::length($serialNumber) < 9 || !ctype_alnum($serialNumber))
{
$invalidSerialCodes[] = $serialNumber;
}
@@ -234,10 +237,12 @@ class CreateLocatorInvoiceValidation extends CreateRecord
if (!empty($uniqueSerialCodes)) {
Notification::make()
->title('Invalid Serial Numbers Found')
->body('The following serial numbers should contain minimum 13 digit alpha numeric values:<br>' . implode(', ', $uniqueSerialCodes))
->danger()
->send();
->title('Invalid Serial Numbers Found')
->body('The following serial numbers should contain minimum 9 digit alpha numeric values:<br>' . implode(', ', $uniqueSerialCodes))
->danger()
->duration(1200)
->send();
if ($disk->exists($filePath)) {
$disk->delete($filePath);
}
@@ -262,7 +267,9 @@ class CreateLocatorInvoiceValidation extends CreateRecord
->title('Duplicate Serial Numbers Found')
->body('The following serial numbers are already exist in imported excel:<br>' . implode(', ', $duplicateSerialCodes))
->danger()
->duration(1200)
->send();
if ($disk->exists($filePath)) {
$disk->delete($filePath);
}
@@ -284,7 +291,9 @@ class CreateLocatorInvoiceValidation extends CreateRecord
->title('Invalid Locator Invoice Found')
->body('Uploaded excel sheet is empty or<br>contains no valid data.')
->danger()
->duration(1200)
->send();
if ($disk->exists($filePath)) {
$disk->delete($filePath);
}
@@ -315,7 +324,9 @@ class CreateLocatorInvoiceValidation extends CreateRecord
->title('Duplicate Serial Numbers Found')
->body('The following serial numbers already exist with a different invoice number:<br>' . implode(', ', $existingSerials))
->danger()
->duration(1200)
->send();
if ($disk->exists($filePath))
{
$disk->delete($filePath);
@@ -387,10 +398,12 @@ class CreateLocatorInvoiceValidation extends CreateRecord
Notification::make()
->title('Success: Invoice inserted successfully.')
->success()
->duration(800)
->send();
Notification::make()
->title("Start the scanning process for imported invoice number '$invoiceNumber'!")
->info()
->duration(1000)
->send();
if ($disk->exists($filePath))
{
@@ -441,7 +454,7 @@ class CreateLocatorInvoiceValidation extends CreateRecord
->title('Updated Invoice File Not Found')
->body("Import the updated 'Invoice' file to proceed..!")
->danger()
->seconds(2)
->duration(1200)
->send();
$this->form->fill([
@@ -476,6 +489,7 @@ class CreateLocatorInvoiceValidation extends CreateRecord
->title('Invalid Updated Locator Invoice Found')
->body('Uploaded excel sheet is empty or<br>contains no valid data.')
->danger()
->duration(1200)
->send();
if ($disk->exists($filePath))
@@ -513,7 +527,7 @@ class CreateLocatorInvoiceValidation extends CreateRecord
}
else
{
if(Str::length($serialNumber) < 13 || !ctype_alnum($serialNumber))
if(Str::length($serialNumber) < 9 || !ctype_alnum($serialNumber))
{
$invalidSerialCodes[] = $serialNumber;
}
@@ -535,10 +549,12 @@ class CreateLocatorInvoiceValidation extends CreateRecord
if (!empty($uniqueSerialCodes)) {
Notification::make()
->title('Invalid Serial Numbers Found')
->body('The following serial numbers should contain minimum 13 digit alpha numeric values:<br>' . implode(', ', $uniqueSerialCodes))
->danger()
->send();
->title('Invalid Serial Numbers Found')
->body('The following serial numbers should contain minimum 9 digit alpha numeric values:<br>' . implode(', ', $uniqueSerialCodes))
->danger()
->duration(1200)
->send();
if ($disk->exists($filePath)) {
$disk->delete($filePath);
}
@@ -560,10 +576,12 @@ class CreateLocatorInvoiceValidation extends CreateRecord
if (!empty($duplicateSerialCodes)) {
Notification::make()
->title('Duplicate Serial Numbers Found')
->body('The following serial numbers are already exist in imported excel:<br>' . implode(', ', $duplicateSerialCodes))
->danger()
->send();
->title('Duplicate Serial Numbers Found')
->body('The following serial numbers are already exist in imported excel:<br>' . implode(', ', $duplicateSerialCodes))
->danger()
->duration(1200)
->send();
if ($disk->exists($filePath))
{
$disk->delete($filePath);
@@ -587,10 +605,12 @@ class CreateLocatorInvoiceValidation extends CreateRecord
->title('Invalid Updated Locator Invoice Found')
->body('Uploaded excel sheet is empty or<br>contains no valid data.')
->danger()
->duration(1200)
->send();
if ($disk->exists($filePath)) {
$disk->delete($filePath);
}
if ($disk->exists($filePath)) {
$disk->delete($filePath);
}
$this->dispatch('loadData', '', $plantId);
$this->form->fill([
'plant_id' => $plantId,
@@ -618,7 +638,9 @@ class CreateLocatorInvoiceValidation extends CreateRecord
->title('Duplicate Serial Numbers Found')
->body('The following serial numbers already exist with a different invoice number:<br>' . implode(', ', $existingSerials))
->danger()
->duration(1200)
->send();
if ($disk->exists($filePath)) {
$disk->delete($filePath);
}
@@ -666,12 +688,14 @@ class CreateLocatorInvoiceValidation extends CreateRecord
if ($createdAny)
{
Notification::make()
->title('Success: Locator invoice updated successfully.')
->title('Success: Invoice updated successfully.')
->success()
->duration(800)
->send();
Notification::make()
->title("Start the scanning process for updated invoice number '$invoiceNumber'!")
->info()
->duration(1000)
->send();
if ($disk->exists($filePath))
{
@@ -703,6 +727,7 @@ class CreateLocatorInvoiceValidation extends CreateRecord
Notification::make()
->title("Start the scanning process for scanned invoice number '$invoiceNumber'!")
->info()
->duration(1000)
->send();
$snoCount = LocatorInvoiceValidation::where('plant_id', $plantId)
@@ -730,6 +755,7 @@ class CreateLocatorInvoiceValidation extends CreateRecord
->title('Error: Locator invoice insertion (or updation).')
->body($e->getMessage())
->danger()
->duration(1200)
->send();
$this->dispatch('loadData', $invoiceNumber, $plantId);
$snoCount = LocatorInvoiceValidation::where('plant_id', $plantId)
@@ -786,7 +812,9 @@ class CreateLocatorInvoiceValidation extends CreateRecord
->title('Invoice Not Found')
->body("Scanned invoice number '$invoiceNumber' does not exist in invoice table!<br>Import the scanned 'Invoice' file to proceed..!")
->danger()
->duration(1200)
->send();
$this->dispatch('loadData', $invoiceNumber, $plantId);
$this->form->fill([
'plant_id' => $plantId,
@@ -821,7 +849,9 @@ class CreateLocatorInvoiceValidation extends CreateRecord
->title('Completed: Locator Invoice')
->body("Invoice number '$invoiceNumber' completed the scanning process.<br>Scan the next 'Locator Invoice' to proceed..!")
->info()
->duration(1000)
->send();
$this->dispatch('loadData', '', $plantId);
$this->form->fill([
'plant_id' => $plantId,
@@ -842,11 +872,12 @@ class CreateLocatorInvoiceValidation extends CreateRecord
Notification::make()
->title("Pallet number can't be empty!")
->danger()
->duration(1200)
->send();
$this->dispatch('loadData', $invoiceNumber, $plantId);
$snoCount = LocatorInvoiceValidation::where('plant_id', $plantId)
->where('invoice_number', $invoiceNumber)
$snoCount = LocatorInvoiceValidation::where('plant_id', $plantId)->where('invoice_number', $invoiceNumber)
->count();
$this->dispatch('loadData', $invoiceNumber, $plantId);
$this->form->fill([
'plant_id' => $plantId,
'plant' => $plantId,
@@ -865,9 +896,11 @@ class CreateLocatorInvoiceValidation extends CreateRecord
if (strlen($palletNumber) < 10)
{
Notification::make()
->title("Pallet number '$palletNumber' must be at least 10 digits.")
->danger()
->send();
->title("Pallet number '$palletNumber' must be at least 10 digits.")
->danger()
->duration(1200)
->send();
$this->dispatch('loadData', $invoiceNumber, $plantId);
$this->form->fill([
'plant_id' => $plantId,
@@ -892,7 +925,9 @@ class CreateLocatorInvoiceValidation extends CreateRecord
Notification::make()
->title("Pallet number '{$palletNumber}' does not exist in pallet table.")
->danger()
->duration(1200)
->send();
$this->dispatch('loadData', $invoiceNumber, $plantId);
$this->form->fill([
'plant_id' => $plantId,
@@ -925,7 +960,9 @@ class CreateLocatorInvoiceValidation extends CreateRecord
Notification::make()
->title("Pallet number '{$palletNumber}' does not completed the master packing!")
->danger()
->duration(1200)
->send();
$this->dispatch('loadData', $invoiceNumber, $plantId);
$this->form->fill([
'plant_id' => $plantId,
@@ -944,28 +981,30 @@ class CreateLocatorInvoiceValidation extends CreateRecord
if ($allCompleted)
{
$PalletSerialNumbers = $palletRecords->pluck('serial_number')
->map(function ($serial) {
return trim($serial);
})
->all();
->map(function ($serial) {
return trim($serial);
})
->all();
$InvoiceSerialNumbers = LocatorInvoiceValidation::where('plant_id', $plantId)
->where('invoice_number', $invoiceNumber)
->where(function ($query) {
$query->where('scanned_status', '=', '')
->orWhereNull('scanned_status');
})
->pluck('serial_number')
->all();
->where('invoice_number', $invoiceNumber)
->where(function ($query) {
$query->where('scanned_status', '=', '')
->orWhereNull('scanned_status');
})
->pluck('serial_number')
->all();
$matchedSerialNumbers = array_intersect($PalletSerialNumbers, $InvoiceSerialNumbers);
if (empty($matchedSerialNumbers))
{
Notification::make()
->title("Scanned pallet number '$palletNumber' does not have invoice serial numbers.<br>Scan the valid exist pallet number to start the scanning process..!")
->danger()
->send();
->title("Scanned pallet number '$palletNumber' does not have invoice serial numbers.<br>Scan the valid exist pallet number to start the scanning process..!")
->danger()
->duration(1200)
->send();
$this->dispatch('loadData', $invoiceNumber, $plantId);
$this->form->fill([
'plant_id' => $plantId,
@@ -1001,10 +1040,12 @@ class CreateLocatorInvoiceValidation extends CreateRecord
// $body = "Scanned pallet number '$palletNumber' has ".$missingSerialsString."<br>Do you want to skip missing serial numbers?<br>Then Press 'Yes' and Click 'Enter'.";
Notification::make()
->title("Partial Pallet Serial Numbers Found")
->body($missingSerialsString)
->danger()
->send();
->title("Partial Pallet Serial Numbers Found")
->body($missingSerialsString)
->danger()
->duration(1200)
->send();
$this->dispatch('loadData', $invoiceNumber, $plantId);
$this->form->fill([
'plant_id' => $plantId,
@@ -1069,6 +1110,7 @@ class CreateLocatorInvoiceValidation extends CreateRecord
Notification::make()
->title("All Serial numbers are moved into invoice from the pallet number '$palletNumber'.<br>Scan the next exist pallet number to start the scanning process..!")
->success()
->duration(800)
->send();
$records = LocatorInvoiceValidation::where('plant_id', $plantId)
@@ -1089,6 +1131,7 @@ class CreateLocatorInvoiceValidation extends CreateRecord
->title('Completed: Locator Invoice')
->body("Invoice number '$invoiceNumber' completed the scanning process.<br>Scan the next 'Locator Invoice' to proceed..!")
->info()
->duration(1000)
->send();
$this->dispatch('loadData', '', $plantId);
@@ -1157,6 +1200,7 @@ class CreateLocatorInvoiceValidation extends CreateRecord
Notification::make()
->title($succMsgStr)
->success()
->duration(800)
->send();
$records = LocatorInvoiceValidation::where('plant_id', $plantId)
@@ -1177,6 +1221,7 @@ class CreateLocatorInvoiceValidation extends CreateRecord
->title('Completed: Locator Invoice')
->body("Invoice number '$invoiceNumber' completed the scanning process.<br>Scan the next 'Locator Invoice' to proceed..!")
->info()
->duration(1000)
->send();
$this->dispatch('loadData', '', $plantId);
@@ -1250,7 +1295,9 @@ class CreateLocatorInvoiceValidation extends CreateRecord
->title('Invoice Not Found')
->body("Scanned invoice number '$invoiceNumber' does not exist in invoice table!<br>Import the scanned 'Invoice' file to proceed..!")
->danger()
->duration(1200)
->send();
$this->form->fill([
'plant_id' => $plantId,
'plant' => $plantId,
@@ -1284,7 +1331,9 @@ class CreateLocatorInvoiceValidation extends CreateRecord
->title('Completed: Locator Invoice')
->body("Invoice number '$invoiceNumber' completed the scanning process.<br>Scan the next 'Locator Invoice' to proceed..!")
->info()
->duration(1000)
->send();
$this->dispatch('loadData', '', $plantId);
$this->form->fill([
'plant_id' => $plantId,
@@ -1303,10 +1352,12 @@ class CreateLocatorInvoiceValidation extends CreateRecord
if ($serialNumber == '' || $serialNumber == null)
{
Notification::make()
->title("Invalid: Serial Number")
->body("Serial number can't be empty!")
->danger()
->send();
->title("Invalid: Serial Number")
->body("Serial number can't be empty!")
->danger()
->duration(1200)
->send();
$snoCount = LocatorInvoiceValidation::where('plant_id', $plantId)->where('invoice_number', $invoiceNumber)->count();
$this->dispatch('loadData', $invoiceNumber, $plantId);
$this->form->fill([
@@ -1324,13 +1375,38 @@ class CreateLocatorInvoiceValidation extends CreateRecord
}
$snoCount = LocatorInvoiceValidation::where('plant_id', $plantId)->where('invoice_number', $invoiceNumber)->count();
if (strlen($serialNumber) < 13)
if (strlen($serialNumber) < 9)
{
Notification::make()
->title("Invalid: Serial Number")
->body("Serial number '$serialNumber' must be at least 13 digits and alpha-numeric value only allowed!")
->body('Serial number should contain minimum 9 digits.')
->danger()
->duration(1200)
->send();
$this->dispatch('loadData', $invoiceNumber, $plantId);
$this->form->fill([
'plant_id' => $plantId,
'plant' => $plantId,
'invoice_number' => $invoiceNumber,
'pallet_number' => null,
'serial_number' => null,
'sno_quantity' => $snoCount,
'created_by' => $operatorName,
'scanned_by' => $operatorName,
]);
return;
}
else if (!ctype_alnum($serialNumber))
{
Notification::make()
->title("Invalid: Serial Number")
->body('Serial number must contain alpha-numeric values only.')
// ->body("Serial number '$serialNumber' must be at least 9 digits and alpha-numeric value only allowed!")
->danger()
->duration(1200)
->send();
$this->dispatch('loadData', $invoiceNumber, $plantId);
$this->form->fill([
'plant_id' => $plantId,
@@ -1353,7 +1429,9 @@ class CreateLocatorInvoiceValidation extends CreateRecord
->title("Unknown: Serial Number")
->body("Serial number '{$serialNumber}' does not exist in invoice number '$invoiceNumber'.")
->danger()
->duration(1200)
->send();
$this->dispatch('loadData', $invoiceNumber, $plantId);
$this->form->fill([
'plant_id' => $plantId,
@@ -1373,7 +1451,9 @@ class CreateLocatorInvoiceValidation extends CreateRecord
->title("Completed: Serial Number")
->body("Serial number '{$serialNumber}' already completed the scanning process for the invoice number '$invoiceNumber'.")
->danger()
->duration(1200)
->send();
$this->dispatch('loadData', $invoiceNumber, $plantId);
$this->form->fill([
'plant_id' => $plantId,
@@ -1403,7 +1483,9 @@ class CreateLocatorInvoiceValidation extends CreateRecord
->title("Unknown: Serial Number")
->body("Serial number '{$serialNumber}' does not exist in pallet table.")
->danger()
->duration(1200)
->send();
$this->dispatch('loadData', $invoiceNumber, $plantId);
$this->form->fill([
'plant_id' => $plantId,
@@ -1434,7 +1516,9 @@ class CreateLocatorInvoiceValidation extends CreateRecord
->title("Incompleted Pallet: Serial Number")//Pallet number '{$existPallNum}' does not completed the master packing!
->body("Serial number '{$serialNumber}' exist in pallet number '$existPallNum' and it does not completed the master packing!")
->danger()
->duration(1200)
->send();
$this->dispatch('loadData', $invoiceNumber, $plantId);
$this->form->fill([
'plant_id' => $plantId,
@@ -1502,6 +1586,7 @@ class CreateLocatorInvoiceValidation extends CreateRecord
Notification::make()
->title($succMsg)
->success()
->duration(800)
->send();
$records = LocatorInvoiceValidation::where('plant_id', $plantId)->where('invoice_number', $invoiceNumber)->get();
@@ -1520,6 +1605,7 @@ class CreateLocatorInvoiceValidation extends CreateRecord
->title('Completed: Locator Invoice')
->body("Invoice number '$invoiceNumber' completed the scanning process.<br>Scan the next 'Locator Invoice' to proceed..!")
->info()
->duration(1000)
->send();
$this->dispatch('loadData', '', $plantId);
@@ -1557,7 +1643,9 @@ class CreateLocatorInvoiceValidation extends CreateRecord
Notification::make()
->title("Failed to check Serial number '{$serialNumber}' existence.<br>Scan the valid serial number to proceed...")
->success()
->duration(1200)
->send();
$this->dispatch('loadData', $invoiceNumber, $plantId);
$this->form->fill([
'plant_id' => $plantId,