1
0
forked from poc/pds

Updated production_order validations

This commit is contained in:
dhanabalan
2025-04-24 13:27:55 +05:30
parent 757d9db536
commit 7078a99347

View File

@@ -298,6 +298,7 @@ class ProductionQuantityResource extends Resource
->reactive() ->reactive()
->required() ->required()
->columnSpan(2) ->columnSpan(2)
// ->rules(['regex:/^[1-9][0-9]{6,}$/'])
->disabled(function ($get) { ->disabled(function ($get) {
return $get('item_code'); return $get('item_code');
}) })
@@ -306,6 +307,16 @@ class ProductionQuantityResource extends Resource
// return $latestProductionOrder ?? null; // return $latestProductionOrder ?? null;
$latestProduction = ProductionQuantity::latest()->first(); $latestProduction = ProductionQuantity::latest()->first();
return $latestProduction ? $latestProduction->production_order : null; return $latestProduction ? $latestProduction->production_order : null;
})
->afterStateUpdated(function ($state, callable $get, callable $set): void {
$set('item_code', null);
$set('item_id', null);
// $set('item_description', null);
$set('serial_number', null);
$set('validationError', null);
return;
// if (empty($state)) {
// }
}), }),
Forms\Components\TextInput::make('item_code') Forms\Components\TextInput::make('item_code')
->label('Item Code') ->label('Item Code')
@@ -382,6 +393,49 @@ class ProductionQuantityResource extends Resource
->send(); ->send();
return; return;
} }
else if (!$get('production_order')) {
$set('item_code', null);
$set('item_id', null);
// $set('item_description', null);
$set('serial_number', null);
$set('validationError', 'Please scan the production order first.');
Notification::make()
->title('Scan the production order first.')
->danger()
->send();
return;
}
if(!is_numeric($get('production_order')))
{
$set('item_code', null);
$set('item_id', null);
// $set('item_description', null);
$set('serial_number', null);
$set('validationError', 'Please scan the valid production order.');
Notification::make()
->title('Invalid Production Order')
->body("Must contain numeric values only.")
->danger()
->send();
return;
}
else if (!preg_match('/^[1-9][0-9]{6,}$/', $get('production_order')))
{
$set('item_code', null);
$set('item_id', null);
// $set('item_description', null);
$set('serial_number', null);
$set('validationError', 'Please scan the valid production order first.');
Notification::make()
->title('Invalid Production Order')
->body("Must contain at least 7 digits.<br>Must start with a non-zero digit.")
->danger()
->send();
return;
}
// ******************************** // ********************************