From 3e41bad7f13ed63e731d9167c5bd83175223eec3 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Sat, 15 Nov 2025 20:04:30 +0530 Subject: [PATCH] Refactor code structure for improved readability and maintainability and Commented imported invoice logic on warning --- .../Resources/SerialValidationResource.php | 35 +- .../Pages/CreateSerialValidation.php | 846 +++++++++--------- 2 files changed, 445 insertions(+), 436 deletions(-) diff --git a/app/Filament/Resources/SerialValidationResource.php b/app/Filament/Resources/SerialValidationResource.php index 5e782a8..fc3d097 100644 --- a/app/Filament/Resources/SerialValidationResource.php +++ b/app/Filament/Resources/SerialValidationResource.php @@ -269,8 +269,7 @@ class SerialValidationResource extends Resource ->alignCenter() ->sortable(), ]) - ->headerActions([ - + ->headerActions([ // Action::make('plant_id') // ->label('Select Plant') // ->form([ @@ -470,10 +469,10 @@ class SerialValidationResource extends Resource if (!empty($uniqueInvalidCodes)) { Notification::make() - ->title('Invalid Item Codes') - ->body('The following item codes should contain minimum 6 digit alpha numeric values:
' . implode(', ', $uniqueInvalidCodes)) - ->danger() - ->send(); + ->title('Invalid Item Codes') + ->body('The following item codes should contain minimum 6 digit alpha numeric values:
' . implode(', ', $uniqueInvalidCodes)) + ->danger() + ->send(); if ($disk->exists($path)) { $disk->delete($path); } @@ -492,10 +491,10 @@ class SerialValidationResource extends Resource } else if (!empty($uniqueSerialCodes)) { Notification::make() - ->title('Invalid Serial Number') - ->body('The following serial numbers should contain minimum 9 digit alpha numeric values:
' . implode(', ', $uniqueSerialCodes)) - ->danger() - ->send(); + ->title('Invalid Serial Number') + ->body('The following serial numbers should contain minimum 9 digit alpha numeric values:
' . implode(', ', $uniqueSerialCodes)) + ->danger() + ->send(); if ($disk->exists($path)) { $disk->delete($path); } @@ -503,10 +502,10 @@ class SerialValidationResource extends Resource } else if (!empty($duplicateSerialCodes)) { Notification::make() - ->title('Duplicate Serial Numbers') - ->body('The following serial numbers are already exist in imported excel:
' . implode(', ', $duplicateSerialCodes)) - ->danger() - ->send(); + ->title('Duplicate Serial Numbers') + ->body('The following serial numbers are already exist in imported excel:
' . implode(', ', $duplicateSerialCodes)) + ->danger() + ->send(); if ($disk->exists($path)) { $disk->delete($path); } @@ -519,9 +518,9 @@ class SerialValidationResource extends Resource ->danger() // This makes the notification red to indicate an error ->body('Uploaded Excel sheet is empty or
contains no valid data.') ->send(); - if ($disk->exists($path)) { - $disk->delete($path); - } + if ($disk->exists($path)) { + $disk->delete($path); + } return; } @@ -589,7 +588,7 @@ class SerialValidationResource extends Resource } else { - // Save full file path to session + // Save full file path to session session(['uploaded_invoice_path' => $fullPath]); Notification::make() ->title('Serial invoice imported successfully.') diff --git a/app/Filament/Resources/SerialValidationResource/Pages/CreateSerialValidation.php b/app/Filament/Resources/SerialValidationResource/Pages/CreateSerialValidation.php index 4aa6994..cee832c 100644 --- a/app/Filament/Resources/SerialValidationResource/Pages/CreateSerialValidation.php +++ b/app/Filament/Resources/SerialValidationResource/Pages/CreateSerialValidation.php @@ -124,7 +124,7 @@ class CreateSerialValidation extends CreateRecord $totMQuan = SerialValidation::where('invoice_number', $invoiceNumber)->whereNotNull('quantity')->where('plant_id', $plantId)->count(); //->where('quantity', '!=', '') $scanMQuan = SerialValidation::where('invoice_number', $invoiceNumber)->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $plantId)->count(); - if($totMQuan > 0) + if ($totMQuan > 0) { $this->form->fill([ 'plant_id' => $plantId, @@ -140,7 +140,7 @@ class CreateSerialValidation extends CreateRecord ->title("Completed: Material Invoice") ->body("Material invoice '$invoiceNumber' completed the scanning process.
Scan the next 'Material Invoice' to proceed!") ->warning() - ->seconds(2) + ->seconds(3) ->send(); $this->dispatch('playNotificationSound'); @@ -162,12 +162,13 @@ class CreateSerialValidation extends CreateRecord ->info() ->seconds(1) ->send(); + $this->dispatch('playNotificationSound'); // $hasRecords = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->first()->stickerMasterRelation->material_type ?? null; // $this->dispatch( (!empty($hasRecords) && $hasRecords) ? 'refreshMaterialInvoiceData' : 'refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId); //$this->invoiceNumber $this->dispatch('refreshMaterialInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId); - if($updateStatus == '1') + if ($updateStatus == '1') { //'Material invoice update in progress...'; $filename = $invoiceNumber . '.xlsx'; @@ -181,16 +182,16 @@ class CreateSerialValidation extends CreateRecord // Now you can read/process the file here $rows = Excel::toArray(null, $fullPath)[0]; - if((count($rows) - 1) <= 0) + if ((count($rows) - 1) <= 0) { Notification::make() ->title('Records Not Found') ->body("Import the valid updated 'Material Invoice' file to proceed..!") ->danger() - ->seconds(2) + ->seconds(3) ->send(); - $this->dispatch('playWarnSound'); + $this->dispatch('playWarnSound'); if ($disk->exists($filePath)) { $disk->delete($filePath); } @@ -216,7 +217,7 @@ class CreateSerialValidation extends CreateRecord } if (!empty($materialCode)) { - if(Str::length($materialCode) < 6 || !ctype_alnum($materialCode)) + if (Str::length($materialCode) < 6 || !ctype_alnum($materialCode)) { $invalidMatCodes[] = $materialCode; } @@ -225,11 +226,11 @@ class CreateSerialValidation extends CreateRecord if (empty($materialQuantity)) { $missingQuantities[] = $materialCode; } - else if(!is_numeric($materialQuantity)) + else if (!is_numeric($materialQuantity)) { $invalidMatQuan[] = $materialCode; } - else if($materialQuantity == 0) + else if ($materialQuantity == 0) { $invalidMatQuan[] = $materialCode; } @@ -246,34 +247,20 @@ class CreateSerialValidation extends CreateRecord } } - if (!$validRowsFound) { - Notification::make() - ->title('Invalid Material Invoice') - ->danger() // This makes the notification red to indicate an error - ->body('Uploaded Excel sheet is empty or
contains no valid data.') - ->seconds(2) - ->send(); - $this->dispatch('playWarnSound'); - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } - return; - } - $uniqueInvalidCodes = array_unique($invalidMatCodes); if (!empty($uniqueInvalidCodes)) { Notification::make() - ->title('Invalid: Item Codes') - ->body('The following item codes should contain minimum 6 digit alpha numeric values:
' . implode(', ', $uniqueInvalidCodes)) - ->danger() - ->seconds(2) - ->send(); - $this->dispatch('playWarnSound'); + ->title('Invalid: Item Codes') + ->body('The following item codes should contain minimum 6 digit alpha numeric values:
' . implode(', ', $uniqueInvalidCodes)) + ->danger() + ->seconds(3) + ->send(); - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + $this->dispatch('playWarnSound'); + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } return; } @@ -284,13 +271,13 @@ class CreateSerialValidation extends CreateRecord ->title('Missing Material Quantity') ->body("The following item codes doesn't have valid material quantity:
" . implode(', ', $uniqueMissingQuanCodes)) ->danger() - ->seconds(2) + ->seconds(3) ->send(); - $this->dispatch('playWarnSound'); - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + $this->dispatch('playWarnSound'); + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } return; } @@ -301,10 +288,25 @@ class CreateSerialValidation extends CreateRecord ->title('Invalid Material Quantity') ->body("The following item codes doesn't have valid material quantity:
" . implode(', ', $uniqueInvalidMatQuan)) ->danger() - ->seconds(2) + ->seconds(3) ->send(); - $this->dispatch('playWarnSound'); + $this->dispatch('playWarnSound'); + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } + return; + } + + if (!$validRowsFound) { + Notification::make() + ->title('Invalid Material Invoice') + ->danger() // This makes the notification red to indicate an error + ->body('Uploaded Excel sheet is empty or
contains no valid data.') + ->seconds(3) + ->send(); + + $this->dispatch('playWarnSound'); if ($disk->exists($filePath)) { $disk->delete($filePath); } @@ -334,13 +336,13 @@ class CreateSerialValidation extends CreateRecord ->title('Unknown: Item Codes') ->body($message) ->danger() - ->seconds(2) + ->seconds(3) ->send(); - $this->dispatch('playWarnSound'); - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + $this->dispatch('playWarnSound'); + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } return; } @@ -365,20 +367,20 @@ class CreateSerialValidation extends CreateRecord ->title('Unknown: Item Codes') ->body($message) ->danger() - ->seconds(2) + ->seconds(3) ->send(); - $this->dispatch('playWarnSound'); - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + $this->dispatch('playWarnSound'); + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } return; } $invalidCodes = $matchedItems - ->filter(fn ($sticker) => empty($sticker->material_type)) //filter invalid - ->pluck('item.code') - ->toArray(); + ->filter(fn ($sticker) => empty($sticker->material_type)) //filter invalid + ->pluck('item.code') + ->toArray(); if (!empty($invalidCodes)) @@ -388,16 +390,16 @@ class CreateSerialValidation extends CreateRecord $message = $missingCount > 10 ? "'$missingCount' Serial Invoice item codes found." : "'Serial Invoice' item codes found:
" . implode(', ', $invalidCodes); Notification::make() - ->title('Invalid: Item Codes') - ->body($message) - ->danger() - ->seconds(2) - ->send(); - $this->dispatch('playWarnSound'); + ->title('Invalid: Item Codes') + ->body($message) + ->danger() + ->seconds(3) + ->send(); - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + $this->dispatch('playWarnSound'); + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } return; } @@ -434,9 +436,9 @@ class CreateSerialValidation extends CreateRecord if ($totalExcelQty == 0) { $zeroQtyCodes[] = $code; - } elseif (!is_numeric($totalExcelQty)) { + } else if (!is_numeric($totalExcelQty)) { $nonNumericQtyCodes[] = $code; // Here you may want to check divisibility condition too - } elseif ($bundleQty != 0 && $totalExcelQty % $bundleQty != 0) { + } else if ($bundleQty != 0 && $totalExcelQty % $bundleQty != 0) { $notDivisibleCodes[] = $code; } } @@ -457,9 +459,9 @@ class CreateSerialValidation extends CreateRecord ->title('Invalid Bundle Quantity') ->body("$message
$codeList") ->danger() - ->seconds(2) + ->seconds(3) ->send(); - $this->dispatch('playWarnSound'); + $this->dispatch('playWarnSound'); }; $showValidationNotification($nonNumericQtyCodes, "The following item codes contains invalid bundle quantity:"); @@ -468,9 +470,9 @@ class CreateSerialValidation extends CreateRecord if ($nonNumericQtyCodes || $zeroQtyCodes || $notDivisibleCodes) { - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } return; } else @@ -636,11 +638,11 @@ class CreateSerialValidation extends CreateRecord // 3 > 0 // 5 > 0 // 0 > 0 // 8 > 0 // 0 > 0 - if($existEmpQty > 0) // update + if ($existEmpQty > 0) // update { // 3 = 6 // 5 = 5 // 0 = 3 // 8 = 9 // 0 = 5 - if($existEmpQty == $newInsQty) { continue; } + if ($existEmpQty == $newInsQty) { continue; } // $existEmpRecQty->delete(); $existEmpRecQty->update([ 'quantity' => $newInsQty, @@ -669,10 +671,10 @@ class CreateSerialValidation extends CreateRecord $newInsQty = $totalExcelQty - $existComQty; // 3 > 0 // 5 > 0 // 0 > 0 // 8 > 0 - if($existEmpQty > 0) // update + if ($existEmpQty > 0) // update { // 3 = 2 // 5 = 4 // 0 = -1 // 8 = 7 - if($existEmpQty == $newInsQty) { continue; } + if ($existEmpQty == $newInsQty) { continue; } // $existEmpRecQty->delete(); $existEmpRecQty->update([ 'quantity' => $newInsQty, @@ -713,6 +715,7 @@ class CreateSerialValidation extends CreateRecord // ->success() ->seconds(1) ->send(); + $this->dispatch('playNotificationSound'); // Update total quantity in the form @@ -736,9 +739,9 @@ class CreateSerialValidation extends CreateRecord } else { - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } $this->dispatch('refreshMaterialInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId); } @@ -749,7 +752,7 @@ class CreateSerialValidation extends CreateRecord ->title("Update Failed: Material Invoice") ->body("No new records were inserted for Material Invoice : '$invoiceNumber'.") ->danger() - ->seconds(2) + ->seconds(3) ->send(); $this->dispatch('playWarnSound'); @@ -763,9 +766,9 @@ class CreateSerialValidation extends CreateRecord 'scanned_quantity'=> $scannedQuantity, ]); - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } $this->dispatch('refreshEmptyInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId); return; @@ -778,7 +781,7 @@ class CreateSerialValidation extends CreateRecord ->title('Updated Invoice Not Found') ->body("Import the updated 'Material Invoice' file to proceed..!") ->danger() - ->seconds(2) + ->seconds(3) ->send(); $this->dispatch('playWarnSound'); @@ -814,8 +817,9 @@ class CreateSerialValidation extends CreateRecord ->title("Completed: Serial Invoice") ->body("Serial invoice '$invoiceNumber' completed the scanning process.
Scan the next 'Serial Invoice' to proceed.!") ->warning() - ->seconds(2) + ->seconds(3) ->send(); + $this->dispatch('playNotificationSound'); $filename = $invoiceNumber . '.xlsx'; @@ -837,10 +841,11 @@ class CreateSerialValidation extends CreateRecord ->info() ->seconds(1) ->send(); + $this->dispatch('playNotificationSound'); $this->dispatch('refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId); - if($updateStatus == '1') + if ($updateStatus == '1') { $filename = $invoiceNumber . '.xlsx'; $directory = 'uploads/temp'; @@ -857,13 +862,13 @@ class CreateSerialValidation extends CreateRecord // Now you can read/process the file here $rows = Excel::toArray(null, $fullPath)[0]; - if((count($rows) - 1) <= 0) + if ((count($rows) - 1) <= 0) { Notification::make() ->title('Records Not Found') ->body("Import the valid updated 'Serial Invoice' file to proceed..!") ->danger() - ->seconds(2) + ->seconds(3) ->send(); $this->dispatch('playWarnSound'); @@ -895,17 +900,17 @@ class CreateSerialValidation extends CreateRecord if (!empty($materialCode)) { - if(Str::length($materialCode) < 6 || !ctype_alnum($materialCode)) + if (Str::length($materialCode) < 6 || !ctype_alnum($materialCode)) { $invalidMatCodes[] = $materialCode; continue; } else { - if(empty($serialNumber)) { + if (empty($serialNumber)) { $missingSerials[] = $materialCode; } - else if(Str::length($serialNumber) < 9 || !ctype_alnum($serialNumber)) + else if (Str::length($serialNumber) < 9 || !ctype_alnum($serialNumber)) { $invalidSerCodes[] = $serialNumber; } @@ -930,33 +935,85 @@ class CreateSerialValidation extends CreateRecord } } + $uniqueInvalidCodes = array_unique($invalidMatCodes); + + if (!empty($uniqueInvalidCodes)) { + Notification::make() + ->title('Invalid: Item Codes') + ->body('The following item codes should contain minimum 6 digit alpha numeric values:
' . implode(', ', $uniqueInvalidCodes)) + ->danger() + ->seconds(3) + ->send(); + + $this->dispatch('playWarnSound'); + + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } + return; + } + + $uniqueMissingSerials = array_unique($missingSerials); + + if (!empty($uniqueMissingSerials)) { + Notification::make() + ->title('Missing Serial Numbers') + ->body("The following item codes doesn't have valid serial number:
" . implode(', ', $uniqueMissingSerials)) + ->danger() + ->seconds(3) + ->send(); + + $this->dispatch('playWarnSound'); + + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } + return; + } + + $uniqueInvalidSerCodes = array_unique($invalidSerCodes); + + if (!empty($uniqueInvalidSerCodes)) { + Notification::make() + ->title('Invalid Serial Numbers') + ->body('The following serial numbers should contain minimum 9 digit alpha numeric values:
' . implode(', ', $uniqueInvalidSerCodes)) + ->danger() + ->seconds(3) + ->send(); + $this->dispatch('playWarnSound'); + + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } + return; + } + + $uniqueDupSerCodes = array_unique($duplicateSerials); + + if (!empty($uniqueDupSerCodes)) { + Notification::make() + ->title('Duplicate Serial Numbers') + ->body('The following serial numbers are already exist in invoice excel:
' . implode(', ', $uniqueDupSerCodes)) + ->danger() + ->seconds(3) + ->send(); + + $this->dispatch('playWarnSound'); + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } + return; + } + if (!$validRowsFound) { Notification::make() ->title('Invalid Serial Invoice') ->danger() // This makes the notification red to indicate an error ->body('Uploaded excel sheet is empty or
contains no valid data.') - ->seconds(2) + ->seconds(3) ->send(); - $this->dispatch('playWarnSound'); - - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } - return; - } - - $uniqueInvalidCodes = array_unique($invalidMatCodes); - - if (!empty($uniqueInvalidCodes)) { - Notification::make() - ->title('Invalid: Item Codes') - ->body('The following item codes should contain minimum 6 digit alpha numeric values:
' . implode(', ', $uniqueInvalidCodes)) - ->danger() - ->seconds(2) - ->send(); $this->dispatch('playWarnSound'); - if ($disk->exists($filePath)) { $disk->delete($filePath); } @@ -986,14 +1043,14 @@ class CreateSerialValidation extends CreateRecord ->title('Unknown: Item Codes') ->body($message) ->danger() - ->seconds(2) + ->seconds(3) ->send(); $this->dispatch('playWarnSound'); - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } return; } @@ -1018,13 +1075,13 @@ class CreateSerialValidation extends CreateRecord ->title('Unknown: Item Codes') ->body($message) ->danger() - ->seconds(2) + ->seconds(3) ->send(); - $this->dispatch('playWarnSound'); - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + $this->dispatch('playWarnSound'); + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } return; } @@ -1043,20 +1100,20 @@ class CreateSerialValidation extends CreateRecord ->title('Invalid: Item Codes') ->body($message) ->danger() - ->seconds(2) + ->seconds(3) ->send(); - $this->dispatch('playWarnSound'); - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + $this->dispatch('playWarnSound'); + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } return; } $missPackCodes = $matchedItems - ->filter(fn ($sticker) => empty($sticker->tube_sticker_motor) && empty($sticker->pack_slip_motor) && empty($sticker->tube_sticker_pump) && empty($sticker->pack_slip_pump) && empty($sticker->tube_sticker_pumpset) && empty($sticker->pack_slip_pumpset) && empty($sticker->panel_box_code)) //filter invalid - ->pluck('item.code') - ->toArray(); + ->filter(fn ($sticker) => empty($sticker->tube_sticker_motor) && empty($sticker->pack_slip_motor) && empty($sticker->tube_sticker_pump) && empty($sticker->pack_slip_pump) && empty($sticker->tube_sticker_pumpset) && empty($sticker->pack_slip_pumpset) && empty($sticker->panel_box_code)) //filter invalid + ->pluck('item.code') + ->toArray(); if (!empty($missPackCodes)) { @@ -1068,66 +1125,13 @@ class CreateSerialValidation extends CreateRecord ->title('Invalid: Item Codes') ->body($message) ->danger() - ->seconds(2) - ->send(); - $this->dispatch('playWarnSound'); - - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } - return; - } - - $uniqueMissingSerials = array_unique($missingSerials); - - if (!empty($uniqueMissingSerials)) { - Notification::make() - ->title('Missing Serial Numbers') - ->body("The following item codes doesn't have valid serial number:
" . implode(', ', $uniqueMissingSerials)) - ->danger() - ->seconds(2) - ->send(); - - $this->dispatch('playWarnSound'); - - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } - return; - } - - $uniqueInvalidSerCodes = array_unique($invalidSerCodes); - - if (!empty($uniqueInvalidSerCodes)) { - Notification::make() - ->title('Invalid Serial Numbers') - ->body('The following serial numbers should contain minimum 9 digit alpha numeric values:
' . implode(', ', $uniqueInvalidSerCodes)) - ->danger() - ->seconds(2) - ->send(); - $this->dispatch('playWarnSound'); - - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } - return; - } - - $uniqueDupSerCodes = array_unique($duplicateSerials); - - if (!empty($uniqueDupSerCodes)) { - Notification::make() - ->title('Duplicate Serial Numbers') - ->body('The following serial numbers are already exist in invoice excel:
' . implode(', ', $uniqueDupSerCodes)) - ->danger() - ->seconds(2) + ->seconds(3) ->send(); - $this->dispatch('playWarnSound'); - - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + $this->dispatch('playWarnSound'); + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } return; } @@ -1170,7 +1174,7 @@ class CreateSerialValidation extends CreateRecord $sNoExist = SerialValidation::where('serial_number', $serialNumber)->where('plant_id', $plantId)->exists(); //->pluck('serial_number') - if($sNoExist) { continue; } + if ($sNoExist) { continue; } $sticker = StickerMaster::where('plant_id', $plantId)->whereHas('item', function ($query) use ($materialCode) { $query->where('plant_id', $this->plantId)->where('code', $materialCode); //Check if item.code matches Excel's materialCode @@ -1227,9 +1231,10 @@ class CreateSerialValidation extends CreateRecord } else { - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } + // $hasRecords = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->first()->stickerMasterRelation->material_type ?? null; // $this->dispatch( (!empty($hasRecords) && $hasRecords) ? 'refreshMaterialInvoiceData' : 'refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId); //$this->invoiceNumber $this->dispatch('refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId); @@ -1241,7 +1246,7 @@ class CreateSerialValidation extends CreateRecord ->title("Update Failed: Serial Invoice") ->body("No new records were inserted for Serial Invoice : '$invoiceNumber'.") ->danger() - ->seconds(2) + ->seconds(3) ->send(); $this->dispatch('playWarnSound'); @@ -1255,9 +1260,9 @@ class CreateSerialValidation extends CreateRecord 'scanned_quantity'=> $scannedQuantity, ]); - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } $this->dispatch('refreshEmptyInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId); return; @@ -1269,7 +1274,7 @@ class CreateSerialValidation extends CreateRecord ->title('Updated Invoice Not Found') ->body("Import the updated 'Serial Invoice' file to proceed..!") ->danger() - ->seconds(2) + ->seconds(3) ->send(); $this->dispatch('playWarnSound'); @@ -1303,14 +1308,14 @@ class CreateSerialValidation extends CreateRecord // Notification::make() // ->title('File exists.') // ->success() - // ->seconds(2) + // ->seconds(3) // ->send(); } else { Notification::make() ->title('Invoice Not Found') ->body("Import the scanned 'Invoice' file to proceed..!") ->danger() - ->seconds(2) + ->seconds(3) ->send(); $this->dispatch('playWarnSound'); $this->form->fill([ @@ -1329,10 +1334,10 @@ class CreateSerialValidation extends CreateRecord Notification::make() ->title('Invoice file doesn\'t exist.') ->danger() - ->seconds(2) + ->seconds(3) ->send(); - $this->dispatch('playWarnSound'); - return; + $this->dispatch('playWarnSound'); + return; } @@ -1344,9 +1349,9 @@ class CreateSerialValidation extends CreateRecord Notification::make() ->title("Uploaded file name does not match the invoice number.") ->danger() - ->seconds(2) + ->seconds(3) ->send(); - $this->dispatch('playWarnSound'); + $this->dispatch('playWarnSound'); return; } @@ -1367,17 +1372,16 @@ class CreateSerialValidation extends CreateRecord // // Get the rows // $rows = $excelImport->getRows(); - if((count($rows) - 1) <= 0) + if ((count($rows) - 1) <= 0) { Notification::make() ->title('Records Not Found') ->body("Import the valid 'Invoice' file to proceed..!") ->danger() - ->seconds(2) + ->seconds(3) ->send(); $this->dispatch('playWarnSound'); - if ($disk->exists($filePath)) { $disk->delete($filePath); } @@ -1391,7 +1395,7 @@ class CreateSerialValidation extends CreateRecord $materialCode = trim($row[0]); if (!empty($materialCode)) { - if(Str::length($materialCode) < 6) + if (Str::length($materialCode) < 6) { continue; } @@ -1400,9 +1404,9 @@ class CreateSerialValidation extends CreateRecord $sticker = StickerMaster::where('plant_id', $plantId)->whereHas('item', function ($query) use ($materialCode) { $query->where('plant_id', $this->plantId)->where('code', $materialCode); //Check if item.code matches Excel's materialCode }); - if($sticker->exists()) + if ($sticker->exists()) { - if($sticker->first()->material_type && !empty($sticker->first()->material_type)) + if ($sticker->first()->material_type && !empty($sticker->first()->material_type)) { $invoiceType = "M"; break; @@ -1425,7 +1429,7 @@ class CreateSerialValidation extends CreateRecord } } - if($invoiceType == 'M') + if ($invoiceType == 'M') { $invalidMatCodes = []; $materialCodes = []; @@ -1445,7 +1449,7 @@ class CreateSerialValidation extends CreateRecord } if (!empty($materialCode)) { - if(Str::length($materialCode) < 6 || !ctype_alnum($materialCode)) + if (Str::length($materialCode) < 6 || !ctype_alnum($materialCode)) { $invalidMatCodes[] = $materialCode; } @@ -1454,11 +1458,11 @@ class CreateSerialValidation extends CreateRecord if (empty($materialQuantity)) { $missingQuantities[] = $materialCode; } - else if(!is_numeric($materialQuantity)) + else if (!is_numeric($materialQuantity)) { $invalidMatQuan[] = $materialCode; } - else if($materialQuantity == 0) + else if ($materialQuantity == 0) { $invalidMatQuan[] = $materialCode; } @@ -1475,34 +1479,20 @@ class CreateSerialValidation extends CreateRecord } } - if (!$validRowsFound) { - Notification::make() - ->title('Invalid Material Invoice') - ->danger() // This makes the notification red to indicate an error - ->body('Uploaded Excel sheet is empty or
contains no valid data.') - ->seconds(2) - ->send(); - $this->dispatch('playWarnSound'); - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } - return; - } - $uniqueInvalidCodes = array_unique($invalidMatCodes); if (!empty($uniqueInvalidCodes)) { Notification::make() - ->title('Invalid: Item Codes') - ->body('The following item codes should contain minimum 6 digit alpha numeric values:
' . implode(', ', $uniqueInvalidCodes)) - ->danger() - ->seconds(2) - ->send(); - $this->dispatch('playWarnSound'); + ->title('Invalid: Item Codes') + ->body('The following item codes should contain minimum 6 digit alpha numeric values:
' . implode(', ', $uniqueInvalidCodes)) + ->danger() + ->seconds(3) + ->send(); - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + $this->dispatch('playWarnSound'); + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } return; } @@ -1513,13 +1503,13 @@ class CreateSerialValidation extends CreateRecord ->title('Missing Material Quantity') ->body("The following item codes doesn't have valid material quantity:
" . implode(', ', $uniqueMissingQuanCodes)) ->danger() - ->seconds(2) + ->seconds(3) ->send(); - $this->dispatch('playWarnSound'); - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + $this->dispatch('playWarnSound'); + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } return; } @@ -1530,11 +1520,25 @@ class CreateSerialValidation extends CreateRecord ->title('Invalid Material Quantity') ->body("The following item codes doesn't have valid material quantity:
" . implode(', ', $uniqueInvalidMatQuan)) ->danger() - ->seconds(2) + ->seconds(3) ->send(); - $this->dispatch('playWarnSound'); + $this->dispatch('playWarnSound'); + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } + return; + } + if (!$validRowsFound) { + Notification::make() + ->title('Invalid Material Invoice') + ->danger() // This makes the notification red to indicate an error + ->body('Uploaded Excel sheet is empty or
contains no valid data.') + ->seconds(3) + ->send(); + + $this->dispatch('playWarnSound'); if ($disk->exists($filePath)) { $disk->delete($filePath); } @@ -1564,13 +1568,13 @@ class CreateSerialValidation extends CreateRecord ->title('Unknown: Item Codes') ->body($message) ->danger() - ->seconds(2) + ->seconds(3) ->send(); - $this->dispatch('playWarnSound'); - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + $this->dispatch('playWarnSound'); + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } return; } @@ -1595,19 +1599,20 @@ class CreateSerialValidation extends CreateRecord ->title('Unknown: Item Codes') ->body($message) ->danger() - ->seconds(2) + ->seconds(3) ->send(); + $this->dispatch('playWarnSound'); - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } return; } $invalidCodes = $matchedItems - ->filter(fn ($sticker) => empty($sticker->material_type)) //filter invalid - ->pluck('item.code') - ->toArray(); + ->filter(fn ($sticker) => empty($sticker->material_type)) //filter invalid + ->pluck('item.code') + ->toArray(); if (!empty($invalidCodes)) { @@ -1619,13 +1624,13 @@ class CreateSerialValidation extends CreateRecord ->title('Invalid: Item Codes') ->body($message) ->danger() - ->seconds(2) + ->seconds(3) ->send(); - $this->dispatch('playWarnSound'); - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + $this->dispatch('playWarnSound'); + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } return; } @@ -1661,9 +1666,9 @@ class CreateSerialValidation extends CreateRecord if ($totalExcelQty == 0) { $zeroQtyCodes[] = $code; - } elseif (!is_numeric($totalExcelQty)) { + } else if (!is_numeric($totalExcelQty)) { $nonNumericQtyCodes[] = $code; // Here you may want to check divisibility condition too - } elseif ($bundleQty != 0 && $totalExcelQty % $bundleQty != 0) { + } else if ($bundleQty != 0 && $totalExcelQty % $bundleQty != 0) { $notDivisibleCodes[] = $code; } } @@ -1679,9 +1684,10 @@ class CreateSerialValidation extends CreateRecord ->title('Invalid Bundle Quantity') ->body("$message
$codeList") ->danger() - ->seconds(2) + ->seconds(3) ->send(); - $this->dispatch('playWarnSound'); + + $this->dispatch('playWarnSound'); }; $showValidationNotification($nonNumericQtyCodes, "The following item codes contains invalid bundle quantity:"); @@ -1690,9 +1696,9 @@ class CreateSerialValidation extends CreateRecord if ($nonNumericQtyCodes || $zeroQtyCodes || $notDivisibleCodes) { - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } return; } else @@ -1837,9 +1843,10 @@ class CreateSerialValidation extends CreateRecord } else { - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } + // $hasRecords = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->first()->stickerMasterRelation->material_type ?? null; // $this->dispatch( (!empty($hasRecords) && $hasRecords) ? 'refreshMaterialInvoiceData' : 'refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId); //$this->invoiceNumber $this->dispatch('refreshMaterialInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId); @@ -1851,7 +1858,7 @@ class CreateSerialValidation extends CreateRecord ->title("Import Failed: Material Invoice") ->body("No new records were inserted for Material Invoice: '$invoiceNumber'.") ->danger() - ->seconds(2) + ->seconds(3) ->send(); $totalQuantity = SerialValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->count(); @@ -1864,16 +1871,16 @@ class CreateSerialValidation extends CreateRecord 'scanned_quantity'=> $scannedQuantity, ]); - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } $this->dispatch('refreshEmptyInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId); return; } } } - else if($invoiceType == 'S') + else if ($invoiceType == 'S') { $invalidMatCodes = []; $materialCodes = []; @@ -1895,17 +1902,17 @@ class CreateSerialValidation extends CreateRecord } if (!empty($materialCode)) { - if(Str::length($materialCode) < 6 || !ctype_alnum($materialCode)) + if (Str::length($materialCode) < 6 || !ctype_alnum($materialCode)) { $invalidMatCodes[] = $materialCode; continue; } else { - if(empty($serialNumber)) { + if (empty($serialNumber)) { $missingSerials[] = $materialCode; } - else if(Str::length($serialNumber) < 9 || !ctype_alnum($serialNumber)) + else if (Str::length($serialNumber) < 9 || !ctype_alnum($serialNumber)) { $invalidSerCodes[] = $serialNumber; } @@ -1927,32 +1934,83 @@ class CreateSerialValidation extends CreateRecord } } + $uniqueInvalidCodes = array_unique($invalidMatCodes); + + if (!empty($uniqueInvalidCodes)) { + Notification::make() + ->title('Invalid: Item Codes') + ->body('The following item codes should contain minimum 6 digit alpha numeric values:
' . implode(', ', $uniqueInvalidCodes)) + ->danger() + ->seconds(3) + ->send(); + + $this->dispatch('playWarnSound'); + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } + return; + } + + $uniqueMissingSerials = array_unique($missingSerials); + + if (!empty($uniqueMissingSerials)) { + Notification::make() + ->title('Missing Serial Numbers') + ->body("The following item codes doesn't have valid serial number:
" . implode(', ', $uniqueMissingSerials)) + ->danger() + ->seconds(3) + ->send(); + + $this->dispatch('playWarnSound'); + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } + return; + } + + $uniqueInvalidSerCodes = array_unique($invalidSerCodes); + + if (!empty($uniqueInvalidSerCodes)) { + Notification::make() + ->title('Invalid Serial Numbers') + ->body('The following serial numbers should contain minimum 9 digit alpha numeric values:
' . implode(', ', $uniqueInvalidSerCodes)) + ->danger() + ->seconds(3) + ->send(); + + $this->dispatch('playWarnSound'); + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } + return; + } + + $uniqueDupSerCodes = array_unique($duplicateSerials); + + if (!empty($uniqueDupSerCodes)) { + Notification::make() + ->title('Duplicate Serial Numbers') + ->body('The following serial numbers are already exist in invoice excel:
' . implode(', ', $uniqueDupSerCodes)) + ->danger() + ->seconds(3) + ->send(); + + $this->dispatch('playWarnSound'); + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } + return; + } + if (!$validRowsFound) { Notification::make() ->title('Invalid Serial Invoice') ->danger() // This makes the notification red to indicate an error ->body('Uploaded excel sheet is empty or
contains no valid data.') - ->seconds(2) + ->seconds(3) ->send(); - $this->dispatch('playWarnSound'); - - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } - return; - } - - $uniqueInvalidCodes = array_unique($invalidMatCodes); - - if (!empty($uniqueInvalidCodes)) { - Notification::make() - ->title('Invalid: Item Codes') - ->body('The following item codes should contain minimum 6 digit alpha numeric values:
' . implode(', ', $uniqueInvalidCodes)) - ->danger() - ->seconds(2) - ->send(); - $this->dispatch('playWarnSound'); + $this->dispatch('playWarnSound'); if ($disk->exists($filePath)) { $disk->delete($filePath); } @@ -1992,13 +2050,13 @@ class CreateSerialValidation extends CreateRecord ->title('Unknown: Item Codes') ->body($message) ->danger() - ->seconds(2) + ->seconds(3) ->send(); - $this->dispatch('playWarnSound'); - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + $this->dispatch('playWarnSound'); + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } return; } @@ -2023,13 +2081,13 @@ class CreateSerialValidation extends CreateRecord ->title('Unknown: Item Codes') ->body($message) ->danger() - ->seconds(2) + ->seconds(3) ->send(); - $this->dispatch('playWarnSound'); - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + $this->dispatch('playWarnSound'); + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } return; } @@ -2048,13 +2106,13 @@ class CreateSerialValidation extends CreateRecord ->title('Invalid: Item Codes') ->body($message) ->danger() - ->seconds(2) + ->seconds(3) ->send(); - $this->dispatch('playWarnSound'); - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + $this->dispatch('playWarnSound'); + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } return; } @@ -2079,64 +2137,13 @@ class CreateSerialValidation extends CreateRecord ->title('Invalid: Item Codes') ->body($message) ->danger() - ->seconds(2) + ->seconds(3) ->send(); - $this->dispatch('playWarnSound'); - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } - return; - } - - $uniqueMissingSerials = array_unique($missingSerials); - - if (!empty($uniqueMissingSerials)) { - Notification::make() - ->title('Missing Serial Numbers') - ->body("The following item codes doesn't have valid serial number:
" . implode(', ', $uniqueMissingSerials)) - ->danger() - ->seconds(2) - ->send(); - $this->dispatch('playWarnSound'); - - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } - return; - } - - $uniqueInvalidSerCodes = array_unique($invalidSerCodes); - - if (!empty($uniqueInvalidSerCodes)) { - Notification::make() - ->title('Invalid Serial Numbers') - ->body('The following serial numbers should contain minimum 9 digit alpha numeric values:
' . implode(', ', $uniqueInvalidSerCodes)) - ->danger() - ->seconds(2) - ->send(); - $this->dispatch('playWarnSound'); - - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } - return; - } - - $uniqueDupSerCodes = array_unique($duplicateSerials); - - if (!empty($uniqueDupSerCodes)) { - Notification::make() - ->title('Duplicate Serial Numbers') - ->body('The following serial numbers are already exist in invoice excel:
' . implode(', ', $uniqueDupSerCodes)) - ->danger() - ->seconds(2) - ->send(); - $this->dispatch('playWarnSound'); - - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + $this->dispatch('playWarnSound'); + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } return; } @@ -2148,13 +2155,13 @@ class CreateSerialValidation extends CreateRecord ->title('Duplicate Serial Numbers') ->body('The following serial numbers are already exist in database:
' . implode(', ', $existingSerialNumbers)) ->danger() - ->seconds(2) + ->seconds(3) ->send(); - $this->dispatch('playWarnSound'); - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + $this->dispatch('playWarnSound'); + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } return; } @@ -2195,6 +2202,7 @@ class CreateSerialValidation extends CreateRecord // ->success() ->seconds(1) ->send(); + $this->dispatch('playNotificationSound'); // Update total quantity in the form @@ -2218,9 +2226,10 @@ class CreateSerialValidation extends CreateRecord } else { - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } + // $hasRecords = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->first()->stickerMasterRelation->material_type ?? null; // $this->dispatch( (!empty($hasRecords) && $hasRecords) ? 'refreshMaterialInvoiceData' : 'refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId); //$this->invoiceNumber $this->dispatch('refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId); @@ -2232,9 +2241,10 @@ class CreateSerialValidation extends CreateRecord ->title("Import Failed: Serial Invoice") ->body("No new records were inserted for Serial Invoice : '$invoiceNumber'.") ->danger() - ->seconds(2) + ->seconds(3) ->send(); - $this->dispatch('playWarnSound'); + + $this->dispatch('playWarnSound'); $totalQuantity = SerialValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->count(); $scannedQuantity = SerialValidation::where('invoice_number', $invoiceNumber)->where('scanned_status', 'Scanned')->where('plant_id', $plantId)->count(); @@ -2246,9 +2256,9 @@ class CreateSerialValidation extends CreateRecord 'scanned_quantity'=> $scannedQuantity, ]); - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } $this->dispatch('refreshEmptyInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId); return; @@ -2260,13 +2270,13 @@ class CreateSerialValidation extends CreateRecord ->title('Invoice Type Not Found') ->body("Import the valid 'Invoice' file to proceed..!") ->danger() - ->seconds(2) + ->seconds(3) ->send(); $this->dispatch('playWarnSound'); - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } return; } } @@ -2317,7 +2327,7 @@ class CreateSerialValidation extends CreateRecord ->danger() ->title('Invalid Serial QR Format') ->body('Scan valid Serial QR code proceed!
Sample formats are:
123456|1234567890123/M (or)
123456|1234567890123/P (or)
123456|1234567890123/C (or)
123456|1234567890123') - ->seconds(2) + ->seconds(3) ->send(); $this->dispatch('playWarnSound'); @@ -2361,7 +2371,7 @@ class CreateSerialValidation extends CreateRecord ->title('Serial Number Not Found
Serial \''.$serialNumber.'\' not found in database for choosed plant.
') // ->body("Serial '$serialNumber' not found in database for choosed plant.").......... ->danger() - ->seconds(2) + ->seconds(3) ->send(); $this->invoiceNumber = ''; @@ -2401,7 +2411,7 @@ class CreateSerialValidation extends CreateRecord ->title('Unknown: Item Code') ->body("Item code '$itemCode' with serial number '$serialNumber' not found.") ->danger() - ->seconds(2) + ->seconds(3) ->send(); $this->dispatch('playWarnSound'); @@ -2439,7 +2449,7 @@ class CreateSerialValidation extends CreateRecord ->title('Invalid: Item Code') ->body("Scanned 'Item Code' doesn't have valid package type to proceed!") ->danger() - ->seconds(2) + ->seconds(3) ->send(); $this->dispatch('playWarnSound'); @@ -2471,7 +2481,7 @@ class CreateSerialValidation extends CreateRecord ->title('Unknown: Motor QR') ->body("Scanned 'Item Code' doesn't have 'Motor' QR to proceed!") ->danger() - ->seconds(2) + ->seconds(3) ->send(); $this->dispatch('playWarnSound'); @@ -2487,13 +2497,13 @@ class CreateSerialValidation extends CreateRecord $this->dispatch( 'refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId); return; } - else if($hadMotorQr == $hasMotorQr) + else if ($hadMotorQr == $hasMotorQr) { Notification::make() ->title('Duplicate: Motor QR') ->body("Scanned 'Motor' serial number already completed the scanning process.") ->danger() - ->seconds(2) + ->seconds(3) ->send(); $this->dispatch('playWarnSound'); @@ -2514,8 +2524,8 @@ class CreateSerialValidation extends CreateRecord $packCnt = 1; $scanCnt = 1; $record->motor_scanned_status = 1; - //if($hadPumpQr == $hasPumpQr && $hadPumpSetQr == $hasPumpSetQr) - if($hasPumpQr || $hasPumpSetQr || $hasCapacitorQr) + //if ($hadPumpQr == $hasPumpQr && $hadPumpSetQr == $hasPumpSetQr) + if ($hasPumpQr || $hasPumpSetQr || $hasCapacitorQr) { $packCnt = $hasPumpQr ? $packCnt + 1 : $packCnt; $packCnt = $hasPumpSetQr ? $packCnt + 1 : $packCnt; @@ -2525,7 +2535,7 @@ class CreateSerialValidation extends CreateRecord $scanCnt = $hadPumpSetQr ? $scanCnt + 1: $scanCnt; $scanCnt = $hadCapacitorQr ? $scanCnt + 1: $scanCnt; - if($packCnt == $scanCnt) + if ($packCnt == $scanCnt) { $record->scanned_status = 'Scanned'; } @@ -2541,7 +2551,7 @@ class CreateSerialValidation extends CreateRecord // ->title('Success: Motor QR') // ->body("'Motor' QR scanned status updated, Scan next QR.") // ->success() // commented - // ->seconds(2) + // ->seconds(3) // ->send(); $scannedQuantity = SerialValidation::where('invoice_number', $invoiceNumber)->where('scanned_status', 'Scanned')->where('plant_id', $plantId)->count(); @@ -2554,13 +2564,13 @@ class CreateSerialValidation extends CreateRecord 'scanned_quantity'=> $scannedQuantity, ]); - if($totQuan == $scannedQuantity) + if ($totQuan == $scannedQuantity) { Notification::make() ->title('Completed: Serial Invoice') ->body("Serial invoice '$invoiceNumber' completed the scanning process.
Scan the next 'Serial Invoice' to proceed!") ->success() - ->seconds(2) + ->seconds(3) ->send(); $this->dispatch('playNotificationSound'); @@ -2598,7 +2608,7 @@ class CreateSerialValidation extends CreateRecord ->title('Unknown: Pump QR') ->body("Scanned 'Item Code' doesn't have 'Pump' QR to proceed!") ->danger() - ->seconds(2) + ->seconds(3) ->send(); $this->dispatch('playWarnSound'); @@ -2615,13 +2625,13 @@ class CreateSerialValidation extends CreateRecord ]); return; } - else if($hadPumpQr == $hasPumpQr) + else if ($hadPumpQr == $hasPumpQr) { Notification::make() ->title('Duplicate: Pump QR') ->body("Scanned 'Pump' serial number already completed the scanning process.") ->danger() - ->seconds(2) + ->seconds(3) ->send(); $this->dispatch('playWarnSound'); @@ -2641,7 +2651,7 @@ class CreateSerialValidation extends CreateRecord $packCnt = 1; $scanCnt = 1; $record->pump_scanned_status = 1; - if($hasMotorQr || $hasPumpSetQr || $hasCapacitorQr) + if ($hasMotorQr || $hasPumpSetQr || $hasCapacitorQr) { $packCnt = $hasMotorQr ? $packCnt + 1 : $packCnt; $packCnt = $hasPumpSetQr ? $packCnt + 1 : $packCnt; @@ -2651,7 +2661,7 @@ class CreateSerialValidation extends CreateRecord $scanCnt = $hadPumpSetQr ? $scanCnt + 1: $scanCnt; $scanCnt = $hadCapacitorQr ? $scanCnt + 1: $scanCnt; - if($packCnt == $scanCnt) + if ($packCnt == $scanCnt) { $record->scanned_status = 'Scanned'; } @@ -2667,7 +2677,7 @@ class CreateSerialValidation extends CreateRecord // ->title('Success: Pump QR') // ->body("'Pump' QR scanned status updated, Scan next QR.") // ->success() // commented - // ->seconds(2) + // ->seconds(3) // ->send(); $scannedQuantity = SerialValidation::where('invoice_number', $invoiceNumber)->where('scanned_status', 'Scanned')->where('plant_id', $plantId)->count(); @@ -2680,13 +2690,13 @@ class CreateSerialValidation extends CreateRecord 'scanned_quantity'=> $scannedQuantity, ]); - if($totQuan == $scannedQuantity) + if ($totQuan == $scannedQuantity) { Notification::make() ->title('Completed: Serial Invoice') ->body("Serial invoice '$invoiceNumber' completed the scanning process.
Scan the next 'Serial Invoice' to proceed!") ->success() - ->seconds(2) + ->seconds(3) ->send(); $this->dispatch('playNotificationSound'); @@ -2708,7 +2718,7 @@ class CreateSerialValidation extends CreateRecord } return; } - elseif ($isMarkC) { + else if ($isMarkC) { // $record = SerialValidation::where('serial_number', $serialNumber) // ->where('plant_id', $plantId) // ->first(); @@ -2723,7 +2733,7 @@ class CreateSerialValidation extends CreateRecord ->title('Missing: Panel Box Code') ->body("Scanned 'Item Code' doesn't have 'Panel Box Code' to proceed!") ->danger() - ->seconds(2) + ->seconds(3) ->send(); $this->dispatch('playWarnSound'); @@ -2740,13 +2750,13 @@ class CreateSerialValidation extends CreateRecord $this->dispatch( 'refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId); return; } - else if($hadCapacitorQr == '1' && $hasCapacitorQr) + else if ($hadCapacitorQr == '1' && $hasCapacitorQr) { Notification::make() ->title('Duplicate: Capacitor QR') ->body("Scanned 'Capacitor' serial number already completed the scanning process.") ->danger() - ->seconds(2) + ->seconds(3) ->send(); $this->dispatch('playWarnSound'); @@ -2783,7 +2793,7 @@ class CreateSerialValidation extends CreateRecord $this->dispatch( 'refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId); return; } - elseif ($isMarkPs) + else if ($isMarkPs) { // $record = SerialValidation::where('serial_number', $serialNumber) // ->where('plant_id', $plantId) @@ -2798,7 +2808,7 @@ class CreateSerialValidation extends CreateRecord ->title('Unknown: Pump Set QR') ->body("Scanned 'Item Code' doesn't have 'Pump Set' QR to proceed!") ->danger() - ->seconds(2) + ->seconds(3) ->send(); $this->dispatch('playWarnSound'); @@ -2814,13 +2824,13 @@ class CreateSerialValidation extends CreateRecord $this->dispatch('refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId); return; } - else if($hadPumpSetQr == $hasPumpSetQr) + else if ($hadPumpSetQr == $hasPumpSetQr) { Notification::make() ->title('Duplicate: Pump Set QR') ->body("Scanned 'Pump Set' serial number already completed the scanning process.") ->danger() - ->seconds(2) + ->seconds(3) ->send(); $this->dispatch('playWarnSound'); @@ -2848,8 +2858,8 @@ class CreateSerialValidation extends CreateRecord $packCnt = 1; $scanCnt = 1; $record->scanned_status_set = 1; - // if($hadMotorQr == $hasMotorQr && $hadPumpQr == $hasPumpQr && ($hadCapacitorQr == '1' && $hasCapacitorQr)) - if($hasMotorQr || $hasPumpQr || $hasCapacitorQr) + // if ($hadMotorQr == $hasMotorQr && $hadPumpQr == $hasPumpQr && ($hadCapacitorQr == '1' && $hasCapacitorQr)) + if ($hasMotorQr || $hasPumpQr || $hasCapacitorQr) { $packCnt = $hasMotorQr ? $packCnt + 1 : $packCnt; $packCnt = $hasPumpQr ? $packCnt + 1 : $packCnt; @@ -2859,7 +2869,7 @@ class CreateSerialValidation extends CreateRecord $scanCnt = $hadPumpQr ? $scanCnt + 1: $scanCnt; $scanCnt = $hadCapacitorQr ? $scanCnt + 1: $scanCnt; - if($packCnt == $scanCnt) + if ($packCnt == $scanCnt) { $record->scanned_status = 'Scanned'; } @@ -2875,7 +2885,7 @@ class CreateSerialValidation extends CreateRecord // ->title('Success: Pump Set QR') // ->body("'Pump Set' QR scanned status updated, Scan next QR.") // ->success() // commented - // ->seconds(2) + // ->seconds(3) // ->send(); @@ -2895,14 +2905,14 @@ class CreateSerialValidation extends CreateRecord $totMQuan = SerialValidation::where('invoice_number', $invoiceNumber)->whereNotNull('quantity')->where('plant_id', $plantId)->count(); //->where('quantity', '!=', '') $scanMQuan = SerialValidation::where('invoice_number', $invoiceNumber)->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $plantId)->count(); - if($totQuan == $scannedQuantity) + if ($totQuan == $scannedQuantity) { Notification::make() - ->title('Completed: Serial Invoice') - ->body("Serial invoice '$invoiceNumber' completed the scanning process.
Scan the next 'Serial Invoice' to proceed!") - ->success() - ->seconds(2) - ->send(); + ->title('Completed: Serial Invoice') + ->body("Serial invoice '$invoiceNumber' completed the scanning process.
Scan the next 'Serial Invoice' to proceed!") + ->success() + ->seconds(3) + ->send(); $this->dispatch('playNotificationSound');