Files
pds/app/Filament/Resources/ItemCharacteristicResource.php
dhanabalan 95624ea9ea
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 15s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 18s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 17s
Laravel Pint / pint (pull_request) Successful in 2m13s
Laravel Larastan / larastan (pull_request) Failing after 5m23s
Added item characteristics excel import functionality with validations
2026-11-20 11:52:57 +05:30

2052 lines
108 KiB
PHP

<?php
namespace App\Filament\Resources;
use App\Filament\Exports\ItemCharacteristicExporter;
use App\Filament\Imports\ItemCharacteristicImporter;
use App\Filament\Resources\ItemCharacteristicResource\Pages;
use App\Models\Item;
use App\Models\ItemCharacteristic;
use App\Models\Plant;
use Filament\Facades\Filament;
use Filament\Forms;
use Filament\Forms\Components\DateTimePicker;
use Filament\Forms\Components\FileUpload;
use Filament\Forms\Components\Section;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Form;
use Filament\Forms\Get;
use Filament\Notifications\Notification;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Actions\ExportAction;
use Filament\Tables\Actions\ImportAction;
use Filament\Tables\Filters\Filter;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
use Maatwebsite\Excel\Facades\Excel;
class ItemCharacteristicResource extends Resource
{
protected static ?string $model = ItemCharacteristic::class;
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
protected static ?string $navigationGroup = 'Sticker Printing';
public static function form(Form $form): Form
{
return $form
->schema([
Section::make('')
->schema([
Forms\Components\Select::make('plant_id')
->label('PLANT NAME')
->relationship('plant', 'name')
->reactive()
->searchable()
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->disabled(fn (Get $get) => ! empty($get('id')))
->default(function () {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? $userHas : optional(ItemCharacteristic::latest()->first())->plant_id;
})
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$set('item_id', null);
$set('updated_by', Filament::auth()->user()?->name);
})
->required(),
Forms\Components\Select::make('item_id')
->label('ITEM CODE')
->reactive()
->searchable()
->options(function (callable $get) {
$plantId = $get('plant_id');
if (empty($plantId)) {
return [];
}
return Item::where('plant_id', $plantId)->orderBy('code')->pluck('code', 'id')->toArray();
})
->disabled(fn (Get $get) => ! empty($get('id')))
->default(function (callable $get) {
$plantId = $get('plant_id');
if (empty($plantId)) {
return null;
}
return ItemCharacteristic::where('plant_id', $plantId)->latest()->first()->item_id ?? null;
})
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
})
->required(),
Forms\Components\TextInput::make('class')
->label('CLASS')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('arbid')
->label('ARBID')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zz1_cn_bill_ord')
->label('ZZ1 CN BILL ORD')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_amps')
->label('ZMM AMPS')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_brand')
->label('ZMM BRAND')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_degreeofprotection')
->label('ZMM DEGREEOFPROTECTION')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_delivery')
->label('ZMM DELIVERY')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_dir_rot')
->label('ZMM DIR ROT')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_discharge')
->label('ZMM DISCHARGE')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_discharge_max')
->label('ZMM DISCHARGE MAX')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_discharge_min')
->label('ZMM DISCHARGE MIN')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_duty')
->label('ZMM DUTY')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_eff_motor')
->label('ZMM EFF MOTOR')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_eff_pump')
->label('ZMM EFF PUMP')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_frequency')
->label('ZMM FREQUENCY')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_head')
->label('ZMM HEAD')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_heading')
->label('ZMM HEADING')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
})
->required(),
Forms\Components\TextInput::make('zmm_head_max')
->label('ZMM HEAD MAX')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_head_minimum')
->label('ZMM HEAD MINIMUM')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_idx_eff_mtr')
->label('ZMM IDX EFF MTR')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_idx_eff_pump')
->label('ZMM IDX EFF PUMP')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_kvacode')
->label('ZMM KVACODE')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_maxambtemp')
->label('ZMM MAXAMBTEMP')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_mincoolingflow')
->label('ZMM MINCOOLINGFLOW')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_motorseries')
->label('ZMM MOTORSERIES')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_motor_model')
->label('ZMM MOTOR MODEL')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_outlet')
->label('ZMM OUTLET')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_phase')
->label('ZMM PHASE')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_pressure')
->label('ZMM PRESSURE')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_pumpflowtype')
->label('ZMM PUMPFLOWTYPE')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_pumpseries')
->label('ZMM PUMPSERIES')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_pump_model')
->label('ZMM PUMP MODEL')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_ratedpower')
->label('ZMM RATEDPOWER')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_region')
->label('ZMM REGION')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_servicefactor')
->label('ZMM SERVICEFACTOR')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_servicefactormaximumamps')
->label('ZMM SERVICEFACTORMAXIMUMAMPS')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_speed')
->label('ZMM SPEED')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_suction')
->label('ZMM SUCTION')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_suctionxdelivery')
->label('ZMM SUCTIONXDELIVERY')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_supplysource')
->label('ZMM SUPPLYSOURCE')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_temperature')
->label('ZMM TEMPERATURE')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_thrustload')
->label('ZMM THRUSTLOAD')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_volts')
->label('ZMM VOLTS')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_wire')
->label('ZMM WIRE')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_package')
->label('ZMM PACKAGE')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_pvarrayrating')
->label('ZMM PVARRAYRATING')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_isi')
->label('ZMM ISI')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_isimotor')
->label('ZMM ISIMOTOR')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_isipump')
->label('ZMM ISIPUMP')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_isipumpset')
->label('ZMM ISIPUMPSET')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_pumpset_model')
->label('ZMM PUMPSET MODEL')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_stages')
->label('ZMM STAGES')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_headrange')
->label('ZMM HEADRANGE')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_overall_efficiency')
->label('ZMM OVERALL EFFICIENCY')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_connection')
->label('ZMM CONNECTION')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_min_bore_size')
->label('ZMM MIN BORE SIZE')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_isireference')
->label('ZMM ISIREFERENCE')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_category')
->label('ZMM CATEGORY')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_submergence')
->label('ZMM SUBMERGENCE')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_capacitorstart')
->label('ZMM CAPACITORSTART')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_capacitorrun')
->label('ZMM CAPACITORRUN')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_inch')
->label('ZMM INCH')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_motor_type')
->label('ZMM MOTOR TYPE')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_dismantle_direction')
->label('ZMM DISMANTLE DIRECTION')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_eff_ovrall')
->label('ZMM EFF OVRALL')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_bodymoc')
->label('ZMM BODYMOC')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_rotormoc')
->label('ZMM ROTORMOC')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_dlwl')
->label('ZMM DLWL')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_inputpower')
->label('ZMM INPUTPOWER')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_imp_od')
->label('ZMM IMP OD')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_ambtemp')
->label('ZMM AMBTEMP')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_de')
->label('ZMM DE')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_dischargerange')
->label('ZMM DISCHARGERANGE')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_efficiency_class')
->label('ZMM EFFICIENCY CLASS')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_framesize')
->label('ZMM FRAMESIZE')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_impellerdiameter')
->label('ZMM IMPELLERDIAMETER')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_insulationclass')
->label('ZMM INSULATIONCLASS')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_maxflow')
->label('ZMM MAXFLOW')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_minhead')
->label('ZMM MINHEAD')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_mtrlofconst')
->label('ZMM MTRLOFCONST')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_nde')
->label('ZMM NDE')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_powerfactor')
->label('ZMM POWERFACTOR')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_tagno')
->label('ZMM TAGNO')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_year')
->label('ZMM YEAR')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_laser_name')
->label('ZMM LASER NAME')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_logo_cp')
->label('ZMM LOGO CP')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_logo_ce')
->label('ZMM LOGO CE')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_logo_nsf')
->label('ZMM LOGO NSF')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_logo_eac')
->label('ZMM LOGO EAC')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_beenote')
->label('ZMM BEENOTE')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_beenumber')
->label('ZMM BEENUMBER')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_beestar')
->label('ZMM BEESTAR')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_codeclass')
->label('ZMM CODECLASS')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_colour')
->label('ZMM COLOUR')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_grade')
->label('ZMM GRADE')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_grwt_pset')
->label('ZMM GRWT PSET')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_grwt_cable')
->label('ZMM GRWT CABLE')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_grwt_motor')
->label('ZMM GRWT MOTOR')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_grwt_pf')
->label('ZMM GRWT PF')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_grwt_pump')
->label('ZMM GRWT PUMP')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_isivalve')
->label('ZMM ISIVALVE')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_isi_wc')
->label('ZMM ISI WC')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_labelperiod')
->label('ZMM LABELPERIOD')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_length')
->label('ZMM LENGTH')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_license_cml_no')
->label('ZMM LICENSE CML NO')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_mfgmonyr')
->label('ZMM MFGMONYR')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_modelyear')
->label('ZMM MODELYEAR')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_motoridentification')
->label('ZMM MOTORIDENTIFICATION')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_newt_pset')
->label('ZMM NEWT PSET')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_newt_cable')
->label('ZMM NEWT CABLE')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_newt_motor')
->label('ZMM NEWT MOTOR')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_newt_pf')
->label('ZMM NEWT PF')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_newt_pump')
->label('ZMM NEWT PUMP')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_packtype')
->label('ZMM PACKTYPE')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_panel')
->label('ZMM PANEL')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_performance_factor')
->label('ZMM PERFORMANCE FACTOR')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_pumpidentification')
->label('ZMM PUMPIDENTIFICATION')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_psettype')
->label('ZMM PSETTYPE')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_size')
->label('ZMM SIZE')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_eff_ttl')
->label('ZMM EFF TTL')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_type')
->label('ZMM TYPE')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_usp')
->label('ZMM USP')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_operating_range')
->label('ZMM OPERATING RANGE')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_intake_air')
->label('ZMM INTAKE AIR')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_oxygen_transfer_rate')
->label('ZMM OXYGEN TRANSFER RATE')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_air_inlet_pipesize')
->label('ZMM AIR INLET PIPESIZE')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_sump_depth')
->label('ZMM SUMP DEPTH')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_poles')
->label('ZMM POLES')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_motor_heading')
->label('ZMM MOTOR HEADING')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_motor_speed')
->label('ZMM MOTOR SPEED')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zqmm_qty')
->label('ZQMM QTY')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_operating_temperature')
->label('ZMM OPERATING TEMPERATURE')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_axial_force')
->label('ZMM AXIAL FORCE')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_mrp')
->label('ZMM MRP')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
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),
Forms\Components\TextInput::make('id')
->hidden()
->readOnly(),
])
->columns(3),
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('No.')
->label('NO')
->alignCenter()
->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 NAME')
->alignCenter()
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('item.code')
->label('ITEM CODE')
->alignCenter()
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('item.description')
->label('DESCRIPTION')
->default('-')
->searchable()
->alignCenter()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('item.category')
->label('CATEGORY')
->default('-')
->searchable()
->alignCenter()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('item.uom')
->label('UNIT OF MEASURE')
->default('-')
->searchable()
->alignCenter()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('class')
->label('CLASS')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('arbid')
->label('ARBID')
->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 DEGREEOFPROTECTION')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('zmm_delivery')
->label('ZMM DELIVERY')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('zmm_dir_rot')
->label('ZMM DIR ROT')
->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 MAXAMBTEMP')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('zmm_mincoolingflow')
->label('ZMM MINCOOLINGFLOW')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('zmm_motorseries')
->label('ZMM MOTORSERIES')
->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 PUMPFLOWTYPE')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('zmm_pumpseries')
->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_region')
->label('ZMM REGION')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('zmm_servicefactor')
->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_logo_cp')
->label('ZMM LOGO CP')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('zmm_logo_ce')
->label('ZMM LOGO CE')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('zmm_logo_nsf')
->label('ZMM LOGO NSF')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('zmm_logo_eac')
->label('ZMM LOGO EAC')
->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_codeclass')
->label('ZMM CODECLASS')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('zmm_colour')
->label('ZMM COLOUR')
->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_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('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('ZQMM QTY')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('zmm_operating_temperature')
->label('ZMM OPERATING TEMPERATURE')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('zmm_axial_force')
->label('ZMM AXIAL FORCE')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('zmm_mrp')
->label('ZMM MRP')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('created_at')
->label('CREATED AT')
->alignCenter()
->dateTime()
->sortable(),
Tables\Columns\TextColumn::make('created_by')
->label('CREATED BY')
->alignCenter(),
Tables\Columns\TextColumn::make('updated_at')
->label('UPDATED AT')
->alignCenter()
->dateTime()
->sortable(),
Tables\Columns\TextColumn::make('updated_by')
->label('UPDATED BY')
->alignCenter(),
Tables\Columns\TextColumn::make('deleted_at')
->label('DELETED AT')
->alignCenter()
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
])
->filters([
Tables\Filters\TrashedFilter::make(),
Filter::make('advanced_filters')
->label('Advanced Filters')
->form([
Select::make('Plant')
->label('Search by Plant Name')
->nullable()
->searchable()
->reactive()
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
if ($userHas && strlen($userHas) > 0) {
return Plant::where('id', $userHas)->pluck('name', 'id')->toArray();
} else {
return Plant::whereHas('ItemCharacteristics', function ($query) {
$query->whereNotNull('id');
})->orderBy('code')->pluck('name', 'id');
}
// return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->afterStateUpdated(function ($state, callable $set, callable $get): void {
$set('item_id', null);
}),
Select::make('item_id')
->label('Search by Item Code')
->nullable()
->searchable()
->reactive()
->options(function (callable $get) {
$plantId = $get('Plant');
if (empty($plantId)) {
return [];
}
return Item::whereHas('ItemCharacteristics', function ($query) use ($plantId) {
if ($plantId) {
$query->where('plant_id', $plantId);
}
})->orderBy('code')->pluck('code', 'id');
}),
TextInput::make('zmm_heading')
->label('Heading')
->placeholder('Enter Heading'),
DateTimePicker::make('created_from')
->label('Created From')
->placeholder('Select From DateTime')
->reactive()
->native(false),
DateTimePicker::make('created_to')
->label('Created To')
->placeholder('Select To DateTime')
->reactive()
->native(false),
])
->query(function ($query, array $data) {
// Hide all records initially if no filters are applied
if (empty($data['Plant']) && empty($data['item_id']) && empty($data['zmm_heading']) && empty($data['created_from']) && empty($data['created_to'])) {
return $query->whereRaw('1 = 0');
}
if (! empty($data['Plant'])) { // $plant = $data['Plant'] ?? null
$query->where('plant_id', $data['Plant']);
} else {
$userHas = Filament::auth()->user()->plant_id;
if ($userHas && strlen($userHas) > 0) {
return $query->whereRaw('1 = 0');
}
}
if (! empty($data['item_id'])) {
$query->where('item_id', $data['item_id']);
}
if (! empty($data['zmm_heading'])) {
$query->where('zmm_heading', 'like', '%'.$data['zmm_heading'].'%');
}
if (! empty($data['created_from'])) {
$query->where('created_at', '>=', $data['created_from']);
}
if (! empty($data['created_to'])) {
$query->where('created_at', '<=', $data['created_to']);
}
})
->indicateUsing(function (array $data) {
$indicators = [];
if (! empty($data['Plant'])) {
$indicators[] = 'Plant Name: '.Plant::where('id', $data['Plant'])->value('name');
} else {
$userHas = Filament::auth()->user()->plant_id;
if ($userHas && strlen($userHas) > 0) {
return 'Plant: Choose plant to filter records.';
}
}
if (! empty($data['item_id'])) {
$indicators[] = 'Item Code: '.Item::where('id', $data['item_id'])->value('code');
}
if (! empty($data['zmm_heading'])) {
$indicators[] = 'Heading: '.$data['zmm_heading'];
}
if (! empty($data['created_from'])) {
$indicators[] = 'Created From: '.$data['created_from'];
}
if (! empty($data['created_to'])) {
$indicators[] = 'Created To: '.$data['created_to'];
}
return $indicators;
}),
])
->filtersFormMaxHeight('280px')
->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([
Tables\Actions\Action::make('Import Item Characteristics (XLSX)')
->label('Import Item Characteristics (XLSX)')
->form([
Select::make('plant_id')
->options(function () {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->searchable()
->label('Search by Plant Name')
->required()
->default(function () {
return optional(ItemCharacteristic::latest()->first())->plant_id;
})
->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('item_characteristics', null);
$plantId = $get('plant_id');
if (! $plantId) {
$set('item_characteristics', null);
return;
}
$plantCode = Plant::find($plantId)?->code ?? null;
$directory = "uploads/classcharacteristic/{$plantCode}";
if ($plantId && ! Storage::disk('local')->exists($directory)) {
Storage::disk('local')->makeDirectory($directory);
}
})
->reactive(),
FileUpload::make('item_characteristics')
->label('Choose Item Characteristics')
->required()
->acceptedFileTypes([
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
// 'application/vnd.ms-excel', // Legacy .xls fallback if needed
])
->rules(['mimes:xlsx', 'max:5120']) // Laravel validation: extension check
->maxSize(5120)
->preserveFilenames() // <- this keeps the original filename
->reactive()
->storeFiles(false) // prevent auto-storing, we will store manually
->disk('local') // 'local' refers to the local storage disk defined in config/filesystems.php, typically pointing to storage/app.
->visible(fn (Get $get) => ! empty($get('plant_id')))
->directory(function (callable $get) {
$plant = Plant::find($get('plant_id'));
$plantCode = $plant?->code ?? null;
return "uploads/classcharacteristic/{$plantCode}";
})
->uploadingMessage('Uploading...')
->helperText('Only .xlsx files are allowed (Excel files).'),
])
->action(function (array $data) {
$uploadedFile = $data['item_characteristics'];
$disk = Storage::disk('local');
$plantId = $data['plant_id'];
$plant = Plant::find($plantId);
$plantCode = $plant?->code ?? null;
$userName = Filament::auth()->user()->name;
$created_by = $userName;
// Get original filename
$originalName = $uploadedFile->getClientOriginalName(); // e.g. 3RA0018732.xlsx
$extension = strtolower(pathinfo($originalName, PATHINFO_EXTENSION));
if ($extension != 'xlsx') {
throw new \Exception('Only .xlsx files allowed.');
}
$originalNameOnly = strtoupper(pathinfo($originalName, PATHINFO_FILENAME));
$originalName = "{$originalNameOnly}.xlsx";
// Store manually using storeAs to keep original name
$path = $uploadedFile->storeAs("uploads/classcharacteristic/{$plantCode}", $originalName, 'local'); // returns relative path
// uploads/temp/{$plantCode}/3RA0018735.xlsx
$fullPath = Storage::disk('local')->path($path);
if ($fullPath && file_exists($fullPath)) {
$rows = Excel::toArray(null, $fullPath)[0];
if ((count($rows) - 1) <= 0) {
Notification::make()
->title('Records Not Found')
->body("Import the valid 'Item Characteristics Excel' file to proceed..!")
->danger()
->send();
if ($disk->exists($path)) {
$disk->delete($path);
}
return;
}
$invalidMatCodes = [];
$materialCodes = [];
$validRowsFound = false;
foreach ($rows as $index => $row) {
if ($index == 0) {
continue;
}
// $plantCode = trim($row[0]);
$materialCode = trim($row[1]);
if (empty($materialCode)) {
continue;
} else {
if (Str::length($materialCode) < 6 || ! ctype_alnum($materialCode)) {
$invalidMatCodes[] = $materialCode;
} else {
$materialCodes[] = $materialCode;
$validRowsFound = true;
}
}
}
$uniqueInvalidCodes = array_unique($invalidMatCodes);
if (! empty($uniqueInvalidCodes)) {
Notification::make()
->title('Invalid Item Codes')
->body('The following item codes should contain minimum 6 digit alpha numeric values:<br>'.implode(', ', $uniqueInvalidCodes))
->danger()
->send();
if ($disk->exists($path)) {
$disk->delete($path);
}
return;
} elseif (! $validRowsFound) {
Notification::make()
->title('Invalid Item Characteristics Excel')
->danger()
->body('Uploaded Excel sheet is empty or<br>contains no valid data.')
->send();
if ($disk->exists($path)) {
$disk->delete($path);
}
return;
}
$uniqueCodes = array_unique($materialCodes);
$matchedItems = Item::where('plant_id', $plantId)->whereIn('code', $uniqueCodes)->get();
$matchedCodes = $matchedItems->pluck('code')->toArray();
$missingCodes = array_diff($uniqueCodes, $matchedCodes);
if (! empty($missingCodes)) {
$missingCount = count($missingCodes);
$message = $missingCount > 10 ? "'$missingCount' item codes are not found in items table." : 'The following item codes are not found in items table:<br>'.implode(', ', $missingCodes);
Notification::make()
->title('Unknown Item Codes')
->body($message)
->danger()
->send();
if ($disk->exists($path)) {
$disk->delete($path);
}
return;
}
foreach ($rows as $index => $row) {
if ($index == 0) {
continue;
}
$iCode = trim($row[1]);
if (empty($materialCode)) {
continue;
}
$item = Item::where('plant_id', $plantId)->where('code', $iCode)->first();
if ($item) {
$itemId = $item->id;
$itemChar = ItemCharacteristic::where('plant_id', $plantId)->where('item_id', $itemId)->first();
if ($itemChar) {
$created_by = $itemChar->created_by;
}
} else {
continue;
}
ItemCharacteristic::updateOrCreate([
'plant_id' => $plantId,
'item_id' => $itemId,
],
[
'class' => trim($row[2]) ?? null,
'arbid' => trim($row[3]) ?? null,
'zz1_cn_bill_ord' => trim($row[4]) ?? null,
'zmm_amps' => trim($row[5]) ?? null,
'zmm_brand' => trim($row[6]) ?? null,
'zmm_degreeofprotection' => trim($row[7]) ?? null,
'zmm_delivery' => trim($row[8]) ?? null,
'zmm_dir_rot' => trim($row[9]) ?? null,
'zmm_discharge' => trim($row[10]) ?? null,
'zmm_discharge_max' => trim($row[11]) ?? null,
'zmm_discharge_min' => trim($row[12]) ?? null,
'zmm_duty' => trim($row[13]) ?? null,
'zmm_eff_motor' => trim($row[14]) ?? null,
'zmm_eff_pump' => trim($row[15]) ?? null,
'zmm_frequency' => trim($row[16]) ?? null,
'zmm_head' => trim($row[17]) ?? null,
'zmm_heading' => trim($row[18]) ?? null,
'zmm_head_max' => trim($row[19]) ?? null,
'zmm_head_minimum' => trim($row[20]) ?? null,
'zmm_idx_eff_mtr' => trim($row[21]) ?? null,
'zmm_idx_eff_pump' => trim($row[22]) ?? null,
'zmm_kvacode' => trim($row[23]) ?? null,
'zmm_maxambtemp' => trim($row[24]) ?? null,
'zmm_mincoolingflow' => trim($row[25]) ?? null,
'zmm_motorseries' => trim($row[26]) ?? null,
'zmm_motor_model' => trim($row[27]) ?? null,
'zmm_outlet' => trim($row[28]) ?? null,
'zmm_phase' => trim($row[29]) ?? null,
'zmm_pressure' => trim($row[30]) ?? null,
'zmm_pumpflowtype' => trim($row[31]) ?? null,
'zmm_pumpseries' => trim($row[32]) ?? null,
'zmm_pump_model' => trim($row[33]) ?? null,
'zmm_ratedpower' => trim($row[34]) ?? null,
'zmm_region' => trim($row[35]) ?? null,
'zmm_servicefactor' => trim($row[36]) ?? null,
'zmm_servicefactormaximumamps' => trim($row[37]) ?? null,
'zmm_speed' => trim($row[38]) ?? null,
'zmm_suction' => trim($row[39]) ?? null,
'zmm_suctionxdelivery' => trim($row[40]) ?? null,
'zmm_supplysource' => trim($row[41]) ?? null,
'zmm_temperature' => trim($row[42]) ?? null,
'zmm_thrustload' => trim($row[43]) ?? null,
'zmm_volts' => trim($row[44]) ?? null,
'zmm_wire' => trim($row[45]) ?? null,
'zmm_package' => trim($row[46]) ?? null,
'zmm_pvarrayrating' => trim($row[47]) ?? null,
'zmm_isi' => trim($row[48]) ?? null,
'zmm_isimotor' => trim($row[49]) ?? null,
'zmm_isipump' => trim($row[50]) ?? null,
'zmm_isipumpset' => trim($row[51]) ?? null,
'zmm_pumpset_model' => trim($row[52]) ?? null,
'zmm_stages' => trim($row[53]) ?? null,
'zmm_headrange' => trim($row[54]) ?? null,
'zmm_overall_efficiency' => trim($row[55]) ?? null,
'zmm_connection' => trim($row[56]) ?? null,
'zmm_min_bore_size' => trim($row[57]) ?? null,
'zmm_isireference' => trim($row[58]) ?? null,
'zmm_category' => trim($row[59]) ?? null,
'zmm_submergence' => trim($row[60]) ?? null,
'zmm_capacitorstart' => trim($row[61]) ?? null,
'zmm_capacitorrun' => trim($row[62]) ?? null,
'zmm_inch' => trim($row[63]) ?? null,
'zmm_motor_type' => trim($row[64]) ?? null,
'zmm_dismantle_direction' => trim($row[65]) ?? null,
'zmm_eff_ovrall' => trim($row[66]) ?? null,
'zmm_bodymoc' => trim($row[67]) ?? null,
'zmm_rotormoc' => trim($row[68]) ?? null,
'zmm_dlwl' => trim($row[69]) ?? null,
'zmm_inputpower' => trim($row[70]) ?? null,
'zmm_imp_od' => trim($row[71]) ?? null,
'zmm_ambtemp' => trim($row[72]) ?? null,
'zmm_de' => trim($row[73]) ?? null,
'zmm_dischargerange' => trim($row[74]) ?? null,
'zmm_efficiency_class' => trim($row[75]) ?? null,
'zmm_framesize' => trim($row[76]) ?? null,
'zmm_impellerdiameter' => trim($row[77]) ?? null,
'zmm_insulationclass' => trim($row[78]) ?? null,
'zmm_maxflow' => trim($row[79]) ?? null,
'zmm_minhead' => trim($row[80]) ?? null,
'zmm_mtrlofconst' => trim($row[81]) ?? null,
'zmm_nde' => trim($row[82]) ?? null,
'zmm_powerfactor' => trim($row[83]) ?? null,
'zmm_tagno' => trim($row[84]) ?? null,
'zmm_year' => trim($row[85]) ?? null,
'zmm_laser_name' => trim($row[86]) ?? null,
'zmm_logo_cp' => trim($row[87]) ?? null,
'zmm_logo_ce' => trim($row[88]) ?? null,
'zmm_logo_nsf' => trim($row[89]) ?? null,
'zmm_logo_eac' => trim($row[90]) ?? null,
'zmm_beenote' => trim($row[91]) ?? null,
'zmm_beenumber' => trim($row[92]) ?? null,
'zmm_beestar' => trim($row[93]) ?? null,
'zmm_codeclass' => trim($row[94]) ?? null,
'zmm_colour' => trim($row[95]) ?? null,
'zmm_grade' => trim($row[96]) ?? null,
'zmm_grwt_pset' => trim($row[97]) ?? null,
'zmm_grwt_cable' => trim($row[98]) ?? null,
'zmm_grwt_motor' => trim($row[99]) ?? null,
'zmm_grwt_pf' => trim($row[100]) ?? null,
'zmm_grwt_pump' => trim($row[101]) ?? null,
'zmm_isivalve' => trim($row[102]) ?? null,
'zmm_isi_wc' => trim($row[103]) ?? null,
'zmm_labelperiod' => trim($row[104]) ?? null,
'zmm_length' => trim($row[105]) ?? null,
'zmm_license_cml_no' => trim($row[106]) ?? null,
'zmm_mfgmonyr' => trim($row[107]) ?? null,
'zmm_modelyear' => trim($row[108]) ?? null,
'zmm_motoridentification' => trim($row[109]) ?? null,
'zmm_newt_pset' => trim($row[110]) ?? null,
'zmm_newt_cable' => trim($row[111]) ?? null,
'zmm_newt_motor' => trim($row[112]) ?? null,
'zmm_newt_pf' => trim($row[113]) ?? null,
'zmm_newt_pump' => trim($row[114]) ?? null,
'zmm_packtype' => trim($row[115]) ?? null,
'zmm_panel' => trim($row[116]) ?? null,
'zmm_performance_factor' => trim($row[117]) ?? null,
'zmm_pumpidentification' => trim($row[118]) ?? null,
'zmm_psettype' => trim($row[119]) ?? null,
'zmm_size' => trim($row[120]) ?? null,
'zmm_eff_ttl' => trim($row[121]) ?? null,
'zmm_type' => trim($row[122]) ?? null,
'zmm_usp' => trim($row[123]) ?? null,
'zmm_operating_range' => trim($row[124]) ?? null,
'zmm_intake_air' => trim($row[125]) ?? null,
'zmm_oxygen_transfer_rate' => trim($row[126]) ?? null,
'zmm_air_inlet_pipesize' => trim($row[127]) ?? null,
'zmm_sump_depth' => trim($row[128]) ?? null,
'zmm_poles' => trim($row[129]) ?? null,
'zmm_motor_heading' => trim($row[130]) ?? null,
'zmm_motor_speed' => trim($row[131]) ?? null,
'zqmm_qty' => trim($row[132]) ?? null,
'zmm_operating_temperature' => trim($row[133]) ?? null,
'zmm_axial_force' => trim($row[134]) ?? null,
'zmm_mrp' => trim($row[135]) ?? null,
'created_by' => $created_by ?? $userName,
'updated_at' => now()->format('Y-m-d H:i:s'),
'updated_by' => $userName,
]
);
}
Notification::make()
->title('Import Successful')
->success()
->body('Item characteristics imported successfully.')
->send();
}
})
->visible(function () {
return Filament::auth()->user()->can('view import item characteristics excel');
}),
ImportAction::make()
->label('Import Item Characteristics (CSV)')
->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,
]);
}
}