Files
pds/app/Filament/Resources/ClassCharacteristicResource.php
dhanabalan 9a003bc22a
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 15s
Added zmm_mrp column migration, model, resource, importer, exporter, and Updated 5 permissions
2026-09-23 15:15:27 +05:30

3198 lines
174 KiB
PHP

<?php
namespace App\Filament\Resources;
use App\Filament\Exports\ClassCharacteristicExporter;
use App\Filament\Imports\ClassCharacteristicImporter;
use App\Filament\Resources\ClassCharacteristicResource\Pages;
use App\Models\ClassCharacteristic;
use App\Models\Item;
use App\Models\ItemCharacteristic;
use App\Models\Machine;
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\Validation\Rule;
use Maatwebsite\Excel\Facades\Excel;
use Str;
class ClassCharacteristicResource extends Resource
{
protected static ?string $model = ClassCharacteristic::class;
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
protected static ?string $navigationGroup = 'Laser Marking';
protected static ?int $navigationSort = 7;
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(ClassCharacteristic::latest()->first())->plant_id;
})
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$set('item_id', null);
$set('machine_id', null);
$set('updated_by', Filament::auth()->user()?->name);
})
->required(),
Forms\Components\Select::make('machine_id')
// ->relationship('item', 'id')
->label('WORK CENTER')
->reactive()
->searchable()
->options(function (callable $get) {
$plantId = $get('plant_id');
// $itemId = $get('item_id');
if (empty($plantId)) {
return [];
}
return Machine::where('plant_id', $plantId)->orderBy('work_center')->pluck('work_center', 'id')->toArray();
})
->disabled(fn (Get $get) => ! empty($get('id')))
->default(function (callable $get) {
$plantId = $get('plant_id');
// $itemId = $get('item_id');
if (empty($plantId)) {
return null;
}
return ClassCharacteristic::where('plant_id', $plantId)->latest()->first()->machine_id ?? null;
})
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
})
->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 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 ClassCharacteristic::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('aufnr')
->label('AUFNR')
->reactive()
->minLength(7)
->maxLength(10)
->readOnly(fn (callable $get) => (! $get('plant_id') || ! $get('machine_id') || ! $get('item_id')))
->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);
})
->readOnly(fn (callable $get) => (! $get('aufnr')))
->required(),
Forms\Components\TextInput::make('arbid')
->label('ARBID')
->reactive()
->readOnly(fn (callable $get) => (! $get('class')))
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
})
->required(),
Forms\Components\TextInput::make('gamng')
->label('GAMNG')
->reactive()
->numeric()
->minValue(1.000)
->readOnly(fn (callable $get) => (! $get('arbid')))
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
})
->required(),
Forms\Components\TextInput::make('lmnga')
->label('LMNGA')
->reactive()
->integer()
->minValue(1)
->maxValue(fn (callable $get) => ($get('gamng') ?? 1))
->readOnly(fn (callable $get) => (! $get('gamng')))
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
})
->required(),
Forms\Components\TextInput::make('gernr')
->label('GERNR')
->reactive()
->minLength(13)
->readOnly(fn (callable $get) => (! $get('lmnga')))
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
})
->rules([
function (callable $get) {
return Rule::unique('class_characteristics', 'gernr')
->where('plant_id', $get('plant_id'))
->ignore($get('id'));
}, // The GERNR has already been taken.
// function (callable $get): Closure {
// return function (string $attribute, $value, Closure $fail) use ($get) {
// $rework = $get('rework_status');
// if ($value && Str::contains($value, '.') && $rework == 0) {
// $fail("Rework status should be 'Yes' for rework coil number '{$value}'!");
// }
// };
// },
])
->validationMessages([
'unique' => "The 'GERNR' has already been taken.", // The GERNR has already been taken for this plant.
])
->required(),
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()
->readOnly(fn (callable $get) => (! $get('aufnr') || ! $get('gernr')))
->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\Select::make('is_stopped')
// ->label('IS STOPPED')
// // ->nullable()
// ->selectablePlaceholder(false)
// ->options(function () {
// return [
// '0' => 'No',
// '1' => 'Yes',
// '2' => 'Yes (Alert Pending)',
// ];
// })
// ->default('0')
// ->reactive()
// ->afterStateUpdated(function (callable $set) {
// $set('updated_by', Filament::auth()->user()?->name);
// })
// ->required(),
// Forms\Components\DateTimePicker::make('stopped_datetime')
// ->label('STOPPED DATETIME')
// ->reactive()
// ->placeholder('Select Stopped DateTime')
// ->afterStateUpdated(function (callable $set) {
// $set('updated_by', Filament::auth()->user()?->name);
// }),
// Forms\Components\TextInput::make('stopped_by')
// ->label('STOPPED BY')
// ->reactive()
// ->readOnly(fn (callable $get) => ! $get('id'))
// ->afterStateUpdated(function (callable $set) {
// $set('updated_by', Filament::auth()->user()?->name);
// }),
Forms\Components\TextInput::make('mark_status')
->label('MARKED STATUS')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('marked_physical_count')
->label('MARKED PHYSICAL COUNT')
->reactive()
->minValue(0)
->integer()
->maxValue(3)
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
})
->default(0)
->required(),
Forms\Components\TextInput::make('marked_expected_time')
->label('MARKED EXPECTED TIME')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
})
->default('0')
->required(),
Forms\Components\DateTimePicker::make('marked_datetime')
->label('MARKED DATETIME')
->reactive()
->placeholder('Select Marked DateTime')
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
})
->default(now())
->required(),
Forms\Components\TextInput::make('marked_by')
->label('MARKED BY')
->reactive()
->readOnly(fn (callable $get) => ! $get('id'))
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
})
->default(Filament::auth()->user()?->name)
->required(),
Forms\Components\TextInput::make('man_marked_status')
->label('MANUAL MARKED PHYSICAL COUNT')
->reactive()
->readOnly(fn (callable $get) => ! ($get('mark_status') == 'Marked') && ! ($get('motor_marked_status') == 'Marked') && ! ($get('pump_marked_status') == 'Marked') && ! ($get('name_plate_marked_status') == 'Marked'))
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
})
->default('0')
->required(),
Forms\Components\DateTimePicker::make('man_marked_datetime')
->label('MANUAL MARKED DATETIME')
->reactive()
->placeholder('Select Manual Marked DateTime')
->readOnly(fn (callable $get) => ! ($get('mark_status') == 'Marked') && ! ($get('motor_marked_status') == 'Marked') && ! ($get('pump_marked_status') == 'Marked') && ! ($get('name_plate_marked_status') == 'Marked'))
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('man_marked_by')
->label('MANUAL MARKED BY')
->reactive()
->readOnly(fn (callable $get) => ! ($get('mark_status') == 'Marked') && ! ($get('motor_marked_status') == 'Marked') && ! ($get('pump_marked_status') == 'Marked') && ! ($get('name_plate_marked_status') == 'Marked'))
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('motor_marked_status')
->label('MOTOR MARKED STATUS')
->reactive()
->readOnly(fn (callable $get) => ! (Str::contains($get('zmm_heading'), 'MOTOR', ignoreCase: true)) && ! (Str::contains($get('zmm_heading'), 'PUMPSET', ignoreCase: true)) && ! (Str::contains($get('zmm_heading'), 'PRESSURE BOOSTER SYSTEM', ignoreCase: true)))
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('motor_marked_physical_count')
->label('MOTOR MARKED PHYSICAL COUNT')
->reactive()
->minValue(0)
->integer()
->maxValue(3)
->readOnly(fn (callable $get) => ! (Str::contains($get('zmm_heading'), 'MOTOR', ignoreCase: true)) && ! (Str::contains($get('zmm_heading'), 'PUMPSET', ignoreCase: true)) && ! (Str::contains($get('zmm_heading'), 'PRESSURE BOOSTER SYSTEM', ignoreCase: true)))
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
})
->default(0)
->required(),
Forms\Components\TextInput::make('motor_expected_time')
->label('MOTOR EXPECTED TIME')
->reactive()
->readOnly(fn (callable $get) => ! (Str::contains($get('zmm_heading'), 'MOTOR', ignoreCase: true)) && ! (Str::contains($get('zmm_heading'), 'PUMPSET', ignoreCase: true)) && ! (Str::contains($get('zmm_heading'), 'PRESSURE BOOSTER SYSTEM', ignoreCase: true)))
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
})
->default('0')
->required(),
Forms\Components\DateTimePicker::make('motor_marked_datetime')
->label('MOTOR MARKED DATETIME')
->reactive()
->placeholder('Select Motor Marked DateTime')
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('motor_marked_by')
->label('MOTOR MARKED BY')
->reactive()
->readOnly(fn (callable $get) => ! (Str::contains($get('zmm_heading'), 'MOTOR', ignoreCase: true)) && ! (Str::contains($get('zmm_heading'), 'PUMPSET', ignoreCase: true)) && ! (Str::contains($get('zmm_heading'), 'PRESSURE BOOSTER SYSTEM', ignoreCase: true)))
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('pump_marked_status')
->label('PUMP MARKED STATUS')
->reactive()
->readOnly(fn (callable $get) => ! (Str::contains($get('zmm_heading'), 'PUMP', ignoreCase: true)) && ! (Str::contains($get('zmm_heading'), 'PUMPSET', ignoreCase: true)) && ! (Str::contains($get('zmm_heading'), 'PRESSURE BOOSTER SYSTEM', ignoreCase: true)))
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('pump_marked_physical_count')
->label('PUMP MARKED PHYSICAL COUNT')
->reactive()
->minValue(0)
->integer()
->maxValue(3)
->readOnly(fn (callable $get) => ! (Str::contains($get('zmm_heading'), 'PUMP', ignoreCase: true)) && ! (Str::contains($get('zmm_heading'), 'PUMPSET', ignoreCase: true)) && ! (Str::contains($get('zmm_heading'), 'PRESSURE BOOSTER SYSTEM', ignoreCase: true)))
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
})
->default(0)
->required(),
Forms\Components\TextInput::make('pump_expected_time')
->label('PUMP EXPECTED TIME')
->reactive()
->readOnly(fn (callable $get) => ! (Str::contains($get('zmm_heading'), 'PUMP', ignoreCase: true)) && ! (Str::contains($get('zmm_heading'), 'PUMPSET', ignoreCase: true)) && ! (Str::contains($get('zmm_heading'), 'PRESSURE BOOSTER SYSTEM', ignoreCase: true)))
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
})
->default('0')
->required(),
Forms\Components\DateTimePicker::make('pump_marked_datetime')
->label('PUMP MARKED DATETIME')
->reactive()
->placeholder('Select Pump Marked DateTime')
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('pump_marked_by')
->label('PUMP MARKED BY')
->reactive()
->readOnly(fn (callable $get) => ! (Str::contains($get('zmm_heading'), 'PUMP', ignoreCase: true)) && ! (Str::contains($get('zmm_heading'), 'PUMPSET', ignoreCase: true)) && ! (Str::contains($get('zmm_heading'), 'PRESSURE BOOSTER SYSTEM', ignoreCase: true)))
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('name_plate_marked_status')
->label('NAME PLATE MARKED STATUS')
->reactive()
->readOnly(fn (callable $get) => ! (Str::contains($get('zmm_heading'), 'PRESSURE BOOSTER SYSTEM', ignoreCase: true)))
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('name_plate_expected_time')
->label('NAME PLATE EXPECTED TIME')
->reactive()
->readOnly(fn (callable $get) => ! (Str::contains($get('zmm_heading'), 'PRESSURE BOOSTER SYSTEM', ignoreCase: true)))
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
})
->default('0')
->required(),
Forms\Components\DateTimePicker::make('name_plate_marked_datetime')
->label('NAME PLATE MARKED DATETIME')
->reactive()
->placeholder('Select Name Plate Marked DateTime')
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('name_plate_marked_by')
->label('NAME PLATE MARKED BY')
->reactive()
->readOnly(fn (callable $get) => ! (Str::contains($get('zmm_heading'), 'PRESSURE BOOSTER SYSTEM', ignoreCase: true)))
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\Select::make('motor_pump_pumpset_status')
->label('MOTOR PUMP PUMPSET STATUS')
// ->label('Search by PUMPSET Type')
->nullable()
->searchable()
->options(function (callable $get) {
$plantId = $get('plant_id');
$machineId = $get('machine_id');
$itemId = $get('item_id');
if (empty($plantId) || empty($machineId) || empty($itemId)) {
return [];
}
if (Str::contains($get('zmm_heading'), 'PRESSURE BOOSTER SYSTEM', ignoreCase: true)) {
return [
'1' => 'Motor',
'2' => 'Pump',
'3' => 'Pump Set',
'4' => 'Name Plate',
];
} elseif (Str::contains($get('zmm_heading'), 'PUMPSET', ignoreCase: true)) {
return [
'1' => 'Motor',
'2' => 'Pump',
'3' => 'Pump Set',
];
} else {
return [];
}
})
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('winded_serial_number')
->label('WINDED SERIAL NUMBER')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('winded_rework_status')
->label('WINDED REWORK STATUS')
->reactive()
->minValue(0)
->integer()
->maxValue(1)
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('motor_machine_name')
->label('MOTOR MACHINE NAME')
->reactive()
->readOnly(fn (callable $get) => ! (Str::contains($get('zmm_heading'), 'MOTOR', ignoreCase: true)) && ! (Str::contains($get('zmm_heading'), 'PUMPSET', ignoreCase: true)) && ! (Str::contains($get('zmm_heading'), 'PRESSURE BOOSTER SYSTEM', ignoreCase: true)))
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('pump_machine_name')
->label('PUMP MACHINE NAME')
->reactive()
->readOnly(fn (callable $get) => ! (Str::contains($get('zmm_heading'), 'PUMP', ignoreCase: true)) && ! (Str::contains($get('zmm_heading'), 'PUMPSET', ignoreCase: true)) && ! (Str::contains($get('zmm_heading'), 'PRESSURE BOOSTER SYSTEM', ignoreCase: true)))
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('name_plate_machine_name')
->label('NAME PLATE MACHINE NAME')
->reactive()
->readOnly(fn (callable $get) => ! (Str::contains($get('zmm_heading'), 'PRESSURE BOOSTER SYSTEM', ignoreCase: true)))
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
// Forms\Components\TextInput::make('pumpset_machine_name')
// ->label('PUMPSET MACHINE NAME')
// ->reactive()
// ->readOnly(fn (callable $get) => ! (Str::contains($get('zmm_heading'), 'PUMPSET', ignoreCase: true)) && ! (Str::contains($get('zmm_heading'), 'PRESSURE BOOSTER SYSTEM', ignoreCase: true)))
// ->afterStateUpdated(function (callable $set) {
// $set('updated_by', Filament::auth()->user()?->name);
// }),
Forms\Components\TextInput::make('part_validation_1')
->label('PART VALIDATION 1')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('part_validation_2')
->label('PART VALIDATION 2')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('samlight_logged_name')
->label('SAMLIGHT LOGGED NAME')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\Select::make('motor_stop_flow_id')
->label('MOTOR STOP FLOW ID')
// ->nullable()
->selectablePlaceholder(false)
->options(function () {
return [
'5' => 'NIL',
'4' => 'Has Master',
'3' => 'Make Alert',
'2' => 'Alert Pending',
'1' => 'Alert Approved',
];
})
->default('5')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
})
->required(),
// Forms\Components\TextInput::make('motor_stop_flow_id')
// ->label('MOTOR STOP FLOW ID')
// ->reactive()
// ->minValue(1)
// ->integer()
// ->maxValue(5)
// ->afterStateUpdated(function (callable $set) {
// $set('updated_by', Filament::auth()->user()?->name);
// })
// ->default(5)
// ->required(),
Forms\Components\Select::make('pump_stop_flow_id')
->label('PUMP STOP FLOW ID')
// ->nullable()
->selectablePlaceholder(false)
->options(function () {
return [
'5' => 'NIL',
'4' => 'Has Master',
'3' => 'Make Alert',
'2' => 'Alert Pending',
'1' => 'Alert Approved',
];
})
->default('5')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
})
->required(),
Forms\Components\Select::make('name_plate_stop_flow_id')
->label('NAME PLATE STOP FLOW ID')
// ->nullable()
->selectablePlaceholder(false)
->options(function () {
return [
'5' => 'NIL',
'4' => 'Has Master',
'3' => 'Make Alert',
'2' => 'Alert Pending',
'1' => 'Alert Approved',
];
})
->default('5')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
})
->required(),
Forms\Components\TextInput::make('pending_released_status')
->label('PENDING RELEASED STATUS')
->reactive()
->integer()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
})
->default(0)
->required(),
Forms\Components\TextInput::make('has_work_flow_id')
->label('HAS WORK FLOW ID')
->reactive()
->minValue(0)
->integer()
->maxValue(3)
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
})
->default(0)
->required(),
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('machine.work_center')
->label('WORK CENTER')
->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('aufnr')
->label('AUFNR')
->alignCenter()
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('class')
->label('CLASS')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('arbid')
->label('ARBID')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('gamng')
->label('GAMNG')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('lmnga')
->label('LMNGA')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('gernr')
->label('GERNR')
->alignCenter()
->searchable()
->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('is_stopped')
// ->label('IS STOPPED')
// ->alignCenter()
// ->formatStateUsing(fn ($state) => ($state == '0') ? 'No' : ($state == '1' ? 'Yes' : 'Yes (Alert Pending)'))
// ->sortable(),
// Tables\Columns\TextColumn::make('stopped_datetime')
// ->label('STOPPED DATETIME')
// ->alignCenter()
// ->sortable(),
// Tables\Columns\TextColumn::make('stopped_by')
// ->label('STOPPED BY')
// ->alignCenter()
// ->sortable(),
Tables\Columns\TextColumn::make('mark_status')
->label('MARKED STATUS')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('marked_physical_count')
->label('MARKED PHYSICAL COUNT')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('marked_expected_time')
->label('MARKED EXPECTED TIME')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('marked_datetime')
->label('MARKED DATETIME')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('marked_by')
->label('MARKED BY')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('man_marked_status')
->label('MANUAL MARKED PHYSICAL COUNT')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('man_marked_datetime')
->label('MANUAL MARKED DATETIME')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('man_marked_by')
->label('MANUAL MARKED BY')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('motor_marked_status')
->label('MOTOR MARKED STATUS')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('motor_marked_physical_count')
->label('MOTOR MARKED PHYSICAL COUNT')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('motor_expected_time')
->label('MOTOR EXPECTED TIME')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('motor_marked_datetime')
->label('MOTOR MARKED DATETIME')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('motor_marked_by')
->label('MOTOR MARKED BY')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('pump_marked_status')
->label('PUMP MARKED STATUS')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('pump_marked_physical_count')
->label('PUMP MARKED PHYSICAL COUNT')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('pump_expected_time')
->label('PUMP EXPECTED TIME')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('pump_marked_datetime')
->label('PUMP MARKED DATETIME')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('pump_marked_by')
->label('PUMP MARKED BY')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('name_plate_marked_status')
->label('NAME PLATE MARKED STATUS')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('name_plate_expected_time')
->label('NAME PLATE EXPECTED TIME')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('name_plate_marked_datetime')
->label('NAME PLATE MARKED DATETIME')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('name_plate_marked_by')
->label('NAME PLATE MARKED BY')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('motor_pump_pumpset_status')
->label('MOTOR PUMP PUMPSET STATUS')
->alignCenter()
->formatStateUsing(fn ($state): string => match ((string) $state) {
'1' => 'Motor',
'2' => 'Pump',
'3' => 'PumpSet',
'4' => 'Name Plate',
default => 'NIL',
})
->sortable(),
Tables\Columns\TextColumn::make('winded_serial_number')
->label('WINDED SERIAL NUMBER')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('winded_rework_status')
->label('WINDED REWORK STATUS')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('motor_machine_name')
->label('MOTOR MACHINE NAME')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('pump_machine_name')
->label('PUMP MACHINE NAME')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('name_plate_machine_name')
->label('NAME PLATE MACHINE NAME')
->alignCenter()
->sortable(),
// Tables\Columns\TextColumn::make('pumpset_machine_name')
// ->label('PUMPSET MACHINE NAME')
// ->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('has_work_flow_id')
->label('HAS WORK FLOW ID')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('motor_stop_flow_id')
->label('MOTOR STOP FLOW ID')
->alignCenter()
// ->formatStateUsing(fn ($state) => ($state == '5') ? 'NIL' : ($state == '4' ? 'Has Master' : ($state == '3' ? 'Make Alert' : ($state == '2' ? 'Alert Pending' : ($state == '1' ? 'Alert Approved' : '-')))))
->formatStateUsing(fn ($state): string => match ((string) $state) {
'5' => 'NIL',
'4' => 'Has Master',
'3' => 'Make Alert',
'2' => 'Alert Pending',
'1' => 'Alert Approved',
default => '-',
})
->badge()
->sortable(),
Tables\Columns\TextColumn::make('pump_stop_flow_id')
->label('PUMP STOP FLOW ID')
->alignCenter()
->formatStateUsing(fn ($state): string => match ((string) $state) {
'5' => 'NIL',
'4' => 'Has Master',
'3' => 'Make Alert',
'2' => 'Alert Pending',
'1' => 'Alert Approved',
default => '-',
})
->badge()
->sortable(),
Tables\Columns\TextColumn::make('name_plate_stop_flow_id')
->label('NAME PLATE STOP FLOW ID')
->alignCenter()
->formatStateUsing(fn ($state): string => match ((string) $state) {
'5' => 'NIL',
'4' => 'Has Master',
'3' => 'Make Alert',
'2' => 'Alert Pending',
'1' => 'Alert Approved',
default => '-',
})
->badge()
->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),
])
->searchPlaceholder('Search Job / Serial No')
->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('ClassCharacteristics', 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('machine', null);
$set('item_id', null);
}),
Select::make('machine')
->label('Search by Work Center')
->nullable()
->searchable()
->reactive()
->options(function (callable $get) {
$plantId = $get('Plant');
if (empty($plantId)) {
return [];
}
return Machine::whereHas('ClassCharacteristics', function ($query) use ($plantId) {
if ($plantId) {
$query->where('plant_id', $plantId);
}
})->pluck('work_center', 'id');
}),
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('ClassCharacteristics', function ($query) use ($plantId) {
if ($plantId) {
$query->where('plant_id', $plantId);
}
})->pluck('code', 'id');
}),
TextInput::make('aufnr')
->label('Job Number')
->placeholder('Enter Job Number')
->minlength(7)
->maxlength(10),
TextInput::make('gernr')
->label('Serial Number')
->placeholder('Enter Serial Number'),
TextInput::make('zmm_heading')
->label('Heading')
->placeholder('Enter Heading'),
DateTimePicker::make('motor_marked_from')
->label('Motor Marked From')
->placeholder('Select From DateTime')
->reactive()
->native(false),
DateTimePicker::make('motor_marked_to')
->label('Motor Marked To')
->placeholder('Select To DateTime')
->reactive()
->native(false),
DateTimePicker::make('pump_marked_from')
->label('Pump Marked From')
->placeholder('Select From DateTime')
->reactive()
->native(false),
DateTimePicker::make('pump_marked_to')
->label('Pump Marked To')
->placeholder('Select To DateTime')
->reactive()
->native(false),
DateTimePicker::make('name_plate_marked_from')
->label('Name Plate Marked From')
->placeholder('Select From DateTime')
->reactive()
->native(false),
DateTimePicker::make('name_plate_marked_to')
->label('Name Plate Marked To')
->placeholder('Select To DateTime')
->reactive()
->native(false),
DateTimePicker::make('created_from')
->label('Created From')
->placeholder('Select From DateTime')
->reactive()
->native(false),
DateTimePicker::make('created_to')
->label('Created To')
->placeholder('Select To DateTime')
->reactive()
->native(false),
Select::make('created_by')
->label('Search by Created By')
->nullable()
->searchable()
->reactive()
->options(function () {
return ClassCharacteristic::pluck('created_by', 'created_by');
}),
DateTimePicker::make('updated_from')
->label('Updated From')
->placeholder('Select From DateTime')
->reactive()
->native(false),
DateTimePicker::make('updated_to')
->label('Updated To')
->placeholder('Select To DateTime')
->reactive()
->native(false),
Select::make('updated_by')
->label('Search by Updated By')
->nullable()
->searchable()
->reactive()
->options(function () {
return ClassCharacteristic::pluck('updated_by', 'updated_by');
}),
])
->query(function ($query, array $data) {
// Hide all records initially if no filters are applied
if (empty($data['Plant']) && empty($data['machine']) && empty($data['item_id']) && empty($data['aufnr']) && empty($data['gernr']) && empty($data['zmm_heading']) && empty($data['motor_marked_from']) && empty($data['motor_marked_to']) && empty($data['pump_marked_from']) && empty($data['pump_marked_to']) && empty($data['name_plate_marked_from']) && empty($data['name_plate_marked_to']) && empty($data['created_from']) && empty($data['created_to']) && empty($data['created_by']) && empty($data['updated_from']) && empty($data['updated_to']) && empty($data['updated_by'])) {
return $query->whereRaw('1 = 0');
}
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['machine'])) {
$query->where('machine_id', $data['machine']);
}
if (! empty($data['item_id'])) {
$query->where('item_id', $data['item_id']);
}
if (! empty($data['aufnr'])) {
$query->where('aufnr', 'like', '%'.$data['aufnr'].'%');
}
if (! empty($data['gernr'])) {
$query->where('gernr', 'like', '%'.$data['gernr'].'%');
}
if (! empty($data['zmm_heading'])) {
$query->where('zmm_heading', 'like', '%'.$data['zmm_heading'].'%');
}
if (! empty($data['motor_marked_from'])) {
$query->where('motor_marked_datetime', '>=', $data['motor_marked_from']);
}
if (! empty($data['motor_marked_to'])) {
$query->where('motor_marked_datetime', '<=', $data['motor_marked_to']);
}
if (! empty($data['pump_marked_from'])) {
$query->where('pump_marked_datetime', '>=', $data['pump_marked_from']);
}
if (! empty($data['pump_marked_to'])) {
$query->where('pump_marked_datetime', '<=', $data['pump_marked_to']);
}
if (! empty($data['name_plate_marked_from'])) {
$query->where('name_plate_marked_datetime', '>=', $data['name_plate_marked_from']);
}
if (! empty($data['name_plate_marked_to'])) {
$query->where('name_plate_marked_datetime', '<=', $data['name_plate_marked_to']);
}
if (! empty($data['created_from'])) {
$query->where('created_at', '>=', $data['created_from']);
}
if (! empty($data['created_to'])) {
$query->where('created_at', '<=', $data['created_to']);
}
if (! empty($data['created_by'])) {
$query->where('created_by', $data['created_by']);
}
if (! empty($data['updated_from'])) {
$query->where('updated_at', '>=', $data['updated_from']);
}
if (! empty($data['updated_to'])) {
$query->where('updated_at', '<=', $data['updated_to']);
}
if (! empty($data['updated_by'])) {
$query->where('updated_by', $data['updated_by']);
}
})
->indicateUsing(function (array $data) {
$indicators = [];
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['machine'])) {
$indicators[] = 'Work Center: '.Machine::where('id', $data['machine'])->value('work_center');
}
if (! empty($data['item_id'])) {
$indicators[] = 'Item Code: '.Item::where('id', $data['item_id'])->value('code');
}
if (! empty($data['aufnr'])) {
$indicators[] = 'Job No: '.$data['aufnr'];
}
if (! empty($data['gernr'])) {
$indicators[] = 'Serial Number: '.$data['gernr'];
}
if (! empty($data['zmm_heading'])) {
$indicators[] = 'Heading: '.$data['zmm_heading'];
}
if (! empty($data['motor_marked_from'])) {
$indicators[] = 'Motor Marked From: '.$data['motor_marked_from'];
}
if (! empty($data['motor_marked_to'])) {
$indicators[] = 'Motor Marked To: '.$data['motor_marked_to'];
}
if (! empty($data['pump_marked_from'])) {
$indicators[] = 'Pump Marked From: '.$data['pump_marked_from'];
}
if (! empty($data['pump_marked_to'])) {
$indicators[] = 'Pump Marked To: '.$data['pump_marked_to'];
}
if (! empty($data['name_plate_marked_from'])) {
$indicators[] = 'Name Plate Marked From: '.$data['name_plate_marked_from'];
}
if (! empty($data['name_plate_marked_to'])) {
$indicators[] = 'Name Plate Marked To: '.$data['name_plate_marked_to'];
}
if (! empty($data['created_from'])) {
$indicators[] = 'Created From: '.$data['created_from'];
}
if (! empty($data['created_to'])) {
$indicators[] = 'Created To: '.$data['created_to'];
}
if (! empty($data['created_by'])) {
$indicators[] = 'Created By: '.$data['created_by'];
}
if (! empty($data['updated_from'])) {
$indicators[] = 'Updated From: '.$data['updated_from'];
}
if (! empty($data['updated_to'])) {
$indicators[] = 'Updated To: '.$data['updated_to'];
}
if (! empty($data['updated_by'])) {
$indicators[] = 'Updated By: '.$data['updated_by'];
}
return $indicators;
}),
])
->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 Class Characteristic Serial')
->label('Import Class Characteristic Serial')
->form([
Select::make('plant_id')
// ->options(Plant::pluck('name', 'id')->toArray()) // Fetch plant names and IDs
->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();
})
->searchable()
->label('Search by Plant Name')
->required()
->default(function () {
return optional(ClassCharacteristic::latest()->first())->plant_id;
})
->afterStateUpdated(function ($state, callable $set, callable $get) {
// $set('class_characteristics_serial', null);
$plantId = $get('plant_id');
if (! $plantId) {
$set('invoice_serial_number', 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('class_characteristics_serial')
->label('Choose Class Characteristic Serial Upload')
->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['class_characteristics_serial'];
$disk = Storage::disk('local');
$plantId = $data['plant_id'];
$plant = Plant::find($plantId);
$plantCode = $plant?->code ?? null;
$userName = Filament::auth()->user()->name;
// 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
$fullPath = Storage::disk('local')->path($path);
// /home/iot-dev/projects/pds/storage/app/private/uploads/temp/{$plantCode}/3RA0018735.xlsx
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 'Serial Invoice' file to proceed..!")
->danger()
->send();
if ($disk->exists($path)) {
$disk->delete($path);
}
return;
}
$invalidMplaCodes = [];
$invalidItemCodes = [];
$invalidWorkCenters = [];
$invalidPOrders = [];
$invalidOrderQuantities = [];
$invalidReleaseQuantities = [];
$invalidSerialCodes = [];
$invalidMatCodesNotFound = [];
$invalidPlaCodesNotFound = [];
$invalidWorkCodesNotFound = [];
$materialCodes = [];
$missingSerials = [];
$duplicateSerials = [];
$seenSerialNumbers = [];
$validRowsFound = false;
$duplicateSerialNoInDb = [];
foreach ($rows as $index => $row) {
if ($index == 0) {
continue;
} // Skip header
$plantCode = trim($row[0]);
$itemCode = trim($row[1]);
$workCenter = trim($row[2]);
$pOrder = trim($row[3]);
$orderQuan = trim($row[4]);
$releaseQuan = trim($row[5]);
$serialNumber = trim($row[6]);
if (empty($plantCode) && empty($itemCode) && empty($workCenter) && empty($pOrder) && empty($orderQuan) && empty($releaseQuan) && empty($serialNumber)) {
continue;
}
if (empty($plantCode)) {
$invalidMplaCodes[] = 'Row '.($index + 1).': Plant Code is empty';
continue;
}
if (Str::length($plantCode) < 4 || ! is_numeric($plantCode)) {
$invalidMplaCodes[] = $plantCode;
continue;
}
if (Str::length($plantCode) > 3) {
$plant = Plant::where('code', $plantCode)->first();
if (! $plant) {
$invalidPlaCodesNotFound[] = $plantCode;
continue;
}
}
if (Str::length($itemCode) < 6 || ! ctype_alnum($itemCode)) {
$invalidItemCodes[] = $itemCode;
continue;
}
if ($itemCode) {
$itemCodeExist = Item::where('plant_id', $plantId)->where('code', $itemCode)->first();
if (! $itemCodeExist) {
$invalidMatCodesNotFound = $itemCode;
continue;
}
}
if (empty($workCenter)) {
$invalidWorkCenters[] = $workCenter;
continue;
}
if (Str::length($workCenter) < 7) {
$invalidWorkCenters[] = $workCenter;
continue;
}
if (Str::length($workCenter) > 6) {
$WorkCenter = Machine::where('plant_id', $plantId)->where('work_center', $workCenter)->first();
if (! $WorkCenter) {
$invalidWorkCodesNotFound[] = $workCenter;
continue;
}
}
if (Str::length($pOrder) < 7 || ! is_numeric($pOrder)) {
$invalidPOrders[] = $pOrder;
continue;
}
if ($orderQuan == '' || ! is_numeric($orderQuan)) {
$invalidOrderQuantities[] = $orderQuan;
continue;
}
if ($releaseQuan == '' || ! is_numeric($releaseQuan)) {
$invalidReleaseQuantities[] = $releaseQuan;
continue;
}
if (! empty($serialNumber)) {
if (Str::length($serialNumber) < 9 || ! ctype_alnum($serialNumber)) {
$invalidSerialCodes[] = $serialNumber;
}
if ($serialNumber) {
if (in_array($serialNumber, $seenSerialNumbers)) {
$duplicateSerials[] = $serialNumber;
} else {
$seenSerialNumbers[] = $serialNumber;
$materialCodes[] = $itemCode;
$validRowsFound = true;
}
}
if (Str::length($serialNumber) > 8) {
$SerialNoExist = ClassCharacteristic::where('plant_id', $plantId)->where('gernr', $serialNumber)->first();
if ($SerialNoExist) {
$duplicateSerialNoInDb[] = $serialNumber;
continue;
}
}
}
}
$uniqueInvalidCodes = array_unique($invalidItemCodes);
$uniqueInvalidMatCodesMaster = array_unique($invalidMatCodesNotFound);
$uniqueInvalidPlaCodesMaster = array_unique($invalidPlaCodesNotFound);
$uniqueInvalidWorkCenter = array_unique($invalidWorkCenters);
$uniqueInvalidWorkCenterMaster = array_unique($invalidWorkCodesNotFound);
$uniqueInvalidPOrder = array_unique($invalidPOrders);
$uniqueInvalidOrdQuan = array_unique($invalidOrderQuantities);
$uniqueInvalidReleaseQuan = array_unique($invalidReleaseQuantities);
$uniqueMissingSerials = array_unique($missingSerials);
$uniqueSerialCodes = array_unique($invalidSerialCodes);
$duplicateSerialCodes = array_unique($duplicateSerials);
$duplicateSerialCodesInDb = array_unique($duplicateSerialNoInDb);
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 (! empty($uniqueInvalidMatCodesMaster)) {
Notification::make()
->title('Invalid Item Codes')
->body('The following item codes not found in item master:<br>'.implode(', ', $uniqueInvalidMatCodesMaster))
->danger()
->send();
if ($disk->exists($path)) {
$disk->delete($path);
}
return;
} elseif (! empty($uniqueInvalidPlaCodesMaster)) {
Notification::make()
->title('Invalid Plant Codes')
->body('The following plant codes not found in plant master:<br>'.implode(', ', $uniqueInvalidPlaCodesMaster))
->danger()
->send();
if ($disk->exists($path)) {
$disk->delete($path);
}
return;
} elseif (! empty($uniqueInvalidWorkCenter)) {
Notification::make()
->title('Invalid Work Center')
->body('The following work center should contain miminum 7 digits:<br>'.implode(', ', $uniqueInvalidWorkCenter))
->danger()
->send();
if ($disk->exists($path)) {
$disk->delete($path);
}
return;
} elseif (! empty($uniqueInvalidWorkCenterMaster)) {
Notification::make()
->title('Invalid Work Center')
->body('The following work center not found in machine master:<br>'.implode(', ', $uniqueInvalidWorkCenterMaster))
->danger()
->send();
if ($disk->exists($path)) {
$disk->delete($path);
}
return;
} elseif (! empty($duplicateSerialCodesInDb)) {
Notification::make()
->title('Duplicate Serial Number In DB')
->body('The following Serial Number already exist in class characteristic table:<br>'.implode(', ', $duplicateSerialCodesInDb))
->danger()
->send();
if ($disk->exists($path)) {
$disk->delete($path);
}
return;
} elseif (! empty($uniqueInvalidPOrder)) {
Notification::make()
->title('Invalid Production Order')
->body('The following production order should contain minimum 7 digit values:<br>'.implode(', ', $uniqueInvalidPOrder))
->danger()
->send();
if ($disk->exists($path)) {
$disk->delete($path);
}
return;
} elseif (! empty($uniqueInvalidOrdQuan)) {
Notification::make()
->title('Invalid Order Quantity')
->body('The following Order Quantity should contain numeric values:<br>'.implode(', ', $uniqueInvalidOrdQuan))
->danger()
->send();
if ($disk->exists($path)) {
$disk->delete($path);
}
return;
} elseif (! empty($uniqueInvalidReleaseQuan)) {
Notification::make()
->title('Invalid Released Quantity')
->body('The following Released Quantity should contain numeric values:<br>'.implode(', ', $uniqueInvalidReleaseQuan))
->danger()
->send();
if ($disk->exists($path)) {
$disk->delete($path);
}
return;
} elseif (! empty($uniqueMissingSerials)) {
Notification::make()
->title('Missing Serial Numbers')
->body("The following item codes doesn't have valid serial number:<br>".implode(', ', $uniqueMissingSerials))
->danger()
->send();
if ($disk->exists($path)) {
$disk->delete($path);
}
return;
} elseif (! empty($uniqueSerialCodes)) {
Notification::make()
->title('Invalid Serial Number')
->body('The following serial numbers should contain minimum 9 digit alpha numeric values:<br>'.implode(', ', $uniqueSerialCodes))
->danger()
->send();
if ($disk->exists($path)) {
$disk->delete($path);
}
return;
} elseif (! empty($duplicateSerialCodes)) {
Notification::make()
->title('Duplicate Serial Numbers')
->body('The following serial numbers are already exist in imported excel:<br>'.implode(', ', $duplicateSerialCodes))
->danger()
->send();
if ($disk->exists($path)) {
$disk->delete($path);
}
return;
} elseif (! $validRowsFound) {
Notification::make()
->title('Invalid Serial Invoice')
->danger() // This makes the notification red to indicate an error
->body('Uploaded Excel sheet is empty or<br>contains no valid data.')
->send();
if ($disk->exists($path)) {
$disk->delete($path);
}
return;
}
// ..Insert Logic
$insertedCount = 0;
foreach ($rows as $index => $row) {
if ($index == 0) {
continue;
} // Skip header
$plantCode = trim($row[0]);
$itemCode = trim($row[1]);
$workCenter = trim($row[2]);
$pOrder = trim($row[3]);
$orderQuan = trim($row[4]);
$releaseQuan = trim($row[5]);
$serialNumber = trim($row[6]);
if (empty($plantCode) && empty($itemCode) && empty($workCenter) && empty($pOrder) && empty($orderQuan) && empty($releaseQuan) && empty($serialNumber)) {
continue;
}
$item = Item::where('plant_id', $plantId)->where('code', $itemCode)->first();
$machine = Machine::where('plant_id', $plantId)->where('work_center', $workCenter)->first();
$record = ClassCharacteristic::create([
'plant_id' => $plantId,
'item_id' => $item->id,
'machine_id' => $machine->id,
'aufnr' => $pOrder,
'gamng' => $orderQuan,
'lmnga' => $releaseQuan,
'gernr' => $serialNumber,
'created_by' => $userName,
'updated_by' => $userName,
]);
if ($record) {
$insertedCount++;
}
}
$itemCharacteristic = ItemCharacteristic::where('plant_id', $plantId)->where('item_id', $item->id)->first();
if ($itemCharacteristic) {
$classCharacteristics = ClassCharacteristic::where('plant_id', $itemCharacteristic->plant_id)
->where('item_id', $itemCharacteristic->item_id)
->get();
$updatedCount = 0;
foreach ($classCharacteristics as $classCharacteristic) {
$classCharacteristic->update([
'zz1_cn_bill_ord' => $itemCharacteristic->zz1_cn_bill_ord,
'zmm_amps' => $itemCharacteristic->zmm_amps,
'zmm_brand' => $itemCharacteristic->zmm_brand,
'zmm_degreeofprotection' => $itemCharacteristic->zmm_degreeofprotection,
'zmm_delivery' => $itemCharacteristic->zmm_delivery,
'zmm_dir_rot' => $itemCharacteristic->zmm_dir_rot,
'zmm_discharge' => $itemCharacteristic->zmm_discharge,
'zmm_discharge_max' => $itemCharacteristic->zmm_discharge_max,
'zmm_discharge_min' => $itemCharacteristic->zmm_discharge_min,
'zmm_duty' => $itemCharacteristic->zmm_duty,
'zmm_eff_motor' => $itemCharacteristic->zmm_eff_motor,
'zmm_eff_pump' => $itemCharacteristic->zmm_eff_pump,
'zmm_frequency' => $itemCharacteristic->zmm_frequency,
'zmm_head' => $itemCharacteristic->zmm_head,
'zmm_heading' => $itemCharacteristic->zmm_heading,
'zmm_head_max' => $itemCharacteristic->zmm_head_max,
'zmm_head_minimum' => $itemCharacteristic->zmm_head_minimum,
'zmm_idx_eff_mtr' => $itemCharacteristic->zmm_idx_eff_mtr,
'zmm_idx_eff_pump' => $itemCharacteristic->zmm_idx_eff_pump,
'zmm_kvacode' => $itemCharacteristic->zmm_kvacode,
'zmm_maxambtemp' => $itemCharacteristic->zmm_maxambtemp,
'zmm_mincoolingflow' => $itemCharacteristic->zmm_mincoolingflow,
'zmm_motorseries' => $itemCharacteristic->zmm_motorseries,
'zmm_motor_model' => $itemCharacteristic->zmm_motor_model,
'zmm_outlet' => $itemCharacteristic->zmm_outlet,
'zmm_phase' => $itemCharacteristic->zmm_phase,
'zmm_pressure' => $itemCharacteristic->zmm_pressure,
'zmm_pumpflowtype' => $itemCharacteristic->zmm_pumpflowtype,
'zmm_pumpseries' => $itemCharacteristic->zmm_pumpseries,
'zmm_pump_model' => $itemCharacteristic->zmm_pump_model,
'zmm_ratedpower' => $itemCharacteristic->zmm_ratedpower,
'zmm_region' => $itemCharacteristic->zmm_region,
'zmm_servicefactor' => $itemCharacteristic->zmm_servicefactor,
'zmm_servicefactormaximumamps' => $itemCharacteristic->zmm_servicefactormaximumamps,
'zmm_speed' => $itemCharacteristic->zmm_speed,
'zmm_suction' => $itemCharacteristic->zmm_suction,
'zmm_suctionxdelivery' => $itemCharacteristic->zmm_suctionxdelivery,
'zmm_supplysource' => $itemCharacteristic->zmm_supplysource,
'zmm_temperature' => $itemCharacteristic->zmm_temperature,
'zmm_thrustload' => $itemCharacteristic->zmm_thrustload,
'zmm_volts' => $itemCharacteristic->zmm_volts,
'zmm_wire' => $itemCharacteristic->zmm_wire,
'zmm_package' => $itemCharacteristic->zmm_package,
'zmm_pvarrayrating' => $itemCharacteristic->zmm_pvarrayrating,
'zmm_isi' => $itemCharacteristic->zmm_isi,
'zmm_isimotor' => $itemCharacteristic->zmm_isimotor,
'zmm_isipump' => $itemCharacteristic->zmm_isipump,
'zmm_isipumpset' => $itemCharacteristic->zmm_isipumpset,
'zmm_pumpset_model' => $itemCharacteristic->zmm_pumpset_model,
'zmm_stages' => $itemCharacteristic->zmm_stages,
'zmm_headrange' => $itemCharacteristic->zmm_headrange,
'zmm_overall_efficiency' => $itemCharacteristic->zmm_overall_efficiency,
'zmm_connection' => $itemCharacteristic->zmm_connection,
'zmm_min_bore_size' => $itemCharacteristic->zmm_min_bore_size,
'zmm_isireference' => $itemCharacteristic->zmm_isireference,
'zmm_category' => $itemCharacteristic->zmm_category,
'zmm_submergence' => $itemCharacteristic->zmm_submergence,
'zmm_capacitorstart' => $itemCharacteristic->zmm_capacitorstart,
'zmm_capacitorrun' => $itemCharacteristic->zmm_capacitorrun,
'zmm_inch' => $itemCharacteristic->zmm_inch,
'zmm_motor_type' => $itemCharacteristic->zmm_motor_type,
'zmm_dismantle_direction' => $itemCharacteristic->zmm_dismantle_direction,
'zmm_eff_ovrall' => $itemCharacteristic->zmm_eff_ovrall,
'zmm_bodymoc' => $itemCharacteristic->zmm_bodymoc,
'zmm_rotormoc' => $itemCharacteristic->zmm_rotormoc,
'zmm_dlwl' => $itemCharacteristic->zmm_dlwl,
'zmm_inputpower' => $itemCharacteristic->zmm_inputpower,
'zmm_imp_od' => $itemCharacteristic->zmm_imp_od,
'zmm_ambtemp' => $itemCharacteristic->zmm_ambtemp,
'zmm_de' => $itemCharacteristic->zmm_de,
'zmm_dischargerange' => $itemCharacteristic->zmm_dischargerange,
'zmm_efficiency_class' => $itemCharacteristic->zmm_efficiency_class,
'zmm_framesize' => $itemCharacteristic->zmm_framesize,
'zmm_impellerdiameter' => $itemCharacteristic->zmm_impellerdiameter,
'zmm_insulationclass' => $itemCharacteristic->zmm_insulationclass,
'zmm_maxflow' => $itemCharacteristic->zmm_maxflow,
'zmm_minhead' => $itemCharacteristic->zmm_minhead,
'zmm_mtrlofconst' => $itemCharacteristic->zmm_mtrlofconst,
'zmm_nde' => $itemCharacteristic->zmm_nde,
'zmm_powerfactor' => $itemCharacteristic->zmm_powerfactor,
'zmm_tagno' => $itemCharacteristic->zmm_tagno,
'zmm_year' => $itemCharacteristic->zmm_year,
'zmm_laser_name' => $itemCharacteristic->zmm_laser_name,
'zmm_logo_cp' => $itemCharacteristic->zmm_logo_cp,
'zmm_logo_ce' => $itemCharacteristic->zmm_logo_ce,
'zmm_logo_nsf' => $itemCharacteristic->zmm_logo_nsf,
'zmm_logo_eac' => $itemCharacteristic->zmm_logo_eac,
'zmm_beenote' => $itemCharacteristic->zmm_beenote,
'zmm_beenumber' => $itemCharacteristic->zmm_beenumber,
'zmm_beestar' => $itemCharacteristic->zmm_beestar,
'zmm_codeclass' => $itemCharacteristic->zmm_codeclass,
'zmm_colour' => $itemCharacteristic->zmm_colour,
'zmm_grade' => $itemCharacteristic->zmm_grade,
'zmm_grwt_pset' => $itemCharacteristic->zmm_grwt_pset,
'zmm_grwt_cable' => $itemCharacteristic->zmm_grwt_cable,
'zmm_grwt_motor' => $itemCharacteristic->zmm_grwt_motor,
'zmm_grwt_pf' => $itemCharacteristic->zmm_grwt_pf,
'zmm_grwt_pump' => $itemCharacteristic->zmm_grwt_pump,
'zmm_isivalve' => $itemCharacteristic->zmm_isivalve,
'zmm_isi_wc' => $itemCharacteristic->zmm_isi_wc,
'zmm_labelperiod' => $itemCharacteristic->zmm_labelperiod,
'zmm_length' => $itemCharacteristic->zmm_length,
'zmm_license_cml_no' => $itemCharacteristic->zmm_license_cml_no,
'zmm_mfgmonyr' => $itemCharacteristic->zmm_mfgmonyr,
'zmm_modelyear' => $itemCharacteristic->zmm_modelyear,
'zmm_motoridentification' => $itemCharacteristic->zmm_motoridentification,
'zmm_newt_pset' => $itemCharacteristic->zmm_newt_pset,
'zmm_newt_cable' => $itemCharacteristic->zmm_newt_cable,
'zmm_newt_motor' => $itemCharacteristic->zmm_newt_motor,
'zmm_newt_pf' => $itemCharacteristic->zmm_newt_pf,
'zmm_newt_pump' => $itemCharacteristic->zmm_newt_pump,
'zmm_packtype' => $itemCharacteristic->zmm_packtype,
'zmm_panel' => $itemCharacteristic->zmm_panel,
'zmm_performance_factor' => $itemCharacteristic->zmm_performance_factor,
'zmm_pumpidentification' => $itemCharacteristic->zmm_pumpidentification,
'zmm_psettype' => $itemCharacteristic->zmm_psettype,
'zmm_size' => $itemCharacteristic->zmm_size,
'zmm_eff_ttl' => $itemCharacteristic->zmm_eff_ttl,
'zmm_type' => $itemCharacteristic->zmm_type,
'zmm_usp' => $itemCharacteristic->zmm_usp,
'zmm_operating_range' => $itemCharacteristic->zmm_operating_range,
'zmm_intake_air' => $itemCharacteristic->zmm_intake_air,
'zmm_oxygen_transfer_rate' => $itemCharacteristic->zmm_oxygen_transfer_rate,
'zmm_air_inlet_pipesize' => $itemCharacteristic->zmm_air_inlet_pipesize,
'zmm_sump_depth' => $itemCharacteristic->zmm_sump_depth,
'zmm_poles' => $itemCharacteristic->zmm_poles,
'zmm_motor_heading' => $itemCharacteristic->zmm_motor_heading,
'zmm_motor_speed' => $itemCharacteristic->zmm_motor_speed,
'zqmm_qty' => $itemCharacteristic->zqmm_qty,
'zmm_operating_temperature' => $itemCharacteristic->zmm_operating_temperature,
'zmm_axial_force' => $itemCharacteristic->zmm_axial_force,
]);
$updatedCount++;
}
}
if ($record) {
Notification::make()
->title('Import Successful')
->body("{$insertedCount} records inserted successfully and updated zmm values success for '{$updatedCount}' records.")
->success();
}
}
})
->visible(function () {
return Filament::auth()->user()->can('view import class characteristic serial');
}),
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,
]);
}
}