Initial commit for new repo
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 1m4s
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 1m4s
This commit is contained in:
320
app/Livewire/GuardPatrolEntryDataTable.php
Normal file
320
app/Livewire/GuardPatrolEntryDataTable.php
Normal file
@@ -0,0 +1,320 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Models\CheckPointTime;
|
||||
use App\Models\GuardPatrolEntry;
|
||||
use Carbon\Carbon;
|
||||
use Livewire\Component;
|
||||
|
||||
class GuardPatrolEntryDataTable extends Component
|
||||
{
|
||||
// public $plantId;
|
||||
// public $date;
|
||||
|
||||
public $newNameFound;
|
||||
public $guardName;
|
||||
public $checkPointName;
|
||||
public $startTime;
|
||||
public $endTime;
|
||||
public $start;
|
||||
public $finish;
|
||||
public $begin;
|
||||
public $end;
|
||||
public $labTime;
|
||||
public $minDiff;
|
||||
public $seqNoCnt = 0;
|
||||
public $seqNo = 0;
|
||||
public $isSequenced = true;
|
||||
public $sequences = [];
|
||||
public $seqTime;
|
||||
public $seqTimes = [];
|
||||
public $startSeqCheckPoints = [];
|
||||
public $records = [];
|
||||
|
||||
protected $listeners = [
|
||||
'loadGuardData' => 'loadGuardPatrolData',
|
||||
];
|
||||
|
||||
public function loadGuardPatrolData($plantId, $date)
|
||||
{
|
||||
// $this->plantId = $plantId;
|
||||
// $this->date = $date;
|
||||
|
||||
$this->records = [];
|
||||
$this->newNameFound = true;
|
||||
$this->guardName = null;
|
||||
$this->checkPointName = null;
|
||||
$this->startTime = null;
|
||||
$this->endTime = null;
|
||||
$this->start = null;
|
||||
$this->finish = null;
|
||||
$this->begin = null;
|
||||
$this->end = null;
|
||||
$this->labTime = null;
|
||||
$this->minDiff = 0;
|
||||
$this->seqNoCnt = 0;
|
||||
$this->seqNo = 0;
|
||||
$this->isSequenced = true;
|
||||
$this->sequences = [];
|
||||
$this->seqTime = null;
|
||||
$this->seqTimes = [];
|
||||
$this->startSeqCheckPoints = [];
|
||||
|
||||
if (!$plantId || !$date)
|
||||
{
|
||||
$this->records = [];
|
||||
return;
|
||||
}
|
||||
|
||||
$this->seqNoCnt = CheckPointTime::where('plant_id', $plantId)->count('sequence_number');
|
||||
|
||||
for ($i = 1; $i <= $this->seqNoCnt; $i++) {
|
||||
$this->startSeqCheckPoints[$i] = CheckPointTime::with('checkPointNames1')->with('checkPointNames2')->where('sequence_number', $i)->where('plant_id', $plantId)->first();
|
||||
}
|
||||
|
||||
$this->sequences = array_fill(1, $this->seqNoCnt, "X");
|
||||
$this->seqTimes = array_fill(1, $this->seqNoCnt, null);
|
||||
|
||||
$hasSingleGuard = GuardPatrolEntry::whereDate('patrol_time', $date)->where('plant_id', $plantId)->orderBy('patrol_time', 'asc')->get();
|
||||
|
||||
$checking = 0;
|
||||
$records = GuardPatrolEntry::with('guardNames')->with('checkPointNames')->whereDate('patrol_time', $date)->where('plant_id', $plantId)->orderBy('patrol_time', 'asc')->get(); //desc Carbon::parse($record->patrol_time)->toTimeString()
|
||||
foreach ($records as $index => $record) { //foreach ($startSeqCheckPoints as $seq => $checkpoint)
|
||||
$checking++;
|
||||
$guardName = $record->guardNames ? $record->guardNames->name : null;
|
||||
$checkPointName = $record->checkPointNames ? $record->checkPointNames->name : null;
|
||||
if ($this->guardName != $guardName || $this->newNameFound) {//if ($this->newNameFound) {
|
||||
if ($this->guardName)
|
||||
{
|
||||
$recordData = [
|
||||
'guard_name' => $this->guardName,
|
||||
'start_time' => $this->startTime,
|
||||
'end_time' => $this->endTime,
|
||||
'lap_time' => $this->labTime,
|
||||
];
|
||||
|
||||
for ($i = 1; $i <= $this->seqNoCnt; $i++) {
|
||||
$recordData["Sequence_$i"] = $this->sequences[$i];
|
||||
$recordData["Sequence_Time_$i"] = $this->seqTimes[$i];
|
||||
}
|
||||
|
||||
$this->records[] = $recordData;
|
||||
}
|
||||
|
||||
$this->seqTimes = array_fill(1, $this->seqNoCnt, null);
|
||||
|
||||
$this->guardName = $guardName;
|
||||
$this->startTime = Carbon::parse($record->patrol_time)->toTimeString(); //"2025-06-01 00:07:12"
|
||||
$this->start = Carbon::parse($record->patrol_time);
|
||||
$this->endTime = Carbon::parse($record->patrol_time)->toTimeString(); //"2025-06-01 00:07:12"
|
||||
$this->finish = Carbon::parse($record->patrol_time);
|
||||
$this->begin = Carbon::parse($record->patrol_time);
|
||||
$this->end = Carbon::parse($record->patrol_time);
|
||||
$this->labTime = (int)$this->start->diffInMinutes($this->finish);
|
||||
$this->minDiff = (int)$this->begin->diffInMinutes($this->end);
|
||||
$this->seqTime = $this->begin->toTimeString(). " - " . $this->end->toTimeString();
|
||||
$this->seqNo = 0;
|
||||
$this->newNameFound = false;
|
||||
$this->isSequenced = true;
|
||||
}
|
||||
else if ($this->guardName == $guardName && $this->start && $this->begin)
|
||||
{
|
||||
$this->endTime = Carbon::parse($record->patrol_time)->toTimeString(); //"2025-06-01 00:07:12"
|
||||
$this->finish = Carbon::parse($record->patrol_time);
|
||||
$this->end = Carbon::parse($record->patrol_time);
|
||||
$this->labTime = (int)$this->start->diffInMinutes($this->finish);
|
||||
$this->minDiff = (int)$this->begin->diffInMinutes($this->end);
|
||||
$this->seqTime = $this->begin->toTimeString(). " - " . $this->end->toTimeString();
|
||||
$this->begin = Carbon::parse($record->patrol_time);
|
||||
// $this->seqNo = 0;
|
||||
}
|
||||
|
||||
$this->seqNo++;
|
||||
|
||||
if ($this->seqNo == 1) {
|
||||
if ($checkPointName == $this->startSeqCheckPoints[$this->seqNo]->checkPointNames1->name) {//"STP BACKSIDE"
|
||||
$this->isSequenced = true;
|
||||
$this->sequences = array_fill(1, $this->seqNoCnt, "X");
|
||||
}
|
||||
else {
|
||||
$this->isSequenced = false;
|
||||
$this->sequences = array_fill(1, $this->seqNoCnt, "X");
|
||||
}
|
||||
|
||||
if (($index+1) == count($hasSingleGuard))
|
||||
{
|
||||
if ($this->guardName)
|
||||
{
|
||||
$recordData = [
|
||||
'guard_name' => $this->guardName,
|
||||
'start_time' => $this->startTime,
|
||||
'end_time' => $this->endTime,
|
||||
'lap_time' => $this->labTime,
|
||||
];
|
||||
|
||||
for ($i = 1; $i <= $this->seqNoCnt; $i++) {
|
||||
$recordData["Sequence_$i"] = $this->sequences[$i];
|
||||
$recordData["Sequence_Time_$i"] = $this->seqTimes[$i];
|
||||
}
|
||||
|
||||
$this->records[] = $recordData;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ($this->seqNo >= ($this->seqNoCnt+1)) {
|
||||
$this->seqTimes[$this->seqNo-1] = $this->seqTime;
|
||||
if ($checkPointName == $this->startSeqCheckPoints[$this->seqNo-1]->checkPointNames2->name) {//"D 72 END"
|
||||
if ($this->isSequenced) {
|
||||
$this->sequences[$this->seqNo-1] = $this->minDiff;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$this->isSequenced = false;
|
||||
}
|
||||
$this->newNameFound = true;
|
||||
|
||||
if ($hasSingleGuard->unique('guard_name_id')->count() == 1)
|
||||
{
|
||||
if (($this->seqNoCnt+1) == count($hasSingleGuard))
|
||||
{
|
||||
//dd("Has 1 Guard and single patrol round (".($this->seqNoCnt+1).") is present");
|
||||
if ($this->guardName)
|
||||
{
|
||||
$recordData = [
|
||||
'guard_name' => $this->guardName,
|
||||
'start_time' => $this->startTime,
|
||||
'end_time' => $this->endTime,
|
||||
'lap_time' => $this->labTime,
|
||||
];
|
||||
|
||||
for ($i = 1; $i <= $this->seqNoCnt; $i++) {
|
||||
$recordData["Sequence_$i"] = $this->sequences[$i];
|
||||
$recordData["Sequence_Time_$i"] = $this->seqTimes[$i];
|
||||
}
|
||||
|
||||
$this->records[] = $recordData;
|
||||
}
|
||||
}
|
||||
else if (($index+1) == count($hasSingleGuard))
|
||||
{
|
||||
if ($this->guardName)
|
||||
{
|
||||
$recordData = [
|
||||
'guard_name' => $this->guardName,
|
||||
'start_time' => $this->startTime,
|
||||
'end_time' => $this->endTime,
|
||||
'lap_time' => $this->labTime,
|
||||
];
|
||||
|
||||
for ($i = 1; $i <= $this->seqNoCnt; $i++) {
|
||||
$recordData["Sequence_$i"] = $this->sequences[$i];
|
||||
$recordData["Sequence_Time_$i"] = $this->seqTimes[$i];
|
||||
}
|
||||
|
||||
$this->records[] = $recordData;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (($index+1) == count($hasSingleGuard))
|
||||
{
|
||||
if ($this->guardName)
|
||||
{
|
||||
$recordData = [
|
||||
'guard_name' => $this->guardName,
|
||||
'start_time' => $this->startTime,
|
||||
'end_time' => $this->endTime,
|
||||
'lap_time' => $this->labTime,
|
||||
];
|
||||
|
||||
for ($i = 1; $i <= $this->seqNoCnt; $i++) {
|
||||
$recordData["Sequence_$i"] = $this->sequences[$i];
|
||||
$recordData["Sequence_Time_$i"] = $this->seqTimes[$i];
|
||||
}
|
||||
|
||||
$this->records[] = $recordData;
|
||||
}
|
||||
}
|
||||
}
|
||||
else // if ($this->seqNo >= 2) {
|
||||
{
|
||||
$this->seqTimes[$this->seqNo-1] = $this->seqTime;
|
||||
if ($checkPointName == $this->startSeqCheckPoints[$this->seqNo]->checkPointNames1->name) {//"CANTEEN"
|
||||
if ($this->isSequenced) {
|
||||
$this->sequences[$this->seqNo-1] = $this->minDiff;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$this->isSequenced = false;
|
||||
}
|
||||
|
||||
if ($hasSingleGuard->unique('guard_name_id')->count() == 1)
|
||||
{
|
||||
if ($this->seqNo == count($hasSingleGuard))
|
||||
{
|
||||
//dd("Has 1 Guard and single patrol round (".($this->seqNoCnt+1).") is present");
|
||||
if ($this->guardName)
|
||||
{
|
||||
$recordData = [
|
||||
'guard_name' => $this->guardName,
|
||||
'start_time' => $this->startTime,
|
||||
'end_time' => $this->endTime,
|
||||
'lap_time' => $this->labTime,
|
||||
];
|
||||
|
||||
for ($i = 1; $i <= $this->seqNoCnt; $i++) {
|
||||
$recordData["Sequence_$i"] = $this->sequences[$i];
|
||||
$recordData["Sequence_Time_$i"] = $this->seqTimes[$i];
|
||||
}
|
||||
|
||||
$this->records[] = $recordData;
|
||||
}
|
||||
}
|
||||
else if (($index+1) == count($hasSingleGuard))
|
||||
{
|
||||
if ($this->guardName)
|
||||
{
|
||||
$recordData = [
|
||||
'guard_name' => $this->guardName,
|
||||
'start_time' => $this->startTime,
|
||||
'end_time' => $this->endTime,
|
||||
'lap_time' => $this->labTime,
|
||||
];
|
||||
|
||||
for ($i = 1; $i <= $this->seqNoCnt; $i++) {
|
||||
$recordData["Sequence_$i"] = $this->sequences[$i];
|
||||
$recordData["Sequence_Time_$i"] = $this->seqTimes[$i];
|
||||
}
|
||||
|
||||
$this->records[] = $recordData;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (($index+1) == count($hasSingleGuard))
|
||||
{
|
||||
if ($this->guardName)
|
||||
{
|
||||
$recordData = [
|
||||
'guard_name' => $this->guardName,
|
||||
'start_time' => $this->startTime,
|
||||
'end_time' => $this->endTime,
|
||||
'lap_time' => $this->labTime,
|
||||
];
|
||||
|
||||
for ($i = 1; $i <= $this->seqNoCnt; $i++) {
|
||||
$recordData["Sequence_$i"] = $this->sequences[$i];
|
||||
$recordData["Sequence_Time_$i"] = $this->seqTimes[$i];
|
||||
}
|
||||
|
||||
$this->records[] = $recordData;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.guard-patrol-entry-data-table');
|
||||
}
|
||||
}
|
||||
404
app/Livewire/InvoiceDataTable.php
Normal file
404
app/Livewire/InvoiceDataTable.php
Normal file
@@ -0,0 +1,404 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Models\InvoiceValidation;
|
||||
use App\Models\StickerMaster;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Notifications\Notification;
|
||||
use Livewire\Component;
|
||||
use Str;
|
||||
|
||||
class InvoiceDataTable extends Component
|
||||
{
|
||||
public $invoiceData = [];
|
||||
|
||||
public $plantId = 0;
|
||||
|
||||
public $packageCount = 0;
|
||||
|
||||
public string $invoiceNumber = '';
|
||||
|
||||
public bool $completedInvoice = false;
|
||||
|
||||
public bool $isSerial = false;
|
||||
|
||||
public bool $onCapFocus = false;
|
||||
|
||||
public bool $emptyInvoice = false;
|
||||
|
||||
public bool $hasSearched = false;
|
||||
|
||||
public bool $materialInvoice = false;
|
||||
|
||||
public bool $showCapacitorInput = false;
|
||||
|
||||
// protected $listeners = ['refreshInvoiceData' => 'loadData',];
|
||||
|
||||
protected $listeners = [
|
||||
'refreshCompletedInvoice' => 'loadCompletedData',
|
||||
'refreshEmptyInvoice' => 'loadEmptyData',
|
||||
'refreshInvoiceData' => 'loadData',
|
||||
'refreshMaterialInvoiceData' => 'loadMaterialData',
|
||||
'openCapacitorModal' => 'showCapacitorInputBox',
|
||||
];
|
||||
|
||||
public $capacitorInput = '';
|
||||
|
||||
public $panel_box_supplier;
|
||||
|
||||
public $panel_box_item_code;
|
||||
|
||||
public $panel_box_serial_number;
|
||||
|
||||
public string $currentItemCode = '';
|
||||
|
||||
public string $currentSerialNumber = '';
|
||||
|
||||
public function loadCompletedData($invoiceNumber, $plantId, $isSerial)
|
||||
{
|
||||
$this->plantId = $plantId;
|
||||
$this->invoiceNumber = $invoiceNumber;
|
||||
$this->completedInvoice = true;
|
||||
$this->isSerial = $isSerial;
|
||||
$this->onCapFocus = false;
|
||||
$this->emptyInvoice = false;
|
||||
$this->hasSearched = false;
|
||||
$this->materialInvoice = false;
|
||||
$this->packageCount = 0;
|
||||
// $this->showCapacitorInput = false;
|
||||
$this->dispatch('focus-invoice-number');
|
||||
}
|
||||
|
||||
public function loadEmptyData($invoiceNumber, $plantId)
|
||||
{
|
||||
$this->plantId = $plantId;
|
||||
$this->invoiceNumber = $invoiceNumber;
|
||||
$this->completedInvoice = false;
|
||||
$this->onCapFocus = false;
|
||||
$this->emptyInvoice = true;
|
||||
$this->hasSearched = false;
|
||||
$this->materialInvoice = false;
|
||||
$this->packageCount = 0;
|
||||
// $this->showCapacitorInput = false;
|
||||
}
|
||||
|
||||
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 loadMaterialData($invoiceNumber, $plantId)
|
||||
{
|
||||
$this->plantId = $plantId;
|
||||
$this->invoiceNumber = $invoiceNumber;
|
||||
$this->completedInvoice = false;
|
||||
$this->isSerial = false;
|
||||
$this->onCapFocus = false;
|
||||
$this->emptyInvoice = false;
|
||||
$this->hasSearched = false;
|
||||
$this->materialInvoice = true;
|
||||
// $this->showCapacitorInput = false;
|
||||
|
||||
// ->where('serial_number', '!=', '')
|
||||
$this->invoiceData = InvoiceValidation::where('invoice_number', $this->invoiceNumber)->where('plant_id', $plantId)->where('serial_number', null)
|
||||
->get()
|
||||
->map(function ($record) {
|
||||
return [
|
||||
'sticker_master_id' => $record->sticker_master_id,
|
||||
// 'material_type' => StickerMaster::where('id', $record->sticker_master_id)->first()->material_type ?? '',
|
||||
'quantity' => $record->quantity ?? '',
|
||||
'serial_number' => $record->serial_number ?? '',
|
||||
'batch_number' => $record->batch_number ?? '',
|
||||
'created_at' => $record->created_at,
|
||||
'operator_id' => $record->operator_id,
|
||||
];
|
||||
})
|
||||
->toArray();
|
||||
|
||||
// Loop through and replace 'code' using related StickerMaster > Item > code
|
||||
foreach ($this->invoiceData as &$row) {
|
||||
// $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';
|
||||
$matType = StickerMaster::where('id', $row['sticker_master_id'] ?? null)->first()->material_type ?? '';
|
||||
if ($matType === 1) {
|
||||
$row['material_type'] = 'Individual';
|
||||
} elseif ($matType === 2) {
|
||||
$row['material_type'] = 'Bundle';
|
||||
} elseif ($matType === 3) {
|
||||
$row['material_type'] = 'Quantity';
|
||||
} else {
|
||||
$row['material_type'] = 'N/A';
|
||||
}
|
||||
}
|
||||
$this->dispatch('focus-serial-number');
|
||||
}
|
||||
|
||||
public function showCapacitorInputBox($itemCode, $serialNumber, $plantId)
|
||||
{
|
||||
$this->plantId = $plantId;
|
||||
$this->currentItemCode = $itemCode;
|
||||
$this->currentSerialNumber = $serialNumber;
|
||||
$this->showCapacitorInput = true;
|
||||
// $this->capacitorInput = '';
|
||||
$this->completedInvoice = false;
|
||||
$this->isSerial = true;
|
||||
$this->onCapFocus = false;
|
||||
$this->emptyInvoice = false;
|
||||
$this->hasSearched = false;
|
||||
$this->materialInvoice = false;
|
||||
$this->dispatch('focus-capacitor-input');
|
||||
}
|
||||
|
||||
public function cancelCapacitorInput()
|
||||
{
|
||||
$this->showCapacitorInput = false;
|
||||
$this->dispatch('focus-serial-number');
|
||||
}
|
||||
|
||||
public function processCapacitorInput()
|
||||
{
|
||||
$user = Filament::auth()->user();
|
||||
$operatorName = $user->name;
|
||||
|
||||
if (! $this->capacitorInput) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (! preg_match('/^[^\/]+\/[^\/]+\/.+$/', $this->capacitorInput)) {
|
||||
Notification::make()
|
||||
->title('Invalid Panel Box QR Format:')
|
||||
->body('Scan the valid panel box QR code to proceed!')
|
||||
->danger()
|
||||
// ->duration(3000)
|
||||
->seconds(2)
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$parts = explode('/', $this->capacitorInput);
|
||||
$supplier = $parts[0];
|
||||
$itemCode = $parts[1];
|
||||
$serialNumber = implode('/', array_slice($parts, 2)); // Keep rest of the string
|
||||
|
||||
$existsInStickerMaster = StickerMaster::where('panel_box_code', $itemCode)->where('plant_id', $this->plantId)->whereHas('item', function ($query) {
|
||||
$query->where('code', $this->currentItemCode);
|
||||
})
|
||||
->exists();
|
||||
|
||||
if (! $existsInStickerMaster) {
|
||||
Notification::make()
|
||||
->title('Unknown: Panel Box Code')
|
||||
->body("Unknown panel box code: $itemCode found for item code: $this->currentItemCode")
|
||||
->danger()
|
||||
// ->duration(4000)
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->capacitorInput = '';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($this->invoiceData as &$row) {
|
||||
if (($row['code'] ?? '') === $this->currentItemCode && ($row['serial_number'] ?? '') === $this->currentSerialNumber) {
|
||||
$row['panel_box_supplier'] = $supplier;
|
||||
$row['panel_box_item_code'] = $itemCode;
|
||||
$row['panel_box_serial_number'] = $serialNumber;
|
||||
$row['capacitor_scanned_status'] = 1;
|
||||
// $row['scanned_status_set'] = true;
|
||||
|
||||
$matchingValidation = InvoiceValidation::with('stickerMaster.item')
|
||||
->where('serial_number', $this->currentSerialNumber)
|
||||
->where('plant_id', $this->plantId)
|
||||
->get()
|
||||
->first(function ($validation) {
|
||||
return $validation->stickerMaster?->item?->code === $this->currentItemCode;
|
||||
});
|
||||
|
||||
if ($matchingValidation) {
|
||||
$hasMotorQr = $matchingValidation->stickerMasterRelation->tube_sticker_motor ?? null;
|
||||
$hasPumpQr = $matchingValidation->stickerMasterRelation->tube_sticker_pump ?? null;
|
||||
$hasPumpSetQr = $matchingValidation->stickerMasterRelation->tube_sticker_pumpset ?? null;
|
||||
// $hasCapacitorQr = $matchingValidation->stickerMasterRelation->panel_box_code ?? null;
|
||||
|
||||
$hadMotorQr = $matchingValidation->motor_scanned_status ?? null;
|
||||
$hadPumpQr = $matchingValidation->pump_scanned_status ?? null;
|
||||
$hadPumpSetQr = $matchingValidation->scanned_status_set ?? null;
|
||||
// $hadCapacitorQr = $matchingValidation->capacitor_scanned_status ?? null;
|
||||
|
||||
$packCnt = 1;
|
||||
$scanCnt = 1;
|
||||
// if ($hadMotorQr === $hasMotorQr && $hadPumpQr === $hasPumpQr && $hadPumpSetQr === $hasPumpSetQr)
|
||||
if ($hasMotorQr || $hasPumpQr || $hasPumpSetQr) {
|
||||
$packCnt = $hasMotorQr ? $packCnt + 1 : $packCnt;
|
||||
$packCnt = $hasPumpQr ? $packCnt + 1 : $packCnt;
|
||||
$packCnt = $hasPumpSetQr ? $packCnt + 1 : $packCnt;
|
||||
|
||||
$scanCnt = $hadMotorQr ? $scanCnt + 1 : $scanCnt;
|
||||
$scanCnt = $hadPumpQr ? $scanCnt + 1 : $scanCnt;
|
||||
$scanCnt = $hadPumpSetQr ? $scanCnt + 1 : $scanCnt;
|
||||
|
||||
if ($packCnt === $scanCnt) {
|
||||
$matchingValidation->update([
|
||||
'panel_box_supplier' => $supplier,
|
||||
'panel_box_item_code' => $itemCode,
|
||||
'panel_box_serial_number' => $serialNumber,
|
||||
'capacitor_scanned_status' => 1,
|
||||
'scanned_status' => 'Scanned',
|
||||
'operator_id' => $operatorName,
|
||||
]);
|
||||
} else {
|
||||
$matchingValidation->update([
|
||||
'panel_box_supplier' => $supplier,
|
||||
'panel_box_item_code' => $itemCode,
|
||||
'panel_box_serial_number' => $serialNumber,
|
||||
'capacitor_scanned_status' => 1,
|
||||
'operator_id' => $operatorName,
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
$matchingValidation->update([
|
||||
'panel_box_supplier' => $supplier,
|
||||
'panel_box_item_code' => $itemCode,
|
||||
'panel_box_serial_number' => $serialNumber,
|
||||
'capacitor_scanned_status' => 1,
|
||||
'scanned_status' => 'Scanned',
|
||||
'operator_id' => $operatorName,
|
||||
]);
|
||||
}
|
||||
|
||||
// Notification::make()
|
||||
// ->title('Success: Capacitor QR')
|
||||
// // ->title("Panel box code scanned: $itemCode")
|
||||
// ->body("'Capacitor' QR scanned status updated, Scan next QR.")
|
||||
// ->success() // commented
|
||||
// ->seconds(2)
|
||||
// ->send();
|
||||
|
||||
$totalQuantity = InvoiceValidation::where('invoice_number', $matchingValidation->invoice_number)->where('plant_id', $this->plantId)->count();
|
||||
$scannedQuantity = InvoiceValidation::where('invoice_number', $matchingValidation->invoice_number)->where('plant_id', $this->plantId)->where('scanned_status', 'Scanned')->count();
|
||||
// $this->form->fill([
|
||||
// 'plant_id' => $matchingValidation->plant_id,
|
||||
// 'invoice_number' => $matchingValidation->invoice_number,
|
||||
// 'serial_number' => null,
|
||||
// 'total_quantity' => $totalQuantity,
|
||||
// 'scanned_quantity'=> $scannedQuantity,
|
||||
// ]);
|
||||
|
||||
if ($totalQuantity === $scannedQuantity) {
|
||||
Notification::make()
|
||||
->title('Completed: Serial Invoice')
|
||||
->body("Serial invoice '$matchingValidation->invoice_number' completed the scanning process.<br>Scan the next 'Serial Invoice' to proceed!")
|
||||
->success()
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->loadCompletedData($matchingValidation->invoice_number, $matchingValidation->plant_id, true);
|
||||
} else {
|
||||
$this->loadData($matchingValidation->invoice_number, $matchingValidation->plant_id, false);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$this->showCapacitorInput = false;
|
||||
$this->capacitorInput = '';
|
||||
$this->dispatch('updateScannedQuantity');
|
||||
// $this->loadData($this->invoiceNumber, $this->plantId);
|
||||
$this->dispatch('focus-serial-number');
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.invoice-data-table');
|
||||
}
|
||||
}
|
||||
313
app/Livewire/InvoiceFinderDataTable.php
Normal file
313
app/Livewire/InvoiceFinderDataTable.php
Normal file
@@ -0,0 +1,313 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Models\LocatorInvoiceValidation;
|
||||
use App\Models\PalletValidation;
|
||||
use Livewire\Component;
|
||||
use Notification;
|
||||
|
||||
class InvoiceFinderDataTable extends Component
|
||||
{
|
||||
|
||||
public $plantId;
|
||||
|
||||
public $invoiceNumber;
|
||||
|
||||
public $records = [];
|
||||
|
||||
protected $listeners = [
|
||||
'loadData' => 'loadlocatorInvoiceData',
|
||||
];
|
||||
|
||||
|
||||
public function loadlocatorInvoiceData($invoiceNumber, $notFoundSerials, $incompleteSerials, $scannedSerials, $foundSerials, $plantId)
|
||||
{
|
||||
$this->records = [];
|
||||
|
||||
if(count($notFoundSerials) > 0)
|
||||
{
|
||||
foreach($notFoundSerials as $serial)
|
||||
{
|
||||
$record = LocatorInvoiceValidation::where('serial_number', $serial)
|
||||
->where('plant_id', $plantId)
|
||||
->first();
|
||||
|
||||
$this->records[] = [
|
||||
'created_at' => $record->created_at,
|
||||
'created_by' => $record->created_by ?? '',
|
||||
'serial_number' => $record->serial_number,
|
||||
'pallet_number' => '',
|
||||
'locator_number' => '',
|
||||
'scanned_status' => 'Not Exist',
|
||||
'scanned_at' => '',
|
||||
'scanned_by' => ''
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if(count($incompleteSerials) > 0)
|
||||
{
|
||||
foreach($incompleteSerials as $serial)
|
||||
{
|
||||
$locatorRecord = LocatorInvoiceValidation::where('serial_number', $serial)
|
||||
->where('plant_id', $plantId)
|
||||
->first();
|
||||
|
||||
$palletRecord = palletValidation::where('serial_number', $serial)
|
||||
->where('plant_id', $plantId)
|
||||
->first();
|
||||
|
||||
$this->records[] = [
|
||||
'created_at' => $locatorRecord->created_at,
|
||||
'created_by' => $locatorRecord->created_by,
|
||||
'serial_number' => $locatorRecord->serial_number,
|
||||
'pallet_number' => $palletRecord->pallet_number,
|
||||
'locator_number' => $palletRecord->locator_number,
|
||||
'scanned_status' => 'Incompleted',
|
||||
'scanned_at' => '',
|
||||
'scanned_by' => ''
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if(count($foundSerials) > 1)
|
||||
{
|
||||
$foundPno = [];
|
||||
$foundLno = [];
|
||||
$foundSno = [];
|
||||
$palletNo = '';
|
||||
$locatorNo = '';
|
||||
$palletSno = [];
|
||||
$locatorSno = [];
|
||||
foreach($foundSerials as $serial)
|
||||
{
|
||||
foreach($foundSerials as $sNo)
|
||||
{
|
||||
if (in_array($sNo, $foundSno))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$palletRecord = palletValidation::where('serial_number', $sNo)
|
||||
->where('plant_id', $plantId)
|
||||
->where('pallet_number', '!=','')
|
||||
->where('pallet_number', '!=',null)
|
||||
// ->whereNotNull('pallet_number')
|
||||
->first();
|
||||
|
||||
if(!$palletRecord || ($palletNo && count($foundPno) > 0 && !in_array($palletRecord->pallet_number, $foundPno)))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
$palletNo = $palletRecord->pallet_number;
|
||||
$locatorNo = $palletRecord->locator_number;
|
||||
$foundSno[] = $sNo;
|
||||
$foundPno[] = $palletRecord->pallet_number;
|
||||
$palletSno[] = $sNo;
|
||||
}
|
||||
}
|
||||
|
||||
if(count($palletSno) > 1)
|
||||
{
|
||||
$locatorRecord = null;
|
||||
|
||||
foreach($palletSno as $mulSNo)
|
||||
{
|
||||
$locatorRecord = LocatorInvoiceValidation::where('serial_number', $mulSNo)
|
||||
->where('plant_id', $plantId)
|
||||
->first();
|
||||
|
||||
}
|
||||
|
||||
$this->records[] = [
|
||||
'created_at' => $locatorRecord->created_at,
|
||||
'created_by' => $locatorRecord->created_by,
|
||||
'serial_number' => count($palletSno),
|
||||
'pallet_number' => $palletNo,
|
||||
'locator_number' => $locatorNo,
|
||||
'scanned_status' => '',
|
||||
'scanned_at' => '',
|
||||
'scanned_by' => ''
|
||||
];
|
||||
|
||||
$palletNo = '';
|
||||
$locatorNo = '';
|
||||
$palletSno = [];
|
||||
}
|
||||
else if(count($palletSno) == 1)
|
||||
{
|
||||
foreach($palletSno as $singleSNo)
|
||||
{
|
||||
$palletRecord = palletValidation::where('serial_number', $singleSNo)
|
||||
->where('plant_id', $plantId)
|
||||
->where('pallet_number', '!=','')
|
||||
->whereNotNull('pallet_number')
|
||||
->first();
|
||||
|
||||
$locatorRecord = LocatorInvoiceValidation::where('serial_number', $singleSNo)
|
||||
->where('plant_id', $plantId)
|
||||
->first();
|
||||
$this->records[] = [
|
||||
'created_at' => $locatorRecord->created_at,
|
||||
'created_by' => $locatorRecord->created_by,
|
||||
'serial_number' => $locatorRecord->serial_number,
|
||||
'pallet_number' => $palletRecord->pallet_number,
|
||||
'locator_number' => $palletRecord->locator_number,
|
||||
'scanned_status' => '',
|
||||
'scanned_at' => '',
|
||||
'scanned_by' => ''
|
||||
];
|
||||
}
|
||||
$palletNo = '';
|
||||
$locatorNo = '';
|
||||
$palletSno = [];
|
||||
}
|
||||
|
||||
if (in_array($serial, $foundSno))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$int = 0;
|
||||
foreach($foundSerials as $locSNo)
|
||||
{
|
||||
if (in_array($locSNo, $foundSno))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$int++;
|
||||
$locatorRecord = null;
|
||||
$locatorRecord = palletValidation::where('serial_number', $locSNo)
|
||||
->where('plant_id', $plantId)
|
||||
->where('locator_number', '!=','')
|
||||
->where('locator_number', '!=',null)
|
||||
->first();
|
||||
|
||||
if(!$locatorRecord || ($locatorNo && count($foundLno) > 0 && !in_array($locatorRecord->locator_number, $foundLno)))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
$palletNo = $locatorRecord->pallet_number;
|
||||
$locatorNo = $locatorRecord->locator_number;
|
||||
$foundSno[] = $locSNo;
|
||||
$foundLno[] = $locatorRecord->locator_number;
|
||||
$locatorSno[] = $locSNo;
|
||||
}
|
||||
}
|
||||
|
||||
if(count($locatorSno) > 1)
|
||||
{
|
||||
$locatorRecord = null;
|
||||
|
||||
foreach($locatorSno as $mulSNo)
|
||||
{
|
||||
$locatorRecord = LocatorInvoiceValidation::where('serial_number', $mulSNo)
|
||||
->where('plant_id', $plantId)
|
||||
->first();
|
||||
}
|
||||
|
||||
$this->records[] = [
|
||||
'created_at' => $locatorRecord->created_at,
|
||||
'created_by' => $locatorRecord->created_by,
|
||||
'serial_number' => count($locatorSno),
|
||||
'pallet_number' => $palletNo,
|
||||
'locator_number' => $locatorNo,
|
||||
'scanned_status' => '',
|
||||
'scanned_at' => '',
|
||||
'scanned_by' => ''
|
||||
];
|
||||
|
||||
$palletNo = '';
|
||||
$locatorNo = '';
|
||||
$locatorSno = [];
|
||||
}
|
||||
else if(count($locatorSno) == 1)
|
||||
{
|
||||
foreach($locatorSno as $singleSNo)
|
||||
{
|
||||
$palletRecord = palletValidation::where('serial_number', $singleSNo)
|
||||
->where('plant_id', $plantId)
|
||||
->where('locator_number', '!=','')
|
||||
->where('locator_number', '!=',null)
|
||||
->first();
|
||||
|
||||
$locatorRecord = LocatorInvoiceValidation::where('serial_number', $singleSNo)
|
||||
->where('plant_id', $plantId)
|
||||
->first();
|
||||
$this->records[] = [
|
||||
'created_at' => $locatorRecord->created_at,
|
||||
'created_by' => $locatorRecord->created_by,
|
||||
'serial_number' => $locatorRecord->serial_number,
|
||||
'pallet_number' => $palletRecord->pallet_number,
|
||||
'locator_number' => $palletRecord->locator_number,
|
||||
'scanned_status' => '',
|
||||
'scanned_at' => '',
|
||||
'scanned_by' => ''
|
||||
];
|
||||
}
|
||||
$palletNo = '';
|
||||
$locatorNo = '';
|
||||
$locatorSno = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(count($foundSerials) == 1)
|
||||
{
|
||||
|
||||
foreach($foundSerials as $serial)
|
||||
{
|
||||
|
||||
$locatorRecord = LocatorInvoiceValidation::where('serial_number', $serial)
|
||||
->where('plant_id', $plantId)
|
||||
->first();
|
||||
|
||||
$palletRecord = palletValidation::where('serial_number', $serial)
|
||||
->where('plant_id', $plantId)
|
||||
->first();
|
||||
|
||||
$this->records[] = [
|
||||
'created_at' => $locatorRecord->created_at,
|
||||
'created_by' => $locatorRecord->created_by,
|
||||
'serial_number' => $locatorRecord->serial_number,
|
||||
'pallet_number' => $palletRecord->pallet_number,
|
||||
'locator_number' => $palletRecord->locator_number,
|
||||
'scanned_status' => '',
|
||||
'scanned_at' => '',
|
||||
'scanned_by' => ''
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if(count($scannedSerials) > 0)
|
||||
{
|
||||
foreach($scannedSerials as $serial)
|
||||
{
|
||||
$locatorRecord = LocatorInvoiceValidation::where('serial_number', $serial)
|
||||
->where('plant_id', $plantId)
|
||||
->first();
|
||||
|
||||
$this->records[] = [
|
||||
'created_at' => $locatorRecord->created_at,
|
||||
'created_by' => $locatorRecord->created_by,
|
||||
'serial_number' => $locatorRecord->serial_number,
|
||||
'pallet_number' => $locatorRecord->pallet_number,
|
||||
'locator_number' => $locatorRecord->locator_number,
|
||||
'scanned_status' => $locatorRecord->scanned_status,
|
||||
'scanned_at' => $locatorRecord->scanned_at,
|
||||
'scanned_by' => $locatorRecord->scanned_by
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.invoice-finder-data-table');
|
||||
}
|
||||
}
|
||||
82
app/Livewire/InvoiceReworkDataTable.php
Normal file
82
app/Livewire/InvoiceReworkDataTable.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Models\LocatorInvoiceValidation;
|
||||
use App\Models\PalletValidation;
|
||||
use Livewire\Component;
|
||||
|
||||
class InvoiceReworkDataTable extends Component
|
||||
{
|
||||
public $plantId;
|
||||
|
||||
public $invoiceNumber;
|
||||
|
||||
public $palletNumber;
|
||||
|
||||
public $reworkTyp;
|
||||
|
||||
public bool $isOpen = false;
|
||||
|
||||
public $records = [];
|
||||
|
||||
public $showConfirmationModal = false;
|
||||
|
||||
public $invoiceNo;
|
||||
|
||||
protected $listeners =
|
||||
[
|
||||
'loadData' => 'loadlocatorInvoiceData',
|
||||
];
|
||||
|
||||
public function loadlocatorInvoiceData($invoiceNumber, $palletNumber, $plantId, $reworkType)
|
||||
{
|
||||
$this->invoiceNumber = $invoiceNumber;
|
||||
$this->palletNumber = $palletNumber;
|
||||
$this->plantId = $plantId;
|
||||
$this->reworkTyp = $reworkType;
|
||||
|
||||
if ($reworkType == 'invoice')
|
||||
{
|
||||
$this->records = LocatorInvoiceValidation::query()->where('plant_id', $plantId)->where('invoice_number', $invoiceNumber)->orderBy('created_at', 'asc')->get()// ->orderByDesc('created_at')
|
||||
->map(function ($record) {
|
||||
return [
|
||||
'created_at' => $record->created_at ?? '',
|
||||
'created_by' => $record->created_by ?? '',
|
||||
'serial_number' => $record->serial_number ?? '',
|
||||
'pallet_number' => $record->pallet_number ?? '',
|
||||
'locator_number' => $record->locator_number ?? '',
|
||||
'scanned_status' => $record->scanned_status ?? '',
|
||||
'scanned_at' => $record->scanned_at ?? '',
|
||||
'scanned_by' => $record->scanned_by ?? '',
|
||||
];
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
else if ($reworkType == 'pallet')
|
||||
{
|
||||
$this->records = PalletValidation::query()->where('plant_id', $plantId)->where('pallet_number', $palletNumber)->orderBy('scanned_at', 'asc')->get()
|
||||
->map(function ($record) {
|
||||
return [
|
||||
'created_at' => $record->created_at ?? '',
|
||||
'created_by' => $record->created_by ?? '',
|
||||
'serial_number' => $record->serial_number ?? '',
|
||||
// 'pallet_number' => $record->pallet_number,
|
||||
// 'locator_number' => $record->locator_number,
|
||||
// 'scanned_status' => $record->scanned_status,
|
||||
'scanned_at' => $record->scanned_at ?? '',
|
||||
'scanned_by' => $record->scanned_by ?? '',
|
||||
];
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->records = [];
|
||||
}
|
||||
}
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.invoice-rework-data-table');
|
||||
}
|
||||
}
|
||||
132
app/Livewire/LocatorDataTable.php
Normal file
132
app/Livewire/LocatorDataTable.php
Normal file
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Models\PalletValidation;
|
||||
use Livewire\Component;
|
||||
|
||||
class LocatorDataTable extends Component
|
||||
{
|
||||
public $plantId;
|
||||
|
||||
public $palletNumber, $serialNumber;
|
||||
|
||||
public $locatorNumber;
|
||||
|
||||
public $locators = [];
|
||||
|
||||
public $locators1 = [];
|
||||
|
||||
public $serials = [];
|
||||
|
||||
protected $listeners = [
|
||||
'loadData' => 'loadPalletData',
|
||||
'loadLocator' => 'loadLocatorData',
|
||||
'loadserialNo' => 'loadserialNodata',
|
||||
];
|
||||
|
||||
public function loadserialNodata($serialNo, $plantId)
|
||||
{
|
||||
$this->plantId = $plantId;
|
||||
$this->serialNumber = $serialNo;
|
||||
$this->locators = [];
|
||||
|
||||
$record = PalletValidation::where('plant_id', $plantId)
|
||||
->where('serial_number', $serialNo)
|
||||
->whereNotNull('locator_number')
|
||||
->where('locator_number', '!=', '')
|
||||
->first();
|
||||
|
||||
if (!$record)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$locatorNumber = $record->locator_number;
|
||||
|
||||
$this->locators = PalletValidation::where('plant_id', $plantId)
|
||||
->where('locator_number', $locatorNumber)
|
||||
->whereNotNull('locator_number')
|
||||
->where('locator_number', '!=', '')
|
||||
->get()
|
||||
->map(function ($record) {
|
||||
return [
|
||||
'created_at' => $record->created_at ?? '',
|
||||
'created_by' => $record->created_by ?? '',
|
||||
'pallet_number' => $record->pallet_number ?? '',
|
||||
'serial_number' => $record->serial_number ?? '',
|
||||
'locator_number' => $record->locator_number ?? '',
|
||||
'locator_quantity' => $record->locator_quantity ?? '',
|
||||
'updated_at' => $record->updated_at ?? '',
|
||||
'updated_by' => $record->updated_by ?? '',
|
||||
];
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
public function loadPalletData($palletNumber,$locatorNumber,$plantId)
|
||||
{
|
||||
$this->plantId = $plantId;
|
||||
$this->palletNumber = $palletNumber;
|
||||
$this->locators = [];
|
||||
|
||||
$this->locators = PalletValidation::query()
|
||||
->where('plant_id', $plantId)
|
||||
->where(function ($query) use ($palletNumber, $locatorNumber) {
|
||||
$query->where(function ($q) use ($palletNumber) {
|
||||
$q->where('pallet_number', $palletNumber)
|
||||
->whereNotNull('locator_number')
|
||||
->where('locator_number', '!=', '');
|
||||
})
|
||||
->orWhere(function ($q) use ($locatorNumber) {
|
||||
$q->where('locator_number', $locatorNumber)
|
||||
->whereNotNull('locator_number')
|
||||
->where('locator_number', '!=', '');
|
||||
});
|
||||
})
|
||||
->get()
|
||||
->map(function ($record) {
|
||||
return [
|
||||
'created_at' => $record->created_at ?? '',
|
||||
'created_by' => $record->created_by ?? '',
|
||||
'pallet_number' => $record->pallet_number ?? '',
|
||||
'serial_number' => $record->serial_number ?? '',
|
||||
'locator_number' => $record->locator_number ?? '',
|
||||
'locator_quantity' => $record->locator_quantity ?? '',
|
||||
'updated_at' => $record->updated_at ?? '',
|
||||
'updated_by' => $record->updated_by ?? '',
|
||||
];
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
public function loadLocatorData($scanLocator, $plantId)
|
||||
{
|
||||
$this->plantId = $plantId;
|
||||
$this->locatorNumber = $scanLocator;
|
||||
$this->locators = [];
|
||||
|
||||
$this->locators = PalletValidation::query()
|
||||
->where('plant_id', $plantId)
|
||||
->where('locator_number', $scanLocator)
|
||||
->get()
|
||||
->map(function ($record) {
|
||||
return [
|
||||
'created_at' => $record->created_at ?? '',
|
||||
'created_by' => $record->created_by ?? '',
|
||||
'pallet_number' => $record->pallet_number ?? '',
|
||||
'serial_number' => $record->serial_number ?? '',
|
||||
'locator_number' => $record->locator_number ?? '',
|
||||
'locator_quantity' => $record->locator_quantity ?? '',
|
||||
'updated_at' => $record->updated_at ?? '',
|
||||
'updated_by' => $record->updated_by ?? '',
|
||||
];
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.locator-data-table');
|
||||
}
|
||||
}
|
||||
56
app/Livewire/LocatorInvoiceDataTable.php
Normal file
56
app/Livewire/LocatorInvoiceDataTable.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Models\LocatorInvoiceValidation;
|
||||
use Livewire\Component;
|
||||
|
||||
class LocatorInvoiceDataTable extends Component
|
||||
{
|
||||
public $plantId;
|
||||
|
||||
public $invoiceNumber;
|
||||
|
||||
public $records = [];
|
||||
public bool $showRemoveSerialsModal = false;
|
||||
|
||||
public $matchedSerialNumbersForRemoval;
|
||||
|
||||
protected $listeners = [
|
||||
'loadData' => 'loadlocatorInvoiceData',
|
||||
];
|
||||
|
||||
public function loadlocatorInvoiceData($invoiceNumber, $plantId)
|
||||
{
|
||||
$this->plantId = $plantId;
|
||||
$this->invoiceNumber = $invoiceNumber;
|
||||
|
||||
$this->records = LocatorInvoiceValidation::query()
|
||||
->where('plant_id', $plantId)
|
||||
->where('invoice_number', $invoiceNumber)
|
||||
->where(function ($query) {
|
||||
$query->where('scanned_status', '=', '')
|
||||
->orWhereNull('scanned_status');
|
||||
})
|
||||
->orderBy('created_at', 'asc')
|
||||
// ->orderByDesc('created_at')
|
||||
->get()
|
||||
->map(function ($record) {
|
||||
return [
|
||||
'created_at' => $record->created_at,
|
||||
'created_by' => $record->created_by ?? '',
|
||||
'serial_number' => $record->serial_number,
|
||||
'pallet_number' => $record->pallet_number,
|
||||
'locator_number' => $record->locator_number,
|
||||
'scanned_status' => $record->scanned_status,
|
||||
'scanned_at' => $record->scanned_at,
|
||||
'scanned_by' => $record->scanned_by ?? '',
|
||||
];
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.locator-invoice-data-table');
|
||||
}
|
||||
}
|
||||
34
app/Livewire/NotificationSound.php
Normal file
34
app/Livewire/NotificationSound.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use Livewire\Component;
|
||||
use Livewire\Attributes\On;
|
||||
|
||||
|
||||
class NotificationSound extends Component
|
||||
{
|
||||
|
||||
protected $listeners = ['playNotificationSound' => 'playSound', 'playWarnSound' => 'playWarnSound', 'beepSound' => 'beepSound'];
|
||||
|
||||
public function playSound()
|
||||
{
|
||||
$this->dispatch('play-notification-sound');
|
||||
}
|
||||
|
||||
public function playWarnSound()
|
||||
{
|
||||
//dd('test');
|
||||
$this->dispatch('play-warn-sound');
|
||||
}
|
||||
public function beepSound()
|
||||
{
|
||||
//dd('test');
|
||||
$this->dispatch('play-beep-sound');
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.notification-sound');
|
||||
}
|
||||
}
|
||||
120
app/Livewire/PalletDataTable.php
Normal file
120
app/Livewire/PalletDataTable.php
Normal file
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Models\PalletValidation;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Notifications\Notification;
|
||||
use Livewire\Component;
|
||||
|
||||
|
||||
class PalletDataTable extends Component
|
||||
{
|
||||
public $plantId;
|
||||
|
||||
public $palletNumber;
|
||||
|
||||
public $snoCount = 0;
|
||||
|
||||
public $records = [];
|
||||
|
||||
protected $listeners = [
|
||||
//'removeSno' => 'requestRemoveSerialNumber',
|
||||
'loadData' => 'loadPalletData',
|
||||
];
|
||||
|
||||
|
||||
|
||||
public function loadPalletData($palletNumber, $plantId)
|
||||
{
|
||||
$this->plantId = $plantId;
|
||||
$this->palletNumber = $palletNumber;
|
||||
$this->records = [];
|
||||
|
||||
$this->records = PalletValidation::query()
|
||||
->where('plant_id', $this->plantId)
|
||||
->where('pallet_number', $this->palletNumber)
|
||||
->orderBy('scanned_at')
|
||||
->get()
|
||||
->map(function ($record) {
|
||||
return [
|
||||
'created_at' => $record->created_at,
|
||||
'created_by' => $record->created_by ?? '',
|
||||
'pallet_number' => $record->pallet_number,
|
||||
'serial_number' => $record->serial_number,
|
||||
'scanned_at' => $record->scanned_at,
|
||||
'scanned_by' => $record->scanned_by ?? '',
|
||||
];
|
||||
})
|
||||
->toArray();
|
||||
|
||||
}
|
||||
|
||||
|
||||
// public function requestRemoveSerialNumber($serialNumber, $palletNumber,$plantId)
|
||||
// {
|
||||
|
||||
// $user = Filament::auth()->user();
|
||||
|
||||
// $operatorName = $user->name;
|
||||
|
||||
// $found = collect($this->records)->contains(function ($record) use ($serialNumber) {
|
||||
// return $record['serial_number'] == $serialNumber;
|
||||
// });
|
||||
|
||||
// if (!$found) {
|
||||
// Notification::make()
|
||||
// ->title('Serial number not found in the pallet data table. Cannot delete.')
|
||||
// ->danger()
|
||||
// ->send();
|
||||
// return;
|
||||
// }
|
||||
|
||||
// // Proceed to delete from the database
|
||||
// $deleted = PalletValidation::where('plant_id', $plantId)
|
||||
// ->where('pallet_number', $palletNumber)
|
||||
// ->where('serial_number', $serialNumber)
|
||||
// ->forceDelete();
|
||||
|
||||
// if ($deleted)
|
||||
// {
|
||||
// Notification::make()
|
||||
// ->title('Serial number deleted successfully.')
|
||||
// ->success()
|
||||
// ->send();
|
||||
|
||||
// $this->form->fill([
|
||||
// 'plant_id' => $this->plantId,
|
||||
// 'pallet_number' => $palletNumber,
|
||||
// 'removeSno_number' => null,
|
||||
// 'pending_pallet_list' => $this->pendingPallet,
|
||||
// 'Sno_quantity' => $this->snoCount,
|
||||
// 'created_by' => $operatorName,
|
||||
// 'scanned_by' => $operatorName,
|
||||
// ]);
|
||||
|
||||
// $this->snoCount = PalletValidation::where('plant_id', $plantId)
|
||||
// ->where('pallet_number', $palletNumber)
|
||||
// ->count();
|
||||
|
||||
// $this->dispatch('updateSnoQuantity', $this->snoCount);
|
||||
|
||||
// //reload the data table
|
||||
// $this->loadPalletData($this->palletNumber, $this->plantId);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Notification::make()
|
||||
// ->title('Failed to delete serial number.')
|
||||
// ->danger()
|
||||
// ->send();
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.pallet-data-table');
|
||||
}
|
||||
}
|
||||
86
app/Livewire/PalletFromLocatorDataTable.php
Normal file
86
app/Livewire/PalletFromLocatorDataTable.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Models\PalletValidation;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Notifications\Notification;
|
||||
use Livewire\Component;
|
||||
|
||||
|
||||
class PalletFromLocatorDataTable extends Component
|
||||
{
|
||||
public $plantId;
|
||||
|
||||
public $locatorNo, $palletNumber, $newpallet;
|
||||
|
||||
public $showSessionRecords = false;
|
||||
|
||||
public $showRemovedRecords = false;
|
||||
|
||||
public $records = [];
|
||||
|
||||
public $scannedRecords = [];
|
||||
public $removeRecords = [];
|
||||
|
||||
public $latestPalletDateTime = null;
|
||||
public $createdBy;
|
||||
|
||||
protected $listeners = [
|
||||
'loadData' => 'loadlocatorData',
|
||||
'open-confirm-modal' => 'openConfirmModal',
|
||||
];
|
||||
|
||||
// public function generatePallet($plantId)
|
||||
// {
|
||||
// $year = now()->format('y');
|
||||
// $month = now()->format('m');
|
||||
// $prefix = "EP-{$year}{$month}";
|
||||
|
||||
// $lastPallet = PalletValidation::where('pallet_number', 'like', "{$prefix}%")
|
||||
// ->where('plant_id', $plantId)
|
||||
// ->orderByDesc('pallet_number')
|
||||
// ->first();
|
||||
|
||||
// $newNumber = $lastPallet
|
||||
// ? str_pad(intval(substr($lastPallet->pallet_number, -3)) + 1, 3, '0', STR_PAD_LEFT)
|
||||
// : '001';
|
||||
|
||||
// $newPalletNumber = "{$prefix}{$newNumber}";
|
||||
|
||||
|
||||
// session(['latestPalletNumber' => $newPalletNumber]);
|
||||
|
||||
// $url = route('download-qr-pdf', ['palletNo' => $newPalletNumber]);
|
||||
// $this->js(<<<JS
|
||||
// window.dispatchEvent(new CustomEvent('open-pdf', {
|
||||
// detail: {
|
||||
// url: "{$url}"
|
||||
// }
|
||||
// }));
|
||||
// JS);
|
||||
// }
|
||||
|
||||
public function openConfirmModal($locatorNo, $plantId)
|
||||
{
|
||||
$this->locatorNo = $locatorNo;
|
||||
$this->plantId = $plantId;
|
||||
$this->dispatch('open-modal', id: 'confirm-process-modal');
|
||||
}
|
||||
|
||||
public function loadlocatorData($records, $plantId)
|
||||
{
|
||||
$this->plantId = $plantId;
|
||||
$this->records = $records;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.pallet-from-locator-data-table');
|
||||
}
|
||||
|
||||
// public function render()
|
||||
// {
|
||||
// return view('livewire.pallet-from-locator-data-table');
|
||||
// }
|
||||
}
|
||||
106
app/Livewire/ProductionSapData.php
Normal file
106
app/Livewire/ProductionSapData.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Models\ProductionQuantity;
|
||||
use App\Models\QualityValidation;
|
||||
use Livewire\Component;
|
||||
|
||||
class ProductionSapData extends Component
|
||||
{
|
||||
public $plantId;
|
||||
public $productionOrder;
|
||||
|
||||
|
||||
public $items = [];
|
||||
|
||||
public bool $attempted = false;
|
||||
|
||||
public bool $refresh = false;
|
||||
|
||||
public $scanned_quantity;
|
||||
|
||||
protected $listeners = [
|
||||
'loadItems',
|
||||
'refreshed',
|
||||
|
||||
];
|
||||
|
||||
public function refreshed($plantId, $productionOrder)
|
||||
{
|
||||
$this->plantId = $plantId;
|
||||
$this->productionOrder = $productionOrder;
|
||||
$this->refresh = true;
|
||||
$this->attempted = false;
|
||||
|
||||
if (!$plantId || !$productionOrder) {
|
||||
$this->items = [];
|
||||
return;
|
||||
}
|
||||
|
||||
$this->items = ProductionQuantity::where('plant_id', $plantId)
|
||||
->where('production_order', $productionOrder)
|
||||
->get()
|
||||
->map(function ($item) {
|
||||
return [
|
||||
'item_code' => optional($item->item)->code ?? 'N/A',
|
||||
'serial_number' => $item->serial_number,
|
||||
'created_at' => $item->created_at->format('Y-m-d H:i:s'),
|
||||
'sap_status' => $item->sap_msg_status,
|
||||
'sap_description' => $item->sap_msg_description,
|
||||
];
|
||||
})
|
||||
->toArray();
|
||||
|
||||
$this->updateRowCount();
|
||||
}
|
||||
|
||||
public function loadItems($plantId, $productionOrder)
|
||||
{
|
||||
$this->plantId = $plantId;
|
||||
$this->productionOrder = $productionOrder;
|
||||
$this->attempted = true;
|
||||
$this->refresh = false;
|
||||
|
||||
|
||||
if (!$plantId || !$productionOrder) {
|
||||
$this->items = [];
|
||||
return;
|
||||
}
|
||||
|
||||
$this->items = ProductionQuantity::where('plant_id', $plantId)
|
||||
->where('production_order', $productionOrder)
|
||||
->get()
|
||||
->map(function ($item) {
|
||||
return [
|
||||
'item_code' => optional($item->item)->code ?? 'N/A',
|
||||
'serial_number' => $item->serial_number,
|
||||
'created_at' => $item->created_at->format('Y-m-d H:i:s'),
|
||||
'sap_status' => $item->sap_msg_status,
|
||||
'sap_description' => $item->sap_msg_description,
|
||||
];
|
||||
})
|
||||
->toArray();
|
||||
|
||||
$this->updateRowCount();
|
||||
}
|
||||
|
||||
// Method to update row count based on scanned_quantity
|
||||
public function updateRowCount()
|
||||
{
|
||||
$this->attempted = true;
|
||||
|
||||
// Ensure scanned_quantity is a valid number and doesn't exceed the available rows
|
||||
if ($this->scanned_quantity > 0 && $this->scanned_quantity <= count($this->items)) {
|
||||
$this->items = array_slice($this->items, 0, $this->scanned_quantity);
|
||||
} else {
|
||||
$this->scanned_quantity = count($this->items); // Reset to show all items if invalid quantity
|
||||
}
|
||||
|
||||
$this->dispatch('updateScannedQuantity', $this->scanned_quantity);
|
||||
}
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.production-sap-data');
|
||||
}
|
||||
}
|
||||
105
app/Livewire/SapData.php
Normal file
105
app/Livewire/SapData.php
Normal file
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Models\QualityValidation;
|
||||
use Livewire\Component;
|
||||
|
||||
class SapData extends Component
|
||||
{
|
||||
public $plantId;
|
||||
public $productionOrder;
|
||||
|
||||
|
||||
public $items = [];
|
||||
|
||||
public bool $attempted = false;
|
||||
|
||||
public bool $refresh = false;
|
||||
|
||||
public $scanned_quantity;
|
||||
|
||||
protected $listeners = [
|
||||
'loadItems',
|
||||
'refreshed',
|
||||
|
||||
];
|
||||
|
||||
public function refreshed($plantId, $productionOrder)
|
||||
{
|
||||
$this->plantId = $plantId;
|
||||
$this->productionOrder = $productionOrder;
|
||||
$this->refresh = true;
|
||||
$this->attempted = false;
|
||||
|
||||
if (!$plantId || !$productionOrder) {
|
||||
$this->items = [];
|
||||
return;
|
||||
}
|
||||
|
||||
$this->items = QualityValidation::where('plant_id', $plantId)
|
||||
->where('production_order', $productionOrder)
|
||||
->get()
|
||||
->map(function ($item) {
|
||||
return [
|
||||
'item_code' => optional($item->stickerMaster->item)->code ?? 'N/A',
|
||||
'serial_number' => $item->serial_number,
|
||||
'created_at' => $item->created_at->format('Y-m-d H:i:s'),
|
||||
'sap_status' => $item->sap_msg_status,
|
||||
'sap_description' => $item->sap_msg_description,
|
||||
];
|
||||
})
|
||||
->toArray();
|
||||
|
||||
$this->updateRowCount();
|
||||
}
|
||||
|
||||
public function loadItems($plantId, $productionOrder)
|
||||
{
|
||||
$this->plantId = $plantId;
|
||||
$this->productionOrder = $productionOrder;
|
||||
$this->attempted = true;
|
||||
$this->refresh = false;
|
||||
|
||||
|
||||
if (!$plantId || !$productionOrder) {
|
||||
$this->items = [];
|
||||
return;
|
||||
}
|
||||
|
||||
$this->items = QualityValidation::where('plant_id', $plantId)
|
||||
->where('production_order', $productionOrder)
|
||||
->get()
|
||||
->map(function ($item) {
|
||||
return [
|
||||
'item_code' => optional($item->stickerMaster->item)->code ?? 'N/A',
|
||||
'serial_number' => $item->serial_number,
|
||||
'created_at' => $item->created_at->format('Y-m-d H:i:s'),
|
||||
'sap_status' => $item->sap_msg_status,
|
||||
'sap_description' => $item->sap_msg_description,
|
||||
];
|
||||
})
|
||||
->toArray();
|
||||
|
||||
$this->updateRowCount();
|
||||
}
|
||||
|
||||
// Method to update row count based on scanned_quantity
|
||||
public function updateRowCount()
|
||||
{
|
||||
$this->attempted = true;
|
||||
|
||||
// Ensure scanned_quantity is a valid number and doesn't exceed the available rows
|
||||
if ($this->scanned_quantity > 0 && $this->scanned_quantity <= count($this->items)) {
|
||||
$this->items = array_slice($this->items, 0, $this->scanned_quantity);
|
||||
} else {
|
||||
$this->scanned_quantity = count($this->items); // Reset to show all items if invalid quantity
|
||||
}
|
||||
|
||||
$this->dispatch('updateScannedQuantity', $this->scanned_quantity);
|
||||
}
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.sap-data');
|
||||
}
|
||||
}
|
||||
82
app/Livewire/SelectPlant.php
Normal file
82
app/Livewire/SelectPlant.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Models\Line;
|
||||
use App\Models\Plant;
|
||||
use App\Models\ProductionQuantity;
|
||||
use Carbon\Carbon;
|
||||
use Livewire\Component;
|
||||
|
||||
class SelectPlant extends Component
|
||||
{
|
||||
|
||||
protected $listeners = [
|
||||
'plant-line-updated' => 'updatePlantLine',
|
||||
'productionUpdated' => '$refresh'
|
||||
];
|
||||
|
||||
public $plantId;
|
||||
public $lineId;
|
||||
|
||||
public $hourlyData = [];
|
||||
|
||||
public function updatePlantLine($plantId, $lineId)
|
||||
{
|
||||
session(['plantId' => $plantId, 'lineId' => $lineId]);
|
||||
$this->plantId = $plantId;
|
||||
$this->lineId = $lineId;
|
||||
$this->loadData();
|
||||
}
|
||||
|
||||
// Method to load hourly production data
|
||||
public function loadData()
|
||||
{
|
||||
// Define the time range from today 8:00 AM to the next day 8:00 AM
|
||||
$today = now()->startOfDay()->addHours(8); // Today 8:00 AM
|
||||
$nextDay = $today->copy()->addDay(); // Next day 8:00 AM
|
||||
|
||||
// Initialize the array to hold the hourly data
|
||||
$productionCounts = [];
|
||||
|
||||
// Loop through each hour from today 8:00 AM to the next day 8:00 AM
|
||||
for ($i = 0; $i < 24; $i++) {
|
||||
// Define the start and end time for the current hour
|
||||
$startOfHour = $today->copy()->addHours($i); // Start of the hour
|
||||
$endOfHour = $startOfHour->copy()->addHour()->subSeconds(1); // End of the hour
|
||||
|
||||
// Query the production counts for the current hour (between start and end time)
|
||||
$count = ProductionQuantity::query()
|
||||
->where('plant_id', $this->plantId)
|
||||
->where('line_id', $this->lineId)
|
||||
->whereBetween('created_at', [$startOfHour, $endOfHour])
|
||||
->count(); // Count the number of records in the current hour
|
||||
|
||||
// Store the count for the current hour in the production counts array
|
||||
$productionCounts[$i] = $count;
|
||||
|
||||
}
|
||||
|
||||
// Set the hourly data to be used in the component's view
|
||||
$this->hourlyData = $productionCounts;
|
||||
|
||||
}
|
||||
|
||||
// public function render()
|
||||
// {
|
||||
// return view('livewire.select-plant', [
|
||||
// 'hourlyData' => $this->hourlyData,
|
||||
// ]);
|
||||
// }
|
||||
|
||||
public function mount()
|
||||
{
|
||||
$this->plantId = session('plantId');
|
||||
$this->lineId = session('lineId');
|
||||
|
||||
if ($this->plantId && $this->lineId) {
|
||||
$this->loadData();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
94
app/Livewire/SerialLocatorDataTable.php
Normal file
94
app/Livewire/SerialLocatorDataTable.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Models\PalletValidation;
|
||||
use Livewire\Component;
|
||||
|
||||
class SerialLocatorDataTable extends Component
|
||||
{
|
||||
|
||||
public $plantId;
|
||||
|
||||
public $locatorNumber;
|
||||
|
||||
public $serialNumber;
|
||||
|
||||
public $hasSearched = false;
|
||||
|
||||
public $locatorNo;
|
||||
|
||||
|
||||
public $locators = [];
|
||||
|
||||
protected $listeners =
|
||||
[
|
||||
'loadData' => 'loadLocatorData',
|
||||
'open-confirm-modal' => 'openConfirmModal',
|
||||
'open-confirm-serial' => 'openConfirmSerial',
|
||||
];
|
||||
|
||||
public function openConfirmModal($locatorNo, $plantId)
|
||||
{
|
||||
$this->locatorNo = $locatorNo;
|
||||
$this->plantId = $plantId;
|
||||
|
||||
$this->dispatch('open-modal', id: 'confirm-process-modal');
|
||||
}
|
||||
|
||||
public function openConfirmSerial($locatorNo, $plantId)
|
||||
{
|
||||
$this->locatorNo = $locatorNo;
|
||||
$this->plantId = $plantId;
|
||||
|
||||
$this->dispatch('open-modal', id: 'confirm-process-serial');
|
||||
}
|
||||
|
||||
public function loadLocatorData($scanLocator, $scanSno, $plantId)
|
||||
{
|
||||
|
||||
$this->hasSearched = true;
|
||||
$this->locatorNumber = $scanLocator;
|
||||
$this->serialNumber = $scanSno;
|
||||
$this->plantId = $plantId;
|
||||
$this->locators = [];
|
||||
|
||||
// $query = PalletValidation::query()->where('plant_id', $plantId)
|
||||
// ->whereNull('pallet_number')
|
||||
// ->orWhere('pallet_number', '=','');
|
||||
$query = PalletValidation::query()
|
||||
->where('plant_id', $plantId)
|
||||
->where(function($q) {
|
||||
$q->whereNull('pallet_number')
|
||||
->orWhere('pallet_number', '=', '');
|
||||
});
|
||||
|
||||
|
||||
|
||||
if ($scanLocator && $scanSno)
|
||||
{
|
||||
$query->where('locator_number', $scanLocator)
|
||||
->where('serial_number', $scanSno);
|
||||
}
|
||||
elseif ($scanLocator)
|
||||
{
|
||||
$query->where('locator_number', $scanLocator);
|
||||
}
|
||||
elseif ($scanSno)
|
||||
{
|
||||
$query->where('serial_number', $scanSno);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->locators = collect();
|
||||
return;
|
||||
}
|
||||
$this->locators = $query->orderByDesc('created_at')->get();
|
||||
|
||||
//dd($this->locators);
|
||||
}
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.serial-locator-data-table');
|
||||
}
|
||||
}
|
||||
371
app/Livewire/SerialValidationData.php
Normal file
371
app/Livewire/SerialValidationData.php
Normal file
@@ -0,0 +1,371 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Models\StickerMaster;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Notifications\Notification;
|
||||
use Livewire\Component;
|
||||
use App\Models\SerialValidation;
|
||||
|
||||
|
||||
class SerialValidationData extends Component
|
||||
{
|
||||
public $invoiceData = [];
|
||||
|
||||
public $plantId = 0;
|
||||
|
||||
public string $invoiceNumber = '';
|
||||
public string $serialNumber = '';
|
||||
|
||||
public bool $completedInvoice = false;
|
||||
|
||||
public bool $isSerial = false;
|
||||
|
||||
public bool $emptyInvoice = false;
|
||||
|
||||
public bool $hasSearched = false;
|
||||
|
||||
public bool $materialInvoice = false;
|
||||
|
||||
public bool $showCapacitorInput = false;
|
||||
|
||||
// protected $listeners = ['refreshInvoiceData' => 'loadData',];
|
||||
|
||||
protected $listeners = [
|
||||
'refreshCompletedInvoice' => 'loadCompletedData',
|
||||
'refreshEmptyInvoice' => 'loadEmptyData',
|
||||
'refreshInvoiceData' => 'loadData',
|
||||
'refreshMaterialInvoiceData' => 'loadMaterialData',
|
||||
'openCapacitorModal' => 'showCapacitorInputBox',
|
||||
];
|
||||
|
||||
public $capacitorInput = '';
|
||||
|
||||
public $panel_box_supplier;
|
||||
|
||||
public $panel_box_item_code;
|
||||
|
||||
public $panel_box_serial_number;
|
||||
|
||||
public string $currentItemCode = '';
|
||||
|
||||
public string $currentSerialNumber = '';
|
||||
|
||||
// public function loadCompletedData($invoiceNumber, $plantId, $isSerial)
|
||||
// {
|
||||
// $this->plantId = $plantId;
|
||||
// $this->invoiceNumber = $invoiceNumber;
|
||||
// $this->completedInvoice = true;
|
||||
// $this->isSerial = $isSerial;
|
||||
// $this->emptyInvoice = false;
|
||||
// $this->hasSearched = false;
|
||||
// $this->materialInvoice = false;
|
||||
// // $this->showCapacitorInput = false;
|
||||
// }
|
||||
|
||||
public function loadCompletedData($invoiceNumber, $plantId, $isSerial)
|
||||
{
|
||||
|
||||
$this->plantId = $plantId;
|
||||
$this->invoiceNumber = $invoiceNumber;
|
||||
$this->completedInvoice = true;
|
||||
$this->isSerial = $isSerial;
|
||||
$this->emptyInvoice = false;
|
||||
$this->hasSearched = false;
|
||||
$this->materialInvoice = false;
|
||||
// $this->showCapacitorInput = false;
|
||||
}
|
||||
|
||||
public function loadEmptyData($invoiceNumber, $plantId)
|
||||
{
|
||||
$this->plantId = $plantId;
|
||||
$this->invoiceNumber = $invoiceNumber;
|
||||
$this->completedInvoice = false;
|
||||
$this->emptyInvoice = true;
|
||||
$this->hasSearched = false;
|
||||
$this->materialInvoice = false;
|
||||
// $this->showCapacitorInput = false;
|
||||
}
|
||||
|
||||
public function loadData($invoiceNumber, $plantId)
|
||||
{
|
||||
$this->plantId = $plantId;
|
||||
$this->invoiceNumber = $invoiceNumber;
|
||||
$this->completedInvoice = false;
|
||||
$this->isSerial = true;
|
||||
$this->emptyInvoice = false;
|
||||
$this->hasSearched = true;
|
||||
$this->materialInvoice = false;
|
||||
// $this->showCapacitorInput = false;
|
||||
|
||||
//->where('serial_number', '!=', '')
|
||||
$this->invoiceData = SerialValidation::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();
|
||||
|
||||
//Loop through and replace 'code' using related StickerMaster > Item > code
|
||||
foreach ($this->invoiceData as &$row) {
|
||||
// $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';
|
||||
}
|
||||
}
|
||||
|
||||
public function loadMaterialData($invoiceNumber, $plantId)
|
||||
{
|
||||
$this->plantId = $plantId;
|
||||
$this->invoiceNumber = $invoiceNumber;
|
||||
$this->completedInvoice = false;
|
||||
$this->isSerial = false;
|
||||
$this->emptyInvoice = false;
|
||||
$this->hasSearched = false;
|
||||
$this->materialInvoice = true;
|
||||
// $this->showCapacitorInput = false;
|
||||
|
||||
//->where('serial_number', '!=', '')
|
||||
$this->invoiceData = SerialValidation::where('invoice_number', $this->invoiceNumber)->where('plant_id', $plantId)->where('serial_number', null)
|
||||
->get()
|
||||
->map(function ($record) {
|
||||
return [
|
||||
'sticker_master_id' => $record->sticker_master_id,
|
||||
// 'material_type' => StickerMaster::where('id', $record->sticker_master_id)->first()->material_type ?? '',
|
||||
'quantity' => $record->quantity ?? '',
|
||||
'serial_number' => $record->serial_number ?? '',
|
||||
'batch_number' => $record->batch_number ?? '',
|
||||
'created_at' => $record->created_at,
|
||||
'operator_id' => $record->operator_id,
|
||||
];
|
||||
})
|
||||
->toArray();
|
||||
|
||||
//Loop through and replace 'code' using related StickerMaster > Item > code
|
||||
foreach ($this->invoiceData as &$row) {
|
||||
// $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';
|
||||
$matType = StickerMaster::where('id', $row['sticker_master_id'] ?? null)->first()->material_type ?? '';
|
||||
if($matType === 1)
|
||||
{
|
||||
$row['material_type'] = 'Individual';
|
||||
}
|
||||
else if($matType === 2)
|
||||
{
|
||||
$row['material_type'] = 'Bundle';
|
||||
}
|
||||
else if($matType === 3)
|
||||
{
|
||||
$row['material_type'] = 'Quantity';
|
||||
}
|
||||
else
|
||||
{
|
||||
$row['material_type'] = 'N/A';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// public function showCapacitorInputBox()
|
||||
// {
|
||||
// $this->showCapacitorInput = true;
|
||||
// }
|
||||
|
||||
public function showCapacitorInputBox($itemCode, $serialNumber, $plantId)
|
||||
{
|
||||
$this->plantId = $plantId;
|
||||
$this->currentItemCode = $itemCode;
|
||||
$this->currentSerialNumber = $serialNumber;
|
||||
$this->showCapacitorInput = true;
|
||||
// $this->capacitorInput = '';
|
||||
$this->completedInvoice = false;
|
||||
$this->isSerial = true;
|
||||
$this->emptyInvoice = false;
|
||||
$this->hasSearched = false;
|
||||
$this->materialInvoice = false;
|
||||
$this->dispatch('focus-capacitor-input');
|
||||
}
|
||||
|
||||
public function cancelCapacitorInput()
|
||||
{
|
||||
$this->showCapacitorInput = false;
|
||||
}
|
||||
|
||||
public function processCapacitorInput()
|
||||
{
|
||||
$user = Filament::auth()->user();
|
||||
$operatorName = $user->name;
|
||||
|
||||
if (!$this->capacitorInput) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!preg_match('/^[^\/]+\/[^\/]+\/.+$/', $this->capacitorInput)) {
|
||||
Notification::make()
|
||||
->title('Invalid Panel Box QR Format:')
|
||||
->body('Scan the valid panel box QR code to proceed!')
|
||||
->danger()
|
||||
// ->duration(3000)
|
||||
->seconds(2)
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
$parts = explode('/', $this->capacitorInput);
|
||||
$supplier = $parts[0];
|
||||
$itemCode = $parts[1];
|
||||
$serialNumber = implode('/', array_slice($parts, 2)); // Keep rest of the string
|
||||
|
||||
$existsInStickerMaster = StickerMaster::where('panel_box_code', $itemCode)->where('plant_id', $this->plantId)->whereHas('item', function ($query) {
|
||||
$query->where('code', $this->currentItemCode);
|
||||
})
|
||||
->exists();
|
||||
|
||||
if (!$existsInStickerMaster) {
|
||||
Notification::make()
|
||||
->title('Unknown: Panel Box Code')
|
||||
->body("Unknown panel box code: $itemCode found for item code: $this->currentItemCode")
|
||||
->danger()
|
||||
// ->duration(4000)
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->capacitorInput = '';
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($this->invoiceData as &$row) {
|
||||
if (
|
||||
($row['code'] ?? '') === $this->currentItemCode &&
|
||||
($row['serial_number'] ?? '') === $this->currentSerialNumber
|
||||
) {
|
||||
$row['panel_box_supplier'] = $supplier;
|
||||
$row['panel_box_item_code'] = $itemCode;
|
||||
$row['panel_box_serial_number'] = $serialNumber;
|
||||
$row['capacitor_scanned_status'] = 1;
|
||||
// $row['scanned_status_set'] = true;
|
||||
|
||||
$matchingValidation = SerialValidation::with('stickerMaster.item')
|
||||
->where('serial_number', $this->currentSerialNumber)
|
||||
->where('plant_id', $this->plantId)
|
||||
->get()
|
||||
->first(function ($validation) {
|
||||
return $validation->stickerMaster?->item?->code === $this->currentItemCode;
|
||||
});
|
||||
|
||||
if ($matchingValidation) {
|
||||
$hasMotorQr = $matchingValidation->stickerMasterRelation->tube_sticker_motor ?? null;
|
||||
$hasPumpQr = $matchingValidation->stickerMasterRelation->tube_sticker_pump ?? null;
|
||||
$hasPumpSetQr = $matchingValidation->stickerMasterRelation->tube_sticker_pumpset ?? null;
|
||||
// $hasCapacitorQr = $matchingValidation->stickerMasterRelation->panel_box_code ?? null;
|
||||
|
||||
$hadMotorQr = $matchingValidation->motor_scanned_status ?? null;
|
||||
$hadPumpQr = $matchingValidation->pump_scanned_status ?? null;
|
||||
$hadPumpSetQr = $matchingValidation->scanned_status_set ?? null;
|
||||
// $hadCapacitorQr = $matchingValidation->capacitor_scanned_status ?? null;
|
||||
|
||||
$packCnt = 1;
|
||||
$scanCnt = 1;
|
||||
// if($hadMotorQr === $hasMotorQr && $hadPumpQr === $hasPumpQr && $hadPumpSetQr === $hasPumpSetQr)
|
||||
if($hasMotorQr || $hasPumpQr || $hasPumpSetQr)
|
||||
{
|
||||
$packCnt = $hasMotorQr ? $packCnt + 1 : $packCnt;
|
||||
$packCnt = $hasPumpQr ? $packCnt + 1 : $packCnt;
|
||||
$packCnt = $hasPumpSetQr ? $packCnt + 1 : $packCnt;
|
||||
|
||||
$scanCnt = $hadMotorQr ? $scanCnt + 1: $scanCnt;
|
||||
$scanCnt = $hadPumpQr ? $scanCnt + 1: $scanCnt;
|
||||
$scanCnt = $hadPumpSetQr ? $scanCnt + 1: $scanCnt;
|
||||
|
||||
if($packCnt === $scanCnt)
|
||||
{
|
||||
$matchingValidation->update([
|
||||
'panel_box_supplier' => $supplier,
|
||||
'panel_box_item_code' => $itemCode,
|
||||
'panel_box_serial_number' => $serialNumber,
|
||||
'capacitor_scanned_status' => 1,
|
||||
'scanned_status' => 'Scanned',
|
||||
'operator_id'=> $operatorName,
|
||||
]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$matchingValidation->update([
|
||||
'panel_box_supplier' => $supplier,
|
||||
'panel_box_item_code' => $itemCode,
|
||||
'panel_box_serial_number' => $serialNumber,
|
||||
'capacitor_scanned_status' => 1,
|
||||
'operator_id'=> $operatorName,
|
||||
]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$matchingValidation->update([
|
||||
'panel_box_supplier' => $supplier,
|
||||
'panel_box_item_code' => $itemCode,
|
||||
'panel_box_serial_number' => $serialNumber,
|
||||
'capacitor_scanned_status' => 1,
|
||||
'scanned_status' => 'Scanned',
|
||||
'operator_id'=> $operatorName,
|
||||
]);
|
||||
}
|
||||
|
||||
// Notification::make()
|
||||
// ->title('Success: Capacitor QR')
|
||||
// // ->title("Panel box code scanned: $itemCode")
|
||||
// ->body("'Capacitor' QR scanned status updated, Scan next QR.")
|
||||
// ->success() // commented
|
||||
// ->seconds(2)
|
||||
// ->send();
|
||||
|
||||
$totalQuantity = SerialValidation::where('invoice_number', $matchingValidation->invoice_number)->where('plant_id', $this->plantId)->count();
|
||||
$scannedQuantity = SerialValidation::where('invoice_number', $matchingValidation->invoice_number)->where('plant_id', $this->plantId)->where('scanned_status', 'Scanned')->count();
|
||||
// $this->form->fill([
|
||||
// 'plant_id' => $matchingValidation->plant_id,
|
||||
// 'invoice_number' => $matchingValidation->invoice_number,
|
||||
// 'serial_number' => null,
|
||||
// 'total_quantity' => $totalQuantity,
|
||||
// 'scanned_quantity'=> $scannedQuantity,
|
||||
// ]);
|
||||
|
||||
if($totalQuantity === $scannedQuantity)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Completed: Serial Invoice')
|
||||
->body("Serial invoice '$matchingValidation->invoice_number' completed the scanning process.<br>Scan the next 'Serial Invoice' to proceed!")
|
||||
->success()
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->loadCompletedData($matchingValidation->invoice_number, $matchingValidation->plant_id, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->loadData($matchingValidation->invoice_number, $matchingValidation->plant_id);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
$this->showCapacitorInput = false;
|
||||
$this->capacitorInput = '';
|
||||
$this->dispatch('focus-serial-number');
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.serial-validation-data');
|
||||
}
|
||||
|
||||
}
|
||||
55
app/Livewire/StickerPrintData.php
Normal file
55
app/Livewire/StickerPrintData.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use Livewire\Component;
|
||||
use App\Models\StickerPrinting;
|
||||
|
||||
class StickerPrintData 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->materialInvoice = true;
|
||||
|
||||
$this->records = StickerPrinting::where('plant_id', $plantId)
|
||||
->where('reference_number', $refNumber)
|
||||
->orderBy('created_at', 'asc')
|
||||
->get(['serial_number', 'created_by']);
|
||||
|
||||
}
|
||||
|
||||
public function loadSticker($plantId, $refNumber, $serialNumber)
|
||||
{
|
||||
|
||||
$this->plantId = $plantId;
|
||||
$this->refNumber = $refNumber;
|
||||
$this->materialInvoice = true;
|
||||
|
||||
$this->records = StickerPrinting::where('plant_id', $plantId)
|
||||
->where('reference_number', $refNumber)
|
||||
->orderBy('created_at', 'asc')
|
||||
->get(['serial_number', 'created_by']);
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.sticker-print-data');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user