Added select for not ok button in panel check list livewire page
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 28s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 17s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 27s
Laravel Larastan / larastan (pull_request) Failing after 5m19s
Laravel Pint / pint (pull_request) Successful in 4m41s

This commit is contained in:
dhanabalan
2026-08-20 09:21:48 +05:30
parent 38dc55ac7c
commit 579daf6a83
2 changed files with 147 additions and 42 deletions

View File

@@ -28,6 +28,8 @@ public $records = [];
public $showChecklist = false;
public bool $selectForNotOk = false;
// public $skipChecklistValidation = false;
// protected $listeners = ['focus-item-id' => 'handleFocus', 'trigger-create' => 'doCreate',];
@@ -66,6 +68,8 @@ public $records = [];
public function saveChecklist()
{
if (empty($this->checklist) || count($this->checklist) != count($this->records)) {
Notification::make()
->title('Incomplete Checklist')
@@ -116,6 +120,61 @@ public $records = [];
return;
}
if(!$this->selectForNotOk){
// First validate all checklist values
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) {
Notification::make()
->title('Characteristic Not Found')
->body("Characteristic '{$characteristic?->name}' was not found.")
->danger()
->send();
return;
}
if ($itemCharacteristic->inspection_type == 'Value') {
if (
!is_numeric($value) ||
$value < $itemCharacteristic->lower ||
$value > $itemCharacteristic->upper
) {
Notification::make()
->title('Invalid Value Selected')
->body("'{$characteristic->name}' must be between {$itemCharacteristic->lower} and {$itemCharacteristic->upper}.")
->danger()
->send();
return;
}
}
else {
// Visual inspection must always be OK
if (strtolower(trim($value)) != 'ok') {
Notification::make()
->title('Inspection Failed')
->body("You selected 'NotOk' for '{$characteristic->name}'. Please select 'OK' to continue.")
->danger()
->send();
return;
}
}
}
}
$qualityValidation = PanelBoxValidation::create([
'plant_id' => $this->data['plant_id'] ?? null,
'line_id' => $this->data['line_id'] ?? null,
@@ -135,7 +194,9 @@ public $records = [];
'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) {
@@ -148,57 +209,93 @@ public $records = [];
return;
}
foreach ($this->checklist as $characteristicId => $value) {
if($this->selectForNotOk){
// $status = 'Ok';
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();
$characteristic = ProductCharacteristicsMaster::find($characteristicId);
// if (($characteristic?->inspection_type ?? null) === 'Value') {
// if ($characteristic && is_numeric($value) && (($value >= $characteristic->lower && $value <= $characteristic->upper) || $value == $characteristic->lower || $value == $characteristic->upper)
// ) {
// $status = 'Ok';
// } else {
// $status = 'NotOk';
// }
// }
// else {
// $status = $value;
// }
$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?->inspection_type ?? null) === 'Value') {
if ($itemCharacteristic && is_numeric($value) && $value >= $itemCharacteristic->lower && $value <= $itemCharacteristic->upper
) {
$status = 'Ok';
} else {
$status = 'NotOk';
if ($itemCharacteristic && is_numeric($value) && $value >= $itemCharacteristic->lower && $value <= $itemCharacteristic->upper
) {
$status = 'Ok';
} else {
$status = 'NotOk';
}
}
}
else {
$status = $value;
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,
]);
}
$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,
'created_by' => $this->data['created_by'] ?? null,
'updated_by' => $this->data['updated_by'] ?? null,
]);
}
else {
//All validations Passed
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 (! $prod) {

View File

@@ -119,6 +119,14 @@
@endif
<div class="border-t mt-6 pt-4 flex justify-end gap-3">
<label class="flex items-center gap-2">
<input
type="checkbox"
wire:model.live="selectForNotOk"
>
<span>Select for Not Ok</span>
</label>
<button
type="button"
wire:click="cancel"