changed logic in panel check list #1550

Merged
jothi merged 1 commits from ranjith-dev into master 2026-11-28 06:13:04 +00:00

View File

@@ -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.')