changed loadData method in invoice data tabele in livewire
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 12s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 11s
Gemini PR Review / review (pull_request) Failing after 31s
Laravel Pint / pint (pull_request) Successful in 3m46s
Laravel Larastan / larastan (pull_request) Failing after 4m50s
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 12s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 11s
Gemini PR Review / review (pull_request) Failing after 31s
Laravel Pint / pint (pull_request) Successful in 3m46s
Laravel Larastan / larastan (pull_request) Failing after 4m50s
This commit is contained in:
@@ -83,7 +83,100 @@ class InvoiceDataTable extends Component
|
||||
// $this->showCapacitorInput = false;
|
||||
}
|
||||
|
||||
public function loadData($invoiceNumber, $plantId, $onCapFocus)
|
||||
// public function loadData($invoiceNumber, $plantId, $onCapFocus)
|
||||
// {
|
||||
// $this->plantId = $plantId;
|
||||
// $this->invoiceNumber = $invoiceNumber;
|
||||
// $this->completedInvoice = false;
|
||||
// $this->isSerial = true;
|
||||
// $this->onCapFocus = $onCapFocus;
|
||||
// $this->emptyInvoice = false;
|
||||
// $this->hasSearched = true;
|
||||
// $this->materialInvoice = false;
|
||||
// // $this->showCapacitorInput = false;
|
||||
|
||||
// // ->where('serial_number', '!=', '')
|
||||
// $this->invoiceData = InvoiceValidation::where('invoice_number', $this->invoiceNumber)
|
||||
// ->where('plant_id', $plantId)->where('scanned_status', null)
|
||||
// ->get()
|
||||
// ->map(function ($record) {
|
||||
// return [
|
||||
// 'sticker_master_id' => $record->sticker_master_id,
|
||||
// 'serial_number' => $record->serial_number,
|
||||
// 'motor_scanned_status' => $record->motor_scanned_status ?? '',
|
||||
// 'pump_scanned_status' => $record->pump_scanned_status ?? '',
|
||||
// 'capacitor_scanned_status' => $record->capacitor_scanned_status ?? '',
|
||||
// 'scanned_status_set' => $record->scanned_status_set ?? '',
|
||||
// 'scanned_status' => $record->scanned_status ?? '',
|
||||
// 'panel_box_supplier' => $record->panel_box_supplier ?? '',
|
||||
// 'panel_box_serial_number' => $record->panel_box_serial_number ?? '',
|
||||
// 'created_at' => $record->created_at,
|
||||
// 'operator_id' => $record->operator_id,
|
||||
// ];
|
||||
// })
|
||||
// ->toArray();
|
||||
|
||||
// $this->packageCount = 0;
|
||||
|
||||
// // Loop through and replace 'code' using related StickerMaster > Item > code
|
||||
// foreach ($this->invoiceData as &$row) {
|
||||
// $stickCount = 0;
|
||||
// $scannedCount = 0;
|
||||
|
||||
// // $stickerMaster = \App\Models\StickerMaster::with('item')->find($row['sticker_master_id'] ?? null);
|
||||
// $row['code'] = StickerMaster::with('item')->find($row['sticker_master_id'] ?? null)?->item?->code ?? 'N/A';
|
||||
// $curStick = StickerMaster::where('id', $row['sticker_master_id'])->first();
|
||||
// if ($curStick) {
|
||||
// if (Str::length($curStick->panel_box_code) > 0) {
|
||||
// $stickCount++;
|
||||
// }
|
||||
// if ($curStick->tube_sticker_motor == 1 || $curStick->tube_sticker_pump == 1 || $curStick->tube_sticker_pumpset == 1) {
|
||||
// if ($curStick->tube_sticker_motor == 1) {
|
||||
// $stickCount++;
|
||||
// }
|
||||
// if ($curStick->tube_sticker_pump == 1 || ($curStick->tube_sticker_pumpset != 1 && $curStick->tube_sticker_pump != 1 && $curStick->pack_slip_pump == 1)) {
|
||||
// $stickCount++;
|
||||
// }
|
||||
// if ($curStick->tube_sticker_pumpset == 1) {
|
||||
// $stickCount++;
|
||||
// }
|
||||
// } elseif ($curStick->pack_slip_motor == 1 || $curStick->pack_slip_pump == 1 || $curStick->pack_slip_pumpset == 1) {
|
||||
// if ($curStick->pack_slip_motor == 1) {
|
||||
// $stickCount++;
|
||||
// }
|
||||
// if ($curStick->pack_slip_pump == 1) {
|
||||
// $stickCount++;
|
||||
// }
|
||||
// if ($curStick->pack_slip_pumpset == 1) {
|
||||
// $stickCount++;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// if ($row['motor_scanned_status'] == 1) {
|
||||
// $scannedCount++;
|
||||
// }
|
||||
// if ($row['pump_scanned_status'] == 1) {
|
||||
// $scannedCount++;
|
||||
// }
|
||||
// if ($row['capacitor_scanned_status'] == 1) {
|
||||
// $scannedCount++;
|
||||
// }
|
||||
// if ($row['scanned_status_set'] == 1) {
|
||||
// $scannedCount++;
|
||||
// }
|
||||
|
||||
// $this->packageCount += $stickCount - $scannedCount;
|
||||
// }
|
||||
|
||||
// if ($onCapFocus) {
|
||||
// $this->dispatch('focus-capacitor-input');
|
||||
// } else {
|
||||
// $this->dispatch('focus-serial-number');
|
||||
// }
|
||||
// }
|
||||
|
||||
public function loadData($invoiceNumber, $plantId, $onCapFocus = false)
|
||||
{
|
||||
$this->plantId = $plantId;
|
||||
$this->invoiceNumber = $invoiceNumber;
|
||||
@@ -93,14 +186,56 @@ class InvoiceDataTable extends Component
|
||||
$this->emptyInvoice = false;
|
||||
$this->hasSearched = true;
|
||||
$this->materialInvoice = false;
|
||||
// $this->showCapacitorInput = false;
|
||||
|
||||
// ->where('serial_number', '!=', '')
|
||||
$this->invoiceData = InvoiceValidation::where('invoice_number', $this->invoiceNumber)
|
||||
->where('plant_id', $plantId)->where('scanned_status', null)
|
||||
->get()
|
||||
->map(function ($record) {
|
||||
return [
|
||||
// Eager load stickerMasterRelation and item
|
||||
$invoiceRecords = InvoiceValidation::with('stickerMasterRelation.item')
|
||||
->where('invoice_number', $invoiceNumber)
|
||||
->where('plant_id', $plantId)
|
||||
->whereNull('scanned_status')
|
||||
->get();
|
||||
|
||||
$this->invoiceData = [];
|
||||
$this->packageCount = 0;
|
||||
|
||||
foreach ($invoiceRecords as $record) {
|
||||
$sm = $record->stickerMasterRelation;
|
||||
|
||||
// Compute code
|
||||
$rowCode = $sm?->item?->code ?? 'N/A';
|
||||
|
||||
$stickCount = 0;
|
||||
$scannedCount = 0;
|
||||
|
||||
if ($sm) {
|
||||
// Panel box code
|
||||
if (Str::length($sm->panel_box_code) > 0) {
|
||||
$stickCount++;
|
||||
}
|
||||
|
||||
// Tube stickers logic
|
||||
if ($sm->tube_sticker_motor == 1 || $sm->tube_sticker_pump == 1 || $sm->tube_sticker_pumpset == 1) {
|
||||
if ($sm->tube_sticker_motor == 1) $stickCount++;
|
||||
if ($sm->tube_sticker_pump == 1 || ($sm->tube_sticker_pumpset != 1 && $sm->tube_sticker_pump != 1 && $sm->pack_slip_pump == 1)) $stickCount++;
|
||||
if ($sm->tube_sticker_pumpset == 1) $stickCount++;
|
||||
}
|
||||
// Pack slip logic (only if tube sticker block didn't apply)
|
||||
elseif ($sm->pack_slip_motor == 1 || $sm->pack_slip_pump == 1 || $sm->pack_slip_pumpset == 1) {
|
||||
if ($sm->pack_slip_motor == 1) $stickCount++;
|
||||
if ($sm->pack_slip_pump == 1) $stickCount++;
|
||||
if ($sm->pack_slip_pumpset == 1) $stickCount++;
|
||||
}
|
||||
}
|
||||
|
||||
// Count already scanned
|
||||
$scannedCount += ($record->motor_scanned_status == 1) ? 1 : 0;
|
||||
$scannedCount += ($record->pump_scanned_status == 1) ? 1 : 0;
|
||||
$scannedCount += ($record->capacitor_scanned_status == 1) ? 1 : 0;
|
||||
$scannedCount += ($record->scanned_status_set == 1) ? 1 : 0;
|
||||
|
||||
// Increment packageCount
|
||||
$this->packageCount += max($stickCount - $scannedCount, 0);
|
||||
|
||||
$this->invoiceData[] = [
|
||||
'sticker_master_id' => $record->sticker_master_id,
|
||||
'serial_number' => $record->serial_number,
|
||||
'motor_scanned_status' => $record->motor_scanned_status ?? '',
|
||||
@@ -112,61 +247,9 @@ class InvoiceDataTable extends Component
|
||||
'panel_box_serial_number' => $record->panel_box_serial_number ?? '',
|
||||
'created_at' => $record->created_at,
|
||||
'operator_id' => $record->operator_id,
|
||||
'code' => $rowCode,
|
||||
'stickCount' => $stickCount,
|
||||
];
|
||||
})
|
||||
->toArray();
|
||||
|
||||
$this->packageCount = 0;
|
||||
|
||||
// Loop through and replace 'code' using related StickerMaster > Item > code
|
||||
foreach ($this->invoiceData as &$row) {
|
||||
$stickCount = 0;
|
||||
$scannedCount = 0;
|
||||
|
||||
// $stickerMaster = \App\Models\StickerMaster::with('item')->find($row['sticker_master_id'] ?? null);
|
||||
$row['code'] = StickerMaster::with('item')->find($row['sticker_master_id'] ?? null)?->item?->code ?? 'N/A';
|
||||
$curStick = StickerMaster::where('id', $row['sticker_master_id'])->first();
|
||||
if ($curStick) {
|
||||
if (Str::length($curStick->panel_box_code) > 0) {
|
||||
$stickCount++;
|
||||
}
|
||||
if ($curStick->tube_sticker_motor == 1 || $curStick->tube_sticker_pump == 1 || $curStick->tube_sticker_pumpset == 1) {
|
||||
if ($curStick->tube_sticker_motor == 1) {
|
||||
$stickCount++;
|
||||
}
|
||||
if ($curStick->tube_sticker_pump == 1 || ($curStick->tube_sticker_pumpset != 1 && $curStick->tube_sticker_pump != 1 && $curStick->pack_slip_pump == 1)) {
|
||||
$stickCount++;
|
||||
}
|
||||
if ($curStick->tube_sticker_pumpset == 1) {
|
||||
$stickCount++;
|
||||
}
|
||||
} elseif ($curStick->pack_slip_motor == 1 || $curStick->pack_slip_pump == 1 || $curStick->pack_slip_pumpset == 1) {
|
||||
if ($curStick->pack_slip_motor == 1) {
|
||||
$stickCount++;
|
||||
}
|
||||
if ($curStick->pack_slip_pump == 1) {
|
||||
$stickCount++;
|
||||
}
|
||||
if ($curStick->pack_slip_pumpset == 1) {
|
||||
$stickCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($row['motor_scanned_status'] == 1) {
|
||||
$scannedCount++;
|
||||
}
|
||||
if ($row['pump_scanned_status'] == 1) {
|
||||
$scannedCount++;
|
||||
}
|
||||
if ($row['capacitor_scanned_status'] == 1) {
|
||||
$scannedCount++;
|
||||
}
|
||||
if ($row['scanned_status_set'] == 1) {
|
||||
$scannedCount++;
|
||||
}
|
||||
|
||||
$this->packageCount += $stickCount - $scannedCount;
|
||||
}
|
||||
|
||||
if ($onCapFocus) {
|
||||
|
||||
Reference in New Issue
Block a user