From 7a5acc0a0df6fe1aa9f6d8ca3fe167f7c9d3a638 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Sat, 28 Nov 2026 11:42:49 +0530 Subject: [PATCH] changed logic in panel check list --- app/Livewire/PanelCheckList.php | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/app/Livewire/PanelCheckList.php b/app/Livewire/PanelCheckList.php index a1fb020d..2a370168 100644 --- a/app/Livewire/PanelCheckList.php +++ b/app/Livewire/PanelCheckList.php @@ -303,6 +303,9 @@ public $records = []; $insertedCount = 0; + $expectedCount = $this->selectForNotOk ? count($this->records) : count($this->checklist); + + if($this->selectForNotOk){ $notOkCharacteristics = []; @@ -313,7 +316,12 @@ public $records = []; $value = $this->checklist[$characteristicId] ?? null; - $characteristic = ProductCharacteristicsMaster::find($characteristicId); + // $characteristic = ProductCharacteristicsMaster::find($characteristicId); + $characteristic = ProductCharacteristicsMaster::where('id', $characteristicId) + ->where('plant_id', $this->data['plant_id']) + ->where('item_id', $itemId) + ->where('line_id', $this->data['line_id']) + ->first(); $itemCharacteristic = ProductCharacteristicsMaster::where('plant_id', $this->data['plant_id']) ->where('line_id', $this->data['line_id']) @@ -360,6 +368,10 @@ public $records = []; 'updated_by' => $this->data['updated_by'] ?? null, ]); + if ($prod) { + $insertedCount++; + } + $notOkCharacteristics[] = [ 'characteristic_name' => $characteristic?->name ?? null, 'observed_value' => $value ?? null, @@ -411,7 +423,12 @@ public $records = []; //All validations Passed foreach ($this->checklist as $characteristicId => $value) { - $characteristic = ProductCharacteristicsMaster::find($characteristicId); + // $characteristic = ProductCharacteristicsMaster::find($characteristicId); + $characteristic = ProductCharacteristicsMaster::where('id', $characteristicId) + ->where('plant_id', $this->data['plant_id']) + ->where('item_id', $itemId) + ->where('line_id', $this->data['line_id']) + ->first(); $itemCharacteristic = ProductCharacteristicsMaster::where('plant_id', $this->data['plant_id']) ->where('line_id', $this->data['line_id']) @@ -447,6 +464,10 @@ public $records = []; 'created_by' => $this->data['created_by'] ?? null, 'updated_by' => $this->data['updated_by'] ?? null, ]); + + if ($prod) { + $insertedCount++; + } } } @@ -460,7 +481,7 @@ public $records = []; // return; // } - if ($insertedCount != count($this->records)) { + if ($insertedCount != $expectedCount) { Notification::make() ->title('Failed to Save Production Characteristics') ->body('One or more characteristic records were not inserted.') -- 2.49.1