From c5727c78c19e7fafb1d971879b83f3db32bc9905 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Wed, 26 Aug 2026 12:10:23 +0530 Subject: [PATCH 1/6] removed unique constriant in panel box validation table --- ..._constraint_from_panel_box_validations.php | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 database/migrations/2026_08_25_170626_remove_unique_constraint_from_panel_box_validations.php diff --git a/database/migrations/2026_08_25_170626_remove_unique_constraint_from_panel_box_validations.php b/database/migrations/2026_08_25_170626_remove_unique_constraint_from_panel_box_validations.php new file mode 100644 index 0000000..b5beac7 --- /dev/null +++ b/database/migrations/2026_08_25_170626_remove_unique_constraint_from_panel_box_validations.php @@ -0,0 +1,31 @@ + Date: Wed, 26 Aug 2026 12:11:05 +0530 Subject: [PATCH 2/6] Added rework count column in panel box validations table --- ..._rework_count_to_panel_box_validations.php | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 database/migrations/2026_08_26_110515_add_rework_count_to_panel_box_validations.php diff --git a/database/migrations/2026_08_26_110515_add_rework_count_to_panel_box_validations.php b/database/migrations/2026_08_26_110515_add_rework_count_to_panel_box_validations.php new file mode 100644 index 0000000..fc3d892 --- /dev/null +++ b/database/migrations/2026_08_26_110515_add_rework_count_to_panel_box_validations.php @@ -0,0 +1,31 @@ + Date: Wed, 26 Aug 2026 12:11:42 +0530 Subject: [PATCH 3/6] Added rework count column in model file of panel box validation --- app/Models/PanelBoxValidation.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Models/PanelBoxValidation.php b/app/Models/PanelBoxValidation.php index 4ae8858..1801cd3 100644 --- a/app/Models/PanelBoxValidation.php +++ b/app/Models/PanelBoxValidation.php @@ -30,6 +30,7 @@ class PanelBoxValidation extends Model 'panel_box_serial_number', 'panel_box_code', 'inspection_lot_number', + 'rework_count', 'created_by', 'updated_by' ]; From 2f45355b265a07fef124cb7ab4889ed2367341ac Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Wed, 26 Aug 2026 12:12:47 +0530 Subject: [PATCH 4/6] Added rework validation logic updation in panel box validation --- .../Resources/PanelBoxValidationResource.php | 141 ++++++++++++++---- 1 file changed, 113 insertions(+), 28 deletions(-) diff --git a/app/Filament/Resources/PanelBoxValidationResource.php b/app/Filament/Resources/PanelBoxValidationResource.php index 080505f..ee5ea66 100644 --- a/app/Filament/Resources/PanelBoxValidationResource.php +++ b/app/Filament/Resources/PanelBoxValidationResource.php @@ -28,6 +28,8 @@ use Filament\Tables\Actions\ExportAction; use Filament\Tables\Actions\ImportAction; use App\Filament\Exports\PanelBoxValidationExporter; use App\Filament\Imports\PanelBoxValidationImporter; +use Filament\Forms\Components\Actions; +use Filament\Forms\Components\Actions\Action; class PanelBoxValidationResource extends Resource { @@ -41,7 +43,7 @@ class PanelBoxValidationResource extends Resource public $data = []; - // public bool $showChecklist = false; + public bool $showChecklist = false; public static function form(Form $form): Form { @@ -239,10 +241,6 @@ class PanelBoxValidationResource extends Resource $set('pqLineError', null); } - // if(!$state){ - // $set('serial_exists', false); - // } - $pOrder = $get('production_order'); if (! $pOrder) { $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 if (! $state || trim($state) == '') { + $set('serial_exists', false); $set('validationError', null); return; } - // // Check if QR format contains '|' + // Check if QR format contains '|' if ($state && str_contains($state, '|')) { @@ -566,11 +565,10 @@ class PanelBoxValidationResource extends Resource ->danger() ->send(); $set('item_id', null); - // $set('serial_exists', false); + $set('serial_exists', false); return; } - $supplier = $parts[0]; $panelBoxCode = $parts[1]; $panelBoxSerialNo = implode('/', array_slice($parts, 2)); @@ -587,6 +585,7 @@ class PanelBoxValidationResource extends Resource ->danger() ->send(); $set('item_id', null); + $set('serial_exists', false); return; } @@ -599,6 +598,7 @@ class PanelBoxValidationResource extends Resource ->danger() ->send(); $set('item_id', null); + $set('serial_exists', false); return; } @@ -611,6 +611,7 @@ class PanelBoxValidationResource extends Resource ->danger() ->send(); $set('item_id', null); + $set('serial_exists', false); return; } else if($existInMaster->supplier_number == '' || $existInMaster->supplier_number == null){ @@ -620,6 +621,7 @@ class PanelBoxValidationResource extends Resource ->danger() ->send(); $set('item_id', null); + $set('serial_exists', false); return; } else if($existInMaster->supplier_number != $supplier){ @@ -629,6 +631,7 @@ class PanelBoxValidationResource extends Resource ->danger() ->send(); $set('item_id', null); + $set('serial_exists', false); return; } else if($existInMaster->inspection_lot_number != $inspecLotNo){ @@ -638,6 +641,7 @@ class PanelBoxValidationResource extends Resource ->danger() ->send(); $set('item_id', null); + $set('serial_exists', false); return; } else if($existInMaster->quantity == '' || $existInMaster->quantity == null){ @@ -647,6 +651,7 @@ class PanelBoxValidationResource extends Resource ->danger() ->send(); $set('item_id', null); + $set('serial_exists', false); return; } else if($existInMaster->invoice_number == '' || $existInMaster->invoice_number == null){ @@ -656,6 +661,7 @@ class PanelBoxValidationResource extends Resource ->danger() ->send(); $set('item_id', null); + $set('serial_exists', false); return; } @@ -668,6 +674,7 @@ class PanelBoxValidationResource extends Resource ->danger() ->send(); $set('item_id', null); + $set('serial_exists', false); return; } @@ -680,6 +687,7 @@ class PanelBoxValidationResource extends Resource ->danger() ->send(); $set('item_id', null); + $set('serial_exists', false); return; } @@ -695,6 +703,7 @@ class PanelBoxValidationResource extends Resource ->danger() ->send(); $set('item_id', null); + $set('serial_exists', false); $set('validationError', null); return; } @@ -702,6 +711,7 @@ class PanelBoxValidationResource extends Resource if (strlen($itemCode) < 6) { $set('validationError', 'Item code must be at least 6 digits.'); $set('part_validation_type', null); + $set('serial_exists', false); $set('show_validation_image', false); $set('part_validation_type_options', []); $set('validation1_image_url', null); @@ -710,6 +720,7 @@ class PanelBoxValidationResource extends Resource } elseif (! ctype_alnum($itemCode)) { $set('validationError', 'Item Code should contain alpha-numeric values.'); $set('item_id', null); + $set('serial_exists', false); $set('part_validation_type', null); $set('show_validation_image', false); $set('part_validation_type_options', []); @@ -745,6 +756,7 @@ class PanelBoxValidationResource extends Resource $set('show_validation_image', false); $set('part_validation_type_options', []); $set('validation1_image_url', null); + $set('serial_exists', false); return; } else { @@ -756,6 +768,7 @@ class PanelBoxValidationResource extends Resource $set('part_validation_type', null); $set('show_validation_image', false); $set('validation1_image_url', null); + $set('serial_exists', false); return; } 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('part_validation_type_options', []); $set('validation1_image_url', null); + $set('serial_exists', false); 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) { - // $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) { @@ -923,12 +937,6 @@ class PanelBoxValidationResource extends Resource $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) => [ 'class' => $get('validationError') ? 'border-red-500' : '', 'id' => 'item_id', @@ -960,6 +968,78 @@ class PanelBoxValidationResource extends Resource ]) ->hint(fn ($get) => $get('validationError') ? $get('validationError') : null) ->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') ->default([]) ->reactive() @@ -1767,6 +1847,11 @@ class PanelBoxValidationResource extends Resource ->alignCenter() ->searchable() ->sortable(), + Tables\Columns\TextColumn::make('rework_count') + ->label('Rework Count') + ->alignCenter() + ->searchable() + ->sortable(), Tables\Columns\TextColumn::make('created_at') ->label('Created At') ->alignCenter() From d676e2f6594f93b2833f144994ea87d3bf016b9e Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Wed, 26 Aug 2026 12:13:41 +0530 Subject: [PATCH 5/6] Added hiding logic of create button in panel box validation --- .../Pages/CreatePanelBoxValidation.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/Filament/Resources/PanelBoxValidationResource/Pages/CreatePanelBoxValidation.php b/app/Filament/Resources/PanelBoxValidationResource/Pages/CreatePanelBoxValidation.php index 00df2f0..2320a69 100644 --- a/app/Filament/Resources/PanelBoxValidationResource/Pages/CreatePanelBoxValidation.php +++ b/app/Filament/Resources/PanelBoxValidationResource/Pages/CreatePanelBoxValidation.php @@ -7,6 +7,7 @@ use App\Models\ProductCharacteristicsMaster; use Filament\Actions; use Filament\Resources\Pages\CreateRecord; use Illuminate\Validation\ValidationException; +use Filament\Actions\Action; class CreatePanelBoxValidation extends CreateRecord { @@ -37,6 +38,17 @@ class CreatePanelBoxValidation extends CreateRecord { { $this->create(); } + public function getCreateFormAction(): Action + { + return parent::getCreateFormAction() + ->visible(fn () => $this->data['serial_exists'] != true); + } + + protected function getCreateAnotherFormAction(): Action + { + return parent::getCreateAnotherFormAction() + ->visible(fn () => ($this->data['serial_exists'] ?? false) != true); + } public function mount(): void { @@ -75,7 +87,7 @@ class CreatePanelBoxValidation extends CreateRecord { } } - protected function checkIfHasCharacteristics(array $data) + public function checkIfHasCharacteristics(array $data) { $plantId = $data['plant_id'] ?? null; $itemCode = $data['item_id'] ?? null; From 3aaf8210402b960d7f22ee5dd94c14fe8acf64a0 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Wed, 26 Aug 2026 12:15:18 +0530 Subject: [PATCH 6/6] Added rework logic in panel check list livewire page --- app/Livewire/PanelCheckList.php | 92 ++++++++++++++++++++++----------- 1 file changed, 61 insertions(+), 31 deletions(-) diff --git a/app/Livewire/PanelCheckList.php b/app/Livewire/PanelCheckList.php index 01e180f..2eb25ed 100644 --- a/app/Livewire/PanelCheckList.php +++ b/app/Livewire/PanelCheckList.php @@ -113,14 +113,14 @@ public $records = []; $plan = Plant::find($this->data['plant_id']); - if ($exists) { - Notification::make() - ->title('Duplicate Serial Number') - ->body("serial number {$this->data['serial_number']} already exists for the selected plant $plan->code.") - ->danger() - ->send(); - return; - } + // if ($exists) { + // Notification::make() + // ->title('Duplicate Serial Number') + // ->body("serial number {$this->data['serial_number']} already exists for the selected plant $plan->code.") + // ->danger() + // ->send(); + // return; + // } if(!$this->selectForNotOk){ @@ -177,29 +177,59 @@ public $records = []; } } - $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, - ]); + $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, + ]); + } if (! $qualityValidation || ! $qualityValidation->exists) { Notification::make()