From b9338498549b895148e32521743f3ae136ae63e9 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Sat, 29 Aug 2026 10:12:02 +0530 Subject: [PATCH 1/3] Added rework logic in panel box validation page --- .../Resources/PanelBoxValidationResource.php | 43 +++++++++++-------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/app/Filament/Resources/PanelBoxValidationResource.php b/app/Filament/Resources/PanelBoxValidationResource.php index dcfec3c..e863e6c 100644 --- a/app/Filament/Resources/PanelBoxValidationResource.php +++ b/app/Filament/Resources/PanelBoxValidationResource.php @@ -9,6 +9,7 @@ use App\Models\ProductionCharacteristic; use Filament\Facades\Filament; use Filament\Forms; use Filament\Forms\Form; +use Filament\Forms\Get; use Filament\Resources\Resource; use Filament\Tables; use Filament\Tables\Table; @@ -31,6 +32,7 @@ use App\Filament\Exports\PanelBoxValidationExporter; use App\Filament\Imports\PanelBoxValidationImporter; use Filament\Forms\Components\Actions; use Filament\Forms\Components\Actions\Action; +use Illuminate\Support\Js; class PanelBoxValidationResource extends Resource { @@ -64,6 +66,7 @@ class PanelBoxValidationResource extends Resource $set('item_id', null); $set('line_id', null); $set('production_order', null); + $set('inspection_lot_number', null); $set('part_validation_type_options', []); $set('part_validation_type', null); @@ -117,6 +120,7 @@ class PanelBoxValidationResource extends Resource ->afterStateUpdated(function (callable $set, callable $get, $state) { $set('item_id', null); $set('production_order', null); + $set('inspection_lot_number', null); $set('line', $state); @@ -810,21 +814,21 @@ class PanelBoxValidationResource extends Resource $serialExists = PanelBoxValidation::where('serial_number', $serialNumber)->where('plant_id', $plantId)->first(); - // if ($serialExists) { - // $set('serial_exists', true); - // } else { - // $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) { + $set('serial_exists', true); + } else { + $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; + // } + $set('validationError', null); foreach ($serialFields as $column) { @@ -943,6 +947,7 @@ class PanelBoxValidationResource extends Resource 'id' => 'item_id', 'onkeydown' => " if (event.key === 'Enter') { + const serialFields = [ 'serial_number_motor_qr', 'serial_number_pump_qr', 'pack_slip_motor_qr', 'name_plate_motor_qr', 'tube_sticker_motor_qr', 'warranty_card_qr' @@ -962,6 +967,7 @@ class PanelBoxValidationResource extends Resource if (anyVisible) { event.preventDefault(); event.stopPropagation(); + event.stopImmediatePropagation(); return false; } } @@ -969,8 +975,11 @@ class PanelBoxValidationResource extends Resource ]) ->hint(fn ($get) => $get('validationError') ? $get('validationError') : null) ->hintColor('danger'), - Forms\Components\Hidden::make('serial_exists') - ->default(false), + Forms\Components\Hidden::make('serial_exists') + // ->default(false) + ->live() + ->dehydrated() + ->id('serial_exists'), Forms\Components\Actions::make([ Action::make('rework') @@ -996,9 +1005,9 @@ class PanelBoxValidationResource extends Resource if ($alreadyExists) { Notification::make() - ->title('Invalid Rework') + ->title('Duplicate Found') ->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 for rework..' + '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 for rework...' ) ->danger() ->send(); From 6905981e55e209db43442e143b07f50e8b2d36b7 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Sat, 29 Aug 2026 10:13:52 +0530 Subject: [PATCH 2/3] Added halt logic in create panel box validation --- .../Pages/CreatePanelBoxValidation.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/Filament/Resources/PanelBoxValidationResource/Pages/CreatePanelBoxValidation.php b/app/Filament/Resources/PanelBoxValidationResource/Pages/CreatePanelBoxValidation.php index 2320a69..38e5f69 100644 --- a/app/Filament/Resources/PanelBoxValidationResource/Pages/CreatePanelBoxValidation.php +++ b/app/Filament/Resources/PanelBoxValidationResource/Pages/CreatePanelBoxValidation.php @@ -74,10 +74,13 @@ class CreatePanelBoxValidation extends CreateRecord { // return $data; // } - if ($this->checkIfHasCharacteristics($data)) { + if ($this->checkIfHasCharacteristics($data) && ($data['serial_exists']) == false) { $this->showChecklist = true; $this->halt(); } + if(($data['serial_exists']) == true){ + $this->halt(); + } else{ \Filament\Notifications\Notification::make() ->title('Characteristics not found for the scanned item.') From d2b104eaf3383255619ada6651b4368a2a5f0777 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Sat, 29 Aug 2026 10:14:52 +0530 Subject: [PATCH 3/3] Added rework logic in panel check list --- app/Livewire/PanelCheckList.php | 111 ++++++++++++++++---------------- 1 file changed, 56 insertions(+), 55 deletions(-) diff --git a/app/Livewire/PanelCheckList.php b/app/Livewire/PanelCheckList.php index 431bbaa..46077cc 100644 --- a/app/Livewire/PanelCheckList.php +++ b/app/Livewire/PanelCheckList.php @@ -177,61 +177,36 @@ public $records = []; } } - // $latestReworkRecord = PanelBoxValidation::where('plant_id', $this->data['plant_id'] ?? null)->where('serial_number', $this->data['serial_number'] ?? null)->latest()->first(); + $latestReworkRecord = PanelBoxValidation::where('plant_id', $this->data['plant_id'] ?? null)->where('serial_number', $this->data['serial_number'] ?? null)->latest()->first(); - // if($latestReworkRecord){ - // $qualityValidation = PanelBoxValidation::create([ - // 'plant_id' => $this->data['plant_id'] ?? null, - // 'line_id' => $this->data['line_id'] ?? null, - // 'sticker_master_id' => $this->data['sticker_master_id'] ?? null, - // 'production_order' => $this->data['production_order'] ?? null, - // 'serial_number' => $this->data['serial_number'] ?? null, - // 'serial_number_panel' => $this->data['serial_number_panel'] ?? null, - // 'pack_slip_panel' => $this->data['pack_slip_panel'] ?? null, - // 'name_plate_panel' => $this->data['name_plate_panel'] ?? null, - // 'tube_sticker_panel' => $this->data['tube_sticker_panel'] ?? null, - // 'warranty_card_panel' => $this->data['warranty_card_panel'] ?? null, - // 'part_validation1' => $this->data['part_validation1'] ?? null, - // 'part_validation2' => $this->data['part_validation2'] ?? null, - // 'part_validation3' => $this->data['part_validation3'] ?? null, - // 'part_validation4' => $this->data['part_validation4'] ?? null, - // 'part_validation5' => $this->data['part_validation5'] ?? null, - // 'panel_box_supplier' => $this->data['panel_box_supplier'] ?? null, - // 'panel_box_serial_number' => $this->data['panel_box_serial_number'] ?? null, - // 'panel_box_code' => $this->data['panel_box_code'] ?? null, - // 'inspection_lot_number' => $this->data['inspection_lot_number'] ?? null, - // 'rework_count' => $latestReworkRecord ? ((int) $latestReworkRecord->rework_count + 1) : 0, - // 'created_by' => $this->data['created_by'] ?? null, - // 'updated_by' => $this->data['updated_by'] ?? null, - // ]); - // } - // else{ - // $qualityValidation = PanelBoxValidation::create([ - // 'plant_id' => $this->data['plant_id'] ?? null, - // 'line_id' => $this->data['line_id'] ?? null, - // 'sticker_master_id' => $this->data['sticker_master_id'] ?? null, - // 'production_order' => $this->data['production_order'] ?? null, - // 'serial_number' => $this->data['serial_number'] ?? null, - // 'serial_number_panel' => $this->data['serial_number_panel'] ?? null, - // 'pack_slip_panel' => $this->data['pack_slip_panel'] ?? null, - // 'name_plate_panel' => $this->data['name_plate_panel'] ?? null, - // 'tube_sticker_panel' => $this->data['tube_sticker_panel'] ?? null, - // 'warranty_card_panel' => $this->data['warranty_card_panel'] ?? null, - // 'part_validation1' => $this->data['part_validation1'] ?? null, - // 'part_validation2' => $this->data['part_validation2'] ?? null, - // 'part_validation3' => $this->data['part_validation3'] ?? null, - // 'part_validation4' => $this->data['part_validation4'] ?? null, - // 'part_validation5' => $this->data['part_validation5'] ?? null, - // 'panel_box_supplier' => $this->data['panel_box_supplier'] ?? null, - // 'panel_box_serial_number' => $this->data['panel_box_serial_number'] ?? null, - // 'panel_box_code' => $this->data['panel_box_code'] ?? null, - // 'inspection_lot_number' => $this->data['inspection_lot_number'] ?? null, - // 'created_by' => $this->data['created_by'] ?? null, - // 'updated_by' => $this->data['updated_by'] ?? null, - // ]); - // } - - $qualityValidation = PanelBoxValidation::create([ + if($latestReworkRecord){ + $qualityValidation = PanelBoxValidation::create([ + 'plant_id' => $this->data['plant_id'] ?? null, + 'line_id' => $this->data['line_id'] ?? null, + 'sticker_master_id' => $this->data['sticker_master_id'] ?? null, + 'production_order' => $this->data['production_order'] ?? null, + 'serial_number' => $this->data['serial_number'] ?? null, + 'serial_number_panel' => $this->data['serial_number_panel'] ?? null, + 'pack_slip_panel' => $this->data['pack_slip_panel'] ?? null, + 'name_plate_panel' => $this->data['name_plate_panel'] ?? null, + 'tube_sticker_panel' => $this->data['tube_sticker_panel'] ?? null, + 'warranty_card_panel' => $this->data['warranty_card_panel'] ?? null, + 'part_validation1' => $this->data['part_validation1'] ?? null, + 'part_validation2' => $this->data['part_validation2'] ?? null, + 'part_validation3' => $this->data['part_validation3'] ?? null, + 'part_validation4' => $this->data['part_validation4'] ?? null, + 'part_validation5' => $this->data['part_validation5'] ?? null, + 'panel_box_supplier' => $this->data['panel_box_supplier'] ?? null, + 'panel_box_serial_number' => $this->data['panel_box_serial_number'] ?? null, + 'panel_box_code' => $this->data['panel_box_code'] ?? null, + 'inspection_lot_number' => $this->data['inspection_lot_number'] ?? null, + 'rework_count' => $latestReworkRecord ? ((int) $latestReworkRecord->rework_count + 1) : 0, + 'created_by' => $this->data['created_by'] ?? null, + 'updated_by' => $this->data['updated_by'] ?? null, + ]); + } + else{ + $qualityValidation = PanelBoxValidation::create([ 'plant_id' => $this->data['plant_id'] ?? null, 'line_id' => $this->data['line_id'] ?? null, 'sticker_master_id' => $this->data['sticker_master_id'] ?? null, @@ -253,7 +228,33 @@ public $records = []; 'inspection_lot_number' => $this->data['inspection_lot_number'] ?? null, 'created_by' => $this->data['created_by'] ?? null, 'updated_by' => $this->data['updated_by'] ?? null, - ]); + ]); + } + + // $qualityValidation = PanelBoxValidation::create([ + // 'plant_id' => $this->data['plant_id'] ?? null, + // 'line_id' => $this->data['line_id'] ?? null, + // 'sticker_master_id' => $this->data['sticker_master_id'] ?? null, + // 'production_order' => $this->data['production_order'] ?? null, + // 'serial_number' => $this->data['serial_number'] ?? null, + // 'serial_number_panel' => $this->data['serial_number_panel'] ?? null, + // 'pack_slip_panel' => $this->data['pack_slip_panel'] ?? null, + // 'name_plate_panel' => $this->data['name_plate_panel'] ?? null, + // 'tube_sticker_panel' => $this->data['tube_sticker_panel'] ?? null, + // 'warranty_card_panel' => $this->data['warranty_card_panel'] ?? null, + // 'part_validation1' => $this->data['part_validation1'] ?? null, + // 'part_validation2' => $this->data['part_validation2'] ?? null, + // 'part_validation3' => $this->data['part_validation3'] ?? null, + // 'part_validation4' => $this->data['part_validation4'] ?? null, + // 'part_validation5' => $this->data['part_validation5'] ?? null, + // 'panel_box_supplier' => $this->data['panel_box_supplier'] ?? null, + // 'panel_box_serial_number' => $this->data['panel_box_serial_number'] ?? null, + // 'panel_box_code' => $this->data['panel_box_code'] ?? null, + // 'inspection_lot_number' => $this->data['inspection_lot_number'] ?? null, + // 'created_by' => $this->data['created_by'] ?? null, + // 'updated_by' => $this->data['updated_by'] ?? null, + // ]); + if (! $qualityValidation || ! $qualityValidation->exists) { Notification::make()