From 9e623d2d294603413a6b3715ce3bb2b2477de35b Mon Sep 17 00:00:00 2001 From: Mekan1206 Date: Sun, 2 Aug 2026 22:08:33 +0500 Subject: [PATCH] Refactor Bonus, DisciplinaryReport, Gift, and Explanation schemas to enhance layout and organization. Introduce sections for better categorization of information, improve date picker functionality, and update localization for various fields across multiple languages. --- .../Resources/Bonuses/Schemas/BonusForm.php | 3 +- .../Bonuses/Schemas/BonusInfolist.php | 72 +++++++++------ .../Schemas/DisciplinaryReportForm.php | 2 + .../Schemas/DisciplinaryReportInfolist.php | 88 ++++++++++++------- .../Schemas/ExplanationInfolist.php | 68 ++++++++------ .../Resources/Gifts/Schemas/GiftForm.php | 3 +- .../Resources/Gifts/Schemas/GiftInfolist.php | 67 ++++++++------ lang/en/hr.php | 4 + lang/ru/hr.php | 4 + lang/tk/hr.php | 4 + 10 files changed, 205 insertions(+), 110 deletions(-) diff --git a/app/Filament/Resources/Bonuses/Schemas/BonusForm.php b/app/Filament/Resources/Bonuses/Schemas/BonusForm.php index 9ff0a91..d1c8f39 100644 --- a/app/Filament/Resources/Bonuses/Schemas/BonusForm.php +++ b/app/Filament/Resources/Bonuses/Schemas/BonusForm.php @@ -20,7 +20,8 @@ class BonusForm DatePicker::make('bonus_date') ->label(__('hr.fields.bonus_date')) ->required() - ->default(now()), + ->default(now()) + ->native(false), Select::make('bonus_type') ->label(__('hr.fields.bonus_type')) ->options(BonusType::class) diff --git a/app/Filament/Resources/Bonuses/Schemas/BonusInfolist.php b/app/Filament/Resources/Bonuses/Schemas/BonusInfolist.php index b8fbad9..d986a3f 100644 --- a/app/Filament/Resources/Bonuses/Schemas/BonusInfolist.php +++ b/app/Filament/Resources/Bonuses/Schemas/BonusInfolist.php @@ -1,9 +1,13 @@ components([ - TextEntry::make('employee.id') - ->label(__('hr.fields.employee')), - TextEntry::make('bonus_date') - ->label(__('hr.fields.bonus_date')) - ->date(), - TextEntry::make('bonus_type') - ->label(__('hr.fields.bonus_type')) - ->badge(), - TextEntry::make('amount') - ->label(__('hr.fields.amount')) - ->numeric(), - TextEntry::make('reason') - ->label(__('hr.fields.reason')) - ->placeholder('-') - ->columnSpanFull(), - TextEntry::make('created_at') - ->label(__('hr.fields.created_at')) - ->dateTime() - ->placeholder('-'), - TextEntry::make('updated_at') - ->label(__('hr.fields.updated_at')) - ->dateTime() - ->placeholder('-'), - TextEntry::make('deleted_at') - ->label(__('hr.fields.deleted_at')) - ->dateTime() - ->visible(fn (Bonus $record): bool => $record->trashed()), + Section::make(__('hr.sections.basic_info')) + ->schema([ + TextEntry::make('employee.full_name') + ->label(__('hr.fields.employee')), + TextEntry::make('bonus_date') + ->label(__('hr.fields.bonus_date')) + ->date('d.m.Y'), + TextEntry::make('bonus_type') + ->label(__('hr.fields.bonus_type')) + ->badge() + ->color(fn (BonusType $state): string => $state->color()) + ->formatStateUsing(fn (BonusType $state): string => $state->label()), + ]) + ->columns(3), + Section::make(__('hr.sections.bonus_details')) + ->schema([ + TextEntry::make('amount') + ->label(__('hr.fields.amount')) + ->money('TMT'), + TextEntry::make('reason') + ->label(__('hr.fields.reason')) + ->placeholder('—') + ->columnSpanFull(), + ]) + ->columns(2), + Section::make(__('hr.sections.metadata')) + ->schema([ + TextEntry::make('created_at') + ->label(__('hr.fields.created_at')) + ->dateTime('d.m.Y H:i') + ->placeholder('—'), + TextEntry::make('updated_at') + ->label(__('hr.fields.updated_at')) + ->dateTime('d.m.Y H:i') + ->placeholder('—'), + TextEntry::make('deleted_at') + ->label(__('hr.fields.deleted_at')) + ->dateTime('d.m.Y H:i') + ->visible(fn (Bonus $record): bool => $record->trashed()), + ]) + ->columns(2), ]); } } diff --git a/app/Filament/Resources/DisciplinaryReports/Schemas/DisciplinaryReportForm.php b/app/Filament/Resources/DisciplinaryReports/Schemas/DisciplinaryReportForm.php index 202d9c7..25a99fe 100644 --- a/app/Filament/Resources/DisciplinaryReports/Schemas/DisciplinaryReportForm.php +++ b/app/Filament/Resources/DisciplinaryReports/Schemas/DisciplinaryReportForm.php @@ -20,7 +20,9 @@ class DisciplinaryReportForm DatePicker::make('report_date') ->label(__('hr.fields.report_date')) ->required() + ->native(false) ->default(now()), + TextInput::make('title') ->label(__('hr.fields.title')) ->required() diff --git a/app/Filament/Resources/DisciplinaryReports/Schemas/DisciplinaryReportInfolist.php b/app/Filament/Resources/DisciplinaryReports/Schemas/DisciplinaryReportInfolist.php index 5ba3076..891529a 100644 --- a/app/Filament/Resources/DisciplinaryReports/Schemas/DisciplinaryReportInfolist.php +++ b/app/Filament/Resources/DisciplinaryReports/Schemas/DisciplinaryReportInfolist.php @@ -1,10 +1,15 @@ components([ - TextEntry::make('employee.id') - ->label(__('hr.fields.employee')), - TextEntry::make('report_date') - ->label(__('hr.fields.report_date')) - ->date(), - TextEntry::make('title') - ->label(__('hr.fields.title')), - TextEntry::make('description') - ->label(__('hr.fields.description')) - ->columnSpanFull(), - TextEntry::make('severity') - ->label(__('hr.fields.severity')) - ->badge(), - TextEntry::make('attachment_path') - ->label(__('hr.fields.attachment')) - ->placeholder('-'), + Section::make(__('hr.sections.basic_info')) + ->schema([ + TextEntry::make('employee.full_name') + ->label(__('hr.fields.employee')), + TextEntry::make('report_date') + ->label(__('hr.fields.report_date')) + ->date('d.m.Y'), + TextEntry::make('severity') + ->label(__('hr.fields.severity')) + ->badge() + ->color(fn (DisciplinarySeverity $state): string => $state->color()) + ->formatStateUsing(fn (DisciplinarySeverity $state): string => $state->label()), + ]) + ->columns(3), + Section::make(__('hr.sections.metadata')) + ->schema([ + TextEntry::make('created_at') + ->label(__('hr.fields.created_at')) + ->dateTime('d.m.Y H:i') + ->placeholder('—'), + TextEntry::make('updated_at') + ->label(__('hr.fields.updated_at')) + ->dateTime('d.m.Y H:i') + ->placeholder('—'), + TextEntry::make('deleted_at') + ->label(__('hr.fields.deleted_at')) + ->dateTime('d.m.Y H:i') + ->visible(fn(DisciplinaryReport $record): bool => $record->trashed()), + TextEntry::make('created_by') ->label(__('hr.fields.created_by')) - ->numeric() - ->placeholder('-'), - TextEntry::make('created_at') - ->label(__('hr.fields.created_at')) - ->dateTime() - ->placeholder('-'), - TextEntry::make('updated_at') - ->label(__('hr.fields.updated_at')) - ->dateTime() - ->placeholder('-'), - TextEntry::make('deleted_at') - ->label(__('hr.fields.deleted_at')) - ->dateTime() - ->visible(fn (DisciplinaryReport $record): bool => $record->trashed()), + ->formatStateUsing(fn($state, DisciplinaryReport $record): string => $record->creator?->name ?? '—'), + ]) + ->columns(2), + Section::make(__('hr.sections.report_details')) + ->schema([ + TextEntry::make('title') + ->label(__('hr.fields.title')) + ->weight('bold') + ->size('lg') + ->hiddenLabel(), + + TextEntry::make('description') + ->label(__('hr.fields.description')) + ->placeholder('—') + ->columnSpanFull() + ->hiddenLabel(), + + ImageEntry::make('attachment_path') + ->square() + ->size(80) + ->label(__('hr.fields.attachment')) + ->visible(fn(?string $state): bool => filled($state)), + ]) + ->columns(2), ]); } } diff --git a/app/Filament/Resources/Explanations/Schemas/ExplanationInfolist.php b/app/Filament/Resources/Explanations/Schemas/ExplanationInfolist.php index 9a71b97..c8fd980 100644 --- a/app/Filament/Resources/Explanations/Schemas/ExplanationInfolist.php +++ b/app/Filament/Resources/Explanations/Schemas/ExplanationInfolist.php @@ -1,9 +1,12 @@ components([ - TextEntry::make('employee.id') - ->label(__('hr.fields.employee')), - TextEntry::make('explanation_date') - ->label(__('hr.fields.explanation_date')) - ->date(), - TextEntry::make('reason') - ->label(__('hr.fields.reason')), - TextEntry::make('description') - ->label(__('hr.fields.description')) - ->columnSpanFull(), - TextEntry::make('attachment_path') - ->label(__('hr.fields.attachment')) - ->placeholder('-'), - TextEntry::make('created_at') - ->label(__('hr.fields.created_at')) - ->dateTime() - ->placeholder('-'), - TextEntry::make('updated_at') - ->label(__('hr.fields.updated_at')) - ->dateTime() - ->placeholder('-'), - TextEntry::make('deleted_at') - ->label(__('hr.fields.deleted_at')) - ->dateTime() - ->visible(fn (Explanation $record): bool => $record->trashed()), + Section::make(__('hr.sections.basic_info')) + ->schema([ + TextEntry::make('employee.full_name') + ->label(__('hr.fields.employee')), + TextEntry::make('explanation_date') + ->label(__('hr.fields.explanation_date')) + ->date('d.m.Y'), + ]) + ->columns(2), + Section::make(__('hr.sections.explanation_details')) + ->schema([ + TextEntry::make('reason') + ->label(__('hr.fields.reason')) + ->placeholder('—') + ->columnSpanFull(), + TextEntry::make('description') + ->label(__('hr.fields.description')) + ->placeholder('—') + ->columnSpanFull(), + TextEntry::make('attachment_path') + ->label(__('hr.fields.attachment')) + ->formatStateUsing(fn (?string $state): string => filled($state) ? basename($state) : '—'), + ]) + ->columns(2), + Section::make(__('hr.sections.metadata')) + ->schema([ + TextEntry::make('created_at') + ->label(__('hr.fields.created_at')) + ->dateTime('d.m.Y H:i') + ->placeholder('—'), + TextEntry::make('updated_at') + ->label(__('hr.fields.updated_at')) + ->dateTime('d.m.Y H:i') + ->placeholder('—'), + TextEntry::make('deleted_at') + ->label(__('hr.fields.deleted_at')) + ->dateTime('d.m.Y H:i') + ->visible(fn (Explanation $record): bool => $record->trashed()), + ]) + ->columns(2), ]); } } diff --git a/app/Filament/Resources/Gifts/Schemas/GiftForm.php b/app/Filament/Resources/Gifts/Schemas/GiftForm.php index cdd0768..cf011d2 100644 --- a/app/Filament/Resources/Gifts/Schemas/GiftForm.php +++ b/app/Filament/Resources/Gifts/Schemas/GiftForm.php @@ -18,7 +18,8 @@ class GiftForm DatePicker::make('gift_date') ->label(__('hr.fields.gift_date')) ->required() - ->default(now()), + ->default(now()) + ->native(false), TextInput::make('gift_name') ->label(__('hr.fields.gift_name')) ->required() diff --git a/app/Filament/Resources/Gifts/Schemas/GiftInfolist.php b/app/Filament/Resources/Gifts/Schemas/GiftInfolist.php index ee54ff5..c2dbba0 100644 --- a/app/Filament/Resources/Gifts/Schemas/GiftInfolist.php +++ b/app/Filament/Resources/Gifts/Schemas/GiftInfolist.php @@ -1,9 +1,12 @@ components([ - TextEntry::make('employee.id') - ->label(__('hr.fields.employee')), - TextEntry::make('gift_date') - ->label(__('hr.fields.gift_date')) - ->date(), - TextEntry::make('gift_name') - ->label(__('hr.fields.gift_name')), - TextEntry::make('value') - ->label(__('hr.fields.value')) - ->numeric(), - TextEntry::make('reason') - ->label(__('hr.fields.reason')) - ->placeholder('-') - ->columnSpanFull(), - TextEntry::make('created_at') - ->label(__('hr.fields.created_at')) - ->dateTime() - ->placeholder('-'), - TextEntry::make('updated_at') - ->label(__('hr.fields.updated_at')) - ->dateTime() - ->placeholder('-'), - TextEntry::make('deleted_at') - ->label(__('hr.fields.deleted_at')) - ->dateTime() - ->visible(fn (Gift $record): bool => $record->trashed()), + Section::make(__('hr.sections.basic_info')) + ->schema([ + TextEntry::make('employee.full_name') + ->label(__('hr.fields.employee')), + TextEntry::make('gift_date') + ->label(__('hr.fields.gift_date')) + ->date('d.m.Y'), + TextEntry::make('gift_name') + ->label(__('hr.fields.gift_name')), + ]) + ->columns(3), + Section::make(__('hr.sections.gift_details')) + ->schema([ + TextEntry::make('value') + ->label(__('hr.fields.value')) + ->money('TMT'), + TextEntry::make('reason') + ->label(__('hr.fields.reason')) + ->placeholder('—') + ->columnSpanFull(), + ]) + ->columns(2), + Section::make(__('hr.sections.metadata')) + ->schema([ + TextEntry::make('created_at') + ->label(__('hr.fields.created_at')) + ->dateTime('d.m.Y H:i') + ->placeholder('—'), + TextEntry::make('updated_at') + ->label(__('hr.fields.updated_at')) + ->dateTime('d.m.Y H:i') + ->placeholder('—'), + TextEntry::make('deleted_at') + ->label(__('hr.fields.deleted_at')) + ->dateTime('d.m.Y H:i') + ->visible(fn (Gift $record): bool => $record->trashed()), + ]) + ->columns(2), ]); } } diff --git a/lang/en/hr.php b/lang/en/hr.php index 30fa853..00f1c2c 100644 --- a/lang/en/hr.php +++ b/lang/en/hr.php @@ -161,6 +161,10 @@ return [ 'approval' => 'Approval', 'metadata' => 'Metadata', 'medical_details' => 'Medical Details', + 'report_details' => 'Report Details', + 'explanation_details' => 'Explanation Details', + 'bonus_details' => 'Bonus Details', + 'gift_details' => 'Gift Details', ], 'messages' => [ diff --git a/lang/ru/hr.php b/lang/ru/hr.php index f6639bd..ade424c 100644 --- a/lang/ru/hr.php +++ b/lang/ru/hr.php @@ -161,6 +161,10 @@ return [ 'approval' => 'Утверждение', 'metadata' => 'Метаданные', 'medical_details' => 'Медицинские данные', + 'report_details' => 'Детали отчёта', + 'explanation_details' => 'Детали объяснительной', + 'bonus_details' => 'Детали премии', + 'gift_details' => 'Детали подарка', ], 'messages' => [ diff --git a/lang/tk/hr.php b/lang/tk/hr.php index cd62796..8fcbb81 100644 --- a/lang/tk/hr.php +++ b/lang/tk/hr.php @@ -161,6 +161,10 @@ return [ 'approval' => 'Tassyklama', 'metadata' => 'Maglumat', 'medical_details' => 'Lukmançylyk maglumatlary', + 'report_details' => 'Hasabat jikme-jiklikleri', + 'explanation_details' => 'Düşündiriş jikme-jiklikleri', + 'bonus_details' => 'Baýrak jikme-jiklikleri', + 'gift_details' => 'Sowgat jikme-jiklikleri', ], 'messages' => [