From 1b2708dd79736c789750db36e35d50216e78b1da Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Thu, 26 Nov 2026 19:33:43 +0530 Subject: [PATCH] changed logic in panel box validation checklist --- app/Livewire/PanelCheckList.php | 62 +++++++++++++++------------------ 1 file changed, 29 insertions(+), 33 deletions(-) diff --git a/app/Livewire/PanelCheckList.php b/app/Livewire/PanelCheckList.php index ca633dfb..f0104c63 100644 --- a/app/Livewire/PanelCheckList.php +++ b/app/Livewire/PanelCheckList.php @@ -193,34 +193,30 @@ public $records = []; } } - $latestReworkRecord = PanelBoxValidation::where('plant_id', $this->data['plant_id'] ?? null)->where('serial_number', $this->data['serial_number'] ?? null)->latest()->first(); + $qualityValidation = null; + + $latestReworkRecord = PanelBoxValidation::where('plant_id', $this->data['plant_id'] ?? null)->where('serial_number', $this->data['serial_number'] ?? null)->where('panel_box_supplier', $this->data['panel_box_supplier'] ?? null)->first(); + + if ($latestReworkRecord && $latestReworkRecord->status == 'Ok') { + + Notification::make() + ->title('Rework Not Allowed') + ->body('This Panel Box has already passed inspection. Rework is not allowed.') + ->warning() + ->send(); + + return; + } if($latestReworkRecord){ + + $reworkCount = $latestReworkRecord + ? ((int) $latestReworkRecord->rework_count + 1) + : 0; try{ - $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, - 'status' => $this->selectForNotOk ? 'NotOk' : 'Ok', - 'created_by' => $this->data['created_by'] ?? null, - 'updated_by' => $this->data['updated_by'] ?? null, + $latestReworkRecord->update([ + 'rework_count' => $reworkCount, + 'status' => $this->selectForNotOk ? 'NotOk' : 'Ok', ]); } catch (\Illuminate\Database\QueryException $e) { @@ -259,14 +255,14 @@ public $records = []; ]); } - if (! $qualityValidation || ! $qualityValidation->exists) { - Notification::make() - ->title('Failed to save Panel Box Validation') - ->body('Something went wrong while inserting data.') - ->danger() - ->send(); - return; - } + // if (! $qualityValidation || ! $qualityValidation->exists) { + // Notification::make() + // ->title('Failed to save Panel Box Validation') + // ->body('Something went wrong while inserting data.') + // ->danger() + // ->send(); + // return; + // } // if($this->selectForNotOk){ -- 2.49.1