ranjith-dev #325
@@ -7,6 +7,7 @@ use App\Filament\Resources\RequestCharacteristicResource\Pages;
|
|||||||
use App\Models\CharacteristicApproverMaster;
|
use App\Models\CharacteristicApproverMaster;
|
||||||
use App\Models\Item;
|
use App\Models\Item;
|
||||||
use App\Models\Machine;
|
use App\Models\Machine;
|
||||||
|
use App\Models\Plant;
|
||||||
use App\Models\RequestCharacteristic;
|
use App\Models\RequestCharacteristic;
|
||||||
use Closure;
|
use Closure;
|
||||||
use Filament\Facades\Filament;
|
use Filament\Facades\Filament;
|
||||||
@@ -65,12 +66,20 @@ class RequestCharacteristicResource extends Resource
|
|||||||
Section::make('')
|
Section::make('')
|
||||||
->schema([
|
->schema([
|
||||||
Forms\Components\Select::make('plant_id')
|
Forms\Components\Select::make('plant_id')
|
||||||
->label('Plant')
|
->label('Plant Name')
|
||||||
->reactive()
|
|
||||||
->relationship('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()
|
->required()
|
||||||
->default(function () {
|
->default(function () {
|
||||||
return optional(RequestCharacteristic::latest()->first())->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
|
return ($userHas && strlen($userHas) > 0) ? null : optional(RequestCharacteristic::latest()->first())->plant_id ?? null;
|
||||||
})
|
})
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$plantId = $get('plant_id');
|
$plantId = $get('plant_id');
|
||||||
@@ -80,8 +89,9 @@ class RequestCharacteristicResource extends Resource
|
|||||||
$set('aufnr', null);
|
$set('aufnr', null);
|
||||||
$set('machine_name', null);
|
$set('machine_name', null);
|
||||||
$set('characteristic_approver_master_id', null);
|
$set('characteristic_approver_master_id', null);
|
||||||
if (! $updRec && $plantId) {
|
$set('approver_type', null);
|
||||||
$set('work_flow_id', self::isNewWorkFlow($get));
|
if (! $updRec) {
|
||||||
|
$set('work_flow_id', $plantId ? self::isNewWorkFlow($get) : null);
|
||||||
}
|
}
|
||||||
$set('updated_by', Filament::auth()->user()?->name);
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
})
|
||||||
@@ -101,13 +111,16 @@ class RequestCharacteristicResource extends Resource
|
|||||||
})
|
})
|
||||||
->required()
|
->required()
|
||||||
->default(function () {
|
->default(function () {
|
||||||
return optional(RequestCharacteristic::latest()->first())->machine_id ?? [];
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
|
return ($userHas && strlen($userHas) > 0) ? null : optional(RequestCharacteristic::latest()->first())->machine_id ?? null;
|
||||||
})
|
})
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$set('item_id', null);
|
$set('item_id', null);
|
||||||
$set('aufnr', null);
|
$set('aufnr', null);
|
||||||
$set('machine_name', null);
|
$set('machine_name', null);
|
||||||
$set('characteristic_approver_master_id', null);
|
$set('characteristic_approver_master_id', null);
|
||||||
|
$set('approver_type', null);
|
||||||
$set('updated_by', Filament::auth()->user()?->name);
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
})
|
||||||
->disabled(fn ($get) => self::isFieldDisabled($get)),
|
->disabled(fn ($get) => self::isFieldDisabled($get)),
|
||||||
@@ -115,6 +128,7 @@ class RequestCharacteristicResource extends Resource
|
|||||||
->label('Work Flow ID')
|
->label('Work Flow ID')
|
||||||
->readOnly()
|
->readOnly()
|
||||||
->reactive()
|
->reactive()
|
||||||
|
->required()
|
||||||
->default(function ($state, callable $set, callable $get) {
|
->default(function ($state, callable $set, callable $get) {
|
||||||
$updRec = $get('id');
|
$updRec = $get('id');
|
||||||
if (! $updRec) {
|
if (! $updRec) {
|
||||||
@@ -128,9 +142,10 @@ class RequestCharacteristicResource extends Resource
|
|||||||
// ->ignore($get('id'));
|
// ->ignore($get('id'));
|
||||||
// }),
|
// }),
|
||||||
Forms\Components\Select::make('item_id')
|
Forms\Components\Select::make('item_id')
|
||||||
->label('Item')
|
->label('Item Code')
|
||||||
// ->relationship('item', 'id')
|
// ->relationship('item', 'id')
|
||||||
->reactive()
|
->reactive()
|
||||||
|
->required()
|
||||||
->searchable()
|
->searchable()
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$plantId = $get('plant_id');
|
$plantId = $get('plant_id');
|
||||||
@@ -140,44 +155,64 @@ class RequestCharacteristicResource extends Resource
|
|||||||
|
|
||||||
return Item::where('plant_id', $plantId)->pluck('code', 'id');
|
return Item::where('plant_id', $plantId)->pluck('code', 'id');
|
||||||
})
|
})
|
||||||
->required()
|
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$set('aufnr', null);
|
if (! $state) {
|
||||||
|
$set('aufnr', null);
|
||||||
|
}
|
||||||
$set('updated_by', Filament::auth()->user()?->name);
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
})
|
||||||
->default(function () {
|
->default(function () {
|
||||||
return optional(RequestCharacteristic::latest()->first())->item_id ?? [];
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
|
return ($userHas && strlen($userHas) > 0) ? null : optional(RequestCharacteristic::latest()->first())->item_id ?? null;
|
||||||
})
|
})
|
||||||
->disabled(fn ($get) => self::isFieldDisabled($get)),
|
->disabled(fn ($get) => self::isFieldDisabled($get)),
|
||||||
Forms\Components\TextInput::make('aufnr')
|
Forms\Components\TextInput::make('aufnr')
|
||||||
->label('Aufnr')
|
->label('Job Number')
|
||||||
->reactive()
|
->reactive()
|
||||||
->required()
|
->required(function (callable $get) {
|
||||||
|
$item = $get('item_id');
|
||||||
|
if ($item) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
})
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$set('updated_by', Filament::auth()->user()?->name);
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
})
|
||||||
->default(function () {
|
->default(function () {
|
||||||
return optional(RequestCharacteristic::latest()->first())->aufnr ?? '';
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
|
return ($userHas && strlen($userHas) > 0) ? null : optional(RequestCharacteristic::latest()->first())->aufnr ?? null;
|
||||||
})
|
})
|
||||||
|
->readOnly(fn ($get) => ($get('item_id') == null))
|
||||||
->disabled(fn ($get) => self::isFieldDisabled($get)),
|
->disabled(fn ($get) => self::isFieldDisabled($get)),
|
||||||
Forms\Components\Select::make('machine_name')
|
Forms\Components\Select::make('machine_name')
|
||||||
->label('Machines')
|
->label('Machine Name')
|
||||||
->reactive()
|
->reactive()
|
||||||
->nullable()
|
->nullable()
|
||||||
->searchable()
|
->searchable()
|
||||||
->options(function (callable $get) {
|
->options(function (callable $set, callable $get) {
|
||||||
$plantId = $get('plant_id');
|
$plantId = $get('plant_id');
|
||||||
$machineId = $get('machine_id');
|
$machineId = $get('machine_id');
|
||||||
|
|
||||||
if (! $plantId || ! $machineId) {
|
if (! $plantId || ! $machineId) {
|
||||||
|
$set('characteristic_name', null);
|
||||||
|
$set('current_value', null);
|
||||||
|
$set('update_value', null);
|
||||||
|
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return CharacteristicApproverMaster::where('plant_id', $plantId)->where('machine_id', $machineId)->pluck('machine_name', 'machine_name')->unique();
|
return CharacteristicApproverMaster::where('plant_id', $plantId)->where('machine_id', $machineId)->pluck('machine_name', 'machine_name')->unique();
|
||||||
})
|
})
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
$set('approver_type', null); // dd($get('characteristic_approver_master_id'));
|
||||||
$set('characteristic_approver_master_id', null);
|
$set('characteristic_approver_master_id', null);
|
||||||
// dd($get('characteristic_approver_master_id'));
|
$set('characteristic_name', null);
|
||||||
|
$set('current_value', null);
|
||||||
|
$set('update_value', null);
|
||||||
$set('updated_by', Filament::auth()->user()?->name);
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
})
|
||||||
->default(function () {
|
->default(function () {
|
||||||
@@ -185,60 +220,121 @@ class RequestCharacteristicResource extends Resource
|
|||||||
$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;
|
||||||
if ($reqMac) {
|
$machineName = $reqMac ?? null;
|
||||||
$machineName = $reqMac;
|
|
||||||
} else {
|
|
||||||
$machineName = null;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$machineName = null;
|
$machineName = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// return optional(RequestCharacteristic::latest()->first())->characteristic_approver_master_id ?? [];
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
return $machineName ?? [];
|
|
||||||
|
return ($userHas && strlen($userHas) > 0) ? null : $machineName ?? null;
|
||||||
})
|
})
|
||||||
->afterStateHydrated(function ($component, $state, Get $get, Set $set) {
|
->afterStateHydrated(function ($component, $state, Get $get, Set $set) {
|
||||||
if ($get('id')) {
|
if ($get('id')) {
|
||||||
$reqId = RequestCharacteristic::where('id', $get('id'))->first()?->characteristic_approver_master_id;
|
$reqId = RequestCharacteristic::where('id', $get('id'))->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;
|
||||||
if ($reqMac) {
|
$set('machine_name', $reqMac ?? null);
|
||||||
$set('machine_name', $reqMac);
|
|
||||||
} else {
|
|
||||||
$set('machine_name', null);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$set('machine_name', null);
|
$set('machine_name', null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
->required(),
|
->required(),
|
||||||
Forms\Components\Select::make('characteristic_approver_master_id')
|
Forms\Components\Select::make('approver_type')
|
||||||
->label('Master Characteristic Field')
|
->label('Request Type')
|
||||||
// ->relationship('characteristicApproverMaster', 'characteristic_field')
|
// ->columnSpan(1)
|
||||||
->reactive()
|
->reactive()
|
||||||
->nullable()
|
->nullable()
|
||||||
->searchable()
|
->searchable()
|
||||||
->options(function (callable $get) {
|
->required()
|
||||||
|
->options(function (callable $set, callable $get) {
|
||||||
$plantId = $get('plant_id');
|
$plantId = $get('plant_id');
|
||||||
$machineId = $get('machine_id');
|
$machineId = $get('machine_id');
|
||||||
$machineName = $get('machine_name');
|
$machineName = $get('machine_name');
|
||||||
|
|
||||||
if (! $plantId || ! $machineId || ! $machineName) {
|
if (! $plantId || ! $machineId || ! $machineName) {
|
||||||
|
$set('characteristic_name', null);
|
||||||
|
$set('current_value', null);
|
||||||
|
$set('update_value', null);
|
||||||
|
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return CharacteristicApproverMaster::where('plant_id', $plantId)->where('machine_id', $machineId)->where('machine_name', $machineName)->pluck('characteristic_field', 'id');
|
return [
|
||||||
})
|
'Characteristic' => 'Characteristic',
|
||||||
->default(function () {
|
'Quality' => 'Quality',
|
||||||
return optional(RequestCharacteristic::latest()->first())->characteristic_approver_master_id ?? [];
|
];
|
||||||
})
|
})
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
$set('characteristic_approver_master_id', null);
|
||||||
|
if ($get('approver_type') != 'Characteristic') {
|
||||||
|
$set('characteristic_name', null);
|
||||||
|
$set('current_value', null);
|
||||||
|
$set('update_value', null);
|
||||||
|
}
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
})
|
||||||
|
->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;
|
||||||
|
})
|
||||||
|
->afterStateHydrated(function ($component, $state, Get $get, Set $set) {
|
||||||
|
if ($get('id')) {
|
||||||
|
$reqId = RequestCharacteristic::where('id', $get('id'))->first()?->characteristic_approver_master_id;
|
||||||
|
if ($reqId) {
|
||||||
|
$reqTyp = CharacteristicApproverMaster::where('id', $reqId)->first()?->approver_type;
|
||||||
|
$set('approver_type', $reqTyp ?? null);
|
||||||
|
} else {
|
||||||
|
$set('approver_type', null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
Forms\Components\Select::make('characteristic_approver_master_id')
|
||||||
|
->label('Master Characteristic Field')
|
||||||
|
// ->relationship('characteristicApproverMaster', 'characteristic_field')
|
||||||
|
->columnSpan(2)
|
||||||
|
->reactive()
|
||||||
|
->nullable()
|
||||||
|
->searchable()
|
||||||
|
->options(function (callable $set, callable $get) {
|
||||||
|
$plantId = $get('plant_id');
|
||||||
|
$machineId = $get('machine_id');
|
||||||
|
$machineName = $get('machine_name');
|
||||||
|
$reqTyp = $get('approver_type');
|
||||||
|
|
||||||
|
if (! $plantId || ! $machineId || ! $machineName || ! $reqTyp) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return CharacteristicApproverMaster::where('plant_id', $plantId)->where('machine_id', $machineId)->where('machine_name', $machineName)->where('approver_type', $reqTyp)->pluck('characteristic_field', 'id');
|
||||||
|
})
|
||||||
|
->default(function () {
|
||||||
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
|
return ($userHas && strlen($userHas) > 0) ? null : optional(RequestCharacteristic::latest()->first())->characteristic_approver_master_id ?? null;
|
||||||
|
})
|
||||||
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
$set('characteristic_name', null);
|
||||||
|
$set('current_value', null);
|
||||||
|
$set('update_value', null);
|
||||||
$set('updated_by', Filament::auth()->user()?->name);
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
})
|
||||||
->required(),
|
->required(),
|
||||||
// ->disabled(fn ($get) => self::isFieldDisabled($get))
|
// ->disabled(fn ($get) => self::isFieldDisabled($get))
|
||||||
Section::make('Request Characteristic Field')
|
Section::make('Request Characteristic Details')
|
||||||
// ->columnSpan(['default' => 2, 'sm' => 4])
|
// ->columnSpan(['default' => 2, 'sm' => 4])
|
||||||
->reactive()
|
->reactive()
|
||||||
->schema([
|
->schema([
|
||||||
@@ -249,7 +345,14 @@ class RequestCharacteristicResource extends Resource
|
|||||||
$set('characteristic_name', strtoupper($state));
|
$set('characteristic_name', strtoupper($state));
|
||||||
$set('updated_by', Filament::auth()->user()?->name);
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
})
|
||||||
->required()
|
->required(function (callable $get) {
|
||||||
|
$reqTyp = $get('approver_type');
|
||||||
|
if ($reqTyp == 'Characteristic') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
})
|
||||||
->rules([
|
->rules([
|
||||||
// function (callable $get) {
|
// function (callable $get) {
|
||||||
// return Rule::unique('request_characteristics', 'characteristic_name')
|
// return Rule::unique('request_characteristics', 'characteristic_name')
|
||||||
@@ -288,7 +391,7 @@ class RequestCharacteristicResource extends Resource
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
->readOnly(fn ($get) => self::isFieldDisabled($get)), // disabled
|
->readOnly(fn ($get) => ($get('approver_type') != 'Characteristic') ?? self::isFieldDisabled($get)),
|
||||||
Forms\Components\TextInput::make('current_value')
|
Forms\Components\TextInput::make('current_value')
|
||||||
->label('Current Value')
|
->label('Current Value')
|
||||||
->reactive()
|
->reactive()
|
||||||
@@ -296,14 +399,15 @@ class RequestCharacteristicResource extends Resource
|
|||||||
$set('updated_by', Filament::auth()->user()?->name);
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
})
|
||||||
->required(function (callable $get) {
|
->required(function (callable $get) {
|
||||||
|
$reqTyp = $get('approver_type');
|
||||||
$updateVal = $get('update_value');
|
$updateVal = $get('update_value');
|
||||||
if ($updateVal == null || $updateVal == '') {
|
if ($reqTyp == 'Characteristic' && ($updateVal == null || $updateVal == '')) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
})
|
})
|
||||||
->readOnly(fn ($get) => self::isFieldDisabled($get)),
|
->readOnly(fn ($get) => ($get('approver_type') != 'Characteristic') ?? self::isFieldDisabled($get)),
|
||||||
Forms\Components\TextInput::make('update_value')
|
Forms\Components\TextInput::make('update_value')
|
||||||
->label('Update Value')
|
->label('Update Value')
|
||||||
->reactive()
|
->reactive()
|
||||||
@@ -321,9 +425,17 @@ class RequestCharacteristicResource extends Resource
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
->readOnly(fn ($get) => self::isFieldDisabled($get)),
|
->readOnly(fn ($get) => ($get('approver_type') != 'Characteristic') ?? self::isFieldDisabled($get)),
|
||||||
])
|
])
|
||||||
->collapsible()
|
// ->collapsed(function ($get): bool {
|
||||||
|
// $reqTyp = $get('approver_type');
|
||||||
|
// if ($reqTyp == 'Characteristic') {
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return false;
|
||||||
|
// })
|
||||||
|
->collapsed()
|
||||||
->columns(['default' => 1, 'sm' => 3]),
|
->columns(['default' => 1, 'sm' => 3]),
|
||||||
Section::make(function ($get): string {
|
Section::make(function ($get): string {
|
||||||
$approverId = $get('characteristic_approver_master_id');
|
$approverId = $get('characteristic_approver_master_id');
|
||||||
@@ -338,16 +450,19 @@ class RequestCharacteristicResource extends Resource
|
|||||||
Forms\Components\Select::make('approver_status1')
|
Forms\Components\Select::make('approver_status1')
|
||||||
->label('Approver Status')
|
->label('Approver Status')
|
||||||
->reactive()
|
->reactive()
|
||||||
->live()
|
// ->live()
|
||||||
->options([
|
->options([
|
||||||
'Approved' => 'Approved',
|
'Approved' => 'Approved',
|
||||||
'Hold' => 'Hold',
|
'Hold' => 'Hold',
|
||||||
'Rejected' => 'Rejected',
|
'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());
|
$set('approved1_at', now()->toDateTimeString()); // now()->format('d-m-Y H:i:s')
|
||||||
|
} else {
|
||||||
|
$set('approved1_at', null);
|
||||||
}
|
}
|
||||||
|
$set('approver_remark1', null);
|
||||||
$set('updated_by', Filament::auth()->user()?->name);
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
})
|
||||||
->disabled(function ($get) {
|
->disabled(function ($get) {
|
||||||
@@ -377,10 +492,17 @@ class RequestCharacteristicResource extends Resource
|
|||||||
}),
|
}),
|
||||||
Forms\Components\TextInput::make('approver_remark1')
|
Forms\Components\TextInput::make('approver_remark1')
|
||||||
->label('Approver Remark')
|
->label('Approver Remark')
|
||||||
->reactive()
|
->live()
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
$appStat = $get('approver_status1');
|
||||||
|
if ($appStat && $state) {
|
||||||
|
$set('approved1_at', now()->toDateTimeString()); // now()->format('d-m-Y H:i:s')
|
||||||
|
} else {
|
||||||
|
$set('approved1_at', null);
|
||||||
|
}
|
||||||
$set('updated_by', Filament::auth()->user()?->name);
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
})
|
||||||
|
->readOnly(fn ($get) => ($get('approver_status1') == null))
|
||||||
->disabled(function ($get) {
|
->disabled(function ($get) {
|
||||||
$currentUser = Filament::auth()->user();
|
$currentUser = Filament::auth()->user();
|
||||||
$updId = $get('id');
|
$updId = $get('id');
|
||||||
@@ -402,10 +524,12 @@ class RequestCharacteristicResource extends Resource
|
|||||||
default => 'Updated At',
|
default => 'Updated At',
|
||||||
})
|
})
|
||||||
->reactive()
|
->reactive()
|
||||||
->live()
|
// ->live()
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$set('updated_by', Filament::auth()->user()?->name);
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
})
|
||||||
|
// ->format('d-m-Y H:i:s')
|
||||||
|
->readOnly(fn ($get) => ($get('approver_status1') == null))
|
||||||
->disabled(function ($get) {
|
->disabled(function ($get) {
|
||||||
$currentUser = Filament::auth()->user(); // logged-in user
|
$currentUser = Filament::auth()->user(); // logged-in user
|
||||||
$approverId = $get('characteristic_approver_master_id');
|
$approverId = $get('characteristic_approver_master_id');
|
||||||
@@ -448,9 +572,12 @@ class RequestCharacteristicResource extends Resource
|
|||||||
'Rejected' => 'Rejected',
|
'Rejected' => 'Rejected',
|
||||||
])
|
])
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
if ($state && empty($get('approved2_at'))) {
|
if ($state) {
|
||||||
$set('approved2_at', now());
|
$set('approved2_at', now()->toDateTimeString());
|
||||||
|
} else {
|
||||||
|
$set('approved2_at', null);
|
||||||
}
|
}
|
||||||
|
$set('approver_remark2', null);
|
||||||
$set('updated_by', Filament::auth()->user()?->name);
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
})
|
||||||
->disabled(function ($get) {
|
->disabled(function ($get) {
|
||||||
@@ -480,10 +607,17 @@ class RequestCharacteristicResource extends Resource
|
|||||||
}),
|
}),
|
||||||
Forms\Components\TextInput::make('approver_remark2')
|
Forms\Components\TextInput::make('approver_remark2')
|
||||||
->label('Approver Remark')
|
->label('Approver Remark')
|
||||||
->reactive()
|
->live()
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
$appStat = $get('approver_status2');
|
||||||
|
if ($appStat && $state) {
|
||||||
|
$set('approved2_at', now()->toDateTimeString());
|
||||||
|
} else {
|
||||||
|
$set('approved2_at', null);
|
||||||
|
}
|
||||||
$set('updated_by', Filament::auth()->user()?->name);
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
})
|
||||||
|
->readOnly(fn ($get) => ($get('approver_status2') == null))
|
||||||
->disabled(function ($get) {
|
->disabled(function ($get) {
|
||||||
$currentUser = Filament::auth()->user();
|
$currentUser = Filament::auth()->user();
|
||||||
$updId = $get('id');
|
$updId = $get('id');
|
||||||
@@ -507,6 +641,7 @@ class RequestCharacteristicResource extends Resource
|
|||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$set('updated_by', Filament::auth()->user()?->name);
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
})
|
||||||
|
->readOnly(fn ($get) => ($get('approver_status2') == null))
|
||||||
->disabled(function ($get) {
|
->disabled(function ($get) {
|
||||||
$currentUser = Filament::auth()->user(); // logged-in user
|
$currentUser = Filament::auth()->user(); // logged-in user
|
||||||
$approverId = $get('characteristic_approver_master_id');
|
$approverId = $get('characteristic_approver_master_id');
|
||||||
@@ -550,9 +685,12 @@ class RequestCharacteristicResource extends Resource
|
|||||||
'Rejected' => 'Rejected',
|
'Rejected' => 'Rejected',
|
||||||
])
|
])
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
if ($state && empty($get('approved3_at'))) {
|
if ($state) {
|
||||||
$set('approved3_at', now());
|
$set('approved3_at', now()->toDateTimeString());
|
||||||
|
} else {
|
||||||
|
$set('approved3_at', null);
|
||||||
}
|
}
|
||||||
|
$set('approver_remark3', null);
|
||||||
$set('updated_by', Filament::auth()->user()?->name);
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
})
|
||||||
->disabled(function ($get) {
|
->disabled(function ($get) {
|
||||||
@@ -581,10 +719,17 @@ class RequestCharacteristicResource extends Resource
|
|||||||
}),
|
}),
|
||||||
Forms\Components\TextInput::make('approver_remark3')
|
Forms\Components\TextInput::make('approver_remark3')
|
||||||
->label('Approver Remark')
|
->label('Approver Remark')
|
||||||
->reactive()
|
->live()
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
$appStat = $get('approver_status3');
|
||||||
|
if ($appStat && $state) {
|
||||||
|
$set('approved3_at', now()->toDateTimeString());
|
||||||
|
} else {
|
||||||
|
$set('approved3_at', null);
|
||||||
|
}
|
||||||
$set('updated_by', Filament::auth()->user()?->name);
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
})
|
||||||
|
->readOnly(fn ($get) => ($get('approver_status3') == null))
|
||||||
->disabled(function ($get) {
|
->disabled(function ($get) {
|
||||||
$currentUser = Filament::auth()->user();
|
$currentUser = Filament::auth()->user();
|
||||||
$updId = $get('id');
|
$updId = $get('id');
|
||||||
@@ -608,6 +753,7 @@ class RequestCharacteristicResource extends Resource
|
|||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$set('updated_by', Filament::auth()->user()?->name);
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
})
|
||||||
|
->readOnly(fn ($get) => ($get('approver_status3') == null))
|
||||||
->disabled(function ($get) {
|
->disabled(function ($get) {
|
||||||
$currentUser = Filament::auth()->user(); // logged-in user
|
$currentUser = Filament::auth()->user(); // logged-in user
|
||||||
$approverId = $get('characteristic_approver_master_id');
|
$approverId = $get('characteristic_approver_master_id');
|
||||||
@@ -695,12 +841,12 @@ class RequestCharacteristicResource extends Resource
|
|||||||
$lastSerial = substr($lastWorkflow->work_flow_id, strlen($prefix));
|
$lastSerial = substr($lastWorkflow->work_flow_id, strlen($prefix));
|
||||||
$nextSerial = str_pad(
|
$nextSerial = str_pad(
|
||||||
intval($lastSerial) + 1,
|
intval($lastSerial) + 1,
|
||||||
3,
|
4,
|
||||||
'0',
|
'0',
|
||||||
STR_PAD_LEFT
|
STR_PAD_LEFT
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$nextSerial = '001';
|
$nextSerial = '0001';
|
||||||
}
|
}
|
||||||
|
|
||||||
$workFlowId = "{$prefix}{$nextSerial}";
|
$workFlowId = "{$prefix}{$nextSerial}";
|
||||||
@@ -726,7 +872,7 @@ class RequestCharacteristicResource extends Resource
|
|||||||
->alignCenter()
|
->alignCenter()
|
||||||
->searchable(), // isIndividual: true
|
->searchable(), // isIndividual: true
|
||||||
Tables\Columns\TextColumn::make('plant.name')
|
Tables\Columns\TextColumn::make('plant.name')
|
||||||
->label('Plant')
|
->label('Plant Name')
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
->searchable()
|
->searchable()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
@@ -741,17 +887,22 @@ class RequestCharacteristicResource extends Resource
|
|||||||
->searchable()
|
->searchable()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('aufnr')
|
Tables\Columns\TextColumn::make('aufnr')
|
||||||
->label('Aufnr')
|
->label('Job Number')
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
->searchable()
|
->searchable()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('characteristicApproverMaster.machine_name')
|
Tables\Columns\TextColumn::make('characteristicApproverMaster.machine_name')
|
||||||
->label('Machine')
|
->label('Machine Name')
|
||||||
|
->alignCenter()
|
||||||
|
->searchable()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('characteristicApproverMaster.approver_type')
|
||||||
|
->label('Request Type')
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
->searchable()
|
->searchable()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('characteristicApproverMaster.characteristic_field')
|
Tables\Columns\TextColumn::make('characteristicApproverMaster.characteristic_field')
|
||||||
->label('Master Characteristic')
|
->label('Master Characteristic Field')
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
->searchable()
|
->searchable()
|
||||||
->formatStateUsing(fn (string $state): string => strtoupper(__($state)))
|
->formatStateUsing(fn (string $state): string => strtoupper(__($state)))
|
||||||
|
|||||||
Reference in New Issue
Block a user