Compare commits
6 Commits
a383aa00ed
...
9c1203df67
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9c1203df67 | ||
|
|
7cd0db415c | ||
|
|
a838faf5d0 | ||
|
|
55f734c536 | ||
|
|
a8b34fe1f3 | ||
|
|
6160d91357 |
@@ -7,6 +7,7 @@ use App\Filament\Resources\BlockResource\Pages;
|
||||
use App\Models\Block;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Get;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
@@ -58,6 +59,7 @@ class BlockResource extends Resource
|
||||
// ->unique(ignoreRecord: true)
|
||||
->required()
|
||||
->reactive()
|
||||
->disabled(fn (Get $get) => !empty($get('id')))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$nameId = $get('plant_id');
|
||||
// Ensure `linestop_id` is not cleared
|
||||
@@ -75,6 +77,9 @@ class BlockResource extends Resource
|
||||
])
|
||||
->hint(fn ($get) => $get('bPlantError') ? $get('bPlantError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\TextInput::make('id')
|
||||
->hidden()
|
||||
->readOnly(),
|
||||
])
|
||||
->columns(2),
|
||||
]);
|
||||
|
||||
@@ -8,6 +8,7 @@ use App\Filament\Resources\ItemResource\Pages;
|
||||
use App\Models\Item;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Get;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
@@ -38,6 +39,7 @@ class ItemResource extends Resource
|
||||
->required()
|
||||
// ->nullable(),
|
||||
->reactive()
|
||||
->disabled(fn (Get $get) => !empty($get('id')))
|
||||
// ->afterStateUpdated(fn ($set) => $set('block_id', null) & $set('name', null) & $set('start_time', null) & $set('duration', null) & $set('end_time', null))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
@@ -64,6 +66,7 @@ class ItemResource extends Resource
|
||||
->minLength(6)
|
||||
// ->autocapitalize('characters')
|
||||
->reactive()
|
||||
->disabled(fn (Get $get) => !empty($get('id')))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$code = $get('code');
|
||||
// Ensure `linestop_id` is not cleared
|
||||
@@ -123,6 +126,9 @@ class ItemResource extends Resource
|
||||
->required()
|
||||
->placeholder('Scan the valid description'),
|
||||
// ->columnSpanFull(),
|
||||
Forms\Components\TextInput::make('id')
|
||||
->hidden()
|
||||
->readOnly(),
|
||||
])
|
||||
->columns(2),
|
||||
]);
|
||||
|
||||
@@ -8,6 +8,7 @@ use App\Filament\Resources\LineResource\RelationManagers;
|
||||
use App\Models\Line;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Get;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
@@ -33,97 +34,101 @@ class LineResource extends Resource
|
||||
Section::make('')
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->relationship('plant', 'name')
|
||||
->required()
|
||||
// ->nullable(),
|
||||
->reactive()
|
||||
// ->afterStateUpdated(fn ($set) => $set('block_id', null) & $set('name', null) & $set('start_time', null) & $set('duration', null) & $set('end_time', null))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
// Ensure `linestop_id` is not cleared
|
||||
if (!$plantId) {
|
||||
$set('lPlantError', 'Please select a plant first.');
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$set('lPlantError', null);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('lPlantError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('lPlantError') ? $get('lPlantError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\TextInput::make('name')
|
||||
->required()
|
||||
->placeholder('Scan the valid name')
|
||||
// ->unique(
|
||||
// ignoreRecord: true,
|
||||
// modifyRuleUsing: function (Unique $rule) {
|
||||
// return $rule->where('plant_id', $this->data['plant_id']);
|
||||
// }
|
||||
// )
|
||||
// ->rule(function () {
|
||||
// return function ($attribute, $value, $fail) {
|
||||
// $exists = Line::where('name', $value)
|
||||
// ->where('plant_id', request()->input('plant_id'))
|
||||
// ->exists();
|
||||
|
||||
// if ($exists) {
|
||||
// $fail('The combination of name and plant ID must be unique.');
|
||||
// }
|
||||
// };
|
||||
// })
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$lineNam = $get('name');
|
||||
// Ensure `linestop_id` is not cleared
|
||||
if (!$lineNam) {
|
||||
$set('lNameError', 'Scan the valid name.');
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$exists = Line::where('name', $lineNam)
|
||||
->where('plant_id', $get('plant_id'))
|
||||
->exists();
|
||||
|
||||
if ($exists) {
|
||||
$set('name', null);
|
||||
$set('lNameError', 'The name has already been taken.');
|
||||
// $set('lNameError', 'The combination of name and plant ID must be unique.');
|
||||
->relationship('plant', 'name')
|
||||
->required()
|
||||
// ->nullable(),
|
||||
->reactive()
|
||||
->disabled(fn (Get $get) => !empty($get('id')))
|
||||
// ->afterStateUpdated(fn ($set) => $set('block_id', null) & $set('name', null) & $set('start_time', null) & $set('duration', null) & $set('end_time', null))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
// Ensure `linestop_id` is not cleared
|
||||
if (!$plantId) {
|
||||
$set('lPlantError', 'Please select a plant first.');
|
||||
return;
|
||||
}
|
||||
$set('lNameError', null);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('lNameError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('lNameError') ? $get('lNameError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\TextInput::make('type')
|
||||
->required()
|
||||
->placeholder('Scan the valid type')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$lineTyp = $get('type');
|
||||
// Ensure `linestop_id` is not cleared
|
||||
if (!$lineTyp) {
|
||||
$set('lTypeError', 'Scan the valid type.');
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$set('lTypeError', null);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('lTypeError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('lTypeError') ? $get('lTypeError') : null)
|
||||
->hintColor('danger'),
|
||||
else
|
||||
{
|
||||
$set('lPlantError', null);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('lPlantError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('lPlantError') ? $get('lPlantError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\TextInput::make('name')
|
||||
->required()
|
||||
->placeholder('Scan the valid name')
|
||||
// ->unique(
|
||||
// ignoreRecord: true,
|
||||
// modifyRuleUsing: function (Unique $rule) {
|
||||
// return $rule->where('plant_id', $this->data['plant_id']);
|
||||
// }
|
||||
// )
|
||||
// ->rule(function () {
|
||||
// return function ($attribute, $value, $fail) {
|
||||
// $exists = Line::where('name', $value)
|
||||
// ->where('plant_id', request()->input('plant_id'))
|
||||
// ->exists();
|
||||
|
||||
// if ($exists) {
|
||||
// $fail('The combination of name and plant ID must be unique.');
|
||||
// }
|
||||
// };
|
||||
// })
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$lineNam = $get('name');
|
||||
// Ensure `linestop_id` is not cleared
|
||||
if (!$lineNam) {
|
||||
$set('lNameError', 'Scan the valid name.');
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$exists = Line::where('name', $lineNam)
|
||||
->where('plant_id', $get('plant_id'))
|
||||
->exists();
|
||||
|
||||
if ($exists) {
|
||||
$set('name', null);
|
||||
$set('lNameError', 'The name has already been taken.');
|
||||
// $set('lNameError', 'The combination of name and plant ID must be unique.');
|
||||
return;
|
||||
}
|
||||
$set('lNameError', null);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('lNameError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('lNameError') ? $get('lNameError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\TextInput::make('type')
|
||||
->required()
|
||||
->placeholder('Scan the valid type')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$lineTyp = $get('type');
|
||||
// Ensure `linestop_id` is not cleared
|
||||
if (!$lineTyp) {
|
||||
$set('lTypeError', 'Scan the valid type.');
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$set('lTypeError', null);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('lTypeError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('lTypeError') ? $get('lTypeError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\TextInput::make('id')
|
||||
->hidden()
|
||||
->readOnly(),
|
||||
])
|
||||
->columns(2),
|
||||
]);
|
||||
|
||||
@@ -8,6 +8,7 @@ use App\Models\Plant;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Get;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
@@ -69,6 +70,7 @@ class PlantResource extends Resource
|
||||
->relationship('company', 'name')
|
||||
->required()
|
||||
->reactive()
|
||||
->disabled(fn (Get $get) => !empty($get('id')))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$companyId = $get('company_id');
|
||||
// Ensure `linestop_id` is not cleared
|
||||
@@ -132,6 +134,9 @@ class PlantResource extends Resource
|
||||
])
|
||||
->hint(fn ($get) => $get('pAddressError') ? $get('pAddressError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\TextInput::make('id')
|
||||
->hidden()
|
||||
->readOnly(),
|
||||
])
|
||||
->columns(2),
|
||||
]);
|
||||
|
||||
@@ -8,6 +8,7 @@ use App\Filament\Resources\ProductionLineStopResource\RelationManagers;
|
||||
use App\Models\ProductionLineStop;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Get;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
@@ -39,6 +40,7 @@ class ProductionLineStopResource extends Resource
|
||||
->required()
|
||||
// ->nullable()
|
||||
->reactive()
|
||||
->disabled(fn (Get $get) => !empty($get('id')))
|
||||
// ->afterStateUpdated(fn ($set) => $set('block_name', null))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
@@ -71,10 +73,31 @@ class ProductionLineStopResource extends Resource
|
||||
->toArray();
|
||||
})
|
||||
->reactive()
|
||||
// ->default(function (callable $get, callable $set) {
|
||||
// if ($get('id')) {
|
||||
// $getShift = ProductionLineStop::where('id', $get('id'))->first();
|
||||
// $getBlock = \App\Models\Shift::where('id', $getShift->shift_id)->first();
|
||||
// // dd($getBlock->block_id);
|
||||
// $set('block_name', $getBlock->block_id);
|
||||
// }
|
||||
// // return null; // Return null if no default value should be set
|
||||
// })
|
||||
// ->afterStateUpdated(fn ($set) => $set('shift_id', null))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
if($get('id'))
|
||||
{
|
||||
$getShift = ProductionLineStop::where('id', $get('id'))->first();
|
||||
$getBlock = \App\Models\Shift::where('id', $getShift->shift_id)->first();
|
||||
if($getBlock->block_id)
|
||||
{
|
||||
$set('block_name', $getBlock->block_id);
|
||||
$set('plsBlockError', null);
|
||||
}
|
||||
}
|
||||
|
||||
$blockId = $get('block_name');
|
||||
$set('shift_id', null);
|
||||
|
||||
if (!$blockId) {
|
||||
$set('plsBlockError', 'Please select a block first.');
|
||||
return;
|
||||
@@ -102,7 +125,6 @@ class ProductionLineStopResource extends Resource
|
||||
if (!$get('plant_id') || !$get('block_name')) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// // Get the block ID based on plant_id and block_name
|
||||
// $block = \App\Models\Block::where('plant_id', $get('plant_id'))
|
||||
// ->where('name', $get('block_name'))
|
||||
@@ -123,8 +145,19 @@ class ProductionLineStopResource extends Resource
|
||||
->reactive()
|
||||
// ->afterStateUpdated(fn ($set) => $set('line_id', null))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
if($get('id'))
|
||||
{
|
||||
$getShift = ProductionLineStop::where('id', $get('id'))->first();
|
||||
if($getShift->shift_id)
|
||||
{
|
||||
$set('shift_id', $getShift->shift_id);
|
||||
$set('plsShiftError', null);
|
||||
}
|
||||
}
|
||||
|
||||
$shiftId = $get('shift_id');
|
||||
$set('line_id', null);
|
||||
|
||||
if (!$shiftId) {
|
||||
$set('plsShiftError', 'Please select a shift first.');
|
||||
return;
|
||||
@@ -159,7 +192,18 @@ class ProductionLineStopResource extends Resource
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
if($get('id'))
|
||||
{
|
||||
$getShift = ProductionLineStop::where('id', $get('id'))->first();
|
||||
if($getShift->line_id)
|
||||
{
|
||||
$set('line_id', $getShift->line_id);
|
||||
$set('plsLineError', null);
|
||||
}
|
||||
}
|
||||
|
||||
$lineId = $get('line_id');
|
||||
|
||||
if (!$lineId) {
|
||||
$set('plsLineError', 'Please select a line first.');
|
||||
return;
|
||||
@@ -243,6 +287,9 @@ class ProductionLineStopResource extends Resource
|
||||
// ->dehydrated(false)
|
||||
->readOnly(true)
|
||||
->numeric(),
|
||||
Forms\Components\TextInput::make('id')
|
||||
->hidden()
|
||||
->readOnly(),
|
||||
])
|
||||
->columns(2),
|
||||
]);
|
||||
|
||||
@@ -8,6 +8,7 @@ use App\Filament\Resources\ProductionPlanResource\RelationManagers;
|
||||
use App\Models\ProductionPlan;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Get;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
@@ -38,6 +39,7 @@ class ProductionPlanResource extends Resource
|
||||
->required()
|
||||
// ->nullable()
|
||||
->reactive()
|
||||
->disabled(fn (Get $get) => !empty($get('id')))
|
||||
// ->afterStateUpdated(fn ($set) => $set('block_name', null))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
@@ -72,8 +74,20 @@ class ProductionPlanResource extends Resource
|
||||
->reactive()
|
||||
//->afterStateUpdated(fn ($set) => $set('shift_id', null))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
if($get('id'))
|
||||
{
|
||||
$getShift = ProductionPlan::where('id', $get('id'))->first();
|
||||
$getBlock = \App\Models\Shift::where('id', $getShift->shift_id)->first();
|
||||
if($getBlock->block_id)
|
||||
{
|
||||
$set('block_name', $getBlock->block_id);
|
||||
$set('ppBlockError', null);
|
||||
}
|
||||
}
|
||||
|
||||
$blockId = $get('block_name');
|
||||
$set('shift_id', null);
|
||||
|
||||
if (!$blockId) {
|
||||
$set('ppBlockError', 'Please select a block first.');
|
||||
return;
|
||||
@@ -105,8 +119,19 @@ class ProductionPlanResource extends Resource
|
||||
->reactive()
|
||||
// ->afterStateUpdated(fn ($set) => $set('line_id', null))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
if($get('id'))
|
||||
{
|
||||
$getShift = ProductionPlan::where('id', $get('id'))->first();
|
||||
if($getShift->shift_id)
|
||||
{
|
||||
$set('shift_id', $getShift->shift_id);
|
||||
$set('ppShiftError', null);
|
||||
}
|
||||
}
|
||||
|
||||
$shiftId = $get('shift_id');
|
||||
$set('line_id', null);
|
||||
|
||||
if (!$shiftId) {
|
||||
$set('ppShiftError', 'Please select a shift first.');
|
||||
return;
|
||||
@@ -141,7 +166,18 @@ class ProductionPlanResource extends Resource
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
if($get('id'))
|
||||
{
|
||||
$getShift = ProductionPlan::where('id', $get('id'))->first();
|
||||
if($getShift->line_id)
|
||||
{
|
||||
$set('line_id', $getShift->line_id);
|
||||
$set('ppLineError', null);
|
||||
}
|
||||
}
|
||||
|
||||
$lineId = $get('line_id');
|
||||
|
||||
if (!$lineId) {
|
||||
$set('ppLineError', 'Please select a line first.');
|
||||
return;
|
||||
@@ -172,19 +208,35 @@ class ProductionPlanResource extends Resource
|
||||
}
|
||||
else
|
||||
{
|
||||
$currentDate = date('Y-m-d');
|
||||
$shiftId = \App\Models\Shift::where('id', $get('shift_id'))
|
||||
->first();
|
||||
|
||||
if($shiftId->start_time > $shiftId->end_time)
|
||||
{
|
||||
$set('ppLineError', 'End time goes tomorrow...');
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$set('ppLineError', 'End time is within today...');
|
||||
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
||||
$hRs = (int) $hRs;
|
||||
$miNs = (int) $miNs;
|
||||
|
||||
$totalMinutes = $hRs * 60 + $miNs;
|
||||
|
||||
$from_dt = $currentDate . ' ' . $shiftId->start_time;
|
||||
|
||||
$to_dt = date('Y-m-d H:i:s', strtotime($from_dt . " + $totalMinutes minutes"));
|
||||
|
||||
$currentDateTime = date('Y-m-d H:i:s');
|
||||
|
||||
// Check if current date time is within the range
|
||||
if ($currentDateTime >= $from_dt && $currentDateTime < $to_dt) {
|
||||
//echo "Choosed a valid shift...";
|
||||
// $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
|
||||
$set('ppLineError', null);
|
||||
return;
|
||||
} else {
|
||||
// 'Invalid (From: '.$from_dt.', To: '.$to_dt.')'
|
||||
$set('ppLineError', 'Choosed a invalid shift...');
|
||||
return;
|
||||
}
|
||||
|
||||
// if($shiftId->start_time > $shiftId->end_time)
|
||||
}
|
||||
}
|
||||
$set('ppLineError', null);
|
||||
|
||||
@@ -8,6 +8,7 @@ use App\Filament\Resources\ProductionQuantityResource\RelationManagers;
|
||||
use App\Models\ProductionQuantity;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Get;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
@@ -37,6 +38,7 @@ class ProductionQuantityResource extends Resource
|
||||
->required()
|
||||
// ->nullable()
|
||||
->reactive()
|
||||
->disabled(fn (Get $get) => !empty($get('id')))
|
||||
// ->afterStateUpdated(fn ($set) => $set('block_name', null))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
@@ -71,8 +73,20 @@ class ProductionQuantityResource extends Resource
|
||||
->reactive()
|
||||
// ->afterStateUpdated(fn ($set) => $set('shift_id', null))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
if($get('id'))
|
||||
{
|
||||
$getShift = ProductionQuantity::where('id', $get('id'))->first();
|
||||
$getBlock = \App\Models\Shift::where('id', $getShift->shift_id)->first();
|
||||
if($getBlock->block_id)
|
||||
{
|
||||
$set('block_name', $getBlock->block_id);
|
||||
$set('pqBlockError', null);
|
||||
}
|
||||
}
|
||||
|
||||
$blockId = $get('block_name');
|
||||
$set('shift_id', null);
|
||||
|
||||
if (!$blockId) {
|
||||
$set('pqBlockError', 'Please select a block first.');
|
||||
return;
|
||||
@@ -105,8 +119,19 @@ class ProductionQuantityResource extends Resource
|
||||
->reactive()
|
||||
->afterStateUpdated(fn ($set) => $set('line_id', null))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
if($get('id'))
|
||||
{
|
||||
$getShift = ProductionQuantity::where('id', $get('id'))->first();
|
||||
if($getShift->shift_id)
|
||||
{
|
||||
$set('shift_id', $getShift->shift_id);
|
||||
$set('pqShiftError', null);
|
||||
}
|
||||
}
|
||||
|
||||
$shiftId = $get('shift_id');
|
||||
$set('line_id', null);
|
||||
|
||||
if (!$shiftId) {
|
||||
$set('pqShiftError', 'Please select a shift first.');
|
||||
return;
|
||||
@@ -142,7 +167,18 @@ class ProductionQuantityResource extends Resource
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
if($get('id'))
|
||||
{
|
||||
$getShift = ProductionQuantity::where('id', $get('id'))->first();
|
||||
if($getShift->line_id)
|
||||
{
|
||||
$set('line_id', $getShift->line_id);
|
||||
$set('pqLineError', null);
|
||||
}
|
||||
}
|
||||
|
||||
$lineId = $get('line_id');
|
||||
|
||||
$set('item_code', null);
|
||||
if (!$lineId) {
|
||||
$set('pqLineError', 'Please select a line first.');
|
||||
@@ -397,6 +433,9 @@ class ProductionQuantityResource extends Resource
|
||||
->readOnly(true)
|
||||
->autocapitalize('serial_number'),
|
||||
//->columnSpanFull(),
|
||||
Forms\Components\TextInput::make('id')
|
||||
->hidden()
|
||||
->readOnly(),
|
||||
])
|
||||
->columns(2),
|
||||
]);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -8,6 +8,7 @@ use App\Models\Shift;
|
||||
use Carbon\Carbon;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Get;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
@@ -37,6 +38,7 @@ class ShiftResource extends Resource
|
||||
->required()
|
||||
// ->nullable()
|
||||
->reactive()
|
||||
->disabled(fn (Get $get) => !empty($get('id')))
|
||||
// ->afterStateUpdated(fn ($set) => $set('block_id', null) & $set('name', null) & $set('start_time', null) & $set('duration', null) & $set('end_time', null))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
@@ -60,6 +62,7 @@ class ShiftResource extends Resource
|
||||
->required()
|
||||
// ->nullable()
|
||||
->reactive()
|
||||
->disabled(fn (Get $get) => !empty($get('id')))
|
||||
// ->options(fn (callable $get) =>
|
||||
// \App\Models\Block::where('plant_id', $get('plant_id'))
|
||||
// ->pluck('name', 'id')
|
||||
@@ -203,6 +206,9 @@ class ShiftResource extends Resource
|
||||
])
|
||||
->hint(fn ($get) => $get('sEndTimeError') ? $get('sEndTimeError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\TextInput::make('id')
|
||||
->hidden()
|
||||
->readOnly(),
|
||||
])
|
||||
->columns(2),
|
||||
]);
|
||||
|
||||
@@ -7,6 +7,7 @@ use App\Filament\Resources\StickerMasterResource\RelationManagers;
|
||||
use App\Models\StickerMaster;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Get;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
@@ -31,6 +32,7 @@ class StickerMasterResource extends Resource
|
||||
->relationship('plant', 'name')
|
||||
->reactive()
|
||||
->nullable()
|
||||
->disabled(fn (Get $get) => !empty($get('id'))) //disable in edit if user try to change
|
||||
->afterStateUpdated(fn (callable $set) =>
|
||||
$set('item_id', null) & $set('item_description', null)
|
||||
)
|
||||
@@ -51,10 +53,11 @@ class StickerMasterResource extends Resource
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->disabled(fn (Get $get) => !empty($get('id')))
|
||||
->live(debounce: 500) // Enable live updates
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$plantId = $get('plant_id'); // Get selected plant_id
|
||||
$itemId = $get('item_id'); // Get entered item_id
|
||||
$plantId = $get('plant_id');
|
||||
$itemId = $get('item_id');
|
||||
|
||||
// Ensure `item_id` is not cleared
|
||||
if (!$plantId || !$itemId) {
|
||||
@@ -74,112 +77,83 @@ class StickerMasterResource extends Resource
|
||||
}
|
||||
|
||||
}),
|
||||
// ->validationAttribute('Item Code')
|
||||
// ->rule('required')
|
||||
// ->extraAttributes(fn ($get) => [
|
||||
// 'class' => $get('validationError') ? 'border-red-500' : '',
|
||||
// ])
|
||||
// ->hint(fn ($get) => $get('validationError') ? $get('validationError') : null)
|
||||
// ->hintColor('danger'), // Show error in red under the input field
|
||||
|
||||
Forms\Components\TextInput::make('item_description')
|
||||
->label('Description')
|
||||
->required()
|
||||
->reactive()
|
||||
->readOnly(true),
|
||||
|
||||
//Forms\Components\Textarea::make('serial_number_motor'),
|
||||
Forms\Components\TextInput::make('item_description')
|
||||
->label('Description')
|
||||
->required()
|
||||
->reactive()
|
||||
->readOnly(true),
|
||||
|
||||
Forms\Components\TextInput::make('part_validation1')
|
||||
->nullable(),
|
||||
->nullable(),
|
||||
|
||||
Forms\Components\TextInput::make('part_validation2')
|
||||
->nullable(),
|
||||
->nullable(),
|
||||
|
||||
Forms\Components\TextInput::make('part_validation3')
|
||||
->nullable(),
|
||||
->nullable(),
|
||||
|
||||
Forms\Components\TextInput::make('part_validation4')
|
||||
->nullable(),
|
||||
->nullable(),
|
||||
|
||||
Forms\Components\TextInput::make('part_validation5')
|
||||
->nullable(),
|
||||
->nullable(),
|
||||
|
||||
Forms\Components\Checkbox::make('serial_number_motor')
|
||||
->nullable()
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||
|
||||
//Forms\Components\Textarea::make('serial_number_pump')
|
||||
->nullable()
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||
|
||||
Forms\Components\Checkbox::make('serial_number_pump')
|
||||
->nullable()
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||
|
||||
//Forms\Components\TextInput::make('serial_number_pumpset'),
|
||||
->nullable()
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||
|
||||
Forms\Components\Checkbox::make('serial_number_pumpset')
|
||||
->nullable()
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||
|
||||
//Forms\Components\TextInput::make('pack_slip_motor'),
|
||||
->nullable()
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||
|
||||
Forms\Components\Checkbox::make('pack_slip_motor')
|
||||
->nullable()
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||
|
||||
//Forms\Components\TextInput::make('pack_slip_pump'),
|
||||
|
||||
Forms\Components\Checkbox::make('pack_slip_pump')
|
||||
->nullable()
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||
|
||||
//Forms\Components\TextInput::make('pack_slip_pumpset'),
|
||||
|
||||
Forms\Components\Checkbox::make('pack_slip_pumpset')
|
||||
Forms\Components\Checkbox::make('pack_slip_pump')
|
||||
->nullable()
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||
|
||||
//Forms\Components\TextInput::make('name_plate_motor'),
|
||||
Forms\Components\Checkbox::make('pack_slip_pumpset')
|
||||
->nullable()
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||
|
||||
Forms\Components\Checkbox::make('name_plate_motor')
|
||||
->nullable()
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||
Forms\Components\Checkbox::make('name_plate_motor')
|
||||
->nullable()
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||
|
||||
//Forms\Components\TextInput::make('name_plate_pump'),
|
||||
Forms\Components\Checkbox::make('name_plate_pump')
|
||||
->nullable()
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||
|
||||
Forms\Components\Checkbox::make('name_plate_pump')
|
||||
->nullable()
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||
Forms\Components\Checkbox::make('name_plate_pumpset')
|
||||
->nullable()
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||
|
||||
//Forms\Components\TextInput::make('name_plate_pumpset'),
|
||||
|
||||
Forms\Components\Checkbox::make('name_plate_pumpset')
|
||||
->nullable()
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||
|
||||
//Forms\Components\TextInput::make('tube_sticker_motor'),
|
||||
|
||||
Forms\Components\Checkbox::make('tube_sticker_motor')
|
||||
->nullable()
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||
|
||||
//Forms\Components\TextInput::make('tube_sticker_pump'),
|
||||
Forms\Components\Checkbox::make('tube_sticker_motor')
|
||||
->nullable()
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||
|
||||
Forms\Components\Checkbox::make('tube_sticker_pump')
|
||||
->nullable()
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||
->nullable()
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||
|
||||
//Forms\Components\TextInput::make('tube_sticker_pumpset'),
|
||||
Forms\Components\Checkbox::make('tube_sticker_pumpset')
|
||||
->nullable()
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null), //to pass null value
|
||||
|
||||
Forms\Components\Checkbox::make('tube_sticker_pumpset')
|
||||
->nullable()
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||
Forms\Components\Checkbox::make('warranty_card')
|
||||
->nullable()
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||
|
||||
//Forms\Components\TextInput::make('warranty_card'),
|
||||
|
||||
Forms\Components\Checkbox::make('warranty_card')
|
||||
->nullable()
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||
Forms\Components\TextInput::make('id')
|
||||
->hidden()
|
||||
->readOnly(),
|
||||
|
||||
]);
|
||||
}
|
||||
@@ -190,74 +164,74 @@ class StickerMasterResource extends Resource
|
||||
->searchable()
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('id')
|
||||
->label('ID')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
->label('ID')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('item.code')
|
||||
->sortable(),
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->sortable(),
|
||||
->sortable(),
|
||||
Tables\Columns\CheckboxColumn::make('serial_number_motor')
|
||||
->disabled(true)
|
||||
->sortable(),
|
||||
->disabled(true)
|
||||
->sortable(),
|
||||
Tables\Columns\CheckboxColumn::make('serial_number_pump')
|
||||
->disabled(true)
|
||||
->sortable(),
|
||||
->disabled(true)
|
||||
->sortable(),
|
||||
Tables\Columns\CheckboxColumn::make('serial_number_pumpset')
|
||||
->disabled(true)
|
||||
->sortable(),
|
||||
->disabled(true)
|
||||
->sortable(),
|
||||
Tables\Columns\CheckboxColumn::make('pack_slip_motor')
|
||||
->disabled(true)
|
||||
->sortable(),
|
||||
->disabled(true)
|
||||
->sortable(),
|
||||
Tables\Columns\CheckboxColumn::make('pack_slip_pump')
|
||||
->disabled(true)
|
||||
->sortable(),
|
||||
->disabled(true)
|
||||
->sortable(),
|
||||
Tables\Columns\CheckboxColumn::make('pack_slip_pumpset')
|
||||
->disabled(true)
|
||||
->sortable(),
|
||||
->disabled(true)
|
||||
->sortable(),
|
||||
Tables\Columns\CheckboxColumn::make('name_plate_motor')
|
||||
->disabled(true)
|
||||
->sortable(),
|
||||
->disabled(true)
|
||||
->sortable(),
|
||||
Tables\Columns\CheckboxColumn::make('name_plate_pump')
|
||||
->disabled(true)
|
||||
->sortable(),
|
||||
->disabled(true)
|
||||
->sortable(),
|
||||
Tables\Columns\CheckboxColumn::make('name_plate_pumpset')
|
||||
->disabled(true)
|
||||
->sortable(),
|
||||
->disabled(true)
|
||||
->sortable(),
|
||||
Tables\Columns\CheckboxColumn::make('tube_sticker_motor')
|
||||
->disabled(true)
|
||||
->sortable(),
|
||||
->disabled(true)
|
||||
->sortable(),
|
||||
Tables\Columns\CheckboxColumn::make('tube_sticker_pump')
|
||||
->disabled(true)
|
||||
->sortable(),
|
||||
->disabled(true)
|
||||
->sortable(),
|
||||
Tables\Columns\CheckboxColumn::make('tube_sticker_pumpset')
|
||||
->disabled(true)
|
||||
->sortable(),
|
||||
->disabled(true)
|
||||
->sortable(),
|
||||
Tables\Columns\CheckboxColumn::make('warranty_card')
|
||||
->disabled(true)
|
||||
->sortable(),
|
||||
->disabled(true)
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('part_validation1')
|
||||
->sortable(),
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('part_validation2')
|
||||
->sortable(),
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('part_validation3')
|
||||
->sortable(),
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('part_validation4')
|
||||
->sortable(),
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('part_validation5')
|
||||
->sortable(),
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
|
||||
Reference in New Issue
Block a user