Added sticker validation livewire pages #84

Merged
jothi merged 1 commits from ranjith-dev into master 2025-12-30 08:59:00 +00:00
2 changed files with 119 additions and 0 deletions

View File

@@ -0,0 +1,65 @@
<?php
namespace App\Livewire;
use App\Models\ProductionQuantity;
use Livewire\Component;
class StickerValidation extends Component
{
public $plantId;
public $refNumber;
public $serialNumber;
public bool $materialInvoice = false;
public $records = [];
protected $listeners = [
'refreshEmptySticker' => 'loadStickerData',
'addStickerToList' => 'loadSticker'
];
public function loadStickerData($plantId, $refNumber)
{
$this->plantId = $plantId;
$this->refNumber = $refNumber;
// $this->records = ProductionQuantity::where('plant_id', $plantId)
// ->where('production_order', $refNumber)
// ->orderBy('created_at', 'asc')
// ->get(['serial_number', 'operator_id']);
$this->records = ProductionQuantity::query()
->where('production_quantities.plant_id', $plantId)
->where('production_quantities.production_order', $refNumber)
->leftJoin(
'sticker_validations',
'sticker_validations.serial_number',
'=',
'production_quantities.serial_number'
)
->orderBy('production_quantities.created_at', 'asc')
->get([
'production_quantities.serial_number',
'production_quantities.operator_id',
'sticker_validations.status',
'sticker_validations.sticker_id',
])
->map(function ($row) {
$row->status = $row->status ?? '';
return $row;
});
//dd($this->records);
}
public function render()
{
return view('livewire.sticker-validation');
}
}

View File

@@ -0,0 +1,54 @@
<div>
<h3 class="text-lg font-semibold mb-2">Sticker Printing Table</h3>
<div
wire:loading.remove
class="overflow-x-auto overflow-y-visible"
style="height: 385px;"
>
<table class="table-auto w-full border-collapse border">
{{-- <thead class="bg-gray-100"> --}}
<thead class="bg-gray-100 text-xs">
<tr>
<th class="border p-2">No</th>
<th class="border p-2">Sticker ID</th>
<th class="border p-2">Production Order</th>
<th class="border p-2">Serial Number</th>
<th class="border p-2">Status</th>
<th class="border p-2">Created By</th>
</tr>
</thead>
{{-- <tbody> --}}
<tbody class="text-xs">
@forelse($records as $index => $record)
<tr>
<td class="border p-2 text-center">{{ $index + 1 }}</td>
<td class="border p-2 text-center">{{ $record->sticker_id }}</td>
<td class="border p-2 text-center">{{ $refNumber }}</td>
<td class="border p-2 text-center">{{ $record['serial_number'] }}</td>
<td class="border p-2 text-center">{{ $record->status }}</td>
<td class="border p-2 text-center">{{ $record->operator_id }}</td>
</tr>
@empty
<tr>
<td class="border p-2 text-center" colspan="6">No serial numbers found.</td>
</tr>
@endforelse
</tbody>
</table>
</div>
<script>
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();
}
}, 50);
});
</script>