Added rework validation logic updation in panel box validation
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 12s
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 12s
This commit is contained in:
@@ -28,6 +28,8 @@ use Filament\Tables\Actions\ExportAction;
|
|||||||
use Filament\Tables\Actions\ImportAction;
|
use Filament\Tables\Actions\ImportAction;
|
||||||
use App\Filament\Exports\PanelBoxValidationExporter;
|
use App\Filament\Exports\PanelBoxValidationExporter;
|
||||||
use App\Filament\Imports\PanelBoxValidationImporter;
|
use App\Filament\Imports\PanelBoxValidationImporter;
|
||||||
|
use Filament\Forms\Components\Actions;
|
||||||
|
use Filament\Forms\Components\Actions\Action;
|
||||||
|
|
||||||
class PanelBoxValidationResource extends Resource
|
class PanelBoxValidationResource extends Resource
|
||||||
{
|
{
|
||||||
@@ -41,7 +43,7 @@ class PanelBoxValidationResource extends Resource
|
|||||||
|
|
||||||
public $data = [];
|
public $data = [];
|
||||||
|
|
||||||
// public bool $showChecklist = false;
|
public bool $showChecklist = false;
|
||||||
|
|
||||||
public static function form(Form $form): Form
|
public static function form(Form $form): Form
|
||||||
{
|
{
|
||||||
@@ -239,10 +241,6 @@ class PanelBoxValidationResource extends Resource
|
|||||||
$set('pqLineError', null);
|
$set('pqLineError', null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if(!$state){
|
|
||||||
// $set('serial_exists', false);
|
|
||||||
// }
|
|
||||||
|
|
||||||
$pOrder = $get('production_order');
|
$pOrder = $get('production_order');
|
||||||
if (! $pOrder) {
|
if (! $pOrder) {
|
||||||
$set('prodOrdError', "Production Order can't be empty.");
|
$set('prodOrdError', "Production Order can't be empty.");
|
||||||
@@ -278,11 +276,12 @@ class PanelBoxValidationResource extends Resource
|
|||||||
|
|
||||||
// Proceed with validation logic for new scanned QR code
|
// Proceed with validation logic for new scanned QR code
|
||||||
if (! $state || trim($state) == '') {
|
if (! $state || trim($state) == '') {
|
||||||
|
$set('serial_exists', false);
|
||||||
$set('validationError', null);
|
$set('validationError', null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// // Check if QR format contains '|'
|
// Check if QR format contains '|'
|
||||||
|
|
||||||
if ($state && str_contains($state, '|'))
|
if ($state && str_contains($state, '|'))
|
||||||
{
|
{
|
||||||
@@ -566,11 +565,10 @@ class PanelBoxValidationResource extends Resource
|
|||||||
->danger()
|
->danger()
|
||||||
->send();
|
->send();
|
||||||
$set('item_id', null);
|
$set('item_id', null);
|
||||||
// $set('serial_exists', false);
|
$set('serial_exists', false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$supplier = $parts[0];
|
$supplier = $parts[0];
|
||||||
$panelBoxCode = $parts[1];
|
$panelBoxCode = $parts[1];
|
||||||
$panelBoxSerialNo = implode('/', array_slice($parts, 2));
|
$panelBoxSerialNo = implode('/', array_slice($parts, 2));
|
||||||
@@ -587,6 +585,7 @@ class PanelBoxValidationResource extends Resource
|
|||||||
->danger()
|
->danger()
|
||||||
->send();
|
->send();
|
||||||
$set('item_id', null);
|
$set('item_id', null);
|
||||||
|
$set('serial_exists', false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -599,6 +598,7 @@ class PanelBoxValidationResource extends Resource
|
|||||||
->danger()
|
->danger()
|
||||||
->send();
|
->send();
|
||||||
$set('item_id', null);
|
$set('item_id', null);
|
||||||
|
$set('serial_exists', false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -611,6 +611,7 @@ class PanelBoxValidationResource extends Resource
|
|||||||
->danger()
|
->danger()
|
||||||
->send();
|
->send();
|
||||||
$set('item_id', null);
|
$set('item_id', null);
|
||||||
|
$set('serial_exists', false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if($existInMaster->supplier_number == '' || $existInMaster->supplier_number == null){
|
else if($existInMaster->supplier_number == '' || $existInMaster->supplier_number == null){
|
||||||
@@ -620,6 +621,7 @@ class PanelBoxValidationResource extends Resource
|
|||||||
->danger()
|
->danger()
|
||||||
->send();
|
->send();
|
||||||
$set('item_id', null);
|
$set('item_id', null);
|
||||||
|
$set('serial_exists', false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if($existInMaster->supplier_number != $supplier){
|
else if($existInMaster->supplier_number != $supplier){
|
||||||
@@ -629,6 +631,7 @@ class PanelBoxValidationResource extends Resource
|
|||||||
->danger()
|
->danger()
|
||||||
->send();
|
->send();
|
||||||
$set('item_id', null);
|
$set('item_id', null);
|
||||||
|
$set('serial_exists', false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if($existInMaster->inspection_lot_number != $inspecLotNo){
|
else if($existInMaster->inspection_lot_number != $inspecLotNo){
|
||||||
@@ -638,6 +641,7 @@ class PanelBoxValidationResource extends Resource
|
|||||||
->danger()
|
->danger()
|
||||||
->send();
|
->send();
|
||||||
$set('item_id', null);
|
$set('item_id', null);
|
||||||
|
$set('serial_exists', false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if($existInMaster->quantity == '' || $existInMaster->quantity == null){
|
else if($existInMaster->quantity == '' || $existInMaster->quantity == null){
|
||||||
@@ -647,6 +651,7 @@ class PanelBoxValidationResource extends Resource
|
|||||||
->danger()
|
->danger()
|
||||||
->send();
|
->send();
|
||||||
$set('item_id', null);
|
$set('item_id', null);
|
||||||
|
$set('serial_exists', false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if($existInMaster->invoice_number == '' || $existInMaster->invoice_number == null){
|
else if($existInMaster->invoice_number == '' || $existInMaster->invoice_number == null){
|
||||||
@@ -656,6 +661,7 @@ class PanelBoxValidationResource extends Resource
|
|||||||
->danger()
|
->danger()
|
||||||
->send();
|
->send();
|
||||||
$set('item_id', null);
|
$set('item_id', null);
|
||||||
|
$set('serial_exists', false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -668,6 +674,7 @@ class PanelBoxValidationResource extends Resource
|
|||||||
->danger()
|
->danger()
|
||||||
->send();
|
->send();
|
||||||
$set('item_id', null);
|
$set('item_id', null);
|
||||||
|
$set('serial_exists', false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -680,6 +687,7 @@ class PanelBoxValidationResource extends Resource
|
|||||||
->danger()
|
->danger()
|
||||||
->send();
|
->send();
|
||||||
$set('item_id', null);
|
$set('item_id', null);
|
||||||
|
$set('serial_exists', false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -695,6 +703,7 @@ class PanelBoxValidationResource extends Resource
|
|||||||
->danger()
|
->danger()
|
||||||
->send();
|
->send();
|
||||||
$set('item_id', null);
|
$set('item_id', null);
|
||||||
|
$set('serial_exists', false);
|
||||||
$set('validationError', null);
|
$set('validationError', null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -702,6 +711,7 @@ class PanelBoxValidationResource extends Resource
|
|||||||
if (strlen($itemCode) < 6) {
|
if (strlen($itemCode) < 6) {
|
||||||
$set('validationError', 'Item code must be at least 6 digits.');
|
$set('validationError', 'Item code must be at least 6 digits.');
|
||||||
$set('part_validation_type', null);
|
$set('part_validation_type', null);
|
||||||
|
$set('serial_exists', false);
|
||||||
$set('show_validation_image', false);
|
$set('show_validation_image', false);
|
||||||
$set('part_validation_type_options', []);
|
$set('part_validation_type_options', []);
|
||||||
$set('validation1_image_url', null);
|
$set('validation1_image_url', null);
|
||||||
@@ -710,6 +720,7 @@ class PanelBoxValidationResource extends Resource
|
|||||||
} elseif (! ctype_alnum($itemCode)) {
|
} elseif (! ctype_alnum($itemCode)) {
|
||||||
$set('validationError', 'Item Code should contain alpha-numeric values.');
|
$set('validationError', 'Item Code should contain alpha-numeric values.');
|
||||||
$set('item_id', null);
|
$set('item_id', null);
|
||||||
|
$set('serial_exists', false);
|
||||||
$set('part_validation_type', null);
|
$set('part_validation_type', null);
|
||||||
$set('show_validation_image', false);
|
$set('show_validation_image', false);
|
||||||
$set('part_validation_type_options', []);
|
$set('part_validation_type_options', []);
|
||||||
@@ -745,6 +756,7 @@ class PanelBoxValidationResource extends Resource
|
|||||||
$set('show_validation_image', false);
|
$set('show_validation_image', false);
|
||||||
$set('part_validation_type_options', []);
|
$set('part_validation_type_options', []);
|
||||||
$set('validation1_image_url', null);
|
$set('validation1_image_url', null);
|
||||||
|
$set('serial_exists', false);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
@@ -756,6 +768,7 @@ class PanelBoxValidationResource extends Resource
|
|||||||
$set('part_validation_type', null);
|
$set('part_validation_type', null);
|
||||||
$set('show_validation_image', false);
|
$set('show_validation_image', false);
|
||||||
$set('validation1_image_url', null);
|
$set('validation1_image_url', null);
|
||||||
|
$set('serial_exists', false);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
} elseif (! is_numeric($get('production_order')) || ! preg_match('/^[1-9][0-9]{6,13}$/', $get('production_order'))) {
|
} elseif (! is_numeric($get('production_order')) || ! preg_match('/^[1-9][0-9]{6,13}$/', $get('production_order'))) {
|
||||||
@@ -768,6 +781,7 @@ class PanelBoxValidationResource extends Resource
|
|||||||
$set('show_validation_image', false);
|
$set('show_validation_image', false);
|
||||||
$set('part_validation_type_options', []);
|
$set('part_validation_type_options', []);
|
||||||
$set('validation1_image_url', null);
|
$set('validation1_image_url', null);
|
||||||
|
$set('serial_exists', false);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -793,23 +807,23 @@ class PanelBoxValidationResource extends Resource
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$serialExists = PanelBoxValidation::where('serial_number', $serialNumber)->where('plant_id', $plantId)->first();
|
$serialExists = PanelBoxValidation::where('serial_number', $serialNumber)->where('plant_id', $plantId)->latest()->first();
|
||||||
|
|
||||||
// if ($serialExists) {
|
if ($serialExists) {
|
||||||
// $set('serial_exists', true);
|
$set('serial_exists', true);
|
||||||
// } else {
|
} else {
|
||||||
// $set('serial_exists', false);
|
$set('serial_exists', false);
|
||||||
// }
|
|
||||||
|
|
||||||
if ($serialExists && ! $get('id')) {
|
|
||||||
$set('validationError', 'Serial number already exists in panel box validation.');
|
|
||||||
$set('sticker_master_id', null);
|
|
||||||
$set('uom', null);
|
|
||||||
$set('serial_number', null);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if ($serialExists && ! $get('id')) {
|
||||||
|
// $set('validationError', 'Serial number already exists in panel box validation.');
|
||||||
|
// $set('sticker_master_id', null);
|
||||||
|
// $set('uom', null);
|
||||||
|
// $set('serial_number', null);
|
||||||
|
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
$set('validationError', null);
|
$set('validationError', null);
|
||||||
|
|
||||||
foreach ($serialFields as $column) {
|
foreach ($serialFields as $column) {
|
||||||
@@ -923,12 +937,6 @@ class PanelBoxValidationResource extends Resource
|
|||||||
$set('part_validation_type_options', $options);
|
$set('part_validation_type_options', $options);
|
||||||
|
|
||||||
})
|
})
|
||||||
// ->extraAttributes(fn ($get) => [
|
|
||||||
// 'class' => $get('validationError') ? 'border-red-500' : '',
|
|
||||||
// 'id' => 'item_id',
|
|
||||||
// 'onkeydown' => "if (event.key === 'Enter') { event.preventDefault(); event.stopPropagation(); return false; }",
|
|
||||||
// ])
|
|
||||||
|
|
||||||
->extraAttributes(fn ($get) => [
|
->extraAttributes(fn ($get) => [
|
||||||
'class' => $get('validationError') ? 'border-red-500' : '',
|
'class' => $get('validationError') ? 'border-red-500' : '',
|
||||||
'id' => 'item_id',
|
'id' => 'item_id',
|
||||||
@@ -960,6 +968,78 @@ class PanelBoxValidationResource extends Resource
|
|||||||
])
|
])
|
||||||
->hint(fn ($get) => $get('validationError') ? $get('validationError') : null)
|
->hint(fn ($get) => $get('validationError') ? $get('validationError') : null)
|
||||||
->hintColor('danger'),
|
->hintColor('danger'),
|
||||||
|
Forms\Components\Hidden::make('serial_exists')
|
||||||
|
->default(false),
|
||||||
|
|
||||||
|
Forms\Components\Actions::make([
|
||||||
|
Action::make('rework')
|
||||||
|
->label('Yes, Rework')
|
||||||
|
->color('warning')
|
||||||
|
->requiresConfirmation()
|
||||||
|
->modalHeading('Confirm Rework')
|
||||||
|
->modalDescription('Have you reworked this serial number?')
|
||||||
|
->modalSubmitActionLabel('Yes, Continue')
|
||||||
|
->visible(fn ($get) => $get('serial_exists') == true)
|
||||||
|
->action(function ($get, $livewire) {
|
||||||
|
|
||||||
|
$serialNumber = $get('serial_number');
|
||||||
|
$plantId = $get('plant_id');
|
||||||
|
$pOrder = $get('production_order');
|
||||||
|
$inspecLotNo = $get('inspection_lot_number');
|
||||||
|
|
||||||
|
// $serialRecords = PanelBoxValidation::where('serial_number', $serialNumber)->where('plant_id', $plantId)->get();
|
||||||
|
|
||||||
|
// if ($serialRecords->isNotEmpty()) {
|
||||||
|
|
||||||
|
// $alreadyExists = $serialRecords->contains(function ($record) use ($pOrder, $inspecLotNo) {
|
||||||
|
// return $record->production_order == $pOrder
|
||||||
|
// && $record->inspection_lot_number == $inspecLotNo;
|
||||||
|
// });
|
||||||
|
|
||||||
|
// if ($alreadyExists) {
|
||||||
|
// Notification::make()
|
||||||
|
// ->title('Invalid Rework')
|
||||||
|
// ->body(
|
||||||
|
// 'This document number and inspection lot number have already been used for this serial number. Please provide a new document number and inspection lot number.'
|
||||||
|
// )
|
||||||
|
// ->danger()
|
||||||
|
// ->send();
|
||||||
|
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
$alreadyExists = PanelBoxValidation::where('serial_number', $serialNumber)
|
||||||
|
->where('plant_id', $plantId)
|
||||||
|
->where('production_order', $pOrder)
|
||||||
|
->where('inspection_lot_number', $inspecLotNo)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if ($alreadyExists) {
|
||||||
|
Notification::make()
|
||||||
|
->title('Invalid Rework')
|
||||||
|
->body(
|
||||||
|
'This document number and inspection lot number have already been used for this serial number. Please provide a new document number and inspection lot number.'
|
||||||
|
)
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// $livewire->showChecklist = true;
|
||||||
|
$data = $livewire->data;
|
||||||
|
|
||||||
|
if ($livewire->checkIfHasCharacteristics($data)) {
|
||||||
|
|
||||||
|
$livewire->showChecklist = true;
|
||||||
|
$livewire->dispatch('close-modal');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
]),
|
||||||
Forms\Components\Hidden::make('part_validation_type_options')
|
Forms\Components\Hidden::make('part_validation_type_options')
|
||||||
->default([])
|
->default([])
|
||||||
->reactive()
|
->reactive()
|
||||||
@@ -1767,6 +1847,11 @@ class PanelBoxValidationResource extends Resource
|
|||||||
->alignCenter()
|
->alignCenter()
|
||||||
->searchable()
|
->searchable()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('rework_count')
|
||||||
|
->label('Rework Count')
|
||||||
|
->alignCenter()
|
||||||
|
->searchable()
|
||||||
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('created_at')
|
Tables\Columns\TextColumn::make('created_at')
|
||||||
->label('Created At')
|
->label('Created At')
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
|
|||||||
Reference in New Issue
Block a user