From f025a2707cbafcea76817b06d033b7c3f1b55f95 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Sun, 23 Aug 2026 20:02:10 +0530 Subject: [PATCH] Updated resource file for new columns (marked, stopped, and winded related) in class_characteristics table --- .../Resources/ClassCharacteristicResource.php | 330 ++++++++++++++++-- 1 file changed, 296 insertions(+), 34 deletions(-) diff --git a/app/Filament/Resources/ClassCharacteristicResource.php b/app/Filament/Resources/ClassCharacteristicResource.php index 2f123e6..21c7e24 100644 --- a/app/Filament/Resources/ClassCharacteristicResource.php +++ b/app/Filament/Resources/ClassCharacteristicResource.php @@ -36,6 +36,8 @@ class ClassCharacteristicResource extends Resource protected static ?string $navigationGroup = 'Laser Marking'; + protected static ?int $navigationSort = 5; + public static function form(Form $form): Form { return $form @@ -76,7 +78,7 @@ class ClassCharacteristicResource extends Resource return []; } - return Machine::where('plant_id', $plantId)->pluck('work_center', 'id')->toArray(); + return Machine::where('plant_id', $plantId)->orderBy('work_center')->pluck('work_center', 'id')->toArray(); }) ->disabled(fn (Get $get) => ! empty($get('id'))) ->default(function (callable $get) { @@ -103,7 +105,7 @@ class ClassCharacteristicResource extends Resource return []; } - return Item::where('plant_id', $plantId)->pluck('code', 'id')->toArray(); + return Item::where('plant_id', $plantId)->orderBy('code')->pluck('code', 'id')->toArray(); }) ->disabled(fn (Get $get) => ! empty($get('id'))) ->default(function (callable $get) { @@ -980,28 +982,61 @@ class ClassCharacteristicResource extends Resource ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), + Forms\Components\Select::make('is_stopped') + ->label('IS STOPPED') + // ->nullable() + ->selectablePlaceholder(false) + ->options(function () { + return [ + '0' => 'No', + '1' => 'Yes', + '2' => 'Yes (Alert Pending)', + ]; + }) + ->default('0') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }) + ->required(), + Forms\Components\DateTimePicker::make('stopped_datetime') + ->label('STOPPED DATETIME') + ->reactive() + ->placeholder('Select Stopped DateTime') + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), + Forms\Components\TextInput::make('stopped_by') + ->label('STOPPED BY') + ->reactive() + ->readOnly(fn (callable $get) => ! $get('id')) + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), + // Forms\Components\TextInput::make('is_stopped') + // ->label('IS STOPPED') + // ->reactive() + // ->afterStateUpdated(function (callable $set) { + // $set('updated_by', Filament::auth()->user()?->name); + // }) + // ->default(0) + // ->required(), Forms\Components\TextInput::make('mark_status') ->label('MARKED STATUS') ->reactive() ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), - Forms\Components\DateTimePicker::make('marked_datetime') - ->label('MARKED DATETIME') - ->reactive() - ->placeholder('Select Marked DateTime') - ->afterStateUpdated(function (callable $set) { - $set('updated_by', Filament::auth()->user()?->name); - }) - ->default(now()) - ->required(), Forms\Components\TextInput::make('marked_physical_count') ->label('MARKED PHYSICAL COUNT') ->reactive() + ->minValue(0) + ->integer() + ->maxValue(3) ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }) - ->default('0') + ->default(0) ->required(), Forms\Components\TextInput::make('marked_expected_time') ->label('MARKED EXPECTED TIME') @@ -1011,9 +1046,19 @@ class ClassCharacteristicResource extends Resource }) ->default('0') ->required(), + Forms\Components\DateTimePicker::make('marked_datetime') + ->label('MARKED DATETIME') + ->reactive() + ->placeholder('Select Marked DateTime') + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }) + ->default(now()) + ->required(), Forms\Components\TextInput::make('marked_by') ->label('MARKED BY') ->reactive() + ->readOnly(fn (callable $get) => ! $get('id')) ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }) @@ -1053,11 +1098,14 @@ class ClassCharacteristicResource extends Resource Forms\Components\TextInput::make('motor_marked_physical_count') ->label('MOTOR MARKED PHYSICAL COUNT') ->reactive() + ->minValue(0) + ->integer() + ->maxValue(3) ->readOnly(fn (callable $get) => ! (Str::contains($get('zmm_heading'), 'MOTOR', ignoreCase: true)) && ! (Str::contains($get('zmm_heading'), 'PUMPSET', ignoreCase: true)) && ! (Str::contains($get('zmm_heading'), 'PRESSURE BOOSTER SYSTEM', ignoreCase: true))) ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }) - ->default('0') + ->default(0) ->required(), Forms\Components\TextInput::make('motor_expected_time') ->label('MOTOR EXPECTED TIME') @@ -1068,6 +1116,13 @@ class ClassCharacteristicResource extends Resource }) ->default('0') ->required(), + Forms\Components\DateTimePicker::make('motor_marked_datetime') + ->label('MOTOR MARKED DATETIME') + ->reactive() + ->placeholder('Select Motor Marked DateTime') + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('motor_marked_by') ->label('MOTOR MARKED BY') ->reactive() @@ -1085,11 +1140,14 @@ class ClassCharacteristicResource extends Resource Forms\Components\TextInput::make('pump_marked_physical_count') ->label('PUMP MARKED PHYSICAL COUNT') ->reactive() + ->minValue(0) + ->integer() + ->maxValue(3) ->readOnly(fn (callable $get) => ! (Str::contains($get('zmm_heading'), 'PUMP', ignoreCase: true)) && ! (Str::contains($get('zmm_heading'), 'PUMPSET', ignoreCase: true)) && ! (Str::contains($get('zmm_heading'), 'PRESSURE BOOSTER SYSTEM', ignoreCase: true))) ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }) - ->default('0') + ->default(0) ->required(), Forms\Components\TextInput::make('pump_expected_time') ->label('PUMP EXPECTED TIME') @@ -1100,6 +1158,13 @@ class ClassCharacteristicResource extends Resource }) ->default('0') ->required(), + Forms\Components\DateTimePicker::make('pump_marked_datetime') + ->label('PUMP MARKED DATETIME') + ->reactive() + ->placeholder('Select Pump Marked DateTime') + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('pump_marked_by') ->label('PUMP MARKED BY') ->reactive() @@ -1123,6 +1188,13 @@ class ClassCharacteristicResource extends Resource }) ->default('0') ->required(), + Forms\Components\DateTimePicker::make('name_plate_marked_datetime') + ->label('NAME PLATE MARKED DATETIME') + ->reactive() + ->placeholder('Select Name Plate Marked DateTime') + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('name_plate_marked_by') ->label('NAME PLATE MARKED BY') ->reactive() @@ -1171,6 +1243,15 @@ class ClassCharacteristicResource extends Resource ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), + Forms\Components\TextInput::make('winded_rework_status') + ->label('WINDED REWORK STATUS') + ->reactive() + ->minValue(0) + ->integer() + ->maxValue(1) + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('motor_machine_name') ->label('MOTOR MACHINE NAME') ->reactive() @@ -1220,6 +1301,7 @@ class ClassCharacteristicResource extends Resource Forms\Components\TextInput::make('pending_released_status') ->label('PENDING RELEASED STATUS') ->reactive() + ->integer() ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }) @@ -1228,6 +1310,9 @@ class ClassCharacteristicResource extends Resource Forms\Components\TextInput::make('has_work_flow_id') ->label('HAS WORK FLOW ID') ->reactive() + ->minValue(0) + ->integer() + ->maxValue(3) ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }) @@ -1276,6 +1361,27 @@ class ClassCharacteristicResource extends Resource ->alignCenter() ->searchable() ->sortable(), + Tables\Columns\TextColumn::make('item.description') + ->label('DESCRIPTION') + ->default('-') + ->searchable() + ->alignCenter() + ->sortable() + ->toggleable(isToggledHiddenByDefault: true), + Tables\Columns\TextColumn::make('item.category') + ->label('CATEGORY') + ->default('-') + ->searchable() + ->alignCenter() + ->sortable() + ->toggleable(isToggledHiddenByDefault: true), + Tables\Columns\TextColumn::make('item.uom') + ->label('UNIT OF MEASURE') + ->default('-') + ->searchable() + ->alignCenter() + ->sortable() + ->toggleable(isToggledHiddenByDefault: true), Tables\Columns\TextColumn::make('aufnr') ->label('AUFNR') ->alignCenter() @@ -1300,6 +1406,7 @@ class ClassCharacteristicResource extends Resource Tables\Columns\TextColumn::make('gernr') ->label('GERNR') ->alignCenter() + ->searchable() ->sortable(), Tables\Columns\TextColumn::make('zz1_cn_bill_ord') ->label('ZZ1 CN BILL ORD') @@ -1824,12 +1931,21 @@ class ClassCharacteristicResource extends Resource ->label('ZMM AXIAL FORCE') ->alignCenter() ->sortable(), - Tables\Columns\TextColumn::make('mark_status') - ->label('MARKED STATUS') + Tables\Columns\TextColumn::make('is_stopped') + ->label('IS STOPPED') + ->alignCenter() + ->formatStateUsing(fn ($state) => ($state == '0') ? 'No' : ($state == '1' ? 'Yes' : 'Yes (Alert Pending)')) + ->sortable(), + Tables\Columns\TextColumn::make('stopped_datetime') + ->label('STOPPED DATETIME') ->alignCenter() ->sortable(), - Tables\Columns\TextColumn::make('marked_datetime') - ->label('MARKED DATETIME') + Tables\Columns\TextColumn::make('stopped_by') + ->label('STOPPED BY') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('mark_status') + ->label('MARKED STATUS') ->alignCenter() ->sortable(), Tables\Columns\TextColumn::make('marked_physical_count') @@ -1840,6 +1956,10 @@ class ClassCharacteristicResource extends Resource ->label('MARKED EXPECTED TIME') ->alignCenter() ->sortable(), + Tables\Columns\TextColumn::make('marked_datetime') + ->label('MARKED DATETIME') + ->alignCenter() + ->sortable(), Tables\Columns\TextColumn::make('marked_by') ->label('MARKED BY') ->alignCenter() @@ -1868,6 +1988,10 @@ class ClassCharacteristicResource extends Resource ->label('MOTOR EXPECTED TIME') ->alignCenter() ->sortable(), + Tables\Columns\TextColumn::make('motor_marked_datetime') + ->label('MOTOR MARKED DATETIME') + ->alignCenter() + ->sortable(), Tables\Columns\TextColumn::make('motor_marked_by') ->label('MOTOR MARKED BY') ->alignCenter() @@ -1884,6 +2008,10 @@ class ClassCharacteristicResource extends Resource ->label('PUMP EXPECTED TIME') ->alignCenter() ->sortable(), + Tables\Columns\TextColumn::make('pump_marked_datetime') + ->label('PUMP MARKED DATETIME') + ->alignCenter() + ->sortable(), Tables\Columns\TextColumn::make('pump_marked_by') ->label('PUMP MARKED BY') ->alignCenter() @@ -1896,6 +2024,10 @@ class ClassCharacteristicResource extends Resource ->label('NAME PLATE EXPECTED TIME') ->alignCenter() ->sortable(), + Tables\Columns\TextColumn::make('name_plate_marked_datetime') + ->label('NAME PLATE MARKED DATETIME') + ->alignCenter() + ->sortable(), Tables\Columns\TextColumn::make('name_plate_marked_by') ->label('NAME PLATE MARKED BY') ->alignCenter() @@ -1908,6 +2040,10 @@ class ClassCharacteristicResource extends Resource ->label('WINDED SERIAL NUMBER') ->alignCenter() ->sortable(), + Tables\Columns\TextColumn::make('winded_rework_status') + ->label('WINDED REWORK STATUS') + ->alignCenter() + ->sortable(), Tables\Columns\TextColumn::make('motor_machine_name') ->label('MOTOR MACHINE NAME') ->alignCenter() @@ -1956,12 +2092,10 @@ class ClassCharacteristicResource extends Resource ->label('UPDATED AT') ->alignCenter() ->dateTime() - ->sortable() - ->toggleable(isToggledHiddenByDefault: false), + ->sortable(), Tables\Columns\TextColumn::make('updated_by') ->label('UPDATED BY') - ->alignCenter() - ->toggleable(isToggledHiddenByDefault: false), + ->alignCenter(), Tables\Columns\TextColumn::make('deleted_at') ->label('DELETED AT') ->alignCenter() @@ -1995,7 +2129,6 @@ class ClassCharacteristicResource extends Resource ->afterStateUpdated(function ($state, callable $set, callable $get): void { $set('machine', null); $set('item_id', null); - // $set('aufnr', null); }), Select::make('machine') ->label('Search by Work Center') @@ -2014,10 +2147,6 @@ class ClassCharacteristicResource extends Resource $query->where('plant_id', $plantId); } })->pluck('work_center', 'id'); - }) - ->afterStateUpdated(function ($state, callable $set, callable $get): void { - // $set('item_id', null); - // $set('aufnr', null); }), Select::make('item_id') ->label('Search by Item Code') @@ -2036,9 +2165,6 @@ class ClassCharacteristicResource extends Resource $query->where('plant_id', $plantId); } })->pluck('code', 'id'); - }) - ->afterStateUpdated(function ($state, callable $set, callable $get): void { - // $set('aufnr', null); }), TextInput::make('aufnr') ->label('Job Number') @@ -2051,7 +2177,37 @@ class ClassCharacteristicResource extends Resource TextInput::make('zmm_heading') ->label('Heading') ->placeholder('Enter Heading'), - DateTimePicker::make(name: 'created_from') + DateTimePicker::make('motor_marked_from') + ->label('Motor Marked From') + ->placeholder('Select From DateTime') + ->reactive() + ->native(false), + DateTimePicker::make('motor_marked_to') + ->label('Motor Marked To') + ->placeholder('Select To DateTime') + ->reactive() + ->native(false), + DateTimePicker::make('pump_marked_from') + ->label('Pump Marked From') + ->placeholder('Select From DateTime') + ->reactive() + ->native(false), + DateTimePicker::make('pump_marked_to') + ->label('Pump Marked To') + ->placeholder('Select To DateTime') + ->reactive() + ->native(false), + DateTimePicker::make('name_plate_marked_from') + ->label('Name Plate Marked From') + ->placeholder('Select From DateTime') + ->reactive() + ->native(false), + DateTimePicker::make('name_plate_marked_to') + ->label('Name Plate Marked To') + ->placeholder('Select To DateTime') + ->reactive() + ->native(false), + DateTimePicker::make('created_from') ->label('Created From') ->placeholder('Select From DateTime') ->reactive() @@ -2061,10 +2217,36 @@ class ClassCharacteristicResource extends Resource ->placeholder('Select To DateTime') ->reactive() ->native(false), + Select::make('created_by') + ->label('Search by Created By') + ->nullable() + ->searchable() + ->reactive() + ->options(function () { + return ClassCharacteristic::pluck('created_by', 'created_by'); + }), + DateTimePicker::make('updated_from') + ->label('Updated From') + ->placeholder('Select From DateTime') + ->reactive() + ->native(false), + DateTimePicker::make('updated_to') + ->label('Updated To') + ->placeholder('Select To DateTime') + ->reactive() + ->native(false), + Select::make('updated_by') + ->label('Search by Updated By') + ->nullable() + ->searchable() + ->reactive() + ->options(function () { + return ClassCharacteristic::pluck('updated_by', 'updated_by'); + }), ]) ->query(function ($query, array $data) { // Hide all records initially if no filters are applied - if (empty($data['Plant']) && empty($data['machine']) && empty($data['item_id']) && empty($data['aufnr']) && empty($data['gernr']) && empty($data['zmm_heading']) && empty($data['created_from']) && empty($data['created_to'])) { + if (empty($data['Plant']) && empty($data['machine']) && empty($data['item_id']) && empty($data['aufnr']) && empty($data['gernr']) && empty($data['zmm_heading']) && empty($data['motor_marked_from']) && empty($data['motor_marked_to']) && empty($data['pump_marked_from']) && empty($data['pump_marked_to']) && empty($data['name_plate_marked_from']) && empty($data['name_plate_marked_to']) && empty($data['created_from']) && empty($data['created_to']) && empty($data['created_by']) && empty($data['updated_from']) && empty($data['updated_to']) && empty($data['updated_by'])) { return $query->whereRaw('1 = 0'); } @@ -2098,6 +2280,30 @@ class ClassCharacteristicResource extends Resource $query->where('zmm_heading', 'like', '%'.$data['zmm_heading'].'%'); } + if (! empty($data['motor_marked_from'])) { + $query->where('motor_marked_datetime', '>=', $data['motor_marked_from']); + } + + if (! empty($data['motor_marked_to'])) { + $query->where('motor_marked_datetime', '<=', $data['motor_marked_to']); + } + + if (! empty($data['pump_marked_from'])) { + $query->where('pump_marked_datetime', '>=', $data['pump_marked_from']); + } + + if (! empty($data['pump_marked_to'])) { + $query->where('pump_marked_datetime', '<=', $data['pump_marked_to']); + } + + if (! empty($data['name_plate_marked_from'])) { + $query->where('name_plate_marked_datetime', '>=', $data['name_plate_marked_from']); + } + + if (! empty($data['name_plate_marked_to'])) { + $query->where('name_plate_marked_datetime', '<=', $data['name_plate_marked_to']); + } + if (! empty($data['created_from'])) { $query->where('created_at', '>=', $data['created_from']); } @@ -2105,6 +2311,22 @@ class ClassCharacteristicResource extends Resource if (! empty($data['created_to'])) { $query->where('created_at', '<=', $data['created_to']); } + + if (! empty($data['created_by'])) { + $query->where('created_by', $data['created_by']); + } + + if (! empty($data['updated_from'])) { + $query->where('updated_at', '>=', $data['updated_from']); + } + + if (! empty($data['updated_to'])) { + $query->where('updated_at', '<=', $data['updated_to']); + } + + if (! empty($data['updated_by'])) { + $query->where('updated_by', $data['updated_by']); + } }) ->indicateUsing(function (array $data) { $indicators = []; @@ -2139,12 +2361,52 @@ class ClassCharacteristicResource extends Resource $indicators[] = 'Heading: '.$data['zmm_heading']; } + if (! empty($data['motor_marked_from'])) { + $indicators[] = 'Motor Marked From: '.$data['motor_marked_from']; + } + + if (! empty($data['motor_marked_to'])) { + $indicators[] = 'Motor Marked To: '.$data['motor_marked_to']; + } + + if (! empty($data['pump_marked_from'])) { + $indicators[] = 'Pump Marked From: '.$data['pump_marked_from']; + } + + if (! empty($data['pump_marked_to'])) { + $indicators[] = 'Pump Marked To: '.$data['pump_marked_to']; + } + + if (! empty($data['name_plate_marked_from'])) { + $indicators[] = 'Name Plate Marked From: '.$data['name_plate_marked_from']; + } + + if (! empty($data['name_plate_marked_to'])) { + $indicators[] = 'Name Plate Marked To: '.$data['name_plate_marked_to']; + } + if (! empty($data['created_from'])) { - $indicators[] = 'From: '.$data['created_from']; + $indicators[] = 'Created From: '.$data['created_from']; } if (! empty($data['created_to'])) { - $indicators[] = 'To: '.$data['created_to']; + $indicators[] = 'Created To: '.$data['created_to']; + } + + if (! empty($data['created_by'])) { + $indicators[] = 'Created By: '.$data['created_by']; + } + + if (! empty($data['updated_from'])) { + $indicators[] = 'Updated From: '.$data['updated_from']; + } + + if (! empty($data['updated_to'])) { + $indicators[] = 'Updated To: '.$data['updated_to']; + } + + if (! empty($data['updated_by'])) { + $indicators[] = 'Updated By: '.$data['updated_by']; } return $indicators;