<?php

namespace App\Filament\Resources;

use App\Filament\Exports\ClassCharacteristicExporter;
use App\Filament\Imports\ClassCharacteristicImporter;
use App\Filament\Resources\ClassCharacteristicResource\Pages;
use App\Filament\Resources\ClassCharacteristicResource\RelationManagers;
use App\Models\ClassCharacteristic;
use App\Models\Plant;
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\Facades\Filament;
use Filament\Tables\Actions\ImportAction;
use Filament\Tables\Actions\ExportAction;

class ClassCharacteristicResource extends Resource
{
    protected static ?string $model = ClassCharacteristic::class;

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

    protected static ?string $navigationGroup = 'Laser';

    public static function form(Form $form): Form
    {
        return $form
            ->schema([
                Forms\Components\Select::make('plant_id')
                    ->label('Plant')
                    ->relationship('plant', 'name')
                    ->reactive()
                    ->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')
                    //->relationship('item', 'id')
                    ->label('Item Code')
                    ->reactive()
                    ->searchable()
                    ->options(function (callable $get) {
                        $plantId = $get('plant_id');
                        if (empty($plantId)) {
                            return [];
                        }
                        return \App\Models\Item::where('plant_id', $plantId)->pluck('code', 'id');
                    })
                    ->required(),
                Forms\Components\Select::make('machine_id')
                    //->relationship('item', 'id')
                    ->label('Machine')
                    ->reactive()
                    ->options(function (callable $get) {
                        $plantId = $get('plant_id');
                        // $itemId = $get('item_id');
                        if (empty($plantId)) {
                            return [];
                        }
                        return \App\Models\Machine::where('plant_id', $plantId)
                        ->pluck('work_center', 'id');
                    })
                    ->required(),
                Forms\Components\TextInput::make('aufnr')
                    ->label('AUFNR'),
                Forms\Components\TextInput::make('class')
                    ->label('CLASS'),
                Forms\Components\TextInput::make('arbid')
                    ->label('ARBID'),
                Forms\Components\TextInput::make('gamng')
                    ->label('GAMNG'),
                Forms\Components\TextInput::make('lmnga')
                    ->label('LMNGA'),
                Forms\Components\TextInput::make('gernr')
                    ->label('GERNR'),
                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_DEGREEOFPROTECTION'),
                Forms\Components\TextInput::make('zmm_delivery')
                    ->label('ZMM_DELIVERY'),
                Forms\Components\TextInput::make('zmm_dir_rot')
                    ->label('ZMM_DIR_ROT'),
                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_dutytext')
                    ->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_MAXAMBTEMP'),
                Forms\Components\TextInput::make('zmm_mincoolingflow')
                    ->label('ZMM_MINCOOLINGFLOW'),
                Forms\Components\TextInput::make('zmm_motorseries')
                    ->label('ZMM_MOTORSERIES'),
                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_PUMPFLOWTYPE'),
                Forms\Components\TextInput::make('zmm_pumpseries')
                    ->label('ZMM_PUMPSERIES'),
                Forms\Components\TextInput::make('zmm_pump_model')
                    ->label('ZMM_PUMP_MODEL'),
                Forms\Components\TextInput::make('zmm_ratedpower')
                    ->label('ZMM_RATEDPOWER'),
                Forms\Components\TextInput::make('zmm_regiontext')
                    ->label('ZMM_REGIONTEXT'),
                Forms\Components\TextInput::make('zmm_servicefactortext')
                    ->label('ZMM_SERVICEFACTORTEXT'),
                Forms\Components\TextInput::make('zmm_servicefactormaximumamps')
                    ->label('ZMM_SERVICEFACTORMAXIMUMAMPS'),
                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_SUCTIONXDELIVERY'),
                Forms\Components\TextInput::make('zmm_supplysource')
                    ->label('ZMM_SUPPLYSOURCE'),
                Forms\Components\TextInput::make('zmm_temperature')
                    ->label('ZMM_TEMPERATURE'),
                Forms\Components\TextInput::make('zmm_thrustload')
                    ->label('ZMM_THRUSTLOAD'),
                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_PVARRAYRATING'),
                Forms\Components\TextInput::make('zmm_isi')
                    ->label('ZMM_ISI'),
                Forms\Components\TextInput::make('zmm_isimotor')
                    ->label('ZMM_ISIMOTOR'),
                Forms\Components\TextInput::make('zmm_isipump')
                    ->label('ZMM_ISIPUMP'),
                Forms\Components\TextInput::make('zmm_isipumpset')
                    ->label('ZMM_ISIPUMPSET'),
                Forms\Components\TextInput::make('zmm_pumpset_model')
                    ->label('ZMM_PUMPSET_MODEL'),
                Forms\Components\TextInput::make('zmm_stages')
                    ->label('ZMM_STAGES'),
                Forms\Components\TextInput::make('zmm_headrange')
                    ->label('ZMM_HEADRANGE'),
                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_ISIREFERENCE'),
                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_CAPACITORSTART'),
                Forms\Components\TextInput::make('zmm_capacitorrun')
                    ->label('ZMM_CAPACITORRUN'),
                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_EFF_OVRALL'),
                Forms\Components\TextInput::make('zmm_bodymoc')
                    ->label('ZMM_BODYMOC'),
                Forms\Components\TextInput::make('zmm_rotormoc')
                    ->label('ZMM_ROTORMOC'),
                Forms\Components\TextInput::make('zmm_dlwl')
                    ->label('ZMM_DLWL'),
                Forms\Components\TextInput::make('zmm_inputpower')
                    ->label('ZMM_INPUTPOWER'),
                Forms\Components\TextInput::make('zmm_imp_od')
                    ->label('ZMM_IMP_OD'),
                Forms\Components\TextInput::make('zmm_ambtemp')
                    ->label('ZMM_AMBTEMP'),
                Forms\Components\TextInput::make('zmm_de')
                    ->label('ZMM_DE'),
                Forms\Components\TextInput::make('zmm_dischargerange')
                    ->label('ZMM_DISCHARGERANGE'),
                Forms\Components\TextInput::make('zmm_efficiency_class')
                    ->label('ZMM_EFFICIENCY_CLASS'),
                Forms\Components\TextInput::make('zmm_framesize')
                    ->label('ZMM_FRAMESIZE'),
                Forms\Components\TextInput::make('zmm_impellerdiameter')
                    ->label('ZMM_IMPELLERDIAMETER'),
                Forms\Components\TextInput::make('zmm_insulationclass')
                    ->label('ZMM_INSULATIONCLASS'),
                Forms\Components\TextInput::make('zmm_maxflow')
                    ->label('ZMM_MAXFLOW'),
                Forms\Components\TextInput::make('zmm_minhead')
                    ->label('ZMM_MINHEAD'),
                Forms\Components\TextInput::make('zmm_mtrlofconst')
                    ->label('ZMM_MTRLOFCONST'),
                Forms\Components\TextInput::make('zmm_nde')
                    ->label('ZMM_NDE'),
                Forms\Components\TextInput::make('zmm_powerfactor')
                    ->label('ZMM_POWERFACTOR'),
                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_BEENOTE'),
                Forms\Components\TextInput::make('zmm_beenumber')
                    ->label('ZMM_BEENUMBER'),
                Forms\Components\TextInput::make('zmm_beestar')
                    ->label('ZMM_BEESTAR'),
                Forms\Components\TextInput::make('zmm_logo_ce')
                    ->label('ZMM_LOGO_CE'),
                Forms\Components\TextInput::make('zmm_codeclass')
                    ->label('ZMM_CODECLASS'),
                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_ISIVALVE'),
                Forms\Components\TextInput::make('zmm_isi_wc')
                    ->label('ZMM_ISI_WC'),
                Forms\Components\TextInput::make('zmm_labelperiod')
                    ->label('ZMM_LABELPERIOD'),
                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_MFGMONYR'),
                Forms\Components\TextInput::make('zmm_modelyear')
                    ->label('ZMM_MODELYEAR'),
                Forms\Components\TextInput::make('zmm_motoridentification')
                    ->label('ZMM_MOTORIDENTIFICATION'),
                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_PACKTYPE'),
                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_PUMPIDENTIFICATION'),
                Forms\Components\TextInput::make('zmm_psettype')
                    ->label('ZMM_PSETTYPE'),
                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('mark_status')
                    ->label('MARK_STATUS'),
                Forms\Components\TextInput::make('marked_datetime')
                    ->label('MARKED_DATETIME'),
                Forms\Components\TextInput::make('marked_by')
                    ->label('MARKED_BY'),
                Forms\Components\TextInput::make('man_marked_status')
                    ->label('MAN_MARKED_STATUS'),
                Forms\Components\TextInput::make('man_marked_datetime')
                    ->label('MAN_MARKED_DATETIME'),
                Forms\Components\TextInput::make('man_marked_by')
                    ->label('MAN_MARKED_BY'),
                Forms\Components\TextInput::make('motor_marked_status')
                    ->label('MOTOR_MARKED_STATUS'),
                Forms\Components\TextInput::make('pump_marked_status')
                    ->label('PUMP_MARKED_STATUS'),
                Forms\Components\TextInput::make('motor_pump_pumpset_status')
                    ->label('MOTOR_PUMP_PUMPSET_STATUS'),
                Forms\Components\TextInput::make('part_validation_1')
                    ->label('PART_VALIDATION_1'),
                Forms\Components\TextInput::make('part_validation_2')
                    ->label('PART_VALIDATION_2'),
                Forms\Components\TextInput::make('samlight_logged_name')
                    ->label('SAMLIGHT_LOGGED_NAME'),
                Forms\Components\TextInput::make('pending_released_status')
                    ->label('PENDING_RELEASED_STATUS'),
                Forms\Components\TextInput::make('expected_time')
                    ->label('EXPECTED_TIME'),
                Forms\Components\Hidden::make('created_by')
                    ->label('CREATED_BY')
                    ->default(Filament::auth()->user()?->name),
                Forms\Components\Hidden::make('updated_by')
                    ->label('UPDATED_BY'),
            ]);
    }

    public static function table(Table $table): Table
    {
        return $table
            ->columns([
                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')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('machine.work_center')
                    ->label('Machine')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('aufnr')
                    ->label('AUFNR')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('class')
                    ->label('CLASS')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('arbidtext')
                    ->label('ARBID')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('gamngtext')
                    ->label('GAMNG')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('lmngatext')
                    ->label('LMNGA')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('gernrtext')
                    ->label('GERNR')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zz1_cn_bill_ordtext')
                    ->label('ZZ1_CN_BILL_ORD')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_ampstext')
                    ->label('ZMM_AMPS')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_brandtext')
                    ->label('ZMM_BRAND')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_degreeofprotectiontext')
                    ->label('ZMM_DEGREEOFPROTECTION')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_deliverytext')
                    ->label('ZMM_DELIVERY')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_dir_rottext')
                    ->label('ZMM_DIR_ROT')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_dischargetext')
                    ->label('ZMM_DISCHARGE')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_discharge_maxtext')
                    ->label('ZMM_DISCHARGE_MAX')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_discharge_mintext')
                    ->label('ZMM_DISCHARGE_MIN')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_dutytext')
                    ->label('ZMM_DUTY')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_eff_motortext')
                    ->label('ZMM_EFF_MOTOR')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_eff_pumptext')
                    ->label('ZMM_EFF_PUMP')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_frequencytext')
                    ->label('ZMM_FREQUENCY')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_headtext')
                    ->label('ZMM_HEAD')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_headingtext')
                    ->label('ZMM_HEADING')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_head_maxtext')
                    ->label('ZMM_HEAD_MAX')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_head_minimumtext')
                    ->label('ZMM_HEAD_MINIMUM')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_idx_eff_mtrtext')
                    ->label('ZMM_IDX_EFF_MTR')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_idx_eff_pumptext')
                    ->label('ZMM_IDX_EFF_PUMP')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_kvacodetext')
                    ->label('ZMM_KVACODE')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_maxambtemptext')
                    ->label('ZMM_MAXAMBTEMP')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_mincoolingflowtext')
                    ->label('ZMM_MINCOOLINGFLOW')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_motorseriestext')
                    ->label('ZMM_MOTORSERIES')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_motor_modeltext')
                    ->label('ZMM_MOTOR_MODEL')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_outlettext')
                    ->label('ZMM_OUTLET')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_phasetext')
                    ->label('ZMM_PHASE')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_pressuretext')
                    ->label('ZMM_PRESSURE')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_pumpflowtypetext')
                    ->label('ZMM_PUMPFLOWTYPE')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_pumpseriestext')
                    ->label('ZMM_PUMPSERIES')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_pump_model')
                    ->label('ZMM_PUMP_MODEL')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_ratedpower')
                    ->label('ZMM_RATEDPOWER')
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_regiontext')
                    ->label('ZMM_REGIONTEXT')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_servicefactortext')
                    ->label('ZMM_SERVICEFACTOR')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_servicefactormaximumamps')
                    ->label('ZMM_SERVICEFACTORMAXIMUMAMPS')
                    ->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_SUCTIONXDELIVERY')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_supplysource')
                    ->label('ZMM_SUPPLYSOURCE')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_temperature')
                    ->label('ZMM_TEMPERATURE')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_thrustload')
                    ->label('ZMM_THRUSTLOAD')
                    ->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_PVARRAYRATING')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_isi')
                    ->label('ZMM_ISI')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_isimotor')
                    ->label('ZMM_ISIMOTOR')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_isipump')
                    ->label('ZMM_ISIPUMP')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_isipumpset')
                    ->label('ZMM_ISIPUMPSET')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_pumpset_model')
                    ->label('ZMM_PUMPSET_MODEL')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_stages')
                    ->label('ZMM_STAGES')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_headrange')
                    ->label('ZMM_HEADRANGE')
                    ->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_ISIREFERENCE')
                    ->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_CAPACITORSTART')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_capacitorrun')
                    ->label('ZMM_CAPACITORRUN')
                    ->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_EFF_OVRALL')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_bodymoc')
                    ->label('ZMM_BODYMOC')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_rotormoc')
                    ->label('ZMM_ROTORMOC')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_dlwl')
                    ->label('ZMM_DLWL')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_inputpower')
                    ->label('ZMM_INPUTPOWER')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_imp_od')
                    ->label('ZMM_IMP_OD')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_ambtemp')
                    ->label('ZMM_AMBTEMP')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_de')
                    ->label('ZMM_DE')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_dischargerange')
                    ->label('ZMM_DISCHARGERANGE')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_efficiency_class')
                    ->label('ZMM_EFFICIENCY_CLASS')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_framesize')
                    ->label('ZMM_FRAMESIZE')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_impellerdiameter')
                    ->label('ZMM_IMPELLERDIAMETER')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_insulationclass')
                    ->label('ZMM_INSULATIONCLASS')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_maxflow')
                    ->label('ZMM_MAXFLOW')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_minhead')
                    ->label('ZMM_MINHEAD')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_mtrlofconst')
                    ->label('ZMM_MTRLOFCONST')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_nde')
                    ->label('ZMM_NDE')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_powerfactor')
                    ->label('ZMM_POWERFACTOR')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_tagno')
                    ->label('ZMM_TANGO')
                    ->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_BEENOTE')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_beenumber')
                    ->label('ZMM_BEENUMBER')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_beestar')
                    ->label('ZMM_BEESTAR')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_logo_ce')
                    ->label('ZMM_LOGO_CE')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_codeclass')
                    ->label('ZMM_CODECLASS')
                    ->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_ISIVALVE')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_isi_wc')
                    ->label('ZMM_ISI_WC')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_labelperiod')
                    ->label('ZMM_LABELPERIOD')
                    ->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_MFGMONYR')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_modelyear')
                    ->label('ZMM_MODELYEAR')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_motoridentification')
                    ->label('ZMM_MOTORIDENTIFICATION')
                    ->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_PACKTYPE')
                    ->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_PUMPIDENTIFICATION')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_psettype')
                    ->label('ZMM_PSETTYPE')
                    ->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('mark_status')
                    ->label('MARK_STATUS')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('marked_datetime')
                    ->label('MARKED_DATETIME')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('marked_by')
                    ->label('MARKED_BY')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('man_marked_status')
                    ->label('MAN_MARKED_STATUS')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('man_marked_datetime')
                    ->label('MAN_MARKED_DATETIME')
                    ->alignCenter()
                    ->sortable(),
                    Tables\Columns\TextColumn::make('man_marked_by')
                    ->label('MAN_MARKED_BY')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('motor_marked_status')
                    ->label('MOTOR_MARKED_STATUS')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('pump_marked_status')
                    ->label('PUMP_MARKED_STATUS')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('motor_pump_pumpset_status')
                    ->label('MOTOR_PUMP_PUMPSET_STATUS')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('part_validation_1')
                    ->label('PART_VALIDATION_1')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('part_validation_2')
                    ->label('PART_VALIDATION_2')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('samlight_logged_name')
                    ->label('SAMLIGHT_LOGGED_NAME')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('pending_released_status')
                    ->label('PENDING_RELEASED_STATUS')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('expected_time')
                    ->label('EXPECTED_TIME')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('created_at')
                    ->label('CREATED_AT')
                    ->alignCenter()
                    ->dateTime()
                    ->sortable()
                    ->toggleable(isToggledHiddenByDefault: true),
                Tables\Columns\TextColumn::make('created_by')
                    ->label('CREATED_BY')
                    ->alignCenter(),
                Tables\Columns\TextColumn::make('updated_at')
                    ->label('UPDATED_AT')
                    ->alignCenter()
                    ->dateTime()
                    ->sortable()
                    ->toggleable(isToggledHiddenByDefault: true),
                Tables\Columns\TextColumn::make('updated_by')
                    ->label('UPDATED_BY')
                    ->alignCenter(),
                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 Class Characteristics')
                    ->color('warning')
                    ->importer(ClassCharacteristicImporter::class)
                    ->visible(function() {
                        return Filament::auth()->user()->can('view import class characteristic');
                    }),
                ExportAction::make()
                    ->label('Export Class Characteristics')
                    ->color('warning')
                    ->exporter(ClassCharacteristicExporter::class)
                    ->visible(function() {
                        return Filament::auth()->user()->can('view export class characteristic');
                    }),
            ]);
    }

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

    public static function getPages(): array
    {
        return [
            'index' => Pages\ListClassCharacteristics::route('/'),
            'create' => Pages\CreateClassCharacteristic::route('/create'),
            'view' => Pages\ViewClassCharacteristic::route('/{record}'),
            'edit' => Pages\EditClassCharacteristic::route('/{record}/edit'),
        ];
    }

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