From 92f3352f6bb39fc2241d50a153472b27723e9712 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Tue, 3 Feb 2026 20:57:39 +0530 Subject: [PATCH] Updated clear panel box QR if cancel button clicked and Added panel_box_code update logic on livewire page --- app/Livewire/InvoiceDataTable.php | 241 +++++++++--------- .../livewire/invoice-data-table.blade.php | 4 + 2 files changed, 120 insertions(+), 125 deletions(-) diff --git a/app/Livewire/InvoiceDataTable.php b/app/Livewire/InvoiceDataTable.php index 048206f..71307b1 100644 --- a/app/Livewire/InvoiceDataTable.php +++ b/app/Livewire/InvoiceDataTable.php @@ -6,17 +6,17 @@ use App\Models\InvoiceValidation; use App\Models\StickerMaster; use Filament\Facades\Filament; use Filament\Notifications\Notification; -use Livewire\Component; -use Str; use Livewire\Attributes\On; +use Livewire\Component; use Livewire\WithPagination; +use Str; class InvoiceDataTable extends Component { - use WithPagination; protected $paginationTheme = 'tailwind'; + public $invoiceData = []; // public $invoiceRecords; @@ -25,7 +25,6 @@ class InvoiceDataTable extends Component public $package = []; - public $packageCount = 0; public string $invoiceNumber = ''; @@ -58,7 +57,7 @@ class InvoiceDataTable extends Component public $panel_box_supplier; - public $panel_box_item_code; + public $panel_box_code; public $panel_box_serial_number; @@ -187,126 +186,124 @@ class InvoiceDataTable extends Component // } // } -// public function loadData($invoiceNumber, $plantId, $onCapFocus = false) -// { -// $this->invoiceNumber = $invoiceNumber; -// $this->plantId = $plantId; + // public function loadData($invoiceNumber, $plantId, $onCapFocus = false) + // { + // $this->invoiceNumber = $invoiceNumber; + // $this->plantId = $plantId; -// $this->completedInvoice = false; -// $this->isSerial = true; -// $this->onCapFocus = $onCapFocus; -// $this->emptyInvoice = false; -// $this->hasSearched = true; -// $this->materialInvoice = false; + // $this->completedInvoice = false; + // $this->isSerial = true; + // $this->onCapFocus = $onCapFocus; + // $this->emptyInvoice = false; + // $this->hasSearched = true; + // $this->materialInvoice = false; -// $this->resetPage(); + // $this->resetPage(); -// $this->packageCount = 0; + // $this->packageCount = 0; -// // IMPORTANT: keep scanned rows, otherwise count will not update -// $this->invoiceRecords = InvoiceValidation::with('stickerMasterRelation') -// ->where('invoice_number', $this->invoiceNumber) -// ->where('plant_id', $this->plantId) -// ->get(); + // // IMPORTANT: keep scanned rows, otherwise count will not update + // $this->invoiceRecords = InvoiceValidation::with('stickerMasterRelation') + // ->where('invoice_number', $this->invoiceNumber) + // ->where('plant_id', $this->plantId) + // ->get(); -// foreach ($this->invoiceRecords as &$row) { + // foreach ($this->invoiceRecords as &$row) { -// $stickCount = 0; -// $scannedCount = 0; + // $stickCount = 0; + // $scannedCount = 0; -// // Get item code -// $row['code'] = StickerMaster::with('item') -// ->find($row['sticker_master_id'] ?? null)?->item?->code ?? 'N/A'; + // // Get item code + // $row['code'] = StickerMaster::with('item') + // ->find($row['sticker_master_id'] ?? null)?->item?->code ?? 'N/A'; -// $curStick = StickerMaster::find($row['sticker_master_id']); + // $curStick = StickerMaster::find($row['sticker_master_id']); -// if ($curStick) { + // if ($curStick) { -// /** ---------------- REQUIRED STICKERS ---------------- */ + // /** ---------------- REQUIRED STICKERS ---------------- */ -// // PANEL BOX (capacitor) -// if (!empty($curStick->panel_box_code)) { -// $stickCount++; + // // PANEL BOX (capacitor) + // if (!empty($curStick->panel_box_code)) { + // $stickCount++; -// // Panel box scan = capacitor_scanned_status -// if ($row['capacitor_scanned_status'] == 1) { -// $scannedCount++; -// } -// } + // // Panel box scan = capacitor_scanned_status + // if ($row['capacitor_scanned_status'] == 1) { + // $scannedCount++; + // } + // } -// // Tube stickers -// if ( -// $curStick->tube_sticker_motor == 1 || -// $curStick->tube_sticker_pump == 1 || -// $curStick->tube_sticker_pumpset == 1 -// ) { -// if ($curStick->tube_sticker_motor == 1) { -// $stickCount++; -// if ($row['motor_scanned_status'] == 1) { -// $scannedCount++; -// } -// } + // // Tube stickers + // if ( + // $curStick->tube_sticker_motor == 1 || + // $curStick->tube_sticker_pump == 1 || + // $curStick->tube_sticker_pumpset == 1 + // ) { + // if ($curStick->tube_sticker_motor == 1) { + // $stickCount++; + // if ($row['motor_scanned_status'] == 1) { + // $scannedCount++; + // } + // } -// if ( -// $curStick->tube_sticker_pump == 1 || -// ($curStick->tube_sticker_pumpset != 1 && -// $curStick->tube_sticker_pump != 1 && -// $curStick->pack_slip_pump == 1) -// ) { -// $stickCount++; -// if ($row['pump_scanned_status'] == 1) { -// $scannedCount++; -// } -// } + // if ( + // $curStick->tube_sticker_pump == 1 || + // ($curStick->tube_sticker_pumpset != 1 && + // $curStick->tube_sticker_pump != 1 && + // $curStick->pack_slip_pump == 1) + // ) { + // $stickCount++; + // if ($row['pump_scanned_status'] == 1) { + // $scannedCount++; + // } + // } -// if ($curStick->tube_sticker_pumpset == 1) { -// $stickCount++; -// if ($row['scanned_status_set'] == 1) { -// $scannedCount++; -// } -// } -// } + // if ($curStick->tube_sticker_pumpset == 1) { + // $stickCount++; + // if ($row['scanned_status_set'] == 1) { + // $scannedCount++; + // } + // } + // } -// // Pack slips (only if no tube stickers) -// elseif ( -// $curStick->pack_slip_motor == 1 || -// $curStick->pack_slip_pump == 1 || -// $curStick->pack_slip_pumpset == 1 -// ) { -// if ($curStick->pack_slip_motor == 1) { -// $stickCount++; -// if ($row['motor_scanned_status'] == 1) { -// $scannedCount++; -// } -// } + // // Pack slips (only if no tube stickers) + // elseif ( + // $curStick->pack_slip_motor == 1 || + // $curStick->pack_slip_pump == 1 || + // $curStick->pack_slip_pumpset == 1 + // ) { + // if ($curStick->pack_slip_motor == 1) { + // $stickCount++; + // if ($row['motor_scanned_status'] == 1) { + // $scannedCount++; + // } + // } -// if ($curStick->pack_slip_pump == 1) { -// $stickCount++; -// if ($row['pump_scanned_status'] == 1) { -// $scannedCount++; -// } -// } + // if ($curStick->pack_slip_pump == 1) { + // $stickCount++; + // if ($row['pump_scanned_status'] == 1) { + // $scannedCount++; + // } + // } -// if ($curStick->pack_slip_pumpset == 1) { -// $stickCount++; -// if ($row['scanned_status_set'] == 1) { -// $scannedCount++; -// } -// } -// } -// } + // if ($curStick->pack_slip_pumpset == 1) { + // $stickCount++; + // if ($row['scanned_status_set'] == 1) { + // $scannedCount++; + // } + // } + // } + // } -// // SAFETY: never go negative -// $this->packageCount += max($stickCount - $scannedCount, 0); -// } - -// $this->dispatch($onCapFocus ? 'focus-capacitor-input' : 'focus-serial-number'); -// } + // // SAFETY: never go negative + // $this->packageCount += max($stickCount - $scannedCount, 0); + // } + // $this->dispatch($onCapFocus ? 'focus-capacitor-input' : 'focus-serial-number'); + // } // #[On('refreshInvoiceData')] - // public function loadData($invoiceNumber, $plantId, $onCapFocus = false) // { // $this->invoiceNumber = $invoiceNumber; @@ -371,7 +368,6 @@ class InvoiceDataTable extends Component // $this->dispatch($onCapFocus ? 'focus-capacitor-input' : 'focus-serial-number'); // } - public function loadData($invoiceNumber, $plantId, $onCapFocus = false) { $this->invoiceNumber = $invoiceNumber; @@ -396,24 +392,23 @@ class InvoiceDataTable extends Component $sm = $record->stickerMasterRelation; - if (!$sm) { + if (! $sm) { return 0; } - $stickCount = 0; + $stickCount = 0; $scannedCount = 0; - if (!empty($sm->panel_box_code)) { + if (! empty($sm->panel_box_code)) { $stickCount++; if ($record->capacitor_scanned_status == 1) { $scannedCount++; } } - if ($sm->tube_sticker_motor == 1 || $sm->tube_sticker_pump == 1 || $sm->tube_sticker_pumpset == 1){ + if ($sm->tube_sticker_motor == 1 || $sm->tube_sticker_pump == 1 || $sm->tube_sticker_pumpset == 1) { - if ($sm->tube_sticker_motor == 1) - { + if ($sm->tube_sticker_motor == 1) { $stickCount++; if ($record->motor_scanned_status == 1) { $scannedCount++; @@ -438,9 +433,7 @@ class InvoiceDataTable extends Component $scannedCount++; } } - } - elseif ($sm->pack_slip_motor == 1 || $sm->pack_slip_pump == 1 || $sm->pack_slip_pumpset == 1) - { + } elseif ($sm->pack_slip_motor == 1 || $sm->pack_slip_pump == 1 || $sm->pack_slip_pumpset == 1) { if ($sm->pack_slip_motor == 1) { $stickCount++; if ($record->motor_scanned_status == 1) { @@ -488,7 +481,6 @@ class InvoiceDataTable extends Component ->paginate(6); } - // public function loadData($invoiceNumber, $plantId, $onCapFocus = false) // { // $this->plantId = $plantId; @@ -571,7 +563,6 @@ class InvoiceDataTable extends Component // } // } - public function loadMaterialData($invoiceNumber, $plantId) { $this->plantId = $plantId; @@ -636,6 +627,7 @@ class InvoiceDataTable extends Component public function cancelCapacitorInput() { + $this->capacitorInput = null; $this->showCapacitorInput = false; $this->dispatch('focus-serial-number'); } @@ -689,7 +681,7 @@ class InvoiceDataTable extends Component // if (($row['code'] ?? '') === $this->currentItemCode && ($row['serial_number'] ?? '') === $this->currentSerialNumber) { // $row['panel_box_supplier'] = $supplier; - // $row['panel_box_item_code'] = $itemCode; + // $row['panel_box_code'] = $itemCode; // $row['panel_box_serial_number'] = $serialNumber; // $row['capacitor_scanned_status'] = 1; // // $row['scanned_status_set'] = true; @@ -730,7 +722,7 @@ class InvoiceDataTable extends Component // if ($packCnt === $scanCnt) { // $matchingValidation->update([ // 'panel_box_supplier' => $supplier, - // 'panel_box_item_code' => $itemCode, + // 'panel_box_code' => $itemCode, // 'panel_box_serial_number' => $serialNumber, // 'capacitor_scanned_status' => 1, // 'scanned_status' => 'Scanned', @@ -739,7 +731,7 @@ class InvoiceDataTable extends Component // } else { // $matchingValidation->update([ // 'panel_box_supplier' => $supplier, - // 'panel_box_item_code' => $itemCode, + // 'panel_box_code' => $itemCode, // 'panel_box_serial_number' => $serialNumber, // 'capacitor_scanned_status' => 1, // 'operator_id' => $operatorName, @@ -748,7 +740,7 @@ class InvoiceDataTable extends Component // } else { // $matchingValidation->update([ // 'panel_box_supplier' => $supplier, - // 'panel_box_item_code' => $itemCode, + // 'panel_box_code' => $itemCode, // 'panel_box_serial_number' => $serialNumber, // 'capacitor_scanned_status' => 1, // 'scanned_status' => 'Scanned', @@ -797,8 +789,6 @@ class InvoiceDataTable extends Component // $this->dispatch('focus-serial-number'); // } - - public function processCapacitorInput() { $user = Filament::auth()->user(); @@ -818,6 +808,7 @@ class InvoiceDataTable extends Component ->send(); $this->capacitorInput = ''; + return; } @@ -856,7 +847,7 @@ class InvoiceDataTable extends Component if ($stickerCode === $this->currentItemCode && $serialNo === $this->currentSerialNumber) { $row['panel_box_supplier'] = $supplier; - $row['panel_box_item_code'] = $itemCode; + $row['panel_box_code'] = $itemCode; $row['panel_box_serial_number'] = $serialNumber; $row['capacitor_scanned_status'] = 1; // $row['scanned_status_set'] = true; @@ -869,7 +860,7 @@ class InvoiceDataTable extends Component return $validation->stickerMaster?->item?->code === $this->currentItemCode; }); - // dd($matchingValidation); + // dd($matchingValidation); if ($matchingValidation) { $hasMotorQr = $matchingValidation->stickerMasterRelation->tube_sticker_motor ?? null; @@ -897,7 +888,7 @@ class InvoiceDataTable extends Component if ($packCnt === $scanCnt) { $matchingValidation->update([ 'panel_box_supplier' => $supplier, - 'panel_box_item_code' => $itemCode, + 'panel_box_code' => $itemCode, 'panel_box_serial_number' => $serialNumber, 'capacitor_scanned_status' => 1, 'scanned_status' => 'Scanned', @@ -906,7 +897,7 @@ class InvoiceDataTable extends Component } else { $matchingValidation->update([ 'panel_box_supplier' => $supplier, - 'panel_box_item_code' => $itemCode, + 'panel_box_code' => $itemCode, 'panel_box_serial_number' => $serialNumber, 'capacitor_scanned_status' => 1, 'operator_id' => $operatorName, @@ -915,7 +906,7 @@ class InvoiceDataTable extends Component } else { $matchingValidation->update([ 'panel_box_supplier' => $supplier, - 'panel_box_item_code' => $itemCode, + 'panel_box_code' => $itemCode, 'panel_box_serial_number' => $serialNumber, 'capacitor_scanned_status' => 1, 'scanned_status' => 'Scanned', diff --git a/resources/views/livewire/invoice-data-table.blade.php b/resources/views/livewire/invoice-data-table.blade.php index b0f2d60..07c29ee 100644 --- a/resources/views/livewire/invoice-data-table.blade.php +++ b/resources/views/livewire/invoice-data-table.blade.php @@ -81,6 +81,7 @@ Scanned Status Time Stamp Operator ID + Panel Box Code Panel Box Supplier Panel Box Serial Number @@ -98,6 +99,7 @@ {{ $row['scanned_status'] ?? '' }} {{ $row['created_at'] ?? '' }} {{ $row['operator_id'] ?? '' }} + {{ $row['panel_box_code'] ?? '' }} {{ $row['panel_box_supplier'] ?? '' }} {{ $row['panel_box_serial_number'] ?? '' }} @@ -130,6 +132,7 @@ Scanned Status Time Stamp Operator ID + Panel Box Code Panel Box Supplier Panel Box Serial Number @@ -148,6 +151,7 @@ {{ $record->scanned_status ?? '' }} {{ optional($record->created_at)->format('d-m-Y H:i:s') }} {{ $record->operator_id ?? '' }} + {{ $record->panel_box_code ?? '' }} {{ $record->panel_box_supplier ?? '' }} {{ $record->panel_box_serial_number ?? '' }}