diff --git a/app/Filament/Resources/InvoiceValidationResource/Pages/CreateInvoiceValidation.php b/app/Filament/Resources/InvoiceValidationResource/Pages/CreateInvoiceValidation.php index 9741d1d..7dd3b6b 100644 --- a/app/Filament/Resources/InvoiceValidationResource/Pages/CreateInvoiceValidation.php +++ b/app/Filament/Resources/InvoiceValidationResource/Pages/CreateInvoiceValidation.php @@ -65,19 +65,23 @@ class CreateInvoiceValidation extends CreateRecord ]; } - // protected $listeners = [ - // 'updateScannedQuantity' => 'updateScannedQuantity', - // ]; + protected $listeners = [ + 'updateScannedQuantity' => 'updateScannedQuantity', + ]; - - // public function updateScannedQuantity() - // { - // $current = $this->form->getState()['scanned_quantity'] ?? 0; - - // $this->form->fill([ - // 'scanned_quantity' => $current + 1, - // ]); - // } + public function updateScannedQuantity() + { + $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, + ]); + } protected function getRedirectUrl(): string { @@ -98,16 +102,8 @@ class CreateInvoiceValidation extends CreateRecord $this->plantId = $plantId; - $plant = Plant::find($plantId); - - if ($plant) - { - $plantCode = $plant->code; - } - else - { - $plantCode = null; - } + //$plant = Plant::find($plantId); + //$plantCode = $plant ? $plant->code : null; //..GET SERIAL INVOICE API @@ -3910,8 +3906,10 @@ class CreateInvoiceValidation extends CreateRecord 'scanned_quantity'=> $scannedQuantity, ]); $this->dispatch( 'refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId); + // $this->refreshInvoiceTable(); return; + } elseif ($isMarkPs) { diff --git a/app/Livewire/InvoiceDataTable.php b/app/Livewire/InvoiceDataTable.php index 7067f69..f1b4c39 100644 --- a/app/Livewire/InvoiceDataTable.php +++ b/app/Livewire/InvoiceDataTable.php @@ -157,7 +157,6 @@ class InvoiceDataTable extends Component $stickCount++; } } - } if ($row['motor_scanned_status'] == 1) @@ -301,10 +300,8 @@ class InvoiceDataTable extends Component } foreach ($this->invoiceData as &$row) { - if ( - ($row['code'] ?? '') === $this->currentItemCode && - ($row['serial_number'] ?? '') === $this->currentSerialNumber - ) { + if (($row['code'] ?? '') === $this->currentItemCode && ($row['serial_number'] ?? '') === $this->currentSerialNumber) + { $row['panel_box_supplier'] = $supplier; $row['panel_box_item_code'] = $itemCode; $row['panel_box_serial_number'] = $serialNumber; @@ -413,8 +410,11 @@ class InvoiceDataTable extends Component break; } } + $this->showCapacitorInput = false; $this->capacitorInput = ''; + $this->dispatch('updateScannedQuantity'); + //$this->loadData($this->invoiceNumber, $this->plantId); $this->dispatch('focus-serial-number'); }