Compare commits
2 Commits
6907083ec0
...
734ab9dfdc
| Author | SHA1 | Date | |
|---|---|---|---|
| 734ab9dfdc | |||
|
|
b9a9a2fd5f |
@@ -25,6 +25,7 @@ use Filament\Tables\Filters\Filter;
|
|||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||||
|
use Str;
|
||||||
|
|
||||||
class CharacteristicValueResource extends Resource
|
class CharacteristicValueResource extends Resource
|
||||||
{
|
{
|
||||||
@@ -187,14 +188,71 @@ class CharacteristicValueResource extends Resource
|
|||||||
Forms\Components\TextInput::make('observed_value')
|
Forms\Components\TextInput::make('observed_value')
|
||||||
->label('Observed Value')
|
->label('Observed Value')
|
||||||
->reactive()
|
->reactive()
|
||||||
|
->afterStateUpdated(function ($state, $set, callable $get) {
|
||||||
|
$plantId = $get('plant_id');
|
||||||
|
$itemId = $get('item_id');
|
||||||
|
$lineId = $get('line_id');
|
||||||
|
$machineId = $get('machine_id');
|
||||||
|
|
||||||
|
if (! $plantId || ! $itemId || ! $lineId || ! $machineId) {
|
||||||
|
$set('status', 'NotOk');
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Str::length($state) <= 0 || ! is_numeric($state) || ! preg_match('/^\d+(\.\d+)?$/', $state)
|
||||||
|
) {
|
||||||
|
$set('status', 'NotOk');
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$specVal = ProductCharacteristicsMaster::where('plant_id', $plantId)->where('item_id', $itemId)->where('line_id', $lineId)->where('machine_id', $machineId)->first();
|
||||||
|
if (! $specVal) {
|
||||||
|
$set('status', 'NotOk');
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$lowLimit = $specVal?->lower ?? 0;
|
||||||
|
$uppLimit = $specVal?->upper ?? 0;
|
||||||
|
|
||||||
|
if (Str::length($lowLimit) <= 0 || ! is_numeric($lowLimit) || ! preg_match('/^\d+(\.\d+)?$/', $lowLimit)
|
||||||
|
) {
|
||||||
|
$set('status', 'NotOk');
|
||||||
|
|
||||||
|
return;
|
||||||
|
} elseif (Str::length($uppLimit) <= 0 || ! is_numeric($uppLimit) || ! preg_match('/^\d+(\.\d+)?$/', $uppLimit)
|
||||||
|
) {
|
||||||
|
$set('status', 'NotOk');
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (($lowLimit == 0 && $uppLimit == 0) || ($uppLimit == 0)) {
|
||||||
|
$set('status', 'NotOk');
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($lowLimit > $state || $uppLimit < $state) {
|
||||||
|
$set('status', 'NotOk');
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$set('status', 'Ok');
|
||||||
|
})
|
||||||
->required(),
|
->required(),
|
||||||
Forms\Components\Select::make('status')
|
Forms\Components\TextInput::make('status')// Select
|
||||||
->label('Status')
|
->label('Status')
|
||||||
->options([
|
// ->options([
|
||||||
'Ok' => 'OK',
|
// 'Ok' => 'OK',
|
||||||
'NotOk' => 'Not Ok',
|
// 'NotOk' => 'Not Ok',
|
||||||
])
|
// ])
|
||||||
->reactive()
|
->reactive()
|
||||||
|
->default('NotOk')
|
||||||
|
->readOnly()
|
||||||
->required(),
|
->required(),
|
||||||
Forms\Components\Hidden::make('created_by')
|
Forms\Components\Hidden::make('created_by')
|
||||||
->label('Created By')
|
->label('Created By')
|
||||||
|
|||||||
Reference in New Issue
Block a user