diff --git a/app/Filament/Pages/ProductionQuantityPage.php b/app/Filament/Pages/ProductionQuantityPage.php
index 342438f91..29a8411c8 100644
--- a/app/Filament/Pages/ProductionQuantityPage.php
+++ b/app/Filament/Pages/ProductionQuantityPage.php
@@ -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.
Must start with a non-zero digit.")
+ ->body("Must be a numeric value with 7 to 14 digits.
Must start with a non-zero digit.")
->danger()
->send();
return;
diff --git a/app/Filament/Pages/StickerReprint.php b/app/Filament/Pages/StickerReprint.php
index ef9e75610..37f347f29 100644
--- a/app/Filament/Pages/StickerReprint.php
+++ b/app/Filament/Pages/StickerReprint.php
@@ -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.
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.
Must start with a non-zero digit.")
+ ->danger()
+ ->send();
+ return;
+ }
+ }
// ********************************
diff --git a/app/Filament/Resources/ProductionQuantityResource.php b/app/Filament/Resources/ProductionQuantityResource.php
index 32a3360a1..791b10d2d 100644
--- a/app/Filament/Resources/ProductionQuantityResource.php
+++ b/app/Filament/Resources/ProductionQuantityResource.php
@@ -319,8 +319,10 @@ class ProductionQuantityResource extends Resource
->label('Production Order')
->reactive()
->required()
+ ->minLength(7)
+ ->maxLength(14)
->columnSpan(2)
- // ->rules(['regex:/^[1-9][0-9]{6,}$/'])
+ //->rules(['regex:/^[1-9][0-9]{6,}$/'])
// ->disabled(function ($get) {
// return $get('item_code');
// })
@@ -332,15 +334,35 @@ class ProductionQuantityResource extends Resource
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)) {
- // }
- }),
+ if(!is_numeric($get('production_order')) || !preg_match('/^[1-9][0-9]{6,13}$/', $get('production_order')))
+ {
+ $set('item_code', null);
+ $set('item_id', null);
+ $set('serial_number', null);
+ $set('production_order', null);
+ $set('prodOrdError', "Must be a numeric value with 7 to 14 digits.");
+ $set('validationError', null);
+ return;
+ }
+ else
+ {
+ $set('item_code', null);
+ $set('item_id', null);
+ // $set('item_description', null);
+ $set('serial_number', null);
+ $set('production_order', $state);
+ $set('prodOrdError', null);
+ $set('validationError', null);
+ return;
+ // if (empty($state)) {
+ // }
+ }
+ })
+ ->extraAttributes(fn ($get) => [
+ 'class' => $get('prodOrdError') ? 'border-red-500' : '',
+ ])
+ ->hint(fn ($get) => $get('prodOrdError') ? $get('prodOrdError') : null)
+ ->hintColor('danger'),
Forms\Components\TextInput::make('item_code')
->label('Item Code')
// ->required()
diff --git a/app/Filament/Resources/ProductionQuantityResource/Pages/CreateProductionQuantity.php b/app/Filament/Resources/ProductionQuantityResource/Pages/CreateProductionQuantity.php
index a0df95869..2ac9ba6fd 100644
--- a/app/Filament/Resources/ProductionQuantityResource/Pages/CreateProductionQuantity.php
+++ b/app/Filament/Resources/ProductionQuantityResource/Pages/CreateProductionQuantity.php
@@ -335,7 +335,7 @@ class CreateProductionQuantity extends CreateRecord
->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,
@@ -354,7 +354,7 @@ class CreateProductionQuantity extends CreateRecord
Notification::make()
->title('Invalid Production Order')
- ->body("Must contain at least 7 digits.
Must start with a non-zero digit.")
+ ->body("Must be a numeric value with 7 to 14 digits.
Must start with a non-zero digit.")
->danger()
->seconds(2)
->send();
diff --git a/app/Filament/Resources/QualityValidationResource.php b/app/Filament/Resources/QualityValidationResource.php
index 6c28e0eef..187ab9475 100644
--- a/app/Filament/Resources/QualityValidationResource.php
+++ b/app/Filament/Resources/QualityValidationResource.php
@@ -127,31 +127,31 @@ class QualityValidationResource extends Resource
Forms\Components\TextInput::make('production_order')
->placeholder('Scan the valid Production Order')
->minLength(7)
+ ->maxLength(14)
->reactive()
->readOnly(fn (callable $get) => $get('item_id'))
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
- if(!is_numeric($get('production_order')))
+ if(!is_numeric($get('production_order')) || !preg_match('/^[1-9][0-9]{6,13}$/', $get('production_order')))
{
- $set('productionError', "Must be a numeric value.");
+ $set('prodOrdError', "Must be a numeric value with 7 to 14 digits.");
$set('production_order', null);
$set('item_id', null);
$set('sticker_master_id', null);
$set('uom', null);
$set('serial_number', null);
- return;
}
else
{
- $set('productionError', null);
+ $set('prodOrdError', null);
+ $set('production_order', $state);
$set('production', $state);
}
-
})
->default(fn ($get) => $get('production') ?? session('last_selected_production'))
->extraAttributes(fn ($get) => [
- 'class' => $get('productionError') ? 'border-red-500' : '',
+ 'class' => $get('prodOrdError') ? 'border-red-500' : '',
])
- ->hint(fn ($get) => $get('productionError') ? $get('productionError') : null)
+ ->hint(fn ($get) => $get('prodOrdError') ? $get('prodOrdError') : null)
->hintColor('danger')
->required(),
@@ -187,11 +187,12 @@ class QualityValidationResource extends Resource
$pOrder = $get('production_order');
if (!$pOrder)
{
- $set('productionError', 'Production Order cant be empty.');
+ $set('prodOrdError', "Production Order can't be empty.");
+ $set('production_order', null);
}
else
{
- $set('productionError', null);
+ $set('prodOrdError', null);
}
$serialFields = [
@@ -333,9 +334,9 @@ class QualityValidationResource extends Resource
$set('serial_number', null);
return;
}
- elseif(!is_numeric($get('production_order')))
+ else if(!is_numeric($get('production_order')) || !preg_match('/^[1-9][0-9]{6,13}$/', $get('production_order')))
{
- $set('productionError', "Must be a numeric value.");
+ $set('prodOrdError', "Must be a numeric value.");
$set('item_id', null);
$set('sticker_master_id', null);
$set('uom', null);