changed logic for select for not ok allowed for incomplete checklist #923
@@ -69,14 +69,16 @@ public $records = [];
|
|||||||
public function saveChecklist()
|
public function saveChecklist()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if(!$this->selectForNotOk){
|
||||||
|
|
||||||
if (empty($this->checklist) || count($this->checklist) != count($this->records)) {
|
if (empty($this->checklist) || count($this->checklist) != count($this->records)) {
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Incomplete Checklist')
|
->title('Incomplete Checklist')
|
||||||
->body('Please complete all checklist fields before submitting.')
|
->body('Please complete all checklist fields before submitting.')
|
||||||
->danger()
|
->danger()
|
||||||
->send();
|
->send();
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$item = Item::where('code', $this->data['item_id'])->first();
|
$item = Item::where('code', $this->data['item_id'])->first();
|
||||||
@@ -209,10 +211,58 @@ public $records = [];
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if($this->selectForNotOk){
|
||||||
|
|
||||||
|
// foreach ($this->checklist as $characteristicId => $value) {
|
||||||
|
|
||||||
|
// $characteristic = ProductCharacteristicsMaster::find($characteristicId);
|
||||||
|
|
||||||
|
// $itemCharacteristic = ProductCharacteristicsMaster::where('plant_id', $this->data['plant_id'])
|
||||||
|
// ->where('line_id', $this->data['line_id'])
|
||||||
|
// ->where('name', $characteristic->name)
|
||||||
|
// ->where('item_id', $itemId)
|
||||||
|
// ->first();
|
||||||
|
|
||||||
|
// if (($itemCharacteristic?->inspection_type ?? null) === 'Value') {
|
||||||
|
|
||||||
|
// if ($itemCharacteristic && is_numeric($value) && $value >= $itemCharacteristic->lower && $value <= $itemCharacteristic->upper
|
||||||
|
// ) {
|
||||||
|
// $status = 'Ok';
|
||||||
|
// } else {
|
||||||
|
// $status = 'NotOk';
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
// $status = $value;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// $prod = ProductionCharacteristic::create([
|
||||||
|
// 'plant_id' => $this->data['plant_id'] ?? null,
|
||||||
|
// 'item_id' => $itemId ?? null,
|
||||||
|
// 'line_id' => $this->data['line_id'] ?? null,
|
||||||
|
// 'machine_id' => $characteristic?->machine_id ?? null,
|
||||||
|
// 'production_order' => $this->data['production_order'] ?? null,
|
||||||
|
// 'serial_number' => $this->data['serial_number'] ?? null,
|
||||||
|
// 'characteristic_name' => $characteristic?->name ?? null,
|
||||||
|
// 'observed_value' => $value ?? null,
|
||||||
|
// 'status' => $status,
|
||||||
|
// 'inspection_status' => $finalInspectionStatus ?? 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($this->selectForNotOk){
|
if($this->selectForNotOk){
|
||||||
|
|
||||||
foreach ($this->checklist as $characteristicId => $value) {
|
foreach ($this->records as $record) {
|
||||||
|
|
||||||
|
$characteristicId = $record['id'];
|
||||||
|
|
||||||
|
$value = $this->checklist[$characteristicId] ?? null;
|
||||||
|
|
||||||
$characteristic = ProductCharacteristicsMaster::find($characteristicId);
|
$characteristic = ProductCharacteristicsMaster::find($characteristicId);
|
||||||
|
|
||||||
@@ -223,8 +273,10 @@ public $records = [];
|
|||||||
->first();
|
->first();
|
||||||
|
|
||||||
if (($itemCharacteristic?->inspection_type ?? null) === 'Value') {
|
if (($itemCharacteristic?->inspection_type ?? null) === 'Value') {
|
||||||
|
if ($value == null || $value == '') {
|
||||||
if ($itemCharacteristic && is_numeric($value) && $value >= $itemCharacteristic->lower && $value <= $itemCharacteristic->upper
|
$status = null;
|
||||||
|
}
|
||||||
|
else if ($itemCharacteristic && is_numeric($value) && $value >= $itemCharacteristic->lower && $value <= $itemCharacteristic->upper
|
||||||
) {
|
) {
|
||||||
$status = 'Ok';
|
$status = 'Ok';
|
||||||
} else {
|
} else {
|
||||||
@@ -232,7 +284,7 @@ public $records = [];
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$status = $value;
|
$status = !empty($value) ? $value : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$prod = ProductionCharacteristic::create([
|
$prod = ProductionCharacteristic::create([
|
||||||
@@ -251,7 +303,6 @@ public $records = [];
|
|||||||
'updated_by' => $this->data['updated_by'] ?? null,
|
'updated_by' => $this->data['updated_by'] ?? null,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
@@ -267,7 +318,7 @@ public $records = [];
|
|||||||
->where('item_id', $itemId)
|
->where('item_id', $itemId)
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
if (($itemCharacteristic?->inspection_type ?? null) === 'Value') {
|
if (($itemCharacteristic?->inspection_type ?? null) == 'Value') {
|
||||||
|
|
||||||
if ($itemCharacteristic && is_numeric($value) && $value >= $itemCharacteristic->lower && $value <= $itemCharacteristic->upper
|
if ($itemCharacteristic && is_numeric($value) && $value >= $itemCharacteristic->lower && $value <= $itemCharacteristic->upper
|
||||||
) {
|
) {
|
||||||
|
|||||||
Reference in New Issue
Block a user