changed logic in panel box validation checklist #1544

Merged
jothi merged 1 commits from ranjith-dev into master 2026-11-28 02:21:14 +00:00

View File

@@ -123,11 +123,11 @@ public $records = [];
$itemId = $itemAgaPlant->id;
$exists = PanelBoxValidation::where('plant_id', $this->data['plant_id'] ?? null)
->where('serial_number', $this->data['serial_number'] ?? null)
->first();
// $exists = PanelBoxValidation::where('plant_id', $this->data['plant_id'] ?? null)
// ->where('serial_number', $this->data['serial_number'] ?? null)
// ->first();
$plan = Plant::find($this->data['plant_id']);
// $plan = Plant::find($this->data['plant_id']);
// if ($exists) {
// Notification::make()
@@ -193,7 +193,7 @@ public $records = [];
}
}
$qualityValidation = null;
$panelBoxSaved = 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();
@@ -211,27 +211,17 @@ public $records = [];
if($latestReworkRecord){
$userName = Filament::auth()->user()?->name;
$reworkCount = $latestReworkRecord
? ((int) $latestReworkRecord->rework_count + 1)
: 0;
try{
$latestReworkRecord->update([
'rework_count' => $reworkCount,
'status' => $this->selectForNotOk ? 'NotOk' : 'Ok',
'updated_by' => $userName,
]);
}
catch (\Illuminate\Database\QueryException $e) {
Notification::make()
->title('Duplicate Record')
->body("Duplicate serial number found against doc number '{$this->data['production_order'] }' and inspection lot number '{$this->data['inspection_lot_number']}'.")
->danger()
->send();
return;
}
$reworkCount = $latestReworkRecord ? ((int) $latestReworkRecord->rework_count + 1) : 0;
$panelBoxSaved = $latestReworkRecord->update([
'rework_count' => $reworkCount,
'status' => $this->selectForNotOk ? 'NotOk' : 'Ok',
'updated_at' => now(),
'updated_by' => $userName,
]);
}
else{
$qualityValidation = PanelBoxValidation::create([
$panelBoxSaved = 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,
@@ -257,14 +247,15 @@ 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 (! $panelBoxSaved) {
Notification::make()
->title('Failed to Save Panel Box Validation')
->body('Unable to save or update Panel Box Validation. Please try again.')
->danger()
->send();
return;
}
// if($this->selectForNotOk){
@@ -311,6 +302,7 @@ public $records = [];
// }
$insertedCount = 0;
if($this->selectForNotOk){
$notOkCharacteristics = [];
@@ -459,11 +451,16 @@ public $records = [];
}
if (! $prod) {
$insertedCount++;
}
if ($insertedCount != count($this->records)) {
Notification::make()
->title('Failed to save Panel Box Validation')
->body('Something went wrong while inserting data.')
->title('Failed to Save Production Characteristics')
->body('One or more characteristic records were not inserted.')
->danger()
->send();
return;
}