diff --git a/app/Filament/Resources/InvoiceValidationResource.php b/app/Filament/Resources/InvoiceValidationResource.php index 3940b81..ba5c2d6 100644 --- a/app/Filament/Resources/InvoiceValidationResource.php +++ b/app/Filament/Resources/InvoiceValidationResource.php @@ -106,9 +106,11 @@ class InvoiceValidationResource extends Resource ->readOnly(fn (callable $get) => !empty($get('serial_number'))) //->disabled(fn (Get $get) => !empty($get('serial_number'))) ->extraAttributes([ + 'id' => 'invoice_number_input', 'x-data' => '{ value: "" }', 'x-model' => 'value', - 'x-on:keydown.enter.prevent' => '$wire.processInvoice(value)', + 'wire:keydown.enter.prevent' => 'processInvoice(value)', + //'x-on:keydown.enter.prevent' => '$wire.processInvoice(value)', ]) // ->afterStateHydrated(function (TextInput $component, string $state) { // $component->state(ucwords($state)); diff --git a/app/Filament/Resources/InvoiceValidationResource/Pages/CreateInvoiceValidation.php b/app/Filament/Resources/InvoiceValidationResource/Pages/CreateInvoiceValidation.php index 312ae30..720f1db 100644 --- a/app/Filament/Resources/InvoiceValidationResource/Pages/CreateInvoiceValidation.php +++ b/app/Filament/Resources/InvoiceValidationResource/Pages/CreateInvoiceValidation.php @@ -73,14 +73,32 @@ class CreateInvoiceValidation extends CreateRecord { $totQuan = InvoiceValidation::where('invoice_number', $this->invoiceNumber)->where('plant_id', $this->plantId)->count(); $scanSQuan = InvoiceValidation::where('invoice_number', $this->invoiceNumber)->where('scanned_status', 'Scanned')->where('plant_id', $this->plantId)->count(); - $this->form->fill([ - 'plant_id' => $this->plantId, - 'invoice_number' => $this->invoiceNumber, - 'serial_number' => null, - 'total_quantity' => $totQuan, - 'update_invoice' => false, - 'scanned_quantity'=> $scanSQuan, - ]); + + $this->dispatch('playNotificationSound'); + if ($totQuan == $scanSQuan) + { + $this->form->fill([ + 'plant_id' => $this->plantId, + 'invoice_number' => null, + 'serial_number' => null, + 'total_quantity' => 0, + 'update_invoice' => false, + 'scanned_quantity'=> 0 + ]); + $this->dispatch('refreshCompletedInvoice', invoiceNumber: $this->invoiceNumber, plantId: $this->plantId, isSerial: true); + } + else + { + $this->form->fill([ + 'plant_id' => $this->plantId, + 'invoice_number' => $this->invoiceNumber, + 'serial_number' => null, + 'total_quantity' => $totQuan, + 'update_invoice' => false, + 'scanned_quantity'=> $scanSQuan + ]); + $this->dispatch('refreshInvoiceData', invoiceNumber: $this->invoiceNumber, plantId: $this->plantId); + } } protected function getRedirectUrl(): string @@ -133,6 +151,7 @@ class CreateInvoiceValidation extends CreateRecord 'total_quantity' => 0, 'scanned_quantity'=> 0, ]); + $this->dispatch('refreshEmptyInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId); } else @@ -854,7 +873,6 @@ class CreateInvoiceValidation extends CreateRecord //$fullPath = $disk->path($filePath); $disk->delete($filePath); } - $this->dispatch('playNotificationSound'); $this->form->fill([ 'plant_id' => $plantId, diff --git a/app/Livewire/InvoiceDataTable.php b/app/Livewire/InvoiceDataTable.php index f1b4c39..0baf441 100644 --- a/app/Livewire/InvoiceDataTable.php +++ b/app/Livewire/InvoiceDataTable.php @@ -65,6 +65,7 @@ class InvoiceDataTable extends Component $this->materialInvoice = false; $this->packageCount = 0; // $this->showCapacitorInput = false; + $this->dispatch('focus-invoice-number'); } public function loadEmptyData($invoiceNumber, $plantId) @@ -178,7 +179,7 @@ class InvoiceDataTable extends Component $this->packageCount += $stickCount - $scannedCount; } - + $this->dispatch('focus-serial-number'); } public function loadMaterialData($invoiceNumber, $plantId) @@ -230,6 +231,7 @@ class InvoiceDataTable extends Component $row['material_type'] = 'N/A'; } } + $this->dispatch('focus-serial-number'); } // public function showCapacitorInputBox() @@ -255,6 +257,7 @@ class InvoiceDataTable extends Component public function cancelCapacitorInput() { $this->showCapacitorInput = false; + $this->dispatch('focus-serial-number'); } public function processCapacitorInput() diff --git a/resources/views/livewire/invoice-data-table.blade.php b/resources/views/livewire/invoice-data-table.blade.php index 3862ee9..2b553e9 100644 --- a/resources/views/livewire/invoice-data-table.blade.php +++ b/resources/views/livewire/invoice-data-table.blade.php @@ -192,17 +192,28 @@ }, 50); }); - window.addEventListener('focus-serial-number', () => { - setTimeout(() => { - const container = document.getElementById('serial_number_input'); - const input = container?.querySelector('input'); // gets the actual input inside + window.addEventListener('focus-serial-number', () => { + setTimeout(() => { + const container = document.getElementById('serial_number_input'); + const input = container?.querySelector('input'); // gets the actual input inside - if (input) { - input.focus(); - input.select(); - } - }, 100); -}); + if (input) { + input.focus(); + input.select(); + } + }, 100); + }); + window.addEventListener('focus-invoice-number', () => { + setTimeout(() => { + const container = document.getElementById('invoice_number_input'); + const input = container?.querySelector('input'); // gets the actual input inside + + if (input) { + input.focus(); + input.select(); + } + }, 100); + });