<?php

namespace App\Filament\Resources;

use App\Filament\Exports\ItemCharacteristicExporter;
use App\Filament\Imports\ItemCharacteristicImporter;
use App\Filament\Resources\ItemCharacteristicResource\Pages;
use App\Filament\Resources\ItemCharacteristicResource\RelationManagers;
use App\Models\Item;
use App\Models\ItemCharacteristic;
use App\Models\Plant;
use Filament\Facades\Filament;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Tables\Actions\ExportAction;
use Filament\Tables\Actions\ImportAction;
use Filament\Forms\Components\Section;

class ItemCharacteristicResource extends Resource
{
    protected static ?string $model = ItemCharacteristic::class;

    protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';

    protected static ?string $navigationGroup = 'Customized Sticker Printing';

    public static function form(Form $form): Form
    {
        return $form
            ->schema([
                Section::make('')
                    ->schema([
                 Forms\Components\Select::make('plant_id')
                    ->label('Plant')
                    ->reactive()
                    ->relationship('plant', 'name')
                    ->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();
                    })
                    ->required(),
                Forms\Components\Select::make('item_id')
                    ->label('Item Code')
                    //->relationship('item', 'id')
                    ->reactive()
                    ->searchable()
                    ->options(function (callable $get) {
                        $plantId = $get('plant_id');
                        if (empty($plantId)) {
                            return [];
                        }
                        return Item::where('plant_id', $plantId)->pluck('code', 'id');
                    })
                    ->required(),
                Forms\Components\TextInput::make('class')
                    ->label('CLASS'),
                Forms\Components\TextInput::make('zz1_cn_bill_ord')
                    ->label('ZZ1 CN BILL ORD'),
                Forms\Components\TextInput::make('zmm_amps')
                    ->label('ZMM AMPS'),
                Forms\Components\TextInput::make('zmm_brand')
                    ->label('ZMM BRAND'),
                Forms\Components\TextInput::make('zmm_degreeofprotection')
                    ->label('ZMM DEGREE OF PROTECTION'),
                Forms\Components\TextInput::make('zmm_delivery')
                    ->label('ZMM DELIVERY'),
                Forms\Components\TextInput::make('zmm_dir_rot')
                    ->label('ZMM DIRECTION ROTATION'),
                Forms\Components\TextInput::make('zmm_discharge')
                    ->label('ZMM DISCHARGE'),
                Forms\Components\TextInput::make('zmm_discharge_max')
                    ->label('ZMM DISCHARGE MAX'),
                Forms\Components\TextInput::make('zmm_discharge_min')
                    ->label('ZMM DISCHARGE MIN'),
                Forms\Components\TextInput::make('zmm_duty')
                    ->label('ZMM DUTY'),
                Forms\Components\TextInput::make('zmm_eff_motor')
                    ->label('ZMM EFF MOTOR'),
                Forms\Components\TextInput::make('zmm_eff_pump')
                    ->label('ZMM EFF PUMP'),
                Forms\Components\TextInput::make('zmm_frequency')
                    ->label('ZMM FREQUENCY'),
                Forms\Components\TextInput::make('zmm_head')
                    ->label('ZMM HEAD'),
                Forms\Components\TextInput::make('zmm_heading')
                    ->label('ZMM HEADING'),
                Forms\Components\TextInput::make('zmm_head_max')
                    ->label('ZMM HEAD MAX'),
                Forms\Components\TextInput::make('zmm_head_minimum')
                    ->label('ZMM HEAD MINIMUM'),
                Forms\Components\TextInput::make('zmm_idx_eff_mtr')
                    ->label('ZMM IDX EFF MTR'),
                Forms\Components\TextInput::make('zmm_idx_eff_pump')
                    ->label('ZMM IDX EFF PUMP'),
                Forms\Components\TextInput::make('zmm_kvacode')
                    ->label('ZMM KVACODE'),
                Forms\Components\TextInput::make('zmm_maxambtemp')
                    ->label('ZMM MAX AMB TEMP'),
                Forms\Components\TextInput::make('zmm_mincoolingflow')
                    ->label('ZMM MIN COOLING FLOW'),
                Forms\Components\TextInput::make('zmm_motorseries')
                    ->label('ZMM MOTOR SERIES'),
                Forms\Components\TextInput::make('zmm_motor_model')
                    ->label('ZMM MOTOR MODEL'),
                Forms\Components\TextInput::make('zmm_outlet')
                    ->label('ZMM OUTLET'),
                Forms\Components\TextInput::make('zmm_phase')
                    ->label('ZMM PHASE'),
                Forms\Components\TextInput::make('zmm_pressure')
                    ->label('ZMM PRESSURE'),
                Forms\Components\TextInput::make('zmm_pumpflowtype')
                    ->label('ZMM PUMP FLOW TYPE'),
                Forms\Components\TextInput::make('zmm_pumpseries')
                    ->label('ZMM PUMP SERIES'),
                Forms\Components\TextInput::make('zmm_pump_model')
                    ->label('ZMM PUMP MODEL'),
                Forms\Components\TextInput::make('zmm_ratedpower')
                    ->label('ZMM RATED POWER'),
                Forms\Components\TextInput::make('zmm_region')
                    ->label('ZMM REGION'),
                Forms\Components\TextInput::make('zmm_servicefactor')
                    ->label('ZMM SERVICE FACTOR'),
                Forms\Components\TextInput::make('zmm_servicefactormaximumamps')
                    ->label('ZMM SERVICE FACTOR MAXIMUM AMPS'),
                Forms\Components\TextInput::make('zmm_speed')
                    ->label('ZMM SPEED'),
                Forms\Components\TextInput::make('zmm_suction')
                    ->label('ZMM SUCTION'),
                Forms\Components\TextInput::make('zmm_suctionxdelivery')
                    ->label('ZMM SUCTION X DELIVERY'),
                Forms\Components\TextInput::make('zmm_supplysource')
                    ->label('ZMM SUPPLY SOURCE'),
                Forms\Components\TextInput::make('zmm_temperature')
                    ->label('ZMM TEMPERATURE'),
                Forms\Components\TextInput::make('zmm_thrustload')
                    ->label('ZMM THRUST LOAD'),
                Forms\Components\TextInput::make('zmm_volts')
                    ->label('ZMM VOLTS'),
                Forms\Components\TextInput::make('zmm_wire')
                    ->label('ZMM WIRE'),
                Forms\Components\TextInput::make('zmm_package')
                    ->label('ZMM PACKAGE'),
                Forms\Components\TextInput::make('zmm_pvarrayrating')
                    ->label('ZMM PV ARRAY RATING'),
                Forms\Components\TextInput::make('zmm_isi')
                    ->label('ZMM ISI'),
                Forms\Components\TextInput::make('zmm_isimotor')
                    ->label('ZMM ISI MOTOR'),
                Forms\Components\TextInput::make('zmm_isipump')
                    ->label('ZMM ISI PUMP'),
                Forms\Components\TextInput::make('zmm_isipumpset')
                    ->label('ZMM ISI PUMP SET'),
                Forms\Components\TextInput::make('zmm_pumpset_model')
                    ->label('ZMM PUMP SET MODEL'),
                Forms\Components\TextInput::make('zmm_stages')
                    ->label('ZMM STAGES'),
                Forms\Components\TextInput::make('zmm_headrange')
                    ->label('ZMM HEAD RANGE'),
                Forms\Components\TextInput::make('zmm_overall_efficiency')
                    ->label('ZMM OVERALL EFFICIENCY'),
                Forms\Components\TextInput::make('zmm_connection')
                    ->label('ZMM CONNECTION'),
                Forms\Components\TextInput::make('zmm_min_bore_size')
                    ->label('ZMM MIN BORE SIZE'),
                Forms\Components\TextInput::make('zmm_isireference')
                    ->label('ZMM ISI REFERENCE'),
                Forms\Components\TextInput::make('zmm_category')
                    ->label('ZMM CATEGORY'),
                Forms\Components\TextInput::make('zmm_submergence')
                    ->label('ZMM SUBMERGENCE'),
                Forms\Components\TextInput::make('zmm_capacitorstart')
                    ->label('ZMM CAPACITOR START'),
                Forms\Components\TextInput::make('zmm_capacitorrun')
                    ->label('ZMM CAPACITOR RUN'),
                Forms\Components\TextInput::make('zmm_inch')
                    ->label('ZMM INCH'),
                Forms\Components\TextInput::make('zmm_motor_type')
                    ->label('ZMM MOTOR TYPE'),
                Forms\Components\TextInput::make('zmm_dismantle_direction')
                    ->label('ZMM DISMANTLE DIRECTION'),
                Forms\Components\TextInput::make('zmm_eff_ovrall')
                    ->label('ZMM OVERALL EFFICIENCY'),
                Forms\Components\TextInput::make('zmm_bodymoc')
                    ->label('ZMM BODY MOC'),
                Forms\Components\TextInput::make('zmm_rotormoc')
                    ->label('ZMM ROTOR MOC'),
                Forms\Components\TextInput::make('zmm_dlwl')
                    ->label('ZMM DLWL'),
                Forms\Components\TextInput::make('zmm_inputpower')
                    ->label('ZMM INPUT POWER'),
                Forms\Components\TextInput::make('zmm_imp_od')
                    ->label('ZMM IMP OD'),
                Forms\Components\TextInput::make('zmm_ambtemp')
                    ->label('ZMM AMBIENT TEMPERATURE'),
                Forms\Components\TextInput::make('zmm_de')
                    ->label('ZMM DE'),
                Forms\Components\TextInput::make('zmm_dischargerange')
                    ->label('ZMM DISCHARGE RANGE'),
                Forms\Components\TextInput::make('zmm_efficiency_class')
                    ->label('ZMM EFFICIENCY CLASS'),
                Forms\Components\TextInput::make('zmm_framesize')
                    ->label('ZMM FRAME SIZE'),
                Forms\Components\TextInput::make('zmm_impellerdiameter')
                    ->label('ZMM IMPELLER DIAMETER'),
                Forms\Components\TextInput::make('zmm_insulationclass')
                    ->label('ZMM INSULATION CLASS'),
                Forms\Components\TextInput::make('zmm_maxflow')
                    ->label('ZMM MAX FLOW'),
                Forms\Components\TextInput::make('zmm_minhead')
                    ->label('ZMM MIN HEAD'),
                Forms\Components\TextInput::make('zmm_mtrlofconst')
                    ->label('ZMM MOTOR LOAD CONSTANT'),
                Forms\Components\TextInput::make('zmm_nde')
                    ->label('ZMM NDE'),
                Forms\Components\TextInput::make('zmm_powerfactor')
                    ->label('ZMM POWER FACTOR'),
                Forms\Components\TextInput::make('zmm_tagno')
                    ->label('ZMM TAGNO'),
                Forms\Components\TextInput::make('zmm_year')
                    ->label('ZMM YEAR'),
                Forms\Components\TextInput::make('zmm_laser_name')
                    ->label('ZMM LASER NAME'),
                Forms\Components\TextInput::make('zmm_beenote')
                    ->label('ZMM BEE NOTE'),
                Forms\Components\TextInput::make('zmm_beenumber')
                    ->label('ZMM BEE NUMBER'),
                Forms\Components\TextInput::make('zmm_beestar')
                    ->label('ZMM BEE STAR'),
                Forms\Components\TextInput::make('zmm_logo_ce')
                    ->label('ZMM LOGO CE'),
                Forms\Components\TextInput::make('zmm_codeclass')
                    ->label('ZMM CODE CLASS'),
                Forms\Components\TextInput::make('zmm_colour')
                    ->label('ZMM COLOUR'),
                Forms\Components\TextInput::make('zmm_logo_cp')
                    ->label('ZMM LOGO CP'),
                Forms\Components\TextInput::make('zmm_grade')
                    ->label('ZMM GRADE'),
                Forms\Components\TextInput::make('zmm_grwt_pset')
                    ->label('ZMM GRWT PSET'),
                Forms\Components\TextInput::make('zmm_grwt_cable')
                    ->label('ZMM GRWT CABLE'),
                Forms\Components\TextInput::make('zmm_grwt_motor')
                    ->label('ZMM GRWT MOTOR'),
                Forms\Components\TextInput::make('zmm_grwt_pf')
                    ->label('ZMM GRWT PF'),
                Forms\Components\TextInput::make('zmm_grwt_pump')
                    ->label('ZMM GRWT PUMP'),
                Forms\Components\TextInput::make('zmm_isivalve')
                    ->label('ZMM ISIV ALVE'),
                Forms\Components\TextInput::make('zmm_isi_wc')
                    ->label('ZMM ISIV WC'),
                Forms\Components\TextInput::make('zmm_labelperiod')
                    ->label('ZMM LABEL PERIOD'),
                Forms\Components\TextInput::make('zmm_length')
                    ->label('ZMM LENGTH'),
                Forms\Components\TextInput::make('zmm_license_cml_no')
                    ->label('ZMM LICENSE CML NO'),
                Forms\Components\TextInput::make('zmm_mfgmonyr')
                    ->label('ZMM MFG MON YR'),
                Forms\Components\TextInput::make('zmm_modelyear')
                    ->label('ZMM MODEL YEAR'),
                Forms\Components\TextInput::make('zmm_motoridentification')
                    ->label('ZMM MOTOR IDENTIFICATION'),
                Forms\Components\TextInput::make('zmm_newt_pset')
                    ->label('ZMM NEWT PSET'),
                Forms\Components\TextInput::make('zmm_newt_cable')
                    ->label('ZMM NEWT CABLE'),
                Forms\Components\TextInput::make('zmm_newt_motor')
                    ->label('ZMM NEWT MOTOR'),
                Forms\Components\TextInput::make('zmm_newt_pf')
                    ->label('ZMM NEWT PF'),
                Forms\Components\TextInput::make('zmm_newt_pump')
                    ->label('ZMM NEWT PUMP'),
                Forms\Components\TextInput::make('zmm_logo_nsf')
                    ->label('ZMM LOGO NSF'),
                Forms\Components\TextInput::make('zmm_packtype')
                    ->label('ZMM PACK TYPE'),
                Forms\Components\TextInput::make('zmm_panel')
                    ->label('ZMM PANEL'),
                Forms\Components\TextInput::make('zmm_performance_factor')
                    ->label('ZMM PERFORMANCE FACTOR'),
                Forms\Components\TextInput::make('zmm_pumpidentification')
                    ->label('ZMM PUMP IDENTIFICATION'),
                Forms\Components\TextInput::make('zmm_psettype')
                    ->label('ZMM PSET TYPE'),
                Forms\Components\TextInput::make('zmm_size')
                    ->label('ZMM SIZE'),
                Forms\Components\TextInput::make('zmm_eff_ttl')
                    ->label('ZMM EFF TTL'),
                Forms\Components\TextInput::make('zmm_type')
                    ->label('ZMM TYPE'),
                Forms\Components\TextInput::make('zmm_usp')
                    ->label('ZMM USP'),
                Forms\Components\TextInput::make('zmm_operating_range')
                    ->label('ZMM OPERATING RANGE'),
                Forms\Components\TextInput::make('zmm_intake_air')
                    ->label('ZMM INTAKE AIR'),
                Forms\Components\TextInput::make('zmm_oxygen_transfer_rate')
                    ->label('ZMM OXYGEN TRANSFER RATE'),
                Forms\Components\TextInput::make('zmm_air_inlet_pipesize')
                    ->label('ZMM AIR INLET PIPESIZE'),
                Forms\Components\TextInput::make('zmm_sump_depth')
                    ->label('ZMM SUMP DEPTH'),
                Forms\Components\TextInput::make('zmm_poles')
                    ->label('ZMM POLES'),
                Forms\Components\TextInput::make('zmm_motor_heading')
                    ->label('ZMM MOTOR HEADING'),
                Forms\Components\TextInput::make('zmm_motor_speed')
                    ->label('ZMM MOTOR SPEED'),
                Forms\Components\TextInput::make('zqmm_qty')
                    ->label('ZMM QTY'),
                Forms\Components\TextInput::make('mrp')
                    ->label('MRP'),
                Forms\Components\TextInput::make('zmm_1')
                    ->label('ZMM 1'),
                Forms\Components\TextInput::make('zmm_2')
                    ->label('ZMM 2'),
                Forms\Components\TextInput::make('zmm_3')
                    ->label('ZMM 3'),
                Forms\Components\TextInput::make('zmm_4')
                    ->label('ZMM 4'),
                Forms\Components\TextInput::make('zmm_5')
                    ->label('ZMM 5'),
                Forms\Components\TextInput::make('zmm_6')
                    ->label('ZMM 6'),
                Forms\Components\TextInput::make('zmm_7')
                    ->label('ZMM 7'),
                Forms\Components\TextInput::make('zmm_8')
                    ->label('ZMM 8'),
                Forms\Components\TextInput::make('zmm_9')
                    ->label('ZMM 9'),
                Forms\Components\TextInput::make('zmm_10')
                    ->label('ZMM 10'),
                Forms\Components\TextInput::make('zmm_11')
                    ->label('ZMM 11'),
                Forms\Components\TextInput::make('zmm_12')
                    ->label('ZMM 12'),
                Forms\Components\TextInput::make('zmm_13')
                    ->label('ZMM 13'),
                Forms\Components\TextInput::make('zmm_14')
                    ->label('ZMM 14'),
                Forms\Components\TextInput::make('zmm_15')
                    ->label('ZMM 15'),
                Forms\Components\Hidden::make('created_by')
                    ->label('Created By')
                    ->default(Filament::auth()->user()?->name),
                Forms\Components\Hidden::make('updated_by')
                    ->label('Updated By')
                    ->default(Filament::auth()->user()?->name),
            ])
            ->columns(3),
        ]);
    }

    public static function table(Table $table): Table
    {
        return $table
            ->columns([
                // Tables\Columns\TextColumn::make('id')
                //     ->label('ID')
                //     ->numeric()
                //     ->sortable(),
                Tables\Columns\TextColumn::make('No.')
                    ->label('No.')
                    ->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
                        $paginator = $livewire->getTableRecords();
                        $perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
                        $currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;

                        return ($currentPage - 1) * $perPage + $rowLoop->iteration;
                    }),
                Tables\Columns\TextColumn::make('plant.name')
                    ->label('PLANT')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('item.code')
                    ->label('ITEM CODE')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('class')
                    ->label('CLASS')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zz1_cn_bill_ord')
                    ->label('ZZ1 CN BILL ORD')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_amps')
                    ->label('ZMM AMPS')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_brand')
                    ->label('ZMM BRAND')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_degreeofprotection')
                    ->label('ZMM DEGREE OF PROTECTION')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_delivery')
                    ->label('ZMM DELIVERY')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_dir_rot')
                    ->label('ZMM DIRECTION ROTATION')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_discharge')
                    ->label('ZMM DISCHARGE')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_discharge_max')
                    ->label('ZMM DISCHARGE MAX')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_discharge_min')
                    ->label('ZMM DISCHARGE MIN')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_duty')
                    ->label('ZMM DUTY')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_eff_motor')
                    ->label('ZMM EFF MOTOR')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_eff_pump')
                    ->label('ZMM EFF PUMP')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_frequency')
                    ->label('ZMM FREQUENCY')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_head')
                    ->label('ZMM HEAD')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_heading')
                    ->label('ZMM HEADING')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_head_max')
                    ->label('ZMM HEAD MAX')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_head_minimum')
                    ->label('ZMM HEAD MINIMUM')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_idx_eff_mtr')
                    ->label('ZMM IDX EFF MTR')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_idx_eff_pump')
                    ->label('ZMM IDX EFF PUMP')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_kvacode')
                    ->label('ZMM KVACODE')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_maxambtemp')
                    ->label('ZMM MAX AMB TEMP')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_mincoolingflow')
                    ->label('ZMM MIN COOLING FLOW')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_motorseries')
                    ->label('ZMM MOTOR SERIES')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_motor_model')
                    ->label('ZMM MOTOR MODEL')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_outlet')
                    ->label('ZMM OUTLET')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_phase')
                    ->label('ZMM PHASE')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_pressure')
                    ->label('ZMM PRESSURE')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_pumpflowtype')
                    ->label('ZMM PUMP FLOW TYPE')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_pumpseries')
                    ->label('ZMM PUMP SERIES')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_pump_model')
                    ->label('ZMM PUMP MODEL')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_ratedpower')
                    ->label('ZMM RATED POWER')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_region')
                    ->label('ZMM REGION')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_servicefactor')
                    ->label('ZMM SERVICE FACTOR')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_servicefactormaximumamps')
                    ->label('ZMM SERVICE FACTOR MAXIMUM AMPS')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_speed')
                    ->label('ZMM SPEED')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_suction')
                    ->label('ZMM SUCTION')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_suctionxdelivery')
                    ->label('ZMM SUCTION X DELIVERY')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_supplysource')
                    ->label('ZMM SUPPLY SOURCE')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_temperature')
                    ->label('ZMM TEMPERATURE')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_thrustload')
                    ->label('ZMM THRUST LOAD')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_volts')
                    ->label('ZMM VOLTS')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_wire')
                    ->label('ZMM WIRE')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_package')
                    ->label('ZMM PACKAGE')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_pvarrayrating')
                    ->label('ZMM PV ARRAY RATING')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_isi')
                    ->label('ZMM ISI')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_isimotor')
                    ->label('ZMM ISI MOTOR')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_isipump')
                    ->label('ZMM ISI PUMP')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_isipumpset')
                    ->label('ZMM ISI PUMP SET')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_pumpset_model')
                    ->label('ZMM PUMP SET MODEL')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_stages')
                    ->label('ZMM STAGES')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_headrange')
                    ->label('ZMM HEAD RANGE')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_overall_efficiency')
                    ->label('ZMM OVERALL EFFICIENCY')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_connection')
                    ->label('ZMM CONNECTION')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_min_bore_size')
                    ->label('ZMM MIN BORE SIZE')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_isireference')
                    ->label('ZMM ISI REFERENCE')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_category')
                    ->label('ZMM CATEGORY')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_submergence')
                    ->label('ZMM SUBMERGENCE')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_capacitorstart')
                    ->label('ZMM CAPACITOR START')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_capacitorrun')
                    ->label('ZMM CAPACITOR RUN')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_inch')
                    ->label('ZMM INCH')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_motor_type')
                    ->label('ZMM MOTOR TYPE')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_dismantle_direction')
                    ->label('ZMM DISMANTLE DIRECTION')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_eff_ovrall')
                    ->label('ZMM OVERALL EFFICIENCY')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_bodymoc')
                    ->label('ZMM BODY MOC')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_rotormoc')
                    ->label('ZMM ROTOR MOC')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_dlwl')
                    ->label('ZMM DLWL')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_inputpower')
                    ->label('ZMM INPUT POWER')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_imp_od')
                    ->label('ZMM IMP OD')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_ambtemp')
                    ->label('ZMM AMBIENT TEMPERATURE')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_de')
                    ->label('ZMM DE')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_dischargerange')
                    ->label('ZMM DISCHARGE RANGE')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_efficiency_class')
                    ->label('ZMM EFFICIENCY CLASS')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_framesize')
                    ->label('ZMM FRAME SIZE')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_impellerdiameter')
                    ->label('ZMM IMPPELLER DIAMETER')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_insulationclass')
                    ->label('ZMM INSULATION CLASS')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_maxflow')
                    ->label('ZMM MAX FLOW')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_minhead')
                    ->label('ZMM MIN HEAD')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_mtrlofconst')
                    ->label('ZMM MOTOR LOAD CONSTANT')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_nde')
                    ->label('ZMM NDE')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_powerfactor')
                    ->label('ZMM POWER FACTOR')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_tagno')
                    ->label('ZMM TAGNO')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_year')
                    ->label('ZMM YEAR')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_laser_name')
                    ->label('ZMM LASER NAME')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_beenote')
                    ->label('ZMM BEE NOTE')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_beenumber')
                    ->label('ZMM BEE NUMBER')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_beestar')
                    ->label('ZMM BEE STAR')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_logo_ce')
                    ->label('ZMM LOGO CE')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_codeclass')
                    ->label('ZMM CODE CLASS')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_colour')
                    ->label('ZMM COLOUR')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_logo_cp')
                    ->label('ZMM LOGO CP')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_grade')
                    ->label('ZMM GRADE')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_grwt_pset')
                    ->label('ZMM GRWT PSET')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_grwt_cable')
                    ->label('ZMM GRWT CABLE')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_grwt_motor')
                    ->label('ZMM GRWT MOTOR')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_grwt_pf')
                    ->label('ZMM GRWT PF')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_grwt_pump')
                    ->label('ZMM GRWT PUMP')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_isivalve')
                    ->label('ZMM ISIV ALVE')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_isi_wc')
                    ->label('ZMM ISIV WC')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_labelperiod')
                    ->label('ZMM LABEL PERIOD')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_length')
                    ->label('ZMM LENGTH')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_license_cml_no')
                    ->label('ZMM LICENSE CML NO')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_mfgmonyr')
                    ->label('ZMM MFG MON YR')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_modelyear')
                    ->label('ZMM MODEL YEAR')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_motoridentification')
                    ->label('ZMM MOTOR IDENTIFICATION')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_newt_pset')
                    ->label('ZMM NEWT PSET')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_newt_cable')
                    ->label('ZMM NEWT CABLE')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_newt_motor')
                    ->label('ZMM NEWT MOTOR')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_newt_pf')
                    ->label('ZMM NEWT PF')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_newt_pump')
                    ->label('ZMM NEWT PUMP')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_logo_nsf')
                    ->label('ZMM LOGO NSF')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_packtype')
                    ->label('ZMM PACK TYPE')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_panel')
                    ->label('ZMM PANEL')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_performance_factor')
                    ->label('ZMM PERFORMANCE FACTOR')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_pumpidentification')
                    ->label('ZMM PUMP IDENTIFICATION')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_psettype')
                    ->label('ZMM PSET TYPE')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_size')
                    ->label('ZMM SIZE')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_eff_ttl')
                    ->label('ZMM EFF TTL')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_type')
                    ->label('ZMM TYPE')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_usp')
                    ->label('ZMM USP')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_operating_range')
                    ->label('ZMM OPERATING RANGE')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_intake_air')
                    ->label('ZMM INTAKE AIR')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_oxygen_transfer_rate')
                    ->label('ZMM OXYGEN TRANSFER RATE')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_air_inlet_pipesize')
                    ->label('ZMM AIR INLET PIPESIZE')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_sump_depth')
                    ->label('ZMM SUMP DEPTH')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_poles')
                    ->label('ZMM POLES')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_motor_heading')
                    ->label('ZMM MOTOR HEADING')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_motor_speed')
                    ->label('ZMM MOTOR SPEED')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zqmm_qty')
                    ->label('ZMM QTY')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('mrp')
                    ->label('MRP')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_1')
                    ->label('ZMM 1')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_2')
                    ->label('ZMM 2')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_3')
                    ->label('ZMM 3')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_4')
                    ->label('ZMM 4')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_5')
                    ->label('ZMM 5')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_6')
                    ->label('ZMM 6')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_7')
                    ->label('ZMM 7')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_8')
                    ->label('ZMM 8')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_9')
                    ->label('ZMM 9')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_10')
                    ->label('ZMM 10')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_11')
                    ->label('ZMM 11')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_12')
                    ->label('ZMM 12')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_13')
                    ->label('ZMM 13')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_14')
                    ->label('ZMM 14')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_15')
                    ->label('ZMM 15')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('created_by')
                    ->label('CREATED BY')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('created_at')
                    ->dateTime()
                    ->sortable()
                    ->toggleable(isToggledHiddenByDefault: true),
                Tables\Columns\TextColumn::make('updated_at')
                    ->dateTime()
                    ->sortable()
                    ->toggleable(isToggledHiddenByDefault: true),
                Tables\Columns\TextColumn::make('updated_by')
                    ->label('UPDATED BY')
                    ->alignCenter()
                    ->sortable()
                    ->toggleable(isToggledHiddenByDefault: true),
                Tables\Columns\TextColumn::make('deleted_at')
                    ->dateTime()
                    ->sortable()
                    ->toggleable(isToggledHiddenByDefault: true),
            ])
            ->filters([
                Tables\Filters\TrashedFilter::make(),
            ])
            ->actions([
                Tables\Actions\ViewAction::make(),
                Tables\Actions\EditAction::make(),
            ])
            ->bulkActions([
                Tables\Actions\BulkActionGroup::make([
                    Tables\Actions\DeleteBulkAction::make(),
                    Tables\Actions\ForceDeleteBulkAction::make(),
                    Tables\Actions\RestoreBulkAction::make(),
                ]),
            ])
            ->headerActions([
                ImportAction::make()
                    ->label('Import Item Characteristics')
                    ->color('warning')
                    ->importer(ItemCharacteristicImporter::class)
                    ->visible(function() {
                        return Filament::auth()->user()->can('view import item characteristics');
                    }),
                ExportAction::make()
                    ->label('Export Item Characteristics')
                    ->color('warning')
                    ->exporter(ItemCharacteristicExporter::class)
                    ->visible(function() {
                        return Filament::auth()->user()->can('view export item characteristics');
                    }),
            ]);

    }

    public static function getRelations(): array
    {
        return [
            //
        ];
    }

    public static function getPages(): array
    {
        return [
            'index' => Pages\ListItemCharacteristics::route('/'),
            'create' => Pages\CreateItemCharacteristic::route('/create'),
            'view' => Pages\ViewItemCharacteristic::route('/{record}'),
            'edit' => Pages\EditItemCharacteristic::route('/{record}/edit'),
        ];
    }

    public static function getEloquentQuery(): Builder
    {
        return parent::getEloquentQuery()
            ->withoutGlobalScopes([
                SoftDeletingScope::class,
            ]);
    }
}
