Updated default values and approver statuses on request characteristic resource file
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 13s
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 13s
This commit is contained in:
@@ -246,11 +246,11 @@ class RequestCharacteristicResource extends Resource
|
|||||||
}
|
}
|
||||||
$set('updated_by', Filament::auth()->user()?->name);
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
})
|
||||||
->default(function () {
|
// ->default(function () {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
// $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))
|
->readOnly(fn ($get) => ($get('item_id') == null))
|
||||||
->disabled(fn (Get $get) => ! empty($get('id'))),
|
->disabled(fn (Get $get) => ! empty($get('id'))),
|
||||||
Forms\Components\TextInput::make('gernr')
|
Forms\Components\TextInput::make('gernr')
|
||||||
@@ -311,19 +311,24 @@ class RequestCharacteristicResource extends Resource
|
|||||||
$set('update_value', null);
|
$set('update_value', null);
|
||||||
$set('updated_by', Filament::auth()->user()?->name);
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
})
|
||||||
->default(function () {
|
// ->default(function () {
|
||||||
$machineName = '';
|
// $machineName = '';
|
||||||
$reqId = RequestCharacteristic::latest()->first()?->characteristic_approver_master_id;
|
// $reqId = RequestCharacteristic::latest()->first()?->characteristic_approver_master_id;
|
||||||
if ($reqId) {
|
// if ($reqId) {
|
||||||
$reqMac = CharacteristicApproverMaster::where('id', $reqId)->first()?->machine_name;
|
// $reqMac = CharacteristicApproverMaster::where('id', $reqId)->first()?->machine_name;
|
||||||
$machineName = $reqMac ?? null;
|
// $machineName = $reqMac ?? null;
|
||||||
} else {
|
// } else {
|
||||||
$machineName = null;
|
// $machineName = null;
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
// $userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
|
// return ($userHas && strlen($userHas) > 0) ? null : $machineName ?? null;
|
||||||
|
// })
|
||||||
|
->default(function () {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$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) {
|
->afterStateHydrated(function ($component, $state, Get $get, Set $set) {
|
||||||
if ($get('id')) {
|
if ($get('id')) {
|
||||||
@@ -377,21 +382,15 @@ class RequestCharacteristicResource extends Resource
|
|||||||
}
|
}
|
||||||
$set('updated_by', Filament::auth()->user()?->name);
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
})
|
||||||
|
// ->default(function () {
|
||||||
|
// $userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
|
// return ($userHas && strlen($userHas) > 0) ? null : 'Characteristic';
|
||||||
|
// })
|
||||||
->default(function () {
|
->default(function () {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? null : 'Characteristic';
|
return ($userHas && strlen($userHas) > 0) ? null : optional(RequestCharacteristic::latest()->first())->characteristicApproverMaster->approver_type ?? null;
|
||||||
// $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;
|
|
||||||
})
|
})
|
||||||
->afterStateHydrated(function ($component, $state, Get $get, Set $set) {
|
->afterStateHydrated(function ($component, $state, Get $get, Set $set) {
|
||||||
if ($get('id')) {
|
if ($get('id')) {
|
||||||
@@ -457,7 +456,11 @@ class RequestCharacteristicResource extends Resource
|
|||||||
$set('update_value', null);
|
$set('update_value', null);
|
||||||
$set('updated_by', Filament::auth()->user()?->name);
|
$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'))),
|
->disabled(fn (Get $get) => ! empty($get('id'))),
|
||||||
Section::make('Request Characteristic Details')
|
Section::make('Request Characteristic Details')
|
||||||
// ->columnSpan(['default' => 2, 'sm' => 4])
|
// ->columnSpan(['default' => 2, 'sm' => 4])
|
||||||
@@ -577,11 +580,21 @@ class RequestCharacteristicResource extends Resource
|
|||||||
->label('Approver Status')
|
->label('Approver Status')
|
||||||
->reactive()
|
->reactive()
|
||||||
// ->live()
|
// ->live()
|
||||||
->options([
|
->options(function (callable $set, callable $get) {
|
||||||
'Approved' => 'Approved',
|
$apprTyp = $get('approver_type');
|
||||||
'Hold' => 'Hold',
|
|
||||||
'Rejected' => 'Rejected',
|
if ($apprTyp && $apprTyp == 'Stop') {
|
||||||
])
|
return [
|
||||||
|
'Approved' => 'Approved',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'Approved' => 'Approved',
|
||||||
|
'Hold' => 'Hold',
|
||||||
|
'Rejected' => 'Rejected',
|
||||||
|
];
|
||||||
|
})
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
if ($state) {// && empty($get('approved1_at'))
|
if ($state) {// && empty($get('approved1_at'))
|
||||||
$set('approved1_at', now()->toDateTimeString()); // now()->format('d-m-Y H:i:s')
|
$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')
|
Forms\Components\TextInput::make('approver_remark1')
|
||||||
->label('Approver Remark')
|
->label('Approver Remark')
|
||||||
->live()
|
->reactive()
|
||||||
->maxLength(60)
|
->maxLength(60)
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$appStat = $get('approver_status1');
|
$appStat = $get('approver_status1');
|
||||||
@@ -693,11 +706,21 @@ class RequestCharacteristicResource extends Resource
|
|||||||
Forms\Components\Select::make('approver_status2')
|
Forms\Components\Select::make('approver_status2')
|
||||||
->label('Approver Status')
|
->label('Approver Status')
|
||||||
->reactive()
|
->reactive()
|
||||||
->options([
|
->options(function (callable $set, callable $get) {
|
||||||
'Approved' => 'Approved',
|
$apprTyp = $get('approver_type');
|
||||||
'Hold' => 'Hold',
|
|
||||||
'Rejected' => 'Rejected',
|
if ($apprTyp && $apprTyp == 'Stop') {
|
||||||
])
|
return [
|
||||||
|
'Approved' => 'Approved',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'Approved' => 'Approved',
|
||||||
|
'Hold' => 'Hold',
|
||||||
|
'Rejected' => 'Rejected',
|
||||||
|
];
|
||||||
|
})
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
if ($state) {
|
if ($state) {
|
||||||
$set('approved2_at', now()->toDateTimeString());
|
$set('approved2_at', now()->toDateTimeString());
|
||||||
@@ -734,7 +757,7 @@ class RequestCharacteristicResource extends Resource
|
|||||||
}),
|
}),
|
||||||
Forms\Components\TextInput::make('approver_remark2')
|
Forms\Components\TextInput::make('approver_remark2')
|
||||||
->label('Approver Remark')
|
->label('Approver Remark')
|
||||||
->live()
|
->reactive()
|
||||||
->maxLength(60)
|
->maxLength(60)
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$appStat = $get('approver_status2');
|
$appStat = $get('approver_status2');
|
||||||
@@ -807,11 +830,21 @@ class RequestCharacteristicResource extends Resource
|
|||||||
Forms\Components\Select::make('approver_status3')
|
Forms\Components\Select::make('approver_status3')
|
||||||
->label('Approver Status')
|
->label('Approver Status')
|
||||||
->reactive()
|
->reactive()
|
||||||
->options([
|
->options(function (callable $set, callable $get) {
|
||||||
'Approved' => 'Approved',
|
$apprTyp = $get('approver_type');
|
||||||
'Hold' => 'Hold',
|
|
||||||
'Rejected' => 'Rejected',
|
if ($apprTyp && $apprTyp == 'Stop') {
|
||||||
])
|
return [
|
||||||
|
'Approved' => 'Approved',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'Approved' => 'Approved',
|
||||||
|
'Hold' => 'Hold',
|
||||||
|
'Rejected' => 'Rejected',
|
||||||
|
];
|
||||||
|
})
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
if ($state) {
|
if ($state) {
|
||||||
$set('approved3_at', now()->toDateTimeString());
|
$set('approved3_at', now()->toDateTimeString());
|
||||||
@@ -847,7 +880,7 @@ class RequestCharacteristicResource extends Resource
|
|||||||
}),
|
}),
|
||||||
Forms\Components\TextInput::make('approver_remark3')
|
Forms\Components\TextInput::make('approver_remark3')
|
||||||
->label('Approver Remark')
|
->label('Approver Remark')
|
||||||
->live()
|
->reactive()
|
||||||
->maxLength(60)
|
->maxLength(60)
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$appStat = $get('approver_status3');
|
$appStat = $get('approver_status3');
|
||||||
|
|||||||
Reference in New Issue
Block a user