diff --git a/app/Filament/Resources/PanelBoxValidationResource.php b/app/Filament/Resources/PanelBoxValidationResource.php index 04d0f7b1a9..f3a41e889a 100644 --- a/app/Filament/Resources/PanelBoxValidationResource.php +++ b/app/Filament/Resources/PanelBoxValidationResource.php @@ -844,7 +844,7 @@ class PanelBoxValidationResource extends Resource } } - $serialExists = PanelBoxValidation::where('serial_number', $serialNumber)->where('plant_id', $plantId)->where('panel_box_supplier', $supplier)->first(); + $serialExists = PanelBoxValidation::where('serial_number', $serialNumber)->where('plant_id', $plantId)->where('panel_box_supplier', $supplier)->where('status', '!=', '')->whereNotNull('status')->where('status', 'NotOk')->first(); if ($serialExists) { $set('serial_exists', true); @@ -852,6 +852,20 @@ class PanelBoxValidationResource extends Resource $set('serial_exists', false); } + $serialExistsPanel = PanelBoxValidation::where('serial_number', $serialNumber)->where('plant_id', $plantId)->where('panel_box_supplier', $supplier)->where('status', '!=', '')->whereNotNull('status')->where('status', 'Ok')->first(); + + if($serialExistsPanel){ + Notification::make() + ->title('Panel Box Already Validated') + ->body("Serial number '$serialNumber' for supplier '$supplier' has already been tested and marked as 'OK'") + ->success() + ->send(); + $set('item_id', null); + $set('serial_exists', false); + $set('validationError', null); + return; + } + // if ($serialExists && ! $get('id')) { // $set('validationError', 'Serial number already exists in panel box validation.'); // $set('sticker_master_id', null);