Compare commits
2 Commits
57f059aca8
...
b54a9af78b
| Author | SHA1 | Date | |
|---|---|---|---|
| b54a9af78b | |||
|
|
2f593326e5 |
65
app/Livewire/StickerValidation.php
Normal file
65
app/Livewire/StickerValidation.php
Normal 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');
|
||||||
|
}
|
||||||
|
}
|
||||||
54
resources/views/livewire/sticker-validation.blade.php
Normal file
54
resources/views/livewire/sticker-validation.blade.php
Normal 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>
|
||||||
Reference in New Issue
Block a user