Merge pull request 'Ordered zmm column in forms of item characteristics page' (#1477) from ranjith-dev into master
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 17s

Reviewed-on: #1477
This commit was merged in pull request #1477.
This commit is contained in:
2026-11-19 06:03:30 +00:00

View File

@@ -44,18 +44,28 @@ class ItemCharacteristicResource extends Resource
Section::make('') Section::make('')
->schema([ ->schema([
Forms\Components\Select::make('plant_id') Forms\Components\Select::make('plant_id')
->label('Plant') ->label('PLANT NAME')
->reactive()
->relationship('plant', 'name') ->relationship('plant', 'name')
->reactive()
->searchable()
->options(function (callable $get) { ->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id; $userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray(); return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->disabled(fn (Get $get) => ! empty($get('id')))
->default(function () {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? $userHas : optional(ItemCharacteristic::latest()->first())->plant_id;
})
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$set('item_id', null);
$set('updated_by', Filament::auth()->user()?->name);
}) })
->required(), ->required(),
Forms\Components\Select::make('item_id') Forms\Components\Select::make('item_id')
->label('Item Code') ->label('ITEM CODE')
// ->relationship('item', 'id')
->reactive() ->reactive()
->searchable() ->searchable()
->options(function (callable $get) { ->options(function (callable $get) {
@@ -64,7 +74,19 @@ class ItemCharacteristicResource extends Resource
return []; return [];
} }
return Item::where('plant_id', $plantId)->pluck('code', 'id'); return Item::where('plant_id', $plantId)->orderBy('code')->pluck('code', 'id')->toArray();
})
->disabled(fn (Get $get) => ! empty($get('id')))
->default(function (callable $get) {
$plantId = $get('plant_id');
if (empty($plantId)) {
return null;
}
return ItemCharacteristic::where('plant_id', $plantId)->latest()->first()->item_id ?? null;
})
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}) })
->required(), ->required(),
Forms\Components\TextInput::make('class') Forms\Components\TextInput::make('class')
@@ -110,7 +132,7 @@ class ItemCharacteristicResource extends Resource
$set('updated_by', Filament::auth()->user()?->name); $set('updated_by', Filament::auth()->user()?->name);
}), }),
Forms\Components\TextInput::make('zmm_dir_rot') Forms\Components\TextInput::make('zmm_dir_rot')
->label('ZMM DIRECTION ROTATION') ->label('ZMM DIR ROT')
->reactive() ->reactive()
->afterStateUpdated(function (callable $set) { ->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name); $set('updated_by', Filament::auth()->user()?->name);
@@ -168,7 +190,8 @@ class ItemCharacteristicResource extends Resource
->reactive() ->reactive()
->afterStateUpdated(function (callable $set) { ->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name); $set('updated_by', Filament::auth()->user()?->name);
}), })
->required(),
Forms\Components\TextInput::make('zmm_head_max') Forms\Components\TextInput::make('zmm_head_max')
->label('ZMM HEAD MAX') ->label('ZMM HEAD MAX')
->reactive() ->reactive()
@@ -452,7 +475,7 @@ class ItemCharacteristicResource extends Resource
$set('updated_by', Filament::auth()->user()?->name); $set('updated_by', Filament::auth()->user()?->name);
}), }),
Forms\Components\TextInput::make('zmm_eff_ovrall') Forms\Components\TextInput::make('zmm_eff_ovrall')
->label('ZMM OVERALL EFFICIENCY') ->label('ZMM EFF OVRALL')
->reactive() ->reactive()
->afterStateUpdated(function (callable $set) { ->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name); $set('updated_by', Filament::auth()->user()?->name);
@@ -488,7 +511,7 @@ class ItemCharacteristicResource extends Resource
$set('updated_by', Filament::auth()->user()?->name); $set('updated_by', Filament::auth()->user()?->name);
}), }),
Forms\Components\TextInput::make('zmm_ambtemp') Forms\Components\TextInput::make('zmm_ambtemp')
->label('ZMM AMBIENT TEMPERATURE') ->label('ZMM AMBTEMP')
->reactive() ->reactive()
->afterStateUpdated(function (callable $set) { ->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name); $set('updated_by', Filament::auth()->user()?->name);
@@ -542,7 +565,7 @@ class ItemCharacteristicResource extends Resource
$set('updated_by', Filament::auth()->user()?->name); $set('updated_by', Filament::auth()->user()?->name);
}), }),
Forms\Components\TextInput::make('zmm_mtrlofconst') Forms\Components\TextInput::make('zmm_mtrlofconst')
->label('ZMM MOTOR LOAD CONSTANT') ->label('ZMM MTRLOFCONST')
->reactive() ->reactive()
->afterStateUpdated(function (callable $set) { ->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name); $set('updated_by', Filament::auth()->user()?->name);
@@ -577,6 +600,30 @@ class ItemCharacteristicResource extends Resource
->afterStateUpdated(function (callable $set) { ->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name); $set('updated_by', Filament::auth()->user()?->name);
}), }),
Forms\Components\TextInput::make('zmm_logo_cp')
->label('ZMM LOGO CP')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_logo_ce')
->label('ZMM LOGO CE')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_logo_nsf')
->label('ZMM LOGO NSF')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_logo_eac')
->label('ZMM LOGO EAC')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_beenote') Forms\Components\TextInput::make('zmm_beenote')
->label('ZMM BEENOTE') ->label('ZMM BEENOTE')
->reactive() ->reactive()
@@ -595,12 +642,6 @@ class ItemCharacteristicResource extends Resource
->afterStateUpdated(function (callable $set) { ->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name); $set('updated_by', Filament::auth()->user()?->name);
}), }),
Forms\Components\TextInput::make('zmm_logo_ce')
->label('ZMM LOGO CE')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_codeclass') Forms\Components\TextInput::make('zmm_codeclass')
->label('ZMM CODECLASS') ->label('ZMM CODECLASS')
->reactive() ->reactive()
@@ -613,12 +654,6 @@ class ItemCharacteristicResource extends Resource
->afterStateUpdated(function (callable $set) { ->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name); $set('updated_by', Filament::auth()->user()?->name);
}), }),
Forms\Components\TextInput::make('zmm_logo_cp')
->label('ZMM LOGO CP')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_grade') Forms\Components\TextInput::make('zmm_grade')
->label('ZMM GRADE') ->label('ZMM GRADE')
->reactive() ->reactive()
@@ -733,18 +768,6 @@ class ItemCharacteristicResource extends Resource
->afterStateUpdated(function (callable $set) { ->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name); $set('updated_by', Filament::auth()->user()?->name);
}), }),
Forms\Components\TextInput::make('zmm_logo_nsf')
->label('ZMM LOGO NSF')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_logo_eac')
->label('ZMM LOGO EAC')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_packtype') Forms\Components\TextInput::make('zmm_packtype')
->label('ZMM PACKTYPE') ->label('ZMM PACKTYPE')
->reactive() ->reactive()
@@ -877,6 +900,9 @@ class ItemCharacteristicResource extends Resource
Forms\Components\Hidden::make('updated_by') Forms\Components\Hidden::make('updated_by')
->label('Updated By') ->label('Updated By')
->default(Filament::auth()->user()?->name), ->default(Filament::auth()->user()?->name),
Forms\Components\TextInput::make('id')
->hidden()
->readOnly(),
]) ])
->columns(3), ->columns(3),
]); ]);