From bc43e0d25e9d62f9450eb22017e15ea4d6a08c03 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Thu, 19 Nov 2026 11:32:23 +0530 Subject: [PATCH] Ordered zmm column in forms of item characteristics page --- .../Resources/ItemCharacteristicResource.php | 192 ++++++++++-------- 1 file changed, 109 insertions(+), 83 deletions(-) diff --git a/app/Filament/Resources/ItemCharacteristicResource.php b/app/Filament/Resources/ItemCharacteristicResource.php index cb3ea75c..6eee694d 100644 --- a/app/Filament/Resources/ItemCharacteristicResource.php +++ b/app/Filament/Resources/ItemCharacteristicResource.php @@ -44,18 +44,28 @@ class ItemCharacteristicResource extends Resource Section::make('') ->schema([ Forms\Components\Select::make('plant_id') - ->label('Plant') - ->reactive() + ->label('PLANT NAME') ->relationship('plant', 'name') + ->reactive() + ->searchable() ->options(function (callable $get) { $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(), Forms\Components\Select::make('item_id') - ->label('Item Code') - // ->relationship('item', 'id') + ->label('ITEM CODE') ->reactive() ->searchable() ->options(function (callable $get) { @@ -64,7 +74,19 @@ class ItemCharacteristicResource extends Resource 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(), Forms\Components\TextInput::make('class') @@ -98,7 +120,7 @@ class ItemCharacteristicResource extends Resource $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_degreeofprotection') - ->label('ZMM DEGREE OF PROTECTION') + ->label('ZMM DEGREEOFPROTECTION') ->reactive() ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); @@ -110,7 +132,7 @@ class ItemCharacteristicResource extends Resource $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_dir_rot') - ->label('ZMM DIRECTION ROTATION') + ->label('ZMM DIR ROT') ->reactive() ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); @@ -168,7 +190,8 @@ class ItemCharacteristicResource extends Resource ->reactive() ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); - }), + }) + ->required(), Forms\Components\TextInput::make('zmm_head_max') ->label('ZMM HEAD MAX') ->reactive() @@ -200,19 +223,19 @@ class ItemCharacteristicResource extends Resource $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_maxambtemp') - ->label('ZMM MAX AMB TEMP') + ->label('ZMM MAXAMBTEMP') ->reactive() ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_mincoolingflow') - ->label('ZMM MIN COOLING FLOW') + ->label('ZMM MINCOOLINGFLOW') ->reactive() ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_motorseries') - ->label('ZMM MOTOR SERIES') + ->label('ZMM MOTORSERIES') ->reactive() ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); @@ -242,13 +265,13 @@ class ItemCharacteristicResource extends Resource $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_pumpflowtype') - ->label('ZMM PUMP FLOW TYPE') + ->label('ZMM PUMPFLOWTYPE') ->reactive() ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_pumpseries') - ->label('ZMM PUMP SERIES') + ->label('ZMM PUMPSERIES') ->reactive() ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); @@ -260,7 +283,7 @@ class ItemCharacteristicResource extends Resource $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_ratedpower') - ->label('ZMM RATED POWER') + ->label('ZMM RATEDPOWER') ->reactive() ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); @@ -272,13 +295,13 @@ class ItemCharacteristicResource extends Resource $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_servicefactor') - ->label('ZMM SERVICE FACTOR') + ->label('ZMM SERVICEFACTOR') ->reactive() ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_servicefactormaximumamps') - ->label('ZMM SERVICE FACTOR MAXIMUM AMPS') + ->label('ZMM SERVICEFACTORMAXIMUMAMPS') ->reactive() ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); @@ -296,13 +319,13 @@ class ItemCharacteristicResource extends Resource $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_suctionxdelivery') - ->label('ZMM SUCTION X DELIVERY') + ->label('ZMM SUCTIONXDELIVERY') ->reactive() ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_supplysource') - ->label('ZMM SUPPLY SOURCE') + ->label('ZMM SUPPLYSOURCE') ->reactive() ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); @@ -314,7 +337,7 @@ class ItemCharacteristicResource extends Resource $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_thrustload') - ->label('ZMM THRUST LOAD') + ->label('ZMM THRUSTLOAD') ->reactive() ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); @@ -338,7 +361,7 @@ class ItemCharacteristicResource extends Resource $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_pvarrayrating') - ->label('ZMM PV ARRAY RATING') + ->label('ZMM PVARRAYRATING') ->reactive() ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); @@ -350,25 +373,25 @@ class ItemCharacteristicResource extends Resource $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_isimotor') - ->label('ZMM ISI MOTOR') + ->label('ZMM ISIMOTOR') ->reactive() ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_isipump') - ->label('ZMM ISI PUMP') + ->label('ZMM ISIPUMP') ->reactive() ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_isipumpset') - ->label('ZMM ISI PUMP SET') + ->label('ZMM ISIPUMPSET') ->reactive() ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_pumpset_model') - ->label('ZMM PUMP SET MODEL') + ->label('ZMM PUMPSET MODEL') ->reactive() ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); @@ -380,7 +403,7 @@ class ItemCharacteristicResource extends Resource $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_headrange') - ->label('ZMM HEAD RANGE') + ->label('ZMM HEADRANGE') ->reactive() ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); @@ -404,7 +427,7 @@ class ItemCharacteristicResource extends Resource $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_isireference') - ->label('ZMM ISI REFERENCE') + ->label('ZMM ISIREFERENCE') ->reactive() ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); @@ -422,13 +445,13 @@ class ItemCharacteristicResource extends Resource $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_capacitorstart') - ->label('ZMM CAPACITOR START') + ->label('ZMM CAPACITORSTART') ->reactive() ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_capacitorrun') - ->label('ZMM CAPACITOR RUN') + ->label('ZMM CAPACITORRUN') ->reactive() ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); @@ -452,19 +475,19 @@ class ItemCharacteristicResource extends Resource $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_eff_ovrall') - ->label('ZMM OVERALL EFFICIENCY') + ->label('ZMM EFF OVRALL') ->reactive() ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_bodymoc') - ->label('ZMM BODY MOC') + ->label('ZMM BODYMOC') ->reactive() ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_rotormoc') - ->label('ZMM ROTOR MOC') + ->label('ZMM ROTORMOC') ->reactive() ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); @@ -476,7 +499,7 @@ class ItemCharacteristicResource extends Resource $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_inputpower') - ->label('ZMM INPUT POWER') + ->label('ZMM INPUTPOWER') ->reactive() ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); @@ -488,7 +511,7 @@ class ItemCharacteristicResource extends Resource $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_ambtemp') - ->label('ZMM AMBIENT TEMPERATURE') + ->label('ZMM AMBTEMP') ->reactive() ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); @@ -500,7 +523,7 @@ class ItemCharacteristicResource extends Resource $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_dischargerange') - ->label('ZMM DISCHARGE RANGE') + ->label('ZMM DISCHARGERANGE') ->reactive() ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); @@ -512,37 +535,37 @@ class ItemCharacteristicResource extends Resource $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_framesize') - ->label('ZMM FRAME SIZE') + ->label('ZMM FRAMESIZE') ->reactive() ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_impellerdiameter') - ->label('ZMM IMPELLER DIAMETER') + ->label('ZMM IMPELLERDIAMETER') ->reactive() ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_insulationclass') - ->label('ZMM INSULATION CLASS') + ->label('ZMM INSULATIONCLASS') ->reactive() ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_maxflow') - ->label('ZMM MAX FLOW') + ->label('ZMM MAXFLOW') ->reactive() ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_minhead') - ->label('ZMM MIN HEAD') + ->label('ZMM MINHEAD') ->reactive() ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_mtrlofconst') - ->label('ZMM MOTOR LOAD CONSTANT') + ->label('ZMM MTRLOFCONST') ->reactive() ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); @@ -554,7 +577,7 @@ class ItemCharacteristicResource extends Resource $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_powerfactor') - ->label('ZMM POWER FACTOR') + ->label('ZMM POWERFACTOR') ->reactive() ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); @@ -577,20 +600,8 @@ class ItemCharacteristicResource extends Resource ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), - Forms\Components\TextInput::make('zmm_beenote') - ->label('ZMM BEE NOTE') - ->reactive() - ->afterStateUpdated(function (callable $set) { - $set('updated_by', Filament::auth()->user()?->name); - }), - Forms\Components\TextInput::make('zmm_beenumber') - ->label('ZMM BEE NUMBER') - ->reactive() - ->afterStateUpdated(function (callable $set) { - $set('updated_by', Filament::auth()->user()?->name); - }), - Forms\Components\TextInput::make('zmm_beestar') - ->label('ZMM BEE STAR') + Forms\Components\TextInput::make('zmm_logo_cp') + ->label('ZMM LOGO CP') ->reactive() ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); @@ -601,8 +612,38 @@ class ItemCharacteristicResource extends Resource ->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') + ->label('ZMM BEENOTE') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), + Forms\Components\TextInput::make('zmm_beenumber') + ->label('ZMM BEENUMBER') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), + Forms\Components\TextInput::make('zmm_beestar') + ->label('ZMM BEESTAR') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_codeclass') - ->label('ZMM CODE CLASS') + ->label('ZMM CODECLASS') ->reactive() ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); @@ -613,12 +654,6 @@ class ItemCharacteristicResource extends Resource ->afterStateUpdated(function (callable $set) { $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') ->label('ZMM GRADE') ->reactive() @@ -656,7 +691,7 @@ class ItemCharacteristicResource extends Resource $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_isivalve') - ->label('ZMM ISI VALVE') + ->label('ZMM ISIVALVE') ->reactive() ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); @@ -668,7 +703,7 @@ class ItemCharacteristicResource extends Resource $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_labelperiod') - ->label('ZMM LABEL PERIOD') + ->label('ZMM LABELPERIOD') ->reactive() ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); @@ -686,19 +721,19 @@ class ItemCharacteristicResource extends Resource $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_mfgmonyr') - ->label('ZMM MFG MON YR') + ->label('ZMM MFGMONYR') ->reactive() ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_modelyear') - ->label('ZMM MODEL YEAR') + ->label('ZMM MODELYEAR') ->reactive() ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_motoridentification') - ->label('ZMM MOTOR IDENTIFICATION') + ->label('ZMM MOTORIDENTIFICATION') ->reactive() ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); @@ -733,20 +768,8 @@ class ItemCharacteristicResource extends Resource ->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_packtype') - ->label('ZMM PACK TYPE') + ->label('ZMM PACKTYPE') ->reactive() ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); @@ -764,13 +787,13 @@ class ItemCharacteristicResource extends Resource $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_pumpidentification') - ->label('ZMM PUMP IDENTIFICATION') + ->label('ZMM PUMPIDENTIFICATION') ->reactive() ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_psettype') - ->label('ZMM PSET TYPE') + ->label('ZMM PSETTYPE') ->reactive() ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); @@ -877,6 +900,9 @@ class ItemCharacteristicResource extends Resource Forms\Components\Hidden::make('updated_by') ->label('Updated By') ->default(Filament::auth()->user()?->name), + Forms\Components\TextInput::make('id') + ->hidden() + ->readOnly(), ]) ->columns(3), ]);