Merge pull request 'Added repush button in class characteristics' (#1161) from ranjith-dev into master
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 13s

Reviewed-on: #1161
This commit was merged in pull request #1161.
This commit is contained in:
2026-10-04 09:18:19 +00:00

View File

@@ -2697,7 +2697,7 @@ class ClassCharacteristicResource extends Resource
if ($plantId) {
$query->where('plant_id', $plantId);
}
})->pluck('code', 'id');
})->orderBy('code')->pluck('code', 'id');
}),
TextInput::make('aufnr')
->label('Job Number')
@@ -2958,6 +2958,274 @@ class ClassCharacteristicResource extends Resource
]),
])
->headerActions([
Tables\Actions\Action::make('Repush Class Characteristic')
->label('Repush Class Characteristic')
->form([
Select::make('plant_id')
// ->options(Plant::pluck('name', 'id')->toArray()) // Fetch plant names and IDs
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->searchable()
->label('Search by Plant Name')
->required()
->default(function () {
return optional(ClassCharacteristic::latest()->first())->plant_id;
})
->afterStateUpdated(function ($state, callable $set, callable $get) {
// $set('class_characteristics_serial', null);
$plantId = $get('plant_id');
if (! $plantId) {
$set('invoice_serial_number', null);
return;
}
$plantCode = Plant::find($plantId)?->code ?? null;
$directory = "uploads/classcharacteristic/{$plantCode}";
if ($plantId && ! Storage::disk('local')->exists($directory)) {
Storage::disk('local')->makeDirectory($directory);
}
})
->reactive(),
Select::make('item_id')
->label('Item Code')
->reactive()
->required()
->searchable()
->options(function (callable $get) {
$plantId = $get('plant_id');
if (! $plantId) {
return [];
}
return Item::where('plant_id', $plantId)
->pluck('code', 'id')
->toArray();
}),
TextInput::make('machine_id')
->label('Machine')
->reactive()
->required(),
TextInput::make('production_order')
->label('Production Order')
->reactive()
->required(),
])
->action(function (array $data) {
$plantId = $data['plant_id'];
$itemId = $data['item_id'];
$plant = Plant::find($plantId);
$plantCode = $plant?->code ?? null;
$item = Item::where('plant_id', $plantId)->find($itemId);
$itemCode = $item?->code ?? null;
$workCenter = $data['machine_id'];
$pOrder = $data['production_order'];
$userName = Filament::auth()->user()->name;
$item = Item::where('plant_id', $plantId)->where('code', $itemCode)->first();
$machine = Machine::where('plant_id', $plantId)->where('work_center', $workCenter)->first();
$itemCharacMaster = ItemCharacteristic::where('plant_id', $plantId)->where('item_id', $itemId)->first();
if (! $itemCharacMaster) {
Notification::make()
->title('Invalid Item Characteristic')
->body("Item characteristics master not found agianst item '$itemCode' and plant '$plantCode'.")
->danger();
return;
}
$classCharFound = ClassCharacteristic::where('plant_id', $plantId)->where('item_id', $itemId)->where('machine_id', $machine->id)->where('aufnr', $pOrder)->first();
if (! $classCharFound) {
Notification::make()
->title('Invalid Class Characteristic')
->body("Class characteristics record not found agianst item '$itemCode' and plant '$plantCode' to update.")
->danger();
return;
}
// $modelHeading = $itemCharacMaster->zmm_heading;
// $updateModelTypeCount = null;
// if (Str::contains($modelHeading, 'PRESSURE BOOSTER SYSTEM', ignoreCase: true) || Str::contains($modelHeading, 'PUMP SET', ignoreCase: true) || Str::contains($modelHeading, 'PUMPSET', ignoreCase: true) || Str::contains($modelHeading, 'PUMPS', ignoreCase: true)) {
// $updateModelTypeCount = '3';
// }
$record = ClassCharacteristic::where('plant_id', $plantId)
->where('item_id', $item->id)
->where('machine_id', $machine->id)
->where('aufnr', $pOrder)
->update([
// 'marked_by' => $userName,
// 'marked_datetime' => now(),
// 'created_by' => $userName,
'updated_by' => $userName,
'zz1_cn_bill_ord' => $itemCharacMaster->zz1_cn_bill_ord,
'zmm_amps' => $itemCharacMaster->zmm_amps,
'zmm_brand' => $itemCharacMaster->zmm_brand,
'zmm_degreeofprotection' => $itemCharacMaster->zmm_degreeofprotection,
'zmm_delivery' => $itemCharacMaster->zmm_delivery,
'zmm_dir_rot' => $itemCharacMaster->zmm_dir_rot,
'zmm_discharge' => $itemCharacMaster->zmm_discharge,
'zmm_discharge_max' => $itemCharacMaster->zmm_discharge_max,
'zmm_discharge_min' => $itemCharacMaster->zmm_discharge_min,
'zmm_duty' => $itemCharacMaster->zmm_duty,
'zmm_eff_motor' => $itemCharacMaster->zmm_eff_motor,
'zmm_eff_pump' => $itemCharacMaster->zmm_eff_pump,
'zmm_frequency' => $itemCharacMaster->zmm_frequency,
'zmm_head' => $itemCharacMaster->zmm_head,
'zmm_heading' => $itemCharacMaster->zmm_heading,
'zmm_head_max' => $itemCharacMaster->zmm_head_max,
'zmm_head_minimum' => $itemCharacMaster->zmm_head_minimum,
'zmm_idx_eff_mtr' => $itemCharacMaster->zmm_idx_eff_mtr,
'zmm_idx_eff_pump' => $itemCharacMaster->zmm_idx_eff_pump,
'zmm_kvacode' => $itemCharacMaster->zmm_kvacode,
'zmm_maxambtemp' => $itemCharacMaster->zmm_maxambtemp,
'zmm_mincoolingflow' => $itemCharacMaster->zmm_mincoolingflow,
'zmm_motorseries' => $itemCharacMaster->zmm_motorseries,
'zmm_motor_model' => $itemCharacMaster->zmm_motor_model,
'zmm_outlet' => $itemCharacMaster->zmm_outlet,
'zmm_phase' => $itemCharacMaster->zmm_phase,
'zmm_pressure' => $itemCharacMaster->zmm_pressure,
'zmm_pumpflowtype' => $itemCharacMaster->zmm_pumpflowtype,
'zmm_pumpseries' => $itemCharacMaster->zmm_pumpseries,
'zmm_pump_model' => $itemCharacMaster->zmm_pump_model,
'zmm_ratedpower' => $itemCharacMaster->zmm_ratedpower,
'zmm_region' => $itemCharacMaster->zmm_region,
'zmm_servicefactor' => $itemCharacMaster->zmm_servicefactor,
'zmm_servicefactormaximumamps' => $itemCharacMaster->zmm_servicefactormaximumamps,
'zmm_speed' => $itemCharacMaster->zmm_speed,
'zmm_suction' => $itemCharacMaster->zmm_suction,
'zmm_suctionxdelivery' => $itemCharacMaster->zmm_suctionxdelivery,
'zmm_supplysource' => $itemCharacMaster->zmm_supplysource,
'zmm_temperature' => $itemCharacMaster->zmm_temperature,
'zmm_thrustload' => $itemCharacMaster->zmm_thrustload,
'zmm_volts' => $itemCharacMaster->zmm_volts,
'zmm_wire' => $itemCharacMaster->zmm_wire,
'zmm_package' => $itemCharacMaster->zmm_package,
'zmm_pvarrayrating' => $itemCharacMaster->zmm_pvarrayrating,
'zmm_isi' => $itemCharacMaster->zmm_isi,
'zmm_isimotor' => $itemCharacMaster->zmm_isimotor,
'zmm_isipump' => $itemCharacMaster->zmm_isipump,
'zmm_isipumpset' => $itemCharacMaster->zmm_isipumpset,
'zmm_pumpset_model' => $itemCharacMaster->zmm_pumpset_model,
'zmm_stages' => $itemCharacMaster->zmm_stages,
'zmm_headrange' => $itemCharacMaster->zmm_headrange,
'zmm_overall_efficiency' => $itemCharacMaster->zmm_overall_efficiency,
'zmm_connection' => $itemCharacMaster->zmm_connection,
'zmm_min_bore_size' => $itemCharacMaster->zmm_min_bore_size,
'zmm_isireference' => $itemCharacMaster->zmm_isireference,
'zmm_category' => $itemCharacMaster->zmm_category,
'zmm_submergence' => $itemCharacMaster->zmm_submergence,
'zmm_capacitorstart' => $itemCharacMaster->zmm_capacitorstart,
'zmm_capacitorrun' => $itemCharacMaster->zmm_capacitorrun,
'zmm_inch' => $itemCharacMaster->zmm_inch,
'zmm_motor_type' => $itemCharacMaster->zmm_motor_type,
'zmm_dismantle_direction' => $itemCharacMaster->zmm_dismantle_direction,
'zmm_eff_ovrall' => $itemCharacMaster->zmm_eff_ovrall,
'zmm_bodymoc' => $itemCharacMaster->zmm_bodymoc,
'zmm_rotormoc' => $itemCharacMaster->zmm_rotormoc,
'zmm_dlwl' => $itemCharacMaster->zmm_dlwl,
'zmm_inputpower' => $itemCharacMaster->zmm_inputpower,
'zmm_imp_od' => $itemCharacMaster->zmm_imp_od,
'zmm_ambtemp' => $itemCharacMaster->zmm_ambtemp,
'zmm_de' => $itemCharacMaster->zmm_de,
'zmm_dischargerange' => $itemCharacMaster->zmm_dischargerange,
'zmm_efficiency_class' => $itemCharacMaster->zmm_efficiency_class,
'zmm_framesize' => $itemCharacMaster->zmm_framesize,
'zmm_impellerdiameter' => $itemCharacMaster->zmm_impellerdiameter,
'zmm_insulationclass' => $itemCharacMaster->zmm_insulationclass,
'zmm_maxflow' => $itemCharacMaster->zmm_maxflow,
'zmm_minhead' => $itemCharacMaster->zmm_minhead,
'zmm_mtrlofconst' => $itemCharacMaster->zmm_mtrlofconst,
'zmm_nde' => $itemCharacMaster->zmm_nde,
'zmm_powerfactor' => $itemCharacMaster->zmm_powerfactor,
'zmm_tagno' => $itemCharacMaster->zmm_tagno,
'zmm_year' => $itemCharacMaster->zmm_year,
'zmm_laser_name' => $itemCharacMaster->zmm_laser_name,
'zmm_logo_cp' => $itemCharacMaster->zmm_logo_cp,
'zmm_logo_ce' => $itemCharacMaster->zmm_logo_ce,
'zmm_logo_nsf' => $itemCharacMaster->zmm_logo_nsf,
'zmm_logo_eac' => $itemCharacMaster->zmm_logo_eac,
'zmm_beenote' => $itemCharacMaster->zmm_beenote,
'zmm_beenumber' => $itemCharacMaster->zmm_beenumber,
'zmm_beestar' => $itemCharacMaster->zmm_beestar,
'zmm_codeclass' => $itemCharacMaster->zmm_codeclass,
'zmm_colour' => $itemCharacMaster->zmm_colour,
'zmm_grade' => $itemCharacMaster->zmm_grade,
'zmm_grwt_pset' => $itemCharacMaster->zmm_grwt_pset,
'zmm_grwt_cable' => $itemCharacMaster->zmm_grwt_cable,
'zmm_grwt_motor' => $itemCharacMaster->zmm_grwt_motor,
'zmm_grwt_pf' => $itemCharacMaster->zmm_grwt_pf,
'zmm_grwt_pump' => $itemCharacMaster->zmm_grwt_pump,
'zmm_isivalve' => $itemCharacMaster->zmm_isivalve,
'zmm_isi_wc' => $itemCharacMaster->zmm_isi_wc,
'zmm_labelperiod' => $itemCharacMaster->zmm_labelperiod,
'zmm_length' => $itemCharacMaster->zmm_length,
'zmm_license_cml_no' => $itemCharacMaster->zmm_license_cml_no,
'zmm_mfgmonyr' => $itemCharacMaster->zmm_mfgmonyr,
'zmm_modelyear' => $itemCharacMaster->zmm_modelyear,
'zmm_motoridentification' => $itemCharacMaster->zmm_motoridentification,
'zmm_newt_pset' => $itemCharacMaster->zmm_newt_pset,
'zmm_newt_cable' => $itemCharacMaster->zmm_newt_cable,
'zmm_newt_motor' => $itemCharacMaster->zmm_newt_motor,
'zmm_newt_pf' => $itemCharacMaster->zmm_newt_pf,
'zmm_newt_pump' => $itemCharacMaster->zmm_newt_pump,
'zmm_packtype' => $itemCharacMaster->zmm_packtype,
'zmm_panel' => $itemCharacMaster->zmm_panel,
'zmm_performance_factor' => $itemCharacMaster->zmm_performance_factor,
'zmm_pumpidentification' => $itemCharacMaster->zmm_pumpidentification,
'zmm_psettype' => $itemCharacMaster->zmm_psettype,
'zmm_size' => $itemCharacMaster->zmm_size,
'zmm_eff_ttl' => $itemCharacMaster->zmm_eff_ttl,
'zmm_type' => $itemCharacMaster->zmm_type,
'zmm_usp' => $itemCharacMaster->zmm_usp,
'zmm_operating_range' => $itemCharacMaster->zmm_operating_range,
'zmm_intake_air' => $itemCharacMaster->zmm_intake_air,
'zmm_oxygen_transfer_rate' => $itemCharacMaster->zmm_oxygen_transfer_rate,
'zmm_air_inlet_pipesize' => $itemCharacMaster->zmm_air_inlet_pipesize,
'zmm_sump_depth' => $itemCharacMaster->zmm_sump_depth,
'zmm_poles' => $itemCharacMaster->zmm_poles,
'zmm_motor_heading' => $itemCharacMaster->zmm_motor_heading,
'zmm_motor_speed' => $itemCharacMaster->zmm_motor_speed,
'zqmm_qty' => $itemCharacMaster->zqmm_qty,
'zmm_operating_temperature' => $itemCharacMaster->zmm_operating_temperature,
'zmm_axial_force' => $itemCharacMaster->zmm_axial_force,
'zmm_mrp' => $itemCharacMaster->zmm_mrp,
]);
if ($record) {
Notification::make()
->title('Update Success')
->body("Records updated successfully against job number '$pOrder' and plant '$plantCode'.")
->success();
return;
} else {
Notification::make()
->title('Update Failed')
->body("Records updation failed against job number '$pOrder' and plant '$plantCode'.")
->danger();
return;
}
})
->visible(function () {
return Filament::auth()->user()->can('view repush class characteristic');
}),
Tables\Actions\Action::make('Import Class Characteristic Serial')
->label('Import Class Characteristic Serial')
->form([
@@ -3439,7 +3707,7 @@ class ClassCharacteristicResource extends Resource
'item_id' => $item->id,
'machine_id' => $machine->id,
'aufnr' => $pOrder,
'gamng' => $orderQuan . '.000',
'gamng' => $orderQuan.'.000',
'lmnga' => $releaseQuan,
'gernr' => $serialNumber,
'motor_pump_pumpset_status' => $updateModelTypeCount,