Updated clear panel box QR if cancel button clicked and Added panel_box_code update logic on livewire page
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled

This commit is contained in:
dhanabalan
2026-02-03 20:57:39 +05:30
parent a14cf0aef6
commit 92f3352f6b
2 changed files with 120 additions and 125 deletions

View File

@@ -6,17 +6,17 @@ use App\Models\InvoiceValidation;
use App\Models\StickerMaster; use App\Models\StickerMaster;
use Filament\Facades\Filament; use Filament\Facades\Filament;
use Filament\Notifications\Notification; use Filament\Notifications\Notification;
use Livewire\Component;
use Str;
use Livewire\Attributes\On; use Livewire\Attributes\On;
use Livewire\Component;
use Livewire\WithPagination; use Livewire\WithPagination;
use Str;
class InvoiceDataTable extends Component class InvoiceDataTable extends Component
{ {
use WithPagination; use WithPagination;
protected $paginationTheme = 'tailwind'; protected $paginationTheme = 'tailwind';
public $invoiceData = []; public $invoiceData = [];
// public $invoiceRecords; // public $invoiceRecords;
@@ -25,7 +25,6 @@ class InvoiceDataTable extends Component
public $package = []; public $package = [];
public $packageCount = 0; public $packageCount = 0;
public string $invoiceNumber = ''; public string $invoiceNumber = '';
@@ -58,7 +57,7 @@ class InvoiceDataTable extends Component
public $panel_box_supplier; public $panel_box_supplier;
public $panel_box_item_code; public $panel_box_code;
public $panel_box_serial_number; public $panel_box_serial_number;
@@ -187,126 +186,124 @@ class InvoiceDataTable extends Component
// } // }
// } // }
// public function loadData($invoiceNumber, $plantId, $onCapFocus = false) // public function loadData($invoiceNumber, $plantId, $onCapFocus = false)
// { // {
// $this->invoiceNumber = $invoiceNumber; // $this->invoiceNumber = $invoiceNumber;
// $this->plantId = $plantId; // $this->plantId = $plantId;
// $this->completedInvoice = false; // $this->completedInvoice = false;
// $this->isSerial = true; // $this->isSerial = true;
// $this->onCapFocus = $onCapFocus; // $this->onCapFocus = $onCapFocus;
// $this->emptyInvoice = false; // $this->emptyInvoice = false;
// $this->hasSearched = true; // $this->hasSearched = true;
// $this->materialInvoice = false; // $this->materialInvoice = false;
// $this->resetPage(); // $this->resetPage();
// $this->packageCount = 0; // $this->packageCount = 0;
// // IMPORTANT: keep scanned rows, otherwise count will not update // // IMPORTANT: keep scanned rows, otherwise count will not update
// $this->invoiceRecords = InvoiceValidation::with('stickerMasterRelation') // $this->invoiceRecords = InvoiceValidation::with('stickerMasterRelation')
// ->where('invoice_number', $this->invoiceNumber) // ->where('invoice_number', $this->invoiceNumber)
// ->where('plant_id', $this->plantId) // ->where('plant_id', $this->plantId)
// ->get(); // ->get();
// foreach ($this->invoiceRecords as &$row) { // foreach ($this->invoiceRecords as &$row) {
// $stickCount = 0; // $stickCount = 0;
// $scannedCount = 0; // $scannedCount = 0;
// // Get item code // // Get item code
// $row['code'] = StickerMaster::with('item') // $row['code'] = StickerMaster::with('item')
// ->find($row['sticker_master_id'] ?? null)?->item?->code ?? 'N/A'; // ->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) // // PANEL BOX (capacitor)
// if (!empty($curStick->panel_box_code)) { // if (!empty($curStick->panel_box_code)) {
// $stickCount++; // $stickCount++;
// // Panel box scan = capacitor_scanned_status // // Panel box scan = capacitor_scanned_status
// if ($row['capacitor_scanned_status'] == 1) { // if ($row['capacitor_scanned_status'] == 1) {
// $scannedCount++; // $scannedCount++;
// } // }
// } // }
// // Tube stickers // // Tube stickers
// if ( // if (
// $curStick->tube_sticker_motor == 1 || // $curStick->tube_sticker_motor == 1 ||
// $curStick->tube_sticker_pump == 1 || // $curStick->tube_sticker_pump == 1 ||
// $curStick->tube_sticker_pumpset == 1 // $curStick->tube_sticker_pumpset == 1
// ) { // ) {
// if ($curStick->tube_sticker_motor == 1) { // if ($curStick->tube_sticker_motor == 1) {
// $stickCount++; // $stickCount++;
// if ($row['motor_scanned_status'] == 1) { // if ($row['motor_scanned_status'] == 1) {
// $scannedCount++; // $scannedCount++;
// } // }
// } // }
// if ( // if (
// $curStick->tube_sticker_pump == 1 || // $curStick->tube_sticker_pump == 1 ||
// ($curStick->tube_sticker_pumpset != 1 && // ($curStick->tube_sticker_pumpset != 1 &&
// $curStick->tube_sticker_pump != 1 && // $curStick->tube_sticker_pump != 1 &&
// $curStick->pack_slip_pump == 1) // $curStick->pack_slip_pump == 1)
// ) { // ) {
// $stickCount++; // $stickCount++;
// if ($row['pump_scanned_status'] == 1) { // if ($row['pump_scanned_status'] == 1) {
// $scannedCount++; // $scannedCount++;
// } // }
// } // }
// if ($curStick->tube_sticker_pumpset == 1) { // if ($curStick->tube_sticker_pumpset == 1) {
// $stickCount++; // $stickCount++;
// if ($row['scanned_status_set'] == 1) { // if ($row['scanned_status_set'] == 1) {
// $scannedCount++; // $scannedCount++;
// } // }
// } // }
// } // }
// // Pack slips (only if no tube stickers) // // Pack slips (only if no tube stickers)
// elseif ( // elseif (
// $curStick->pack_slip_motor == 1 || // $curStick->pack_slip_motor == 1 ||
// $curStick->pack_slip_pump == 1 || // $curStick->pack_slip_pump == 1 ||
// $curStick->pack_slip_pumpset == 1 // $curStick->pack_slip_pumpset == 1
// ) { // ) {
// if ($curStick->pack_slip_motor == 1) { // if ($curStick->pack_slip_motor == 1) {
// $stickCount++; // $stickCount++;
// if ($row['motor_scanned_status'] == 1) { // if ($row['motor_scanned_status'] == 1) {
// $scannedCount++; // $scannedCount++;
// } // }
// } // }
// if ($curStick->pack_slip_pump == 1) { // if ($curStick->pack_slip_pump == 1) {
// $stickCount++; // $stickCount++;
// if ($row['pump_scanned_status'] == 1) { // if ($row['pump_scanned_status'] == 1) {
// $scannedCount++; // $scannedCount++;
// } // }
// } // }
// if ($curStick->pack_slip_pumpset == 1) { // if ($curStick->pack_slip_pumpset == 1) {
// $stickCount++; // $stickCount++;
// if ($row['scanned_status_set'] == 1) { // if ($row['scanned_status_set'] == 1) {
// $scannedCount++; // $scannedCount++;
// } // }
// } // }
// } // }
// } // }
// // SAFETY: never go negative // // SAFETY: never go negative
// $this->packageCount += max($stickCount - $scannedCount, 0); // $this->packageCount += max($stickCount - $scannedCount, 0);
// } // }
// $this->dispatch($onCapFocus ? 'focus-capacitor-input' : 'focus-serial-number');
// }
// $this->dispatch($onCapFocus ? 'focus-capacitor-input' : 'focus-serial-number');
// }
// #[On('refreshInvoiceData')] // #[On('refreshInvoiceData')]
// public function loadData($invoiceNumber, $plantId, $onCapFocus = false) // public function loadData($invoiceNumber, $plantId, $onCapFocus = false)
// { // {
// $this->invoiceNumber = $invoiceNumber; // $this->invoiceNumber = $invoiceNumber;
@@ -371,7 +368,6 @@ class InvoiceDataTable extends Component
// $this->dispatch($onCapFocus ? 'focus-capacitor-input' : 'focus-serial-number'); // $this->dispatch($onCapFocus ? 'focus-capacitor-input' : 'focus-serial-number');
// } // }
public function loadData($invoiceNumber, $plantId, $onCapFocus = false) public function loadData($invoiceNumber, $plantId, $onCapFocus = false)
{ {
$this->invoiceNumber = $invoiceNumber; $this->invoiceNumber = $invoiceNumber;
@@ -396,24 +392,23 @@ class InvoiceDataTable extends Component
$sm = $record->stickerMasterRelation; $sm = $record->stickerMasterRelation;
if (!$sm) { if (! $sm) {
return 0; return 0;
} }
$stickCount = 0; $stickCount = 0;
$scannedCount = 0; $scannedCount = 0;
if (!empty($sm->panel_box_code)) { if (! empty($sm->panel_box_code)) {
$stickCount++; $stickCount++;
if ($record->capacitor_scanned_status == 1) { if ($record->capacitor_scanned_status == 1) {
$scannedCount++; $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++; $stickCount++;
if ($record->motor_scanned_status == 1) { if ($record->motor_scanned_status == 1) {
$scannedCount++; $scannedCount++;
@@ -438,9 +433,7 @@ class InvoiceDataTable extends Component
$scannedCount++; $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) { if ($sm->pack_slip_motor == 1) {
$stickCount++; $stickCount++;
if ($record->motor_scanned_status == 1) { if ($record->motor_scanned_status == 1) {
@@ -488,7 +481,6 @@ class InvoiceDataTable extends Component
->paginate(6); ->paginate(6);
} }
// public function loadData($invoiceNumber, $plantId, $onCapFocus = false) // public function loadData($invoiceNumber, $plantId, $onCapFocus = false)
// { // {
// $this->plantId = $plantId; // $this->plantId = $plantId;
@@ -571,7 +563,6 @@ class InvoiceDataTable extends Component
// } // }
// } // }
public function loadMaterialData($invoiceNumber, $plantId) public function loadMaterialData($invoiceNumber, $plantId)
{ {
$this->plantId = $plantId; $this->plantId = $plantId;
@@ -636,6 +627,7 @@ class InvoiceDataTable extends Component
public function cancelCapacitorInput() public function cancelCapacitorInput()
{ {
$this->capacitorInput = null;
$this->showCapacitorInput = false; $this->showCapacitorInput = false;
$this->dispatch('focus-serial-number'); $this->dispatch('focus-serial-number');
} }
@@ -689,7 +681,7 @@ class InvoiceDataTable extends Component
// 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_supplier'] = $supplier;
// $row['panel_box_item_code'] = $itemCode; // $row['panel_box_code'] = $itemCode;
// $row['panel_box_serial_number'] = $serialNumber; // $row['panel_box_serial_number'] = $serialNumber;
// $row['capacitor_scanned_status'] = 1; // $row['capacitor_scanned_status'] = 1;
// // $row['scanned_status_set'] = true; // // $row['scanned_status_set'] = true;
@@ -730,7 +722,7 @@ class InvoiceDataTable extends Component
// if ($packCnt === $scanCnt) { // if ($packCnt === $scanCnt) {
// $matchingValidation->update([ // $matchingValidation->update([
// 'panel_box_supplier' => $supplier, // 'panel_box_supplier' => $supplier,
// 'panel_box_item_code' => $itemCode, // 'panel_box_code' => $itemCode,
// 'panel_box_serial_number' => $serialNumber, // 'panel_box_serial_number' => $serialNumber,
// 'capacitor_scanned_status' => 1, // 'capacitor_scanned_status' => 1,
// 'scanned_status' => 'Scanned', // 'scanned_status' => 'Scanned',
@@ -739,7 +731,7 @@ class InvoiceDataTable extends Component
// } else { // } else {
// $matchingValidation->update([ // $matchingValidation->update([
// 'panel_box_supplier' => $supplier, // 'panel_box_supplier' => $supplier,
// 'panel_box_item_code' => $itemCode, // 'panel_box_code' => $itemCode,
// 'panel_box_serial_number' => $serialNumber, // 'panel_box_serial_number' => $serialNumber,
// 'capacitor_scanned_status' => 1, // 'capacitor_scanned_status' => 1,
// 'operator_id' => $operatorName, // 'operator_id' => $operatorName,
@@ -748,7 +740,7 @@ class InvoiceDataTable extends Component
// } else { // } else {
// $matchingValidation->update([ // $matchingValidation->update([
// 'panel_box_supplier' => $supplier, // 'panel_box_supplier' => $supplier,
// 'panel_box_item_code' => $itemCode, // 'panel_box_code' => $itemCode,
// 'panel_box_serial_number' => $serialNumber, // 'panel_box_serial_number' => $serialNumber,
// 'capacitor_scanned_status' => 1, // 'capacitor_scanned_status' => 1,
// 'scanned_status' => 'Scanned', // 'scanned_status' => 'Scanned',
@@ -797,8 +789,6 @@ class InvoiceDataTable extends Component
// $this->dispatch('focus-serial-number'); // $this->dispatch('focus-serial-number');
// } // }
public function processCapacitorInput() public function processCapacitorInput()
{ {
$user = Filament::auth()->user(); $user = Filament::auth()->user();
@@ -818,6 +808,7 @@ class InvoiceDataTable extends Component
->send(); ->send();
$this->capacitorInput = ''; $this->capacitorInput = '';
return; return;
} }
@@ -856,7 +847,7 @@ class InvoiceDataTable extends Component
if ($stickerCode === $this->currentItemCode && $serialNo === $this->currentSerialNumber) { if ($stickerCode === $this->currentItemCode && $serialNo === $this->currentSerialNumber) {
$row['panel_box_supplier'] = $supplier; $row['panel_box_supplier'] = $supplier;
$row['panel_box_item_code'] = $itemCode; $row['panel_box_code'] = $itemCode;
$row['panel_box_serial_number'] = $serialNumber; $row['panel_box_serial_number'] = $serialNumber;
$row['capacitor_scanned_status'] = 1; $row['capacitor_scanned_status'] = 1;
// $row['scanned_status_set'] = true; // $row['scanned_status_set'] = true;
@@ -869,7 +860,7 @@ class InvoiceDataTable extends Component
return $validation->stickerMaster?->item?->code === $this->currentItemCode; return $validation->stickerMaster?->item?->code === $this->currentItemCode;
}); });
// dd($matchingValidation); // dd($matchingValidation);
if ($matchingValidation) { if ($matchingValidation) {
$hasMotorQr = $matchingValidation->stickerMasterRelation->tube_sticker_motor ?? null; $hasMotorQr = $matchingValidation->stickerMasterRelation->tube_sticker_motor ?? null;
@@ -897,7 +888,7 @@ class InvoiceDataTable extends Component
if ($packCnt === $scanCnt) { if ($packCnt === $scanCnt) {
$matchingValidation->update([ $matchingValidation->update([
'panel_box_supplier' => $supplier, 'panel_box_supplier' => $supplier,
'panel_box_item_code' => $itemCode, 'panel_box_code' => $itemCode,
'panel_box_serial_number' => $serialNumber, 'panel_box_serial_number' => $serialNumber,
'capacitor_scanned_status' => 1, 'capacitor_scanned_status' => 1,
'scanned_status' => 'Scanned', 'scanned_status' => 'Scanned',
@@ -906,7 +897,7 @@ class InvoiceDataTable extends Component
} else { } else {
$matchingValidation->update([ $matchingValidation->update([
'panel_box_supplier' => $supplier, 'panel_box_supplier' => $supplier,
'panel_box_item_code' => $itemCode, 'panel_box_code' => $itemCode,
'panel_box_serial_number' => $serialNumber, 'panel_box_serial_number' => $serialNumber,
'capacitor_scanned_status' => 1, 'capacitor_scanned_status' => 1,
'operator_id' => $operatorName, 'operator_id' => $operatorName,
@@ -915,7 +906,7 @@ class InvoiceDataTable extends Component
} else { } else {
$matchingValidation->update([ $matchingValidation->update([
'panel_box_supplier' => $supplier, 'panel_box_supplier' => $supplier,
'panel_box_item_code' => $itemCode, 'panel_box_code' => $itemCode,
'panel_box_serial_number' => $serialNumber, 'panel_box_serial_number' => $serialNumber,
'capacitor_scanned_status' => 1, 'capacitor_scanned_status' => 1,
'scanned_status' => 'Scanned', 'scanned_status' => 'Scanned',

View File

@@ -81,6 +81,7 @@
<th class="border px-4 py-2">Scanned Status</th> <th class="border px-4 py-2">Scanned Status</th>
<th class="border px-4 py-2 w-[300px] whitespace-nowrap">Time Stamp</th> <th class="border px-4 py-2 w-[300px] whitespace-nowrap">Time Stamp</th>
<th class="border px-4 py-2">Operator ID</th> <th class="border px-4 py-2">Operator ID</th>
<th class="border px-4 py-2">Panel Box Code</th>
<th class="border px-4 py-2">Panel Box Supplier</th> <th class="border px-4 py-2">Panel Box Supplier</th>
<th class="border px-4 py-2">Panel Box Serial Number</th> <th class="border px-4 py-2">Panel Box Serial Number</th>
</tr> </tr>
@@ -98,6 +99,7 @@
<td class="border px-4 py-2">{{ $row['scanned_status'] ?? '' }}</td> <td class="border px-4 py-2">{{ $row['scanned_status'] ?? '' }}</td>
<td class="border px-4 py-2">{{ $row['created_at'] ?? '' }}</td> <td class="border px-4 py-2">{{ $row['created_at'] ?? '' }}</td>
<td class="border px-4 py-2">{{ $row['operator_id'] ?? '' }}</td> <td class="border px-4 py-2">{{ $row['operator_id'] ?? '' }}</td>
<td class="border px-4 py-2">{{ $row['panel_box_code'] ?? '' }}</td>
<td class="border px-4 py-2">{{ $row['panel_box_supplier'] ?? '' }}</td> <td class="border px-4 py-2">{{ $row['panel_box_supplier'] ?? '' }}</td>
<td class="border px-4 py-2">{{ $row['panel_box_serial_number'] ?? '' }}</td> <td class="border px-4 py-2">{{ $row['panel_box_serial_number'] ?? '' }}</td>
</tr> </tr>
@@ -130,6 +132,7 @@
<th class="border px-4 py-2">Scanned Status</th> <th class="border px-4 py-2">Scanned Status</th>
<th class="border px-4 py-2 w-[300px] whitespace-nowrap">Time Stamp</th> <th class="border px-4 py-2 w-[300px] whitespace-nowrap">Time Stamp</th>
<th class="border px-4 py-2">Operator ID</th> <th class="border px-4 py-2">Operator ID</th>
<th class="border px-4 py-2">Panel Box Code</th>
<th class="border px-4 py-2">Panel Box Supplier</th> <th class="border px-4 py-2">Panel Box Supplier</th>
<th class="border px-4 py-2">Panel Box Serial Number</th> <th class="border px-4 py-2">Panel Box Serial Number</th>
</tr> </tr>
@@ -148,6 +151,7 @@
<td class="border px-2 py-2">{{ $record->scanned_status ?? '' }}</td> <td class="border px-2 py-2">{{ $record->scanned_status ?? '' }}</td>
<td class="border px-2 py-2 whitespace-nowrap">{{ optional($record->created_at)->format('d-m-Y H:i:s') }}</td> <td class="border px-2 py-2 whitespace-nowrap">{{ optional($record->created_at)->format('d-m-Y H:i:s') }}</td>
<td class="border px-2 py-2">{{ $record->operator_id ?? '' }}</td> <td class="border px-2 py-2">{{ $record->operator_id ?? '' }}</td>
<td class="border px-2 py-2">{{ $record->panel_box_code ?? '' }}</td>
<td class="border px-2 py-2">{{ $record->panel_box_supplier ?? '' }}</td> <td class="border px-2 py-2">{{ $record->panel_box_supplier ?? '' }}</td>
<td class="border px-2 py-2">{{ $record->panel_box_serial_number ?? '' }}</td> <td class="border px-2 py-2">{{ $record->panel_box_serial_number ?? '' }}</td>
</tr> </tr>