1
0
forked from poc/pds

Enhance production order validation to require numeric values with 7 to 14 digits across multiple resources

This commit is contained in:
dhanabalan
2025-08-04 19:35:50 +05:30
parent 68d4240ab0
commit d6c77bd6c3
5 changed files with 164 additions and 101 deletions

View File

@@ -320,23 +320,44 @@ class ProductionQuantityPage extends Page implements HasForms
->hintColor('danger'),
TextInput::make('production_order')
->label('Production Order')
->reactive()
->required()
//->columnSpan(1)
->columnSpan(['default' => 1, 'sm' => 1])
->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);
$this->prodOrder = $state;
return;
// if (empty($state)) {
// }
}),
->label('Production Order')
->reactive()
->required()
->minLength(7)
->maxLength(14)
//->columnSpan(1)
->columnSpan(['default' => 1, 'sm' => 1])
->afterStateUpdated(function ($state, callable $get, callable $set): void {
if(!is_numeric($get('production_order')) || !preg_match('/^[1-9][0-9]{6,13}$/', $get('production_order')))
{
$set('productionError', "Must be a numeric value with 7 to 14 digits.");
$set('production_order', null);
$set('item_code', null);
$set('item_id', null);
// $set('item_description', null);
$set('serial_number', null);
$set('validationError', null);
$this->prodOrder = null;
}
else
{
$set('productionError', null);
$set('production_order', $state);
$set('item_code', null);
$set('item_id', null);
// $set('item_description', null);
$set('serial_number', null);
$set('validationError', null);
$this->prodOrder = $state;
// if (empty($state)) {
// }
}
})
->extraAttributes(fn ($get) => [
'class' => $get('productionError') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('productionError') ? $get('productionError') : null)
->hintColor('danger'),
// TextInput::make('item_code')
// ->label('Item Code')
@@ -592,7 +613,7 @@ class ProductionQuantityPage extends Page implements HasForms
->send();
return;
}
else if (!preg_match('/^[1-9][0-9]{6,}$/', $this->prodOrder))
else if (!preg_match('/^[1-9][0-9]{6,13}$/', $this->prodOrder))
{
$this->form->fill([
'plant_id'=> $this->pId,
@@ -611,7 +632,7 @@ class ProductionQuantityPage extends Page implements HasForms
Notification::make()
->title('Invalid Production Order')
->body("Must contain at least 7 digits.<br>Must start with a non-zero digit.")
->body("Must be a numeric value with 7 to 14 digits.<br>Must start with a non-zero digit.")
->danger()
->send();
return;

View File

@@ -313,23 +313,40 @@ class StickerReprint extends Page implements HasForms
TextInput::make('production_order')
->label('Production Order')
->minLength(7)
->maxLength(14)
->reactive()
//->required()
//->columnSpan(1)
->columnSpan(['default' => 1, 'sm' => 1])
->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);
$this->prodOrder = $state;
return;
// if (empty($state)) {
// }
}),
if(!is_numeric($get('production_order')) || !preg_match('/^[1-9][0-9]{6,13}$/', $get('production_order')))
{
$set('productionError', "Must be a numeric value with 7 to 14 digits.");
$set('production_order', null);
$set('item_code', null);
$set('item_id', null);
$set('serial_number', null);
$this->prodOrder = null;
}
else
{
$set('productionError', null);
$set('production_order', $state);
$set('item_code', null);
$set('item_id', null);
// $set('item_description', null);
$set('serial_number', null);
$this->prodOrder = $state;
// if (empty($state)) {
// }
}
})
->extraAttributes(fn ($get) => [
'class' => $get('productionError') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('productionError') ? $get('productionError') : null)
->hintColor('danger'),
// TextInput::make('item_code')
// ->label('Item Code')
// ->columnSpan(1)
@@ -565,55 +582,57 @@ class StickerReprint extends Page implements HasForms
// ->send();
// return;
// }
else if ($this->prodOrder)
{
if(!is_numeric($this->prodOrder))
{
$this->form->fill([
'plant_id'=> $this->pId,
'block_name'=> $this->bId,
'shift_id'=> $this->sId,
'line_id'=> $this->lId,
'item_id'=> null,
'serial_number'=> null,
'success_msg'=> null,
'production_order'=> null,
'sap_msg_status' => null,
'sap_msg_description' => null,
'operator_id'=> $operatorName,
'recent_qr' => $this->recQr,
]);
// if(!is_numeric($this->prodOrder))
// {
// $this->form->fill([
// 'plant_id'=> $this->pId,
// 'block_name'=> $this->bId,
// 'shift_id'=> $this->sId,
// 'line_id'=> $this->lId,
// 'item_id'=> null,
// 'serial_number'=> null,
// 'success_msg'=> null,
// 'production_order'=> null,
// 'sap_msg_status' => null,
// 'sap_msg_description' => null,
// 'operator_id'=> $operatorName,
// 'recent_qr' => $this->recQr,
// ]);
Notification::make()
->title('Invalid Production Order')
->body("Must contain numeric values only.")
->danger()
->send();
return;
}
else if (!preg_match('/^[1-9][0-9]{6,13}$/', $this->prodOrder))
{
$this->form->fill([
'plant_id'=> $this->pId,
'block_name'=> $this->bId,
'shift_id'=> $this->sId,
'line_id'=> $this->lId,
'item_id'=> null,
'serial_number'=> null,
'success_msg'=> null,
'production_order'=> null,
'sap_msg_status' => null,
'sap_msg_description' => null,
'operator_id'=> $operatorName,
'recent_qr' => $this->recQr,
]);
// Notification::make()
// ->title('Invalid Production Order')
// ->body("Must contain numeric values only.")
// ->danger()
// ->send();
// return;
// }
// else if (!preg_match('/^[1-9][0-9]{6,}$/', $this->prodOrder))
// {
// $this->form->fill([
// 'plant_id'=> $this->pId,
// 'block_name'=> $this->bId,
// 'shift_id'=> $this->sId,
// 'line_id'=> $this->lId,
// 'item_id'=> null,
// 'serial_number'=> null,
// 'success_msg'=> null,
// 'production_order'=> null,
// 'sap_msg_status' => null,
// 'sap_msg_description' => null,
// 'operator_id'=> $operatorName,
// 'recent_qr' => $this->recQr,
// ]);
// Notification::make()
// ->title('Invalid Production Order')
// ->body("Must contain at least 7 digits.<br>Must start with a non-zero digit.")
// ->danger()
// ->send();
// return;
// }
Notification::make()
->title('Invalid Production Order')
->body("Must be a numeric value with 7 to 14 digits.<br>Must start with a non-zero digit.")
->danger()
->send();
return;
}
}
// ********************************