diff --git a/app/Filament/Resources/LocatorInvoiceValidationResource.php b/app/Filament/Resources/LocatorInvoiceValidationResource.php index 112f818..0ce2146 100644 --- a/app/Filament/Resources/LocatorInvoiceValidationResource.php +++ b/app/Filament/Resources/LocatorInvoiceValidationResource.php @@ -56,7 +56,7 @@ class LocatorInvoiceValidationResource extends Resource ->options(function (callable $get) { $userHas = Filament::auth()->user()->plant_id; - return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray(); + return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray(); }) ->disabled(fn (Get $get) => $get('invoice_number')) ->required() @@ -498,7 +498,7 @@ class LocatorInvoiceValidationResource extends Resource ->options(function (callable $get) { $userHas = Filament::auth()->user()->plant_id; - return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray(); + return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray(); }) ->label('Select Plant') ->required() @@ -534,8 +534,7 @@ class LocatorInvoiceValidationResource extends Resource // $invoiceNumber = trim(str_replace('.xlsx', '', $originalName)); // $originalNameOnly = pathinfo($originalName, PATHINFO_FILENAME); - $folderPath = Configuration::where('c_name', 'INVOICE_FOLDER_PATH') - ->value('c_value'); + $folderPath = 'ExportDispatch'; // Configuration::where('c_name', 'INVOICE_FOLDER_PATH')->value('c_value'); $fullFolderPath = "uploads/$folderPath"; @@ -708,7 +707,7 @@ class LocatorInvoiceValidationResource extends Resource ->options(function (callable $get) { $userHas = Filament::auth()->user()->plant_id; - return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray(); + return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray(); }) ->reactive() ->afterStateUpdated(function ($state, callable $set, callable $get): void { diff --git a/app/Filament/Resources/LocatorInvoiceValidationResource/Pages/CreateLocatorInvoiceValidation.php b/app/Filament/Resources/LocatorInvoiceValidationResource/Pages/CreateLocatorInvoiceValidation.php index bb17fc2..9dce2ff 100644 --- a/app/Filament/Resources/LocatorInvoiceValidationResource/Pages/CreateLocatorInvoiceValidation.php +++ b/app/Filament/Resources/LocatorInvoiceValidationResource/Pages/CreateLocatorInvoiceValidation.php @@ -7,10 +7,9 @@ use App\Models\Configuration; use App\Models\Locator; use App\Models\LocatorInvoiceValidation; use App\Models\PalletValidation; -use Filament\Actions; use Filament\Facades\Filament; -use Filament\Resources\Pages\CreateRecord; use Filament\Notifications\Notification; +use Filament\Resources\Pages\CreateRecord; use Maatwebsite\Excel\Facades\Excel; use Storage; use Str; @@ -18,6 +17,7 @@ use Str; class CreateLocatorInvoiceValidation extends CreateRecord { protected static string $resource = LocatorInvoiceValidationResource::class; + protected static string $view = 'filament.resources.pallet-validation-resource.pages.create-locator-invoice-validation'; public $plantId; @@ -26,7 +26,9 @@ class CreateLocatorInvoiceValidation extends CreateRecord public $pallet_number; - public $serial_number, $snoCount; + public $serial_number; + + public $snoCount; public $locator_number; @@ -63,8 +65,7 @@ class CreateLocatorInvoiceValidation extends CreateRecord $operatorName = $user->name; - if(!$plantId) - { + if (! $plantId) { Notification::make() ->title('Plant Not Found') ->body("Plant can't be empty!") @@ -74,47 +75,44 @@ class CreateLocatorInvoiceValidation extends CreateRecord $this->dispatch('loadData', '', $plantId); $this->form->fill([ - 'plant_id' => $plantId, - 'plant' => $plantId, + 'plant_id' => $plantId, + 'plant' => $plantId, 'invoice_number' => $invoiceNumber, 'pallet_number' => null, 'serial_number' => null, 'sno_quantity' => 0, 'scan_quantity' => 0, 'pend_quantity' => 0, - 'created_by' => $operatorName, - 'scanned_by' => $operatorName, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, ]); + return; } - $filename = $invoiceNumber . '.xlsx'; + $filename = $invoiceNumber.'.xlsx'; - $folderPath = Configuration::where('c_name', 'INVOICE_FOLDER_PATH') - ->where('plant_id', $plantId) - ->value('c_value'); + $folderPath = 'ExportDispatch'; // Configuration::where('c_name', 'INVOICE_FOLDER_PATH')->where('plant_id', $plantId)->value('c_value'); $fullFolderPath = "uploads/$folderPath"; $directory = $fullFolderPath; $disk = Storage::disk('local'); - $filePath = $directory . '/' . $filename; + $filePath = $directory.'/'.$filename; - try - { + try { // $record1 = LocatorInvoiceValidation::query() // ->where('plant_id', $plantId) // ->where('invoice_number', $invoiceNumber) // ->first(); $records = LocatorInvoiceValidation::where('plant_id', $plantId) - ->where('invoice_number', $invoiceNumber) - ->get(); + ->where('invoice_number', $invoiceNumber) + ->get(); $allScanned = true; - foreach ($records as $record) - { + foreach ($records as $record) { if (($record->scanned_status == null) || trim($record->scanned_status) == '') { $allScanned = false; break; @@ -129,23 +127,23 @@ class CreateLocatorInvoiceValidation extends CreateRecord ->duration(5000) ->send(); - if ($disk->exists($filePath)) - { + if ($disk->exists($filePath)) { $disk->delete($filePath); } $this->dispatch('loadData', '', $plantId); $this->form->fill([ - 'plant_id' => $plantId, - 'plant' => $plantId, + 'plant_id' => $plantId, + 'plant' => $plantId, 'invoice_number' => null, 'pallet_number' => null, 'serial_number' => null, 'sno_quantity' => 0, 'scan_quantity' => 0, 'pend_quantity' => 0, - 'created_by' => $operatorName, - 'scanned_by' => $operatorName, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, ]); + return; } @@ -153,27 +151,21 @@ class CreateLocatorInvoiceValidation extends CreateRecord ->where('invoice_number', $invoiceNumber) ->count('invoice_number'); - if($invoiceExist <= 0) - { - $filename = $invoiceNumber . '.xlsx'; + if ($invoiceExist <= 0) { + $filename = $invoiceNumber.'.xlsx'; - $folderPath = Configuration::where('c_name', 'INVOICE_FOLDER_PATH') - ->where('plant_id', $plantId) - ->value('c_value'); + $folderPath = 'ExportDispatch'; // Configuration::where('c_name', 'INVOICE_FOLDER_PATH')->where('plant_id', $plantId)->value('c_value'); $fullFolderPath = "uploads/$folderPath"; $directory = $fullFolderPath; $disk = Storage::disk('local'); - $filePath = $directory . '/' . $filename; + $filePath = $directory.'/'.$filename; $fullPath = $disk->path($filePath); - if ($disk->exists($filePath)) - { + if ($disk->exists($filePath)) { $fullPath = $disk->path($filePath); - } - else - { + } else { Notification::make() ->title('Invoice File Not Found') ->body("Import the scanned 'Invoice' file to proceed..!") @@ -182,27 +174,26 @@ class CreateLocatorInvoiceValidation extends CreateRecord ->send(); $this->form->fill([ - 'plant_id' => $plantId, - 'plant' => $plantId, + 'plant_id' => $plantId, + 'plant' => $plantId, 'invoice_number' => null, 'pallet_number' => null, 'serial_number' => null, 'sno_quantity' => 0, 'scan_quantity' => 0, 'pend_quantity' => 0, - 'created_by' => $operatorName, - 'scanned_by' => $operatorName, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, ]); $this->dispatch('loadData', '', $plantId); + return; } - if ($fullPath && file_exists($fullPath)) - { + if ($fullPath && file_exists($fullPath)) { $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 'Serial Invoice' file to proceed..!") @@ -212,54 +203,47 @@ class CreateLocatorInvoiceValidation extends CreateRecord ->duration(5000) ->send(); - if ($disk->exists($filePath)) - { + if ($disk->exists($filePath)) { $disk->delete($filePath); } $this->dispatch('loadData', '', $plantId); $this->form->fill([ - 'plant_id' => $plantId, - 'plant' => $plantId, + 'plant_id' => $plantId, + 'plant' => $plantId, 'invoice_number' => null, 'pallet_number' => null, 'serial_number' => null, 'sno_quantity' => 0, 'scan_quantity' => 0, 'pend_quantity' => 0, - 'created_by' => $operatorName, - 'scanned_by' => $operatorName, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, ]); + return; } - $invalidSerialCodes=[]; + $invalidSerialCodes = []; $duplicateSerials = []; $seenSerialNumbers = []; $validRowsFound = false; - foreach ($rows as $index => $row) - { - if ($index === 0) continue; // Skip header - - $serialNumber = trim((string)($row[0] ?? '')); - - if (empty($serialNumber)) - { + foreach ($rows as $index => $row) { + if ($index === 0) { continue; - } - else - { - if(Str::length($serialNumber) < 9 || Str::length($serialNumber) > 20 || !ctype_alnum($serialNumber)) - { + } // Skip header + + $serialNumber = trim((string) ($row[0] ?? '')); + + if (empty($serialNumber)) { + continue; + } else { + if (Str::length($serialNumber) < 9 || Str::length($serialNumber) > 20 || ! ctype_alnum($serialNumber)) { $invalidSerialCodes[] = $serialNumber; - } - else - { + } else { if (in_array($serialNumber, $seenSerialNumbers)) { $duplicateSerials[] = $serialNumber; - } - else - { + } else { $seenSerialNumbers[] = $serialNumber; $validRowsFound = true; } @@ -269,10 +253,10 @@ class CreateLocatorInvoiceValidation extends CreateRecord $uniqueSerialCodes = array_unique($invalidSerialCodes); - if (!empty($uniqueSerialCodes)) { + if (! empty($uniqueSerialCodes)) { Notification::make() ->title('Invalid Serial Numbers Found') - ->body('The following serial numbers should contain minimum 9 digit (and maximum 20 digit) alpha numeric values:
' . implode(', ', $uniqueSerialCodes)) + ->body('The following serial numbers should contain minimum 9 digit (and maximum 20 digit) alpha numeric values:
'.implode(', ', $uniqueSerialCodes)) ->danger() ->duration(5000) ->send(); @@ -282,26 +266,27 @@ class CreateLocatorInvoiceValidation extends CreateRecord // } $this->dispatch('loadData', '', $plantId); $this->form->fill([ - 'plant_id' => $plantId, - 'plant' => $plantId, + 'plant_id' => $plantId, + 'plant' => $plantId, 'invoice_number' => $invoiceNumber, 'pallet_number' => null, 'serial_number' => null, 'sno_quantity' => 0, 'scan_quantity' => 0, 'pend_quantity' => 0, - 'created_by' => $operatorName, - 'scanned_by' => $operatorName, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, ]); + return; } $duplicateSerialCodes = array_unique($duplicateSerials); - if (!empty($duplicateSerialCodes)) { + if (! empty($duplicateSerialCodes)) { Notification::make() ->title('Duplicate Serial Numbers Found') - ->body('The following serial numbers are already exist in imported excel:
' . implode(', ', $duplicateSerialCodes)) + ->body('The following serial numbers are already exist in imported excel:
'.implode(', ', $duplicateSerialCodes)) ->danger() ->duration(5000) ->send(); @@ -311,20 +296,21 @@ class CreateLocatorInvoiceValidation extends CreateRecord // } $this->dispatch('loadData', '', $plantId); $this->form->fill([ - 'plant_id' => $plantId, + 'plant_id' => $plantId, 'invoice_number' => $invoiceNumber, 'pallet_number' => null, 'serial_number' => null, 'sno_quantity' => 0, 'scan_quantity' => 0, 'pend_quantity' => 0, - 'created_by' => $operatorName, - 'scanned_by' => $operatorName, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, ]); + return; } - if (!$validRowsFound) { + if (! $validRowsFound) { Notification::make() ->title('Invalid Locator Invoice Found') ->body('Uploaded excel sheet is empty or
contains no valid data.') @@ -337,17 +323,18 @@ class CreateLocatorInvoiceValidation extends CreateRecord } $this->dispatch('loadData', '', $plantId); $this->form->fill([ - 'plant_id' => $plantId, - 'plant' => $plantId, + 'plant_id' => $plantId, + 'plant' => $plantId, 'invoice_number' => null, 'pallet_number' => null, 'serial_number' => null, 'sno_quantity' => 0, 'scan_quantity' => 0, 'pend_quantity' => 0, - 'created_by' => $operatorName, - 'scanned_by' => $operatorName, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, ]); + return; } @@ -359,10 +346,10 @@ class CreateLocatorInvoiceValidation extends CreateRecord ->pluck('serial_number') ->toArray(); - if (!empty($existingSerials)) { + if (! empty($existingSerials)) { Notification::make() ->title('Duplicate Serial Numbers Found') - ->body('The following serial numbers already exist with a different invoice number:
' . implode(', ', $existingSerials)) + ->body('The following serial numbers already exist with a different invoice number:
'.implode(', ', $existingSerials)) ->danger() ->duration(5000) ->send(); @@ -373,24 +360,22 @@ class CreateLocatorInvoiceValidation extends CreateRecord // } $this->dispatch('loadData', '', $plantId); $this->form->fill([ - 'plant_id' => $plantId, - 'plant' => $plantId, + 'plant_id' => $plantId, + 'plant' => $plantId, 'invoice_number' => $invoiceNumber, 'pallet_number' => null, 'serial_number' => null, 'sno_quantity' => 0, 'scan_quantity' => 0, 'pend_quantity' => 0, - 'created_by' => $operatorName, - 'scanned_by' => $operatorName, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, ]); + return; - } - else - { + } else { $createdAny = false; - foreach ($seenSerialNumbers as $serialNumber) - { + foreach ($seenSerialNumbers as $serialNumber) { // $deleted = LocatorInvoiceValidation::where('invoice_number', $invoiceNumber) // ->where('serial_number', $serialNumber) // ->where('plant_id', $plantId) @@ -435,8 +420,7 @@ class CreateLocatorInvoiceValidation extends CreateRecord } - if ($createdAny) - { + if ($createdAny) { Notification::make() ->title('Success: Invoice inserted successfully.') ->success() @@ -460,8 +444,8 @@ class CreateLocatorInvoiceValidation extends CreateRecord $scannedCount = LocatorInvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->where('scanned_status', '=', 'Scanned')->count(); $this->form->fill([ - 'plant_id' => $plantId, - 'plant' => $plantId, + 'plant_id' => $plantId, + 'plant' => $plantId, 'invoice_number' => $invoiceNumber, 'update_invoice' => 0, 'pallet_number' => null, @@ -469,35 +453,29 @@ class CreateLocatorInvoiceValidation extends CreateRecord 'sno_quantity' => $snoCount, 'scan_quantity' => $scannedCount, 'pend_quantity' => $pendingCount, - 'created_by' => $operatorName, - 'scanned_by' => $operatorName, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, ]); $this->dispatch('loadData', $invoiceNumber, $plantId); } } } - } - else if($updateStatus == 1) - { - $filename = $invoiceNumber . '.xlsx'; + } elseif ($updateStatus == 1) { + $filename = $invoiceNumber.'.xlsx'; - $folderPath = Configuration::where('c_name', 'INVOICE_FOLDER_PATH') - ->where('plant_id', $plantId) - ->value('c_value'); + $folderPath = 'ExportDispatch'; // Configuration::where('c_name', 'INVOICE_FOLDER_PATH')->where('plant_id', $plantId)->value('c_value'); $fullFolderPath = "uploads/$folderPath"; $directory = $fullFolderPath; $disk = Storage::disk('local'); - $filePath = $directory . '/' . $filename; + $filePath = $directory.'/'.$filename; $fullPath = $disk->path($filePath); if ($disk->exists($filePath)) { $fullPath = $disk->path($filePath); - } - else - { + } else { Notification::make() ->title('Updated Invoice File Not Found') ->body("Import the updated 'Invoice' file to proceed..!") @@ -507,150 +485,27 @@ class CreateLocatorInvoiceValidation extends CreateRecord $this->dispatch('loadData', '', $plantId); $this->form->fill([ - 'plant_id' => $plantId, - 'plant' => $plantId, + 'plant_id' => $plantId, + 'plant' => $plantId, 'invoice_number' => null, 'pallet_number' => null, 'serial_number' => null, 'sno_quantity' => 0, 'scan_quantity' => 0, 'pend_quantity' => 0, - 'created_by' => $operatorName, - 'scanned_by' => $operatorName, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, ]); + return; } // session()->flash('invoice_valid', true); - if ($fullPath && file_exists($fullPath)) - { + if ($fullPath && file_exists($fullPath)) { $rows = Excel::toArray(null, $fullPath)[0]; - if((count($rows) - 1) <= 0) - { - Notification::make() - ->title('Invalid Updated Locator Invoice Found') - ->body('Uploaded excel sheet is empty or
contains no valid data.') - ->danger() - ->duration(5000) - ->send(); - - if ($disk->exists($filePath)) - { - $disk->delete($filePath); - } - $this->dispatch('loadData', '', $plantId); - $this->form->fill([ - 'plant_id' => $plantId, - 'plant' => $plantId, - 'invoice_number' => null, - 'pallet_number' => null, - 'serial_number' => null, - 'sno_quantity' => 0, - 'scan_quantity' => 0, - 'pend_quantity' => 0, - 'created_by' => $operatorName, - 'scanned_by' => $operatorName, - ]); - return; - } - - $invalidSerialCodes=[]; - $duplicateSerials = []; - $seenSerialNumbers = []; - $validRowsFound = false; - - foreach ($rows as $index => $row) - { - if ($index === 0) continue; // Skip header - - $serialNumber = trim((string) ($row[0] ?? '')); - - if (empty($serialNumber)) - { - continue; - } - else - { - if(Str::length($serialNumber) < 9 || Str::length($serialNumber) > 20 || !ctype_alnum($serialNumber)) - { - $invalidSerialCodes[] = $serialNumber; - } - else - { - if (in_array($serialNumber, $seenSerialNumbers)) { - $duplicateSerials[] = $serialNumber; - } - else - { - $seenSerialNumbers[] = $serialNumber; - $validRowsFound = true; - } - } - } - } - - $uniqueSerialCodes = array_unique($invalidSerialCodes); - - if (!empty($uniqueSerialCodes)) { - Notification::make() - ->title('Invalid Serial Numbers Found') - ->body('The following serial numbers should contain minimum 9 digit (and maximum 20 digit) alpha numeric values:
' . implode(', ', $uniqueSerialCodes)) - ->danger() - ->duration(5000) - ->send(); - - // if ($disk->exists($filePath)) { - // $disk->delete($filePath); - // } - $this->dispatch('loadData', '', $plantId); - $this->form->fill([ - 'plant_id' => $plantId, - 'plant' => $plantId, - 'invoice_number' => $invoiceNumber, - 'pallet_number' => null, - 'serial_number' => null, - 'sno_quantity' => 0, - 'scan_quantity' => 0, - 'pend_quantity' => 0, - 'created_by' => $operatorName, - 'scanned_by' => $operatorName, - ]); - return; - } - - $duplicateSerialCodes = array_unique($duplicateSerials); - - if (!empty($duplicateSerialCodes)) { - Notification::make() - ->title('Duplicate Serial Numbers Found') - ->body('The following serial numbers are already exist in imported excel:
' . implode(', ', $duplicateSerialCodes)) - ->danger() - ->duration(5000) - ->send(); - - // if ($disk->exists($filePath)) - // { - // $disk->delete($filePath); - // } - $this->dispatch('loadData', '', $plantId); - $this->form->fill([ - 'plant_id' => $plantId, - 'plant' => $plantId, - 'invoice_number' => $invoiceNumber, - 'pallet_number' => null, - 'serial_number' => null, - 'sno_quantity' => 0, - 'scan_quantity' => 0, - 'pend_quantity' => 0, - 'created_by' => $operatorName, - 'scanned_by' => $operatorName, - ]); - return; - } - - if (!$validRowsFound) { + if ((count($rows) - 1) <= 0) { Notification::make() ->title('Invalid Updated Locator Invoice Found') ->body('Uploaded excel sheet is empty or
contains no valid data.') @@ -663,17 +518,135 @@ class CreateLocatorInvoiceValidation extends CreateRecord } $this->dispatch('loadData', '', $plantId); $this->form->fill([ - 'plant_id' => $plantId, - 'plant' => $plantId, + 'plant_id' => $plantId, + 'plant' => $plantId, 'invoice_number' => null, 'pallet_number' => null, 'serial_number' => null, 'sno_quantity' => 0, 'scan_quantity' => 0, 'pend_quantity' => 0, - 'created_by' => $operatorName, - 'scanned_by' => $operatorName, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, ]); + + return; + } + + $invalidSerialCodes = []; + $duplicateSerials = []; + $seenSerialNumbers = []; + $validRowsFound = false; + + foreach ($rows as $index => $row) { + if ($index === 0) { + continue; + } // Skip header + + $serialNumber = trim((string) ($row[0] ?? '')); + + if (empty($serialNumber)) { + continue; + } else { + if (Str::length($serialNumber) < 9 || Str::length($serialNumber) > 20 || ! ctype_alnum($serialNumber)) { + $invalidSerialCodes[] = $serialNumber; + } else { + if (in_array($serialNumber, $seenSerialNumbers)) { + $duplicateSerials[] = $serialNumber; + } else { + $seenSerialNumbers[] = $serialNumber; + $validRowsFound = true; + } + } + } + } + + $uniqueSerialCodes = array_unique($invalidSerialCodes); + + if (! empty($uniqueSerialCodes)) { + Notification::make() + ->title('Invalid Serial Numbers Found') + ->body('The following serial numbers should contain minimum 9 digit (and maximum 20 digit) alpha numeric values:
'.implode(', ', $uniqueSerialCodes)) + ->danger() + ->duration(5000) + ->send(); + + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } + $this->dispatch('loadData', '', $plantId); + $this->form->fill([ + 'plant_id' => $plantId, + 'plant' => $plantId, + 'invoice_number' => $invoiceNumber, + 'pallet_number' => null, + 'serial_number' => null, + 'sno_quantity' => 0, + 'scan_quantity' => 0, + 'pend_quantity' => 0, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, + ]); + + return; + } + + $duplicateSerialCodes = array_unique($duplicateSerials); + + if (! empty($duplicateSerialCodes)) { + Notification::make() + ->title('Duplicate Serial Numbers Found') + ->body('The following serial numbers are already exist in imported excel:
'.implode(', ', $duplicateSerialCodes)) + ->danger() + ->duration(5000) + ->send(); + + // if ($disk->exists($filePath)) + // { + // $disk->delete($filePath); + // } + $this->dispatch('loadData', '', $plantId); + $this->form->fill([ + 'plant_id' => $plantId, + 'plant' => $plantId, + 'invoice_number' => $invoiceNumber, + 'pallet_number' => null, + 'serial_number' => null, + 'sno_quantity' => 0, + 'scan_quantity' => 0, + 'pend_quantity' => 0, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, + ]); + + return; + } + + if (! $validRowsFound) { + Notification::make() + ->title('Invalid Updated Locator Invoice Found') + ->body('Uploaded excel sheet is empty or
contains no valid data.') + ->danger() + ->duration(5000) + ->send(); + + if ($disk->exists($filePath)) { + $disk->delete($filePath); + } + $this->dispatch('loadData', '', $plantId); + $this->form->fill([ + 'plant_id' => $plantId, + 'plant' => $plantId, + 'invoice_number' => null, + 'pallet_number' => null, + 'serial_number' => null, + 'sno_quantity' => 0, + 'scan_quantity' => 0, + 'pend_quantity' => 0, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, + ]); + return; } @@ -685,10 +658,10 @@ class CreateLocatorInvoiceValidation extends CreateRecord ->pluck('serial_number') ->toArray(); - if (!empty($existingSerials)) { + if (! empty($existingSerials)) { Notification::make() ->title('Duplicate Serial Numbers Found') - ->body('The following serial numbers already exist with a different invoice number:
' . implode(', ', $existingSerials)) + ->body('The following serial numbers already exist with a different invoice number:
'.implode(', ', $existingSerials)) ->danger() ->duration(5000) ->send(); @@ -698,24 +671,22 @@ class CreateLocatorInvoiceValidation extends CreateRecord // } $this->dispatch('loadData', '', $plantId); $this->form->fill([ - 'plant_id' => $plantId, - 'plant' => $plantId, + 'plant_id' => $plantId, + 'plant' => $plantId, 'invoice_number' => $invoiceNumber, 'pallet_number' => null, 'serial_number' => null, 'sno_quantity' => 0, 'scan_quantity' => 0, 'pend_quantity' => 0, - 'created_by' => $operatorName, - 'scanned_by' => $operatorName, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, ]); + return; - } - else - { + } else { $createdAny = false; - foreach ($seenSerialNumbers as $serialNumber) - { + foreach ($seenSerialNumbers as $serialNumber) { $existingRecord = LocatorInvoiceValidation::where('invoice_number', $invoiceNumber) ->where('serial_number', $serialNumber) ->where('plant_id', $plantId) @@ -739,8 +710,7 @@ class CreateLocatorInvoiceValidation extends CreateRecord $createdAny = true; } - if ($createdAny) - { + if ($createdAny) { Notification::make() ->title('Success: Invoice updated successfully.') ->success() @@ -764,8 +734,8 @@ class CreateLocatorInvoiceValidation extends CreateRecord $scannedCount = LocatorInvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->where('scanned_status', '=', 'Scanned')->count(); $this->form->fill([ - 'plant_id' => $plantId, - 'plant' => $plantId, + 'plant_id' => $plantId, + 'plant' => $plantId, 'invoice_number' => $invoiceNumber, 'update_invoice' => 0, 'pallet_number' => null, @@ -773,17 +743,15 @@ class CreateLocatorInvoiceValidation extends CreateRecord 'sno_quantity' => $snoCount, 'scan_quantity' => $scannedCount, 'pend_quantity' => $pendingCount, - 'created_by' => $operatorName, - 'scanned_by' => $operatorName, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, ]); } $this->dispatch('loadData', $invoiceNumber, $plantId); } } - } - else - { + } else { Notification::make() ->title("Start the scanning process for scanned invoice number '$invoiceNumber'!") ->info() @@ -797,24 +765,22 @@ class CreateLocatorInvoiceValidation extends CreateRecord $scannedCount = LocatorInvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->where('scanned_status', '=', 'Scanned')->count(); $this->form->fill([ - 'plant_id' => $plantId, - 'plant' => $plantId, + 'plant_id' => $plantId, + 'plant' => $plantId, 'invoice_number' => $invoiceNumber, 'pallet_number' => null, 'serial_number' => null, 'sno_quantity' => $snoCount, 'scan_quantity' => $scannedCount, 'pend_quantity' => $pendingCount, - 'created_by' => $operatorName, - 'scanned_by' => $operatorName, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, ]); $this->dispatch('loadData', $invoiceNumber, $plantId); } - } - catch (\Exception $e) - { + } catch (\Exception $e) { Notification::make() ->title('Error: Locator invoice insertion (or updation).') ->body($e->getMessage()) @@ -830,16 +796,16 @@ class CreateLocatorInvoiceValidation extends CreateRecord $this->dispatch('loadData', $invoiceNumber, $plantId); $this->form->fill([ - 'plant_id' => $plantId, - 'plant' => $plantId, + 'plant_id' => $plantId, + 'plant' => $plantId, 'invoice_number' => $invoiceNumber, 'pallet_number' => null, 'serial_number' => null, 'sno_quantity' => $snoCount, 'scan_quantity' => $scannedCount, 'pend_quantity' => $pendingCount, - 'created_by' => $operatorName, - 'scanned_by' => $operatorName, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, ]); } } @@ -874,21 +840,18 @@ class CreateLocatorInvoiceValidation extends CreateRecord $UnknownSerialNumbers = []; - $filename = $invoiceNumber . '.xlsx'; + $filename = $invoiceNumber.'.xlsx'; - $folderPath = Configuration::where('c_name', 'INVOICE_FOLDER_PATH') - ->where('plant_id', $plantId) - ->value('c_value'); + $folderPath = 'ExportDispatch'; // Configuration::where('c_name', 'INVOICE_FOLDER_PATH')->where('plant_id', $plantId)->value('c_value'); $fullFolderPath = "uploads/$folderPath"; $directory = $fullFolderPath; $disk = Storage::disk('local'); - $filePath = $directory . '/' . $filename; + $filePath = $directory.'/'.$filename; $invExist = LocatorInvoiceValidation::where('plant_id', $plantId)->where('invoice_number', $invoiceNumber)->first(); - if (!$invExist) - { + if (! $invExist) { Notification::make() ->title('Invoice Not Found') ->body("Scanned invoice number '$invoiceNumber' does not exist in invoice table!
Import the scanned 'Invoice' file to proceed..!") @@ -898,29 +861,27 @@ class CreateLocatorInvoiceValidation extends CreateRecord $this->dispatch('loadData', $invoiceNumber, $plantId); $this->form->fill([ - 'plant_id' => $plantId, - 'plant' => $plantId, + 'plant_id' => $plantId, + 'plant' => $plantId, 'invoice_number' => null, 'pallet_number' => null, 'serial_number' => null, 'sno_quantity' => 0, 'scan_quantity' => 0, 'pend_quantity' => 0, - 'created_by' => $operatorName, - 'scanned_by' => $operatorName, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, ]); + return; - } - else - { + } else { $records = LocatorInvoiceValidation::where('plant_id', $plantId) - ->where('invoice_number', $invoiceNumber) - ->get(); + ->where('invoice_number', $invoiceNumber) + ->get(); $allScanned = true; - foreach ($records as $record) - { + foreach ($records as $record) { if (($record->scanned_status == null) || trim($record->scanned_status) == '') { $allScanned = false; break; @@ -935,23 +896,23 @@ class CreateLocatorInvoiceValidation extends CreateRecord ->duration(1000) ->send(); - if ($disk->exists($filePath)) - { + if ($disk->exists($filePath)) { $disk->delete($filePath); } $this->dispatch('loadData', '', $plantId); $this->form->fill([ - 'plant_id' => $plantId, - 'plant' => $plantId, + 'plant_id' => $plantId, + 'plant' => $plantId, 'invoice_number' => null, 'pallet_number' => null, 'serial_number' => null, 'sno_quantity' => 0, 'scan_quantity' => 0, 'pend_quantity' => 0, - 'created_by' => $operatorName, - 'scanned_by' => $operatorName, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, ]); + return; } } @@ -962,8 +923,7 @@ class CreateLocatorInvoiceValidation extends CreateRecord $scannedCount = LocatorInvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->where('scanned_status', '=', 'Scanned')->count(); - if ($palletNumber == '' || $palletNumber == null) - { + if ($palletNumber == '' || $palletNumber == null) { Notification::make() ->title("Pallet number can't be empty!") ->danger() @@ -972,8 +932,8 @@ class CreateLocatorInvoiceValidation extends CreateRecord $this->dispatch('loadData', $invoiceNumber, $plantId); $this->form->fill([ - 'plant_id' => $plantId, - 'plant' => $plantId, + 'plant_id' => $plantId, + 'plant' => $plantId, 'invoice_number' => $invoiceNumber, 'pallet_number' => null, 'update_invoice' => 0, @@ -981,14 +941,14 @@ class CreateLocatorInvoiceValidation extends CreateRecord 'sno_quantity' => $snoCount, 'scan_quantity' => $scannedCount, 'pend_quantity' => $pendingCount, - 'created_by' => $operatorName, - 'scanned_by' => $operatorName, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, ]); + return; } - if (strlen($palletNumber) < 10) - { + if (strlen($palletNumber) < 10) { Notification::make() ->title("Pallet number '$palletNumber' must be at least 10 digits.") ->danger() @@ -997,8 +957,8 @@ class CreateLocatorInvoiceValidation extends CreateRecord $this->dispatch('loadData', $invoiceNumber, $plantId); $this->form->fill([ - 'plant_id' => $plantId, - 'plant' => $plantId, + 'plant_id' => $plantId, + 'plant' => $plantId, 'invoice_number' => $invoiceNumber, 'pallet_number' => null, 'update_invoice' => 0, @@ -1006,18 +966,18 @@ class CreateLocatorInvoiceValidation extends CreateRecord 'sno_quantity' => $snoCount, 'scan_quantity' => $scannedCount, 'pend_quantity' => $pendingCount, - 'created_by' => $operatorName, - 'scanned_by' => $operatorName, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, ]); + return; } $palletRecord = PalletValidation::where('plant_id', $plantId) - ->where('pallet_number', $palletNumber) - ->first(); + ->where('pallet_number', $palletNumber) + ->first(); - if (!$palletRecord) - { + if (! $palletRecord) { Notification::make() ->title("Pallet number '{$palletNumber}' does not exist in pallet table.") ->danger() @@ -1026,8 +986,8 @@ class CreateLocatorInvoiceValidation extends CreateRecord $this->dispatch('loadData', $invoiceNumber, $plantId); $this->form->fill([ - 'plant_id' => $plantId, - 'plant' => $plantId, + 'plant_id' => $plantId, + 'plant' => $plantId, 'invoice_number' => $invoiceNumber, 'pallet_number' => null, 'update_invoice' => 0, @@ -1035,15 +995,16 @@ class CreateLocatorInvoiceValidation extends CreateRecord 'sno_quantity' => $snoCount, 'scan_quantity' => $scannedCount, 'pend_quantity' => $pendingCount, - 'created_by' => $operatorName, - 'scanned_by' => $operatorName, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, ]); + return; } $palletRecords = PalletValidation::where('plant_id', $plantId) - ->where('pallet_number', $palletNumber) - ->get(); + ->where('pallet_number', $palletNumber) + ->get(); $allCompleted = true; foreach ($palletRecords as $record) { @@ -1053,8 +1014,7 @@ class CreateLocatorInvoiceValidation extends CreateRecord } } - if (!$allCompleted) - { + if (! $allCompleted) { Notification::make() ->title("Pallet number '{$palletNumber}' does not completed the master packing!") ->danger() @@ -1063,8 +1023,8 @@ class CreateLocatorInvoiceValidation extends CreateRecord $this->dispatch('loadData', $invoiceNumber, $plantId); $this->form->fill([ - 'plant_id' => $plantId, - 'plant' => $plantId, + 'plant_id' => $plantId, + 'plant' => $plantId, 'invoice_number' => $invoiceNumber, 'pallet_number' => null, 'update_invoice' => 0, @@ -1072,14 +1032,14 @@ class CreateLocatorInvoiceValidation extends CreateRecord 'sno_quantity' => $snoCount, 'scan_quantity' => $scannedCount, 'pend_quantity' => $pendingCount, - 'created_by' => $operatorName, - 'scanned_by' => $operatorName, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, ]); + return; } - if ($allCompleted) - { + if ($allCompleted) { $PalletSerialNumbers = $palletRecords->pluck('serial_number') ->map(function ($serial) { return trim($serial); @@ -1097,8 +1057,7 @@ class CreateLocatorInvoiceValidation extends CreateRecord $matchedSerialNumbers = array_intersect($PalletSerialNumbers, $InvoiceSerialNumbers); - if (empty($matchedSerialNumbers)) - { + if (empty($matchedSerialNumbers)) { Notification::make() ->title("Scanned pallet number '$palletNumber' does not have invoice serial numbers.
Scan the valid exist pallet number to start the scanning process..!") ->danger() @@ -1107,8 +1066,8 @@ class CreateLocatorInvoiceValidation extends CreateRecord $this->dispatch('loadData', $invoiceNumber, $plantId); $this->form->fill([ - 'plant_id' => $plantId, - 'plant' => $plantId, + 'plant_id' => $plantId, + 'plant' => $plantId, 'invoice_number' => $invoiceNumber, 'pallet_number' => null, 'update_invoice' => 0, @@ -1116,33 +1075,31 @@ class CreateLocatorInvoiceValidation extends CreateRecord 'sno_quantity' => $snoCount, 'scan_quantity' => $scannedCount, 'pend_quantity' => $pendingCount, - 'created_by' => $operatorName, - 'scanned_by' => $operatorName, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, ]); + return; } $UnknownSerialNumbers = array_diff($PalletSerialNumbers, $InvoiceSerialNumbers); // $matchedSerialNumbers = array_unique(array_merge($InvoiceSerialNumbers, $PalletSerialNumbers)); - if (!empty($UnknownSerialNumbers)) - { - //hereToContinue... - if($updateLocatorStatus == null || $updateLocatorStatus == 0) - { + if (! empty($UnknownSerialNumbers)) { + // hereToContinue... + if ($updateLocatorStatus == null || $updateLocatorStatus == 0) { // $missingSerialsString = "Missing serial numbers:\n" . implode(",\n", $missingSerialNumbers); - $missingSerialsString = "Scanned pallet number '$palletNumber' has '".count($PalletSerialNumbers)."' serial numbers.

But, below mentioned '".count($matchedSerialNumbers)."' serial numbers only exist in invoice,
".implode(", ", $matchedSerialNumbers)."

Press 'Yes' and Click 'Enter' in the pallet text box to proceed with existing serial number!

Press 'No' to cancel the scanning process!"; + $missingSerialsString = "Scanned pallet number '$palletNumber' has '".count($PalletSerialNumbers)."' serial numbers.

But, below mentioned '".count($matchedSerialNumbers)."' serial numbers only exist in invoice,
".implode(', ', $matchedSerialNumbers)."

Press 'Yes' and Click 'Enter' in the pallet text box to proceed with existing serial number!

Press 'No' to cancel the scanning process!"; - if (count($matchedSerialNumbers) > 10) - { - //$missingSerialsString = "Missing serial numbers: " . count($missingSerialNumbers); + if (count($matchedSerialNumbers) > 10) { + // $missingSerialsString = "Missing serial numbers: " . count($missingSerialNumbers); $missingSerialsString = "Scanned pallet number '$palletNumber' has '".count($PalletSerialNumbers)."' serial numbers.

But, '".count($matchedSerialNumbers)."' serial numbers only exist in invoice,

Press 'Yes' and Click 'Enter' in the pallet text box to proceed with existing serial number!

Press 'No' to cancel the scanning process!"; } // $body = "Scanned pallet number '$palletNumber' has ".$missingSerialsString."
Do you want to skip missing serial numbers?
Then Press 'Yes' and Click 'Enter'."; Notification::make() - ->title("Partial Pallet Serial Numbers Found") + ->title('Partial Pallet Serial Numbers Found') ->body($missingSerialsString) ->danger() ->duration(5000) @@ -1150,8 +1107,8 @@ class CreateLocatorInvoiceValidation extends CreateRecord $this->dispatch('loadData', $invoiceNumber, $plantId); $this->form->fill([ - 'plant_id' => $plantId, - 'plant' => $plantId, + 'plant_id' => $plantId, + 'plant' => $plantId, 'invoice_number' => $invoiceNumber, 'pallet_number' => $palletNumber, 'update_invoice' => 0, @@ -1159,21 +1116,17 @@ class CreateLocatorInvoiceValidation extends CreateRecord 'sno_quantity' => $snoCount, 'scan_quantity' => $scannedCount, 'pend_quantity' => $pendingCount, - 'created_by' => $operatorName, - 'scanned_by' => $operatorName, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, ]); } - } - else - { + } else { $updLocNam = ''; - foreach ($matchedSerialNumbers as $serial) - { + foreach ($matchedSerialNumbers as $serial) { $palletRecord = PalletValidation::where('plant_id', $plantId)->where('pallet_number', $palletNumber)->where('serial_number', $serial)->first(); $invoiceRecord = LocatorInvoiceValidation::where('plant_id', $plantId)->where('invoice_number', $invoiceNumber)->where('serial_number', $serial)->first(); - if ($invoiceRecord) - { + if ($invoiceRecord) { $invoiceRecord->scanned_status = 'Scanned'; $invoiceRecord->pallet_number = $palletNumber; $invoiceRecord->locator_number = $palletRecord->locator_number; @@ -1182,8 +1135,7 @@ class CreateLocatorInvoiceValidation extends CreateRecord $invoiceRecord->save(); } - if ($updLocNam == '' || $updLocNam == null) - { + if ($updLocNam == '' || $updLocNam == null) { $updLocNam = $palletRecord->locator_number; } @@ -1191,8 +1143,7 @@ class CreateLocatorInvoiceValidation extends CreateRecord $palletRecord->forceDelete(); } - if ($updLocNam != '' && $updLocNam != null) - { + if ($updLocNam != '' && $updLocNam != null) { $locator = Locator::where('locator_number', $updLocNam)->where('plant_id', $plantId) ->first(); @@ -1207,7 +1158,7 @@ class CreateLocatorInvoiceValidation extends CreateRecord ->where('locator_number', $updLocNam) ->update([ 'locator_quantity' => $locator->locator_quantity, - 'updated_at' => now() + 'updated_at' => now(), ]); } @@ -1222,8 +1173,7 @@ class CreateLocatorInvoiceValidation extends CreateRecord ->get(); $allScanned = true; - foreach ($records as $record) - { + foreach ($records as $record) { if (($record->scanned_status == null) || trim($record->scanned_status) == '') { $allScanned = false; break; @@ -1238,15 +1188,14 @@ class CreateLocatorInvoiceValidation extends CreateRecord ->duration(1000) ->send(); - if ($disk->exists($filePath)) - { + if ($disk->exists($filePath)) { $disk->delete($filePath); } $this->dispatch('loadData', '', $plantId); $this->form->fill([ - 'plant_id' => $plantId, - 'plant' => $plantId, + 'plant_id' => $plantId, + 'plant' => $plantId, 'invoice_number' => null, 'pallet_number' => null, 'update_invoice' => 0, @@ -1254,21 +1203,20 @@ class CreateLocatorInvoiceValidation extends CreateRecord 'sno_quantity' => 0, 'scan_quantity' => 0, 'pend_quantity' => 0, - 'created_by' => $operatorName, - 'scanned_by' => $operatorName, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, ]); + return; - } - else - { + } else { $pendingCount = LocatorInvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->whereNull('scanned_status')->orWhere('scanned_status', '=', '')->count(); $scannedCount = LocatorInvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->where('scanned_status', '=', 'Scanned')->count(); $this->dispatch('loadData', $invoiceNumber, $plantId); $this->form->fill([ - 'plant_id' => $plantId, - 'plant' => $plantId, + 'plant_id' => $plantId, + 'plant' => $plantId, 'invoice_number' => $invoiceNumber, 'pallet_number' => null, 'update_invoice' => 0, @@ -1276,25 +1224,22 @@ class CreateLocatorInvoiceValidation extends CreateRecord 'sno_quantity' => $snoCount, 'scan_quantity' => $scannedCount, 'pend_quantity' => $pendingCount, - 'created_by' => $operatorName, - 'scanned_by' => $operatorName, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, ]); + return; } } } - if($updateLocatorStatus == 1) - { - if ($allCompleted) - { - foreach ($matchedSerialNumbers as $serial) - { + if ($updateLocatorStatus == 1) { + if ($allCompleted) { + foreach ($matchedSerialNumbers as $serial) { $palletRecord = PalletValidation::where('plant_id', $plantId)->where('pallet_number', $palletNumber)->where('serial_number', $serial)->first(); $invoiceRecord = LocatorInvoiceValidation::where('plant_id', $plantId)->where('invoice_number', $invoiceNumber)->where('serial_number', $serial)->first(); - if ($invoiceRecord) - { + if ($invoiceRecord) { $invoiceRecord->scanned_status = 'Scanned'; $invoiceRecord->pallet_number = $palletNumber; $invoiceRecord->locator_number = $palletRecord->locator_number; @@ -1307,10 +1252,9 @@ class CreateLocatorInvoiceValidation extends CreateRecord $palletRecord->forceDelete(); } - $succMsgStr = "Below mentioned '".count($matchedSerialNumbers)."' Serial numbers are moved into invoice from the pallet number '$palletNumber'.

".implode(", ", $matchedSerialNumbers)."

Scan the next exist pallet number to start the scanning process..!"; + $succMsgStr = "Below mentioned '".count($matchedSerialNumbers)."' Serial numbers are moved into invoice from the pallet number '$palletNumber'.

".implode(', ', $matchedSerialNumbers).'

Scan the next exist pallet number to start the scanning process..!'; - if (count($matchedSerialNumbers) > 10) - { + if (count($matchedSerialNumbers) > 10) { $succMsgStr = "'".count($matchedSerialNumbers)."' Serial numbers are moved into invoice from the pallet number '$palletNumber'.
Scan the next exist pallet number to start the scanning process..!"; } @@ -1325,8 +1269,7 @@ class CreateLocatorInvoiceValidation extends CreateRecord ->get(); $allScanned = true; - foreach ($records as $record) - { + foreach ($records as $record) { if (($record->scanned_status == null) || trim($record->scanned_status) == '') { $allScanned = false; break; @@ -1341,15 +1284,14 @@ class CreateLocatorInvoiceValidation extends CreateRecord ->duration(1000) ->send(); - if ($disk->exists($filePath)) - { + if ($disk->exists($filePath)) { $disk->delete($filePath); } $this->dispatch('loadData', '', $plantId); $this->form->fill([ - 'plant_id' => $plantId, - 'plant' => $plantId, + 'plant_id' => $plantId, + 'plant' => $plantId, 'invoice_number' => null, 'pallet_number' => null, 'update_invoice' => 0, @@ -1357,21 +1299,20 @@ class CreateLocatorInvoiceValidation extends CreateRecord 'sno_quantity' => 0, 'scan_quantity' => 0, 'pend_quantity' => 0, - 'created_by' => $operatorName, - 'scanned_by' => $operatorName, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, ]); + return; - } - else - { + } else { $pendingCount = LocatorInvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->whereNull('scanned_status')->orWhere('scanned_status', '=', '')->count(); $scannedCount = LocatorInvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->where('scanned_status', '=', 'Scanned')->count(); $this->dispatch('loadData', $invoiceNumber, $plantId); $this->form->fill([ - 'plant_id' => $plantId, - 'plant' => $plantId, + 'plant_id' => $plantId, + 'plant' => $plantId, 'invoice_number' => $invoiceNumber, 'pallet_number' => null, 'update_invoice' => 0, @@ -1379,14 +1320,13 @@ class CreateLocatorInvoiceValidation extends CreateRecord 'sno_quantity' => $snoCount, 'scan_quantity' => $scannedCount, 'pend_quantity' => $pendingCount, - 'created_by' => $operatorName, - 'scanned_by' => $operatorName, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, ]); + return; } - } - else if($updateLocatorStatus == 0) - { + } elseif ($updateLocatorStatus == 0) { $updateLocatorStatus == null; } } @@ -1418,21 +1358,18 @@ class CreateLocatorInvoiceValidation extends CreateRecord $InvoiceSerialNumber = ''; - $filename = $invoiceNumber . '.xlsx'; + $filename = $invoiceNumber.'.xlsx'; - $folderPath = Configuration::where('c_name', 'INVOICE_FOLDER_PATH') - ->where('plant_id', $plantId) - ->value('c_value'); + $folderPath = 'ExportDispatch'; // Configuration::where('c_name', 'INVOICE_FOLDER_PATH')->where('plant_id', $plantId)->value('c_value'); $fullFolderPath = "uploads/$folderPath"; $directory = $fullFolderPath; $disk = Storage::disk('local'); - $filePath = $directory . '/' . $filename; + $filePath = $directory.'/'.$filename; $invExist = LocatorInvoiceValidation::where('plant_id', $plantId)->where('invoice_number', $invoiceNumber)->first(); - if (!$invExist) - { + if (! $invExist) { Notification::make() ->title('Invoice Not Found') ->body("Scanned invoice number '$invoiceNumber' does not exist in invoice table!
Import the scanned 'Invoice' file to proceed..!") @@ -1441,29 +1378,27 @@ class CreateLocatorInvoiceValidation extends CreateRecord ->send(); $this->form->fill([ - 'plant_id' => $plantId, - 'plant' => $plantId, + 'plant_id' => $plantId, + 'plant' => $plantId, 'invoice_number' => $invoiceNumber, 'pallet_number' => null, 'serial_number' => null, 'sno_quantity' => 0, 'scan_quantity' => 0, 'pend_quantity' => 0, - 'created_by' => $operatorName, - 'scanned_by' => $operatorName, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, ]); + return; - } - else - { + } else { $records = LocatorInvoiceValidation::where('plant_id', $plantId) - ->where('invoice_number', $invoiceNumber) - ->get(); + ->where('invoice_number', $invoiceNumber) + ->get(); $allScanned = true; - foreach ($records as $record) - { + foreach ($records as $record) { if (($record->scanned_status == null) || trim($record->scanned_status) == '') { $allScanned = false; break; @@ -1478,24 +1413,24 @@ class CreateLocatorInvoiceValidation extends CreateRecord ->duration(1000) ->send(); - if ($disk->exists($filePath)) - { + if ($disk->exists($filePath)) { $disk->delete($filePath); } $this->dispatch('loadData', '', $plantId); $this->form->fill([ - 'plant_id' => $plantId, - 'plant' => $plantId, + 'plant_id' => $plantId, + 'plant' => $plantId, 'invoice_number' => null, 'pallet_number' => null, 'serial_number' => null, 'sno_quantity' => 0, 'scan_quantity' => 0, 'pend_quantity' => 0, - 'created_by' => $operatorName, - 'scanned_by' => $operatorName, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, ]); + return; } } @@ -1506,10 +1441,9 @@ class CreateLocatorInvoiceValidation extends CreateRecord $scannedCount = LocatorInvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->where('scanned_status', '=', 'Scanned')->count(); - if ($serialNumber == '' || $serialNumber == null) - { + if ($serialNumber == '' || $serialNumber == null) { Notification::make() - ->title("Invalid: Serial Number") + ->title('Invalid: Serial Number') ->body("Serial number can't be empty!") ->danger() ->duration(5000) @@ -1517,8 +1451,8 @@ class CreateLocatorInvoiceValidation extends CreateRecord $this->dispatch('loadData', $invoiceNumber, $plantId); $this->form->fill([ - 'plant_id' => $plantId, - 'plant' => $plantId, + 'plant_id' => $plantId, + 'plant' => $plantId, 'invoice_number' => $invoiceNumber, 'pallet_number' => null, 'update_invoice' => 0, @@ -1526,15 +1460,14 @@ class CreateLocatorInvoiceValidation extends CreateRecord 'sno_quantity' => $snoCount, 'scan_quantity' => $scannedCount, 'pend_quantity' => $pendingCount, - 'created_by' => $operatorName, - 'scanned_by' => $operatorName, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, ]); + return; - } - else if (strlen($serialNumber) < 9 || strlen($serialNumber) > 20) - { + } elseif (strlen($serialNumber) < 9 || strlen($serialNumber) > 20) { Notification::make() - ->title("Invalid: Serial Number") + ->title('Invalid: Serial Number') ->body('Serial number should contain minimum 9 digits and maximum 20 digits.') ->danger() ->duration(5000) @@ -1542,23 +1475,22 @@ class CreateLocatorInvoiceValidation extends CreateRecord $this->dispatch('loadData', $invoiceNumber, $plantId); $this->form->fill([ - 'plant_id' => $plantId, - 'plant' => $plantId, + 'plant_id' => $plantId, + 'plant' => $plantId, 'invoice_number' => $invoiceNumber, 'pallet_number' => null, 'serial_number' => null, 'sno_quantity' => $snoCount, 'scan_quantity' => $scannedCount, 'pend_quantity' => $pendingCount, - 'created_by' => $operatorName, - 'scanned_by' => $operatorName, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, ]); + return; - } - else if (!ctype_alnum($serialNumber)) - { + } elseif (! ctype_alnum($serialNumber)) { Notification::make() - ->title("Invalid: Serial Number") + ->title('Invalid: Serial Number') ->body('Serial number must contain alpha-numeric values only.') ->danger() ->duration(5000) @@ -1566,26 +1498,26 @@ class CreateLocatorInvoiceValidation extends CreateRecord $this->dispatch('loadData', $invoiceNumber, $plantId); $this->form->fill([ - 'plant_id' => $plantId, - 'plant' => $plantId, + 'plant_id' => $plantId, + 'plant' => $plantId, 'invoice_number' => $invoiceNumber, 'pallet_number' => null, 'serial_number' => null, 'sno_quantity' => $snoCount, 'scan_quantity' => $scannedCount, 'pend_quantity' => $pendingCount, - 'created_by' => $operatorName, - 'scanned_by' => $operatorName, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, ]); + return; } $InvoiceSerialNumber = LocatorInvoiceValidation::where('plant_id', $plantId)->where('invoice_number', $invoiceNumber)->where('serial_number', $serialNumber)->first(); - if (!$InvoiceSerialNumber) - { + if (! $InvoiceSerialNumber) { Notification::make() - ->title("Unknown: Serial Number") + ->title('Unknown: Serial Number') ->body("Serial number '{$serialNumber}' does not exist in invoice number '$invoiceNumber'.") ->danger() ->duration(5000) @@ -1593,23 +1525,22 @@ class CreateLocatorInvoiceValidation extends CreateRecord $this->dispatch('loadData', $invoiceNumber, $plantId); $this->form->fill([ - 'plant_id' => $plantId, - 'plant' => $plantId, + 'plant_id' => $plantId, + 'plant' => $plantId, 'invoice_number' => $invoiceNumber, 'pallet_number' => null, 'serial_number' => null, 'sno_quantity' => $snoCount, 'scan_quantity' => $scannedCount, 'pend_quantity' => $pendingCount, - 'created_by' => $operatorName, - 'scanned_by' => $operatorName, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, ]); + return; - } - else if($InvoiceSerialNumber->scanned_status != null && $InvoiceSerialNumber->scanned_status != '') - { + } elseif ($InvoiceSerialNumber->scanned_status != null && $InvoiceSerialNumber->scanned_status != '') { Notification::make() - ->title("Completed: Serial Number") + ->title('Completed: Serial Number') ->body("Serial number '{$serialNumber}' already completed the scanning process for the invoice number '$invoiceNumber'.") ->danger() ->duration(5000) @@ -1617,17 +1548,18 @@ class CreateLocatorInvoiceValidation extends CreateRecord $this->dispatch('loadData', $invoiceNumber, $plantId); $this->form->fill([ - 'plant_id' => $plantId, - 'plant' => $plantId, + 'plant_id' => $plantId, + 'plant' => $plantId, 'invoice_number' => $invoiceNumber, 'pallet_number' => null, 'serial_number' => null, 'sno_quantity' => $snoCount, 'scan_quantity' => $scannedCount, 'pend_quantity' => $pendingCount, - 'created_by' => $operatorName, - 'scanned_by' => $operatorName, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, ]); + return; } @@ -1638,12 +1570,11 @@ class CreateLocatorInvoiceValidation extends CreateRecord $existPallNum = $existSerialNumber->pallet_number ?? null; $existPallStat = $existSerialNumber->pallet_status ?? null; $existLocatNum = $existSerialNumber->locator_number ?? null; - if (!$existSerialNumber) - { - //skip update locator quantity + if (! $existSerialNumber) { + // skip update locator quantity $updLocQty = false; Notification::make() - ->title("Unknown: Serial Number") + ->title('Unknown: Serial Number') ->body("Serial number '{$serialNumber}' does not exist in pallet table.") ->danger() ->duration(5000) @@ -1651,34 +1582,30 @@ class CreateLocatorInvoiceValidation extends CreateRecord $this->dispatch('loadData', $invoiceNumber, $plantId); $this->form->fill([ - 'plant_id' => $plantId, - 'plant' => $plantId, + 'plant_id' => $plantId, + 'plant' => $plantId, 'invoice_number' => $invoiceNumber, 'pallet_number' => null, 'serial_number' => null, 'sno_quantity' => $snoCount, 'scan_quantity' => $scannedCount, 'pend_quantity' => $pendingCount, - 'created_by' => $operatorName, - 'scanned_by' => $operatorName, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, ]); + return; - } - else if ($existPallNum == null || $existPallNum == '') - { - //skip update locator quantity + } elseif ($existPallNum == null || $existPallNum == '') { + // skip update locator quantity $updLocQty = false; $succMsg = "Scanned serial number '{$serialNumber}' is moved into invoice from the locator number '$existLocatNum'.

Scan the next exist serial number to start the scanning process..!"; - } - else if ($existLocatNum == null || $existLocatNum == '') - { - if ($existPallStat == null || $existPallStat == '') - { - //skip update locator quantity + } elseif ($existLocatNum == null || $existLocatNum == '') { + if ($existPallStat == null || $existPallStat == '') { + // skip update locator quantity $updLocQty = false; $succMsg = "Scanned serial number '{$serialNumber}' is moved into invoice from the pallet number '$existPallNum'.

Scan the next exist serial number to start the scanning process..!"; Notification::make() - ->title("Incompleted Pallet: Serial Number")//Pallet number '{$existPallNum}' does not completed the master packing! + ->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(5000) @@ -1686,43 +1613,36 @@ class CreateLocatorInvoiceValidation extends CreateRecord $this->dispatch('loadData', $invoiceNumber, $plantId); $this->form->fill([ - 'plant_id' => $plantId, - 'plant' => $plantId, + 'plant_id' => $plantId, + 'plant' => $plantId, 'invoice_number' => $invoiceNumber, 'pallet_number' => null, 'serial_number' => null, 'sno_quantity' => $snoCount, 'scan_quantity' => $scannedCount, 'pend_quantity' => $pendingCount, - 'created_by' => $operatorName, - 'scanned_by' => $operatorName, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, ]); + return; - } - else - { - //skip update locator quantity + } else { + // skip update locator quantity $updLocQty = false; $succMsg = "Scanned serial number '{$serialNumber}' is moved into invoice from the pallet number '$existPallNum'.

Scan the next exist serial number to start the scanning process..!"; } - } - else if ($existPallNum != null && $existPallNum != '' && $existLocatNum != null && $existLocatNum != '') - { - //update locator quantity based on condition + } elseif ($existPallNum != null && $existPallNum != '' && $existLocatNum != null && $existLocatNum != '') { + // update locator quantity based on condition $snoCount = PalletValidation::where('plant_id', $plantId)->where('pallet_number', $existPallNum)->count(); - if ($snoCount > 0 && $snoCount == 1) - { + if ($snoCount > 0 && $snoCount == 1) { $updLocQty = true; - } - else - { + } else { $updLocQty = false; } $succMsg = "Scanned serial number '{$serialNumber}' is moved into invoice from the pallet number '$existPallNum' in the locator number '$existLocatNum'.

Scan the next exist serial number to start the scanning process..!"; } - if ($InvoiceSerialNumber) - { + if ($InvoiceSerialNumber) { $InvoiceSerialNumber->pallet_number = $existPallNum; $InvoiceSerialNumber->locator_number = $existLocatNum; $InvoiceSerialNumber->scanned_status = 'Scanned'; @@ -1731,9 +1651,8 @@ class CreateLocatorInvoiceValidation extends CreateRecord $InvoiceSerialNumber->save(); $existSerialNumber->forceDelete(); - if ($updLocQty) - { - //hereToContinue + if ($updLocQty) { + // hereToContinue $locator = Locator::where('locator_number', $existLocatNum)->where('plant_id', $plantId)->first(); if ($locator && $locator->locator_quantity > 0) { @@ -1746,7 +1665,7 @@ class CreateLocatorInvoiceValidation extends CreateRecord PalletValidation::where('plant_id', $plantId)->where('locator_number', $existLocatNum) ->update([ 'locator_quantity' => $locator->locator_quantity, - 'updated_at' => now() + 'updated_at' => now(), ]); } @@ -1759,8 +1678,7 @@ class CreateLocatorInvoiceValidation extends CreateRecord $records = LocatorInvoiceValidation::where('plant_id', $plantId)->where('invoice_number', $invoiceNumber)->get(); $allScanned = true; - foreach ($records as $record) - { + foreach ($records as $record) { if (($record->scanned_status == null) || trim($record->scanned_status) == '') { $allScanned = false; break; @@ -1775,15 +1693,14 @@ class CreateLocatorInvoiceValidation extends CreateRecord ->duration(1000) ->send(); - if ($disk->exists($filePath)) - { + if ($disk->exists($filePath)) { $disk->delete($filePath); } $this->dispatch('loadData', '', $plantId); $this->form->fill([ - 'plant_id' => $plantId, - 'plant' => $plantId, + 'plant_id' => $plantId, + 'plant' => $plantId, 'invoice_number' => null, 'pallet_number' => null, 'update_invoice' => 0, @@ -1791,21 +1708,20 @@ class CreateLocatorInvoiceValidation extends CreateRecord 'sno_quantity' => 0, 'scan_quantity' => 0, 'pend_quantity' => 0, - 'created_by' => $operatorName, - 'scanned_by' => $operatorName, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, ]); + return; - } - else - { + } else { $pendingCount = LocatorInvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->whereNull('scanned_status')->orWhere('scanned_status', '=', '')->count(); $scannedCount = LocatorInvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->where('scanned_status', '=', 'Scanned')->count(); $this->dispatch('loadData', $invoiceNumber, $plantId); $this->form->fill([ - 'plant_id' => $plantId, - 'plant' => $plantId, + 'plant_id' => $plantId, + 'plant' => $plantId, 'invoice_number' => $invoiceNumber, 'pallet_number' => null, 'update_invoice' => 0, @@ -1813,14 +1729,13 @@ class CreateLocatorInvoiceValidation extends CreateRecord 'sno_quantity' => $snoCount, 'scan_quantity' => $scannedCount, 'pend_quantity' => $pendingCount, - 'created_by' => $operatorName, - 'scanned_by' => $operatorName, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, ]); + return; } - } - else - { + } else { Notification::make() ->title("Failed to check Serial number '{$serialNumber}' existence.
Scan the valid serial number to proceed...") ->danger() @@ -1829,8 +1744,8 @@ class CreateLocatorInvoiceValidation extends CreateRecord $this->dispatch('loadData', $invoiceNumber, $plantId); $this->form->fill([ - 'plant_id' => $plantId, - 'plant' => $plantId, + 'plant_id' => $plantId, + 'plant' => $plantId, 'invoice_number' => $invoiceNumber, 'pallet_number' => null, 'update_invoice' => 0, @@ -1838,9 +1753,10 @@ class CreateLocatorInvoiceValidation extends CreateRecord 'sno_quantity' => $snoCount, 'scan_quantity' => $scannedCount, 'pend_quantity' => $pendingCount, - 'created_by' => $operatorName, - 'scanned_by' => $operatorName, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, ]); + return; } } diff --git a/database/seeders/AdminSeeder.php b/database/seeders/AdminSeeder.php index 4210da1..0c519c0 100644 --- a/database/seeders/AdminSeeder.php +++ b/database/seeders/AdminSeeder.php @@ -13,7 +13,7 @@ class AdminSeeder extends Seeder */ public function run(): void { - //updateOrCreate + // updateOrCreate $user1 = User::updateOrCreate( // Unique identifier ['email' => 'admin@cripumps.com'], @@ -21,9 +21,9 @@ class AdminSeeder extends Seeder // Data to update/create [ 'name' => 'Admin', - 'password' => Hash::make('jOtHi$9000'), + 'password' => Hash::make('jOtHi#9000'), 'updated_at' => now(), - 'created_at' => now() + 'created_at' => now(), ] ); // $user1 = User::firstOrCreate([ diff --git a/database/seeders/PermissionSeeder.php b/database/seeders/PermissionSeeder.php index 6a6b499..6a37f38 100644 --- a/database/seeders/PermissionSeeder.php +++ b/database/seeders/PermissionSeeder.php @@ -2,7 +2,6 @@ namespace Database\Seeders; -use Illuminate\Database\Console\Seeds\WithoutModelEvents; use Illuminate\Database\Seeder; use Spatie\Permission\Models\Permission; @@ -26,14 +25,14 @@ class PermissionSeeder extends Seeder 'edit roles', 'delete roles', 'restore roles', - 'force-delete roles' + 'force-delete roles', ]; foreach ($permissions as $permission) { - Permission::updateOrCreate(['name' => $permission]); //firstOrCreate + Permission::updateOrCreate(['name' => $permission]); // firstOrCreate } - //Master and Transaction Pages + // Master and Transaction Pages Permission::updateOrCreate(['name' => 'view import user']); Permission::updateOrCreate(['name' => 'view export user']); @@ -142,9 +141,9 @@ class PermissionSeeder extends Seeder Permission::updateOrCreate(['name' => 'view import sticker mapping master']); Permission::updateOrCreate(['name' => 'view export sticker mapping master']); - //Dashboard Permissions - Permission::updateOrCreate(['name' => 'view invoice dashboard']); //invoice dashboard - Permission::updateOrCreate(['name' => 'view production hourly count dashboard']); //hourly production + // Dashboard Permissions + Permission::updateOrCreate(['name' => 'view invoice dashboard']); // invoice dashboard + Permission::updateOrCreate(['name' => 'view production hourly count dashboard']); // hourly production Permission::updateOrCreate(['name' => 'view production line count dashboard']); Permission::updateOrCreate(['name' => 'view production order count dashboard']); Permission::updateOrCreate(['name' => 'view production line stop count dashboard']); @@ -156,13 +155,14 @@ class PermissionSeeder extends Seeder Permission::updateOrCreate(['name' => 'view ems trend line analysis dashboard']); Permission::updateOrCreate(['name' => 'view ems trend chart analysis dashboard']); - //Send To Sap Permissions + // Send To Sap Permissions Permission::updateOrCreate(['name' => 'view quality data send to sap']); Permission::updateOrCreate(['name' => 'view production data send to sap']); Permission::updateOrCreate(['name' => 'create production sticker reject reason page']); Permission::updateOrCreate(['name' => 'create web capture page']); Permission::updateOrCreate(['name' => 'view invoice pending reason']); + Permission::updateOrCreate(['name' => 'view file manager page']); Permission::updateOrCreate(['name' => 'view import invoice out validation']); Permission::updateOrCreate(['name' => 'view export invoice out validation']); @@ -181,5 +181,10 @@ class PermissionSeeder extends Seeder Permission::updateOrCreate(['name' => 'view import invoice in transit']); Permission::updateOrCreate(['name' => 'view export invoice in transit']); + Permission::updateOrCreate(['name' => 'view import request characteristic']); + Permission::updateOrCreate(['name' => 'view export request characteristic']); + + Permission::updateOrCreate(['name' => 'view import characteristic approver master']); + Permission::updateOrCreate(['name' => 'view export characteristic approver master']); } } diff --git a/database/seeders/UserSeeder.php b/database/seeders/UserSeeder.php index 7503b9a..f39f04f 100644 --- a/database/seeders/UserSeeder.php +++ b/database/seeders/UserSeeder.php @@ -13,6 +13,17 @@ class UserSeeder extends Seeder public function run(): void { $user1 = User::updateOrCreate( + ['email' => 'RAS00332@cripumps.com'], + [ + 'name' => 'Jeithef Shibu C', + 'password' => bcrypt('ShIbu#123'), + 'updated_at' => now(), + 'created_at' => now(), + ] + ); + $user1->assignRole('Super Admin'); + + $user2 = User::updateOrCreate( ['email' => 'dhanabalan.saravanan@cripumps.com'], [ 'name' => 'Dhanabalan S', @@ -21,18 +32,18 @@ class UserSeeder extends Seeder 'created_at' => now(), ] ); - $user1->assignRole('Super Admin'); + $user2->assignRole('Super Admin'); - $user2 = User::updateOrCreate( + $user3 = User::updateOrCreate( ['email' => 'ranjith.bala@cripumps.com'], [ 'name' => 'Ranjith B', - 'password' => bcrypt('Ranjii$5503'), + 'password' => bcrypt('RAS00334@12'), 'updated_at' => now(), 'created_at' => now(), ] ); - $user2->assignRole('Super Admin'); + $user3->assignRole('Super Admin'); // User::factory()->count(5)->create(); } }