Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
868 lines
30 KiB
PHP
868 lines
30 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\PanelPalletValidationResource\Pages;
|
|
|
|
use App\Filament\Resources\PanelPalletValidationResource;
|
|
use Filament\Actions;
|
|
use Filament\Resources\Pages\CreateRecord;
|
|
use Illuminate\View\View;
|
|
use Filament\Facades\Filament;
|
|
use Filament\Notifications\Notification;
|
|
use App\Models\PanelPalletValidation;
|
|
use App\Models\InvoiceValidation;
|
|
use App\Models\PanelBoxValidation;
|
|
use App\Models\Item;
|
|
use App\Models\Plant;
|
|
|
|
class CreatePanelPalletValidation extends CreateRecord
|
|
{
|
|
public $plantId;
|
|
|
|
public $pallet_number;
|
|
|
|
public $palletNo;
|
|
|
|
public $pendingPallet;
|
|
|
|
public $snoCount = 0;
|
|
|
|
public $pallet_number_locked = false;
|
|
|
|
public $serial_number;
|
|
|
|
protected static string $view = 'filament.resources.panel-pallet-validation-resource.create-panel-pallet-validation';
|
|
|
|
protected static string $resource = PanelPalletValidationResource::class;
|
|
|
|
protected $listeners = [
|
|
'updateSnoQuantity' => 'handleUpdateSnoQuantity',
|
|
];
|
|
|
|
public ?array $data = null;
|
|
|
|
protected function getRedirectUrl(): string
|
|
{
|
|
return $this->getResource()::getUrl('create');
|
|
}
|
|
|
|
public function processPalletSNo()
|
|
{
|
|
$plantId = $this->form->getState()['plant_id'];
|
|
|
|
$plantId = trim($plantId) ?? null;
|
|
|
|
$pendingPallet = $this->form->getState()['pending_pallet_list'];
|
|
|
|
$palletNumber = trim($this->form->getState()['pallet_number'])?? null;
|
|
|
|
$palletNumber = trim($palletNumber) ?? null;
|
|
|
|
$serNo = trim($this->form->getState()['serial_number'])?? null;
|
|
|
|
$serNo = trim($serNo) ?? null;
|
|
|
|
$user = Filament::auth()->user();
|
|
|
|
$operatorName = $user->name;
|
|
|
|
$clickedAt = session('pallet_clicked_time');
|
|
|
|
$clickedBy = session('pallet_created_by');
|
|
|
|
$plantName = Plant::where('id', $plantId)->value('name');
|
|
|
|
if (!$palletNumber)
|
|
{
|
|
Notification::make()
|
|
->title("Pallet number can't be empty")
|
|
->danger()
|
|
->duration(5000)
|
|
->send();
|
|
|
|
$this->form->fill([
|
|
'serial_number' => null,
|
|
'plant_id' => $plantId,
|
|
'pallet_number' => $palletNumber,
|
|
'pending_pallet_list' => $pendingPallet,
|
|
'Sno_quantity' => 0,
|
|
'created_by' => $operatorName,
|
|
'scanned_by' => $operatorName,
|
|
]);
|
|
return;
|
|
}
|
|
|
|
$count = PanelPalletValidation::where('plant_id', $plantId)
|
|
->where('pallet_number', $palletNumber)
|
|
->count('pallet_number');
|
|
|
|
if (!preg_match('/^(\d+)\/(\d+)\/(\d+)\/(\d+)$/', $serNo, $matches)) {
|
|
Notification::make()
|
|
->title("Invalid Panel Box QR format: $serNo <br>Sample Format '1070107/398679/2611/000001'")
|
|
->danger()
|
|
->send();
|
|
|
|
$this->form->fill([
|
|
'plant_id' => $plantId,
|
|
'item_id' => null,
|
|
'pallet_number' => $palletNumber,
|
|
'pending_pallet_list' => $pendingPallet,
|
|
'serial_number' => null,
|
|
'panel_box_supplier' => null,
|
|
'panel_box_serial_number' => null,
|
|
'panel_box_code' => null,
|
|
'Sno_quantity' => 0,
|
|
]);
|
|
|
|
return;
|
|
}
|
|
|
|
|
|
if (preg_match('/^(\d+)\/(\d+)\/(\d+)\/(\d+)$/', $serNo, $matches)) {
|
|
$itemCode = $matches[2];
|
|
$serialNumber = $matches[1] . $matches[3] . $matches[4];
|
|
|
|
$supplierNo = $matches[1];
|
|
$supplierSNo = implode('/', array_slice($matches, 3));
|
|
$panelBoxCode = $matches[2];
|
|
|
|
$pBoxSNo = $matches[3] . '/' . $matches[4];
|
|
|
|
$itemExists = Item::where('code', $panelBoxCode)->first();
|
|
|
|
if (!$itemExists) {
|
|
Notification::make()
|
|
->title("Item code '$panelBoxCode' does not exist.")
|
|
->danger()
|
|
->duration(5000)
|
|
->send();
|
|
|
|
$this->form->fill([
|
|
'plant_id' => $plantId,
|
|
'item_id' => null,
|
|
'pallet_number' => $palletNumber,
|
|
'pending_pallet_list' => $pendingPallet,
|
|
'serial_number' => null,
|
|
'panel_box_supplier' => null,
|
|
'panel_box_serial_number' => null,
|
|
'panel_box_code' => null,
|
|
'Sno_quantity' => 0,
|
|
]);
|
|
|
|
return;
|
|
}
|
|
|
|
$itemExistsAgaPlant = Item::where('plant_id', $plantId)->where('code', $panelBoxCode)->first();
|
|
|
|
if (!$itemExistsAgaPlant) {
|
|
Notification::make()
|
|
->title("Item code '$panelBoxCode' does not exist against plant $plantName.")
|
|
->danger()
|
|
->duration(5000)
|
|
->send();
|
|
|
|
$this->form->fill([
|
|
'plant_id' => $plantId,
|
|
'item_id' => null,
|
|
'pallet_number' => $palletNumber,
|
|
'pending_pallet_list' => $pendingPallet,
|
|
'serial_number' => null,
|
|
'panel_box_supplier' => null,
|
|
'panel_box_serial_number' => null,
|
|
'panel_box_code' => null,
|
|
'Sno_quantity' => 0,
|
|
]);
|
|
|
|
return;
|
|
}
|
|
|
|
$panelBoxExist = PanelBoxValidation::where('plant_id', $plantId)->where('panel_box_supplier', $supplierNo)->where('panel_box_serial_number', $pBoxSNo)->where('panel_box_code', $panelBoxCode)->first();
|
|
|
|
if(!$panelBoxExist){
|
|
Notification::make()
|
|
->title('Unknwon : Serial Number')
|
|
->body("Scanned Panel Box Serial Number '$serNo' was not found in Panel Box Validation.<br>Please complete the testing process for this Panel Box before proceeding.")
|
|
->danger()
|
|
->seconds(3)
|
|
->send();
|
|
|
|
$this->dispatch('playWarnSound');
|
|
|
|
$this->form->fill([
|
|
'plant_id' => $plantId,
|
|
'item_id' => null,
|
|
'pallet_number' => $palletNumber,
|
|
'pending_pallet_list' => $pendingPallet,
|
|
'serial_number' => null,
|
|
'panel_box_supplier' => null,
|
|
'panel_box_serial_number' => null,
|
|
'panel_box_code' => null,
|
|
'Sno_quantity' => 0,
|
|
]);
|
|
|
|
return;
|
|
}
|
|
|
|
$panelBoxExistStatus = PanelBoxValidation::where('plant_id', $plantId)->where('panel_box_supplier', $supplierNo)->where('panel_box_serial_number', $pBoxSNo)->where('panel_box_code', $panelBoxCode)->first();
|
|
|
|
if($panelBoxExistStatus && $panelBoxExistStatus->status == 'NotOk'){
|
|
Notification::make()
|
|
->title('NotOk : Serial Number')
|
|
->body("Scanned Panel Box Serial Number '$serNo' was found in Panel Box Validation, but its status is Not OK.")
|
|
->danger()
|
|
->seconds(3)
|
|
->send();
|
|
|
|
$this->dispatch('playWarnSound');
|
|
|
|
$this->form->fill([
|
|
'plant_id' => $plantId,
|
|
'item_id' => null,
|
|
'pallet_number' => $palletNumber,
|
|
'pending_pallet_list' => $pendingPallet,
|
|
'serial_number' => null,
|
|
'panel_box_supplier' => null,
|
|
'panel_box_serial_number' => null,
|
|
'panel_box_code' => null,
|
|
'Sno_quantity' => 0,
|
|
]);
|
|
|
|
return;
|
|
}
|
|
|
|
}
|
|
|
|
try
|
|
{
|
|
|
|
$existingPallet = PanelPalletValidation::where('plant_id', $plantId)->where('pallet_number', $palletNumber)->first();
|
|
|
|
$createdAt = $existingPallet ? $existingPallet->created_at : $clickedAt ?? now();
|
|
|
|
$createdBy = $existingPallet ? $existingPallet->created_by : $clickedBy ?? $operatorName;
|
|
|
|
$record = PanelPalletValidation::create([
|
|
'plant_id' => $plantId,
|
|
'item_id' => $itemExistsAgaPlant->id,
|
|
'pallet_number' => $palletNumber,
|
|
'serial_number' => $serialNumber,
|
|
'panel_box_supplier' => $supplierNo,
|
|
'panel_box_serial_number' => $pBoxSNo,
|
|
'panel_box_code' => $panelBoxCode,
|
|
'created_by' => $createdBy,
|
|
'scanned_by' => $operatorName,
|
|
'created_at' => $createdAt,
|
|
'scanned_at' => now(),
|
|
'updated_by' => $operatorName,
|
|
]);
|
|
|
|
$count = PanelPalletValidation::where('plant_id', $plantId)
|
|
->where('pallet_number', $palletNumber)
|
|
->count('pallet_number');
|
|
|
|
if ($record)
|
|
{
|
|
|
|
$this->snoCount = PanelPalletValidation::where('plant_id', $plantId)
|
|
->where('pallet_number', $palletNumber)
|
|
->count();
|
|
|
|
$this->dispatch('loadData', $palletNumber, $plantId);
|
|
$this->form->fill([
|
|
'plant_id' => $plantId,
|
|
'pallet_number' => $palletNumber,
|
|
'serial_number' => null,
|
|
'pending_pallet_list' => $pendingPallet,
|
|
'Sno_quantity' => $count,
|
|
'created_by' => $operatorName,
|
|
'scanned_by' => $operatorName,
|
|
]);
|
|
}
|
|
else
|
|
{
|
|
Notification::make()
|
|
->title("Failed to insert scanned serial number '$serialNumber' into pallet table!")
|
|
->danger()
|
|
->duration(5000)
|
|
->send();
|
|
|
|
$this->dispatch('loadData', $palletNumber, $plantId);
|
|
$this->form->fill([
|
|
'plant_id' => $plantId,
|
|
'pallet_number' => $palletNumber,
|
|
'serial_number' => null,
|
|
'pending_pallet_list' => $pendingPallet,
|
|
'Sno_quantity' => $count,
|
|
'scanned_by' => $operatorName,
|
|
]);
|
|
return;
|
|
}
|
|
}
|
|
catch (\Exception $e)
|
|
{
|
|
Notification::make()
|
|
->title('Error: Serial not inserted.')
|
|
->body("Something went wrong while inserting serial number '{$serialNumber}' into pallet table!\nScan the new serial number to proceed...")
|
|
->danger()
|
|
->duration(5000)
|
|
->send();
|
|
|
|
$this->dispatch('loadData', $palletNumber, $plantId);
|
|
$this->form->fill([
|
|
'plant_id' => $plantId,
|
|
'pallet_number' => $palletNumber,
|
|
'serial_number' => null,
|
|
'pending_pallet_list' => $pendingPallet,
|
|
'Sno_quantity' => $count,
|
|
'created_by' => $operatorName,
|
|
'scanned_by' => $operatorName,
|
|
]);
|
|
return;
|
|
}
|
|
}
|
|
|
|
public function handleUpdateSnoQuantity($newValue)
|
|
{
|
|
// Update the form field
|
|
$this->form->fill([
|
|
'Sno_quantity' => $newValue,
|
|
]);
|
|
}
|
|
|
|
public function redirectToPanelQrPdf($palletNo)
|
|
{
|
|
$this->palletNo = $palletNo;
|
|
|
|
//return redirect()->route('download-qr-pdf', ['palletNo' => $this->palletNo]);
|
|
$url = route('download-qr-panel-pdf', ['panelPalletNo' => $this->palletNo]);
|
|
$this->js(<<<JS
|
|
window.dispatchEvent(new CustomEvent('open-pdf', {
|
|
detail: {
|
|
url: "{$url}"
|
|
}
|
|
}));
|
|
JS);
|
|
|
|
}
|
|
|
|
public function markAsComplete()
|
|
{
|
|
|
|
$plantId = $this->form->getState()['plant_id'];
|
|
|
|
$plantId = trim($plantId) ?? null;
|
|
|
|
$pendingPallet = $this->form->getState()['pending_pallet_list'];
|
|
|
|
$palletNumber = trim($this->form->getState()['pallet_number'])?? null;
|
|
|
|
$palletNumber = trim($palletNumber) ?? null;
|
|
|
|
$serialNumber = trim($this->form->getState()['serial_number'])?? null;
|
|
|
|
$serialNumber = trim($serialNumber) ?? null;
|
|
|
|
$user = Filament::auth()->user();
|
|
|
|
$operatorName = $user->name;
|
|
|
|
$isCompleted = $this->data['is_completed'] ?? false;
|
|
|
|
$this->pendingPallet = $this->form->getState()['pending_pallet_list'];
|
|
|
|
|
|
$palletExist = PanelPalletValidation::where('pallet_number', $palletNumber)
|
|
->where('plant_id', $plantId)
|
|
->first();
|
|
|
|
if (!$palletExist)
|
|
{
|
|
Notification::make()
|
|
->title("Pallet number '$palletNumber' does not have serial numbers to save!<br>Add the valid serial number into pallet number to proceed...")
|
|
->danger()
|
|
->duration(5000)
|
|
->send();
|
|
|
|
$this->dispatch('loadData', $palletNumber, $plantId);
|
|
$this->form->fill([
|
|
'serial_number' => null,
|
|
'plant_id' => $plantId,
|
|
'pallet_number' => $palletNumber,
|
|
'pending_pallet_list' => $pendingPallet,
|
|
'Sno_quantity' => 0,
|
|
'created_by' => $operatorName,
|
|
'scanned_by' => $operatorName,
|
|
]);
|
|
return;
|
|
}
|
|
|
|
$allCompleted = PanelPalletValidation::where('plant_id', $plantId)
|
|
->where('pallet_number', $palletNumber)
|
|
->where('pallet_status', '=','Completed')
|
|
->first();
|
|
|
|
if ($allCompleted)
|
|
{
|
|
Notification::make()
|
|
->title("Pallet number '$palletNumber' already completed the master packing!<br>Generate the new pallet number or choose from pending pallet list!")
|
|
->danger()
|
|
->duration(5000)
|
|
->send();
|
|
|
|
$this->dispatch('loadData', '', $plantId);
|
|
$this->form->fill([
|
|
'serial_number' => null,
|
|
'plant_id' => $plantId,
|
|
'pallet_number' => null,
|
|
'pending_pallet_list' => null,//$pendingPallet
|
|
'Sno_quantity' => 0,
|
|
'created_by' => $operatorName,
|
|
'scanned_by' => $operatorName,
|
|
]);
|
|
return;
|
|
}
|
|
|
|
// $count = PalletValidation::where('plant_id', $plantId)
|
|
// ->where('pallet_number', $palletNumber)
|
|
// ->count('pallet_number');
|
|
|
|
if (!$isCompleted)
|
|
{
|
|
$updated = PanelPalletValidation::where('pallet_number', $palletNumber)
|
|
->where('plant_id', $plantId)
|
|
->update([
|
|
'updated_at' => now(),
|
|
'updated_by' => $operatorName,
|
|
]);
|
|
|
|
if ($updated > 0)
|
|
{
|
|
Notification::make()
|
|
->title("Pallet number '$palletNumber' records saved successfully!")
|
|
->success()
|
|
->duration(800)
|
|
->send();
|
|
|
|
$this->dispatch('loadData', '', $plantId);
|
|
$this->form->fill([
|
|
'serial_number' => null,
|
|
'plant_id' => $plantId,
|
|
'pallet_number' => null,//$palletNumber
|
|
'pending_pallet_list' => null,//$pendingPallet
|
|
'Sno_quantity' => 0,//$count,
|
|
'created_by' => $operatorName,
|
|
'scanned_by' => $operatorName,
|
|
]);
|
|
return;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
$updated = PanelPalletValidation::where('pallet_number', $palletNumber)
|
|
->where('plant_id', $plantId)
|
|
->update([
|
|
'pallet_status' => 'Completed',
|
|
'updated_at' => now(),
|
|
'updated_by' => $operatorName,
|
|
]);
|
|
|
|
if ($updated > 0)
|
|
{
|
|
Notification::make()
|
|
->title("Pallet number '$palletNumber' completed the master packing successfully!")
|
|
->success()
|
|
->duration(800)
|
|
->send();
|
|
|
|
$this->dispatch('loadData', '', $plantId);
|
|
$this->form->fill([
|
|
'serial_number' => null,
|
|
'plant_id' => $plantId,
|
|
'pallet_number' => null,//$palletNumber
|
|
'pending_pallet_list' => null,//$pendingPallet
|
|
'Sno_quantity' => 0,//$count
|
|
'created_by' => $operatorName,
|
|
'scanned_by' => $operatorName,
|
|
]);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
public function processRemoveSNo()
|
|
{
|
|
$plantId = $this->form->getState()['plant_id'];
|
|
|
|
$plantId = trim($plantId) ?? null;
|
|
|
|
$pendingPallet = $this->form->getState()['pending_pallet_list'];
|
|
|
|
$palletNumber = trim($this->form->getState()['pallet_number']) ?? null;
|
|
|
|
$palletNumber = trim($palletNumber) ?? null;
|
|
|
|
$serialNumber = trim($this->form->getState()['removeSno_number']) ?? null;
|
|
|
|
$serialNumber = trim($serialNumber) ?? null;
|
|
|
|
$user = Filament::auth()->user();
|
|
|
|
$operatorName = $user->name;
|
|
|
|
if (!$palletNumber)
|
|
{
|
|
Notification::make()
|
|
->title('Pallet number is required to remove.')
|
|
->danger()
|
|
->duration(5000)
|
|
->send();
|
|
return;
|
|
}
|
|
|
|
|
|
$count = PanelPalletValidation::where('plant_id', $plantId)
|
|
->where('pallet_number', $palletNumber)
|
|
->count('pallet_number');
|
|
|
|
if (!$serialNumber)
|
|
{
|
|
Notification::make()
|
|
->title('Serial number is required to remove.')
|
|
->danger()
|
|
->duration(5000)
|
|
->send();
|
|
|
|
$this->dispatch('loadData', $palletNumber, $plantId);
|
|
$this->form->fill([
|
|
'serial_number' => null,
|
|
'plant_id' => $plantId,
|
|
'pallet_number' => $palletNumber,
|
|
'pending_pallet_list' => $pendingPallet,
|
|
'Sno_quantity' => $count,
|
|
'created_by' => $operatorName,
|
|
'scanned_by' => $operatorName,
|
|
]);
|
|
return;
|
|
}
|
|
else if (strlen($serialNumber) < 9 || strlen($serialNumber) > 20)
|
|
{
|
|
Notification::make()
|
|
->title('Serial number should contain minimum 9 digits and maximum 20 digits.')
|
|
->danger()
|
|
->duration(5000)
|
|
->send();
|
|
|
|
$this->dispatch('loadData', $palletNumber, $plantId);
|
|
$this->form->fill([
|
|
'serial_number' => null,
|
|
'plant_id' => $plantId,
|
|
'pallet_number' => $palletNumber,
|
|
'pending_pallet_list' => $pendingPallet,
|
|
'Sno_quantity' => $count,
|
|
'created_by' => $operatorName,
|
|
'scanned_by' => $operatorName,
|
|
]);
|
|
return;
|
|
}
|
|
else if (!ctype_alnum($serialNumber))
|
|
{
|
|
Notification::make()
|
|
->title('Serial number must contain alpha-numeric values only.')
|
|
->danger()
|
|
->duration(5000)
|
|
->send();
|
|
|
|
$this->dispatch('loadData', $palletNumber, $plantId);
|
|
$this->form->fill([
|
|
'serial_number' => null,
|
|
'plant_id' => $plantId,
|
|
'pallet_number' => $palletNumber,
|
|
'pending_pallet_list' => $pendingPallet,
|
|
'Sno_quantity' => $count,
|
|
'created_by' => $operatorName,
|
|
'scanned_by' => $operatorName,
|
|
]);
|
|
return;
|
|
}
|
|
|
|
$invoiceExist = LocatorInvoiceValidation::where('plant_id', $plantId)
|
|
->where('serial_number', $serialNumber)
|
|
->where('scanned_status', '=', 'Scanned')
|
|
->first();
|
|
|
|
if ($invoiceExist)
|
|
{
|
|
Notification::make()
|
|
->title("Scanned serial number '{$serialNumber}' already completed the scanning process and exist in invoice number '{$invoiceExist->invoice_number}'.<br>Scan the valid exist serial number to remove!")
|
|
->danger()
|
|
->duration(5000)
|
|
->send();
|
|
|
|
$this->dispatch('loadData', $palletNumber, $plantId);
|
|
$this->form->fill([
|
|
'serial_number' => null,
|
|
'plant_id' => $plantId,
|
|
'pallet_number' => $palletNumber,
|
|
'pending_pallet_list' => $pendingPallet,
|
|
'Sno_quantity' => $count,
|
|
'created_by' => $operatorName,
|
|
'scanned_by' => $operatorName,
|
|
]);
|
|
return;
|
|
}
|
|
|
|
$serialexist = PanelPalletValidation::where('plant_id', $plantId)
|
|
->where('serial_number', $serialNumber)
|
|
->first();
|
|
if (!$serialexist)
|
|
{
|
|
Notification::make()
|
|
->title('Serial number not exists in pallet table.')
|
|
->danger()
|
|
->duration(5000)
|
|
->send();
|
|
|
|
$this->dispatch('loadData', $palletNumber, $plantId);
|
|
$this->form->fill([
|
|
'serial_number' => null,
|
|
'plant_id' => $plantId,
|
|
'pallet_number' => $palletNumber,
|
|
'pending_pallet_list' => $pendingPallet,
|
|
'Sno_quantity' => $count,
|
|
'created_by' => $operatorName,
|
|
'scanned_by' => $operatorName,
|
|
]);
|
|
return;
|
|
}
|
|
|
|
$palletExist = PanelPalletValidation::where('plant_id', $plantId)
|
|
->where('serial_number', $serialNumber)
|
|
->where('pallet_number', '!=', '')
|
|
->where('pallet_number', '!=', null)
|
|
->first();
|
|
|
|
if ($palletExist && $palletExist->pallet_number != $palletNumber)
|
|
{
|
|
Notification::make()
|
|
->title("Scanned serial number exist in pallet number '$palletExist->pallet_number'.<br>Scan the valid exist serial number to remove!")
|
|
->danger()
|
|
->duration(5000)
|
|
->send();
|
|
|
|
$this->dispatch('loadData', $palletNumber, $plantId);
|
|
$this->form->fill([
|
|
'serial_number' => null,
|
|
'plant_id' => $plantId,
|
|
'pallet_number' => $palletNumber,
|
|
'pending_pallet_list' => $pendingPallet,
|
|
'Sno_quantity' => $count,
|
|
'created_by' => $operatorName,
|
|
'scanned_by' => $operatorName,
|
|
]);
|
|
return;
|
|
}
|
|
|
|
$locatorExist = PanelPalletValidation::where('plant_id', $plantId)
|
|
->where('serial_number', $serialNumber)
|
|
->where('locator_number', '!=', '')
|
|
->where('locator_number', '!=', null)
|
|
->first();
|
|
|
|
if ($locatorExist && $locatorExist->locator_number)
|
|
{
|
|
Notification::make()
|
|
->title("Scanned serial number exist in locator number '$locatorExist->locator_number'.<br>Scan the valid exist serial number to remove!")
|
|
->danger()
|
|
->duration(5000)
|
|
->send();
|
|
|
|
$this->dispatch('loadData', $palletNumber, $plantId);
|
|
$this->form->fill([
|
|
'serial_number' => null,
|
|
'plant_id' => $plantId,
|
|
'pallet_number' => $palletNumber,
|
|
'pending_pallet_list' => $pendingPallet,
|
|
'Sno_quantity' => $count,
|
|
'created_by' => $operatorName,
|
|
'scanned_by' => $operatorName,
|
|
]);
|
|
return;
|
|
}
|
|
|
|
|
|
$deleted = PanelPalletValidation::where('plant_id', $plantId)
|
|
->where('pallet_number', $palletNumber)
|
|
->where('serial_number', $serialNumber)
|
|
->forceDelete();
|
|
|
|
if ($deleted)
|
|
{
|
|
// Notification::make()
|
|
// ->title("Scanned serial number '$serialNumber' successfully removed from pallet table!<br>Scan the next exist serial number to remove...")
|
|
// ->success()
|
|
// ->duration(600)
|
|
// ->send();
|
|
|
|
$this->snoCount = PanelPalletValidation::where('plant_id', $plantId)
|
|
->where('pallet_number', $palletNumber)
|
|
->count();
|
|
|
|
$this->form->fill([
|
|
'plant_id' => $plantId,
|
|
'pallet_number' => $palletNumber,
|
|
'removeSno_number' => null,
|
|
'pending_pallet_list' => $this->pendingPallet,
|
|
'Sno_quantity' => $this->snoCount,
|
|
'created_by' => $operatorName,
|
|
'scanned_by' => $operatorName,
|
|
]);
|
|
|
|
$this->dispatch('loadData', $palletNumber, $plantId);
|
|
}
|
|
else
|
|
{
|
|
Notification::make()
|
|
->title("Failed to remove scanned serial number '$serialNumber' from pallet table!")
|
|
->danger()
|
|
->duration(5000)
|
|
->send();
|
|
|
|
$this->dispatch('loadData', $palletNumber, $plantId);
|
|
$this->form->fill([
|
|
'serial_number' => null,
|
|
'plant_id' => $plantId,
|
|
'pallet_number' => $palletNumber,
|
|
'pending_pallet_list' => $pendingPallet,
|
|
'Sno_quantity' => $count,
|
|
'created_by' => $operatorName,
|
|
'scanned_by' => $operatorName,
|
|
]);
|
|
}
|
|
|
|
//$this->dispatch('removeSno', $serialNumber, $palletNumber, $plantId);
|
|
}
|
|
|
|
public function processPalletNo()
|
|
{
|
|
$plantId = $this->form->getState()['plant_id'];
|
|
|
|
$plantId = trim($plantId) ?? null;
|
|
|
|
$pendingPallet = $this->form->getState()['pending_pallet_list'];
|
|
|
|
$palletNumber = trim($this->form->getState()['pallet_number']) ?? null;
|
|
|
|
$palletNumber = trim($palletNumber) ?? null;
|
|
|
|
$serialNumber = trim($this->form->getState()['serial_number']) ?? null;
|
|
|
|
$serialNumber = trim($serialNumber) ?? null;
|
|
|
|
$user = Filament::auth()->user();
|
|
|
|
$operatorName = $user->name;
|
|
|
|
//$this->dispatch('loadData', $palletNumber, $plantId);
|
|
$this->form->fill([
|
|
'serial_number' => null,
|
|
'plant_id' => $plantId,
|
|
'pallet_number' => $palletNumber,
|
|
'pending_pallet_list' => $pendingPallet,
|
|
'Sno_quantity' => 0,
|
|
'created_by' => $operatorName,
|
|
'scanned_by' => $operatorName,
|
|
]);
|
|
|
|
if (!$palletNumber)
|
|
{
|
|
Notification::make()
|
|
->title('Pallet number is required.')
|
|
->danger()
|
|
->duration(5000)
|
|
->send();
|
|
|
|
$this->dispatch('loadData', '', $plantId);
|
|
$this->form->fill([
|
|
'serial_number' => null,
|
|
'plant_id' => $plantId,
|
|
'pallet_number' => $palletNumber,
|
|
'pending_pallet_list' => $pendingPallet,
|
|
'Sno_quantity' => 0,
|
|
'created_by' => $operatorName,
|
|
'scanned_by' => $operatorName,
|
|
]);
|
|
return;
|
|
}
|
|
|
|
if (strlen($palletNumber) < 10)
|
|
{
|
|
Notification::make()
|
|
->title("Pallet number '$palletNumber' must be at least 10 digits.")
|
|
->danger()
|
|
->duration(5000)
|
|
->send();
|
|
|
|
$this->dispatch('loadLocator' ,'',$plantId);
|
|
$this->form->fill([
|
|
'serial_number' => null,
|
|
'plant_id' => $plantId,
|
|
'pallet_number' => $palletNumber,
|
|
'pending_pallet_list' => $pendingPallet,
|
|
'Sno_quantity' => 0,
|
|
'created_by' => $operatorName,
|
|
'scanned_by' => $operatorName,
|
|
]);
|
|
return;
|
|
}
|
|
|
|
$count = PanelPalletValidation::where('plant_id', $plantId)
|
|
->where('pallet_number', $palletNumber)
|
|
->count('pallet_number');
|
|
|
|
|
|
$palletNotCompleted = PanelPalletValidation::where('plant_id', $plantId)
|
|
->where('pallet_number', $palletNumber)
|
|
->where('pallet_status', '=','')
|
|
->orWhere('pallet_status', '=',null)
|
|
->first();
|
|
|
|
if (!$palletNotCompleted)
|
|
{
|
|
Notification::make()
|
|
->title("Already completed for pallet number $palletNumber!")
|
|
->danger()
|
|
->duration(5000)
|
|
->send();
|
|
|
|
$this->dispatch('loadData', $palletNumber, $plantId);
|
|
$this->form->fill([
|
|
'serial_number' => null,
|
|
'plant_id' => $plantId,
|
|
'pallet_number' => $palletNumber,
|
|
'pending_pallet_list' => $pendingPallet,
|
|
'Sno_quantity' => $count,
|
|
'created_by' => $operatorName,
|
|
'scanned_by' => $operatorName,
|
|
]);
|
|
return;
|
|
}
|
|
|
|
$this->form->fill([
|
|
'serial_number' => null,
|
|
'plant_id' => $plantId,
|
|
'pallet_number' => $palletNumber,
|
|
'pending_pallet_list' => $pendingPallet,
|
|
'Sno_quantity' => $count,
|
|
'created_by' => $operatorName,
|
|
'scanned_by' => $operatorName,
|
|
]);
|
|
|
|
$this->dispatch('loadData', $palletNumber, $plantId);
|
|
|
|
}
|
|
|
|
public function getFormActions(): array
|
|
{
|
|
return [];
|
|
}
|
|
}
|