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 App\Models\Block;
|
||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
|
use Filament\Forms\Get;
|
||||||
use Filament\Resources\Resource;
|
use Filament\Resources\Resource;
|
||||||
use Filament\Tables;
|
use Filament\Tables;
|
||||||
use Filament\Tables\Actions\ImportAction;
|
use Filament\Tables\Actions\ImportAction;
|
||||||
@@ -58,6 +59,7 @@ class BlockResource extends Resource
|
|||||||
// ->unique(ignoreRecord: true)
|
// ->unique(ignoreRecord: true)
|
||||||
->required()
|
->required()
|
||||||
->reactive()
|
->reactive()
|
||||||
|
->disabled(fn (Get $get) => !empty($get('id')))
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$nameId = $get('plant_id');
|
$nameId = $get('plant_id');
|
||||||
// Ensure `linestop_id` is not cleared
|
// Ensure `linestop_id` is not cleared
|
||||||
@@ -75,6 +77,9 @@ class BlockResource extends Resource
|
|||||||
])
|
])
|
||||||
->hint(fn ($get) => $get('bPlantError') ? $get('bPlantError') : null)
|
->hint(fn ($get) => $get('bPlantError') ? $get('bPlantError') : null)
|
||||||
->hintColor('danger'),
|
->hintColor('danger'),
|
||||||
|
Forms\Components\TextInput::make('id')
|
||||||
|
->hidden()
|
||||||
|
->readOnly(),
|
||||||
])
|
])
|
||||||
->columns(2),
|
->columns(2),
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use App\Filament\Resources\ItemResource\Pages;
|
|||||||
use App\Models\Item;
|
use App\Models\Item;
|
||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
|
use Filament\Forms\Get;
|
||||||
use Filament\Resources\Resource;
|
use Filament\Resources\Resource;
|
||||||
use Filament\Tables;
|
use Filament\Tables;
|
||||||
use Filament\Tables\Actions\ExportAction;
|
use Filament\Tables\Actions\ExportAction;
|
||||||
@@ -38,6 +39,7 @@ class ItemResource extends Resource
|
|||||||
->required()
|
->required()
|
||||||
// ->nullable(),
|
// ->nullable(),
|
||||||
->reactive()
|
->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(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) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$plantId = $get('plant_id');
|
$plantId = $get('plant_id');
|
||||||
@@ -64,6 +66,7 @@ class ItemResource extends Resource
|
|||||||
->minLength(6)
|
->minLength(6)
|
||||||
// ->autocapitalize('characters')
|
// ->autocapitalize('characters')
|
||||||
->reactive()
|
->reactive()
|
||||||
|
->disabled(fn (Get $get) => !empty($get('id')))
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$code = $get('code');
|
$code = $get('code');
|
||||||
// Ensure `linestop_id` is not cleared
|
// Ensure `linestop_id` is not cleared
|
||||||
@@ -123,6 +126,9 @@ class ItemResource extends Resource
|
|||||||
->required()
|
->required()
|
||||||
->placeholder('Scan the valid description'),
|
->placeholder('Scan the valid description'),
|
||||||
// ->columnSpanFull(),
|
// ->columnSpanFull(),
|
||||||
|
Forms\Components\TextInput::make('id')
|
||||||
|
->hidden()
|
||||||
|
->readOnly(),
|
||||||
])
|
])
|
||||||
->columns(2),
|
->columns(2),
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use App\Filament\Resources\LineResource\RelationManagers;
|
|||||||
use App\Models\Line;
|
use App\Models\Line;
|
||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
|
use Filament\Forms\Get;
|
||||||
use Filament\Resources\Resource;
|
use Filament\Resources\Resource;
|
||||||
use Filament\Tables;
|
use Filament\Tables;
|
||||||
use Filament\Tables\Actions\ImportAction;
|
use Filament\Tables\Actions\ImportAction;
|
||||||
@@ -37,6 +38,7 @@ class LineResource extends Resource
|
|||||||
->required()
|
->required()
|
||||||
// ->nullable(),
|
// ->nullable(),
|
||||||
->reactive()
|
->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(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) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$plantId = $get('plant_id');
|
$plantId = $get('plant_id');
|
||||||
@@ -124,6 +126,9 @@ class LineResource extends Resource
|
|||||||
])
|
])
|
||||||
->hint(fn ($get) => $get('lTypeError') ? $get('lTypeError') : null)
|
->hint(fn ($get) => $get('lTypeError') ? $get('lTypeError') : null)
|
||||||
->hintColor('danger'),
|
->hintColor('danger'),
|
||||||
|
Forms\Components\TextInput::make('id')
|
||||||
|
->hidden()
|
||||||
|
->readOnly(),
|
||||||
])
|
])
|
||||||
->columns(2),
|
->columns(2),
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use App\Models\Plant;
|
|||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
use Filament\Forms\Components\Section;
|
use Filament\Forms\Components\Section;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
|
use Filament\Forms\Get;
|
||||||
use Filament\Resources\Resource;
|
use Filament\Resources\Resource;
|
||||||
use Filament\Tables;
|
use Filament\Tables;
|
||||||
use Filament\Tables\Actions\ImportAction;
|
use Filament\Tables\Actions\ImportAction;
|
||||||
@@ -69,6 +70,7 @@ class PlantResource extends Resource
|
|||||||
->relationship('company', 'name')
|
->relationship('company', 'name')
|
||||||
->required()
|
->required()
|
||||||
->reactive()
|
->reactive()
|
||||||
|
->disabled(fn (Get $get) => !empty($get('id')))
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$companyId = $get('company_id');
|
$companyId = $get('company_id');
|
||||||
// Ensure `linestop_id` is not cleared
|
// Ensure `linestop_id` is not cleared
|
||||||
@@ -132,6 +134,9 @@ class PlantResource extends Resource
|
|||||||
])
|
])
|
||||||
->hint(fn ($get) => $get('pAddressError') ? $get('pAddressError') : null)
|
->hint(fn ($get) => $get('pAddressError') ? $get('pAddressError') : null)
|
||||||
->hintColor('danger'),
|
->hintColor('danger'),
|
||||||
|
Forms\Components\TextInput::make('id')
|
||||||
|
->hidden()
|
||||||
|
->readOnly(),
|
||||||
])
|
])
|
||||||
->columns(2),
|
->columns(2),
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use App\Filament\Resources\ProductionLineStopResource\RelationManagers;
|
|||||||
use App\Models\ProductionLineStop;
|
use App\Models\ProductionLineStop;
|
||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
|
use Filament\Forms\Get;
|
||||||
use Filament\Resources\Resource;
|
use Filament\Resources\Resource;
|
||||||
use Filament\Tables;
|
use Filament\Tables;
|
||||||
use Filament\Tables\Actions\ImportAction;
|
use Filament\Tables\Actions\ImportAction;
|
||||||
@@ -39,6 +40,7 @@ class ProductionLineStopResource extends Resource
|
|||||||
->required()
|
->required()
|
||||||
// ->nullable()
|
// ->nullable()
|
||||||
->reactive()
|
->reactive()
|
||||||
|
->disabled(fn (Get $get) => !empty($get('id')))
|
||||||
// ->afterStateUpdated(fn ($set) => $set('block_name', null))
|
// ->afterStateUpdated(fn ($set) => $set('block_name', null))
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$plantId = $get('plant_id');
|
$plantId = $get('plant_id');
|
||||||
@@ -71,10 +73,31 @@ class ProductionLineStopResource extends Resource
|
|||||||
->toArray();
|
->toArray();
|
||||||
})
|
})
|
||||||
->reactive()
|
->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(fn ($set) => $set('shift_id', null))
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->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');
|
$blockId = $get('block_name');
|
||||||
$set('shift_id', null);
|
$set('shift_id', null);
|
||||||
|
|
||||||
if (!$blockId) {
|
if (!$blockId) {
|
||||||
$set('plsBlockError', 'Please select a block first.');
|
$set('plsBlockError', 'Please select a block first.');
|
||||||
return;
|
return;
|
||||||
@@ -102,7 +125,6 @@ class ProductionLineStopResource extends Resource
|
|||||||
if (!$get('plant_id') || !$get('block_name')) {
|
if (!$get('plant_id') || !$get('block_name')) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
// // Get the block ID based on plant_id and block_name
|
// // Get the block ID based on plant_id and block_name
|
||||||
// $block = \App\Models\Block::where('plant_id', $get('plant_id'))
|
// $block = \App\Models\Block::where('plant_id', $get('plant_id'))
|
||||||
// ->where('name', $get('block_name'))
|
// ->where('name', $get('block_name'))
|
||||||
@@ -123,8 +145,19 @@ class ProductionLineStopResource extends Resource
|
|||||||
->reactive()
|
->reactive()
|
||||||
// ->afterStateUpdated(fn ($set) => $set('line_id', null))
|
// ->afterStateUpdated(fn ($set) => $set('line_id', null))
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->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');
|
$shiftId = $get('shift_id');
|
||||||
$set('line_id', null);
|
$set('line_id', null);
|
||||||
|
|
||||||
if (!$shiftId) {
|
if (!$shiftId) {
|
||||||
$set('plsShiftError', 'Please select a shift first.');
|
$set('plsShiftError', 'Please select a shift first.');
|
||||||
return;
|
return;
|
||||||
@@ -159,7 +192,18 @@ class ProductionLineStopResource extends Resource
|
|||||||
})
|
})
|
||||||
->reactive()
|
->reactive()
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->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');
|
$lineId = $get('line_id');
|
||||||
|
|
||||||
if (!$lineId) {
|
if (!$lineId) {
|
||||||
$set('plsLineError', 'Please select a line first.');
|
$set('plsLineError', 'Please select a line first.');
|
||||||
return;
|
return;
|
||||||
@@ -243,6 +287,9 @@ class ProductionLineStopResource extends Resource
|
|||||||
// ->dehydrated(false)
|
// ->dehydrated(false)
|
||||||
->readOnly(true)
|
->readOnly(true)
|
||||||
->numeric(),
|
->numeric(),
|
||||||
|
Forms\Components\TextInput::make('id')
|
||||||
|
->hidden()
|
||||||
|
->readOnly(),
|
||||||
])
|
])
|
||||||
->columns(2),
|
->columns(2),
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use App\Filament\Resources\ProductionPlanResource\RelationManagers;
|
|||||||
use App\Models\ProductionPlan;
|
use App\Models\ProductionPlan;
|
||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
|
use Filament\Forms\Get;
|
||||||
use Filament\Resources\Resource;
|
use Filament\Resources\Resource;
|
||||||
use Filament\Tables;
|
use Filament\Tables;
|
||||||
use Filament\Tables\Actions\ImportAction;
|
use Filament\Tables\Actions\ImportAction;
|
||||||
@@ -38,6 +39,7 @@ class ProductionPlanResource extends Resource
|
|||||||
->required()
|
->required()
|
||||||
// ->nullable()
|
// ->nullable()
|
||||||
->reactive()
|
->reactive()
|
||||||
|
->disabled(fn (Get $get) => !empty($get('id')))
|
||||||
// ->afterStateUpdated(fn ($set) => $set('block_name', null))
|
// ->afterStateUpdated(fn ($set) => $set('block_name', null))
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$plantId = $get('plant_id');
|
$plantId = $get('plant_id');
|
||||||
@@ -72,8 +74,20 @@ class ProductionPlanResource extends Resource
|
|||||||
->reactive()
|
->reactive()
|
||||||
//->afterStateUpdated(fn ($set) => $set('shift_id', null))
|
//->afterStateUpdated(fn ($set) => $set('shift_id', null))
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->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');
|
$blockId = $get('block_name');
|
||||||
$set('shift_id', null);
|
$set('shift_id', null);
|
||||||
|
|
||||||
if (!$blockId) {
|
if (!$blockId) {
|
||||||
$set('ppBlockError', 'Please select a block first.');
|
$set('ppBlockError', 'Please select a block first.');
|
||||||
return;
|
return;
|
||||||
@@ -105,8 +119,19 @@ class ProductionPlanResource extends Resource
|
|||||||
->reactive()
|
->reactive()
|
||||||
// ->afterStateUpdated(fn ($set) => $set('line_id', null))
|
// ->afterStateUpdated(fn ($set) => $set('line_id', null))
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->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');
|
$shiftId = $get('shift_id');
|
||||||
$set('line_id', null);
|
$set('line_id', null);
|
||||||
|
|
||||||
if (!$shiftId) {
|
if (!$shiftId) {
|
||||||
$set('ppShiftError', 'Please select a shift first.');
|
$set('ppShiftError', 'Please select a shift first.');
|
||||||
return;
|
return;
|
||||||
@@ -141,7 +166,18 @@ class ProductionPlanResource extends Resource
|
|||||||
})
|
})
|
||||||
->reactive()
|
->reactive()
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->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');
|
$lineId = $get('line_id');
|
||||||
|
|
||||||
if (!$lineId) {
|
if (!$lineId) {
|
||||||
$set('ppLineError', 'Please select a line first.');
|
$set('ppLineError', 'Please select a line first.');
|
||||||
return;
|
return;
|
||||||
@@ -172,19 +208,35 @@ class ProductionPlanResource extends Resource
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
$currentDate = date('Y-m-d');
|
||||||
$shiftId = \App\Models\Shift::where('id', $get('shift_id'))
|
$shiftId = \App\Models\Shift::where('id', $get('shift_id'))
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
if($shiftId->start_time > $shiftId->end_time)
|
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
||||||
{
|
$hRs = (int) $hRs;
|
||||||
$set('ppLineError', 'End time goes tomorrow...');
|
$miNs = (int) $miNs;
|
||||||
return;
|
|
||||||
}
|
$totalMinutes = $hRs * 60 + $miNs;
|
||||||
else
|
|
||||||
{
|
$from_dt = $currentDate . ' ' . $shiftId->start_time;
|
||||||
$set('ppLineError', 'End time is within today...');
|
|
||||||
|
$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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if($shiftId->start_time > $shiftId->end_time)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$set('ppLineError', null);
|
$set('ppLineError', null);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use App\Filament\Resources\ProductionQuantityResource\RelationManagers;
|
|||||||
use App\Models\ProductionQuantity;
|
use App\Models\ProductionQuantity;
|
||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
|
use Filament\Forms\Get;
|
||||||
use Filament\Resources\Resource;
|
use Filament\Resources\Resource;
|
||||||
use Filament\Tables;
|
use Filament\Tables;
|
||||||
use Filament\Tables\Actions\ImportAction;
|
use Filament\Tables\Actions\ImportAction;
|
||||||
@@ -37,6 +38,7 @@ class ProductionQuantityResource extends Resource
|
|||||||
->required()
|
->required()
|
||||||
// ->nullable()
|
// ->nullable()
|
||||||
->reactive()
|
->reactive()
|
||||||
|
->disabled(fn (Get $get) => !empty($get('id')))
|
||||||
// ->afterStateUpdated(fn ($set) => $set('block_name', null))
|
// ->afterStateUpdated(fn ($set) => $set('block_name', null))
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$plantId = $get('plant_id');
|
$plantId = $get('plant_id');
|
||||||
@@ -71,8 +73,20 @@ class ProductionQuantityResource extends Resource
|
|||||||
->reactive()
|
->reactive()
|
||||||
// ->afterStateUpdated(fn ($set) => $set('shift_id', null))
|
// ->afterStateUpdated(fn ($set) => $set('shift_id', null))
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->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');
|
$blockId = $get('block_name');
|
||||||
$set('shift_id', null);
|
$set('shift_id', null);
|
||||||
|
|
||||||
if (!$blockId) {
|
if (!$blockId) {
|
||||||
$set('pqBlockError', 'Please select a block first.');
|
$set('pqBlockError', 'Please select a block first.');
|
||||||
return;
|
return;
|
||||||
@@ -105,8 +119,19 @@ class ProductionQuantityResource extends Resource
|
|||||||
->reactive()
|
->reactive()
|
||||||
->afterStateUpdated(fn ($set) => $set('line_id', null))
|
->afterStateUpdated(fn ($set) => $set('line_id', null))
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->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');
|
$shiftId = $get('shift_id');
|
||||||
$set('line_id', null);
|
$set('line_id', null);
|
||||||
|
|
||||||
if (!$shiftId) {
|
if (!$shiftId) {
|
||||||
$set('pqShiftError', 'Please select a shift first.');
|
$set('pqShiftError', 'Please select a shift first.');
|
||||||
return;
|
return;
|
||||||
@@ -142,7 +167,18 @@ class ProductionQuantityResource extends Resource
|
|||||||
})
|
})
|
||||||
->reactive()
|
->reactive()
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->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');
|
$lineId = $get('line_id');
|
||||||
|
|
||||||
$set('item_code', null);
|
$set('item_code', null);
|
||||||
if (!$lineId) {
|
if (!$lineId) {
|
||||||
$set('pqLineError', 'Please select a line first.');
|
$set('pqLineError', 'Please select a line first.');
|
||||||
@@ -397,6 +433,9 @@ class ProductionQuantityResource extends Resource
|
|||||||
->readOnly(true)
|
->readOnly(true)
|
||||||
->autocapitalize('serial_number'),
|
->autocapitalize('serial_number'),
|
||||||
//->columnSpanFull(),
|
//->columnSpanFull(),
|
||||||
|
Forms\Components\TextInput::make('id')
|
||||||
|
->hidden()
|
||||||
|
->readOnly(),
|
||||||
])
|
])
|
||||||
->columns(2),
|
->columns(2),
|
||||||
]);
|
]);
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -8,6 +8,7 @@ use App\Models\Shift;
|
|||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
|
use Filament\Forms\Get;
|
||||||
use Filament\Resources\Resource;
|
use Filament\Resources\Resource;
|
||||||
use Filament\Tables;
|
use Filament\Tables;
|
||||||
use Filament\Tables\Actions\ImportAction;
|
use Filament\Tables\Actions\ImportAction;
|
||||||
@@ -37,6 +38,7 @@ class ShiftResource extends Resource
|
|||||||
->required()
|
->required()
|
||||||
// ->nullable()
|
// ->nullable()
|
||||||
->reactive()
|
->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(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) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$plantId = $get('plant_id');
|
$plantId = $get('plant_id');
|
||||||
@@ -60,6 +62,7 @@ class ShiftResource extends Resource
|
|||||||
->required()
|
->required()
|
||||||
// ->nullable()
|
// ->nullable()
|
||||||
->reactive()
|
->reactive()
|
||||||
|
->disabled(fn (Get $get) => !empty($get('id')))
|
||||||
// ->options(fn (callable $get) =>
|
// ->options(fn (callable $get) =>
|
||||||
// \App\Models\Block::where('plant_id', $get('plant_id'))
|
// \App\Models\Block::where('plant_id', $get('plant_id'))
|
||||||
// ->pluck('name', 'id')
|
// ->pluck('name', 'id')
|
||||||
@@ -203,6 +206,9 @@ class ShiftResource extends Resource
|
|||||||
])
|
])
|
||||||
->hint(fn ($get) => $get('sEndTimeError') ? $get('sEndTimeError') : null)
|
->hint(fn ($get) => $get('sEndTimeError') ? $get('sEndTimeError') : null)
|
||||||
->hintColor('danger'),
|
->hintColor('danger'),
|
||||||
|
Forms\Components\TextInput::make('id')
|
||||||
|
->hidden()
|
||||||
|
->readOnly(),
|
||||||
])
|
])
|
||||||
->columns(2),
|
->columns(2),
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ use App\Filament\Resources\StickerMasterResource\RelationManagers;
|
|||||||
use App\Models\StickerMaster;
|
use App\Models\StickerMaster;
|
||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
|
use Filament\Forms\Get;
|
||||||
use Filament\Resources\Resource;
|
use Filament\Resources\Resource;
|
||||||
use Filament\Tables;
|
use Filament\Tables;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
@@ -31,6 +32,7 @@ class StickerMasterResource extends Resource
|
|||||||
->relationship('plant', 'name')
|
->relationship('plant', 'name')
|
||||||
->reactive()
|
->reactive()
|
||||||
->nullable()
|
->nullable()
|
||||||
|
->disabled(fn (Get $get) => !empty($get('id'))) //disable in edit if user try to change
|
||||||
->afterStateUpdated(fn (callable $set) =>
|
->afterStateUpdated(fn (callable $set) =>
|
||||||
$set('item_id', null) & $set('item_description', null)
|
$set('item_id', null) & $set('item_description', null)
|
||||||
)
|
)
|
||||||
@@ -51,10 +53,11 @@ class StickerMasterResource extends Resource
|
|||||||
->nullable()
|
->nullable()
|
||||||
->searchable()
|
->searchable()
|
||||||
->reactive()
|
->reactive()
|
||||||
|
->disabled(fn (Get $get) => !empty($get('id')))
|
||||||
->live(debounce: 500) // Enable live updates
|
->live(debounce: 500) // Enable live updates
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$plantId = $get('plant_id'); // Get selected plant_id
|
$plantId = $get('plant_id');
|
||||||
$itemId = $get('item_id'); // Get entered item_id
|
$itemId = $get('item_id');
|
||||||
|
|
||||||
// Ensure `item_id` is not cleared
|
// Ensure `item_id` is not cleared
|
||||||
if (!$plantId || !$itemId) {
|
if (!$plantId || !$itemId) {
|
||||||
@@ -74,13 +77,6 @@ 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')
|
Forms\Components\TextInput::make('item_description')
|
||||||
->label('Description')
|
->label('Description')
|
||||||
@@ -88,8 +84,6 @@ class StickerMasterResource extends Resource
|
|||||||
->reactive()
|
->reactive()
|
||||||
->readOnly(true),
|
->readOnly(true),
|
||||||
|
|
||||||
//Forms\Components\Textarea::make('serial_number_motor'),
|
|
||||||
|
|
||||||
Forms\Components\TextInput::make('part_validation1')
|
Forms\Components\TextInput::make('part_validation1')
|
||||||
->nullable(),
|
->nullable(),
|
||||||
|
|
||||||
@@ -109,78 +103,58 @@ class StickerMasterResource extends Resource
|
|||||||
->nullable()
|
->nullable()
|
||||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||||
|
|
||||||
//Forms\Components\Textarea::make('serial_number_pump')
|
|
||||||
|
|
||||||
Forms\Components\Checkbox::make('serial_number_pump')
|
Forms\Components\Checkbox::make('serial_number_pump')
|
||||||
->nullable()
|
->nullable()
|
||||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||||
|
|
||||||
//Forms\Components\TextInput::make('serial_number_pumpset'),
|
|
||||||
|
|
||||||
Forms\Components\Checkbox::make('serial_number_pumpset')
|
Forms\Components\Checkbox::make('serial_number_pumpset')
|
||||||
->nullable()
|
->nullable()
|
||||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||||
|
|
||||||
//Forms\Components\TextInput::make('pack_slip_motor'),
|
|
||||||
|
|
||||||
Forms\Components\Checkbox::make('pack_slip_motor')
|
Forms\Components\Checkbox::make('pack_slip_motor')
|
||||||
->nullable()
|
->nullable()
|
||||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||||
|
|
||||||
//Forms\Components\TextInput::make('pack_slip_pump'),
|
|
||||||
|
|
||||||
Forms\Components\Checkbox::make('pack_slip_pump')
|
Forms\Components\Checkbox::make('pack_slip_pump')
|
||||||
->nullable()
|
->nullable()
|
||||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
->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_pumpset')
|
||||||
->nullable()
|
->nullable()
|
||||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||||
|
|
||||||
//Forms\Components\TextInput::make('name_plate_motor'),
|
|
||||||
|
|
||||||
Forms\Components\Checkbox::make('name_plate_motor')
|
Forms\Components\Checkbox::make('name_plate_motor')
|
||||||
->nullable()
|
->nullable()
|
||||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||||
|
|
||||||
//Forms\Components\TextInput::make('name_plate_pump'),
|
|
||||||
|
|
||||||
Forms\Components\Checkbox::make('name_plate_pump')
|
Forms\Components\Checkbox::make('name_plate_pump')
|
||||||
->nullable()
|
->nullable()
|
||||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||||
|
|
||||||
//Forms\Components\TextInput::make('name_plate_pumpset'),
|
|
||||||
|
|
||||||
Forms\Components\Checkbox::make('name_plate_pumpset')
|
Forms\Components\Checkbox::make('name_plate_pumpset')
|
||||||
->nullable()
|
->nullable()
|
||||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||||
|
|
||||||
//Forms\Components\TextInput::make('tube_sticker_motor'),
|
|
||||||
|
|
||||||
Forms\Components\Checkbox::make('tube_sticker_motor')
|
Forms\Components\Checkbox::make('tube_sticker_motor')
|
||||||
->nullable()
|
->nullable()
|
||||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||||
|
|
||||||
//Forms\Components\TextInput::make('tube_sticker_pump'),
|
|
||||||
|
|
||||||
Forms\Components\Checkbox::make('tube_sticker_pump')
|
Forms\Components\Checkbox::make('tube_sticker_pump')
|
||||||
->nullable()
|
->nullable()
|
||||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||||
|
|
||||||
//Forms\Components\TextInput::make('tube_sticker_pumpset'),
|
|
||||||
|
|
||||||
Forms\Components\Checkbox::make('tube_sticker_pumpset')
|
Forms\Components\Checkbox::make('tube_sticker_pumpset')
|
||||||
->nullable()
|
->nullable()
|
||||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
->dehydrateStateUsing(fn ($state) => $state ? $state : null), //to pass null value
|
||||||
|
|
||||||
//Forms\Components\TextInput::make('warranty_card'),
|
|
||||||
|
|
||||||
Forms\Components\Checkbox::make('warranty_card')
|
Forms\Components\Checkbox::make('warranty_card')
|
||||||
->nullable()
|
->nullable()
|
||||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||||
|
|
||||||
|
Forms\Components\TextInput::make('id')
|
||||||
|
->hidden()
|
||||||
|
->readOnly(),
|
||||||
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user