From 8ee226bcf8f8785127767b72d5c8ffbb2f2c894c Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Mon, 14 Sep 2026 12:29:16 +0530 Subject: [PATCH 01/18] removed laser stop alert and consolidate report mail --- app/Console/Commands/Scheduler.php | 142 ++++++++++++++--------------- 1 file changed, 71 insertions(+), 71 deletions(-) diff --git a/app/Console/Commands/Scheduler.php b/app/Console/Commands/Scheduler.php index 13e441d..24b5537 100644 --- a/app/Console/Commands/Scheduler.php +++ b/app/Console/Commands/Scheduler.php @@ -396,81 +396,81 @@ class Scheduler extends Command } //..Laser Stop Report - $laserStopReport = AlertMailRule::where('module', 'LaserStopAlert') - ->where('rule_name', 'LaserStopAlertMail') - ->select('plant', 'schedule_type', 'machine_id') - ->distinct() - ->get(); + // $laserStopReport = AlertMailRule::where('module', 'LaserStopAlert') + // ->where('rule_name', 'LaserStopAlertMail') + // ->select('plant', 'schedule_type', 'machine_id') + // ->distinct() + // ->get(); - foreach ($laserStopReport as $rule) { - switch ($rule->schedule_type) { - case 'Live': - // Run every minute - \Artisan::call('send:laser-stop-report', [ - 'schedule_type' => $rule->schedule_type, - 'plant' => $rule->plant, - 'machine_id' => $rule->machine_id, - ]); - break; - case 'Hourly': - if (now()->minute == 0) { - \Artisan::call('send:laser-stop-report', [ - 'schedule_type' => $rule->schedule_type, - 'plant' => $rule->plant, - 'machine_id' => $rule->machine_id, - ]); - } - break; - case 'Daily': - if (now()->format('H:i') == '07:59') { - \Artisan::call('send:laser-stop-report', [ - 'schedule_type' => $rule->schedule_type, - 'plant' => $rule->plant, - 'machine_id' => $rule->machine_id, - ]); - } - break; - } - } + // foreach ($laserStopReport as $rule) { + // switch ($rule->schedule_type) { + // case 'Live': + // // Run every minute + // \Artisan::call('send:laser-stop-report', [ + // 'schedule_type' => $rule->schedule_type, + // 'plant' => $rule->plant, + // 'machine_id' => $rule->machine_id, + // ]); + // break; + // case 'Hourly': + // if (now()->minute == 0) { + // \Artisan::call('send:laser-stop-report', [ + // 'schedule_type' => $rule->schedule_type, + // 'plant' => $rule->plant, + // 'machine_id' => $rule->machine_id, + // ]); + // } + // break; + // case 'Daily': + // if (now()->format('H:i') == '07:59') { + // \Artisan::call('send:laser-stop-report', [ + // 'schedule_type' => $rule->schedule_type, + // 'plant' => $rule->plant, + // 'machine_id' => $rule->machine_id, + // ]); + // } + // break; + // } + // } - //..Laser Stop Final Report + // //..Laser Stop Final Report - $laserStopFinalReport = AlertMailRule::where('module', 'LaserStopReport') - ->where('rule_name', 'LaserStopMail') - ->select('plant', 'schedule_type', 'machine_id') - ->distinct() - ->get(); + // $laserStopFinalReport = AlertMailRule::where('module', 'LaserStopReport') + // ->where('rule_name', 'LaserStopMail') + // ->select('plant', 'schedule_type', 'machine_id') + // ->distinct() + // ->get(); - foreach ($laserStopFinalReport as $rule) { - switch ($rule->schedule_type) { - case 'Live': - // Run every minute - \Artisan::call('send:laser-stop-consolidate-report', [ - 'schedule_type' => $rule->schedule_type, - 'plant' => $rule->plant, - 'machine_id' => $rule->machine_id, - ]); - break; - case 'Hourly': - if (now()->minute == 0) { - \Artisan::call('send:laser-stop-consolidate-report', [ - 'schedule_type' => $rule->schedule_type, - 'plant' => $rule->plant, - 'machine_id' => $rule->machine_id, - ]); - } - break; - case 'Daily': - if (now()->format('H:i') == '08:00') { - \Artisan::call('send:laser-stop-consolidate-report', [ - 'schedule_type' => $rule->schedule_type, - 'plant' => $rule->plant, - 'machine_id' => $rule->machine_id, - ]); - } - break; - } - } + // foreach ($laserStopFinalReport as $rule) { + // switch ($rule->schedule_type) { + // case 'Live': + // // Run every minute + // \Artisan::call('send:laser-stop-consolidate-report', [ + // 'schedule_type' => $rule->schedule_type, + // 'plant' => $rule->plant, + // 'machine_id' => $rule->machine_id, + // ]); + // break; + // case 'Hourly': + // if (now()->minute == 0) { + // \Artisan::call('send:laser-stop-consolidate-report', [ + // 'schedule_type' => $rule->schedule_type, + // 'plant' => $rule->plant, + // 'machine_id' => $rule->machine_id, + // ]); + // } + // break; + // case 'Daily': + // if (now()->format('H:i') == '08:00') { + // \Artisan::call('send:laser-stop-consolidate-report', [ + // 'schedule_type' => $rule->schedule_type, + // 'plant' => $rule->plant, + // 'machine_id' => $rule->machine_id, + // ]); + // } + // break; + // } + // } //..Panel Box Final Report -- 2.49.1 From e489be4e5715e99e30e59214ea31a0519127c25a Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Mon, 14 Sep 2026 12:32:46 +0530 Subject: [PATCH 02/18] Added temp stop characteristics migration file --- ...create_temp_stop_characteristics_table.php | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 database/migrations/2026_09_05_105433_create_temp_stop_characteristics_table.php diff --git a/database/migrations/2026_09_05_105433_create_temp_stop_characteristics_table.php b/database/migrations/2026_09_05_105433_create_temp_stop_characteristics_table.php new file mode 100644 index 0000000..2b62954 --- /dev/null +++ b/database/migrations/2026_09_05_105433_create_temp_stop_characteristics_table.php @@ -0,0 +1,51 @@ + Date: Mon, 14 Sep 2026 12:34:05 +0530 Subject: [PATCH 03/18] Added temp stop characteristics model and policy files --- app/Models/TempStopCharacteristic.php | 47 ++++++++ app/Policies/TempStopCharacteristicPolicy.php | 105 ++++++++++++++++++ 2 files changed, 152 insertions(+) create mode 100644 app/Models/TempStopCharacteristic.php create mode 100644 app/Policies/TempStopCharacteristicPolicy.php diff --git a/app/Models/TempStopCharacteristic.php b/app/Models/TempStopCharacteristic.php new file mode 100644 index 0000000..039529c --- /dev/null +++ b/app/Models/TempStopCharacteristic.php @@ -0,0 +1,47 @@ +belongsTo(Plant::class); + } + + public function item(): BelongsTo + { + return $this->belongsTo(Item::class); + } + + public function machine(): BelongsTo + { + return $this->belongsTo(Machine::class); + } +} diff --git a/app/Policies/TempStopCharacteristicPolicy.php b/app/Policies/TempStopCharacteristicPolicy.php new file mode 100644 index 0000000..14c3d4b --- /dev/null +++ b/app/Policies/TempStopCharacteristicPolicy.php @@ -0,0 +1,105 @@ +checkPermissionTo('view-any TempStopCharacteristic'); + } + + /** + * Determine whether the user can view the model. + */ + public function view(User $user, TempStopCharacteristic $tempstopcharacteristic): bool + { + return $user->checkPermissionTo('view TempStopCharacteristic'); + } + + /** + * Determine whether the user can create models. + */ + public function create(User $user): bool + { + return $user->checkPermissionTo('create TempStopCharacteristic'); + } + + /** + * Determine whether the user can update the model. + */ + public function update(User $user, TempStopCharacteristic $tempstopcharacteristic): bool + { + return $user->checkPermissionTo('update TempStopCharacteristic'); + } + + /** + * Determine whether the user can delete the model. + */ + public function delete(User $user, TempStopCharacteristic $tempstopcharacteristic): bool + { + return $user->checkPermissionTo('delete TempStopCharacteristic'); + } + + /** + * Determine whether the user can delete any models. + */ + public function deleteAny(User $user): bool + { + return $user->checkPermissionTo('delete-any TempStopCharacteristic'); + } + + /** + * Determine whether the user can restore the model. + */ + public function restore(User $user, TempStopCharacteristic $tempstopcharacteristic): bool + { + return $user->checkPermissionTo('restore TempStopCharacteristic'); + } + + /** + * Determine whether the user can restore any models. + */ + public function restoreAny(User $user): bool + { + return $user->checkPermissionTo('restore-any TempStopCharacteristic'); + } + + /** + * Determine whether the user can replicate the model. + */ + public function replicate(User $user, TempStopCharacteristic $tempstopcharacteristic): bool + { + return $user->checkPermissionTo('replicate TempStopCharacteristic'); + } + + /** + * Determine whether the user can reorder the models. + */ + public function reorder(User $user): bool + { + return $user->checkPermissionTo('reorder TempStopCharacteristic'); + } + + /** + * Determine whether the user can permanently delete the model. + */ + public function forceDelete(User $user, TempStopCharacteristic $tempstopcharacteristic): bool + { + return $user->checkPermissionTo('force-delete TempStopCharacteristic'); + } + + /** + * Determine whether the user can permanently delete any models. + */ + public function forceDeleteAny(User $user): bool + { + return $user->checkPermissionTo('force-delete-any TempStopCharacteristic'); + } +} -- 2.49.1 From 2e3d3d80521d936054caed73e47aa3f967e614d1 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Mon, 14 Sep 2026 12:36:41 +0530 Subject: [PATCH 04/18] Added temp stop characteristics model files for hasMany relations --- app/Models/Item.php | 5 +++++ app/Models/Machine.php | 5 +++++ app/Models/Plant.php | 8 ++++---- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/app/Models/Item.php b/app/Models/Item.php index e792553..bfba54e 100644 --- a/app/Models/Item.php +++ b/app/Models/Item.php @@ -105,6 +105,11 @@ class Item extends Model return $this->hasMany(TempClassCharacteristic::class, 'item_id', 'id'); } + public function tempStopCharacteristics() + { + return $this->hasMany(TempStopCharacteristic::class, 'item_id', 'id'); + } + public function weightValidations() { return $this->hasMany(WeightValidation::class); diff --git a/app/Models/Machine.php b/app/Models/Machine.php index f584c02..349c7e8 100644 --- a/app/Models/Machine.php +++ b/app/Models/Machine.php @@ -88,6 +88,11 @@ class Machine extends Model return $this->hasMany(TempClassCharacteristic::class, 'machine_id', 'id'); } + public function tempStopCharacteristics() + { + return $this->hasMany(TempStopCharacteristic::class, 'machine_id', 'id'); + } + public function equipmentMasters() { return $this->hasMany(EquipmentMaster::class, 'machine_id', 'id'); diff --git a/app/Models/Plant.php b/app/Models/Plant.php index e9ed341..2017230 100644 --- a/app/Models/Plant.php +++ b/app/Models/Plant.php @@ -189,10 +189,10 @@ class Plant extends Model return $this->hasMany(TempClassCharacteristic::class, 'plant_id', 'id'); } - // public function tempStopCharacteristics() - // { - // return $this->hasMany(TempStopCharacteristic::class, 'plant_id', 'id'); - // } + public function tempStopCharacteristics() + { + return $this->hasMany(TempStopCharacteristic::class, 'plant_id', 'id'); + } public function users() { -- 2.49.1 From 9cd772ac9e5c7bc8b1654fa88d0a091a2f1e85e2 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Mon, 14 Sep 2026 12:41:38 +0530 Subject: [PATCH 05/18] Added temp stop characteristics resources, importer, and exporter files --- .../TempStopCharacteristicExporter.php | 77 ++ .../TempStopCharacteristicImporter.php | 111 +++ .../TempStopCharacteristicResource.php | 793 ++++++++++++++++++ .../Pages/CreateTempStopCharacteristic.php | 12 + .../Pages/EditTempStopCharacteristic.php | 22 + .../Pages/ListTempStopCharacteristics.php | 19 + .../Pages/ViewTempStopCharacteristic.php | 19 + 7 files changed, 1053 insertions(+) create mode 100644 app/Filament/Exports/TempStopCharacteristicExporter.php create mode 100644 app/Filament/Imports/TempStopCharacteristicImporter.php create mode 100644 app/Filament/Resources/TempStopCharacteristicResource.php create mode 100644 app/Filament/Resources/TempStopCharacteristicResource/Pages/CreateTempStopCharacteristic.php create mode 100644 app/Filament/Resources/TempStopCharacteristicResource/Pages/EditTempStopCharacteristic.php create mode 100644 app/Filament/Resources/TempStopCharacteristicResource/Pages/ListTempStopCharacteristics.php create mode 100644 app/Filament/Resources/TempStopCharacteristicResource/Pages/ViewTempStopCharacteristic.php diff --git a/app/Filament/Exports/TempStopCharacteristicExporter.php b/app/Filament/Exports/TempStopCharacteristicExporter.php new file mode 100644 index 0000000..0537df5 --- /dev/null +++ b/app/Filament/Exports/TempStopCharacteristicExporter.php @@ -0,0 +1,77 @@ +label('ID'), + ExportColumn::make('no') + ->label('NO') + ->state(function ($record) use (&$rowNumber) { + // Increment and return the row number + return ++$rowNumber; + }), + ExportColumn::make('plant.code') + ->label('PLANT CODE'), + ExportColumn::make('machine.work_center') + ->label('WORK CENTER'), + ExportColumn::make('machine_name') + ->label('MACHINE NAME'), + ExportColumn::make('has_stop_flow_id') + ->label('HAS STOP FLOW ID'), + ExportColumn::make('item.code') + ->label('ITEM CODE'), + ExportColumn::make('aufnr') + ->label('JOB NUMBER'), + ExportColumn::make('gernr') + ->label('SERIAL NUMBER'), + ExportColumn::make('zmm_heading') + ->label('ZMM HEADING'), + ExportColumn::make('model_type') + ->label('MODEL TYPE'), + ExportColumn::make('characteristic_field') + ->label('MASTER CHARACTERISTIC FIELD'), + ExportColumn::make('samlight_logged_name') + ->label('SAMLIGHT LOGGED NAME'), + ExportColumn::make('stopped_at') + ->label('STOPPED AT'), + ExportColumn::make('stopped_by') + ->label('STOPPED BY'), + ExportColumn::make('has_stop_flow_id') + ->label('HAS STOP FLOW ID'), + ExportColumn::make('created_at') + ->label('CREATED AT'), + ExportColumn::make('created_by') + ->label('CREATED BY'), + ExportColumn::make('updated_at') + ->label('UPDATED AT'), + ExportColumn::make('updated_by') + ->label('UPDATED BY'), + ExportColumn::make('deleted_at') + ->enabledByDefault(false) + ->label('DELETED AT'), + ]; + } + + public static function getCompletedNotificationBody(Export $export): string + { + $body = 'Your temp stop characteristic export has completed and '.number_format($export->successful_rows).' '.str('row')->plural($export->successful_rows).' exported.'; + + if ($failedRowsCount = $export->getFailedRowsCount()) { + $body .= ' '.number_format($failedRowsCount).' '.str('row')->plural($failedRowsCount).' failed to export.'; + } + + return $body; + } +} diff --git a/app/Filament/Imports/TempStopCharacteristicImporter.php b/app/Filament/Imports/TempStopCharacteristicImporter.php new file mode 100644 index 0000000..41482bd --- /dev/null +++ b/app/Filament/Imports/TempStopCharacteristicImporter.php @@ -0,0 +1,111 @@ +requiredMapping() + ->label('PLANT CODE') + ->exampleHeader('PLANT CODE') + ->example('1000') + ->relationship(resolveUsing: 'code') + ->rules(['required']), + ImportColumn::make('machine') + ->requiredMapping() + ->label('WORK CENTER') + ->exampleHeader('WORK CENTER') + ->example('RMGLAS01') + ->relationship(resolveUsing: 'work_center') + ->rules(['required']), + ImportColumn::make('machine_name') + ->label('MACHINE NAME') + ->exampleHeader('MACHINE NAME') + ->example('RMGLAS01') + ->rules(['required']), + ImportColumn::make('item') + ->requiredMapping() + ->exampleHeader('ITEM CODE') + ->example('630214') + ->label('ITEM CODE') + ->relationship(resolveUsing: 'code') + ->rules(['required']), + ImportColumn::make('aufnr') + ->label('JOB NUMBER') + ->exampleHeader('JOB NUMBER') + ->example('1234567'), + ImportColumn::make('gernr') + ->label('SERIAL NUMBER') + ->exampleHeader('SERIAL NUMBER') + ->example('1234567890123'), + ImportColumn::make('zmm_heading') + ->exampleHeader('ZMM HEADING') + ->example('ZMM001') + ->label('ZMM HEADING'), + ImportColumn::make('model_type') + ->label('MODEL TYPE') + ->exampleHeader('MODEL TYPE') + ->example('PUMP'), + ImportColumn::make('characteristic_field') + ->label('MASTER CHARACTERISTIC FIELD') + ->exampleHeader('MASTER CHARACTERISTIC FIELD') + ->example('NIL'), + ImportColumn::make('samlight_logged_name') + ->label('SAMLIGHT LOGGED NAME') + ->exampleHeader('SAMLIGHT LOGGED NAME') + ->example('User'), + ImportColumn::make('stopped_at') + ->label('STOPPED AT') + ->exampleHeader('STOPPED AT') + ->example('01-09-2026 12:00:00') + ->rules(['datetime']), + ImportColumn::make('stopped_by') + ->label('STOPPED BY') + ->exampleHeader('STOPPED BY') + ->example('RAW01234'), + ImportColumn::make('has_stop_flow_id') + ->label('HAS STOP FLOW ID') + ->exampleHeader('HAS STOP FLOW ID') + ->example('2'), + ImportColumn::make('created_by') + ->label('CREATED BY') + ->exampleHeader('CREATED BY') + ->example('RAW01234'), + ImportColumn::make('updated_by') + ->label('UPDATED BY') + ->exampleHeader('UPDATED BY') + ->example('RAW01234'), + ]; + } + + public function resolveRecord(): ?TempStopCharacteristic + { + // return TempStopCharacteristic::firstOrNew([ + // // Update existing records, matching them by `$this->data['column_name']` + // 'email' => $this->data['email'], + // ]); + + return new TempStopCharacteristic; + } + + public static function getCompletedNotificationBody(Import $import): string + { + $body = 'Your temp stop characteristic import has completed and '.number_format($import->successful_rows).' '.str('row')->plural($import->successful_rows).' imported.'; + + if ($failedRowsCount = $import->getFailedRowsCount()) { + $body .= ' '.number_format($failedRowsCount).' '.str('row')->plural($failedRowsCount).' failed to import.'; + } + + return $body; + } +} diff --git a/app/Filament/Resources/TempStopCharacteristicResource.php b/app/Filament/Resources/TempStopCharacteristicResource.php new file mode 100644 index 0000000..501b2d0 --- /dev/null +++ b/app/Filament/Resources/TempStopCharacteristicResource.php @@ -0,0 +1,793 @@ +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(); + }) + ->required() + ->default(function () { + $userHas = Filament::auth()->user()->plant_id; + + return ($userHas && strlen($userHas) > 0) ? null : optional(TempStopCharacteristic::latest()->first())->plant_id ?? null; + }) + ->afterStateUpdated(function ($state, callable $set, callable $get) { + $set('item_id', null); + $set('aufnr', null); + $set('gernr', null); + $set('machine_id', null); + $set('machine_name', null); + $set('has_stop_flow_id', '2'); + $set('updated_by', Filament::auth()->user()?->name); + }) + ->disabled(fn (Get $get) => ! empty($get('id'))), + Forms\Components\Select::make('item_id') + ->label('Item Code') + // ->relationship('item', 'id') + ->reactive() + ->required() + ->searchable() + ->options(function (callable $get) { + $plantId = $get('plant_id'); + if (! $plantId) { + return []; + } + + return Item::where('plant_id', $plantId)->pluck('code', 'id'); + }) + ->afterStateUpdated(function ($state, callable $set, callable $get) { + $set('aufnr', null); + $set('gernr', null); + $set('has_stop_flow_id', '2'); + $set('updated_by', Filament::auth()->user()?->name); + }) + ->default(function () { + $userHas = Filament::auth()->user()->plant_id; + + return ($userHas && strlen($userHas) > 0) ? null : optional(TempStopCharacteristic::latest()->first())->item_id ?? null; + }) + ->disabled(fn (Get $get) => ! empty($get('id'))), + Forms\Components\Select::make('machine_id') + ->label('Work Center') + // ->relationship('machine', 'name') + ->reactive() + ->searchable() + ->options(function (callable $get) { + $plantId = $get('plant_id'); + if (! $plantId) { + return []; + } + + return Machine::where('plant_id', $plantId)->pluck('work_center', 'id'); + }) + ->required() + ->default(function () { + $userHas = Filament::auth()->user()->plant_id; + + return ($userHas && strlen($userHas) > 0) ? null : optional(TempStopCharacteristic::latest()->first())->machine_id ?? null; + }) + ->afterStateUpdated(function ($state, callable $set, callable $get) { + $set('machine_name', null); + $set('has_stop_flow_id', '2'); + $set('updated_by', Filament::auth()->user()?->name); + }) + ->disabled(fn (Get $get) => ! empty($get('id'))), + Forms\Components\TextInput::make('machine_name') + ->label('Machine Name') + ->reactive() + ->nullable() + ->afterStateUpdated(function ($state, callable $set, callable $get) { + $set('has_stop_flow_id', '2'); + $set('updated_by', Filament::auth()->user()?->name); + }) + ->required() + ->disabled(fn (Get $get) => ! empty($get('id'))), + Forms\Components\TextInput::make('aufnr') + ->label('Job Number') + ->reactive() + ->numeric() + ->minlength(7) + ->maxlength(10) + ->required(function (callable $get) { + $item = $get('item_id'); + if ($item) { + return true; + } + + return false; + }) + ->afterStateUpdated(function ($state, callable $set, callable $get) { + $set('gernr', null); + $set('updated_by', Filament::auth()->user()?->name); + }) + ->default(function () { + $userHas = Filament::auth()->user()->plant_id; + + return ($userHas && strlen($userHas) > 0) ? null : optional(TempStopCharacteristic::latest()->first())->aufnr ?? null; + }) + ->readOnly(fn ($get) => ($get('item_id') == null)) + ->disabled(fn (Get $get) => ! empty($get('id'))), + Forms\Components\TextInput::make('gernr') + ->label('Serial Number') + ->reactive() + ->minLength(13) + ->readOnly(fn (callable $get) => ! $get('aufnr')) + ->afterStateUpdated(function ($state, callable $set, callable $get) { + $set('updated_by', Filament::auth()->user()?->name); + }) + ->required() + ->disabled(fn (Get $get) => ! empty($get('id'))), + Forms\Components\TextInput::make('zmm_heading') + ->label('Zmm Heading') + ->reactive() + ->nullable() + ->afterStateUpdated(function ($state, callable $set, callable $get) { + $set('updated_by', Filament::auth()->user()?->name); + }) + ->required() + ->disabled(fn (Get $get) => ! empty($get('id'))), + Forms\Components\Select::make('model_type') + ->label('Model Type') + ->reactive() + ->nullable() + ->searchable() + ->required() + ->options(function () { + return [ + 'MOTOR' => 'MOTOR', + 'PUMP' => 'PUMP', + 'NAME_PLATE' => 'NAME_PLATE', + 'UNKNOWN' => 'UNKNOWN', + ]; + }) + ->afterStateUpdated(function ($state, callable $set, callable $get) { + $set('updated_by', Filament::auth()->user()?->name); + }) + ->default('MOTOR') + ->disabled(fn (Get $get) => ! empty($get('id'))), + Forms\Components\TextInput::make('characteristic_field') + ->label('Master Characteristic Field') + ->reactive() + ->nullable() + ->afterStateUpdated(function ($state, callable $set, callable $get) { + $set('updated_by', Filament::auth()->user()?->name); + }) + ->required() + ->disabled(fn (Get $get) => ! empty($get('id'))), + Forms\Components\TextInput::make('samlight_logged_name') + ->label('SAMLight Logged Name') + ->reactive() + ->nullable() + ->afterStateUpdated(function ($state, callable $set, callable $get) { + $set('updated_by', Filament::auth()->user()?->name); + }) + ->disabled(fn (Get $get) => ! empty($get('id'))), + Forms\Components\DateTimePicker::make('stopped_at') + ->label('Stopped At') + ->default(now()) + ->reactive() + ->afterStateUpdated(function ($state, callable $set, callable $get) { + $set('updated_by', Filament::auth()->user()?->name); + }) + ->required(), + Forms\Components\TextInput::make('stopped_by') + ->label('Stopped By') + ->reactive() + ->default(Filament::auth()->user()?->name) + ->afterStateUpdated(function ($state, callable $set, callable $get) { + $set('updated_by', Filament::auth()->user()?->name); + }) + ->required(), + Forms\Components\TextInput::make('has_stop_flow_id') + ->label('Has Stop Flow ID') + ->reactive() + ->default('2') + ->afterStateUpdated(function ($state, callable $set, callable $get) { + $curId = $get('id'); + if (! $curId) { + $set('has_stop_flow_id', '2'); + } + $set('updated_by', Filament::auth()->user()?->name); + }) + ->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(['default' => 1, 'sm' => 2]), + ]); + } + + public static function table(Table $table): Table + { + return $table + ->columns([ + Tables\Columns\TextColumn::make('No.') + ->label('No.') + ->getStateUsing(function ($record, $livewire, $column, $rowLoop) { + $paginator = $livewire->getTableRecords(); + $perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10; + $currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1; + + return ($currentPage - 1) * $perPage + $rowLoop->iteration; + }), + Tables\Columns\TextColumn::make('plant.name') + ->label('Plant Name') + ->alignCenter() + ->searchable() + ->sortable(), + Tables\Columns\TextColumn::make('machine.work_center') + ->label('Work Center') + ->alignCenter() + ->searchable() + ->sortable(), + Tables\Columns\TextColumn::make('machine_name') + ->label('Machine Name') + ->alignCenter() + ->searchable() + ->sortable(), + Tables\Columns\TextColumn::make('item.code') + ->label('Item Code') + ->alignCenter() + ->searchable() + ->sortable(), + Tables\Columns\TextColumn::make('aufnr') + ->label('Job Number') + ->alignCenter() + ->searchable() + ->sortable(), + Tables\Columns\TextColumn::make('gernr') + ->label('Serial Number') + ->alignCenter() + ->searchable() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_heading') + ->label('Zmm Heading') + ->alignCenter() + ->searchable() + ->sortable(), + Tables\Columns\TextColumn::make('model_type') + ->label('Model Type') + ->alignCenter() + ->searchable() + ->sortable(), + Tables\Columns\TextColumn::make('characteristic_field') + ->label('Master Characteristic Field') + ->alignCenter() + ->searchable() + ->formatStateUsing(fn (string $state): string => strtoupper(__($state))) + ->extraAttributes(['class' => 'uppercase']) + ->sortable(), + Tables\Columns\TextColumn::make('samlight_logged_name') + ->label('SAMLIGHT LOGGED NAME') + ->alignCenter() + ->searchable() + ->sortable(), + Tables\Columns\TextColumn::make('stopped_at') + ->label('Stopped At') + ->dateTime() + ->alignCenter() + ->searchable() + ->sortable(), + Tables\Columns\TextColumn::make('stopped_by') + ->label('Stopped By') + ->alignCenter() + ->searchable() + ->sortable(), + Tables\Columns\TextColumn::make('has_stop_flow_id') + ->label('Has Stop Flow ID') + ->alignCenter() + ->searchable() + ->sortable(), + Tables\Columns\TextColumn::make('created_at') + ->label('Created At') + ->dateTime() + ->alignCenter() + ->searchable() + ->sortable(), + Tables\Columns\TextColumn::make('created_by') + ->label('Created By') + ->alignCenter() + ->searchable() + ->sortable(), + Tables\Columns\TextColumn::make('updated_at') + ->label('Updated At') + ->dateTime() + ->alignCenter() + ->searchable() + ->sortable() + ->toggleable(isToggledHiddenByDefault: true), + Tables\Columns\TextColumn::make('updated_by') + ->label('Updated By') + ->alignCenter() + ->searchable() + ->sortable() + ->toggleable(isToggledHiddenByDefault: true), + Tables\Columns\TextColumn::make('deleted_at') + ->label('Deleted At') + ->dateTime() + ->alignCenter() + ->searchable() + ->sortable() + ->toggleable(isToggledHiddenByDefault: true), + ]) + ->searchPlaceholder('Search Job / Serial Number') + ->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('tempStopCharacteristics', 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); + // $set('aufnr', 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('tempStopCharacteristics', function ($query) use ($plantId) { + if ($plantId) { + $query->where('plant_id', $plantId); + } + })->pluck('work_center', 'id'); + }) + ->afterStateUpdated(function ($state, callable $set, callable $get): void { + // $set('item_id', null); + // $set('aufnr', null); + }), + TextInput::make('machine_name') + ->label('Machine Name') + ->placeholder('Enter Machine Name'), + 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('tempStopCharacteristics', function ($query) use ($plantId) { + if ($plantId) { + $query->where('plant_id', $plantId); + } + })->pluck('code', 'id'); + }) + ->afterStateUpdated(function ($state, callable $set, callable $get): void { + // $set('aufnr', null); + }), + TextInput::make('aufnr') + ->label('Job Number') + ->placeholder('Enter Job Number') + ->numeric() + ->maxlength(10), + TextInput::make('gernr') + ->label('Serial Number') + ->placeholder('Enter Serial Number') + ->numeric(), + TextInput::make('zmm_heading') + ->label('Zmm Heading') + ->placeholder('Enter Zmm Heading'), + Select::make('model_type') + ->label('Search by Model Type') + ->nullable() + ->searchable() + ->reactive() + ->options(function (callable $get) { + $userHas = Filament::auth()->user()->plant_id; + $plantId = $get('Plant'); + + if ($userHas && strlen($userHas) > 0) { + return TempStopCharacteristic::where('plant_id', $userHas)->pluck('model_type', 'model_type')->toArray(); + } elseif ($plantId) { + return TempStopCharacteristic::where('plant_id', $plantId)->select('model_type')->distinct()->pluck('model_type', 'model_type'); + } else { + return TempStopCharacteristic::select('model_type')->distinct()->pluck('model_type', 'model_type'); + } + }), + TextInput::make('characteristic_field') + ->label('Master Characteristic Field') + ->placeholder('Enter Master Characteristic Field'), + TextInput::make('samlight_logged_name') + ->label('Samlight Logged Name') + ->placeholder('Enter Samlight Logged Name'), + Select::make('stopped_by') + ->label('Search by Stopped By') + ->nullable() + ->options(function (callable $get) { + $plantId = $get('Plant'); + if (! $plantId) { + return TempStopCharacteristic::whereNotNull('stopped_by')->select('stopped_by')->distinct()->pluck('stopped_by', 'stopped_by'); + } else { + return TempStopCharacteristic::where('plant_id', $plantId)->whereNotNull('stopped_by')->select('stopped_by')->distinct()->pluck('stopped_by', 'stopped_by'); + } + }) + ->searchable() + ->reactive(), + DateTimePicker::make('stopped_from') + ->label('Stopped From') + ->placeholder('Select From DateTime') + ->reactive() + ->native(false), + DateTimePicker::make('stopped_to') + ->label('Stopped To') + ->placeholder('Select To DateTime') + ->reactive() + ->native(false), + Select::make('created_by') + ->label('Search by Created By') + ->nullable() + ->options(function (callable $get) { + $plantId = $get('Plant'); + if (! $plantId) { + return TempStopCharacteristic::whereNotNull('created_by')->select('created_by')->distinct()->pluck('created_by', 'created_by'); + } else { + return TempStopCharacteristic::where('plant_id', $plantId)->whereNotNull('created_by')->select('created_by')->distinct()->pluck('created_by', 'created_by'); + } + }) + ->searchable() + ->reactive(), + 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('updated_by') + ->label('Search by Updated By') + ->nullable() + ->options(function (callable $get) { + $plantId = $get('Plant'); + if (! $plantId) { + return TempStopCharacteristic::whereNotNull('updated_by')->select('updated_by')->distinct()->pluck('updated_by', 'updated_by'); + } else { + return TempStopCharacteristic::where('plant_id', $plantId)->whereNotNull('updated_by')->select('updated_by')->distinct()->pluck('updated_by', 'updated_by'); + } + }) + ->searchable() + ->reactive(), + DateTimePicker::make(name: 'updated_from') + ->label('Updated From') + ->placeholder(placeholder: 'Select From DateTime') + ->reactive() + ->native(false), + DateTimePicker::make('updated_to') + ->label('Updated To') + ->placeholder(placeholder: 'Select To DateTime') + ->reactive() + ->native(false), + TextInput::make('has_stop_flow_id') + ->label('Has Stop Flow ID') + ->placeholder('Enter Has Stop Flow ID'), + ]) + ->query(function ($query, array $data) { + // Hide all records initially if no filters are applied + if (empty($data['Plant']) && empty($data['machine']) && empty($data['machine_name']) && empty($data['item_id']) && empty($data['aufnr']) && empty($data['gernr']) && empty($data['zmm_heading']) && empty($data['model_type']) && empty($data['characteristic_field']) && empty($data['samlight_logged_name']) && empty($data['stopped_by']) && empty($data['stopped_from']) && empty($data['stopped_to']) && empty($data['created_by']) && empty($data['created_from']) && empty($data['created_to']) && empty($data['updated_by']) && empty($data['updated_from']) && empty($data['updated_to']) && empty($data['has_stop_flow_id'])) { + 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['machine_name'])) { + $query->where('machine_name', 'like', '%'.$data['machine_name'].'%'); + } + + 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['model_type'])) { + $query->where('model_type', $data['model_type']); + } + + if (! empty($data['characteristic_field'])) { + $query->where('characteristic_field', 'like', '%'.$data['characteristic_field'].'%'); + } + + if (! empty($data['samlight_logged_name'])) { + $query->where('samlight_logged_name', 'like', '%'.$data['samlight_logged_name'].'%'); + } + + if (! empty($data['stopped_by'])) { + $query->where('stopped_by', $data['stopped_by']); + } + + if (! empty($data['stopped_from'])) { + $query->where('stopped_at', '>=', $data['stopped_from']); + } + + if (! empty($data['stopped_to'])) { + $query->where('stopped_at', '<=', $data['stopped_to']); + } + + if (! empty($data['created_by'])) { + $query->where('created_by', $data['created_by']); + } + + 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['updated_by'])) { + $query->where('updated_by', $data['updated_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['has_stop_flow_id'])) { + $query->where('has_stop_flow_id', 'like', '%'.$data['has_stop_flow_id'].'%'); + } + + }) + ->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['machine_name'])) { + $indicators[] = 'Machine Name: '.$data['machine_name']; + } + + 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 No: '.$data['gernr']; + } + + if (! empty($data['zmm_heading'])) { + $indicators[] = 'Zmm Heading: '.$data['zmm_heading']; + } + + if (! empty($data['model_type'])) { + $indicators[] = 'Model Type: '.$data['model_type']; + } + + if (! empty($data['characteristic_field'])) { + $indicators[] = 'Master Characteristic Field: '.$data['characteristic_field']; + } + + if (! empty($data['work_flow_id'])) { + $indicators[] = 'Work Flow ID: '.$data['work_flow_id']; + } + + if (! empty($data['samlight_logged_name'])) { + $indicators[] = 'Samlight Logged Name: '.$data['samlight_logged_name']; + } + + if (! empty($data['stopped_by'])) { + $indicators[] = 'Stopped By: '.$data['stopped_by']; + } + + if (! empty($data['stopped_from'])) { + $indicators[] = 'Stopped From: '.$data['stopped_from']; + } + + if (! empty($data['stopped_to'])) { + $indicators[] = 'Stopped To: '.$data['stopped_to']; + } + + if (! empty($data['created_by'])) { + $indicators[] = 'Created By: '.$data['created_by']; + } + + 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['updated_by'])) { + $indicators[] = 'Updated By: '.$data['updated_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['has_stop_flow_id'])) { + $indicators[] = 'Stop Flow ID: '.$data['has_stop_flow_id']; + } + + 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([ + ImportAction::make() + ->label('Import Temp Stop Characteristics') + ->color('warning') + ->importer(TempStopCharacteristicImporter::class) + ->visible(function () { + return Filament::auth()->user()->can('view import temp stop characteristics'); + }), + ExportAction::make() + ->label('Export Temp Stop Characteristics') + ->color('warning') + ->exporter(TempStopCharacteristicExporter::class) + ->visible(function () { + return Filament::auth()->user()->can('view export temp stop characteristics'); + }), + ]); + } + + public static function getRelations(): array + { + return [ + // + ]; + } + + public static function getPages(): array + { + return [ + 'index' => Pages\ListTempStopCharacteristics::route('/'), + 'create' => Pages\CreateTempStopCharacteristic::route('/create'), + 'view' => Pages\ViewTempStopCharacteristic::route('/{record}'), + 'edit' => Pages\EditTempStopCharacteristic::route('/{record}/edit'), + ]; + } + + public static function getEloquentQuery(): Builder + { + return parent::getEloquentQuery() + ->withoutGlobalScopes([ + SoftDeletingScope::class, + ]); + } +} diff --git a/app/Filament/Resources/TempStopCharacteristicResource/Pages/CreateTempStopCharacteristic.php b/app/Filament/Resources/TempStopCharacteristicResource/Pages/CreateTempStopCharacteristic.php new file mode 100644 index 0000000..03cf09d --- /dev/null +++ b/app/Filament/Resources/TempStopCharacteristicResource/Pages/CreateTempStopCharacteristic.php @@ -0,0 +1,12 @@ + Date: Mon, 14 Sep 2026 12:48:48 +0530 Subject: [PATCH 06/18] Added migration, model, resource, importer, and exporter files for add stop_flow_id columns and remove stopped columns --- .../Exports/ClassCharacteristicExporter.php | 53 ++++- .../Imports/ClassCharacteristicImporter.php | 24 +-- .../Resources/ClassCharacteristicResource.php | 201 ++++++++++++++---- app/Models/ClassCharacteristic.php | 8 +- ...lumns_from_class_characteristics_table.php | 67 ++++++ 5 files changed, 282 insertions(+), 71 deletions(-) create mode 100644 database/migrations/2026_09_09_180717_add_stop_flow_id_columns_and_remove_stopped_columns_from_class_characteristics_table.php diff --git a/app/Filament/Exports/ClassCharacteristicExporter.php b/app/Filament/Exports/ClassCharacteristicExporter.php index 77645be..e45105e 100644 --- a/app/Filament/Exports/ClassCharacteristicExporter.php +++ b/app/Filament/Exports/ClassCharacteristicExporter.php @@ -311,13 +311,13 @@ class ClassCharacteristicExporter extends Exporter ->label('ZMM OPERATING TEMPERATURE'), ExportColumn::make('zmm_axial_force') ->label('ZMM AXIAL FORCE'), - ExportColumn::make('is_stopped') - ->label('IS STOPPED') - ->formatStateUsing(fn ($state) => ($state == '0') ? 'No' : ($state == '1' ? 'Yes' : 'Yes (Alert Pending)')), - ExportColumn::make('stopped_datetime') - ->label('STOPPED DATETIME'), - ExportColumn::make('stopped_by') - ->label('STOPPED BY'), + // ExportColumn::make('is_stopped') + // ->label('IS STOPPED') + // ->formatStateUsing(fn ($state) => ($state == '0') ? 'No' : ($state == '1' ? 'Yes' : 'Yes (Alert Pending)')), + // ExportColumn::make('stopped_datetime') + // ->label('STOPPED DATETIME'), + // ExportColumn::make('stopped_by') + // ->label('STOPPED BY'), ExportColumn::make('mark_status') ->label('MARKED STATUS'), ExportColumn::make('marked_physical_count') @@ -363,7 +363,14 @@ class ClassCharacteristicExporter extends Exporter ExportColumn::make('name_plate_marked_by') ->label('NAME PLATE MARKED BY'), ExportColumn::make('motor_pump_pumpset_status') - ->label('MOTOR PUMP PUMPSET STATUS'), + ->label('MOTOR PUMP PUMPSET STATUS') + ->formatStateUsing(fn ($state): string => match ((string) $state) { + '1' => 'Motor', + '2' => 'Pump', + '3' => 'PumpSet', + '4' => 'Name Plate', + default => 'NIL', + }), ExportColumn::make('winded_serial_number') ->label('WINDED SERIAL NUMBER'), ExportColumn::make('winded_rework_status') @@ -386,6 +393,36 @@ class ClassCharacteristicExporter extends Exporter ->label('PENDING RELEASED STATUS'), ExportColumn::make('has_work_flow_id') ->label('HAS WORK FLOW ID'), + ExportColumn::make('motor_stop_flow_id') + ->label('MOTOR STOP FLOW ID') + ->formatStateUsing(fn ($state): string => match ((string) $state) { + '5' => 'NIL', + '4' => 'Has Master', + '3' => 'Make Alert', + '2' => 'Alert Pending', + '1' => 'Alert Approved', + default => '-', + }), + ExportColumn::make('pump_stop_flow_id') + ->label('PUMP STOP FLOW ID') + ->formatStateUsing(fn ($state): string => match ((string) $state) { + '5' => 'NIL', + '4' => 'Has Master', + '3' => 'Make Alert', + '2' => 'Alert Pending', + '1' => 'Alert Approved', + default => '-', + }), + ExportColumn::make('name_plate_stop_flow_id') + ->label('NAME PLATE STOP FLOW ID') + ->formatStateUsing(fn ($state): string => match ((string) $state) { + '5' => 'NIL', + '4' => 'Has Master', + '3' => 'Make Alert', + '2' => 'Alert Pending', + '1' => 'Alert Approved', + default => '-', + }), ExportColumn::make('created_at') ->label('CREATED AT'), ExportColumn::make('created_by') diff --git a/app/Filament/Imports/ClassCharacteristicImporter.php b/app/Filament/Imports/ClassCharacteristicImporter.php index d42b1fd..e62289c 100644 --- a/app/Filament/Imports/ClassCharacteristicImporter.php +++ b/app/Filament/Imports/ClassCharacteristicImporter.php @@ -583,18 +583,6 @@ class ClassCharacteristicImporter extends Importer ->label('ZMM AXIAL FORCE') ->exampleHeader('ZMM AXIAL FORCE') ->example(''), - ImportColumn::make('is_stopped') - ->label('IS STOPPED') - ->exampleHeader('IS STOPPED') - ->example('0'), - ImportColumn::make('stopped_datetime') - ->label('STOPPED DATETIME') - ->exampleHeader('STOPPED DATETIME') - ->example('01-01-2026 00:08:00'), - ImportColumn::make('stopped_by') - ->label('STOPPED BY') - ->exampleHeader('STOPPED BY') - ->example(''), ImportColumn::make('mark_status') ->label('MARKED STATUS') ->exampleHeader('MARKED STATUS') @@ -731,6 +719,18 @@ class ClassCharacteristicImporter extends Importer ->label('HAS WORK FLOW ID') ->exampleHeader('HAS WORK FLOW ID') ->example('0'), + ImportColumn::make('motor_stop_flow_id') + ->label('MOTOR STOP FLOW ID') + ->exampleHeader('MOTOR STOP FLOW ID') + ->example('5'), + ImportColumn::make('pump_stop_flow_id') + ->label('PUMP STOP FLOW ID') + ->exampleHeader('PUMP STOP FLOW ID') + ->example('5'), + ImportColumn::make('name_plate_stop_flow_id') + ->label('NAME PLATE STOP FLOW ID') + ->exampleHeader('NAME PLATE STOP FLOW ID') + ->example('5'), ImportColumn::make('created_at') ->label('CREATED AT') ->exampleHeader('CREATED AT') diff --git a/app/Filament/Resources/ClassCharacteristicResource.php b/app/Filament/Resources/ClassCharacteristicResource.php index c8ebbc2..16ed4e4 100644 --- a/app/Filament/Resources/ClassCharacteristicResource.php +++ b/app/Filament/Resources/ClassCharacteristicResource.php @@ -875,7 +875,7 @@ class ClassCharacteristicResource extends Resource $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_performance_factor') - ->label('ZMM PERFORMANCE_FACTOR') + ->label('ZMM PERFORMANCE FACTOR') ->reactive() ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); @@ -982,45 +982,37 @@ class ClassCharacteristicResource extends Resource ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), - Forms\Components\Select::make('is_stopped') - ->label('IS STOPPED') - // ->nullable() - ->selectablePlaceholder(false) - ->options(function () { - return [ - '0' => 'No', - '1' => 'Yes', - '2' => 'Yes (Alert Pending)', - ]; - }) - ->default('0') - ->reactive() - ->afterStateUpdated(function (callable $set) { - $set('updated_by', Filament::auth()->user()?->name); - }) - ->required(), - Forms\Components\DateTimePicker::make('stopped_datetime') - ->label('STOPPED DATETIME') - ->reactive() - ->placeholder('Select Stopped DateTime') - ->afterStateUpdated(function (callable $set) { - $set('updated_by', Filament::auth()->user()?->name); - }), - Forms\Components\TextInput::make('stopped_by') - ->label('STOPPED BY') - ->reactive() - ->readOnly(fn (callable $get) => ! $get('id')) - ->afterStateUpdated(function (callable $set) { - $set('updated_by', Filament::auth()->user()?->name); - }), - // Forms\Components\TextInput::make('is_stopped') + // 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); // }) - // ->default(0) // ->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() @@ -1318,6 +1310,74 @@ class ClassCharacteristicResource extends Resource }) ->default(0) ->required(), + 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\Hidden::make('created_by') ->label('Created By') ->default(Filament::auth()->user()?->name), @@ -1931,19 +1991,19 @@ class ClassCharacteristicResource extends Resource ->label('ZMM AXIAL FORCE') ->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('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() @@ -2035,6 +2095,13 @@ class ClassCharacteristicResource extends Resource 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') @@ -2080,6 +2147,46 @@ class ClassCharacteristicResource extends Resource ->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() diff --git a/app/Models/ClassCharacteristic.php b/app/Models/ClassCharacteristic.php index 2dd2ebb..00f9ea4 100644 --- a/app/Models/ClassCharacteristic.php +++ b/app/Models/ClassCharacteristic.php @@ -154,9 +154,6 @@ class ClassCharacteristic extends Model 'zqmm_qty', 'zmm_operating_temperature', 'zmm_axial_force', - 'is_stopped', - 'stopped_datetime', - 'stopped_by', 'mark_status', 'marked_physical_count', 'marked_expected_time', @@ -181,6 +178,7 @@ class ClassCharacteristic extends Model 'name_plate_marked_by', 'motor_pump_pumpset_status', 'winded_serial_number', + 'winded_rework_status', 'motor_machine_name', 'pump_machine_name', 'name_plate_machine_name', @@ -189,7 +187,9 @@ class ClassCharacteristic extends Model 'samlight_logged_name', 'pending_released_status', 'has_work_flow_id', - 'winded_rework_status', + 'motor_stop_flow_id', + 'pump_stop_flow_id', + 'name_plate_stop_flow_id', 'created_at', 'updated_at', 'created_by', diff --git a/database/migrations/2026_09_09_180717_add_stop_flow_id_columns_and_remove_stopped_columns_from_class_characteristics_table.php b/database/migrations/2026_09_09_180717_add_stop_flow_id_columns_and_remove_stopped_columns_from_class_characteristics_table.php new file mode 100644 index 0000000..7fc11e7 --- /dev/null +++ b/database/migrations/2026_09_09_180717_add_stop_flow_id_columns_and_remove_stopped_columns_from_class_characteristics_table.php @@ -0,0 +1,67 @@ + Date: Mon, 14 Sep 2026 12:56:04 +0530 Subject: [PATCH 07/18] Updated default values and approver statuses on request characteristic resource file --- .../RequestCharacteristicResource.php | 123 +++++++++++------- 1 file changed, 78 insertions(+), 45 deletions(-) diff --git a/app/Filament/Resources/RequestCharacteristicResource.php b/app/Filament/Resources/RequestCharacteristicResource.php index e8c5f63..4a3491d 100644 --- a/app/Filament/Resources/RequestCharacteristicResource.php +++ b/app/Filament/Resources/RequestCharacteristicResource.php @@ -246,11 +246,11 @@ class RequestCharacteristicResource extends Resource } $set('updated_by', Filament::auth()->user()?->name); }) - ->default(function () { - $userHas = Filament::auth()->user()->plant_id; + // ->default(function () { + // $userHas = Filament::auth()->user()->plant_id; - return ($userHas && strlen($userHas) > 0) ? null : optional(RequestCharacteristic::latest()->first())->aufnr ?? null; - }) + // return ($userHas && strlen($userHas) > 0) ? null : optional(RequestCharacteristic::latest()->first())->aufnr ?? null; + // }) ->readOnly(fn ($get) => ($get('item_id') == null)) ->disabled(fn (Get $get) => ! empty($get('id'))), Forms\Components\TextInput::make('gernr') @@ -311,19 +311,24 @@ class RequestCharacteristicResource extends Resource $set('update_value', null); $set('updated_by', Filament::auth()->user()?->name); }) - ->default(function () { - $machineName = ''; - $reqId = RequestCharacteristic::latest()->first()?->characteristic_approver_master_id; - if ($reqId) { - $reqMac = CharacteristicApproverMaster::where('id', $reqId)->first()?->machine_name; - $machineName = $reqMac ?? null; - } else { - $machineName = null; - } + // ->default(function () { + // $machineName = ''; + // $reqId = RequestCharacteristic::latest()->first()?->characteristic_approver_master_id; + // if ($reqId) { + // $reqMac = CharacteristicApproverMaster::where('id', $reqId)->first()?->machine_name; + // $machineName = $reqMac ?? null; + // } else { + // $machineName = null; + // } + // $userHas = Filament::auth()->user()->plant_id; + + // return ($userHas && strlen($userHas) > 0) ? null : $machineName ?? null; + // }) + ->default(function () { $userHas = Filament::auth()->user()->plant_id; - return ($userHas && strlen($userHas) > 0) ? null : $machineName ?? null; + return ($userHas && strlen($userHas) > 0) ? null : optional(RequestCharacteristic::latest()->first())->characteristicApproverMaster->machine_name ?? null; }) ->afterStateHydrated(function ($component, $state, Get $get, Set $set) { if ($get('id')) { @@ -377,21 +382,15 @@ class RequestCharacteristicResource extends Resource } $set('updated_by', Filament::auth()->user()?->name); }) + // ->default(function () { + // $userHas = Filament::auth()->user()->plant_id; + + // return ($userHas && strlen($userHas) > 0) ? null : 'Characteristic'; + // }) ->default(function () { $userHas = Filament::auth()->user()->plant_id; - return ($userHas && strlen($userHas) > 0) ? null : 'Characteristic'; - // $approverType = null; - // $reqId = RequestCharacteristic::latest()->first()?->characteristic_approver_master_id; - // if ($reqId) { - // $reqTyp = CharacteristicApproverMaster::where('id', $reqId)->first()?->approver_type; - // $approverType = $reqTyp ?? null; - // } else { - // $approverType = null; - // } - - // // return optional(CharacteristicApproverMaster::latest()->first())->approver_type ?? null; - // return $approverType ?? null; + return ($userHas && strlen($userHas) > 0) ? null : optional(RequestCharacteristic::latest()->first())->characteristicApproverMaster->approver_type ?? null; }) ->afterStateHydrated(function ($component, $state, Get $get, Set $set) { if ($get('id')) { @@ -457,7 +456,11 @@ class RequestCharacteristicResource extends Resource $set('update_value', null); $set('updated_by', Filament::auth()->user()?->name); }) - ->default('MOTOR') + ->default(function () { + $userHas = Filament::auth()->user()->plant_id; + + return ($userHas && strlen($userHas) > 0) ? null : optional(RequestCharacteristic::latest()->first())->model_type ?? null; + }) ->disabled(fn (Get $get) => ! empty($get('id'))), Section::make('Request Characteristic Details') // ->columnSpan(['default' => 2, 'sm' => 4]) @@ -577,11 +580,21 @@ class RequestCharacteristicResource extends Resource ->label('Approver Status') ->reactive() // ->live() - ->options([ - 'Approved' => 'Approved', - 'Hold' => 'Hold', - 'Rejected' => 'Rejected', - ]) + ->options(function (callable $set, callable $get) { + $apprTyp = $get('approver_type'); + + if ($apprTyp && $apprTyp == 'Stop') { + return [ + 'Approved' => 'Approved', + ]; + } + + return [ + 'Approved' => 'Approved', + 'Hold' => 'Hold', + 'Rejected' => 'Rejected', + ]; + }) ->afterStateUpdated(function ($state, callable $set, callable $get) { if ($state) {// && empty($get('approved1_at')) $set('approved1_at', now()->toDateTimeString()); // now()->format('d-m-Y H:i:s') @@ -618,7 +631,7 @@ class RequestCharacteristicResource extends Resource }), Forms\Components\TextInput::make('approver_remark1') ->label('Approver Remark') - ->live() + ->reactive() ->maxLength(60) ->afterStateUpdated(function ($state, callable $set, callable $get) { $appStat = $get('approver_status1'); @@ -693,11 +706,21 @@ class RequestCharacteristicResource extends Resource Forms\Components\Select::make('approver_status2') ->label('Approver Status') ->reactive() - ->options([ - 'Approved' => 'Approved', - 'Hold' => 'Hold', - 'Rejected' => 'Rejected', - ]) + ->options(function (callable $set, callable $get) { + $apprTyp = $get('approver_type'); + + if ($apprTyp && $apprTyp == 'Stop') { + return [ + 'Approved' => 'Approved', + ]; + } + + return [ + 'Approved' => 'Approved', + 'Hold' => 'Hold', + 'Rejected' => 'Rejected', + ]; + }) ->afterStateUpdated(function ($state, callable $set, callable $get) { if ($state) { $set('approved2_at', now()->toDateTimeString()); @@ -734,7 +757,7 @@ class RequestCharacteristicResource extends Resource }), Forms\Components\TextInput::make('approver_remark2') ->label('Approver Remark') - ->live() + ->reactive() ->maxLength(60) ->afterStateUpdated(function ($state, callable $set, callable $get) { $appStat = $get('approver_status2'); @@ -807,11 +830,21 @@ class RequestCharacteristicResource extends Resource Forms\Components\Select::make('approver_status3') ->label('Approver Status') ->reactive() - ->options([ - 'Approved' => 'Approved', - 'Hold' => 'Hold', - 'Rejected' => 'Rejected', - ]) + ->options(function (callable $set, callable $get) { + $apprTyp = $get('approver_type'); + + if ($apprTyp && $apprTyp == 'Stop') { + return [ + 'Approved' => 'Approved', + ]; + } + + return [ + 'Approved' => 'Approved', + 'Hold' => 'Hold', + 'Rejected' => 'Rejected', + ]; + }) ->afterStateUpdated(function ($state, callable $set, callable $get) { if ($state) { $set('approved3_at', now()->toDateTimeString()); @@ -847,7 +880,7 @@ class RequestCharacteristicResource extends Resource }), Forms\Components\TextInput::make('approver_remark3') ->label('Approver Remark') - ->live() + ->reactive() ->maxLength(60) ->afterStateUpdated(function ($state, callable $set, callable $get) { $appStat = $get('approver_status3'); -- 2.49.1 From 83c0ea83a55cdee205ea77f18b8a1417aade2b7d Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Mon, 14 Sep 2026 12:58:18 +0530 Subject: [PATCH 08/18] Added getRequestStopCharacteristics api --- routes/api.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/routes/api.php b/routes/api.php index f08df9c..122a14f 100644 --- a/routes/api.php +++ b/routes/api.php @@ -232,6 +232,10 @@ Route::post('laser/characteristics/change', [CharacteristicsController::class, ' Route::get('laser/characteristics/request', [CharacteristicsController::class, 'getLaserRequestChar']); +// ..Request Stop Characteristics Master - Status + +Route::get('laser/characteristics/get-status', [CharacteristicsController::class, 'getLaserRequestStop']); + Route::post('laser-doc-pdf', [PdfController::class, 'storeLaserPdf']); // ..Process Order -- 2.49.1 From 08ac010a9a3329bab736a47de15da038cf1e4f3f Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Mon, 14 Sep 2026 13:25:40 +0530 Subject: [PATCH 09/18] Updated characteristicsController for create or update record on ItemCharacteristics and removed stopped columns in ClassCharacteristic and getRequestStopCharacteristics details function updated and Added getLaserRequestStop function --- .../Controllers/CharacteristicsController.php | 1482 +++++++++++++---- 1 file changed, 1167 insertions(+), 315 deletions(-) diff --git a/app/Http/Controllers/CharacteristicsController.php b/app/Http/Controllers/CharacteristicsController.php index f0c4161..9f9e606 100644 --- a/app/Http/Controllers/CharacteristicsController.php +++ b/app/Http/Controllers/CharacteristicsController.php @@ -6,13 +6,16 @@ use App\Models\CharacteristicApproverMaster; use App\Models\CharacteristicValue; use App\Models\ClassCharacteristic; use App\Models\Item; +use App\Models\ItemCharacteristic; use App\Models\Line; use App\Models\Machine; use App\Models\Plant; use App\Models\ProductCharacteristicsMaster; +use App\Models\ProductionTemp; use App\Models\RequestCharacteristic; use App\Models\StickerMaster; use App\Models\TempClassCharacteristic; +use App\Models\TempStopCharacteristic; use App\Models\User; use App\Models\WindedSerialValidationError; use App\Models\WorkGroupMaster; @@ -257,6 +260,7 @@ class CharacteristicsController extends Controller } $userName = $request->header('user-name'); + $stopAlert = $request->header('alert'); if (! $userName || $userName == null || $userName == '') { return response()->json([ @@ -267,9 +271,12 @@ class CharacteristicsController extends Controller $userName = 'Admin'; } + $stopAlert = ($stopAlert == '1') ? true : false; + $data = $request->all(); $plantCode = $data['plant_code'] ?? ''; + $charField = $data['characteristic_field'] ?? ''; $workCenter = $data['work_center'] ?? ''; $jobNo = $data['aufnr'] ?? ''; $serialNumber = $data['gernr'] ?? ''; @@ -277,6 +284,7 @@ class CharacteristicsController extends Controller $modelType = $data['model_type'] ?? ''; $expectedTime = $data['expected_time'] ?? 0; $markedStatus = (Str::contains($data['marked_status'], 'marked', ignoreCase: true)) ? 'Marked' : 'Stopped'; + $requestType = ($markedStatus == 'Stopped') ? 'Stop' : ''; $characteristics = $data['characteristics']; if ($plantCode == null || $plantCode == '' || ! $plantCode) { @@ -330,6 +338,10 @@ class CharacteristicsController extends Controller ], 404); } + if ($charField == null || $charField == '' || $charField == 'nil') { + $charField = 'NIL'; + } + if ($expectedTime == null || $expectedTime == '' || $expectedTime == '0' || ! $expectedTime) { return response()->json([ 'status_code' => 'ERROR', @@ -743,6 +755,140 @@ class CharacteristicsController extends Controller $modelTyp = strtolower($modelType); $isAuto = false; + $machineName = null; + if ($stopAlert && $markedStatus == 'Stopped') { + foreach ($data['characteristics'] as $char) { + if ($modelType == 'MOTOR') { // empty($char['motor_machine_name']) + $machineName = $char['motor_machine_name']; + } elseif ($modelType == 'PUMP') { + $machineName = $char['pump_machine_name']; + } elseif ($modelType == 'NAME_PLATE') { + $machineName = $char['name_plate_machine_name']; + } + } + + $pCode = CharacteristicApproverMaster::where('plant_id', $plantId)->first(); + if (! $pCode) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Plant code '{$plantCode}' not found in approver master!", + ], 404); + } + + $wCenter = CharacteristicApproverMaster::where('machine_id', $machineId)->first(); + if (! $wCenter) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Work center '{$workCenter}' not found in approver master!", + ], 404); + } + + $wCenterAgaPlant = CharacteristicApproverMaster::where('machine_id', $machineId)->where('plant_id', $plantId)->first(); + if (! $wCenterAgaPlant) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Work center '{$workCenter}' not found for the plant code '{$plantCode}' in approver master!", + ], 404); + } + + $mName = CharacteristicApproverMaster::where('machine_name', $machineName)->first(); + if (! $mName) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Machine name '{$machineName}' not found in approver master!", + ], 404); + } + + $mNameAgaPlant = CharacteristicApproverMaster::where('machine_name', $machineName)->where('plant_id', $plantId)->first(); + if (! $mNameAgaPlant) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Machine name '{$machineName}' not found for the plant code '{$plantCode}' in approver master!", + ], 404); + } + + $cField = CharacteristicApproverMaster::where('characteristic_field', $charField)->first(); + if (! $cField) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Master characteristic field value '{$charField}' not found in approver master!", + ], 404); + } + + // Master characteristic field value 'NIL' not found in approver master! + $cFieldAgaPlant = CharacteristicApproverMaster::where('characteristic_field', $charField)->where('plant_id', $plantId)->first(); + if (! $cFieldAgaPlant) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Master characteristic field value '{$charField}' not found for the plant code '{$plantCode}' in approver master!", + ], 404); + } + + $mNameAndWorkCenter = CharacteristicApproverMaster::where('machine_name', $machineName)->where('machine_id', $machineId)->first(); + if (! $mNameAndWorkCenter) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Machine name '{$machineName}' and work center '{$workCenter}' not found in approver master!", + ], 404); + } + + $mNameAndWorkCenterAgaPlant = CharacteristicApproverMaster::where('machine_name', $machineName)->where('machine_id', $machineId)->where('plant_id', $plantId)->first(); + if (! $mNameAndWorkCenterAgaPlant) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Machine name '{$machineName}' and work center '{$workCenter}' not found for the plant code '{$plantCode}' in approver master!", + ], 404); + } + + $cFieldAndWorkCent = CharacteristicApproverMaster::where('characteristic_field', $charField)->where('machine_id', $machineId)->first(); + if (! $cFieldAndWorkCent) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Master characteristic field value '{$charField}' not found for the work center '{$workCenter}' in approver master!", + ], 404); + } + + $cFieldAndWorkCentAgaPlant = CharacteristicApproverMaster::where('characteristic_field', $charField)->where('machine_id', $machineId)->where('plant_id', $plantId)->first(); + if (! $cFieldAndWorkCentAgaPlant) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Master characteristic field value '{$charField}' and work center '{$workCenter}' not found for the plant code '{$plantCode}' in approver master!", + ], 404); + } + + $cFieldAndMach = CharacteristicApproverMaster::where('characteristic_field', $charField)->where('machine_name', $machineName)->first(); + if (! $cFieldAndMach) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Master characteristic field value '{$charField}' not found for the machine name '{$machineName}' in approver master!", + ], 404); + } + + $cFieldAndMachAgaPlant = CharacteristicApproverMaster::where('characteristic_field', $charField)->where('machine_name', $machineName)->where('plant_id', $plantId)->first(); + if (! $cFieldAndMachAgaPlant) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Master characteristic field value '{$charField}' and machine name '{$machineName}' not found for the plant code '{$plantCode}' in approver master!", + ], 404); + } + + $cFieldAndWorkCentAndMachAgaPlant = CharacteristicApproverMaster::where('characteristic_field', $charField)->where('machine_name', $machineName)->where('machine_id', $machineId)->where('plant_id', $plantId)->first(); + if (! $cFieldAndWorkCentAndMachAgaPlant) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Master characteristic field value '{$charField}', work center '{$workCenter}', and machine name '{$machineName}' not found for the plant code '{$plantCode}' in approver master!", + ], 404); + } + + $appTypExist = CharacteristicApproverMaster::where('characteristic_field', $charField)->where('approver_type', $requestType)->where('machine_name', $machineName)->where('machine_id', $machineId)->where('plant_id', $plantId)->first(); + if (! $appTypExist) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Master characteristic field value '{$charField}', work center '{$workCenter}', machine name '{$machineName}', and plant code '{$plantCode}' not found for the approver type 'Stop' in approver master!", + ], 404); + } + } + foreach ($data['characteristics'] as $char) { $curMarkStat = $curStat->mark_status ?? null; $curMotorMarkStat = $curStat->motor_marked_status ?? null; @@ -832,9 +978,9 @@ class CharacteristicsController extends Controller 'motor_machine_name' => $curMMach, 'pump_machine_name' => $curPMach, 'name_plate_machine_name' => $curNpMach, - 'stopped_datetime' => now(), - 'is_stopped' => '2', - 'stopped_by' => $userName ?? null, + // 'stopped_datetime' => now(), + // 'is_stopped' => '2', + // 'stopped_by' => $userName ?? null, 'updated_by' => $userName ?? null, ]; } else { @@ -925,9 +1071,9 @@ class CharacteristicsController extends Controller 'name_plate_marked_by' => $curNamePlateMarkBy, 'motor_pump_pumpset_status' => '3', 'name_plate_machine_name' => $curNpMach, - 'stopped_datetime' => now(), - 'is_stopped' => '2', - 'stopped_by' => $userName ?? null, + // 'stopped_datetime' => now(), + // 'is_stopped' => '2', + // 'stopped_by' => $userName ?? null, 'updated_by' => $userName ?? null, ]; } else { @@ -986,9 +1132,9 @@ class CharacteristicsController extends Controller 'pump_marked_by' => $curPumpMarkBy, 'motor_pump_pumpset_status' => '3', 'pump_machine_name' => $curPMach, - 'stopped_datetime' => now(), - 'is_stopped' => '2', - 'stopped_by' => $userName ?? null, + // 'stopped_datetime' => now(), + // 'is_stopped' => '2', + // 'stopped_by' => $userName ?? null, 'updated_by' => $userName ?? null, ]; } else { @@ -1053,9 +1199,9 @@ class CharacteristicsController extends Controller 'motor_marked_by' => $curMotorMarkBy, 'motor_pump_pumpset_status' => '3', 'motor_machine_name' => $curMMach, - 'stopped_datetime' => now(), - 'is_stopped' => '2', - 'stopped_by' => $userName ?? null, + // 'stopped_datetime' => now(), + // 'is_stopped' => '2', + // 'stopped_by' => $userName ?? null, 'updated_by' => $userName ?? null, ]; } else { @@ -1134,9 +1280,9 @@ class CharacteristicsController extends Controller 'motor_machine_name' => $curMMach, 'pump_machine_name' => $curPMach, 'name_plate_machine_name' => $curNpMach, - 'stopped_datetime' => now(), - 'is_stopped' => '2', - 'stopped_by' => $userName ?? null, + // 'stopped_datetime' => now(), + // 'is_stopped' => '2', + // 'stopped_by' => $userName ?? null, 'updated_by' => $userName ?? null, ]; } else { @@ -1237,9 +1383,9 @@ class CharacteristicsController extends Controller 'motor_machine_name' => $curMMach, 'pump_machine_name' => $curPMach, 'name_plate_machine_name' => $curNpMach, - 'stopped_datetime' => now(), - 'is_stopped' => '2', - 'stopped_by' => $userName ?? null, + // 'stopped_datetime' => now(), + // 'is_stopped' => '2', + // 'stopped_by' => $userName ?? null, 'updated_by' => $userName ?? null, ]; } else { @@ -2066,7 +2212,7 @@ class CharacteristicsController extends Controller } } - $availFields = ['class', 'arbid', 'gamng', 'lmnga', 'zz1_cn_bill_ord', 'zmm_amps', 'zmm_brand', 'zmm_degreeofprotection', 'zmm_delivery', 'zmm_dir_rot', 'zmm_discharge', 'zmm_discharge_max', 'zmm_discharge_min', 'zmm_duty', 'zmm_eff_motor', 'zmm_eff_pump', 'zmm_frequency', 'zmm_head', 'zmm_heading', 'zmm_head_max', 'zmm_head_minimum', 'zmm_idx_eff_mtr', 'zmm_idx_eff_pump', 'zmm_kvacode', 'zmm_maxambtemp', 'zmm_mincoolingflow', 'zmm_motorseries', 'zmm_motor_model', 'zmm_outlet', 'zmm_phase', 'zmm_pressure', 'zmm_pumpflowtype', 'zmm_pumpseries', 'zmm_pump_model', 'zmm_ratedpower', 'zmm_region', 'zmm_servicefactor', 'zmm_servicefactormaximumamps', 'zmm_speed', 'zmm_suction', 'zmm_suctionxdelivery', 'zmm_supplysource', 'zmm_temperature', 'zmm_thrustload', 'zmm_volts', 'zmm_wire', 'zmm_package', 'zmm_pvarrayrating', 'zmm_isi', 'zmm_isimotor', 'zmm_isipump', 'zmm_isipumpset', 'zmm_pumpset_model', 'zmm_stages', 'zmm_headrange', 'zmm_overall_efficiency', 'zmm_connection', 'zmm_min_bore_size', 'zmm_isireference', 'zmm_category', 'zmm_submergence', 'zmm_capacitorstart', 'zmm_capacitorrun', 'zmm_inch', 'zmm_motor_type', 'zmm_dismantle_direction', 'zmm_eff_ovrall', 'zmm_bodymoc', 'zmm_rotormoc', 'zmm_dlwl', 'zmm_inputpower', 'zmm_imp_od', 'zmm_ambtemp', 'zmm_de', 'zmm_dischargerange', 'zmm_efficiency_class', 'zmm_framesize', 'zmm_impellerdiameter', 'zmm_insulationclass', 'zmm_maxflow', 'zmm_minhead', 'zmm_mtrlofconst', 'zmm_nde', 'zmm_powerfactor', 'zmm_tagno', 'zmm_year', 'zmm_laser_name', 'zmm_logo_cp', 'zmm_logo_ce', 'zmm_logo_nsf', 'zmm_logo_eac', 'zmm_grwt_motor', 'zmm_grwt_pump', 'zmm_grwt_pset', 'zmm_grwt_cable', 'zmm_grwt_pf', 'zmm_newt_motor', 'zmm_newt_pump', 'zmm_newt_pset', 'zmm_newt_cable', 'zmm_newt_pf', 'zmm_operating_range', 'zmm_intake_air', 'zmm_oxygen_transfer_rate', 'zmm_air_inlet_pipesize', 'zmm_sump_depth', 'zmm_poles', 'zmm_motor_heading', 'zmm_motor_speed', 'zmm_beenote', 'zmm_beenumber', 'zmm_beestar', 'zmm_eff_ttl', 'zmm_labelperiod', 'zmm_modelyear', 'zmm_performance_factor', 'zqmm_qty', 'zmm_operating_temperature', 'zmm_axial_force', 'zmm_codeclass', 'zmm_colour', 'zmm_grade', 'zmm_isivalve', 'zmm_isi_wc', 'zmm_length', 'zmm_license_cml_no', 'zmm_mfgmonyr', 'zmm_motoridentification', 'zmm_packtype', 'zmm_panel', 'zmm_pumpidentification', 'zmm_psettype', 'zmm_size', 'zmm_type', 'zmm_usp', 'marked_datetime', 'marked_by', 'motor_pump_pumpset_status', 'motor_machine_name', 'pump_machine_name', 'name_plate_machine_name', 'pending_released_status', 'has_work_flow_id']; // 'mark_status','marked_physical_count', 'marked_expected_time', 'man_marked_status', 'man_marked_datetime', 'man_marked_by', 'motor_marked_status', 'motor_marked_physical_count', 'motor_expected_time', 'motor_marked_datetime', 'motor_marked_by', 'pump_marked_status', 'pump_marked_physical_count', 'pump_expected_time', 'pump_marked_datetime', 'pump_marked_by', 'name_plate_marked_status', 'name_plate_expected_time', 'name_plate_marked_datetime', 'name_plate_marked_by', 'winded_serial_number', 'winded_rework_status', 'part_validation_1', 'part_validation_2', 'samlight_logged_name' + $availFields = ['class', 'arbid', 'gamng', 'lmnga', 'zz1_cn_bill_ord', 'zmm_amps', 'zmm_brand', 'zmm_degreeofprotection', 'zmm_delivery', 'zmm_dir_rot', 'zmm_discharge', 'zmm_discharge_max', 'zmm_discharge_min', 'zmm_duty', 'zmm_eff_motor', 'zmm_eff_pump', 'zmm_frequency', 'zmm_head', 'zmm_heading', 'zmm_head_max', 'zmm_head_minimum', 'zmm_idx_eff_mtr', 'zmm_idx_eff_pump', 'zmm_kvacode', 'zmm_maxambtemp', 'zmm_mincoolingflow', 'zmm_motorseries', 'zmm_motor_model', 'zmm_outlet', 'zmm_phase', 'zmm_pressure', 'zmm_pumpflowtype', 'zmm_pumpseries', 'zmm_pump_model', 'zmm_ratedpower', 'zmm_region', 'zmm_servicefactor', 'zmm_servicefactormaximumamps', 'zmm_speed', 'zmm_suction', 'zmm_suctionxdelivery', 'zmm_supplysource', 'zmm_temperature', 'zmm_thrustload', 'zmm_volts', 'zmm_wire', 'zmm_package', 'zmm_pvarrayrating', 'zmm_isi', 'zmm_isimotor', 'zmm_isipump', 'zmm_isipumpset', 'zmm_pumpset_model', 'zmm_stages', 'zmm_headrange', 'zmm_overall_efficiency', 'zmm_connection', 'zmm_min_bore_size', 'zmm_isireference', 'zmm_category', 'zmm_submergence', 'zmm_capacitorstart', 'zmm_capacitorrun', 'zmm_inch', 'zmm_motor_type', 'zmm_dismantle_direction', 'zmm_eff_ovrall', 'zmm_bodymoc', 'zmm_rotormoc', 'zmm_dlwl', 'zmm_inputpower', 'zmm_imp_od', 'zmm_ambtemp', 'zmm_de', 'zmm_dischargerange', 'zmm_efficiency_class', 'zmm_framesize', 'zmm_impellerdiameter', 'zmm_insulationclass', 'zmm_maxflow', 'zmm_minhead', 'zmm_mtrlofconst', 'zmm_nde', 'zmm_powerfactor', 'zmm_tagno', 'zmm_year', 'zmm_laser_name', 'zmm_logo_cp', 'zmm_logo_ce', 'zmm_logo_nsf', 'zmm_logo_eac', 'zmm_grwt_motor', 'zmm_grwt_pump', 'zmm_grwt_pset', 'zmm_grwt_cable', 'zmm_grwt_pf', 'zmm_newt_motor', 'zmm_newt_pump', 'zmm_newt_pset', 'zmm_newt_cable', 'zmm_newt_pf', 'zmm_operating_range', 'zmm_intake_air', 'zmm_oxygen_transfer_rate', 'zmm_air_inlet_pipesize', 'zmm_sump_depth', 'zmm_poles', 'zmm_motor_heading', 'zmm_motor_speed', 'zmm_beenote', 'zmm_beenumber', 'zmm_beestar', 'zmm_eff_ttl', 'zmm_labelperiod', 'zmm_modelyear', 'zmm_performance_factor', 'zqmm_qty', 'zmm_operating_temperature', 'zmm_axial_force', 'zmm_codeclass', 'zmm_colour', 'zmm_grade', 'zmm_isivalve', 'zmm_isi_wc', 'zmm_length', 'zmm_license_cml_no', 'zmm_mfgmonyr', 'zmm_motoridentification', 'zmm_packtype', 'zmm_panel', 'zmm_pumpidentification', 'zmm_psettype', 'zmm_size', 'zmm_type', 'zmm_usp', 'marked_datetime', 'marked_by', 'motor_pump_pumpset_status', 'motor_machine_name', 'pump_machine_name', 'name_plate_machine_name', 'pending_released_status', 'has_work_flow_id', 'motor_stop_flow_id', 'pump_stop_flow_id', 'name_plate_stop_flow_id']; // 'mark_status','marked_physical_count', 'marked_expected_time', 'man_marked_status', 'man_marked_datetime', 'man_marked_by', 'motor_marked_status', 'motor_marked_physical_count', 'motor_expected_time', 'motor_marked_datetime', 'motor_marked_by', 'pump_marked_status', 'pump_marked_physical_count', 'pump_expected_time', 'pump_marked_datetime', 'pump_marked_by', 'name_plate_marked_status', 'name_plate_expected_time', 'name_plate_marked_datetime', 'name_plate_marked_by', 'winded_serial_number', 'winded_rework_status', 'part_validation_1', 'part_validation_2', 'samlight_logged_name' if ($itemCode != '' && $itemCode != null && $itemCode && Str::length($itemCode) > 0) { $existingJobNo = ClassCharacteristic::where('aufnr', $jobNo)->first(); // ->where('machine_id', $machineId)->where('plant_id', $plantId) @@ -2134,6 +2280,8 @@ class CharacteristicsController extends Controller $columns = Schema::getColumnListing((new ClassCharacteristic)->getTable()); + $itemColumns = Schema::getColumnListing((new ItemCharacteristic)->getTable()); + $invalidFields = []; foreach ($request->input('characteristics', []) as $char) { @@ -2289,6 +2437,9 @@ class CharacteristicsController extends Controller ], 404); } + $masterItemFields = ['class', 'zz1_cn_bill_ord', 'zmm_amps', 'zmm_brand', 'zmm_degreeofprotection', 'zmm_delivery', 'zmm_dir_rot', 'zmm_discharge', 'zmm_discharge_max', 'zmm_discharge_min', 'zmm_duty', 'zmm_eff_motor', 'zmm_eff_pump', 'zmm_frequency', 'zmm_head', 'zmm_heading', 'zmm_head_max', 'zmm_head_minimum', 'zmm_idx_eff_mtr', 'zmm_idx_eff_pump', 'zmm_kvacode', 'zmm_maxambtemp', 'zmm_mincoolingflow', 'zmm_motorseries', 'zmm_motor_model', 'zmm_outlet', 'zmm_phase', 'zmm_pressure', 'zmm_pumpflowtype', 'zmm_pumpseries', 'zmm_pump_model', 'zmm_ratedpower', 'zmm_region', 'zmm_servicefactor', 'zmm_servicefactormaximumamps', 'zmm_speed', 'zmm_suction', 'zmm_suctionxdelivery', 'zmm_supplysource', 'zmm_temperature', 'zmm_thrustload', 'zmm_volts', 'zmm_wire', 'zmm_package', 'zmm_pvarrayrating', 'zmm_isi', 'zmm_isimotor', 'zmm_isipump', 'zmm_isipumpset', 'zmm_pumpset_model', 'zmm_stages', 'zmm_headrange', 'zmm_overall_efficiency', 'zmm_connection', 'zmm_min_bore_size', 'zmm_isireference', 'zmm_category', 'zmm_submergence', 'zmm_capacitorstart', 'zmm_capacitorrun', 'zmm_inch', 'zmm_motor_type', 'zmm_dismantle_direction', 'zmm_eff_ovrall', 'zmm_bodymoc', 'zmm_rotormoc', 'zmm_dlwl', 'zmm_inputpower', 'zmm_imp_od', 'zmm_ambtemp', 'zmm_de', 'zmm_dischargerange', 'zmm_efficiency_class', 'zmm_framesize', 'zmm_impellerdiameter', 'zmm_insulationclass', 'zmm_maxflow', 'zmm_minhead', 'zmm_mtrlofconst', 'zmm_nde', 'zmm_powerfactor', 'zmm_tagno', 'zmm_year', 'zmm_laser_name', 'zmm_logo_cp', 'zmm_logo_ce', 'zmm_logo_nsf', 'zmm_logo_eac', 'zmm_grwt_motor', 'zmm_grwt_pump', 'zmm_grwt_pset', 'zmm_newt_motor', 'zmm_newt_pump', 'zmm_newt_pset', 'zmm_operating_range', 'zmm_intake_air', 'zmm_oxygen_transfer_rate', 'zmm_air_inlet_pipesize', 'zmm_sump_depth', 'zmm_poles', 'zmm_motor_heading', 'zmm_motor_speed', 'zmm_beenote', 'zmm_beenumber', 'zmm_beestar', 'zmm_eff_ttl', 'zmm_labelperiod', 'zmm_modelyear', 'zmm_performance_factor', 'zqmm_qty', 'zmm_operating_temperature', 'zmm_axial_force']; + + $isNewItem = true; $isInsert = false; foreach ($serialNumbers as $serial) { @@ -2308,6 +2459,20 @@ class CharacteristicsController extends Controller } } + if ($isNewItem) { + $insertItemData = [ + 'plant_id' => $plantId, + 'item_id' => $itemId, + 'updated_by' => $userName ?? null, + ]; + + foreach ($masterItemFields as $field) { + if (in_array($field, $itemColumns)) { + $insertItemData[$field] = $char[$field] ?? null; + } + } + } + $insertData['marked_datetime'] = empty($char['marked_datetime']) ? now() : $char['marked_datetime']; $insertData['marked_by'] = ($char['marked_by'] == 'jothi') ? 'Admin' : $char['marked_by'] ?? null; @@ -2329,6 +2494,19 @@ class CharacteristicsController extends Controller $isInsert = true; $insertData['created_by'] = $userName ?? null; ClassCharacteristic::create($insertData); + + if ($isNewItem) { + $existingItem = ItemCharacteristic::where('item_id', $itemId)->where('plant_id', $plantId); + + if ($existingItem) { + $isNewItem = false; + $existingItem->update($insertItemData); + } else { + $isNewItem = false; + $insertItemData['created_by'] = $userName ?? null; + ItemCharacteristic::create($insertItemData); + } + } } } catch (\Exception $e) { return response()->json([ @@ -2401,6 +2579,8 @@ class CharacteristicsController extends Controller $columns = Schema::getColumnListing((new ClassCharacteristic)->getTable()); + $itemColumns = Schema::getColumnListing((new ItemCharacteristic)->getTable()); + $invalidFields = []; foreach ($request->input('characteristics', []) as $char) { @@ -2459,6 +2639,7 @@ class CharacteristicsController extends Controller // 'status_code' => "ERROR", // 'status_description' => "Serial numbers can't be empty!" // ], 404); + foreach ($characteristics as $ch) { $curHead = $ch['zmm_heading'] ?? null; if ($curHead == '' || $curHead == null) { @@ -2642,6 +2823,8 @@ class CharacteristicsController extends Controller $masterFields = ['class', 'arbid', 'gamng', 'lmnga', 'zz1_cn_bill_ord', 'zmm_amps', 'zmm_brand', 'zmm_degreeofprotection', 'zmm_delivery', 'zmm_dir_rot', 'zmm_discharge', 'zmm_discharge_max', 'zmm_discharge_min', 'zmm_duty', 'zmm_eff_motor', 'zmm_eff_pump', 'zmm_frequency', 'zmm_head', 'zmm_heading', 'zmm_head_max', 'zmm_head_minimum', 'zmm_idx_eff_mtr', 'zmm_idx_eff_pump', 'zmm_kvacode', 'zmm_maxambtemp', 'zmm_mincoolingflow', 'zmm_motorseries', 'zmm_motor_model', 'zmm_outlet', 'zmm_phase', 'zmm_pressure', 'zmm_pumpflowtype', 'zmm_pumpseries', 'zmm_pump_model', 'zmm_ratedpower', 'zmm_region', 'zmm_servicefactor', 'zmm_servicefactormaximumamps', 'zmm_speed', 'zmm_suction', 'zmm_suctionxdelivery', 'zmm_supplysource', 'zmm_temperature', 'zmm_thrustload', 'zmm_volts', 'zmm_wire', 'zmm_package', 'zmm_pvarrayrating', 'zmm_isi', 'zmm_isimotor', 'zmm_isipump', 'zmm_isipumpset', 'zmm_pumpset_model', 'zmm_stages', 'zmm_headrange', 'zmm_overall_efficiency', 'zmm_connection', 'zmm_min_bore_size', 'zmm_isireference', 'zmm_category', 'zmm_submergence', 'zmm_capacitorstart', 'zmm_capacitorrun', 'zmm_inch', 'zmm_motor_type', 'zmm_dismantle_direction', 'zmm_eff_ovrall', 'zmm_bodymoc', 'zmm_rotormoc', 'zmm_dlwl', 'zmm_inputpower', 'zmm_imp_od', 'zmm_ambtemp', 'zmm_de', 'zmm_dischargerange', 'zmm_efficiency_class', 'zmm_framesize', 'zmm_impellerdiameter', 'zmm_insulationclass', 'zmm_maxflow', 'zmm_minhead', 'zmm_mtrlofconst', 'zmm_nde', 'zmm_powerfactor', 'zmm_tagno', 'zmm_year', 'zmm_laser_name', 'zmm_logo_cp', 'zmm_logo_ce', 'zmm_logo_nsf', 'zmm_logo_eac', 'zmm_grwt_motor', 'zmm_grwt_pump', 'zmm_grwt_pset', 'zmm_newt_motor', 'zmm_newt_pump', 'zmm_newt_pset', 'zmm_operating_range', 'zmm_intake_air', 'zmm_oxygen_transfer_rate', 'zmm_air_inlet_pipesize', 'zmm_sump_depth', 'zmm_poles', 'zmm_motor_heading', 'zmm_motor_speed', 'zmm_beenote', 'zmm_beenumber', 'zmm_beestar', 'zmm_eff_ttl', 'zmm_labelperiod', 'zmm_modelyear', 'zmm_performance_factor', 'zqmm_qty', 'zmm_operating_temperature', 'zmm_axial_force', 'pending_released_status']; + $masterItemFields = ['class', 'zz1_cn_bill_ord', 'zmm_amps', 'zmm_brand', 'zmm_degreeofprotection', 'zmm_delivery', 'zmm_dir_rot', 'zmm_discharge', 'zmm_discharge_max', 'zmm_discharge_min', 'zmm_duty', 'zmm_eff_motor', 'zmm_eff_pump', 'zmm_frequency', 'zmm_head', 'zmm_heading', 'zmm_head_max', 'zmm_head_minimum', 'zmm_idx_eff_mtr', 'zmm_idx_eff_pump', 'zmm_kvacode', 'zmm_maxambtemp', 'zmm_mincoolingflow', 'zmm_motorseries', 'zmm_motor_model', 'zmm_outlet', 'zmm_phase', 'zmm_pressure', 'zmm_pumpflowtype', 'zmm_pumpseries', 'zmm_pump_model', 'zmm_ratedpower', 'zmm_region', 'zmm_servicefactor', 'zmm_servicefactormaximumamps', 'zmm_speed', 'zmm_suction', 'zmm_suctionxdelivery', 'zmm_supplysource', 'zmm_temperature', 'zmm_thrustload', 'zmm_volts', 'zmm_wire', 'zmm_package', 'zmm_pvarrayrating', 'zmm_isi', 'zmm_isimotor', 'zmm_isipump', 'zmm_isipumpset', 'zmm_pumpset_model', 'zmm_stages', 'zmm_headrange', 'zmm_overall_efficiency', 'zmm_connection', 'zmm_min_bore_size', 'zmm_isireference', 'zmm_category', 'zmm_submergence', 'zmm_capacitorstart', 'zmm_capacitorrun', 'zmm_inch', 'zmm_motor_type', 'zmm_dismantle_direction', 'zmm_eff_ovrall', 'zmm_bodymoc', 'zmm_rotormoc', 'zmm_dlwl', 'zmm_inputpower', 'zmm_imp_od', 'zmm_ambtemp', 'zmm_de', 'zmm_dischargerange', 'zmm_efficiency_class', 'zmm_framesize', 'zmm_impellerdiameter', 'zmm_insulationclass', 'zmm_maxflow', 'zmm_minhead', 'zmm_mtrlofconst', 'zmm_nde', 'zmm_powerfactor', 'zmm_tagno', 'zmm_year', 'zmm_laser_name', 'zmm_logo_cp', 'zmm_logo_ce', 'zmm_logo_nsf', 'zmm_logo_eac', 'zmm_grwt_motor', 'zmm_grwt_pump', 'zmm_grwt_pset', 'zmm_newt_motor', 'zmm_newt_pump', 'zmm_newt_pset', 'zmm_operating_range', 'zmm_intake_air', 'zmm_oxygen_transfer_rate', 'zmm_air_inlet_pipesize', 'zmm_sump_depth', 'zmm_poles', 'zmm_motor_heading', 'zmm_motor_speed', 'zmm_beenote', 'zmm_beenumber', 'zmm_beestar', 'zmm_eff_ttl', 'zmm_labelperiod', 'zmm_modelyear', 'zmm_performance_factor', 'zqmm_qty', 'zmm_operating_temperature', 'zmm_axial_force']; + $isInsertOrUpdate = false; foreach ($characteristics as $char) { @@ -2658,12 +2841,33 @@ class CharacteristicsController extends Controller } } + $insertItemData = [ + 'plant_id' => $plantId, + 'item_id' => $itemId, + 'updated_by' => $userName ?? null, + ]; + + foreach ($masterItemFields as $field) { + if (in_array($field, $itemColumns)) { + $insertItemData[$field] = $char[$field] ?? null; + } + } + $existing = ClassCharacteristic::where('aufnr', $jobNo)->where('machine_id', $machineId)->where('plant_id', $plantId); if ($existing) { $isInsertOrUpdate = true; $insertData['updated_by'] = $userName ?? null; $existing->update($insertData); + + $existingItem = ItemCharacteristic::where('item_id', $itemId)->where('plant_id', $plantId); + + if ($existingItem) { + $existingItem->update($insertItemData); + } else { + $insertItemData['created_by'] = $userName ?? null; + ItemCharacteristic::create($insertItemData); + } } else { return response()->json([ 'status_code' => 'ERROR', @@ -2943,80 +3147,152 @@ class CharacteristicsController extends Controller ], 404); } - $job = ClassCharacteristic::where('aufnr', $jobNumber)->first(); - - if (! $job) { - return response()->json([ - 'status_code' => 'SUCCESS', - 'status_description' => "Job number '{$jobNumber}' not found!", - ], 404); - } - - $jobPlant = ClassCharacteristic::where('aufnr', $jobNumber)->where('plant_id', $plantId)->first(); - - if (! $jobPlant) { - return response()->json([ - 'status_code' => 'ERROR', - 'status_description' => "Job number '{$jobNumber}' not found for the plant code '{$plantCode}'!", - ], 404); - } - - $jobWorkCenter = ClassCharacteristic::where('aufnr', $jobNumber)->where('machine_id', $machineId)->where('plant_id', $plantId)->first(); - - if (! $jobWorkCenter) { - return response()->json([ - 'status_code' => 'ERROR', - 'status_description' => "Job number '{$jobNumber}' not found for the work center '{$workCenter}'!", - ], 404); - } - - $columnsToShow = ['mark_status', 'marked_datetime', 'marked_physical_count', 'marked_expected_time', 'marked_by', 'man_marked_status', 'man_marked_datetime', 'man_marked_by', 'motor_marked_status', 'motor_marked_physical_count', 'motor_expected_time', 'motor_marked_datetime', 'motor_marked_by', 'pump_marked_status', 'pump_marked_physical_count', 'pump_expected_time', 'pump_marked_datetime', 'pump_marked_by', 'name_plate_marked_status', 'name_plate_expected_time', 'name_plate_marked_datetime', 'name_plate_marked_by', 'motor_pump_pumpset_status', 'winded_serial_number', 'winded_rework_status', 'motor_machine_name', 'pump_machine_name', 'name_plate_machine_name', 'part_validation_1', 'part_validation_2', 'samlight_logged_name', 'pending_released_status', 'has_work_flow_id']; + $columnsToShow = ['mark_status', 'marked_datetime', 'marked_physical_count', 'marked_expected_time', 'marked_by', 'man_marked_status', 'man_marked_datetime', 'man_marked_by', 'motor_marked_status', 'motor_marked_physical_count', 'motor_expected_time', 'motor_marked_datetime', 'motor_marked_by', 'pump_marked_status', 'pump_marked_physical_count', 'pump_expected_time', 'pump_marked_datetime', 'pump_marked_by', 'name_plate_marked_status', 'name_plate_expected_time', 'name_plate_marked_datetime', 'name_plate_marked_by', 'motor_pump_pumpset_status', 'winded_serial_number', 'winded_rework_status', 'motor_machine_name', 'pump_machine_name', 'name_plate_machine_name', 'part_validation_1', 'part_validation_2', 'samlight_logged_name', 'pending_released_status', 'has_work_flow_id', 'motor_stop_flow_id', 'pump_stop_flow_id', 'name_plate_stop_flow_id']; $characteristicsColumns = ['class', 'arbid', 'gamng', 'lmnga', 'zz1_cn_bill_ord', 'zmm_amps', 'zmm_brand', 'zmm_degreeofprotection', 'zmm_delivery', 'zmm_dir_rot', 'zmm_discharge', 'zmm_discharge_max', 'zmm_discharge_min', 'zmm_duty', 'zmm_eff_motor', 'zmm_eff_pump', 'zmm_frequency', 'zmm_head', 'zmm_heading', 'zmm_head_max', 'zmm_head_minimum', 'zmm_idx_eff_mtr', 'zmm_idx_eff_pump', 'zmm_kvacode', 'zmm_maxambtemp', 'zmm_mincoolingflow', 'zmm_motorseries', 'zmm_motor_model', 'zmm_outlet', 'zmm_phase', 'zmm_pressure', 'zmm_pumpflowtype', 'zmm_pumpseries', 'zmm_pump_model', 'zmm_ratedpower', 'zmm_region', 'zmm_servicefactor', 'zmm_servicefactormaximumamps', 'zmm_speed', 'zmm_suction', 'zmm_suctionxdelivery', 'zmm_supplysource', 'zmm_temperature', 'zmm_thrustload', 'zmm_volts', 'zmm_wire', 'zmm_package', 'zmm_pvarrayrating', 'zmm_isi', 'zmm_isimotor', 'zmm_isipump', 'zmm_isipumpset', 'zmm_pumpset_model', 'zmm_stages', 'zmm_headrange', 'zmm_overall_efficiency', 'zmm_connection', 'zmm_min_bore_size', 'zmm_isireference', 'zmm_category', 'zmm_submergence', 'zmm_capacitorstart', 'zmm_capacitorrun', 'zmm_inch', 'zmm_motor_type', 'zmm_dismantle_direction', 'zmm_eff_ovrall', 'zmm_bodymoc', 'zmm_rotormoc', 'zmm_dlwl', 'zmm_inputpower', 'zmm_imp_od', 'zmm_ambtemp', 'zmm_de', 'zmm_dischargerange', 'zmm_efficiency_class', 'zmm_framesize', 'zmm_impellerdiameter', 'zmm_insulationclass', 'zmm_maxflow', 'zmm_minhead', 'zmm_mtrlofconst', 'zmm_nde', 'zmm_powerfactor', 'zmm_tagno', 'zmm_year', 'zmm_laser_name', 'zmm_logo_cp', 'zmm_logo_ce', 'zmm_logo_nsf', 'zmm_logo_eac', 'zmm_grwt_motor', 'zmm_grwt_pump', 'zmm_grwt_pset', 'zmm_newt_motor', 'zmm_newt_pump', 'zmm_newt_pset', 'zmm_operating_range', 'zmm_intake_air', 'zmm_oxygen_transfer_rate', 'zmm_air_inlet_pipesize', 'zmm_sump_depth', 'zmm_poles', 'zmm_motor_heading', 'zmm_motor_speed', 'zmm_beenote', 'zmm_beenumber', 'zmm_beestar', 'zmm_eff_ttl', 'zmm_labelperiod', 'zmm_modelyear', 'zmm_performance_factor', 'zqmm_qty', 'zmm_operating_temperature', 'zmm_axial_force']; - $characteristicsData = ClassCharacteristic::where('aufnr', $jobNumber)->where('machine_id', $machineId)->where('plant_id', $plantId)->distinct()->get($characteristicsColumns); // ->get(); + $job = ClassCharacteristic::where('aufnr', $jobNumber)->first(); - if ($characteristicsData->isEmpty()) { - return response()->json([ - 'status_code' => 'ERROR', - 'status_description' => 'No characteristics data found for the provided Plant Code, Work Center, and Job Number!', - ], 404); - } + if (! $job) { + // check in production temp table for job characteristics to send + $prodJob = ProductionTemp::where('aufnr', $jobNumber)->first(); - $serials = ClassCharacteristic::where('aufnr', $jobNumber)->where('machine_id', $machineId)->where('plant_id', $plantId)->orderBy('gernr')->get(array_merge(['gernr', 'item_id'], $columnsToShow)); // ->get(array_merge(['gernr'], $columnsToShow)); - - $itemId = $serials->first()->item_id; - - $itemcode = Item::where('id', $itemId)->value('code') ?? ''; - - $markedSerials = ClassCharacteristic::where('aufnr', $jobNumber)->where('machine_id', $machineId)->where('plant_id', $plantId)->get(['gernr', 'mark_status']); - - $allMarked = $markedSerials->every(function ($serial) { - return strtolower($serial->mark_status) == 'marked'; - }); - - if ($allMarked) { - return response()->json([ - 'status_code' => 'ERROR', - 'status_description' => 'All serial numbers are already marked!', - ], 404); - } - - $serialNumbers = $serials->map(function ($serial) use ($columnsToShow) { - $otherData = []; - foreach ($columnsToShow as $col) { - $otherData[strtoupper($col)] = (string) $serial->$col ?? ''; + if (! $prodJob) { + return response()->json([ + 'status_code' => 'SUCCESS', + 'status_description' => "Job number '{$jobNumber}' not found!", // skip + ], 404); } - $otherData['MARKED_BY'] = ($otherData['MARKED_BY'] == 'Admin') ? 'jothi' : $otherData['MARKED_BY'] ?? ''; // marked_by - $otherData['MAN_MARKED_BY'] = ($otherData['MAN_MARKED_BY'] == 'Admin') ? 'jothi' : $otherData['MAN_MARKED_BY'] ?? ''; // man_marked_by - $otherData['MOTOR_MARKED_BY'] = ($otherData['MOTOR_MARKED_BY'] == 'Admin') ? 'jothi' : $otherData['MOTOR_MARKED_BY'] ?? ''; // motor_marked_by - $otherData['PUMP_MARKED_BY'] = ($otherData['PUMP_MARKED_BY'] == 'Admin') ? 'jothi' : $otherData['PUMP_MARKED_BY'] ?? ''; // pump_marked_by - $otherData['NAME_PLATE_MARKED_BY'] = ($otherData['NAME_PLATE_MARKED_BY'] == 'Admin') ? 'jothi' : $otherData['NAME_PLATE_MARKED_BY'] ?? ''; // name_plate_marked_by + $prodJobPlant = ProductionTemp::where('aufnr', $jobNumber)->where('plant_id', $plantId)->first(); - // $otherData['pending_released_status'] = (string)$otherData['pending_released_status'] ?? ''; - return array_merge(['GERNR' => $serial->gernr], $otherData); - }); + if (! $prodJobPlant) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Job number '{$jobNumber}' not found for the plant code '{$plantCode}' in Production Temp table!", + ], 404); + } + + $prodJobWorkCenter = ProductionTemp::where('aufnr', $jobNumber)->where('machine_id', $machineId)->where('plant_id', $plantId)->first(); + + if (! $prodJobWorkCenter) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Job number '{$jobNumber}' not found for the work center '{$workCenter}' in Production Temp table!", + ], 404); + } + + $curHeadVal = strtoupper($prodJobWorkCenter?->zmm_heading ?? ''); + + if (Str::contains($curHeadVal, 'PRESSURE BOOSTER SYSTEM', ignoreCase: true) || Str::contains($curHeadVal, 'PUMP SET', ignoreCase: true) || Str::contains($curHeadVal, 'PUMPSET', ignoreCase: true) || Str::contains($curHeadVal, 'PUMPS', ignoreCase: true)) { + $curHeadVal = '3'; + } else { + $curHeadVal = ''; + } + + // pass here all available job characteristics + + $characteristicsData = ProductionTemp::where('aufnr', $jobNumber)->where('machine_id', $machineId)->where('plant_id', $plantId)->distinct()->get($characteristicsColumns); // ->get(); + + if ($characteristicsData->isEmpty()) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => 'No characteristics data found for the provided Plant Code, Work Center, and Job Number in Production Temp table!', + ], 404); + } + + $serials = ProductionTemp::where('aufnr', $jobNumber)->where('machine_id', $machineId)->where('plant_id', $plantId)->orderBy('gernr')->get(['gernr', 'pending_released_status']); + + $itemcode = ''; + + $serialNumbers = $serials->map(function ($serial) use ($columnsToShow, $userName, $curHeadVal) { + $otherData = []; + foreach ($columnsToShow as $col) { + $otherData[strtoupper($col)] = ($col == 'pending_released_status') ? (string) $serial->$col ?? '0' : ''; + } + + $otherData['MARKED_DATETIME'] = now()->timezone('Asia/Kolkata')->format('Y-m-d H:i:s'); + $otherData['MARKED_PHYSICAL_COUNT'] = '0'; + $otherData['MARKED_EXPECTED_TIME'] = '0'; + $otherData['MARKED_BY'] = ($userName == 'Admin') ? 'jothi' : $userName ?? ''; + $otherData['MAN_MARKED_STATUS'] = '0'; + $otherData['MOTOR_MARKED_PHYSICAL_COUNT'] = '0'; + $otherData['MOTOR_EXPECTED_TIME'] = '0'; + $otherData['PUMP_MARKED_PHYSICAL_COUNT'] = '0'; + $otherData['PUMP_EXPECTED_TIME'] = '0'; + $otherData['NAME_PLATE_EXPECTED_TIME'] = '0'; + $otherData['MOTOR_PUMP_PUMPSET_STATUS'] = $curHeadVal ?? ''; + $otherData['WINDED_REWORK_STATUS'] = '0'; + $otherData['HAS_WORK_FLOW_ID'] = '0'; + $otherData['MOTOR_STOP_FLOW_ID'] = '5'; + $otherData['PUMP_STOP_FLOW_ID'] = '5'; + $otherData['NAME_PLATE_STOP_FLOW_ID'] = '5'; + + return array_merge(['GERNR' => $serial->gernr], $otherData); + }); + } else { + $jobPlant = ClassCharacteristic::where('aufnr', $jobNumber)->where('plant_id', $plantId)->first(); + + if (! $jobPlant) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Job number '{$jobNumber}' not found for the plant code '{$plantCode}'!", + ], 404); + } + + $jobWorkCenter = ClassCharacteristic::where('aufnr', $jobNumber)->where('machine_id', $machineId)->where('plant_id', $plantId)->first(); + + if (! $jobWorkCenter) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Job number '{$jobNumber}' not found for the work center '{$workCenter}'!", + ], 404); + } + + $characteristicsData = ClassCharacteristic::where('aufnr', $jobNumber)->where('machine_id', $machineId)->where('plant_id', $plantId)->distinct()->get($characteristicsColumns); // ->get(); + + if ($characteristicsData->isEmpty()) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => 'No characteristics data found for the provided Plant Code, Work Center, and Job Number!', + ], 404); + } + + $serials = ClassCharacteristic::where('aufnr', $jobNumber)->where('machine_id', $machineId)->where('plant_id', $plantId)->orderBy('gernr')->get(array_merge(['gernr', 'item_id'], $columnsToShow)); // ->get(array_merge(['gernr'], $columnsToShow)); + + $itemId = $serials->first()->item_id; + + $itemcode = Item::where('id', $itemId)->value('code') ?? ''; + + $markedSerials = ClassCharacteristic::where('aufnr', $jobNumber)->where('machine_id', $machineId)->where('plant_id', $plantId)->get(['gernr', 'mark_status']); + + $allMarked = $markedSerials->every(function ($serial) { + return strtolower($serial->mark_status) == 'marked'; + }); + + if ($allMarked) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => 'All serial numbers are already marked!', + ], 404); + } + + $serialNumbers = $serials->map(function ($serial) use ($columnsToShow) { + $otherData = []; + foreach ($columnsToShow as $col) { + $otherData[strtoupper($col)] = (string) $serial->$col ?? ''; + } + + $otherData['MARKED_BY'] = ($otherData['MARKED_BY'] == 'Admin') ? 'jothi' : $otherData['MARKED_BY'] ?? ''; // marked_by + $otherData['MAN_MARKED_BY'] = ($otherData['MAN_MARKED_BY'] == 'Admin') ? 'jothi' : $otherData['MAN_MARKED_BY'] ?? ''; // man_marked_by + $otherData['MOTOR_MARKED_BY'] = ($otherData['MOTOR_MARKED_BY'] == 'Admin') ? 'jothi' : $otherData['MOTOR_MARKED_BY'] ?? ''; // motor_marked_by + $otherData['PUMP_MARKED_BY'] = ($otherData['PUMP_MARKED_BY'] == 'Admin') ? 'jothi' : $otherData['PUMP_MARKED_BY'] ?? ''; // pump_marked_by + $otherData['NAME_PLATE_MARKED_BY'] = ($otherData['NAME_PLATE_MARKED_BY'] == 'Admin') ? 'jothi' : $otherData['NAME_PLATE_MARKED_BY'] ?? ''; // name_plate_marked_by + + // $otherData['pending_released_status'] = (string)$otherData['pending_released_status'] ?? ''; + return array_merge(['GERNR' => $serial->gernr], $otherData); + }); + } $characteristics = $characteristicsData->map(function ($char) use ($characteristicsColumns) { $data = []; @@ -3056,7 +3332,7 @@ class CharacteristicsController extends Controller } elseif (! preg_match('/^[1-9][a-zA-Z0-9]{8,}$/', $serialNumber)) { return response()->json([ 'status_code' => 'ERROR', - 'status_description' => "Serial number '{$serialNumber}' should not begin with '0'!", + 'status_description' => "Serial number '{$serialNumber}' should not begin with '0' or letter!", ], 404); } @@ -3241,7 +3517,7 @@ class CharacteristicsController extends Controller $characteristicsData = ClassCharacteristic::where('gernr', $serialNumber)->where('item_id', $itemId)->where('machine_id', $machineId)->where('plant_id', $plantId)->get(); - $remFields = ['id', 'plant_id', 'machine_id', 'item_id', 'gernr', 'zmm_codeclass', 'zmm_colour', 'zmm_grade', 'zmm_grwt_cable', 'zmm_grwt_pf', 'zmm_isivalve', 'zmm_isi_wc', 'zmm_length', 'zmm_license_cml_no', 'zmm_mfgmonyr', 'zmm_motoridentification', 'zmm_newt_cable', 'zmm_newt_pf', 'zmm_packtype', 'zmm_panel', 'zmm_pumpidentification', 'zmm_psettype', 'zmm_size', 'zmm_type', 'zmm_usp', 'created_at', 'updated_at', 'created_by', 'updated_by', 'deleted_at', 'is_stopped', 'stopped_datetime', 'stopped_by']; + $remFields = ['id', 'plant_id', 'machine_id', 'item_id', 'gernr', 'zmm_codeclass', 'zmm_colour', 'zmm_grade', 'zmm_grwt_cable', 'zmm_grwt_pf', 'zmm_isivalve', 'zmm_isi_wc', 'zmm_length', 'zmm_license_cml_no', 'zmm_mfgmonyr', 'zmm_motoridentification', 'zmm_newt_cable', 'zmm_newt_pf', 'zmm_packtype', 'zmm_panel', 'zmm_pumpidentification', 'zmm_psettype', 'zmm_size', 'zmm_type', 'zmm_usp', 'created_at', 'updated_at', 'created_by', 'updated_by', 'deleted_at']; // , 'is_stopped', 'stopped_datetime', 'stopped_by' $filteredData = $characteristicsData->map(function ($char) use ($remFields) { $charArray = $char->toArray(); @@ -3441,10 +3717,38 @@ class CharacteristicsController extends Controller $job = ClassCharacteristic::where('aufnr', $jobNumber)->first(); if (! $job) { + // check in production temp table for pending serial numbers + $prodJob = ProductionTemp::where('aufnr', $jobNumber)->first(); + + if (! $prodJob) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Job number '{$jobNumber}' not found!", // skip + ], 404); + } + + $prodJobPlant = ProductionTemp::where('aufnr', $jobNumber)->where('plant_id', $plantId)->first(); + + if (! $prodJobPlant) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Job number '{$jobNumber}' not found for the plant code '{$plantCode}' in Production Temp table!", + ], 404); + } + + $prodJobWorkCenter = ProductionTemp::where('aufnr', $jobNumber)->where('machine_id', $machineId)->where('plant_id', $plantId)->first(); + + if (! $prodJobWorkCenter) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Job number '{$jobNumber}' not found for the work center '{$workCenter}' in Production Temp table!", + ], 404); + } + return response()->json([ - 'status_code' => 'ERROR', - 'status_description' => "Job number '{$jobNumber}' not found!", // skip - ], 404); + 'status_code' => 'SUCCESS', + 'status_description' => 'Has some pending serial numbers to mark!', + ], 200); } $jobPlant = ClassCharacteristic::where('aufnr', $jobNumber)->where('plant_id', $plantId)->first(); @@ -3504,7 +3808,7 @@ class CharacteristicsController extends Controller } } - // $columnsToShow = ['mark_status', 'marked_datetime', 'marked_physical_count', 'marked_expected_time', 'marked_by', 'man_marked_status', 'man_marked_datetime', 'man_marked_by', 'motor_marked_status', 'motor_marked_physical_count', 'motor_expected_time', 'motor_marked_by', 'pump_marked_status', 'pump_marked_physical_count', 'pump_expected_time', 'pump_marked_by', 'name_plate_marked_status', 'name_plate_expected_time', 'name_plate_marked_by', 'motor_pump_pumpset_status', 'winded_serial_number', 'motor_machine_name', 'pump_machine_name', 'name_plate_machine_name', 'part_validation_1', 'part_validation_2', 'samlight_logged_name', 'pending_released_status', 'has_work_flow_id']; + // $columnsToShow = ['mark_status', 'marked_datetime', 'marked_physical_count', 'marked_expected_time', 'marked_by', 'man_marked_status', 'man_marked_datetime', 'man_marked_by', 'motor_marked_status', 'motor_marked_physical_count', 'motor_expected_time', 'motor_marked_by', 'pump_marked_status', 'pump_marked_physical_count', 'pump_expected_time', 'pump_marked_by', 'name_plate_marked_status', 'name_plate_expected_time', 'name_plate_marked_by', 'motor_pump_pumpset_status', 'winded_serial_number', 'motor_machine_name', 'pump_machine_name', 'name_plate_machine_name', 'part_validation_1', 'part_validation_2', 'samlight_logged_name', 'pending_released_status', 'has_work_flow_id', 'motor_stop_flow_id', 'pump_stop_flow_id', 'name_plate_stop_flow_id']; $characteristicsColumns = ['class', 'arbid', 'gamng', 'lmnga', 'zz1_cn_bill_ord', 'zmm_amps', 'zmm_brand', 'zmm_degreeofprotection', 'zmm_delivery', 'zmm_dir_rot', 'zmm_discharge', 'zmm_discharge_max', 'zmm_discharge_min', 'zmm_duty', 'zmm_eff_motor', 'zmm_eff_pump', 'zmm_frequency', 'zmm_head', 'zmm_heading', 'zmm_head_max', 'zmm_head_minimum', 'zmm_idx_eff_mtr', 'zmm_idx_eff_pump', 'zmm_kvacode', 'zmm_maxambtemp', 'zmm_mincoolingflow', 'zmm_motorseries', 'zmm_motor_model', 'zmm_outlet', 'zmm_phase', 'zmm_pressure', 'zmm_pumpflowtype', 'zmm_pumpseries', 'zmm_pump_model', 'zmm_ratedpower', 'zmm_region', 'zmm_servicefactor', 'zmm_servicefactormaximumamps', 'zmm_speed', 'zmm_suction', 'zmm_suctionxdelivery', 'zmm_supplysource', 'zmm_temperature', 'zmm_thrustload', 'zmm_volts', 'zmm_wire', 'zmm_package', 'zmm_pvarrayrating', 'zmm_isi', 'zmm_isimotor', 'zmm_isipump', 'zmm_isipumpset', 'zmm_pumpset_model', 'zmm_stages', 'zmm_headrange', 'zmm_overall_efficiency', 'zmm_connection', 'zmm_min_bore_size', 'zmm_isireference', 'zmm_category', 'zmm_submergence', 'zmm_capacitorstart', 'zmm_capacitorrun', 'zmm_inch', 'zmm_motor_type', 'zmm_dismantle_direction', 'zmm_eff_ovrall', 'zmm_bodymoc', 'zmm_rotormoc', 'zmm_dlwl', 'zmm_inputpower', 'zmm_imp_od', 'zmm_ambtemp', 'zmm_de', 'zmm_dischargerange', 'zmm_efficiency_class', 'zmm_framesize', 'zmm_impellerdiameter', 'zmm_insulationclass', 'zmm_maxflow', 'zmm_minhead', 'zmm_mtrlofconst', 'zmm_nde', 'zmm_powerfactor', 'zmm_tagno', 'zmm_year', 'zmm_laser_name', 'zmm_logo_cp', 'zmm_logo_ce', 'zmm_logo_nsf', 'zmm_logo_eac', 'zmm_grwt_motor', 'zmm_grwt_pump', 'zmm_grwt_pset', 'zmm_newt_motor', 'zmm_newt_pump', 'zmm_newt_pset', 'zmm_operating_range', 'zmm_intake_air', 'zmm_oxygen_transfer_rate', 'zmm_air_inlet_pipesize', 'zmm_sump_depth', 'zmm_poles', 'zmm_motor_heading', 'zmm_motor_speed', 'zmm_beenote', 'zmm_beenumber', 'zmm_beestar', 'zmm_eff_ttl', 'zmm_labelperiod', 'zmm_modelyear', 'zmm_performance_factor', 'zqmm_qty', 'zmm_operating_temperature', 'zmm_axial_force']; @@ -3579,7 +3883,7 @@ class CharacteristicsController extends Controller } elseif (! preg_match('/^[1-9][a-zA-Z0-9]{8,}$/', $serialNumber)) { return response()->json([ 'status_code' => 'ERROR', - 'status_description' => "Serial number '{$serialNumber}' should not begin with '0'!", + 'status_description' => "Serial number '{$serialNumber}' should not begin with '0' or letter!", ], 404); } @@ -3746,7 +4050,7 @@ class CharacteristicsController extends Controller // ], 404); // } - // $columnsToShow = ['mark_status', 'marked_datetime', 'marked_physical_count', 'marked_expected_time', 'marked_by', 'man_marked_status', 'man_marked_datetime', 'man_marked_by', 'motor_marked_status', 'motor_marked_physical_count', 'motor_expected_time', 'motor_marked_by', 'pump_marked_status', 'pump_marked_physical_count', 'pump_expected_time', 'pump_marked_by', 'name_plate_marked_status', 'name_plate_expected_time', 'name_plate_marked_by', 'motor_pump_pumpset_status', 'winded_serial_number', 'motor_machine_name', 'pump_machine_name', 'name_plate_machine_name', 'part_validation_1', 'part_validation_2', 'samlight_logged_name', 'pending_released_status', 'has_work_flow_id']; + // $columnsToShow = ['mark_status', 'marked_datetime', 'marked_physical_count', 'marked_expected_time', 'marked_by', 'man_marked_status', 'man_marked_datetime', 'man_marked_by', 'motor_marked_status', 'motor_marked_physical_count', 'motor_expected_time', 'motor_marked_by', 'pump_marked_status', 'pump_marked_physical_count', 'pump_expected_time', 'pump_marked_by', 'name_plate_marked_status', 'name_plate_expected_time', 'name_plate_marked_by', 'motor_pump_pumpset_status', 'winded_serial_number', 'motor_machine_name', 'pump_machine_name', 'name_plate_machine_name', 'part_validation_1', 'part_validation_2', 'samlight_logged_name', 'pending_released_status', 'has_work_flow_id', 'motor_stop_flow_id', 'pump_stop_flow_id', 'name_plate_stop_flow_id']; // $characteristicsColumns = ['class', 'arbid', 'gamng', 'lmnga', 'zz1_cn_bill_ord', 'zmm_amps', 'zmm_brand', 'zmm_degreeofprotection', 'zmm_delivery', 'zmm_dir_rot', 'zmm_discharge', 'zmm_discharge_max', 'zmm_discharge_min', 'zmm_duty', 'zmm_eff_motor', 'zmm_eff_pump', 'zmm_frequency', 'zmm_head', 'zmm_heading', 'zmm_head_max', 'zmm_head_minimum', 'zmm_idx_eff_mtr', 'zmm_idx_eff_pump', 'zmm_kvacode', 'zmm_maxambtemp', 'zmm_mincoolingflow', 'zmm_motorseries', 'zmm_motor_model', 'zmm_outlet', 'zmm_phase', 'zmm_pressure', 'zmm_pumpflowtype', 'zmm_pumpseries', 'zmm_pump_model', 'zmm_ratedpower', 'zmm_region', 'zmm_servicefactor', 'zmm_servicefactormaximumamps', 'zmm_speed', 'zmm_suction', 'zmm_suctionxdelivery', 'zmm_supplysource', 'zmm_temperature', 'zmm_thrustload', 'zmm_volts', 'zmm_wire', 'zmm_package', 'zmm_pvarrayrating', 'zmm_isi', 'zmm_isimotor', 'zmm_isipump', 'zmm_isipumpset', 'zmm_pumpset_model', 'zmm_stages', 'zmm_headrange', 'zmm_overall_efficiency', 'zmm_connection', 'zmm_min_bore_size', 'zmm_isireference', 'zmm_category', 'zmm_submergence', 'zmm_capacitorstart', 'zmm_capacitorrun', 'zmm_inch', 'zmm_motor_type', 'zmm_dismantle_direction', 'zmm_eff_ovrall', 'zmm_bodymoc', 'zmm_rotormoc', 'zmm_dlwl', 'zmm_inputpower', 'zmm_imp_od', 'zmm_ambtemp', 'zmm_de', 'zmm_dischargerange', 'zmm_efficiency_class', 'zmm_framesize', 'zmm_impellerdiameter', 'zmm_insulationclass', 'zmm_maxflow', 'zmm_minhead', 'zmm_mtrlofconst', 'zmm_nde', 'zmm_powerfactor', 'zmm_tagno', 'zmm_year', 'zmm_laser_name', 'zmm_logo_cp', 'zmm_logo_ce', 'zmm_logo_nsf', 'zmm_logo_eac', 'zmm_beenote', 'zmm_beenumber', 'zmm_beestar', 'zmm_codeclass', 'zmm_colour', 'zmm_grade', 'zmm_grwt_pset', 'zmm_grwt_cable', 'zmm_grwt_motor', 'zmm_grwt_pf', 'zmm_grwt_pump', 'zmm_isivalve', 'zmm_isi_wc', 'zmm_labelperiod', 'zmm_length', 'zmm_license_cml_no', 'zmm_mfgmonyr', 'zmm_modelyear', 'zmm_motoridentification', 'zmm_newt_pset', 'zmm_newt_cable', 'zmm_newt_motor', 'zmm_newt_pf', 'zmm_newt_pump', 'zmm_packtype', 'zmm_panel', 'zmm_performance_factor', 'zmm_pumpidentification', 'zmm_psettype', 'zmm_size', 'zmm_eff_ttl', 'zmm_type', 'zmm_usp', 'zmm_operating_range', 'zmm_intake_air', 'zmm_oxygen_transfer_rate', 'zmm_air_inlet_pipesize', 'zmm_sump_depth', 'zmm_poles', 'zmm_motor_heading', 'zmm_motor_speed', 'zqmm_qty', 'zmm_operating_temperature', 'zmm_axial_force']; @@ -3794,6 +4098,9 @@ class CharacteristicsController extends Controller 'PENDING_RELEASED_STATUS' => (string) $serialExists->pending_released_status ?? '0', 'SAMLIGHT_LOGGED_NAME' => $serialExists->samlight_logged_name ?? '', 'HAS_WORK_FLOW_ID' => $serialExists->has_work_flow_id ?? '0', + 'MOTOR_STOP_FLOW_ID' => $serialExists->motor_stop_flow_id ?? '5', + 'PUMP_STOP_FLOW_ID' => $serialExists->pump_stop_flow_id ?? '5', + 'NAME_PLATE_STOP_FLOW_ID' => $serialExists->name_plate_stop_flow_id ?? '5', ], 200); } } @@ -5362,6 +5669,7 @@ class CharacteristicsController extends Controller $workCenter = $request->header('work-center'); $machineName = $request->header('machine-name'); $jobNo = $request->header('aufnr'); + $serialNo = $request->header('gernr'); $itemCode = $request->header('item-code'); $workFlowId = $request->header('work-flow-id'); $workFlowId = strtoupper($workFlowId); @@ -5369,7 +5677,7 @@ class CharacteristicsController extends Controller $modelHeading = $request->header('model-heading'); $requestType = $request->header('request-type'); - Log::info("Request {$requestType} POST API >>", ['user-name' => $userName, 'characteristic-field' => $charField, 'plant-code' => $plantCode, 'work-center' => $workCenter, 'machine-name' => $machineName, 'aufnr' => $jobNo, 'item-code' => $itemCode, 'work-flow-id' => $workFlowId]); + Log::info("Request {$requestType} POST API >>", ['user-name' => $userName, 'characteristic-field' => $charField, 'plant-code' => $plantCode, 'work-center' => $workCenter, 'machine-name' => $machineName, 'aufnr' => $jobNo, 'gernr' => $serialNo, 'item-code' => $itemCode, 'work-flow-id' => $workFlowId]); if (! $userName || $userName == null || $userName == '') { return response()->json([ @@ -5380,7 +5688,17 @@ class CharacteristicsController extends Controller $userName = 'Admin'; } - if (! $plantCode || $plantCode == null || $plantCode == '') { + if (! $requestType || $requestType == null || $requestType == '') { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Request type can't be empty!", + ], 404); + } elseif ($requestType != 'Characteristic' && $requestType != 'Quality' && $requestType != 'Stop') { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Unknown request type '{$requestType}' found!", + ], 404); + } elseif (! $plantCode || $plantCode == null || $plantCode == '') { return response()->json([ 'status_code' => 'ERROR', 'status_description' => "Plant code can't be empty!", @@ -5400,6 +5718,11 @@ class CharacteristicsController extends Controller 'status_code' => 'ERROR', 'status_description' => "Job number can't be empty!", ], 404); + } elseif ($requestType == 'Stop' && (! $serialNo || $serialNo == null || $serialNo == '')) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Serial number can't be empty!", + ], 404); } elseif (! $machineName || $machineName == null || $machineName == '') { return response()->json([ 'status_code' => 'ERROR', @@ -5415,11 +5738,6 @@ class CharacteristicsController extends Controller 'status_code' => 'ERROR', 'status_description' => "Model heading can't be empty!", ], 404); - } elseif (! $requestType || $requestType == null || $requestType == '') { - return response()->json([ - 'status_code' => 'ERROR', - 'status_description' => "Request type can't be empty!", - ], 404); } if ($charField == null || $charField == '' || $charField == 'nil') { @@ -5484,11 +5802,23 @@ class CharacteristicsController extends Controller ], 404); } - if ($requestType != 'Characteristic' && $requestType != 'Quality') { - return response()->json([ - 'status_code' => 'ERROR', - 'status_description' => "Unknown request type '{$requestType}' found!", - ], 404); + if ($requestType == 'Stop') { + if (Str::length($serialNo) < 9) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Serial number '{$serialNo}' should contain minimum 9 digits!", + ], 404); + } elseif (! ctype_alnum($serialNo)) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Serial number '{$serialNo}' should contain only alpha-numeric values!", + ], 404); + } elseif (! preg_match('/^[1-9][a-zA-Z0-9]{8,}$/', $serialNo)) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Serial number '{$serialNo}' should not begin with '0' or letter!", + ], 404); + } } if ($modelType != 'MOTOR' && $modelType != 'PUMP' && $modelType != 'NAME_PLATE') { @@ -5736,6 +6066,48 @@ class CharacteristicsController extends Controller ], 404); } + if ($requestType == 'Stop') { + $serial = RequestCharacteristic::where('gernr', $serialNo)->first(); + if (! $serial) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Serial number '{$serialNo}' not found in request approval table!", + ], 404); + } + + $serAgaJob = RequestCharacteristic::where('gernr', $serialNo)->where('plant_id', $plantId)->first(); + if (! $serAgaJob) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Serial number '{$serialNo}' not found for the plant code '{$plantCode}' in request approval table!", + ], 404); + } + + $serAgaPlant = RequestCharacteristic::where('gernr', $serialNo)->where('aufnr', $jobNo)->where('plant_id', $plantId)->first(); + if (! $serAgaPlant) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Serial number '{$serialNo}' not found with the job number '{$jobNo}' in request approval table!", + ], 404); + } + + $serAgaPlantItem = RequestCharacteristic::where('gernr', $serialNo)->where('aufnr', $jobNo)->where('item_id', $itemId)->where('plant_id', $plantId)->first(); + if (! $serAgaPlantItem) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Serial number '{$serialNo}' not found with the item code '{$itemCode}' in request approval table!", + ], 404); + } + + $serAgaPlantMachine = RequestCharacteristic::where('gernr', $serialNo)->where('aufnr', $jobNo)->where('item_id', $itemId)->where('machine_id', $machineId)->where('plant_id', $plantId)->first(); + if (! $serAgaPlantMachine) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Job number '$jobNo' not found for the work center '$workCenter' in request approval table!", + ], 404); + } + } + if ($requestType == 'Characteristic') { $appTypExist = CharacteristicApproverMaster::where('characteristic_field', $charField)->where('approver_type', $requestType)->where('machine_name', $machineName)->where('machine_id', $machineId)->where('plant_id', $plantId)->first(); if (! $appTypExist) { @@ -5766,6 +6138,8 @@ class CharacteristicsController extends Controller ], 404); } + $existApprTyp = $charWfIdExist->characteristicApproverMaster->approver_type ?? null; + $charWfIdExist = RequestCharacteristic::where('work_flow_id', $workFlowId) ->whereHas('approver', function ($query) use ($requestType) { $query->where('approver_type', $requestType); @@ -5774,11 +6148,11 @@ class CharacteristicsController extends Controller if (! $charWfIdExist) { return response()->json([ 'status_code' => 'ERROR', - 'status_description' => "Quality approval Work Flow ID : '{$workFlowId}' found!", + 'status_description' => "{$existApprTyp} approval Work Flow ID : '{$workFlowId}' found!", ], 404); } } - } else { + } elseif ($requestType == 'Quality') { $appTypExist = CharacteristicApproverMaster::where('characteristic_field', $charField)->where('approver_type', $requestType)->where('machine_name', $machineName)->where('machine_id', $machineId)->where('plant_id', $plantId)->first(); if (! $appTypExist) { return response()->json([ @@ -5808,6 +6182,8 @@ class CharacteristicsController extends Controller ], 404); } + $existApprTyp = $qualWfIdExist->characteristicApproverMaster->approver_type ?? null; + $qualWfIdExist = RequestCharacteristic::where('work_flow_id', $workFlowId) ->whereHas('approver', function ($query) use ($requestType) { $query->where('approver_type', $requestType); @@ -5816,7 +6192,51 @@ class CharacteristicsController extends Controller if (! $qualWfIdExist) { return response()->json([ 'status_code' => 'ERROR', - 'status_description' => "Characteristic approval Work Flow ID : '{$workFlowId}' found!", + 'status_description' => "{$existApprTyp} approval Work Flow ID : '{$workFlowId}' found!", + ], 404); + } + } + } else { + $appTypExist = CharacteristicApproverMaster::where('characteristic_field', $charField)->where('approver_type', $requestType)->where('machine_name', $machineName)->where('machine_id', $machineId)->where('plant_id', $plantId)->first(); + if (! $appTypExist) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Master characteristic field value '{$charField}', work center '{$workCenter}', machine name '{$machineName}', and plant code '{$plantCode}' not found for the approver type 'Stop' in approver master!", + ], 404); + } + + $reqCharExist = RequestCharacteristic::where('gernr', $serialNo)->where('aufnr', $jobNo)->where('item_id', $itemId)->where('model_type', $modelType) + ->whereHas('approver', function ($query) use ($requestType) { + $query->where('approver_type', $requestType); + })->where('machine_id', $machineId)->where('plant_id', $plantId)->first(); + + if (! $reqCharExist) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Request stop approvals not found for the Job number '{$jobNo}', item code '{$itemCode}', work center '{$workCenter}', model type '{$modelType}' and plant code '{$plantCode}'!", + ], 404); + } + + if ($workFlowId && $workFlowId != 'FINAL') { + $qualWfIdExist = RequestCharacteristic::where('work_flow_id', $workFlowId)->first(); + if (! $qualWfIdExist) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Stop approval 'Work Flow ID' not found in database!", + ], 404); + } + + $existApprTyp = $qualWfIdExist->characteristicApproverMaster->approver_type ?? null; + + $qualWfIdExist = RequestCharacteristic::where('work_flow_id', $workFlowId) + ->whereHas('approver', function ($query) use ($requestType) { + $query->where('approver_type', $requestType); + }) + ->first(); + if (! $qualWfIdExist) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "{$existApprTyp} approval Work Flow ID : '{$workFlowId}' found!", ], 404); } } @@ -5824,62 +6244,124 @@ class CharacteristicsController extends Controller $classRow = ClassCharacteristic::where('aufnr', $jobNo)->where('machine_id', $machineId)->where('plant_id', $plantId)->latest()->first(); + if ($requestType == 'Stop') { + $classRow = ClassCharacteristic::where('gernr', $serialNo)->where('aufnr', $jobNo)->where('machine_id', $machineId)->where('plant_id', $plantId)->latest()->first(); + } + if ($classRow) { - $requestChars = RequestCharacteristic::where('aufnr', $jobNo) - ->whereHas('approver', function ($query) { - $query->where('approver_type', 'Characteristic'); - })->where('machine_id', $machineId)->where('plant_id', $plantId)->get(); + if ($requestType == 'Stop') { + $requestStop = RequestCharacteristic::where('gernr', $serialNo)->where('aufnr', $jobNo)->where('item_id', $itemId)->where('model_type', $modelType) + ->whereHas('approver', function ($query) { + $query->where('approver_type', 'Stop'); + })->where('machine_id', $machineId)->where('plant_id', $plantId)->latest()->first(); - $requestQual = RequestCharacteristic::where('aufnr', $jobNo)->where('item_id', $itemId)->where('model_type', $modelType) - ->whereHas('approver', function ($query) { - $query->where('approver_type', 'Quality'); - })->where('machine_id', $machineId)->where('plant_id', $plantId)->orderBy('id')->get(); + if ($requestStop) { + $stopFlowStatus = ($requestStop->approver_status1 == 'Approved' || $requestStop->approver_status2 == 'Approved' || $requestStop->approver_status3 == 'Approved') ? '0' : '1'; - foreach ($requestQual as $row) { - $workFlowStatus = ($row->approver_status1 == 'Approved' || $row->approver_status2 == 'Approved' || $row->approver_status3 == 'Approved') ? '0' : '1'; + $classModelType = strtolower($modelType).'_stop_flow_id'; - TempClassCharacteristic::where('aufnr', $jobNo)->where('model_type', $modelType)->where('machine_id', $machineId)->where('plant_id', $plantId) - ->update([ - 'has_work_flow_id' => $workFlowStatus, - 'updated_by' => $userName, - ]); - } - - $tempClassChars = TempClassCharacteristic::where('aufnr', $jobNo)->where('machine_id', $machineId)->where('plant_id', $plantId)->get(); - - if (! $requestChars->isEmpty()) { - $hasCharPending = false; - $hasQualPending = false; - $allCharApproved = true; - $allQualApproved = true; - - foreach ($requestChars as $row) { - $isApproved = ($row->approver_status1 == 'Approved' || $row->approver_status1 == 'Rejected' || $row->approver_status2 == 'Approved' || $row->approver_status2 == 'Rejected' || $row->approver_status3 == 'Approved' || $row->approver_status3 == 'Rejected'); - - if (! $isApproved) { - $allCharApproved = false; - $hasCharPending = true; - break; - } - } - - if ($hasCharPending) { - $newValue = '3'; - TempClassCharacteristic::where('aufnr', $jobNo)->where('machine_id', $machineId)->where('plant_id', $plantId)->forceDelete(); - - foreach ($typesToCreate as $type) { - TempClassCharacteristic::create([ - 'plant_id' => $plantId, - 'machine_id' => $machineId, - 'item_id' => $itemId, - 'aufnr' => $jobNo, - 'model_type' => $type, - 'has_work_flow_id' => '2', - 'created_by' => $userName, + TempStopCharacteristic::where('gernr', $serialNo)->where('aufnr', $jobNo)->where('model_type', $modelType)->where('machine_id', $machineId)->where('plant_id', $plantId) + ->update([ + 'has_stop_flow_id' => $stopFlowStatus, 'updated_by' => $userName, ]); + + $classStopFlowStatus = ($stopFlowStatus == '0') ? '1' : '2'; + + ClassCharacteristic::where('gernr', $serialNo)->where('aufnr', $jobNo)->where('machine_id', $machineId)->where('plant_id', $plantId) + ->update([ + $classModelType => $classStopFlowStatus, + 'updated_at' => now(), + 'updated_by' => $userName, + ]); + } + } else { + $requestChars = RequestCharacteristic::where('aufnr', $jobNo) + ->whereHas('approver', function ($query) { + $query->where('approver_type', 'Characteristic'); + })->where('machine_id', $machineId)->where('plant_id', $plantId)->get(); + + $requestQual = RequestCharacteristic::where('aufnr', $jobNo)->where('item_id', $itemId)->where('model_type', $modelType) + ->whereHas('approver', function ($query) { + $query->where('approver_type', 'Quality'); + })->where('machine_id', $machineId)->where('plant_id', $plantId)->latest()->first(); + + if ($requestQual) { + $workFlowStatus = ($requestQual->approver_status1 == 'Approved' || $requestQual->approver_status2 == 'Approved' || $requestQual->approver_status3 == 'Approved') ? '0' : '1'; + + TempClassCharacteristic::where('aufnr', $jobNo)->where('model_type', $modelType)->where('machine_id', $machineId)->where('plant_id', $plantId) + ->update([ + 'has_work_flow_id' => $workFlowStatus, + 'updated_by' => $userName, + ]); + } + + $tempClassChars = TempClassCharacteristic::where('aufnr', $jobNo)->where('machine_id', $machineId)->where('plant_id', $plantId)->get(); + + if (! $requestChars->isEmpty()) { + $hasCharPending = false; + $hasQualPending = false; + $allCharApproved = true; + $allQualApproved = true; + + foreach ($requestChars as $row) { + $isApproved = ($row->approver_status1 == 'Approved' || $row->approver_status1 == 'Rejected' || $row->approver_status2 == 'Approved' || $row->approver_status2 == 'Rejected' || $row->approver_status3 == 'Approved' || $row->approver_status3 == 'Rejected'); + + if (! $isApproved) { + $allCharApproved = false; + $hasCharPending = true; + break; + } } + + if ($hasCharPending) { + $newValue = '3'; + TempClassCharacteristic::where('aufnr', $jobNo)->where('machine_id', $machineId)->where('plant_id', $plantId)->forceDelete(); + + foreach ($typesToCreate as $type) { + TempClassCharacteristic::create([ + 'plant_id' => $plantId, + 'machine_id' => $machineId, + 'item_id' => $itemId, + 'aufnr' => $jobNo, + 'model_type' => $type, + 'has_work_flow_id' => '2', + 'created_by' => $userName, + 'updated_by' => $userName, + ]); + } + } elseif (! $tempClassChars->isEmpty()) { + foreach ($tempClassChars as $temp) { + if ($temp->has_work_flow_id == '1' || $temp->has_work_flow_id == '2') { + $hasQualPending = true; + $allQualApproved = false; + break; + } + + if ($temp->has_work_flow_id == '0') { + $allQualApproved = true; + } + } + + if ($hasQualPending) { + $newValue = '2'; + } elseif ($allQualApproved) { + $newValue = '0'; + } + } elseif ($allCharApproved) { + $newValue = '0'; + } + + ClassCharacteristic::where('aufnr', $jobNo)->where('machine_id', $machineId)->where('plant_id', $plantId) + ->update([ + 'has_work_flow_id' => $newValue, + 'updated_at' => now(), + 'updated_by' => $userName, + ]); } elseif (! $tempClassChars->isEmpty()) { + $hasQualPending = false; + $allQualApproved = true; + foreach ($tempClassChars as $temp) { if ($temp->has_work_flow_id == '1' || $temp->has_work_flow_id == '2') { $hasQualPending = true; @@ -5897,105 +6379,92 @@ class CharacteristicsController extends Controller } elseif ($allQualApproved) { $newValue = '0'; } - } elseif ($allCharApproved) { - $newValue = '0'; - } - ClassCharacteristic::where('aufnr', $jobNo)->where('machine_id', $machineId)->where('plant_id', $plantId) - ->update([ - 'has_work_flow_id' => $newValue, - 'updated_at' => now(), - 'updated_by' => $userName, - ]); - } elseif (! $tempClassChars->isEmpty()) { - $hasQualPending = false; - $allQualApproved = true; - - foreach ($tempClassChars as $temp) { - if ($temp->has_work_flow_id == '1' || $temp->has_work_flow_id == '2') { - $hasQualPending = true; - $allQualApproved = false; - break; - } - - if ($temp->has_work_flow_id == '0') { - $allQualApproved = true; - } - } - - if ($hasQualPending) { - $newValue = '2'; - } elseif ($allQualApproved) { - $newValue = '0'; - } - - ClassCharacteristic::where('aufnr', $jobNo)->where('machine_id', $machineId)->where('plant_id', $plantId) - ->update([ - 'has_work_flow_id' => $newValue, - 'updated_at' => now(), - 'updated_by' => $userName, - ]); - } else { - ClassCharacteristic::where('aufnr', $jobNo)->where('machine_id', $machineId)->where('plant_id', $plantId) - ->update([ - 'has_work_flow_id' => '0', - 'updated_at' => now(), - 'updated_by' => $userName, - ]); - } - } else { - $requestChars = RequestCharacteristic::where('aufnr', $jobNo) - ->whereHas('approver', function ($query) { - $query->where('approver_type', 'Characteristic'); - })->where('machine_id', $machineId)->where('plant_id', $plantId)->get(); - - $requestQual = RequestCharacteristic::where('aufnr', $jobNo)->where('item_id', $itemId)->where('model_type', $modelType) - ->whereHas('approver', function ($query) { - $query->where('approver_type', 'Quality'); - })->where('machine_id', $machineId)->where('plant_id', $plantId)->orderBy('id')->get(); - - foreach ($requestQual as $row) { - $workFlowStatus = ($row->approver_status1 == 'Approved' || $row->approver_status2 == 'Approved' || $row->approver_status3 == 'Approved') ? '0' : '1'; - - TempClassCharacteristic::where('aufnr', $jobNo)->where('model_type', $modelType)->where('machine_id', $machineId)->where('plant_id', $plantId) - ->update([ - 'has_work_flow_id' => $workFlowStatus, - 'updated_by' => $userName, - ]); - } - - if (! $requestChars->isEmpty()) { - $hasCharPending = false; - - foreach ($requestChars as $row) { - $isApproved = ($row->approver_status1 == 'Approved' || $row->approver_status1 == 'Rejected' || $row->approver_status2 == 'Approved' || $row->approver_status2 == 'Rejected' || $row->approver_status3 == 'Approved' || $row->approver_status3 == 'Rejected'); - - if (! $isApproved) { - $hasCharPending = true; - break; - } - } - - if ($hasCharPending) { - TempClassCharacteristic::where('aufnr', $jobNo)->where('machine_id', $machineId)->where('plant_id', $plantId)->forceDelete(); - - foreach ($typesToCreate as $type) { - TempClassCharacteristic::create([ - 'plant_id' => $plantId, - 'machine_id' => $machineId, - 'item_id' => $itemId, - 'aufnr' => $jobNo, - 'model_type' => $type, - 'has_work_flow_id' => '2', - 'created_by' => $userName, + ClassCharacteristic::where('aufnr', $jobNo)->where('machine_id', $machineId)->where('plant_id', $plantId) + ->update([ + 'has_work_flow_id' => $newValue, + 'updated_at' => now(), 'updated_by' => $userName, ]); + } else { + ClassCharacteristic::where('aufnr', $jobNo)->where('machine_id', $machineId)->where('plant_id', $plantId) + ->update([ + 'has_work_flow_id' => '0', + 'updated_at' => now(), + 'updated_by' => $userName, + ]); + } + } + } else { + if ($requestType == 'Stop') { + $requestStop = RequestCharacteristic::where('gernr', $serialNo)->where('aufnr', $jobNo)->where('item_id', $itemId)->where('model_type', $modelType) + ->whereHas('approver', function ($query) { + $query->where('approver_type', 'Stop'); + })->where('machine_id', $machineId)->where('plant_id', $plantId)->latest()->first(); + + if ($requestStop) { + $stopFlowStatus = ($requestStop->approver_status1 == 'Approved' || $requestStop->approver_status2 == 'Approved' || $requestStop->approver_status3 == 'Approved') ? '0' : '1'; + + TempStopCharacteristic::where('gernr', $serialNo)->where('aufnr', $jobNo)->where('model_type', $modelType)->where('machine_id', $machineId)->where('plant_id', $plantId) + ->update([ + 'has_stop_flow_id' => $stopFlowStatus, + 'updated_by' => $userName, + ]); + } + } else { + $requestChars = RequestCharacteristic::where('aufnr', $jobNo) + ->whereHas('approver', function ($query) { + $query->where('approver_type', 'Characteristic'); + })->where('machine_id', $machineId)->where('plant_id', $plantId)->get(); + + $requestQual = RequestCharacteristic::where('aufnr', $jobNo)->where('item_id', $itemId)->where('model_type', $modelType) + ->whereHas('approver', function ($query) { + $query->where('approver_type', 'Quality'); + })->where('machine_id', $machineId)->where('plant_id', $plantId)->latest()->first(); + + if ($requestQual) { + $workFlowStatus = ($requestQual->approver_status1 == 'Approved' || $requestQual->approver_status2 == 'Approved' || $requestQual->approver_status3 == 'Approved') ? '0' : '1'; + + TempClassCharacteristic::where('aufnr', $jobNo)->where('model_type', $modelType)->where('machine_id', $machineId)->where('plant_id', $plantId) + ->update([ + 'has_work_flow_id' => $workFlowStatus, + 'updated_by' => $userName, + ]); + } + + if (! $requestChars->isEmpty()) { + $hasCharPending = false; + + foreach ($requestChars as $row) { + $isApproved = ($row->approver_status1 == 'Approved' || $row->approver_status1 == 'Rejected' || $row->approver_status2 == 'Approved' || $row->approver_status2 == 'Rejected' || $row->approver_status3 == 'Approved' || $row->approver_status3 == 'Rejected'); + + if (! $isApproved) { + $hasCharPending = true; + break; + } + } + + if ($hasCharPending) { + TempClassCharacteristic::where('aufnr', $jobNo)->where('machine_id', $machineId)->where('plant_id', $plantId)->forceDelete(); + + foreach ($typesToCreate as $type) { + TempClassCharacteristic::create([ + 'plant_id' => $plantId, + 'machine_id' => $machineId, + 'item_id' => $itemId, + 'aufnr' => $jobNo, + 'model_type' => $type, + 'has_work_flow_id' => '2', + 'created_by' => $userName, + 'updated_by' => $userName, + ]); + } } } } } - if (! $workFlowId) { + if (! $workFlowId || $workFlowId == 'FINAL') { $records = null; if ($requestType == 'Characteristic') { @@ -6003,87 +6472,152 @@ class CharacteristicsController extends Controller ->whereHas('approver', function ($query) use ($requestType) { $query->where('approver_type', $requestType); })->where('machine_id', $machineId)->where('plant_id', $plantId)->orderBy('id')->get(); - } else { + } elseif ($requestType == 'Quality') { $records = RequestCharacteristic::where('aufnr', $jobNo)->where('item_id', $itemId)->where('model_type', $modelType) ->whereHas('approver', function ($query) use ($requestType) { $query->where('approver_type', $requestType); })->where('machine_id', $machineId)->where('plant_id', $plantId)->orderBy('id')->get(); + } elseif ($requestType == 'Stop') { + if ($workFlowId == 'FINAL') { + $records = RequestCharacteristic::where('gernr', $serialNo)->where('aufnr', $jobNo)->where('item_id', $itemId)->where('model_type', $modelType) + ->whereHas('approver', function ($query) use ($requestType) { + $query->where('approver_type', $requestType); + })->where('machine_id', $machineId)->where('plant_id', $plantId)->latest() + ->first(); + } else { + $records = RequestCharacteristic::where('gernr', $serialNo)->where('aufnr', $jobNo)->where('item_id', $itemId)->where('model_type', $modelType) + ->whereHas('approver', function ($query) use ($requestType) { + $query->where('approver_type', $requestType); + })->where('machine_id', $machineId)->where('plant_id', $plantId)->orderBy('id')->get(); + } } $response = []; - foreach ($records as $row) { - if ($requestType == 'Characteristic') { - $workFlowStatus = ($row->approver_status1 == 'Approved' || $row->approver_status2 == 'Approved' || $row->approver_status3 == 'Approved' || $row->approver_status1 == 'Rejected' || $row->approver_status2 == 'Rejected' || $row->approver_status3 == 'Rejected') ? '0' : '1'; + if ($workFlowId == 'FINAL') { + $workFlowStatus = ($records->approver_status1 == 'Approved' || $records->approver_status2 == 'Approved' || $records->approver_status3 == 'Approved') ? '0' : '1'; - // if ($row->approver?->approver_type != 'Characteristic' || ! $row->characteristic_name) { - // continue; - // } + $response[] = [ + 'work_flow_id' => (string) $records->work_flow_id, + 'work_flow_status' => $workFlowStatus, + 'model_type' => strtoupper($records->model_type) ?? '', + // 'approver_name_1' => $records->approver_name1 ?? '', + 'approver_name_1' => $records->approver?->name1 ?? '', + 'approver_status_1' => $records->approver_status1 ?? '', + 'approver_remark_1' => $records->approver_remark1 ?? '', + 'approved_at_1' => $records->approved1_at ?? '', // ? $records->approved1_at->format('d-m-Y H:i:s') : '', + 'approver_name_2' => $records->approver?->name2 ?? '', + 'approver_status_2' => $records->approver_status2 ?? '', + 'approver_remark_2' => $records->approver_remark2 ?? '', + 'approved_at_2' => $records->approved2_at ?? '', + 'approver_name_3' => $records->approver?->name3 ?? '', + 'approver_status_3' => $records->approver_status3 ?? '', + 'approver_remark_3' => $records->approver_remark3 ?? '', + 'approved_at_3' => $records->approved3_at ?? '', + 'mail_status' => ($records->mail_status == 'Sent') ? 'Sent-M1' : (($records->mail_status == 'Sent-Mail2') ? 'Sent-M2' : (($records->mail_status == 'Sent-Mail3') ? 'Sent-M3' : '-')), + 'triggered_at' => $records->trigger_at ?? '', + 'requested_by' => ($records->created_by == 'Admin') ? 'jothi' : $records->created_by ?? '', + 'requested_at' => $records->created_at ? $records->created_at->format('Y-m-d H:i:s') : '', + ]; + } else { + foreach ($records as $row) { + if ($requestType == 'Characteristic') { + $workFlowStatus = ($row->approver_status1 == 'Approved' || $row->approver_status2 == 'Approved' || $row->approver_status3 == 'Approved' || $row->approver_status1 == 'Rejected' || $row->approver_status2 == 'Rejected' || $row->approver_status3 == 'Rejected') ? '0' : '1'; - $response[] = [ - 'work_flow_id' => (string) $row->work_flow_id, - 'work_flow_status' => $workFlowStatus, - 'model_type' => strtoupper($row->model_type) ?? '', - 'characteristic_name' => strtoupper($row->characteristic_name) ?? '', - 'current_value' => $row->current_value ?? '', - 'update_value' => $row->update_value ?? '', - // 'approver_name_1' => $row->approver_name1 ?? '', - 'approver_name_1' => $row->approver?->name1 ?? '', - 'approver_status_1' => $row->approver_status1 ?? '', - 'approver_remark_1' => $row->approver_remark1 ?? '', - 'approved_at_1' => $row->approved1_at ?? '', // ? $row->approved1_at->format('d-m-Y H:i:s') : '', - 'approver_name_2' => $row->approver?->name2 ?? '', - 'approver_status_2' => $row->approver_status2 ?? '', - 'approver_remark_2' => $row->approver_remark2 ?? '', - 'approved_at_2' => $row->approved2_at ?? '', // ? $row->approved2_at->format('d-m-Y H:i:s') : '', - 'approver_name_3' => $row->approver?->name3 ?? '', - 'approver_status_3' => $row->approver_status3 ?? '', - 'approver_remark_3' => $row->approver_remark3 ?? '', - 'approved_at_3' => $row->approved3_at ?? '', // ? $row->approved3_at->format('d-m-Y H:i:s') : '', - 'mail_status' => ($row->mail_status == 'Sent') ? 'Sent-M1' : (($row->mail_status == 'Sent-Mail2') ? 'Sent-M2' : (($row->mail_status == 'Sent-Mail3') ? 'Sent-M3' : '-')), - 'triggered_at' => $row->trigger_at ?? '', - 'requested_by' => ($row->created_by == 'Admin') ? 'jothi' : $row->created_by ?? '', - 'requested_at' => $row->created_at ? $row->created_at->format('Y-m-d H:i:s') : '', - ]; - } else { - $workFlowStatus = ($row->approver_status1 == 'Approved' || $row->approver_status2 == 'Approved' || $row->approver_status3 == 'Approved') ? '0' : '1'; + // if ($row->approver?->approver_type != 'Characteristic' || ! $row->characteristic_name) { + // continue; + // } - // / TempClassCharacteristic::where('aufnr', $jobNo)->where('model_type', $modelType)->where('machine_id', $machineId)->where('plant_id', $plantId) - // / ->update([ - // / 'has_work_flow_id' => $workFlowStatus, - // / 'updated_by' => $userName, - // / ]); + $response[] = [ + 'work_flow_id' => (string) $row->work_flow_id, + 'work_flow_status' => $workFlowStatus, + 'model_type' => strtoupper($row->model_type) ?? '', + 'characteristic_name' => strtoupper($row->characteristic_name) ?? '', + 'current_value' => $row->current_value ?? '', + 'update_value' => $row->update_value ?? '', + // 'approver_name_1' => $row->approver_name1 ?? '', + 'approver_name_1' => $row->approver?->name1 ?? '', + 'approver_status_1' => $row->approver_status1 ?? '', + 'approver_remark_1' => $row->approver_remark1 ?? '', + 'approved_at_1' => $row->approved1_at ?? '', // ? $row->approved1_at->format('d-m-Y H:i:s') : '', + 'approver_name_2' => $row->approver?->name2 ?? '', + 'approver_status_2' => $row->approver_status2 ?? '', + 'approver_remark_2' => $row->approver_remark2 ?? '', + 'approved_at_2' => $row->approved2_at ?? '', // ? $row->approved2_at->format('d-m-Y H:i:s') : '', + 'approver_name_3' => $row->approver?->name3 ?? '', + 'approver_status_3' => $row->approver_status3 ?? '', + 'approver_remark_3' => $row->approver_remark3 ?? '', + 'approved_at_3' => $row->approved3_at ?? '', // ? $row->approved3_at->format('d-m-Y H:i:s') : '', + 'mail_status' => ($row->mail_status == 'Sent') ? 'Sent-M1' : (($row->mail_status == 'Sent-Mail2') ? 'Sent-M2' : (($row->mail_status == 'Sent-Mail3') ? 'Sent-M3' : '-')), + 'triggered_at' => $row->trigger_at ?? '', + 'requested_by' => ($row->created_by == 'Admin') ? 'jothi' : $row->created_by ?? '', + 'requested_at' => $row->created_at ? $row->created_at->format('Y-m-d H:i:s') : '', + ]; + } elseif ($requestType == 'Quality') { + $workFlowStatus = ($row->approver_status1 == 'Approved' || $row->approver_status2 == 'Approved' || $row->approver_status3 == 'Approved') ? '0' : '1'; - if ($workFlowStatus == '1') { - $workFlowStatus = ($row->approver_status1 == 'Rejected' || $row->approver_status2 == 'Rejected' || $row->approver_status3 == 'Rejected') ? '2' : '1'; + // / TempClassCharacteristic::where('aufnr', $jobNo)->where('model_type', $modelType)->where('machine_id', $machineId)->where('plant_id', $plantId) + // / ->update([ + // / 'has_work_flow_id' => $workFlowStatus, + // / 'updated_by' => $userName, + // / ]); + + if ($workFlowStatus == '1') { + $workFlowStatus = ($row->approver_status1 == 'Rejected' || $row->approver_status2 == 'Rejected' || $row->approver_status3 == 'Rejected') ? '2' : '1'; + } + + // if ($row->approver?->approver_type != 'Quality' || $row->characteristic_name) { + // continue; + // } + + $response[] = [ + 'work_flow_id' => (string) $row->work_flow_id, + 'work_flow_status' => $workFlowStatus, + 'model_type' => strtoupper($row->model_type) ?? '', + // 'approver_name_1' => $row->approver_name1 ?? '', + 'approver_name_1' => $row->approver?->name1 ?? '', + 'approver_status_1' => $row->approver_status1 ?? '', + 'approver_remark_1' => $row->approver_remark1 ?? '', + 'approved_at_1' => $row->approved1_at ?? '', // ? $row->approved1_at->format('d-m-Y H:i:s') : '', + 'approver_name_2' => $row->approver?->name2 ?? '', + 'approver_status_2' => $row->approver_status2 ?? '', + 'approver_remark_2' => $row->approver_remark2 ?? '', + 'approved_at_2' => $row->approved2_at ?? '', // ? $row->approved2_at->format('d-m-Y H:i:s') : '', + 'approver_name_3' => $row->approver?->name3 ?? '', + 'approver_status_3' => $row->approver_status3 ?? '', + 'approver_remark_3' => $row->approver_remark3 ?? '', + 'approved_at_3' => $row->approved3_at ?? '', // ? $row->approved3_at->format('d-m-Y H:i:s') : '', + 'mail_status' => ($row->mail_status == 'Sent') ? 'Sent-M1' : (($row->mail_status == 'Sent-Mail2') ? 'Sent-M2' : (($row->mail_status == 'Sent-Mail3') ? 'Sent-M3' : '-')), + 'triggered_at' => $row->trigger_at ?? '', + 'requested_by' => ($row->created_by == 'Admin') ? 'jothi' : $row->created_by ?? '', + 'requested_at' => $row->created_at ? $row->created_at->format('Y-m-d H:i:s') : '', + ]; + } else { + $workFlowStatus = ($row->approver_status1 == 'Approved' || $row->approver_status2 == 'Approved' || $row->approver_status3 == 'Approved') ? '0' : '1'; + + $response[] = [ + 'work_flow_id' => (string) $row->work_flow_id, + 'work_flow_status' => $workFlowStatus, + 'model_type' => strtoupper($row->model_type) ?? '', + // 'approver_name_1' => $row->approver_name1 ?? '', + 'approver_name_1' => $row->approver?->name1 ?? '', + 'approver_status_1' => $row->approver_status1 ?? '', + 'approver_remark_1' => $row->approver_remark1 ?? '', + 'approved_at_1' => $row->approved1_at ?? '', // ? $row->approved1_at->format('d-m-Y H:i:s') : '', + 'approver_name_2' => $row->approver?->name2 ?? '', + 'approver_status_2' => $row->approver_status2 ?? '', + 'approver_remark_2' => $row->approver_remark2 ?? '', + 'approved_at_2' => $row->approved2_at ?? '', + 'approver_name_3' => $row->approver?->name3 ?? '', + 'approver_status_3' => $row->approver_status3 ?? '', + 'approver_remark_3' => $row->approver_remark3 ?? '', + 'approved_at_3' => $row->approved3_at ?? '', + 'mail_status' => ($row->mail_status == 'Sent') ? 'Sent-M1' : (($row->mail_status == 'Sent-Mail2') ? 'Sent-M2' : (($row->mail_status == 'Sent-Mail3') ? 'Sent-M3' : '-')), + 'triggered_at' => $row->trigger_at ?? '', + 'requested_by' => ($row->created_by == 'Admin') ? 'jothi' : $row->created_by ?? '', + 'requested_at' => $row->created_at ? $row->created_at->format('Y-m-d H:i:s') : '', + ]; } - - // if ($row->approver?->approver_type != 'Quality' || $row->characteristic_name) { - // continue; - // } - - $response[] = [ - 'work_flow_id' => (string) $row->work_flow_id, - 'work_flow_status' => $workFlowStatus, - 'model_type' => strtoupper($row->model_type) ?? '', - // 'approver_name_1' => $row->approver_name1 ?? '', - 'approver_name_1' => $row->approver?->name1 ?? '', - 'approver_status_1' => $row->approver_status1 ?? '', - 'approver_remark_1' => $row->approver_remark1 ?? '', - 'approved_at_1' => $row->approved1_at ?? '', // ? $row->approved1_at->format('d-m-Y H:i:s') : '', - 'approver_name_2' => $row->approver?->name2 ?? '', - 'approver_status_2' => $row->approver_status2 ?? '', - 'approver_remark_2' => $row->approver_remark2 ?? '', - 'approved_at_2' => $row->approved2_at ?? '', // ? $row->approved2_at->format('d-m-Y H:i:s') : '', - 'approver_name_3' => $row->approver?->name3 ?? '', - 'approver_status_3' => $row->approver_status3 ?? '', - 'approver_remark_3' => $row->approver_remark3 ?? '', - 'approved_at_3' => $row->approved3_at ?? '', // ? $row->approved3_at->format('d-m-Y H:i:s') : '', - 'mail_status' => ($row->mail_status == 'Sent') ? 'Sent-M1' : (($row->mail_status == 'Sent-Mail2') ? 'Sent-M2' : (($row->mail_status == 'Sent-Mail3') ? 'Sent-M3' : '-')), - 'triggered_at' => $row->trigger_at ?? '', - 'requested_by' => ($row->created_by == 'Admin') ? 'jothi' : $row->created_by ?? '', - 'requested_at' => $row->created_at ? $row->created_at->format('Y-m-d H:i:s') : '', - ]; } } @@ -6125,6 +6659,324 @@ class CharacteristicsController extends Controller } } + public function getLaserRequestStop(Request $request) + { + $expectedUser = env('API_AUTH_USER'); + $expectedPw = env('API_AUTH_PW'); + + $headerAuth = $request->header('Authorization'); + $expectedToken = 'Bearer '.$expectedUser.':'.$expectedPw; + + if ($headerAuth != $expectedToken) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => 'Invalid authorization token!', + ], 401); + } + + $userName = $request->header('user-name'); + $charField = $request->header('characteristic-field'); + $plantCode = $request->header('plant-code'); + $workCenter = $request->header('work-center'); + $machineName = $request->header('machine-name'); + $jobNo = $request->header('aufnr'); + $modelType = $request->header('model-type'); + $requestType = $request->header('request-type'); + + Log::info("Request {$requestType} GET API >>", ['user-name' => $userName, 'characteristic-field' => $charField, 'plant-code' => $plantCode, 'work-center' => $workCenter, 'machine-name' => $machineName]); + + if (! $userName || $userName == null || $userName == '') { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "User name can't be empty!", + ], 404); + } elseif ($userName == 'jothi') { + $userName = 'Admin'; + } + + if (! $plantCode || $plantCode == null || $plantCode == '') { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Plant code can't be empty!", + ], 404); + } elseif (! $workCenter || $workCenter == null || $workCenter == '') { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Work center can't be empty!", + ], 404); + } elseif (! $machineName || $machineName == null || $machineName == '') { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Machine name can't be empty!", + ], 404); + } elseif (! $jobNo || $jobNo == null || $jobNo == '') { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Job number can't be empty", + ], 404); + } elseif (! $modelType || $modelType == null || $modelType == '') { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Model type can't be empty!", + ], 404); + } elseif (! $requestType || $requestType == null || $requestType == '') { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Request type can't be empty!", + ], 404); + } + + if ($charField == null || $charField == '' || $charField == 'nil') { + $charField = 'NIL'; + } + + if (! is_numeric($plantCode)) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Plant code '{$plantCode}' should contain only numeric values!", + ], 400); + } elseif (Str::length($plantCode) < 4 || Str::length($plantCode) > 7) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Plant code '{$plantCode}' must be between 4 and 7 digits only!", + ], 400); + } elseif (! preg_match('/^[1-9]\d{3,6}$/', $plantCode)) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Invalid plant code '{$plantCode}' found!", + ], 400); + } + + if (Str::length($workCenter) < 6) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Work center '{$workCenter}' should contain minimum 6 characters!", + ], 404); + } elseif (! ctype_alnum($workCenter)) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Work center '{$workCenter}' should contain only alpha-numeric values!", + ], 404); + } + + if (Str::length($jobNo) < 7) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Job number '{$jobNo}' should contain minimum 7 digits!", + ], 404); + } elseif (! is_numeric($jobNo)) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Job number '{$jobNo}' should contain only numeric values!", + ], 404); + } elseif (! preg_match('/^[1-9]\d{6,}$/', $jobNo)) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Job number '{$jobNo}' should not begin with '0'!", + ], 404); + } + + if ($modelType != 'MOTOR' && $modelType != 'PUMP' && $modelType != 'NAME_PLATE') { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Unknown model type '{$modelType}' found!", + ], 404); + } + + if ($requestType != 'Stop') { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Unknown request type '{$requestType}' found!", + ], 404); + } + + $plant = Plant::where('code', $plantCode)->first(); + if (! $plant) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Plant code '{$plantCode}' not found in plants table!", + ], 404); + } + + $plantId = $plant->id; + + $user = User::where('name', $userName)->first(); + + if (! $user) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "User name '{$userName}' not found in users table!", + ], 404); + } + + $userPlant = User::where('name', $userName)->where('plant_id', $plantId)->first(); + + if (! $userPlant && ! $user->hasRole('Super Admin')) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "User name '{$userName}' not found for the plant code '{$plantCode}' in users table!", + ], 404); + } elseif (! $user->hasRole(['Super Admin', 'Laser Manager', 'Laser Supervisor', 'Laser Employee'])) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "User '{$userName}' does not have rights!", + ], 404); + } + + $machine = Machine::where('work_center', $workCenter)->first(); + if (! $machine) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Work center '{$workCenter}' not found in machines table!", + ], 404); + } + + $machine = Machine::where('work_center', $workCenter)->where('plant_id', $plantId)->first(); + if (! $machine) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Work center '{$workCenter}' not found for the plant code '{$plantCode}' in machines table!", + ], 404); + } + + $machineId = $machine->id; + + $pCode = CharacteristicApproverMaster::where('plant_id', $plantId)->first(); + if (! $pCode) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Plant code '{$plantCode}' not found in approver master!", + ], 404); + } + + $wCenter = CharacteristicApproverMaster::where('machine_id', $machineId)->first(); + if (! $wCenter) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Work center '{$workCenter}' not found in approver master!", + ], 404); + } + + $wCenterAgaPlant = CharacteristicApproverMaster::where('machine_id', $machineId)->where('plant_id', $plantId)->first(); + if (! $wCenterAgaPlant) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Work center '{$workCenter}' not found for the plant code '{$plantCode}' in approver master!", + ], 404); + } + + $mName = CharacteristicApproverMaster::where('machine_name', $machineName)->first(); + if (! $mName) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Machine name '{$machineName}' not found in approver master!", + ], 404); + } + + $mNameAgaPlant = CharacteristicApproverMaster::where('machine_name', $machineName)->where('plant_id', $plantId)->first(); + if (! $mNameAgaPlant) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Machine name '{$machineName}' not found for the plant code '{$plantCode}' in approver master!", + ], 404); + } + + $cField = CharacteristicApproverMaster::where('characteristic_field', $charField)->first(); + if (! $cField) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Master characteristic field value '{$charField}' not found in approver master!", + ], 404); + } + + // Master characteristic field value 'NIL' not found in approver master! + $cFieldAgaPlant = CharacteristicApproverMaster::where('characteristic_field', $charField)->where('plant_id', $plantId)->first(); + if (! $cFieldAgaPlant) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Master characteristic field value '{$charField}' not found for the plant code '{$plantCode}' in approver master!", + ], 404); + } + + $mNameAndWorkCenter = CharacteristicApproverMaster::where('machine_name', $machineName)->where('machine_id', $machineId)->first(); + if (! $mNameAndWorkCenter) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Machine name '{$machineName}' and work center '{$workCenter}' not found in approver master!", + ], 404); + } + + $mNameAndWorkCenterAgaPlant = CharacteristicApproverMaster::where('machine_name', $machineName)->where('machine_id', $machineId)->where('plant_id', $plantId)->first(); + if (! $mNameAndWorkCenterAgaPlant) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Machine name '{$machineName}' and work center '{$workCenter}' not found for the plant code '{$plantCode}' in approver master!", + ], 404); + } + + $cFieldAndWorkCent = CharacteristicApproverMaster::where('characteristic_field', $charField)->where('machine_id', $machineId)->first(); + if (! $cFieldAndWorkCent) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Master characteristic field value '{$charField}' not found for the work center '{$workCenter}' in approver master!", + ], 404); + } + + $cFieldAndWorkCentAgaPlant = CharacteristicApproverMaster::where('characteristic_field', $charField)->where('machine_id', $machineId)->where('plant_id', $plantId)->first(); + if (! $cFieldAndWorkCentAgaPlant) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Master characteristic field value '{$charField}' and work center '{$workCenter}' not found for the plant code '{$plantCode}' in approver master!", + ], 404); + } + + $cFieldAndMach = CharacteristicApproverMaster::where('characteristic_field', $charField)->where('machine_name', $machineName)->first(); + if (! $cFieldAndMach) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Master characteristic field value '{$charField}' not found for the machine name '{$machineName}' in approver master!", + ], 404); + } + + $cFieldAndMachAgaPlant = CharacteristicApproverMaster::where('characteristic_field', $charField)->where('machine_name', $machineName)->where('plant_id', $plantId)->first(); + if (! $cFieldAndMachAgaPlant) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Master characteristic field value '{$charField}' and machine name '{$machineName}' not found for the plant code '{$plantCode}' in approver master!", + ], 404); + } + + $cFieldAndWorkCentAndMachAgaPlant = CharacteristicApproverMaster::where('characteristic_field', $charField)->where('machine_name', $machineName)->where('machine_id', $machineId)->where('plant_id', $plantId)->first(); + if (! $cFieldAndWorkCentAndMachAgaPlant) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Master characteristic field value '{$charField}', work center '{$workCenter}', and machine name '{$machineName}' not found for the plant code '{$plantCode}' in approver master!", + ], 404); + } + + $appTypExist = CharacteristicApproverMaster::where('characteristic_field', $charField)->where('approver_type', $requestType)->where('machine_name', $machineName)->where('machine_id', $machineId)->where('plant_id', $plantId)->first(); + if (! $appTypExist) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Master characteristic field value '{$charField}', work center '{$workCenter}', machine name '{$machineName}', and plant code '{$plantCode}' not found for the approver type 'Stop' in approver master!", + ], 404); + } + + $classModelType = strtolower($modelType).'_stop_flow_id'; + + ClassCharacteristic::where('aufnr', $jobNo)->where('machine_id', $machineId)->where('plant_id', $plantId)->where($classModelType, '5') + ->update([ + $classModelType => '4', + 'updated_at' => now(), + 'updated_by' => $userName, + ]); + + return response()->json([ + 'status_code' => 'SUCCESS', + 'status_description' => "Has {$modelType} Approver Master!", + ], 200); + } + public function show(string $id) { // -- 2.49.1 From dd0668349eddac1c7c6abafa05aebc8f31407fc7 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Mon, 14 Sep 2026 14:17:07 +0530 Subject: [PATCH 10/18] Added zmm columns in item characteristics table --- ...mp_axial_force_to_item_characteristics.php | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 database/migrations/2026_09_14_140156_add_zmm_logo_eac_operating_temp_axial_force_to_item_characteristics.php diff --git a/database/migrations/2026_09_14_140156_add_zmm_logo_eac_operating_temp_axial_force_to_item_characteristics.php b/database/migrations/2026_09_14_140156_add_zmm_logo_eac_operating_temp_axial_force_to_item_characteristics.php new file mode 100644 index 0000000..1ac71a6 --- /dev/null +++ b/database/migrations/2026_09_14_140156_add_zmm_logo_eac_operating_temp_axial_force_to_item_characteristics.php @@ -0,0 +1,45 @@ + Date: Mon, 14 Sep 2026 14:17:54 +0530 Subject: [PATCH 11/18] Added columns in item characteristic model file --- app/Models/ItemCharacteristic.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/Models/ItemCharacteristic.php b/app/Models/ItemCharacteristic.php index 3c278ea..e15df77 100644 --- a/app/Models/ItemCharacteristic.php +++ b/app/Models/ItemCharacteristic.php @@ -142,6 +142,9 @@ class ItemCharacteristic extends Model 'zmm_motor_heading', 'zmm_motor_speed', 'zqmm_qty', + 'zmm_logo_eac', + 'zmm_operating_temperature', + 'zmm_axial_force', 'mrp', 'zmm_1', 'zmm_2', -- 2.49.1 From 6d3952dc7c41d2d0ab6b8e06579ea63124420171 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Mon, 14 Sep 2026 14:19:02 +0530 Subject: [PATCH 12/18] Added columns in item charcateristic resource page --- .../Resources/ItemCharacteristicResource.php | 904 +++++++++++++++--- 1 file changed, 757 insertions(+), 147 deletions(-) diff --git a/app/Filament/Resources/ItemCharacteristicResource.php b/app/Filament/Resources/ItemCharacteristicResource.php index 1354891..ef2936a 100644 --- a/app/Filament/Resources/ItemCharacteristicResource.php +++ b/app/Filament/Resources/ItemCharacteristicResource.php @@ -58,295 +58,893 @@ class ItemCharacteristicResource extends Resource }) ->required(), Forms\Components\TextInput::make('class') - ->label('CLASS'), + ->label('CLASS') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zz1_cn_bill_ord') - ->label('ZZ1 CN BILL ORD'), + ->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'), + ->label('ZMM AMPS') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_brand') - ->label('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 DEGREE OF PROTECTION'), + ->label('ZMM DEGREE OF PROTECTION') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_delivery') - ->label('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 DIRECTION ROTATION'), + ->label('ZMM DIRECTION ROTATION') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_discharge') - ->label('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'), + ->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'), + ->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'), + ->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'), + ->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'), + ->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'), + ->label('ZMM FREQUENCY') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_head') - ->label('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'), + ->label('ZMM HEADING') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_head_max') - ->label('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'), + ->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'), + ->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'), + ->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'), + ->label('ZMM KVACODE') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_maxambtemp') - ->label('ZMM MAX AMB TEMP'), + ->label('ZMM MAX AMB TEMP') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_mincoolingflow') - ->label('ZMM MIN COOLING FLOW'), + ->label('ZMM MIN COOLING FLOW') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_motorseries') - ->label('ZMM MOTOR SERIES'), + ->label('ZMM MOTOR SERIES') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_motor_model') - ->label('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'), + ->label('ZMM OUTLET') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_phase') - ->label('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'), + ->label('ZMM PRESSURE') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_pumpflowtype') - ->label('ZMM PUMP FLOW TYPE'), + ->label('ZMM PUMP FLOW TYPE') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_pumpseries') - ->label('ZMM PUMP SERIES'), + ->label('ZMM PUMP SERIES') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_pump_model') - ->label('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 RATED POWER'), + ->label('ZMM RATED POWER') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_region') - ->label('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 SERVICE FACTOR'), + ->label('ZMM SERVICE FACTOR') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_servicefactormaximumamps') - ->label('ZMM SERVICE FACTOR MAXIMUM AMPS'), + ->label('ZMM SERVICE FACTOR MAXIMUM AMPS') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_speed') - ->label('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'), + ->label('ZMM SUCTION') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_suctionxdelivery') - ->label('ZMM SUCTION X DELIVERY'), + ->label('ZMM SUCTION X DELIVERY') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_supplysource') - ->label('ZMM SUPPLY SOURCE'), + ->label('ZMM SUPPLY SOURCE') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_temperature') - ->label('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 THRUST LOAD'), + ->label('ZMM THRUST LOAD') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_volts') - ->label('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'), + ->label('ZMM WIRE') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_package') - ->label('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 PV ARRAY RATING'), + ->label('ZMM PV ARRAY RATING') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_isi') - ->label('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 ISI MOTOR'), + ->label('ZMM ISI MOTOR') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_isipump') - ->label('ZMM ISI PUMP'), + ->label('ZMM ISI PUMP') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_isipumpset') - ->label('ZMM ISI PUMP SET'), + ->label('ZMM ISI PUMP SET') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_pumpset_model') - ->label('ZMM PUMP SET MODEL'), + ->label('ZMM PUMP SET MODEL') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_stages') - ->label('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 HEAD RANGE'), + ->label('ZMM HEAD RANGE') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_overall_efficiency') - ->label('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'), + ->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'), + ->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 ISI REFERENCE'), + ->label('ZMM ISI REFERENCE') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_category') - ->label('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'), + ->label('ZMM SUBMERGENCE') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_capacitorstart') - ->label('ZMM CAPACITOR START'), + ->label('ZMM CAPACITOR START') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_capacitorrun') - ->label('ZMM CAPACITOR RUN'), + ->label('ZMM CAPACITOR RUN') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_inch') - ->label('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'), + ->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'), + ->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 OVERALL EFFICIENCY'), + ->label('ZMM OVERALL EFFICIENCY') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_bodymoc') - ->label('ZMM BODY MOC'), + ->label('ZMM BODY MOC') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_rotormoc') - ->label('ZMM ROTOR MOC'), + ->label('ZMM ROTOR MOC') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_dlwl') - ->label('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 INPUT POWER'), + ->label('ZMM INPUT POWER') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_imp_od') - ->label('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 AMBIENT TEMPERATURE'), + ->label('ZMM AMBIENT TEMPERATURE') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_de') - ->label('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 DISCHARGE RANGE'), + ->label('ZMM DISCHARGE RANGE') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_efficiency_class') - ->label('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 FRAME SIZE'), + ->label('ZMM FRAME SIZE') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_impellerdiameter') - ->label('ZMM IMPELLER DIAMETER'), + ->label('ZMM IMPELLER DIAMETER') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_insulationclass') - ->label('ZMM INSULATION CLASS'), + ->label('ZMM INSULATION CLASS') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_maxflow') - ->label('ZMM MAX FLOW'), + ->label('ZMM MAX FLOW') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_minhead') - ->label('ZMM MIN HEAD'), + ->label('ZMM MIN HEAD') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_mtrlofconst') - ->label('ZMM MOTOR LOAD CONSTANT'), + ->label('ZMM MOTOR LOAD CONSTANT') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_nde') - ->label('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 POWER FACTOR'), + ->label('ZMM POWER FACTOR') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_tagno') - ->label('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'), + ->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'), + ->label('ZMM LASER NAME') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_beenote') - ->label('ZMM BEE NOTE'), + ->label('ZMM BEE NOTE') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_beenumber') - ->label('ZMM BEE NUMBER'), + ->label('ZMM BEE NUMBER') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_beestar') - ->label('ZMM BEE STAR'), + ->label('ZMM BEE STAR') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_logo_ce') - ->label('ZMM LOGO CE'), + ->label('ZMM LOGO CE') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_codeclass') - ->label('ZMM CODE CLASS'), + ->label('ZMM CODE CLASS') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_colour') - ->label('ZMM COLOUR'), + ->label('ZMM COLOUR') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_logo_cp') - ->label('ZMM LOGO CP'), + ->label('ZMM LOGO CP') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_grade') - ->label('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'), + ->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'), + ->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'), + ->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'), + ->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'), + ->label('ZMM GRWT PUMP') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_isivalve') - ->label('ZMM ISIV ALVE'), + ->label('ZMM ISI VALVE') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_isi_wc') - ->label('ZMM ISIV 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 LABEL PERIOD'), + ->label('ZMM LABEL PERIOD') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_length') - ->label('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'), + ->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 MFG MON YR'), + ->label('ZMM MFG MON YR') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_modelyear') - ->label('ZMM MODEL YEAR'), + ->label('ZMM MODEL YEAR') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_motoridentification') - ->label('ZMM MOTOR IDENTIFICATION'), + ->label('ZMM MOTOR IDENTIFICATION') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_newt_pset') - ->label('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'), + ->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'), + ->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'), + ->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'), + ->label('ZMM NEWT PUMP') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_logo_nsf') - ->label('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_packtype') - ->label('ZMM PACK TYPE'), + ->label('ZMM PACK TYPE') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_panel') - ->label('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'), + ->label('ZMM PERFORMANCE FACTOR') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_pumpidentification') - ->label('ZMM PUMP IDENTIFICATION'), + ->label('ZMM PUMP IDENTIFICATION') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_psettype') - ->label('ZMM PSET TYPE'), + ->label('ZMM PSET TYPE') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_size') - ->label('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'), + ->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'), + ->label('ZMM TYPE') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_usp') - ->label('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'), + ->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'), + ->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'), + ->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'), + ->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'), + ->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'), + ->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'), + ->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'), + ->label('ZMM MOTOR SPEED') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zqmm_qty') - ->label('ZMM 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('mrp') - ->label('MRP'), + ->label('MRP') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_1') - ->label('ZMM 1'), + ->label('ZMM 1') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_2') - ->label('ZMM 2'), + ->label('ZMM 2') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_3') - ->label('ZMM 3'), + ->label('ZMM 3') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_4') - ->label('ZMM 4'), + ->label('ZMM 4') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_5') - ->label('ZMM 5'), + ->label('ZMM 5') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_6') - ->label('ZMM 6'), + ->label('ZMM 6') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_7') - ->label('ZMM 7'), + ->label('ZMM 7') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_8') - ->label('ZMM 8'), + ->label('ZMM 8') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_9') - ->label('ZMM 9'), + ->label('ZMM 9') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_10') - ->label('ZMM 10'), + ->label('ZMM 10') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_11') - ->label('ZMM 11'), + ->label('ZMM 11') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_12') - ->label('ZMM 12'), + ->label('ZMM 12') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_13') - ->label('ZMM 13'), + ->label('ZMM 13') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_14') - ->label('ZMM 14'), + ->label('ZMM 14') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\TextInput::make('zmm_15') - ->label('ZMM 15'), + ->label('ZMM 15') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), Forms\Components\Hidden::make('created_by') ->label('Created By') ->default(Filament::auth()->user()?->name), @@ -772,11 +1370,11 @@ class ItemCharacteristicResource extends Resource ->alignCenter() ->sortable(), Tables\Columns\TextColumn::make('zmm_isivalve') - ->label('ZMM ISIV ALVE') + ->label('ZMM ISI VALVE') ->alignCenter() ->sortable(), Tables\Columns\TextColumn::make('zmm_isi_wc') - ->label('ZMM ISIV WC') + ->label('ZMM ISI WC') ->alignCenter() ->sortable(), Tables\Columns\TextColumn::make('zmm_labelperiod') @@ -827,6 +1425,10 @@ class ItemCharacteristicResource extends Resource ->label('ZMM LOGO NSF') ->alignCenter() ->sortable(), + Tables\Columns\TextColumn::make('zmm_logo_eac') + ->label('ZMM LOGO EAC') + ->alignCenter() + ->sortable(), Tables\Columns\TextColumn::make('zmm_packtype') ->label('ZMM PACK TYPE') ->alignCenter() @@ -899,6 +1501,14 @@ class ItemCharacteristicResource extends Resource ->label('ZMM 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('mrp') ->label('MRP') ->alignCenter() -- 2.49.1 From c53b41ea2fb0ec61efaa8a16d5732a609b2c6006 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Mon, 14 Sep 2026 14:22:05 +0530 Subject: [PATCH 13/18] Added three columns in item charcateristic exporter --- app/Filament/Exports/ItemCharacteristicExporter.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/Filament/Exports/ItemCharacteristicExporter.php b/app/Filament/Exports/ItemCharacteristicExporter.php index 7b3b966..4204c48 100644 --- a/app/Filament/Exports/ItemCharacteristicExporter.php +++ b/app/Filament/Exports/ItemCharacteristicExporter.php @@ -247,6 +247,8 @@ class ItemCharacteristicExporter extends Exporter ->label('ZMM NEWT PUMP'), ExportColumn::make('zmm_logo_nsf') ->label('ZMM LOGO NSF'), + ExportColumn::make('zmm_logo_eac') + ->label('ZMM LOGO EAC'), ExportColumn::make('zmm_packtype') ->label('ZMM PACK TYPE'), ExportColumn::make('zmm_panel') @@ -282,7 +284,11 @@ class ItemCharacteristicExporter extends Exporter ExportColumn::make('zmm_motor_speed') ->label('ZMM MOTOR SPEED'), ExportColumn::make('zqmm_qty') - ->label('ZMM QTY'), + ->label('ZQMM QTY'), + ExportColumn::make('zmm_operating_temperature') + ->label('ZMM OPERATING TEMPERATURE'), + ExportColumn::make('zmm_axial_force') + ->label('ZMM AXIAL FORCE'), ExportColumn::make('zmm_1') ->label('ZMM 1') ->enabledByDefault(false), -- 2.49.1 From 00700da0d9e93e24295111f453a833591a20102b Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Mon, 14 Sep 2026 15:04:05 +0530 Subject: [PATCH 14/18] Added columns in item characteristic importer --- .../Imports/ItemCharacteristicImporter.php | 668 ++++++++++++++---- 1 file changed, 537 insertions(+), 131 deletions(-) diff --git a/app/Filament/Imports/ItemCharacteristicImporter.php b/app/Filament/Imports/ItemCharacteristicImporter.php index bd61dfe..9f254d1 100644 --- a/app/Filament/Imports/ItemCharacteristicImporter.php +++ b/app/Filament/Imports/ItemCharacteristicImporter.php @@ -16,141 +16,547 @@ class ItemCharacteristicImporter extends Importer return [ ImportColumn::make('plant') ->requiredMapping() - ->relationship() + ->exampleHeader('PLANT CODE') + ->example('1000') + ->label('PLANT CODE') + ->relationship(resolveUsing: 'code') ->rules(['required']), ImportColumn::make('item') ->requiredMapping() - ->relationship() + ->exampleHeader('ITEM CODE') + ->example('630214') + ->label('ITEM CODE') + ->relationship(resolveUsing: 'code') ->rules(['required']), - ImportColumn::make('class'), - ImportColumn::make('zz1_cn_bill_ord'), - ImportColumn::make('zmm_amps'), - ImportColumn::make('zmm_brand'), - ImportColumn::make('zmm_degreeofprotection'), - ImportColumn::make('zmm_delivery'), - ImportColumn::make('zmm_dir_rot'), - ImportColumn::make('zmm_discharge'), - ImportColumn::make('zmm_discharge_max'), - ImportColumn::make('zmm_discharge_min'), - ImportColumn::make('zmm_duty'), - ImportColumn::make('zmm_eff_motor'), - ImportColumn::make('zmm_eff_pump'), - ImportColumn::make('zmm_frequency'), - ImportColumn::make('zmm_head'), - ImportColumn::make('zmm_heading'), - ImportColumn::make('zmm_head_max'), - ImportColumn::make('zmm_head_minimum'), - ImportColumn::make('zmm_idx_eff_mtr'), - ImportColumn::make('zmm_idx_eff_pump'), - ImportColumn::make('zmm_kvacode'), - ImportColumn::make('zmm_maxambtemp'), - ImportColumn::make('zmm_mincoolingflow'), - ImportColumn::make('zmm_motorseries'), - ImportColumn::make('zmm_motor_model'), - ImportColumn::make('zmm_outlet'), - ImportColumn::make('zmm_phase'), - ImportColumn::make('zmm_pressure'), - ImportColumn::make('zmm_pumpflowtype'), - ImportColumn::make('zmm_pumpseries'), - ImportColumn::make('zmm_pump_model'), - ImportColumn::make('zmm_ratedpower'), - ImportColumn::make('zmm_region'), - ImportColumn::make('zmm_servicefactor'), - ImportColumn::make('zmm_servicefactormaximumamps'), - ImportColumn::make('zmm_speed'), - ImportColumn::make('zmm_suction'), - ImportColumn::make('zmm_suctionxdelivery'), - ImportColumn::make('zmm_supplysource'), - ImportColumn::make('zmm_temperature'), - ImportColumn::make('zmm_thrustload'), - ImportColumn::make('zmm_volts'), - ImportColumn::make('zmm_wire'), - ImportColumn::make('zmm_package'), - ImportColumn::make('zmm_pvarrayrating'), - ImportColumn::make('zmm_isi'), - ImportColumn::make('zmm_isimotor'), - ImportColumn::make('zmm_isipump'), - ImportColumn::make('zmm_isipumpset'), - ImportColumn::make('zmm_pumpset_model'), - ImportColumn::make('zmm_stages'), - ImportColumn::make('zmm_headrange'), - ImportColumn::make('zmm_overall_efficiency'), - ImportColumn::make('zmm_connection'), - ImportColumn::make('zmm_min_bore_size'), - ImportColumn::make('zmm_isireference'), - ImportColumn::make('zmm_category'), - ImportColumn::make('zmm_submergence'), - ImportColumn::make('zmm_capacitorstart'), - ImportColumn::make('zmm_capacitorrun'), - ImportColumn::make('zmm_inch'), - ImportColumn::make('zmm_motor_type'), - ImportColumn::make('zmm_dismantle_direction'), - ImportColumn::make('zmm_eff_ovrall'), - ImportColumn::make('zmm_bodymoc'), - ImportColumn::make('zmm_rotormoc'), - ImportColumn::make('zmm_dlwl'), - ImportColumn::make('zmm_inputpower'), - ImportColumn::make('zmm_imp_od'), - ImportColumn::make('zmm_ambtemp'), - ImportColumn::make('zmm_de'), - ImportColumn::make('zmm_dischargerange'), - ImportColumn::make('zmm_efficiency_class'), - ImportColumn::make('zmm_framesize'), - ImportColumn::make('zmm_impellerdiameter'), - ImportColumn::make('zmm_insulationclass'), - ImportColumn::make('zmm_maxflow'), - ImportColumn::make('zmm_minhead'), - ImportColumn::make('zmm_mtrlofconst'), - ImportColumn::make('zmm_nde'), - ImportColumn::make('zmm_powerfactor'), - ImportColumn::make('zmm_tagno'), - ImportColumn::make('zmm_year'), - ImportColumn::make('zmm_laser_name'), - ImportColumn::make('zmm_beenote'), - ImportColumn::make('zmm_beenumber'), - ImportColumn::make('zmm_beestar'), - ImportColumn::make('zmm_logo_ce'), - ImportColumn::make('zmm_codeclass'), - ImportColumn::make('zmm_colour'), - ImportColumn::make('zmm_logo_cp'), - ImportColumn::make('zmm_grade'), - ImportColumn::make('zmm_grwt_pset'), - ImportColumn::make('zmm_grwt_cable'), - ImportColumn::make('zmm_grwt_motor'), - ImportColumn::make('zmm_grwt_pf'), - ImportColumn::make('zmm_grwt_pump'), - ImportColumn::make('zmm_isivalve'), - ImportColumn::make('zmm_isi_wc'), - ImportColumn::make('zmm_labelperiod'), - ImportColumn::make('zmm_length'), - ImportColumn::make('zmm_license_cml_no'), - ImportColumn::make('zmm_mfgmonyr'), - ImportColumn::make('zmm_modelyear'), - ImportColumn::make('zmm_motoridentification'), - ImportColumn::make('zmm_newt_pset'), - ImportColumn::make('zmm_newt_cable'), - ImportColumn::make('zmm_newt_motor'), - ImportColumn::make('zmm_newt_pf'), - ImportColumn::make('zmm_newt_pump'), - ImportColumn::make('zmm_logo_nsf'), - ImportColumn::make('zmm_packtype'), - ImportColumn::make('zmm_panel'), - ImportColumn::make('zmm_performance_factor'), - ImportColumn::make('zmm_pumpidentification'), - ImportColumn::make('zmm_psettype'), - ImportColumn::make('zmm_size'), - ImportColumn::make('zmm_eff_ttl'), - ImportColumn::make('zmm_type'), - ImportColumn::make('zmm_usp'), - ImportColumn::make('zmm_operating_range'), - ImportColumn::make('zmm_intake_air'), - ImportColumn::make('zmm_oxygen_transfer_rate'), - ImportColumn::make('zmm_air_inlet_pipesize'), - ImportColumn::make('zmm_sump_depth'), - ImportColumn::make('zmm_poles'), - ImportColumn::make('zmm_motor_heading'), - ImportColumn::make('zmm_motor_speed'), - ImportColumn::make('zqmm_qty'), + ImportColumn::make('class') + ->label('CLASS') + ->exampleHeader('CLASS') + ->example('ZLASER'), + ImportColumn::make('zz1_cn_bill_ord') + ->label('ZZ1 CN BILL ORD') + ->exampleHeader('ZZ1 CN BILL ORD') + ->example('INDIA'), + ImportColumn::make('zmm_amps') + ->label('ZMM AMPS') + ->exampleHeader('ZMM AMPS') + ->example('11A'), + ImportColumn::make('zmm_brand') + ->label('ZMM BRAND') + ->exampleHeader('ZMM BRAND') + ->example('CRI'), + ImportColumn::make('zmm_degreeofprotection') + ->label('ZMM DEGREEOFPROTECTION') + ->exampleHeader('ZMM DEGREEOFPROTECTION') + ->example('IP55'), + ImportColumn::make('zmm_delivery') + ->label('ZMM DELIVERY') + ->exampleHeader('ZMM DELIVERY') + ->example('65MM'), + ImportColumn::make('zmm_dir_rot') + ->label('ZMM DIR ROT') + ->exampleHeader('ZMM DIR ROT') + ->example(''), + ImportColumn::make('zmm_discharge') + ->label('ZMM DISCHARGE') + ->exampleHeader('ZMM DISCHARGE') + ->example('17m³/h'), + ImportColumn::make('zmm_discharge_max') + ->label('ZMM DISCHARGE MAX') + ->exampleHeader('ZMM DISCHARGE MAX') + ->example(''), + ImportColumn::make('zmm_discharge_min') + ->label('ZMM DISCHARGE MIN') + ->exampleHeader('ZMM DISCHARGE MIN') + ->example(''), + ImportColumn::make('zmm_duty') + ->label('ZMM DUTY') + ->exampleHeader('ZMM DUTY') + ->example('DUTY S1'), + ImportColumn::make('zmm_eff_motor') + ->label('ZMM EFF MOTOR') + ->exampleHeader('ZMM EFF MOTOR') + ->example(''), + ImportColumn::make('zmm_eff_pump') + ->label('ZMM EFF PUMP') + ->exampleHeader('ZMM EFF PUMP') + ->example(''), + ImportColumn::make('zmm_frequency') + ->label('ZMM FREQUENCY') + ->exampleHeader('ZMM FREQUENCY') + ->example('50Hz'), + ImportColumn::make('zmm_head') + ->label('ZMM HEAD') + ->exampleHeader('ZMM HEAD') + ->example('77M'), + ImportColumn::make('zmm_heading') + ->label('ZMM HEADING') + ->exampleHeader('ZMM HEADING') + ->example('PRESSURE BOOSTER SYSTEM'), + ImportColumn::make('zmm_head_max') + ->label('ZMM HEAD MAX') + ->exampleHeader('ZMM HEAD MAX') + ->example('96m'), + ImportColumn::make('zmm_head_minimum') + ->label('ZMM HEAD MINIMUM') + ->exampleHeader('ZMM HEAD MINIMUM') + ->example(''), + ImportColumn::make('zmm_idx_eff_mtr') + ->label('ZMM IDX EFF MTR') + ->exampleHeader('ZMM IDX EFF MTR') + ->example(''), + ImportColumn::make('zmm_idx_eff_pump') + ->label('ZMM IDX EFF PUMP') + ->exampleHeader('ZMM IDX EFF PUMP') + ->example(''), + ImportColumn::make('zmm_kvacode') + ->label('ZMM KVACODE') + ->exampleHeader('ZMM KVACODE') + ->example(''), + ImportColumn::make('zmm_maxambtemp') + ->label('ZMM MAXAMBTEMP') + ->exampleHeader('ZMM MAXAMBTEMP') + ->example(''), + ImportColumn::make('zmm_mincoolingflow') + ->label('ZMM MINCOOLINGFLOW') + ->exampleHeader('ZMM MINCOOLINGFLOW') + ->example(''), + ImportColumn::make('zmm_motorseries') + ->label('ZMM MOTORSERIES') + ->exampleHeader('ZMM MOTORSERIES') + ->example(''), + ImportColumn::make('zmm_motor_model') + ->label('ZMM MOTOR MODEL') + ->exampleHeader('ZMM MOTOR MODEL') + ->example(''), + ImportColumn::make('zmm_outlet') + ->label('ZMM OUTLET') + ->exampleHeader('ZMM OUTLET') + ->example('IE2'), + ImportColumn::make('zmm_phase') + ->label('ZMM PHASE') + ->exampleHeader('ZMM PHASE') + ->example('3Ph'), + ImportColumn::make('zmm_pressure') + ->label('ZMM PRESSURE') + ->exampleHeader('ZMM PRESSURE') + ->example('16bar'), + ImportColumn::make('zmm_pumpflowtype') + ->label('ZMM PUMPFLOWTYPE') + ->exampleHeader('ZMM PUMPFLOWTYPE') + ->example(''), + ImportColumn::make('zmm_pumpseries') + ->label('ZMM PUMPSERIES') + ->exampleHeader('ZMM PUMPSERIES') + ->example(''), + ImportColumn::make('zmm_pump_model') + ->label('ZMM PUMP MODEL') + ->exampleHeader('ZMM PUMP MODEL') + ->example('MVHS-15/07TR'), + ImportColumn::make('zmm_ratedpower') + ->label('ZMM RATEDPOWER') + ->exampleHeader('ZMM RATEDPOWER') + ->example('5.5kW/7.5HP'), + ImportColumn::make('zmm_region') + ->label('ZMM REGION') + ->exampleHeader('ZMM REGION') + ->example(''), + ImportColumn::make('zmm_servicefactor') + ->label('ZMM SERVICEFACTOR') + ->exampleHeader('ZMM SERVICEFACTOR') + ->example(''), + ImportColumn::make('zmm_servicefactormaximumamps') + ->label('ZMM SERVICEFACTORMAXIMUMAMPS') + ->exampleHeader('ZMM SERVICEFACTORMAXIMUMAMPS') + ->example(''), + ImportColumn::make('zmm_speed') + ->label('ZMM SPEED') + ->exampleHeader('ZMM SPEED') + ->example('2900rpm'), + ImportColumn::make('zmm_suction') + ->label('ZMM SUCTION') + ->exampleHeader('ZMM SUCTION') + ->example('65mm'), + ImportColumn::make('zmm_suctionxdelivery') + ->label('ZMM SUCTIONXDELIVERY') + ->exampleHeader('ZMM SUCTIONXDELIVERY') + ->example('50 x 50mm'), + ImportColumn::make('zmm_supplysource') + ->label('ZMM SUPPLYSOURCE') + ->exampleHeader('ZMM SUPPLYSOURCE') + ->example('AC SUPPLY'), + ImportColumn::make('zmm_temperature') + ->label('ZMM TEMPERATURE') + ->exampleHeader('ZMM TEMPERATURE') + ->example('90°C'), + ImportColumn::make('zmm_thrustload') + ->label('ZMM THRUSTLOAD') + ->exampleHeader('ZMM THRUSTLOAD') + ->example(''), + ImportColumn::make('zmm_volts') + ->label('ZMM VOLTS') + ->exampleHeader('ZMM VOLTS') + ->example('415V'), + ImportColumn::make('zmm_wire') + ->label('ZMM WIRE') + ->exampleHeader('ZMM WIRE') + ->example(''), + ImportColumn::make('zmm_package') + ->label('ZMM PACKAGE') + ->exampleHeader('ZMM PACKAGE') + ->example(''), + ImportColumn::make('zmm_pvarrayrating') + ->label('ZMM PVARRAYRATING') + ->exampleHeader('ZMM PVARRAYRATING') + ->example(''), + ImportColumn::make('zmm_isi') + ->label('ZMM ISI') + ->exampleHeader('ZMM ISI') + ->example('Y'), + ImportColumn::make('zmm_isimotor') + ->label('ZMM ISIMOTOR') + ->exampleHeader('ZMM ISIMOTOR') + ->example('IS:12615'), + ImportColumn::make('zmm_isipump') + ->label('ZMM ISIPUMP') + ->exampleHeader('ZMM ISIPUMP') + ->example(''), + ImportColumn::make('zmm_isipumpset') + ->label('ZMM ISIPUMPSET') + ->exampleHeader('ZMM ISIPUMPSET') + ->example('IS:12615'), + ImportColumn::make('zmm_pumpset_model') + ->label('ZMM PUMPSET MODEL') + ->exampleHeader('ZMM PUMPSET MODEL') + ->example('MVHS-15/07TR'), + ImportColumn::make('zmm_stages') + ->label('ZMM STAGES') + ->exampleHeader('ZMM STAGES') + ->example('7'), + ImportColumn::make('zmm_headrange') + ->label('ZMM HEADRANGE') + ->exampleHeader('ZMM HEADRANGE') + ->example(''), + ImportColumn::make('zmm_overall_efficiency') + ->label('ZMM OVERALL EFFICIENCY') + ->exampleHeader('ZMM OVERALL EFFICIENCY') + ->example(''), + ImportColumn::make('zmm_connection') + ->label('ZMM CONNECTION') + ->exampleHeader('ZMM CONNECTION') + ->example('STAR/DELTA'), + ImportColumn::make('zmm_min_bore_size') + ->label('ZMM MIN BORE SIZE') + ->exampleHeader('ZMM MIN BORE SIZE') + ->example(''), + ImportColumn::make('zmm_isireference') + ->label('ZMM ISIREFERENCE') + ->exampleHeader('ZMM ISIREFERENCE') + ->example(''), + ImportColumn::make('zmm_category') + ->label('ZMM CATEGORY') + ->exampleHeader('ZMM CATEGORY') + ->example('B'), + ImportColumn::make('zmm_submergence') + ->label('ZMM SUBMERGENCE') + ->exampleHeader('ZMM SUBMERGENCE') + ->example(''), + ImportColumn::make('zmm_capacitorstart') + ->label('ZMM CAPACITORSTART') + ->exampleHeader('ZMM CAPACITORSTART') + ->example(''), + ImportColumn::make('zmm_capacitorrun') + ->label('ZMM CAPACITORRUN') + ->exampleHeader('ZMM CAPACITORRUN') + ->example(''), + ImportColumn::make('zmm_inch') + ->label('ZMM INCH') + ->exampleHeader('ZMM INCH') + ->example(''), + ImportColumn::make('zmm_motor_type') + ->label('ZMM MOTOR TYPE') + ->exampleHeader('ZMM MOTOR TYPE') + ->example('TEFC'), + ImportColumn::make('zmm_dismantle_direction') + ->label('ZMM DISMANTLE DIRECTION') + ->exampleHeader('ZMM DISMANTLE DIRECTION') + ->example(''), + ImportColumn::make('zmm_eff_ovrall') + ->label('ZMM EFF OVERALL') + ->exampleHeader('ZMM EFF OVERALL') + ->example(''), + ImportColumn::make('zmm_bodymoc') + ->label('ZMM BODYMOC') + ->exampleHeader('ZMM BODYMOC') + ->example(''), + ImportColumn::make('zmm_rotormoc') + ->label('ZMM ROTORMOC') + ->exampleHeader('ZMM ROTORMOC') + ->example(''), + ImportColumn::make('zmm_dlwl') + ->label('ZMM DLWL') + ->exampleHeader('ZMM DLWL') + ->example(''), + ImportColumn::make('zmm_inputpower') + ->label('ZMM INPUTPOWER') + ->exampleHeader('ZMM INPUTPOWER') + ->example(''), + ImportColumn::make('zmm_imp_od') + ->label('ZMM IMP OD') + ->exampleHeader('ZMM IMP OD') + ->example(''), + ImportColumn::make('zmm_ambtemp') + ->label('ZMM AMBTEMP') + ->exampleHeader('ZMM AMBTEMP') + ->example(''), + ImportColumn::make('zmm_de') + ->label('ZMM DE') + ->exampleHeader('ZMM DE') + ->example(''), + ImportColumn::make('zmm_dischargerange') + ->label('ZMM DISCHARGERANGE') + ->exampleHeader('ZMM DISCHARGERANGE') + ->example(''), + ImportColumn::make('zmm_efficiency_class') + ->label('ZMM EFFICIENCY CLASS') + ->exampleHeader('ZMM EFFICIENCY CLASS') + ->example('IE2'), + ImportColumn::make('zmm_framesize') + ->label('ZMM FRAMESIZE') + ->exampleHeader('ZMM FRAMESIZE') + ->example(''), + ImportColumn::make('zmm_impellerdiameter') + ->label('ZMM IMPELLERDIAMETER') + ->exampleHeader('ZMM IMPELLERDIAMETER') + ->example(''), + ImportColumn::make('zmm_insulationclass') + ->label('ZMM INSULATIONCLASS') + ->exampleHeader('ZMM INSULATIONCLASS') + ->example('F'), + ImportColumn::make('zmm_maxflow') + ->label('ZMM MAXFLOW') + ->exampleHeader('ZMM MAXFLOW') + ->example(''), + ImportColumn::make('zmm_minhead') + ->label('ZMM MINHEAD') + ->exampleHeader('ZMM MINHEAD') + ->example(''), + ImportColumn::make('zmm_mtrlofconst') + ->label('ZMM MTRLOFCONST') + ->exampleHeader('ZMM MTRLOFCONST') + ->example(''), + ImportColumn::make('zmm_nde') + ->label('ZMM NDE') + ->exampleHeader('ZMM NDE') + ->example(''), + ImportColumn::make('zmm_powerfactor') + ->label('ZMM POWERFACTOR') + ->exampleHeader('ZMM POWERFACTOR') + ->example(''), + ImportColumn::make('zmm_tagno') + ->label('ZMM TAGNO') + ->exampleHeader('ZMM TAGNO') + ->example(''), + ImportColumn::make('zmm_year') + ->label('ZMM YEAR') + ->exampleHeader('ZMM YEAR') + ->example(''), + ImportColumn::make('zmm_laser_name') + ->label('ZMM LASER NAME') + ->exampleHeader('ZMM LASER NAME') + ->example(''), + ImportColumn::make('zmm_beenote') + ->label('ZMM BEENOTE') + ->exampleHeader('ZMM BEENOTE') + ->example(''), + ImportColumn::make('zmm_beenumber') + ->label('ZMM BEENUMBER') + ->exampleHeader('ZMM BEENUMBER') + ->example(''), + ImportColumn::make('zmm_beestar') + ->label('ZMM BEESTAR') + ->exampleHeader('ZMM BEESTAR') + ->example(''), + ImportColumn::make('zmm_logo_ce') + ->label('ZMM LOGO CE') + ->exampleHeader('ZMM LOGO CE') + ->example('NO'), + ImportColumn::make('zmm_codeclass') + ->label('ZMM CODECLASS') + ->exampleHeader('ZMM CODECLASS') + ->example(''), + ImportColumn::make('zmm_colour') + ->label('ZMM COLOUR') + ->exampleHeader('ZMM COLOUR') + ->example(''), + ImportColumn::make('zmm_logo_cp') + ->label('ZMM LOGO CP') + ->exampleHeader('ZMM LOGO CP') + ->example(''), + ImportColumn::make('zmm_grade') + ->label('ZMM GRADE') + ->exampleHeader('ZMM GRADE') + ->example(''), + ImportColumn::make('zmm_grwt_pset') + ->label('ZMM GRWT PSET') + ->exampleHeader('ZMM GRWT PSET') + ->example(''), + ImportColumn::make('zmm_grwt_cable') + ->label('ZMM GRWT CABLE') + ->exampleHeader('ZMM GRWT CABLE') + ->example(''), + ImportColumn::make('zmm_grwt_motor') + ->label('ZMM GRWT MOTOR') + ->exampleHeader('ZMM GRWT MOTOR') + ->example(''), + ImportColumn::make('zmm_grwt_pf') + ->label('ZMM GRWT PF') + ->exampleHeader('ZMM GRWT PF') + ->example(''), + ImportColumn::make('zmm_grwt_pump') + ->label('ZMM GRWT PUMP') + ->exampleHeader('ZMM GRWT PUMP') + ->example(''), + ImportColumn::make('zmm_isivalve') + ->label('ZMM ISIVALVE') + ->exampleHeader('ZMM ISIVALVE') + ->example(''), + ImportColumn::make('zmm_isi_wc') + ->label('ZMM ISI WC') + ->exampleHeader('ZMM ISI WC') + ->example(''), + ImportColumn::make('zmm_labelperiod') + ->label('ZMM LABELPERIOD') + ->exampleHeader('ZMM LABELPERIOD') + ->example(''), + ImportColumn::make('zmm_length') + ->label('ZMM LENGTH') + ->exampleHeader('ZMM LENGTH') + ->example(''), + ImportColumn::make('zmm_license_cml_no') + ->label('ZMM LICENSE CML NO') + ->exampleHeader('ZMM LICENSE CML NO') + ->example(''), + ImportColumn::make('zmm_mfgmonyr') + ->label('ZMM MFGMONYR') + ->exampleHeader('ZMM MFGMONYR') + ->example(''), + ImportColumn::make('zmm_modelyear') + ->label('ZMM MODELYEAR') + ->exampleHeader('ZMM MODELYEAR') + ->example(''), + ImportColumn::make('zmm_motoridentification') + ->label('ZMM MOTORIDENTIFICATION') + ->exampleHeader('ZMM MOTORIDENTIFICATION') + ->example(''), + ImportColumn::make('zmm_newt_pset') + ->label('ZMM NEWT PSET') + ->exampleHeader('ZMM NEWT PSET') + ->example(''), + ImportColumn::make('zmm_newt_cable') + ->label('ZMM NEWT CABLE') + ->exampleHeader('ZMM NEWT CABLE') + ->example(''), + ImportColumn::make('zmm_newt_motor') + ->label('ZMM NEWT MOTOR') + ->exampleHeader('ZMM NEWT MOTOR') + ->example(''), + ImportColumn::make('zmm_newt_pf') + ->label('ZMM NEWT PF') + ->exampleHeader('ZMM NEWT PF') + ->example(''), + ImportColumn::make('zmm_newt_pump') + ->label('ZMM NEWT PUMP') + ->exampleHeader('ZMM NEWT PUMP') + ->example(''), + ImportColumn::make('zmm_logo_nsf') + ->label('ZMM LOGO NSF') + ->exampleHeader('ZMM LOGO NSF') + ->example(''), + ImportColumn::make('zmm_logo_eac') + ->label('ZMM LOGO EAC') + ->exampleHeader('ZMM LOGO EAC') + ->example(''), + ImportColumn::make('zmm_packtype') + ->label('ZMM PACKTYPE') + ->exampleHeader('ZMM PACKTYPE') + ->example(''), + ImportColumn::make('zmm_panel') + ->label('ZMM PANEL') + ->exampleHeader('ZMM PANEL') + ->example(''), + ImportColumn::make('zmm_performance_factor') + ->label('ZMM PERFORMANCE FACTOR') + ->exampleHeader('ZMM PERFORMANCE FACTOR') + ->example(''), + ImportColumn::make('zmm_pumpidentification') + ->label('ZMM PUMPIDENTIFICATION') + ->exampleHeader('ZMM PUMPIDENTIFICATION') + ->example(''), + ImportColumn::make('zmm_psettype') + ->label('ZMM PSETTYPE') + ->exampleHeader('ZMM PSETTYPE') + ->example(''), + ImportColumn::make('zmm_size') + ->label('ZMM SIZE') + ->exampleHeader('ZMM SIZE') + ->example(''), + ImportColumn::make('zmm_eff_ttl') + ->label('ZMM EFF TTL') + ->exampleHeader('ZMM EFF TTL') + ->example(''), + ImportColumn::make('zmm_type') + ->label('ZMM TYPE') + ->exampleHeader('ZMM TYPE') + ->example(''), + ImportColumn::make('zmm_usp') + ->label('ZMM USP') + ->exampleHeader('ZMM USP') + ->example(''), + ImportColumn::make('zmm_operating_range') + ->label('ZMM OPERATING RANGE') + ->exampleHeader('ZMM OPERATING RANGE') + ->example(''), + ImportColumn::make('zmm_intake_air') + ->label('ZMM INTAKE AIR') + ->exampleHeader('ZMM INTAKE AIR') + ->example(''), + ImportColumn::make('zmm_oxygen_transfer_rate') + ->label('ZMM OXYGEN TRANSFER RATE') + ->exampleHeader('ZMM OXYGEN TRANSFER RATE') + ->example(''), + ImportColumn::make('zmm_air_inlet_pipesize') + ->label('ZMM AIR INLET PIPESIZE') + ->exampleHeader('ZMM AIR INLET PIPESIZE') + ->example(''), + ImportColumn::make('zmm_sump_depth') + ->label('ZMM SUMP DEPTH') + ->exampleHeader('ZMM SUMP DEPTH') + ->example(''), + ImportColumn::make('zmm_poles') + ->label('ZMM POLES') + ->exampleHeader('ZMM POLES') + ->example(''), + ImportColumn::make('zmm_motor_heading') + ->label('ZMM MOTOR HEADING') + ->exampleHeader('ZMM MOTOR HEADING') + ->example(''), + ImportColumn::make('zmm_motor_speed') + ->label('ZMM MOTOR SPEED') + ->exampleHeader('ZMM MOTOR SPEED') + ->example(''), + ImportColumn::make('zqmm_qty') + ->label('ZQMM QTY') + ->exampleHeader('ZQMM QTY') + ->example(''), + ImportColumn::make('zmm_operating_temperature') + ->label('ZMM OPERATING TEMPERATURE') + ->exampleHeader('ZMM OPERATING TEMPERATURE') + ->example(''), + ImportColumn::make('zmm_axial_force') + ->label('ZMM AXIAL FORCE') + ->exampleHeader('ZMM AXIAL FORCE') + ->example(''), + ImportColumn::make('mrp'), ImportColumn::make('zmm_1'), ImportColumn::make('zmm_2'), ImportColumn::make('zmm_3'), -- 2.49.1 From 364421622e2652f74e7065f60d45cd7daec1fb2a Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Mon, 14 Sep 2026 15:05:05 +0530 Subject: [PATCH 15/18] Added production temp migration file --- ...9_094132_create_production_temps_table.php | 181 ++++++++++++++++++ 1 file changed, 181 insertions(+) create mode 100644 database/migrations/2026_03_19_094132_create_production_temps_table.php diff --git a/database/migrations/2026_03_19_094132_create_production_temps_table.php b/database/migrations/2026_03_19_094132_create_production_temps_table.php new file mode 100644 index 0000000..5a3a5d4 --- /dev/null +++ b/database/migrations/2026_03_19_094132_create_production_temps_table.php @@ -0,0 +1,181 @@ + Date: Mon, 14 Sep 2026 15:05:31 +0530 Subject: [PATCH 16/18] Added production temp model file --- app/Models/ProductionTemp.php | 169 ++++++++++++++++++++++++++++++++++ 1 file changed, 169 insertions(+) create mode 100644 app/Models/ProductionTemp.php diff --git a/app/Models/ProductionTemp.php b/app/Models/ProductionTemp.php new file mode 100644 index 0000000..be0ba11 --- /dev/null +++ b/app/Models/ProductionTemp.php @@ -0,0 +1,169 @@ +belongsTo(Plant::class); + } + + public function machine(): BelongsTo + { + return $this->belongsTo(Machine::class); + } +} -- 2.49.1 From 740f8bdd0b8609aea16c219b55278b46ae802c72 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Mon, 14 Sep 2026 15:06:34 +0530 Subject: [PATCH 17/18] Added production temp resource pages --- .../Resources/ProductionTempResource.php | 1605 +++++++++++++++++ .../Pages/CreateProductionTemp.php | 12 + .../Pages/EditProductionTemp.php | 22 + .../Pages/ListProductionTemps.php | 19 + .../Pages/ViewProductionTemp.php | 19 + 5 files changed, 1677 insertions(+) create mode 100644 app/Filament/Resources/ProductionTempResource.php create mode 100644 app/Filament/Resources/ProductionTempResource/Pages/CreateProductionTemp.php create mode 100644 app/Filament/Resources/ProductionTempResource/Pages/EditProductionTemp.php create mode 100644 app/Filament/Resources/ProductionTempResource/Pages/ListProductionTemps.php create mode 100644 app/Filament/Resources/ProductionTempResource/Pages/ViewProductionTemp.php diff --git a/app/Filament/Resources/ProductionTempResource.php b/app/Filament/Resources/ProductionTempResource.php new file mode 100644 index 0000000..175efcd --- /dev/null +++ b/app/Filament/Resources/ProductionTempResource.php @@ -0,0 +1,1605 @@ +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(ProductionTemp::latest()->first())->plant_id; + }) + ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + $set('machine_id', null); + $set('updated_by', Filament::auth()->user()?->name); + }) + ->required(), + Forms\Components\Select::make('machine_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)->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 ProductionTemp::where('plant_id', $plantId)->latest()->first()->machine_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('production_temps', '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('pending_released_status') + ->label('PENDING RELEASED STATUS') + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), + Forms\Components\Hidden::make('created_by') + ->label('Created By') + ->default(Filament::auth()->user()?->name), + Forms\Components\Hidden::make('updated_by') + ->label('Updated By') + ->default(Filament::auth()->user()?->name), + ]); + } + + 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() + ->sortable(), + Tables\Columns\TextColumn::make('machine.work_center') + ->label('WORK CENTER') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('aufnr') + ->label('AUFNR') + ->searchable() + ->alignCenter() + ->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') + ->searchable() + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zz1_cn_bill_ord') + ->label('ZZ1 CN BILL ORD') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_amps') + ->label('ZMM AMPS') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_brand') + ->label('ZMM BRAND') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_degreeofprotection') + ->label('ZMM DEGREEOFPROTECTION') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_delivery') + ->label('ZMM DELIVERY') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_dir_rot') + ->label('ZMM DIR ROT') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_discharge') + ->label('ZMM DISCHARGE') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_discharge_max') + ->label('ZMM DISCHARGE MAX') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_discharge_min') + ->label('ZMM DISCHARGE MIN') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_duty') + ->label('ZMM DUTY') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_eff_motor') + ->label('ZMM EFF MOTOR') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_eff_pump') + ->label('ZMM EFF PUMP') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_frequency') + ->label('ZMM FREQUENCY') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_head') + ->label('ZMM HEAD') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_heading') + ->label('ZMM HEADING') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_head_max') + ->label('ZMM HEAD MAX') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_head_minimum') + ->label('ZMM HEAD MINIMUM') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_idx_eff_mtr') + ->label('ZMM IDX EFF MTR') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_idx_eff_pump') + ->label('ZMM IDX EFF PUMP') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_kvacode') + ->label('ZMM KVACODE') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_maxambtemp') + ->label('ZMM MAXAMBTEMP') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_mincoolingflow') + ->label('ZMM MINCOOLINGFLOW') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_motorseries') + ->label('ZMM MOTORSERIES') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_motor_model') + ->label('ZMM MOTOR MODEL') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_outlet') + ->label('ZMM OUTLET') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_phase') + ->label('ZMM PHASE') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_pressure') + ->label('ZMM PRESSURE') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_pumpflowtype') + ->label('ZMM PUMPFLOWTYPE') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_pumpseries') + ->label('ZMM PUMPSERIES') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_pump_model') + ->label('ZMM PUMP MODEL') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_ratedpower') + ->label('ZMM RATEDPOWER') + ->sortable(), + Tables\Columns\TextColumn::make('zmm_region') + ->label('ZMM REGION') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_servicefactor') + ->label('ZMM SERVICEFACTOR') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_servicefactormaximumamps') + ->label('ZMM SERVICEFACTORMAXIMUMAMPS') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_speed') + ->label('ZMM SPEED') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_suction') + ->label('ZMM SUCTION') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_suctionxdelivery') + ->label('ZMM SUCTIONXDELIVERY') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_supplysource') + ->label('ZMM SUPPLYSOURCE') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_temperature') + ->label('ZMM TEMPERATURE') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_thrustload') + ->label('ZMM THRUSTLOAD') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_volts') + ->label('ZMM VOLTS') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_wire') + ->label('ZMM WIRE') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_package') + ->label('ZMM PACKAGE') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_pvarrayrating') + ->label('ZMM PVARRAYRATING') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_isi') + ->label('ZMM ISI') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_isimotor') + ->label('ZMM ISIMOTOR') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_isipump') + ->label('ZMM ISIPUMP') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_isipumpset') + ->label('ZMM ISIPUMPSET') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_pumpset_model') + ->label('ZMM PUMPSET MODEL') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_stages') + ->label('ZMM STAGES') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_headrange') + ->label('ZMM HEADRANGE') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_overall_efficiency') + ->label('ZMM OVERALL EFFICIENCY') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_connection') + ->label('ZMM CONNECTION') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_min_bore_size') + ->label('ZMM MIN BORE SIZE') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_isireference') + ->label('ZMM ISIREFERENCE') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_category') + ->label('ZMM CATEGORY') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_submergence') + ->label('ZMM SUBMERGENCE') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_capacitorstart') + ->label('ZMM CAPACITORSTART') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_capacitorrun') + ->label('ZMM CAPACITORRUN') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_inch') + ->label('ZMM INCH') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_motor_type') + ->label('ZMM MOTOR TYPE') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_dismantle_direction') + ->label('ZMM DISMANTLE DIRECTION') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_eff_ovrall') + ->label('ZMM EFF OVRALL') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_bodymoc') + ->label('ZMM BODYMOC') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_rotormoc') + ->label('ZMM ROTORMOC') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_dlwl') + ->label('ZMM DLWL') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_inputpower') + ->label('ZMM INPUTPOWER') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_imp_od') + ->label('ZMM IMP OD') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_ambtemp') + ->label('ZMM AMBTEMP') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_de') + ->label('ZMM DE') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_dischargerange') + ->label('ZMM DISCHARGERANGE') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_efficiency_class') + ->label('ZMM EFFICIENCY CLASS') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_framesize') + ->label('ZMM FRAMESIZE') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_impellerdiameter') + ->label('ZMM IMPELLERDIAMETER') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_insulationclass') + ->label('ZMM INSULATIONCLASS') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_maxflow') + ->label('ZMM MAXFLOW') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_minhead') + ->label('ZMM MINHEAD') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_mtrlofconst') + ->label('ZMM MTRLOFCONST') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_nde') + ->label('ZMM NDE') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_powerfactor') + ->label('ZMM POWERFACTOR') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_tagno') + ->label('ZMM TANGO') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_year') + ->label('ZMM YEAR') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_laser_name') + ->label('ZMM LASER NAME') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_logo_cp') + ->label('ZMM LOGO CP') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_logo_ce') + ->label('ZMM LOGO CE') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_logo_nsf') + ->label('ZMM LOGO NSF') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_logo_eac') + ->label('ZMM LOGO EAC') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_beenote') + ->label('ZMM BEENOTE') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_beenumber') + ->label('ZMM BEENUMBER') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_beestar') + ->label('ZMM BEESTAR') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_codeclass') + ->label('ZMM CODECLASS') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_colour') + ->label('ZMM COLOUR') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_grade') + ->label('ZMM GRADE') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_grwt_pset') + ->label('ZMM GRWT PSET') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_grwt_cable') + ->label('ZMM GRWT CABLE') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_grwt_motor') + ->label('ZMM GRWT MOTOR') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_grwt_pf') + ->label('ZMM GRWT PF') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_grwt_pump') + ->label('ZMM GRWT PUMP') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_isivalve') + ->label('ZMM ISIVALVE') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_isi_wc') + ->label('ZMM ISI WC') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_labelperiod') + ->label('ZMM LABELPERIOD') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_length') + ->label('ZMM LENGTH') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_license_cml_no') + ->label('ZMM LICENSE CML NO') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_mfgmonyr') + ->label('ZMM MFGMONYR') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_modelyear') + ->label('ZMM MODELYEAR') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_motoridentification') + ->label('ZMM MOTORIDENTIFICATION') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_newt_pset') + ->label('ZMM NEWT PSET') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_newt_cable') + ->label('ZMM NEWT CABLE') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_newt_motor') + ->label('ZMM NEWT MOTOR') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_newt_pf') + ->label('ZMM NEWT PF') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_newt_pump') + ->label('ZMM NEWT PUMP') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_packtype') + ->label('ZMM PACKTYPE') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_panel') + ->label('ZMM PANEL') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_performance_factor') + ->label('ZMM PERFORMANCE FACTOR') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_pumpidentification') + ->label('ZMM PUMPIDENTIFICATION') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_psettype') + ->label('ZMM PSETTYPE') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_size') + ->label('ZMM SIZE') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_eff_ttl') + ->label('ZMM EFF TTL') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_type') + ->label('ZMM TYPE') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_usp') + ->label('ZMM USP') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_operating_range') + ->label('ZMM OPERATING RANGE') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_intake_air') + ->label('ZMM INTAKE AIR') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_oxygen_transfer_rate') + ->label('ZMM OXYGEN TRANSFER RATE') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_air_inlet_pipesize') + ->label('ZMM AIR INLET PIPESIZE') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_sump_depth') + ->label('ZMM SUMP DEPTH') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_poles') + ->label('ZMM POLES') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_motor_heading') + ->label('ZMM MOTOR HEADING') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_motor_speed') + ->label('ZMM MOTOR SPEED') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zqmm_qty') + ->label('ZQMM QTY') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_operating_temperature') + ->label('ZMM OPERATING TEMPERATURE') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('zmm_axial_force') + ->label('ZMM AXIAL FORCE') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('pending_released_status') + ->label('PENDING RELEASED STATUS') + ->alignCenter() + ->sortable(), + Tables\Columns\TextColumn::make('created_at') + ->dateTime() + ->sortable() + ->toggleable(isToggledHiddenByDefault: true), + Tables\Columns\TextColumn::make('updated_at') + ->dateTime() + ->sortable() + ->toggleable(isToggledHiddenByDefault: true), + Tables\Columns\TextColumn::make('deleted_at') + ->dateTime() + ->sortable() + ->toggleable(isToggledHiddenByDefault: true), + ]) + ->filters([ + Tables\Filters\TrashedFilter::make(), + ]) + ->actions([ + Tables\Actions\ViewAction::make(), + Tables\Actions\EditAction::make(), + ]) + ->bulkActions([ + Tables\Actions\BulkActionGroup::make([ + Tables\Actions\DeleteBulkAction::make(), + Tables\Actions\ForceDeleteBulkAction::make(), + Tables\Actions\RestoreBulkAction::make(), + ]), + ]) + ->headerActions([ + ImportAction::make() + ->label('Import Production Temp') + ->color('warning') + ->importer(ProductionTempImporter::class) + ->visible(function () { + return Filament::auth()->user()->can('view import production temp'); + }), + ExportAction::make() + ->label('Export Production Temp') + ->color('warning') + ->exporter(ProductionTempExporter::class) + ->visible(function () { + return Filament::auth()->user()->can('view export production temp'); + }), + ]); + } + + public static function getRelations(): array + { + return [ + // + ]; + } + + public static function getPages(): array + { + return [ + 'index' => Pages\ListProductionTemps::route('/'), + 'create' => Pages\CreateProductionTemp::route('/create'), + 'view' => Pages\ViewProductionTemp::route('/{record}'), + 'edit' => Pages\EditProductionTemp::route('/{record}/edit'), + ]; + } + + public static function getEloquentQuery(): Builder + { + return parent::getEloquentQuery() + ->withoutGlobalScopes([ + SoftDeletingScope::class, + ]); + } +} diff --git a/app/Filament/Resources/ProductionTempResource/Pages/CreateProductionTemp.php b/app/Filament/Resources/ProductionTempResource/Pages/CreateProductionTemp.php new file mode 100644 index 0000000..4ddcc8b --- /dev/null +++ b/app/Filament/Resources/ProductionTempResource/Pages/CreateProductionTemp.php @@ -0,0 +1,12 @@ + Date: Mon, 14 Sep 2026 15:07:27 +0530 Subject: [PATCH 18/18] Added production temp importer and exporter --- .../Exports/ProductionTempExporter.php | 333 ++++++++++ .../Imports/ProductionTempImporter.php | 621 ++++++++++++++++++ 2 files changed, 954 insertions(+) create mode 100644 app/Filament/Exports/ProductionTempExporter.php create mode 100644 app/Filament/Imports/ProductionTempImporter.php diff --git a/app/Filament/Exports/ProductionTempExporter.php b/app/Filament/Exports/ProductionTempExporter.php new file mode 100644 index 0000000..2998364 --- /dev/null +++ b/app/Filament/Exports/ProductionTempExporter.php @@ -0,0 +1,333 @@ +label('NO') + ->state(function ($record) use (&$rowNumber) { + // Increment and return the row number + return ++$rowNumber; + }), + ExportColumn::make('plant.code') + ->label('PLANT CODE'), + ExportColumn::make('machine.work_center') + ->label('WORK CENTER'), + ExportColumn::make('item.code') + ->label('ITEM CODE'), + ExportColumn::make('aufnr') + ->label('AUFNR'), + ExportColumn::make('class') + ->label('CLASS'), + ExportColumn::make('arbid') + ->label('ARBID'), + ExportColumn::make('gamng') + ->label('GAMNG'), + ExportColumn::make('lmnga') + ->label('LMNGA'), + ExportColumn::make('gernr') + ->label('GERNR'), + ExportColumn::make('zz1_cn_bill_ord') + ->label('ZZ1 CN BILL ORD'), + ExportColumn::make('zmm_amps') + ->label('ZMM AMPS'), + ExportColumn::make('zmm_brand') + ->label('ZMM BRAND'), + ExportColumn::make('zmm_degreeofprotection') + ->label('ZMM DEGREEOFPROTECTION'), + ExportColumn::make('zmm_delivery') + ->label('ZMM DELIVERY'), + ExportColumn::make('zmm_dir_rot') + ->label('ZMM DIR ROT'), + ExportColumn::make('zmm_discharge') + ->label('ZMM DISCHARGE'), + ExportColumn::make('zmm_discharge_max') + ->label('ZMM DISCHARGE MAX'), + ExportColumn::make('zmm_discharge_min') + ->label('ZMM DISCHARGE MIN'), + ExportColumn::make('zmm_duty') + ->label('ZMM DUTY'), + ExportColumn::make('zmm_eff_motor') + ->label('ZMM EFF MOTOR'), + ExportColumn::make('zmm_eff_pump') + ->label('ZMM EFF PUMP'), + ExportColumn::make('zmm_frequency') + ->label('ZMM FREQUENCY'), + ExportColumn::make('zmm_head') + ->label('ZMM HEAD'), + ExportColumn::make('zmm_heading') + ->label('ZMM HEADING'), + ExportColumn::make('zmm_head_max') + ->label('ZMM HEAD MAX'), + ExportColumn::make('zmm_head_minimum') + ->label('ZMM HEAD MINIMUM'), + ExportColumn::make('zmm_idx_eff_mtr') + ->label('ZMM IDX EFF MTR'), + ExportColumn::make('zmm_idx_eff_pump') + ->label('ZMM IDX EFF PUMP'), + ExportColumn::make('zmm_kvacode') + ->label('ZMM KVACODE'), + ExportColumn::make('zmm_maxambtemp') + ->label('ZMM MAXAMBTEMP'), + ExportColumn::make('zmm_mincoolingflow') + ->label('ZMM MINCOOLINGFLOW'), + ExportColumn::make('zmm_motorseries') + ->label('ZMM MOTORSERIES'), + ExportColumn::make('zmm_motor_model') + ->label('ZMM MOTOR MODEL'), + ExportColumn::make('zmm_outlet') + ->label('ZMM OUTLET'), + ExportColumn::make('zmm_phase') + ->label('ZMM PHASE'), + ExportColumn::make('zmm_pressure') + ->label('ZMM PRESSURE'), + ExportColumn::make('zmm_pumpflowtype') + ->label('ZMM PUMPFLOWTYPE'), + ExportColumn::make('zmm_pumpseries') + ->label('ZMM PUMPSERIES'), + ExportColumn::make('zmm_pump_model') + ->label('ZMM PUMP MODEL'), + ExportColumn::make('zmm_ratedpower') + ->label('ZMM RATEDPOWER'), + ExportColumn::make('zmm_region') + ->label('ZMM REGION'), + ExportColumn::make('zmm_servicefactor') + ->label('ZMM SERVICEFACTOR'), + ExportColumn::make('zmm_servicefactormaximumamps') + ->label('ZMM SERVICEFACTORMAXIMUMAMPS'), + ExportColumn::make('zmm_speed') + ->label('ZMM SPEED'), + ExportColumn::make('zmm_suction') + ->label('ZMM SUCTION'), + ExportColumn::make('zmm_suctionxdelivery') + ->label('ZMM SUCTIONXDELIVERY'), + ExportColumn::make('zmm_supplysource') + ->label('ZMM SUPPLYSOURCE'), + ExportColumn::make('zmm_temperature') + ->label('ZMM TEMPERATURE'), + ExportColumn::make('zmm_thrustload') + ->label('ZMM THRUSTLOAD'), + ExportColumn::make('zmm_volts') + ->label('ZMM VOLTS'), + ExportColumn::make('zmm_wire') + ->label('ZMM WIRE'), + ExportColumn::make('zmm_package') + ->label('ZMM PACKAGE'), + ExportColumn::make('zmm_pvarrayrating') + ->label('ZMM PVARRAYRATING'), + ExportColumn::make('zmm_isi') + ->label('ZMM ISI'), + ExportColumn::make('zmm_isimotor') + ->label('ZMM ISIMOTOR'), + ExportColumn::make('zmm_isipump') + ->label('ZMM ISIPUMP'), + ExportColumn::make('zmm_isipumpset') + ->label('ZMM ISIPUMPSET'), + ExportColumn::make('zmm_pumpset_model') + ->label('ZMM PUMPSET MODEL'), + ExportColumn::make('zmm_stages') + ->label('ZMM STAGES'), + ExportColumn::make('zmm_headrange') + ->label('ZMM HEADRANGE'), + ExportColumn::make('zmm_overall_efficiency') + ->label('ZMM OVERALL EFFICIENCY'), + ExportColumn::make('zmm_connection') + ->label('ZMM CONNECTION'), + ExportColumn::make('zmm_min_bore_size') + ->label('ZMM MIN BORE SIZE'), + ExportColumn::make('zmm_isireference') + ->label('ZMM ISIREFERENCE'), + ExportColumn::make('zmm_category') + ->label('ZMM CATEGORY'), + ExportColumn::make('zmm_submergence') + ->label('ZMM SUBMERGENCE'), + ExportColumn::make('zmm_capacitorstart') + ->label('ZMM CAPACITORSTART'), + ExportColumn::make('zmm_capacitorrun') + ->label('ZMM CAPACITORRUN'), + ExportColumn::make('zmm_inch') + ->label('ZMM INCH'), + ExportColumn::make('zmm_motor_type') + ->label('ZMM MOTOR TYPE'), + ExportColumn::make('zmm_dismantle_direction') + ->label('ZMM DISMANTLE DIRECTION'), + ExportColumn::make('zmm_eff_ovrall') + ->label('ZMM EFF OVRALL'), + ExportColumn::make('zmm_bodymoc') + ->label('ZMM BODYMOC'), + ExportColumn::make('zmm_rotormoc') + ->label('ZMM ROTORMOC'), + ExportColumn::make('zmm_dlwl') + ->label('ZMM DLWL'), + ExportColumn::make('zmm_inputpower') + ->label('ZMM INPUTPOWER'), + ExportColumn::make('zmm_imp_od') + ->label('ZMM IMP OD'), + ExportColumn::make('zmm_ambtemp') + ->label('ZMM AMBTEMP'), + ExportColumn::make('zmm_de') + ->label('ZMM DE'), + ExportColumn::make('zmm_dischargerange') + ->label('ZMM DISCHARGERANGE'), + ExportColumn::make('zmm_efficiency_class') + ->label('ZMM EFFICIENCY CLASS'), + ExportColumn::make('zmm_framesize') + ->label('ZMM FRAMESIZE'), + ExportColumn::make('zmm_impellerdiameter') + ->label('ZMM IMPELLERDIAMETER'), + ExportColumn::make('zmm_insulationclass') + ->label('ZMM INSULATIONCLASS'), + ExportColumn::make('zmm_maxflow') + ->label('ZMM MAXFLOW'), + ExportColumn::make('zmm_minhead') + ->label('ZMM MINHEAD'), + ExportColumn::make('zmm_mtrlofconst') + ->label('ZMM MTRLOFCONST'), + ExportColumn::make('zmm_nde') + ->label('ZMM NDE'), + ExportColumn::make('zmm_powerfactor') + ->label('ZMM POWERFACTOR'), + ExportColumn::make('zmm_tagno') + ->label('ZMM TANGO'), + ExportColumn::make('zmm_year') + ->label('ZMM YEAR'), + ExportColumn::make('zmm_laser_name') + ->label('ZMM LASER NAME'), + ExportColumn::make('zmm_logo_cp') + ->label('ZMM LOGO CP'), + ExportColumn::make('zmm_logo_ce') + ->label('ZMM LOGO CE'), + ExportColumn::make('zmm_logo_nsf') + ->label('ZMM LOGO NSF'), + ExportColumn::make('zmm_logo_eac') + ->label('ZMM LOGO EAC'), + ExportColumn::make('zmm_beenote') + ->label('ZMM BEENOTE'), + ExportColumn::make('zmm_beenumber') + ->label('ZMM BEENUMBER'), + ExportColumn::make('zmm_beestar') + ->label('ZMM BEESTAR'), + ExportColumn::make('zmm_codeclass') + ->label('ZMM CODECLASS'), + ExportColumn::make('zmm_colour') + ->label('ZMM COLOUR'), + ExportColumn::make('zmm_grade') + ->label('ZMM GRADE'), + ExportColumn::make('zmm_grwt_pset') + ->label('ZMM GRWT PSET'), + ExportColumn::make('zmm_grwt_cable') + ->label('ZMM GRWT CABLE'), + ExportColumn::make('zmm_grwt_motor') + ->label('ZMM GRWT MOTOR'), + ExportColumn::make('zmm_grwt_pf') + ->label('ZMM GRWT PF'), + ExportColumn::make('zmm_grwt_pump') + ->label('ZMM GRWT PUMP'), + ExportColumn::make('zmm_isivalve') + ->label('ZMM ISIVALVE'), + ExportColumn::make('zmm_isi_wc') + ->label('ZMM ISI WC'), + ExportColumn::make('zmm_labelperiod') + ->label('ZMM LABELPERIOD'), + ExportColumn::make('zmm_length') + ->label('ZMM LENGTH'), + ExportColumn::make('zmm_license_cml_no') + ->label('ZMM LICENSE CML NO'), + ExportColumn::make('zmm_mfgmonyr') + ->label('ZMM MFGMONYR'), + ExportColumn::make('zmm_modelyear') + ->label('ZMM MODELYEAR'), + ExportColumn::make('zmm_motoridentification') + ->label('ZMM MOTORIDENTIFICATION'), + ExportColumn::make('zmm_newt_pset') + ->label('ZMM NEWT PSET'), + ExportColumn::make('zmm_newt_cable') + ->label('ZMM NEWT CABLE'), + ExportColumn::make('zmm_newt_motor') + ->label('ZMM NEWT MOTOR'), + ExportColumn::make('zmm_newt_pf') + ->label('ZMM NEWT PF'), + ExportColumn::make('zmm_newt_pump') + ->label('ZMM NEWT PUMP'), + ExportColumn::make('zmm_packtype') + ->label('ZMM PACKTYPE'), + ExportColumn::make('zmm_panel') + ->label('ZMM PANEL'), + ExportColumn::make('zmm_performance_factor') + ->label('ZMM PERFORMANCE FACTOR'), + ExportColumn::make('zmm_pumpidentification') + ->label('ZMM PUMPIDENTIFICATION'), + ExportColumn::make('zmm_psettype') + ->label('ZMM PSETTYPE'), + ExportColumn::make('zmm_size') + ->label('ZMM SIZE'), + ExportColumn::make('zmm_eff_ttl') + ->label('ZMM EFF TTL'), + ExportColumn::make('zmm_type') + ->label('ZMM TYPE'), + ExportColumn::make('zmm_usp') + ->label('ZMM USP'), + ExportColumn::make('zmm_operating_range') + ->label('ZMM OPERATING RANGE'), + ExportColumn::make('zmm_intake_air') + ->label('ZMM INTAKE AIR'), + ExportColumn::make('zmm_oxygen_transfer_rate') + ->label('ZMM OXYGEN TRANSFER RATE'), + ExportColumn::make('zmm_air_inlet_pipesize') + ->label('ZMM AIR INLET PIPESIZE'), + ExportColumn::make('zmm_sump_depth') + ->label('ZMM SUMP DEPTH'), + ExportColumn::make('zmm_poles') + ->label('ZMM POLES'), + ExportColumn::make('zmm_motor_heading') + ->label('ZMM MOTOR HEADING'), + ExportColumn::make('zmm_motor_speed') + ->label('ZMM MOTOR SPEED'), + ExportColumn::make('zqmm_qty') + ->label('ZQMM QTY'), + ExportColumn::make('zmm_operating_temperature') + ->label('ZMM OPERATING TEMPERATURE'), + ExportColumn::make('zmm_axial_force') + ->label('ZMM AXIAL FORCE'), + ExportColumn::make('pending_released_status') + ->label('PENDING RELEASED STATUS'), + ExportColumn::make('created_at') + ->label('CREATED AT'), + ExportColumn::make('created_by') + ->label('CREATED BY'), + ExportColumn::make('updated_at') + ->label('UPDATED AT') + ->enabledByDefault(true), + ExportColumn::make('updated_by') + ->label('UPDATED BY') + ->enabledByDefault(true), + ExportColumn::make('deleted_at') + ->label('DELETED AT') + ->enabledByDefault(false), + ]; + } + + public static function getCompletedNotificationBody(Export $export): string + { + $body = 'Your production temp export has completed and '.number_format($export->successful_rows).' '.str('row')->plural($export->successful_rows).' exported.'; + + if ($failedRowsCount = $export->getFailedRowsCount()) { + $body .= ' '.number_format($failedRowsCount).' '.str('row')->plural($failedRowsCount).' failed to export.'; + } + + return $body; + } +} diff --git a/app/Filament/Imports/ProductionTempImporter.php b/app/Filament/Imports/ProductionTempImporter.php new file mode 100644 index 0000000..40293d1 --- /dev/null +++ b/app/Filament/Imports/ProductionTempImporter.php @@ -0,0 +1,621 @@ +requiredMapping() + ->exampleHeader('PLANT CODE') + ->example('1000') + ->label('PLANT CODE') + ->relationship(resolveUsing: 'code') + ->rules(['required']), + ImportColumn::make('machine') + ->requiredMapping() + ->exampleHeader('WORK CENTER') + ->example('RMGLAS01') + ->label('WORK CENTER') + ->relationship(resolveUsing: 'work_center') + ->rules(['required']), + ImportColumn::make('item') + ->requiredMapping() + ->exampleHeader('ITEM CODE') + ->example('630214') + ->label('ITEM CODE') + ->relationship(resolveUsing: 'code') + ->rules(['required']), + ImportColumn::make('aufnr') + ->label('AUFNR') + ->exampleHeader('AUFNR') + ->example('1234567'), + ImportColumn::make('class') + ->label('CLASS') + ->exampleHeader('CLASS') + ->example('ZLASER'), + ImportColumn::make('arbid') + ->label('ARBID') + ->exampleHeader('ARBID') + ->example('LASER'), + ImportColumn::make('gamng') + ->label('GAMNG') + ->exampleHeader('GAMNG') + ->example('1.000'), + ImportColumn::make('lmnga') + ->label('LMNGA') + ->exampleHeader('LMNGA') + ->example('1'), + ImportColumn::make('gernr') + ->label('GERNR') + ->exampleHeader('GERNR') + ->example('12345678901234'), + ImportColumn::make('zz1_cn_bill_ord') + ->label('ZZ1 CN BILL ORD') + ->exampleHeader('ZZ1 CN BILL ORD') + ->example('INDIA'), + ImportColumn::make('zmm_amps') + ->label('ZMM AMPS') + ->exampleHeader('ZMM AMPS') + ->example('11A'), + ImportColumn::make('zmm_brand') + ->label('ZMM BRAND') + ->exampleHeader('ZMM BRAND') + ->example('CRI'), + ImportColumn::make('zmm_degreeofprotection') + ->label('ZMM DEGREEOFPROTECTION') + ->exampleHeader('ZMM DEGREEOFPROTECTION') + ->example('IP55'), + ImportColumn::make('zmm_delivery') + ->label('ZMM DELIVERY') + ->exampleHeader('ZMM DELIVERY') + ->example('65MM'), + ImportColumn::make('zmm_dir_rot') + ->label('ZMM DIR ROT') + ->exampleHeader('ZMM DIR ROT') + ->example(''), + ImportColumn::make('zmm_discharge') + ->label('ZMM DISCHARGE') + ->exampleHeader('ZMM DISCHARGE') + ->example('17m³/h'), + ImportColumn::make('zmm_discharge_max') + ->label('ZMM DISCHARGE MAX') + ->exampleHeader('ZMM DISCHARGE MAX') + ->example(''), + ImportColumn::make('zmm_discharge_min') + ->label('ZMM DISCHARGE MIN') + ->exampleHeader('ZMM DISCHARGE MIN') + ->example(''), + ImportColumn::make('zmm_duty') + ->label('ZMM DUTY') + ->exampleHeader('ZMM DUTY') + ->example('DUTY S1'), + ImportColumn::make('zmm_eff_motor') + ->label('ZMM EFF MOTOR') + ->exampleHeader('ZMM EFF MOTOR') + ->example(''), + ImportColumn::make('zmm_eff_pump') + ->label('ZMM EFF PUMP') + ->exampleHeader('ZMM EFF PUMP') + ->example(''), + ImportColumn::make('zmm_frequency') + ->label('ZMM FREQUENCY') + ->exampleHeader('ZMM FREQUENCY') + ->example('50Hz'), + ImportColumn::make('zmm_head') + ->label('ZMM HEAD') + ->exampleHeader('ZMM HEAD') + ->example('77M'), + ImportColumn::make('zmm_heading') + ->label('ZMM HEADING') + ->exampleHeader('ZMM HEADING') + ->example('PRESSURE BOOSTER SYSTEM'), + ImportColumn::make('zmm_head_max') + ->label('ZMM HEAD MAX') + ->exampleHeader('ZMM HEAD MAX') + ->example('96m'), + ImportColumn::make('zmm_head_minimum') + ->label('ZMM HEAD MINIMUM') + ->exampleHeader('ZMM HEAD MINIMUM') + ->example(''), + ImportColumn::make('zmm_idx_eff_mtr') + ->label('ZMM IDX EFF MTR') + ->exampleHeader('ZMM IDX EFF MTR') + ->example(''), + ImportColumn::make('zmm_idx_eff_pump') + ->label('ZMM IDX EFF PUMP') + ->exampleHeader('ZMM IDX EFF PUMP') + ->example(''), + ImportColumn::make('zmm_kvacode') + ->label('ZMM KVACODE') + ->exampleHeader('ZMM KVACODE') + ->example(''), + ImportColumn::make('zmm_maxambtemp') + ->label('ZMM MAXAMBTEMP') + ->exampleHeader('ZMM MAXAMBTEMP') + ->example(''), + ImportColumn::make('zmm_mincoolingflow') + ->label('ZMM MINCOOLINGFLOW') + ->exampleHeader('ZMM MINCOOLINGFLOW') + ->example(''), + ImportColumn::make('zmm_motorseries') + ->label('ZMM MOTORSERIES') + ->exampleHeader('ZMM MOTORSERIES') + ->example(''), + ImportColumn::make('zmm_motor_model') + ->label('ZMM MOTOR MODEL') + ->exampleHeader('ZMM MOTOR MODEL') + ->example(''), + ImportColumn::make('zmm_outlet') + ->label('ZMM OUTLET') + ->exampleHeader('ZMM OUTLET') + ->example('IE2'), + ImportColumn::make('zmm_phase') + ->label('ZMM PHASE') + ->exampleHeader('ZMM PHASE') + ->example('3Ph'), + ImportColumn::make('zmm_pressure') + ->label('ZMM PRESSURE') + ->exampleHeader('ZMM PRESSURE') + ->example('16bar'), + ImportColumn::make('zmm_pumpflowtype') + ->label('ZMM PUMPFLOWTYPE') + ->exampleHeader('ZMM PUMPFLOWTYPE') + ->example(''), + ImportColumn::make('zmm_pumpseries') + ->label('ZMM PUMPSERIES') + ->exampleHeader('ZMM PUMPSERIES') + ->example(''), + ImportColumn::make('zmm_pump_model') + ->label('ZMM PUMP MODEL') + ->exampleHeader('ZMM PUMP MODEL') + ->example('MVHS-15/07TR'), + ImportColumn::make('zmm_ratedpower') + ->label('ZMM RATEDPOWER') + ->exampleHeader('ZMM RATEDPOWER') + ->example('5.5kW/7.5HP'), + ImportColumn::make('zmm_region') + ->label('ZMM REGION') + ->exampleHeader('ZMM REGION') + ->example(''), + ImportColumn::make('zmm_servicefactor') + ->label('ZMM SERVICEFACTOR') + ->exampleHeader('ZMM SERVICEFACTOR') + ->example(''), + ImportColumn::make('zmm_servicefactormaximumamps') + ->label('ZMM SERVICEFACTORMAXIMUMAMPS') + ->exampleHeader('ZMM SERVICEFACTORMAXIMUMAMPS') + ->example(''), + ImportColumn::make('zmm_speed') + ->label('ZMM SPEED') + ->exampleHeader('ZMM SPEED') + ->example('2900rpm'), + ImportColumn::make('zmm_suction') + ->label('ZMM SUCTION') + ->exampleHeader('ZMM SUCTION') + ->example('65mm'), + ImportColumn::make('zmm_suctionxdelivery') + ->label('ZMM SUCTIONXDELIVERY') + ->exampleHeader('ZMM SUCTIONXDELIVERY') + ->example('50 x 50mm'), + ImportColumn::make('zmm_supplysource') + ->label('ZMM SUPPLYSOURCE') + ->exampleHeader('ZMM SUPPLYSOURCE') + ->example('AC SUPPLY'), + ImportColumn::make('zmm_temperature') + ->label('ZMM TEMPERATURE') + ->exampleHeader('ZMM TEMPERATURE') + ->example('90°C'), + ImportColumn::make('zmm_thrustload') + ->label('ZMM THRUSTLOAD') + ->exampleHeader('ZMM THRUSTLOAD') + ->example(''), + ImportColumn::make('zmm_volts') + ->label('ZMM VOLTS') + ->exampleHeader('ZMM VOLTS') + ->example('415V'), + ImportColumn::make('zmm_wire') + ->label('ZMM WIRE') + ->exampleHeader('ZMM WIRE') + ->example(''), + ImportColumn::make('zmm_package') + ->label('ZMM PACKAGE') + ->exampleHeader('ZMM PACKAGE') + ->example(''), + ImportColumn::make('zmm_pvarrayrating') + ->label('ZMM PVARRAYRATING') + ->exampleHeader('ZMM PVARRAYRATING') + ->example(''), + ImportColumn::make('zmm_isi') + ->label('ZMM ISI') + ->exampleHeader('ZMM ISI') + ->example('Y'), + ImportColumn::make('zmm_isimotor') + ->label('ZMM ISIMOTOR') + ->exampleHeader('ZMM ISIMOTOR') + ->example('IS:12615'), + ImportColumn::make('zmm_isipump') + ->label('ZMM ISIPUMP') + ->exampleHeader('ZMM ISIPUMP') + ->example(''), + ImportColumn::make('zmm_isipumpset') + ->label('ZMM ISIPUMPSET') + ->exampleHeader('ZMM ISIPUMPSET') + ->example('IS:12615'), + ImportColumn::make('zmm_pumpset_model') + ->label('ZMM PUMPSET MODEL') + ->exampleHeader('ZMM PUMPSET MODEL') + ->example('MVHS-15/07TR'), + ImportColumn::make('zmm_stages') + ->label('ZMM STAGES') + ->exampleHeader('ZMM STAGES') + ->example('7'), + ImportColumn::make('zmm_headrange') + ->label('ZMM HEADRANGE') + ->exampleHeader('ZMM HEADRANGE') + ->example(''), + ImportColumn::make('zmm_overall_efficiency') + ->label('ZMM OVERALL EFFICIENCY') + ->exampleHeader('ZMM OVERALL EFFICIENCY') + ->example(''), + ImportColumn::make('zmm_connection') + ->label('ZMM CONNECTION') + ->exampleHeader('ZMM CONNECTION') + ->example('STAR/DELTA'), + ImportColumn::make('zmm_min_bore_size') + ->label('ZMM MIN BORE SIZE') + ->exampleHeader('ZMM MIN BORE SIZE') + ->example(''), + ImportColumn::make('zmm_isireference') + ->label('ZMM ISIREFERENCE') + ->exampleHeader('ZMM ISIREFERENCE') + ->example(''), + ImportColumn::make('zmm_category') + ->label('ZMM CATEGORY') + ->exampleHeader('ZMM CATEGORY') + ->example('B'), + ImportColumn::make('zmm_submergence') + ->label('ZMM SUBMERGENCE') + ->exampleHeader('ZMM SUBMERGENCE') + ->example(''), + ImportColumn::make('zmm_capacitorstart') + ->label('ZMM CAPACITORSTART') + ->exampleHeader('ZMM CAPACITORSTART') + ->example(''), + ImportColumn::make('zmm_capacitorrun') + ->label('ZMM CAPACITORRUN') + ->exampleHeader('ZMM CAPACITORRUN') + ->example(''), + ImportColumn::make('zmm_inch') + ->label('ZMM INCH') + ->exampleHeader('ZMM INCH') + ->example(''), + ImportColumn::make('zmm_motor_type') + ->label('ZMM MOTOR TYPE') + ->exampleHeader('ZMM MOTOR TYPE') + ->example('TEFC'), + ImportColumn::make('zmm_dismantle_direction') + ->label('ZMM DISMANTLE DIRECTION') + ->exampleHeader('ZMM DISMANTLE DIRECTION') + ->example(''), + ImportColumn::make('zmm_eff_ovrall') + ->label('ZMM EFF OVERALL') + ->exampleHeader('ZMM EFF OVERALL') + ->example(''), + ImportColumn::make('zmm_bodymoc') + ->label('ZMM BODYMOC') + ->exampleHeader('ZMM BODYMOC') + ->example(''), + ImportColumn::make('zmm_rotormoc') + ->label('ZMM ROTORMOC') + ->exampleHeader('ZMM ROTORMOC') + ->example(''), + ImportColumn::make('zmm_dlwl') + ->label('ZMM DLWL') + ->exampleHeader('ZMM DLWL') + ->example(''), + ImportColumn::make('zmm_inputpower') + ->label('ZMM INPUTPOWER') + ->exampleHeader('ZMM INPUTPOWER') + ->example(''), + ImportColumn::make('zmm_imp_od') + ->label('ZMM IMP OD') + ->exampleHeader('ZMM IMP OD') + ->example(''), + ImportColumn::make('zmm_ambtemp') + ->label('ZMM AMBTEMP') + ->exampleHeader('ZMM AMBTEMP') + ->example(''), + ImportColumn::make('zmm_de') + ->label('ZMM DE') + ->exampleHeader('ZMM DE') + ->example(''), + ImportColumn::make('zmm_dischargerange') + ->label('ZMM DISCHARGERANGE') + ->exampleHeader('ZMM DISCHARGERANGE') + ->example(''), + ImportColumn::make('zmm_efficiency_class') + ->label('ZMM EFFICIENCY CLASS') + ->exampleHeader('ZMM EFFICIENCY CLASS') + ->example('IE2'), + ImportColumn::make('zmm_framesize') + ->label('ZMM FRAMESIZE') + ->exampleHeader('ZMM FRAMESIZE') + ->example(''), + ImportColumn::make('zmm_impellerdiameter') + ->label('ZMM IMPELLERDIAMETER') + ->exampleHeader('ZMM IMPELLERDIAMETER') + ->example(''), + ImportColumn::make('zmm_insulationclass') + ->label('ZMM INSULATIONCLASS') + ->exampleHeader('ZMM INSULATIONCLASS') + ->example('F'), + ImportColumn::make('zmm_maxflow') + ->label('ZMM MAXFLOW') + ->exampleHeader('ZMM MAXFLOW') + ->example(''), + ImportColumn::make('zmm_minhead') + ->label('ZMM MINHEAD') + ->exampleHeader('ZMM MINHEAD') + ->example(''), + ImportColumn::make('zmm_mtrlofconst') + ->label('ZMM MTRLOFCONST') + ->exampleHeader('ZMM MTRLOFCONST') + ->example(''), + ImportColumn::make('zmm_nde') + ->label('ZMM NDE') + ->exampleHeader('ZMM NDE') + ->example(''), + ImportColumn::make('zmm_powerfactor') + ->label('ZMM POWERFACTOR') + ->exampleHeader('ZMM POWERFACTOR') + ->example(''), + ImportColumn::make('zmm_tagno') + ->label('ZMM TAGNO') + ->exampleHeader('ZMM TAGNO') + ->example(''), + ImportColumn::make('zmm_year') + ->label('ZMM YEAR') + ->exampleHeader('ZMM YEAR') + ->example(''), + ImportColumn::make('zmm_laser_name') + ->label('ZMM LASER NAME') + ->exampleHeader('ZMM LASER NAME') + ->example(''), + ImportColumn::make('zmm_logo_cp') + ->label('ZMM LOGO CP') + ->exampleHeader('ZMM LOGO CP') + ->example(''), + ImportColumn::make('zmm_logo_ce') + ->label('ZMM LOGO CE') + ->exampleHeader('ZMM LOGO CE') + ->example('NO'), + ImportColumn::make('zmm_logo_nsf') + ->label('ZMM LOGO NSF') + ->exampleHeader('ZMM LOGO NSF') + ->example(''), + ImportColumn::make('zmm_logo_eac') + ->label('ZMM LOGO EAC') + ->exampleHeader('ZMM LOGO EAC') + ->example(''), + ImportColumn::make('zmm_beenote') + ->label('ZMM BEENOTE') + ->exampleHeader('ZMM BEENOTE') + ->example(''), + ImportColumn::make('zmm_beenumber') + ->label('ZMM BEENUMBER') + ->exampleHeader('ZMM BEENUMBER') + ->example(''), + ImportColumn::make('zmm_beestar') + ->label('ZMM BEESTAR') + ->exampleHeader('ZMM BEESTAR') + ->example(''), + ImportColumn::make('zmm_codeclass') + ->label('ZMM CODECLASS') + ->exampleHeader('ZMM CODECLASS') + ->example(''), + ImportColumn::make('zmm_colour') + ->label('ZMM COLOUR') + ->exampleHeader('ZMM COLOUR') + ->example(''), + ImportColumn::make('zmm_grade') + ->label('ZMM GRADE') + ->exampleHeader('ZMM GRADE') + ->example(''), + ImportColumn::make('zmm_grwt_pset') + ->label('ZMM GRWT PSET') + ->exampleHeader('ZMM GRWT PSET') + ->example(''), + ImportColumn::make('zmm_grwt_cable') + ->label('ZMM GRWT CABLE') + ->exampleHeader('ZMM GRWT CABLE') + ->example(''), + ImportColumn::make('zmm_grwt_motor') + ->label('ZMM GRWT MOTOR') + ->exampleHeader('ZMM GRWT MOTOR') + ->example(''), + ImportColumn::make('zmm_grwt_pf') + ->label('ZMM GRWT PF') + ->exampleHeader('ZMM GRWT PF') + ->example(''), + ImportColumn::make('zmm_grwt_pump') + ->label('ZMM GRWT PUMP') + ->exampleHeader('ZMM GRWT PUMP') + ->example(''), + ImportColumn::make('zmm_isivalve') + ->label('ZMM ISIVALVE') + ->exampleHeader('ZMM ISIVALVE') + ->example(''), + ImportColumn::make('zmm_isi_wc') + ->label('ZMM ISI WC') + ->exampleHeader('ZMM ISI WC') + ->example(''), + ImportColumn::make('zmm_labelperiod') + ->label('ZMM LABELPERIOD') + ->exampleHeader('ZMM LABELPERIOD') + ->example(''), + ImportColumn::make('zmm_length') + ->label('ZMM LENGTH') + ->exampleHeader('ZMM LENGTH') + ->example(''), + ImportColumn::make('zmm_license_cml_no') + ->label('ZMM LICENSE CML NO') + ->exampleHeader('ZMM LICENSE CML NO') + ->example(''), + ImportColumn::make('zmm_mfgmonyr') + ->label('ZMM MFGMONYR') + ->exampleHeader('ZMM MFGMONYR') + ->example(''), + ImportColumn::make('zmm_modelyear') + ->label('ZMM MODELYEAR') + ->exampleHeader('ZMM MODELYEAR') + ->example(''), + ImportColumn::make('zmm_motoridentification') + ->label('ZMM MOTORIDENTIFICATION') + ->exampleHeader('ZMM MOTORIDENTIFICATION') + ->example(''), + ImportColumn::make('zmm_newt_pset') + ->label('ZMM NEWT PSET') + ->exampleHeader('ZMM NEWT PSET') + ->example(''), + ImportColumn::make('zmm_newt_cable') + ->label('ZMM NEWT CABLE') + ->exampleHeader('ZMM NEWT CABLE') + ->example(''), + ImportColumn::make('zmm_newt_motor') + ->label('ZMM NEWT MOTOR') + ->exampleHeader('ZMM NEWT MOTOR') + ->example(''), + ImportColumn::make('zmm_newt_pf') + ->label('ZMM NEWT PF') + ->exampleHeader('ZMM NEWT PF') + ->example(''), + ImportColumn::make('zmm_newt_pump') + ->label('ZMM NEWT PUMP') + ->exampleHeader('ZMM NEWT PUMP') + ->example(''), + ImportColumn::make('zmm_packtype') + ->label('ZMM PACKTYPE') + ->exampleHeader('ZMM PACKTYPE') + ->example(''), + ImportColumn::make('zmm_panel') + ->label('ZMM PANEL') + ->exampleHeader('ZMM PANEL') + ->example(''), + ImportColumn::make('zmm_performance_factor') + ->label('ZMM PERFORMANCE FACTOR') + ->exampleHeader('ZMM PERFORMANCE FACTOR') + ->example(''), + ImportColumn::make('zmm_pumpidentification') + ->label('ZMM PUMPIDENTIFICATION') + ->exampleHeader('ZMM PUMPIDENTIFICATION') + ->example(''), + ImportColumn::make('zmm_psettype') + ->label('ZMM PSETTYPE') + ->exampleHeader('ZMM PSETTYPE') + ->example(''), + ImportColumn::make('zmm_size') + ->label('ZMM SIZE') + ->exampleHeader('ZMM SIZE') + ->example(''), + ImportColumn::make('zmm_eff_ttl') + ->label('ZMM EFF TTL') + ->exampleHeader('ZMM EFF TTL') + ->example(''), + ImportColumn::make('zmm_type') + ->label('ZMM TYPE') + ->exampleHeader('ZMM TYPE') + ->example(''), + ImportColumn::make('zmm_usp') + ->label('ZMM USP') + ->exampleHeader('ZMM USP') + ->example(''), + ImportColumn::make('zmm_operating_range') + ->label('ZMM OPERATING RANGE') + ->exampleHeader('ZMM OPERATING RANGE') + ->example(''), + ImportColumn::make('zmm_intake_air') + ->label('ZMM USP') + ->exampleHeader('ZMM USP') + ->example(''), + ImportColumn::make('zmm_oxygen_transfer_rate') + ->label('ZMM OXYGEN TRANSFER RATE') + ->exampleHeader('ZMM OXYGEN TRANSFER RATE') + ->example(''), + ImportColumn::make('zmm_air_inlet_pipesize') + ->label('ZMM AIR INLET PIPESIZE') + ->exampleHeader('ZMM AIR INLET PIPESIZE') + ->example(''), + ImportColumn::make('zmm_sump_depth') + ->label('ZMM SUMP DEPTH') + ->exampleHeader('ZMM SUMP DEPTH') + ->example(''), + ImportColumn::make('zmm_poles') + ->label('ZMM POLES') + ->exampleHeader('ZMM POLES') + ->example(''), + ImportColumn::make('zmm_motor_heading') + ->label('ZMM MOTOR HEADING') + ->exampleHeader('ZMM MOTOR HEADING') + ->example(''), + ImportColumn::make('zmm_motor_speed') + ->label('ZMM MOTOR SPEED') + ->exampleHeader('ZMM MOTOR SPEED') + ->example(''), + ImportColumn::make('zqmm_qty') + ->label('ZQMM QTY') + ->exampleHeader('ZQMM QTY') + ->example(''), + ImportColumn::make('zmm_operating_temperature') + ->label('ZMM OPERATING TEMPERATURE') + ->exampleHeader('ZMM OPERATING TEMPERATURE') + ->example(''), + ImportColumn::make('zmm_axial_force') + ->label('ZMM AXIAL FORCE') + ->exampleHeader('ZMM AXIAL FORCE') + ->example(''), + ImportColumn::make('pending_released_status') + ->label('PENDING RELEASED STATUS') + ->exampleHeader('ZMM AXIAL FORCE') + ->example(''), + ImportColumn::make('created_by') + ->label('CREATED BY') + ->exampleHeader('CREATED BY') + ->example(''), + ImportColumn::make('updated_by') + ->label('UPDATED BY') + ->exampleHeader('UPDATED BY') + ->example(''), + ]; + } + + public function resolveRecord(): ?ProductionTemp + { + // return ProductionTemp::firstOrNew([ + // // Update existing records, matching them by `$this->data['column_name']` + // 'email' => $this->data['email'], + // ]); + + return new ProductionTemp; + } + + public static function getCompletedNotificationBody(Import $import): string + { + $body = 'Your production temp import has completed and '.number_format($import->successful_rows).' '.str('row')->plural($import->successful_rows).' imported.'; + + if ($failedRowsCount = $import->getFailedRowsCount()) { + $body .= ' '.number_format($failedRowsCount).' '.str('row')->plural($failedRowsCount).' failed to import.'; + } + + return $body; + } +} -- 2.49.1