Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 17s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 19s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 18s
Laravel Pint / pint (pull_request) Failing after 29s
Laravel Larastan / larastan (pull_request) Failing after 3m38s
934 lines
33 KiB
PHP
934 lines
33 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;
|
|
}
|
|
|
|
$panelBoxExistPallet = PanelPalletValidation::where('plant_id', $plantId)->where('pallet_number', $palletNumber)->where('panel_box_supplier', $supplierNo)->where('panel_box_serial_number', $pBoxSNo)->first();
|
|
|
|
if($panelBoxExistPallet){
|
|
Notification::make()
|
|
->title('Serial Number')
|
|
->body("Scanned Panel Box Serial Number '$serNo' already added in pallet $palletNumber.")
|
|
->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;
|
|
}
|
|
|
|
$panelBoxExistOtherPallet = PanelPalletValidation::where('plant_id', $plantId)
|
|
->where('pallet_number', '!=', $palletNumber)
|
|
->where('panel_box_supplier', $supplierNo)
|
|
->where('panel_box_serial_number', $pBoxSNo)
|
|
->first();
|
|
|
|
if ($panelBoxExistOtherPallet) {
|
|
|
|
Notification::make()
|
|
->title('Serial Number')
|
|
->body("Scanned Panel Box Serial Number '$serNo' already added in another pallet: {$panelBoxExistOtherPallet->pallet_number}.")
|
|
->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;
|
|
|
|
$serNo = trim($this->form->getState()['removeSno_number']) ?? null;
|
|
|
|
$serNo = trim($serNo) ?? 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 (!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();
|
|
|
|
$plantName = Plant::find($plantId)?->name;
|
|
|
|
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){
|
|
Notification::make()
|
|
->title('Serial Number')
|
|
->body("Scanned Panel Box Serial Number '$serNo' not found in Panel Box Validation")
|
|
->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;
|
|
}
|
|
|
|
$panelBoxExistPallet = PanelPalletValidation::where('plant_id', $plantId)->where('pallet_number', $palletNumber)->where('panel_box_supplier', $supplierNo)->where('panel_box_serial_number', $pBoxSNo)->where('panel_box_code', $panelBoxCode)->first();
|
|
|
|
if(!$panelBoxExistPallet){
|
|
|
|
$panelBoxExistOtherPallet = PanelPalletValidation::where('plant_id', $plantId)
|
|
->where('pallet_number', '!=', $palletNumber)
|
|
->where('panel_box_supplier', $supplierNo)
|
|
->where('panel_box_serial_number', $pBoxSNo)
|
|
->where('panel_box_code', $panelBoxCode)
|
|
->first();
|
|
|
|
if ($panelBoxExistOtherPallet) {
|
|
$message = "Scanned Panel Box Serial Number '$serNo' already exists in another pallet: {$panelBoxExistOtherPallet->pallet_number}.";
|
|
} else {
|
|
$message = "Scanned Panel Box Serial Number '$serNo' not found in selected pallet number '$palletNumber'.";
|
|
}
|
|
|
|
Notification::make()
|
|
->title('Serial Number')
|
|
->body($message)
|
|
->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;
|
|
}
|
|
}
|
|
|
|
$deleted = PanelPalletValidation::where('plant_id', $plantId)
|
|
->where('pallet_number', $palletNumber)
|
|
->where('panel_box_serial_number', $pBoxSNo)
|
|
->where('panel_box_supplier', $supplierNo)
|
|
->where('panel_box_code', $panelBoxCode)
|
|
->forceDelete();
|
|
|
|
if ($deleted)
|
|
{
|
|
|
|
$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 [];
|
|
}
|
|
}
|