Compare commits
12
Commits
8147f23750
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3cdbeda805 | ||
|
|
3504e39646 | ||
|
|
0237c2b9ef | ||
|
|
9e623d2d29 | ||
|
|
a9f7dc1076 | ||
|
|
986ca397c0 | ||
|
|
0b6ef45a40 | ||
|
|
76416de568 | ||
|
|
e16402b23f | ||
|
|
eed46157cd | ||
|
|
28cbef8eb5 | ||
|
|
e3ec83686c |
No files matched your search
@@ -4,7 +4,7 @@ # HR Management System
|
||||
|
||||
**Stack:** Laravel 13, PHP 8.3+, Filament 5, SQLite (default) or MySQL, Vite + Tailwind 4.
|
||||
|
||||
**Key packages:** Filament Shield (RBAC), Language Switch, Spatie Activity Log, Maatwebsite Excel, DomPDF.
|
||||
**Key packages:** Filament Shield (RBAC), Language Switch, Spatie Activity Log, Bokshorn IT Activity Timeline, Maatwebsite Excel, DomPDF.
|
||||
|
||||
## Requirements
|
||||
|
||||
@@ -172,7 +172,7 @@ ### Import pipeline
|
||||
### Audit trail
|
||||
|
||||
- The `LogsHrActivity` concern on HR models logs changes to fillable fields via Spatie Activity Log
|
||||
- The **Activity Log** resource provides a read-only audit viewer in the admin panel
|
||||
- The **Audit Log** resource (via `bokshorn-it/filament-activity-timeline`) provides a read-only audit viewer with readable diffs and per-record timelines in the admin panel
|
||||
|
||||
### Localization
|
||||
|
||||
|
||||
@@ -4,13 +4,15 @@
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum ApprovalStatus: string
|
||||
use Filament\Support\Contracts\HasLabel;
|
||||
|
||||
enum ApprovalStatus: string implements HasLabel
|
||||
{
|
||||
case Pending = 'pending';
|
||||
case Approved = 'approved';
|
||||
case Rejected = 'rejected';
|
||||
|
||||
public function label(): string
|
||||
public function getLabel(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::Pending => __('enums.approval_status.pending'),
|
||||
@@ -19,6 +21,11 @@ public function label(): string
|
||||
};
|
||||
}
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return $this->getLabel();
|
||||
}
|
||||
|
||||
public function color(): string
|
||||
{
|
||||
return match ($this) {
|
||||
|
||||
@@ -4,14 +4,16 @@
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum BonusType: string
|
||||
use Filament\Support\Contracts\HasLabel;
|
||||
|
||||
enum BonusType: string implements HasLabel
|
||||
{
|
||||
case Performance = 'performance';
|
||||
case Holiday = 'holiday';
|
||||
case Retention = 'retention';
|
||||
case Other = 'other';
|
||||
|
||||
public function label(): string
|
||||
public function getLabel(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::Performance => __('enums.bonus_type.performance'),
|
||||
@@ -21,6 +23,11 @@ public function label(): string
|
||||
};
|
||||
}
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return $this->getLabel();
|
||||
}
|
||||
|
||||
public function color(): string
|
||||
{
|
||||
return match ($this) {
|
||||
|
||||
@@ -4,13 +4,15 @@
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum DisciplinarySeverity: string
|
||||
use Filament\Support\Contracts\HasLabel;
|
||||
|
||||
enum DisciplinarySeverity: string implements HasLabel
|
||||
{
|
||||
case Low = 'low';
|
||||
case Medium = 'medium';
|
||||
case High = 'high';
|
||||
|
||||
public function label(): string
|
||||
public function getLabel(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::Low => __('enums.disciplinary_severity.low'),
|
||||
@@ -19,6 +21,11 @@ public function label(): string
|
||||
};
|
||||
}
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return $this->getLabel();
|
||||
}
|
||||
|
||||
public function color(): string
|
||||
{
|
||||
return match ($this) {
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum DocumentType: string
|
||||
use Filament\Support\Contracts\HasLabel;
|
||||
|
||||
enum DocumentType: string implements HasLabel
|
||||
{
|
||||
case Passport = 'passport';
|
||||
case Contract = 'contract';
|
||||
@@ -12,7 +14,7 @@ enum DocumentType: string
|
||||
case EducationCertificate = 'education_certificate';
|
||||
case Other = 'other';
|
||||
|
||||
public function label(): string
|
||||
public function getLabel(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::Passport => __('enums.document_type.passport'),
|
||||
@@ -23,6 +25,11 @@ public function label(): string
|
||||
};
|
||||
}
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return $this->getLabel();
|
||||
}
|
||||
|
||||
public function color(): string
|
||||
{
|
||||
return match ($this) {
|
||||
|
||||
@@ -4,14 +4,16 @@
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum EmploymentStatus: string
|
||||
use Filament\Support\Contracts\HasLabel;
|
||||
|
||||
enum EmploymentStatus: string implements HasLabel
|
||||
{
|
||||
case Active = 'active';
|
||||
case Inactive = 'inactive';
|
||||
case Terminated = 'terminated';
|
||||
case OnLeave = 'on_leave';
|
||||
|
||||
public function label(): string
|
||||
public function getLabel(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::Active => __('enums.employment_status.active'),
|
||||
@@ -21,6 +23,11 @@ public function label(): string
|
||||
};
|
||||
}
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return $this->getLabel();
|
||||
}
|
||||
|
||||
public function color(): string
|
||||
{
|
||||
return match ($this) {
|
||||
|
||||
+13
-6
@@ -4,27 +4,34 @@
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum Gender: string
|
||||
use Filament\Support\Contracts\HasLabel;
|
||||
|
||||
enum Gender: string implements HasLabel
|
||||
{
|
||||
case Male = 'male';
|
||||
case Female = 'female';
|
||||
case Other = 'other';
|
||||
// case Other = 'other';
|
||||
|
||||
public function label(): string
|
||||
public function getLabel(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::Male => __('enums.gender.male'),
|
||||
self::Female => __('enums.gender.female'),
|
||||
self::Other => __('enums.gender.other'),
|
||||
// self::Other => __('enums.gender.other'),
|
||||
};
|
||||
}
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return $this->getLabel();
|
||||
}
|
||||
|
||||
public function color(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::Male => 'info',
|
||||
self::Female => 'pink',
|
||||
self::Other => 'gray',
|
||||
// self::Other => 'gray',
|
||||
};
|
||||
}
|
||||
|
||||
@@ -33,7 +40,7 @@ public function icon(): string
|
||||
return match ($this) {
|
||||
self::Male => 'heroicon-o-user',
|
||||
self::Female => 'heroicon-o-user',
|
||||
self::Other => 'heroicon-o-users',
|
||||
// self::Other => 'heroicon-o-users',
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -4,14 +4,16 @@
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum ImportType: string
|
||||
use Filament\Support\Contracts\HasLabel;
|
||||
|
||||
enum ImportType: string implements HasLabel
|
||||
{
|
||||
case Employees = 'employees';
|
||||
case Vacations = 'vacations';
|
||||
case Bonuses = 'bonuses';
|
||||
case Reports = 'reports';
|
||||
|
||||
public function label(): string
|
||||
public function getLabel(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::Employees => __('enums.import_type.employees'),
|
||||
@@ -21,6 +23,11 @@ public function label(): string
|
||||
};
|
||||
}
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return $this->getLabel();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
|
||||
@@ -4,14 +4,16 @@
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum VacationType: string
|
||||
use Filament\Support\Contracts\HasLabel;
|
||||
|
||||
enum VacationType: string implements HasLabel
|
||||
{
|
||||
case Annual = 'annual';
|
||||
case Marriage = 'marriage';
|
||||
case Study = 'study';
|
||||
case Other = 'other';
|
||||
|
||||
public function label(): string
|
||||
public function getLabel(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::Annual => __('enums.vacation_type.annual'),
|
||||
@@ -21,6 +23,11 @@ public function label(): string
|
||||
};
|
||||
}
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return $this->getLabel();
|
||||
}
|
||||
|
||||
public function color(): string
|
||||
{
|
||||
return match ($this) {
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Models\Employee;
|
||||
use App\Support\Countries;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Maatwebsite\Excel\Concerns\FromQuery;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
@@ -39,7 +40,7 @@ public function headings(): array
|
||||
return [
|
||||
'Employee Number',
|
||||
'Full Name',
|
||||
'National ID',
|
||||
'Nationality',
|
||||
'Gender',
|
||||
'Birth Date',
|
||||
'Phone',
|
||||
@@ -63,7 +64,7 @@ public function map($employee): array
|
||||
return [
|
||||
$employee->employee_number,
|
||||
$employee->full_name,
|
||||
$employee->national_id,
|
||||
Countries::name($employee->national_id) ?? $employee->national_id,
|
||||
$employee->gender?->value,
|
||||
$employee->birth_date?->toDateString(),
|
||||
$employee->phone,
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Filament\ActivityTimeline;
|
||||
|
||||
use App\Enums\NavigationGroup;
|
||||
use App\Filament\Concerns\HasHrResourceLabels;
|
||||
use BokshornIt\FilamentActivityTimeline\Resources\ActivityResource;
|
||||
use Filament\Navigation\NavigationItem;
|
||||
|
||||
class AuditLogResource extends ActivityResource
|
||||
{
|
||||
use HasHrResourceLabels;
|
||||
|
||||
protected static ?string $slug = 'activity-logs';
|
||||
|
||||
protected static function hrLabelKeys(): array
|
||||
{
|
||||
return [
|
||||
'model' => 'activity_log',
|
||||
'plural' => 'activity_logs',
|
||||
'navigation' => 'audit_log',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<NavigationItem>
|
||||
*/
|
||||
public static function getNavigationItems(): array
|
||||
{
|
||||
return array_map(
|
||||
fn (NavigationItem $item): NavigationItem => $item->group(NavigationGroup::System),
|
||||
parent::getNavigationItems(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Filament\Resources\ActivityLogs;
|
||||
|
||||
use App\Enums\NavigationGroup;
|
||||
use App\Filament\Concerns\HasHrResourceLabels;
|
||||
use App\Filament\Resources\ActivityLogs\Pages\ListActivityLogs;
|
||||
use App\Filament\Resources\ActivityLogs\Pages\ViewActivityLog;
|
||||
use App\Filament\Resources\ActivityLogs\Schemas\ActivityLogInfolist;
|
||||
use App\Filament\Resources\ActivityLogs\Tables\ActivityLogsTable;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
use Spatie\Activitylog\Models\Activity;
|
||||
use UnitEnum;
|
||||
|
||||
class ActivityLogResource extends Resource
|
||||
{
|
||||
use HasHrResourceLabels;
|
||||
|
||||
protected static ?string $model = Activity::class;
|
||||
|
||||
protected static function hrLabelKeys(): array
|
||||
{
|
||||
return [
|
||||
'model' => 'activity_log',
|
||||
'plural' => 'activity_logs',
|
||||
'navigation' => 'audit_log',
|
||||
];
|
||||
}
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedClipboardDocumentList;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = NavigationGroup::System;
|
||||
|
||||
protected static ?int $navigationSort = 3;
|
||||
|
||||
protected static ?string $slug = 'activity-logs';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema;
|
||||
}
|
||||
|
||||
public static function infolist(Schema $schema): Schema
|
||||
{
|
||||
return ActivityLogInfolist::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return ActivityLogsTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListActivityLogs::route('/'),
|
||||
'view' => ViewActivityLog::route('/{record}'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function canCreate(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function canEdit($record): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function canDelete($record): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function canForceDelete($record): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function canRestore($record): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Filament\Resources\ActivityLogs\Pages;
|
||||
|
||||
use App\Filament\Resources\ActivityLogs\ActivityLogResource;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListActivityLogs extends ListRecords
|
||||
{
|
||||
protected static string $resource = ActivityLogResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Filament\Resources\ActivityLogs\Pages;
|
||||
|
||||
use App\Filament\Resources\ActivityLogs\ActivityLogResource;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewActivityLog extends ViewRecord
|
||||
{
|
||||
protected static string $resource = ActivityLogResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Filament\Resources\ActivityLogs\Schemas;
|
||||
|
||||
use Filament\Infolists\Components\KeyValueEntry;
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class ActivityLogInfolist
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Section::make(__('hr.sections.activity_details'))
|
||||
->schema([
|
||||
TextEntry::make('created_at')
|
||||
->label(__('hr.fields.date'))
|
||||
->dateTime(),
|
||||
TextEntry::make('description'),
|
||||
TextEntry::make('event')
|
||||
->badge(),
|
||||
TextEntry::make('log_name')
|
||||
->label(__('hr.fields.log_name')),
|
||||
TextEntry::make('subject_type')
|
||||
->label(__('hr.fields.subject_type'))
|
||||
->formatStateUsing(fn (?string $state): string => $state ? class_basename($state) : '—'),
|
||||
TextEntry::make('subject_id')
|
||||
->label(__('hr.fields.subject_id')),
|
||||
TextEntry::make('causer.name')
|
||||
->label(__('hr.fields.causer')),
|
||||
KeyValueEntry::make('properties.attributes')
|
||||
->label(__('hr.fields.changes'))
|
||||
->visible(fn ($record): bool => filled($record->properties['attributes'] ?? null)),
|
||||
KeyValueEntry::make('properties.old')
|
||||
->label(__('hr.fields.previous_values'))
|
||||
->visible(fn ($record): bool => filled($record->properties['old'] ?? null)),
|
||||
])
|
||||
->columns(2),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,100 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Filament\Resources\ActivityLogs\Tables;
|
||||
|
||||
use App\Models\Bonus;
|
||||
use App\Models\Department;
|
||||
use App\Models\DisciplinaryReport;
|
||||
use App\Models\Employee;
|
||||
use App\Models\User;
|
||||
use App\Models\Vacation;
|
||||
use Filament\Actions\ViewAction;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class ActivityLogsTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('created_at')
|
||||
->label(__('hr.fields.date'))
|
||||
->dateTime()
|
||||
->sortable(),
|
||||
TextColumn::make('description')
|
||||
->searchable()
|
||||
->limit(50),
|
||||
TextColumn::make('event')
|
||||
->badge()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
TextColumn::make('subject_type')
|
||||
->label(__('hr.fields.subject_type'))
|
||||
->formatStateUsing(fn (?string $state): string => $state ? class_basename($state) : '—')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
TextColumn::make('subject_id')
|
||||
->label(__('hr.fields.subject_id'))
|
||||
->sortable(),
|
||||
TextColumn::make('causer.name')
|
||||
->label(__('hr.fields.causer'))
|
||||
->searchable()
|
||||
->sortable(),
|
||||
TextColumn::make('log_name')
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->defaultSort('created_at', 'desc')
|
||||
->filters([
|
||||
SelectFilter::make('subject_type')
|
||||
->label(__('hr.fields.subject_type'))
|
||||
->options([
|
||||
Employee::class => __('hr.audit.employee'),
|
||||
Vacation::class => __('hr.audit.vacation'),
|
||||
Bonus::class => __('hr.audit.bonus'),
|
||||
DisciplinaryReport::class => __('hr.audit.disciplinary_report'),
|
||||
Department::class => __('hr.audit.department'),
|
||||
User::class => __('hr.audit.user'),
|
||||
]),
|
||||
SelectFilter::make('event')
|
||||
->options(fn (): array => \Spatie\Activitylog\Models\Activity::query()
|
||||
->whereNotNull('event')
|
||||
->distinct()
|
||||
->pluck('event', 'event')
|
||||
->all()),
|
||||
SelectFilter::make('causer')
|
||||
->label(__('hr.fields.causer'))
|
||||
->relationship('causer', 'name')
|
||||
->searchable()
|
||||
->preload(),
|
||||
Filter::make('created_at')
|
||||
->schema([
|
||||
DatePicker::make('from')
|
||||
->label(__('hr.fields.from')),
|
||||
DatePicker::make('until')
|
||||
->label(__('hr.fields.until')),
|
||||
])
|
||||
->query(function (Builder $query, array $data): Builder {
|
||||
return $query
|
||||
->when(
|
||||
$data['from'] ?? null,
|
||||
fn (Builder $query, string $date): Builder => $query->whereDate('created_at', '>=', $date),
|
||||
)
|
||||
->when(
|
||||
$data['until'] ?? null,
|
||||
fn (Builder $query, string $date): Builder => $query->whereDate('created_at', '<=', $date),
|
||||
);
|
||||
}),
|
||||
])
|
||||
->recordActions([
|
||||
ViewAction::make(),
|
||||
])
|
||||
->toolbarActions([]);
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Resources\Bonuses\Pages;
|
||||
|
||||
use App\Filament\Resources\Bonuses\BonusResource;
|
||||
use BokshornIt\FilamentActivityTimeline\Actions\ActivityTimelineAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
@@ -13,6 +14,7 @@ class ViewBonus extends ViewRecord
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
ActivityTimelineAction::make(),
|
||||
EditAction::make(),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -18,19 +18,24 @@ public static function configure(Schema $schema): Schema
|
||||
->components([
|
||||
HrForm::employeeSelect(),
|
||||
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)
|
||||
->required()
|
||||
->native(false),
|
||||
TextInput::make('amount')
|
||||
->label(__('hr.fields.amount'))
|
||||
->required()
|
||||
->numeric()
|
||||
->prefix('TMT')
|
||||
->minValue(0)
|
||||
->step(0.01),
|
||||
Textarea::make('reason')
|
||||
->label(__('hr.fields.reason'))
|
||||
->rows(3)
|
||||
->columnSpanFull(),
|
||||
]);
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Filament\Resources\Bonuses\Schemas;
|
||||
|
||||
use App\Enums\BonusType;
|
||||
use App\Models\Bonus;
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class BonusInfolist
|
||||
@@ -12,26 +16,47 @@ public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextEntry::make('employee.id')
|
||||
->label(__('hr.fields.employee')),
|
||||
TextEntry::make('bonus_date')
|
||||
->date(),
|
||||
TextEntry::make('bonus_type')
|
||||
->badge(),
|
||||
TextEntry::make('amount')
|
||||
->numeric(),
|
||||
TextEntry::make('reason')
|
||||
->placeholder('-')
|
||||
->columnSpanFull(),
|
||||
TextEntry::make('created_at')
|
||||
->dateTime()
|
||||
->placeholder('-'),
|
||||
TextEntry::make('updated_at')
|
||||
->dateTime()
|
||||
->placeholder('-'),
|
||||
TextEntry::make('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),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,7 @@ public static function configure(Table $table): Table
|
||||
->searchable()
|
||||
->sortable(),
|
||||
TextColumn::make('bonus_date')
|
||||
->label(__('hr.fields.bonus_date'))
|
||||
->date()
|
||||
->sortable(),
|
||||
TextColumn::make('bonus_type')
|
||||
@@ -36,20 +37,25 @@ public static function configure(Table $table): Table
|
||||
->searchable()
|
||||
->sortable(),
|
||||
TextColumn::make('amount')
|
||||
->label(__('hr.fields.amount'))
|
||||
->money('TMT')
|
||||
->sortable(),
|
||||
TextColumn::make('reason')
|
||||
->label(__('hr.fields.reason'))
|
||||
->limit(40)
|
||||
->toggleable(),
|
||||
TextColumn::make('created_at')
|
||||
->label(__('hr.fields.created_at'))
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('updated_at')
|
||||
->label(__('hr.fields.updated_at'))
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('deleted_at')
|
||||
->label(__('hr.fields.deleted_at'))
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Resources\Departments\Pages;
|
||||
|
||||
use App\Filament\Resources\Departments\DepartmentResource;
|
||||
use BokshornIt\FilamentActivityTimeline\Actions\ActivityTimelineAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
@@ -13,6 +14,7 @@ class ViewDepartment extends ViewRecord
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
ActivityTimelineAction::make(),
|
||||
EditAction::make(),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -14,11 +14,15 @@ public static function configure(Schema $schema): Schema
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('name')
|
||||
->label(__('hr.fields.name'))
|
||||
->required()
|
||||
->maxLength(255),
|
||||
|
||||
Textarea::make('description')
|
||||
->label(__('hr.fields.description'))
|
||||
->rows(3)
|
||||
->columnSpanFull(),
|
||||
|
||||
Toggle::make('is_active')
|
||||
->label(__('hr.fields.active'))
|
||||
->default(true)
|
||||
|
||||
@@ -13,20 +13,27 @@ public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextEntry::make('name'),
|
||||
TextEntry::make('code'),
|
||||
TextEntry::make('name')
|
||||
->label(__('hr.fields.name')),
|
||||
TextEntry::make('code')
|
||||
->label(__('hr.fields.code')),
|
||||
TextEntry::make('description')
|
||||
->label(__('hr.fields.description'))
|
||||
->placeholder('-')
|
||||
->columnSpanFull(),
|
||||
IconEntry::make('is_active')
|
||||
->label(__('hr.fields.status'))
|
||||
->boolean(),
|
||||
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 (Department $record): bool => $record->trashed()),
|
||||
]);
|
||||
|
||||
@@ -20,12 +20,15 @@ public static function configure(Table $table): Table
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('name')
|
||||
->label(__('hr.fields.name'))
|
||||
->searchable()
|
||||
->sortable(),
|
||||
TextColumn::make('code')
|
||||
->label(__('hr.fields.code'))
|
||||
->searchable()
|
||||
->sortable(),
|
||||
TextColumn::make('description')
|
||||
->label(__('hr.fields.description'))
|
||||
->limit(50)
|
||||
->toggleable(),
|
||||
TextColumn::make('is_active')
|
||||
@@ -35,14 +38,17 @@ public static function configure(Table $table): Table
|
||||
->color(fn (bool $state): string => $state ? 'success' : 'danger')
|
||||
->sortable(),
|
||||
TextColumn::make('created_at')
|
||||
->label(__('hr.fields.created_at'))
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('updated_at')
|
||||
->label(__('hr.fields.updated_at'))
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('deleted_at')
|
||||
->label(__('hr.fields.deleted_at'))
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Resources\DisciplinaryReports\Pages;
|
||||
|
||||
use App\Filament\Resources\DisciplinaryReports\DisciplinaryReportResource;
|
||||
use BokshornIt\FilamentActivityTimeline\Actions\ActivityTimelineAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
@@ -13,6 +14,7 @@ class ViewDisciplinaryReport extends ViewRecord
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
ActivityTimelineAction::make(),
|
||||
EditAction::make(),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -18,16 +18,22 @@ public static function configure(Schema $schema): Schema
|
||||
->components([
|
||||
HrForm::employeeSelect(),
|
||||
DatePicker::make('report_date')
|
||||
->label(__('hr.fields.report_date'))
|
||||
->required()
|
||||
->native(false)
|
||||
->default(now()),
|
||||
|
||||
TextInput::make('title')
|
||||
->label(__('hr.fields.title'))
|
||||
->required()
|
||||
->maxLength(255),
|
||||
Textarea::make('description')
|
||||
->label(__('hr.fields.description'))
|
||||
->required()
|
||||
->rows(4)
|
||||
->columnSpanFull(),
|
||||
Select::make('severity')
|
||||
->label(__('hr.fields.severity'))
|
||||
->options(DisciplinarySeverity::class)
|
||||
->required()
|
||||
->native(false),
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Filament\Resources\DisciplinaryReports\Schemas;
|
||||
|
||||
use App\Enums\DisciplinarySeverity;
|
||||
use App\Models\DisciplinaryReport;
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Infolists\Components\ImageEntry;
|
||||
|
||||
class DisciplinaryReportInfolist
|
||||
{
|
||||
@@ -12,29 +17,61 @@ public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextEntry::make('employee.id')
|
||||
->label(__('hr.fields.employee')),
|
||||
TextEntry::make('report_date')
|
||||
->date(),
|
||||
TextEntry::make('title'),
|
||||
TextEntry::make('description')
|
||||
->columnSpanFull(),
|
||||
TextEntry::make('severity')
|
||||
->badge(),
|
||||
TextEntry::make('attachment_path')
|
||||
->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')
|
||||
->numeric()
|
||||
->placeholder('-'),
|
||||
TextEntry::make('created_at')
|
||||
->dateTime()
|
||||
->placeholder('-'),
|
||||
TextEntry::make('updated_at')
|
||||
->dateTime()
|
||||
->placeholder('-'),
|
||||
TextEntry::make('deleted_at')
|
||||
->dateTime()
|
||||
->visible(fn (DisciplinaryReport $record): bool => $record->trashed()),
|
||||
->label(__('hr.fields.created_by'))
|
||||
->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),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -27,12 +27,15 @@ public static function configure(Table $table): Table
|
||||
->searchable()
|
||||
->sortable(),
|
||||
TextColumn::make('report_date')
|
||||
->label(__('hr.fields.report_date'))
|
||||
->date()
|
||||
->sortable(),
|
||||
TextColumn::make('title')
|
||||
->label(__('hr.fields.title'))
|
||||
->searchable()
|
||||
->sortable(),
|
||||
TextColumn::make('severity')
|
||||
->label(__('hr.fields.severity'))
|
||||
->badge()
|
||||
->color(fn (DisciplinarySeverity $state): string => $state->color())
|
||||
->formatStateUsing(fn (DisciplinarySeverity $state): string => $state->label())
|
||||
@@ -48,20 +51,24 @@ public static function configure(Table $table): Table
|
||||
->sortable()
|
||||
->toggleable(),
|
||||
TextColumn::make('created_at')
|
||||
->label(__('hr.fields.created_at'))
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('updated_at')
|
||||
->label(__('hr.fields.updated_at'))
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('deleted_at')
|
||||
->label(__('hr.fields.deleted_at'))
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
SelectFilter::make('severity')
|
||||
->label(__('hr.fields.severity'))
|
||||
->options(DisciplinarySeverity::class),
|
||||
TrashedFilter::make(),
|
||||
])
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Resources\EmployeeDocuments\Pages;
|
||||
|
||||
use App\Filament\Resources\EmployeeDocuments\EmployeeDocumentResource;
|
||||
use BokshornIt\FilamentActivityTimeline\Actions\ActivityTimelineAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
@@ -13,6 +14,7 @@ class ViewEmployeeDocument extends ViewRecord
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
ActivityTimelineAction::make(),
|
||||
EditAction::make(),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -16,10 +16,12 @@ public static function configure(Schema $schema): Schema
|
||||
->components([
|
||||
HrForm::employeeSelect(),
|
||||
Select::make('document_type')
|
||||
->label(__('hr.fields.document_type'))
|
||||
->options(DocumentType::class)
|
||||
->required()
|
||||
->native(false),
|
||||
TextInput::make('title')
|
||||
->label(__('hr.fields.title'))
|
||||
->required()
|
||||
->maxLength(255),
|
||||
HrForm::fileUpload('file_path')
|
||||
|
||||
@@ -15,18 +15,25 @@ public static function configure(Schema $schema): Schema
|
||||
TextEntry::make('employee.id')
|
||||
->label(__('hr.fields.employee')),
|
||||
TextEntry::make('document_type')
|
||||
->label(__('hr.fields.document_type'))
|
||||
->badge(),
|
||||
TextEntry::make('title'),
|
||||
TextEntry::make('file_path'),
|
||||
TextEntry::make('title')
|
||||
->label(__('hr.fields.title')),
|
||||
TextEntry::make('file_path')
|
||||
->label(__('hr.fields.file_path')),
|
||||
TextEntry::make('uploaded_at')
|
||||
->label(__('hr.fields.uploaded_at'))
|
||||
->dateTime(),
|
||||
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 (EmployeeDocument $record): bool => $record->trashed()),
|
||||
]);
|
||||
|
||||
@@ -35,21 +35,26 @@ public static function configure(Table $table): Table
|
||||
->searchable()
|
||||
->sortable(),
|
||||
TextColumn::make('title')
|
||||
->label(__('hr.fields.title'))
|
||||
->searchable()
|
||||
->sortable(),
|
||||
TextColumn::make('uploaded_at')
|
||||
->label(__('hr.fields.uploaded_at'))
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('created_at')
|
||||
->label(__('hr.fields.created_at'))
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('updated_at')
|
||||
->label(__('hr.fields.updated_at'))
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('deleted_at')
|
||||
->label(__('hr.fields.deleted_at'))
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Filament\Resources\EmployeeStats;
|
||||
|
||||
use App\Enums\NavigationGroup;
|
||||
use App\Filament\Concerns\HasHrResourceLabels;
|
||||
use App\Filament\Resources\EmployeeStats\Pages\ListEmployeeStats;
|
||||
use App\Filament\Resources\EmployeeStats\Tables\EmployeeStatsTable;
|
||||
use App\Models\Employee;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use UnitEnum;
|
||||
|
||||
class EmployeeStatsResource extends Resource
|
||||
{
|
||||
use HasHrResourceLabels;
|
||||
|
||||
protected static ?string $model = Employee::class;
|
||||
|
||||
protected static function hrLabelKeys(): array
|
||||
{
|
||||
return [
|
||||
'model' => 'employee_stat',
|
||||
'plural' => 'stats',
|
||||
'navigation' => 'stats',
|
||||
];
|
||||
}
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedChartBar;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = NavigationGroup::Employees;
|
||||
|
||||
protected static ?int $navigationSort = 2;
|
||||
|
||||
protected static ?string $slug = 'stats';
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'full_name';
|
||||
|
||||
protected static bool $isGloballySearchable = false;
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema;
|
||||
}
|
||||
|
||||
public static function infolist(Schema $schema): Schema
|
||||
{
|
||||
return $schema;
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return EmployeeStatsTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListEmployeeStats::route('/'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function canViewAny(): bool
|
||||
{
|
||||
return Gate::check('viewAny', Employee::class);
|
||||
}
|
||||
|
||||
public static function canView(Model $record): bool
|
||||
{
|
||||
return Gate::check('view', $record);
|
||||
}
|
||||
|
||||
public static function canCreate(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function canEdit(Model $record): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function canDelete(Model $record): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function canForceDelete(Model $record): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function canRestore(Model $record): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function getRecordRouteBindingEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getRecordRouteBindingEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Filament\Resources\EmployeeStats\Pages;
|
||||
|
||||
use App\Filament\Resources\EmployeeStats\EmployeeStatsResource;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListEmployeeStats extends ListRecords
|
||||
{
|
||||
protected static string $resource = EmployeeStatsResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Filament\Resources\EmployeeStats\Tables;
|
||||
|
||||
use App\Enums\EmploymentStatus;
|
||||
use App\Filament\Resources\Employees\EmployeeResource;
|
||||
use App\Models\Employee;
|
||||
use App\Services\Employee\EmployeeStatisticsService;
|
||||
use Filament\Actions\ViewAction;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class EmployeeStatsTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->modifyQueryUsing(fn ($query) => app(EmployeeStatisticsService::class)->applyTableAggregates($query))
|
||||
->columns([
|
||||
TextColumn::make('employee_number')
|
||||
->label(__('hr.fields.number'))
|
||||
->searchable()
|
||||
->sortable(),
|
||||
TextColumn::make('full_name')
|
||||
->label(__('hr.fields.full_name'))
|
||||
->searchable()
|
||||
->sortable(),
|
||||
TextColumn::make('department.name')
|
||||
->label(__('hr.fields.department'))
|
||||
->badge()
|
||||
->color('info')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
TextColumn::make('position.name')
|
||||
->label(__('hr.fields.position'))
|
||||
->badge()
|
||||
->color('primary')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
TextColumn::make('hire_date')
|
||||
->label(__('hr.fields.hire_date'))
|
||||
->date()
|
||||
->sortable(),
|
||||
TextColumn::make('tenure')
|
||||
->label(__('hr.fields.tenure'))
|
||||
->state(fn (Employee $record): string => $record->hire_date
|
||||
? $record->hire_date->diffForHumans(now(), true)
|
||||
: '—'),
|
||||
TextColumn::make('annual_vacation_days_taken')
|
||||
->label(__('hr.fields.vacation_taken_days'))
|
||||
->numeric()
|
||||
->sortable(),
|
||||
TextColumn::make('vacation_remaining')
|
||||
->label(__('hr.fields.vacation_remaining_days'))
|
||||
->state(fn (Employee $record): int => (int) config('hr.annual_leave_days') - (int) ($record->annual_vacation_days_taken ?? 0))
|
||||
->numeric()
|
||||
->color('success'),
|
||||
TextColumn::make('sick_leaves_count')
|
||||
->label(__('hr.fields.sick_leave_records'))
|
||||
->numeric()
|
||||
->sortable(),
|
||||
TextColumn::make('unpaid_leaves_count')
|
||||
->label(__('hr.fields.unpaid_leave_records'))
|
||||
->numeric()
|
||||
->sortable(),
|
||||
TextColumn::make('disciplinary_reports_count')
|
||||
->label(__('hr.fields.disciplinary_reports'))
|
||||
->numeric()
|
||||
->sortable(),
|
||||
TextColumn::make('explanations_count')
|
||||
->label(__('hr.fields.explanations'))
|
||||
->numeric()
|
||||
->sortable(),
|
||||
TextColumn::make('bonuses_sum_amount')
|
||||
->label(__('hr.fields.total_bonuses'))
|
||||
->money('TMT')
|
||||
->sortable(),
|
||||
TextColumn::make('gifts_count')
|
||||
->label(__('hr.fields.gifts_received'))
|
||||
->numeric()
|
||||
->sortable(),
|
||||
])
|
||||
->filters([
|
||||
SelectFilter::make('department_id')
|
||||
->label(__('hr.fields.department'))
|
||||
->relationship('department', 'name')
|
||||
->searchable()
|
||||
->preload(),
|
||||
SelectFilter::make('position_id')
|
||||
->label(__('hr.fields.position'))
|
||||
->relationship('position', 'name')
|
||||
->searchable()
|
||||
->preload(),
|
||||
SelectFilter::make('employment_status')
|
||||
->label(__('hr.fields.employment_status'))
|
||||
->options(EmploymentStatus::class),
|
||||
])
|
||||
->recordActions([
|
||||
ViewAction::make()
|
||||
->url(fn (Employee $record): string => EmployeeResource::getUrl('view', ['record' => $record])),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@
|
||||
use App\Filament\Resources\Employees\EmployeeResource;
|
||||
use App\Filament\Resources\Employees\Widgets\EmployeeStatsWidget;
|
||||
use App\Filament\Support\ExportPdfAction;
|
||||
use BokshornIt\FilamentActivityTimeline\Actions\ActivityTimelineAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
@@ -17,6 +18,17 @@ class ViewEmployee extends ViewRecord
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
ActivityTimelineAction::make()
|
||||
->withRelations([
|
||||
'vacations',
|
||||
'sickLeaves',
|
||||
'unpaidLeaves',
|
||||
'disciplinaryReports',
|
||||
'explanations',
|
||||
'bonuses',
|
||||
'gifts',
|
||||
'documents',
|
||||
]),
|
||||
ExportPdfAction::employeeProfile(),
|
||||
ExportPdfAction::employeeLeaveSummary(),
|
||||
EditAction::make(),
|
||||
|
||||
@@ -37,19 +37,23 @@ public function form(Schema $schema): Schema
|
||||
return $schema
|
||||
->components([
|
||||
DatePicker::make('bonus_date')
|
||||
->label(__('hr.fields.bonus_date'))
|
||||
->required()
|
||||
->default(now()),
|
||||
Select::make('bonus_type')
|
||||
->label(__('hr.fields.bonus_type'))
|
||||
->options(BonusType::class)
|
||||
->required()
|
||||
->native(false),
|
||||
TextInput::make('amount')
|
||||
->label(__('hr.fields.amount'))
|
||||
->required()
|
||||
->numeric()
|
||||
->prefix('TMT')
|
||||
->minValue(0)
|
||||
->step(0.01),
|
||||
Textarea::make('reason')
|
||||
->label(__('hr.fields.reason'))
|
||||
->rows(3)
|
||||
->columnSpanFull(),
|
||||
]);
|
||||
@@ -61,6 +65,7 @@ public function table(Table $table): Table
|
||||
->recordTitleAttribute('bonus_date')
|
||||
->columns([
|
||||
TextColumn::make('bonus_date')
|
||||
->label(__('hr.fields.bonus_date'))
|
||||
->date()
|
||||
->sortable(),
|
||||
TextColumn::make('bonus_type')
|
||||
@@ -70,9 +75,11 @@ public function table(Table $table): Table
|
||||
->formatStateUsing(fn (BonusType $state): string => $state->label())
|
||||
->sortable(),
|
||||
TextColumn::make('amount')
|
||||
->label(__('hr.fields.amount'))
|
||||
->money('TMT')
|
||||
->sortable(),
|
||||
TextColumn::make('reason')
|
||||
->label(__('hr.fields.reason'))
|
||||
->limit(40)
|
||||
->toggleable(),
|
||||
])
|
||||
|
||||
+8
@@ -39,16 +39,20 @@ public function form(Schema $schema): Schema
|
||||
return $schema
|
||||
->components([
|
||||
DatePicker::make('report_date')
|
||||
->label(__('hr.fields.report_date'))
|
||||
->required()
|
||||
->default(now()),
|
||||
TextInput::make('title')
|
||||
->label(__('hr.fields.title'))
|
||||
->required()
|
||||
->maxLength(255),
|
||||
Textarea::make('description')
|
||||
->label(__('hr.fields.description'))
|
||||
->required()
|
||||
->rows(4)
|
||||
->columnSpanFull(),
|
||||
Select::make('severity')
|
||||
->label(__('hr.fields.severity'))
|
||||
->options(DisciplinarySeverity::class)
|
||||
->required()
|
||||
->native(false),
|
||||
@@ -65,12 +69,15 @@ public function table(Table $table): Table
|
||||
->recordTitleAttribute('title')
|
||||
->columns([
|
||||
TextColumn::make('report_date')
|
||||
->label(__('hr.fields.report_date'))
|
||||
->date()
|
||||
->sortable(),
|
||||
TextColumn::make('title')
|
||||
->label(__('hr.fields.title'))
|
||||
->searchable()
|
||||
->sortable(),
|
||||
TextColumn::make('severity')
|
||||
->label(__('hr.fields.severity'))
|
||||
->badge()
|
||||
->color(fn (DisciplinarySeverity $state): string => $state->color())
|
||||
->formatStateUsing(fn (DisciplinarySeverity $state): string => $state->label())
|
||||
@@ -86,6 +93,7 @@ public function table(Table $table): Table
|
||||
])
|
||||
->filters([
|
||||
SelectFilter::make('severity')
|
||||
->label(__('hr.fields.severity'))
|
||||
->options(DisciplinarySeverity::class),
|
||||
TrashedFilter::make(),
|
||||
])
|
||||
|
||||
@@ -39,10 +39,12 @@ public function form(Schema $schema): Schema
|
||||
return $schema
|
||||
->components([
|
||||
Select::make('document_type')
|
||||
->label(__('hr.fields.document_type'))
|
||||
->options(DocumentType::class)
|
||||
->required()
|
||||
->native(false),
|
||||
TextInput::make('title')
|
||||
->label(__('hr.fields.title'))
|
||||
->required()
|
||||
->maxLength(255),
|
||||
HrForm::fileUpload('file_path')
|
||||
@@ -65,9 +67,11 @@ public function table(Table $table): Table
|
||||
->formatStateUsing(fn (DocumentType $state): string => $state->label())
|
||||
->sortable(),
|
||||
TextColumn::make('title')
|
||||
->label(__('hr.fields.title'))
|
||||
->searchable()
|
||||
->sortable(),
|
||||
TextColumn::make('uploaded_at')
|
||||
->label(__('hr.fields.uploaded_at'))
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
|
||||
@@ -36,12 +36,15 @@ public function form(Schema $schema): Schema
|
||||
return $schema
|
||||
->components([
|
||||
DatePicker::make('explanation_date')
|
||||
->label(__('hr.fields.explanation_date'))
|
||||
->required()
|
||||
->default(now()),
|
||||
TextInput::make('reason')
|
||||
->label(__('hr.fields.reason'))
|
||||
->required()
|
||||
->maxLength(255),
|
||||
Textarea::make('description')
|
||||
->label(__('hr.fields.description'))
|
||||
->required()
|
||||
->rows(4)
|
||||
->columnSpanFull(),
|
||||
@@ -58,12 +61,15 @@ public function table(Table $table): Table
|
||||
->recordTitleAttribute('reason')
|
||||
->columns([
|
||||
TextColumn::make('explanation_date')
|
||||
->label(__('hr.fields.explanation_date'))
|
||||
->date()
|
||||
->sortable(),
|
||||
TextColumn::make('reason')
|
||||
->label(__('hr.fields.reason'))
|
||||
->searchable()
|
||||
->limit(40),
|
||||
TextColumn::make('description')
|
||||
->label(__('hr.fields.description'))
|
||||
->limit(50)
|
||||
->toggleable(),
|
||||
IconColumn::make('attachment_path')
|
||||
|
||||
@@ -34,6 +34,7 @@ public function form(Schema $schema): Schema
|
||||
return $schema
|
||||
->components([
|
||||
DatePicker::make('gift_date')
|
||||
->label(__('hr.fields.gift_date'))
|
||||
->required()
|
||||
->default(now()),
|
||||
TextInput::make('gift_name')
|
||||
@@ -41,6 +42,7 @@ public function form(Schema $schema): Schema
|
||||
->required()
|
||||
->maxLength(255),
|
||||
TextInput::make('value')
|
||||
->label(__('hr.fields.value'))
|
||||
->required()
|
||||
->numeric()
|
||||
->prefix('TMT')
|
||||
@@ -48,6 +50,7 @@ public function form(Schema $schema): Schema
|
||||
->step(0.01)
|
||||
->default(0),
|
||||
Textarea::make('reason')
|
||||
->label(__('hr.fields.reason'))
|
||||
->rows(3)
|
||||
->columnSpanFull(),
|
||||
]);
|
||||
@@ -59,6 +62,7 @@ public function table(Table $table): Table
|
||||
->recordTitleAttribute('gift_name')
|
||||
->columns([
|
||||
TextColumn::make('gift_date')
|
||||
->label(__('hr.fields.gift_date'))
|
||||
->date()
|
||||
->sortable(),
|
||||
TextColumn::make('gift_name')
|
||||
@@ -66,9 +70,11 @@ public function table(Table $table): Table
|
||||
->searchable()
|
||||
->sortable(),
|
||||
TextColumn::make('value')
|
||||
->label(__('hr.fields.value'))
|
||||
->money('TMT')
|
||||
->sortable(),
|
||||
TextColumn::make('reason')
|
||||
->label(__('hr.fields.reason'))
|
||||
->limit(40)
|
||||
->toggleable(),
|
||||
])
|
||||
|
||||
@@ -34,12 +34,14 @@ public function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
HrForm::leaveDatePicker('start_date', __(hr.fields.start_date)),
|
||||
HrForm::leaveDatePicker('end_date', __(hr.fields.end_date)),
|
||||
HrForm::leaveDatePicker('start_date', __('hr.fields.start_date')),
|
||||
HrForm::leaveDatePicker('end_date', __('hr.fields.end_date')),
|
||||
HrForm::leaveDaysDisplay(),
|
||||
TextInput::make('medical_institution')
|
||||
->label(__('hr.fields.institution'))
|
||||
->maxLength(255),
|
||||
Textarea::make('reason')
|
||||
->label(__('hr.fields.reason'))
|
||||
->rows(3)
|
||||
->columnSpanFull(),
|
||||
HrForm::fileUpload('document_path')
|
||||
@@ -55,15 +57,19 @@ public function table(Table $table): Table
|
||||
->recordTitleAttribute('start_date')
|
||||
->columns([
|
||||
TextColumn::make('start_date')
|
||||
->label(__('hr.fields.start_date'))
|
||||
->date()
|
||||
->sortable(),
|
||||
TextColumn::make('end_date')
|
||||
->label(__('hr.fields.end_date'))
|
||||
->date()
|
||||
->sortable(),
|
||||
TextColumn::make('days')
|
||||
->label(__('hr.fields.days'))
|
||||
->numeric()
|
||||
->sortable(),
|
||||
TextColumn::make('medical_institution')
|
||||
->label(__('hr.fields.institution'))
|
||||
->searchable()
|
||||
->toggleable(),
|
||||
IconColumn::make('document_path')
|
||||
|
||||
@@ -38,10 +38,11 @@ public function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
HrForm::leaveDatePicker('start_date', __(hr.fields.start_date)),
|
||||
HrForm::leaveDatePicker('end_date', __(hr.fields.end_date)),
|
||||
HrForm::leaveDatePicker('start_date', __('hr.fields.start_date')),
|
||||
HrForm::leaveDatePicker('end_date', __('hr.fields.end_date')),
|
||||
HrForm::leaveDaysDisplay(),
|
||||
Textarea::make('reason')
|
||||
->label(__('hr.fields.reason'))
|
||||
->rows(3)
|
||||
->columnSpanFull(),
|
||||
]);
|
||||
@@ -53,15 +54,19 @@ public function table(Table $table): Table
|
||||
->recordTitleAttribute('start_date')
|
||||
->columns([
|
||||
TextColumn::make('start_date')
|
||||
->label(__('hr.fields.start_date'))
|
||||
->date()
|
||||
->sortable(),
|
||||
TextColumn::make('end_date')
|
||||
->label(__('hr.fields.end_date'))
|
||||
->date()
|
||||
->sortable(),
|
||||
TextColumn::make('days')
|
||||
->label(__('hr.fields.days'))
|
||||
->numeric()
|
||||
->sortable(),
|
||||
TextColumn::make('status')
|
||||
->label(__('hr.fields.status'))
|
||||
->badge()
|
||||
->color(fn (ApprovalStatus $state): string => $state->color())
|
||||
->formatStateUsing(fn (ApprovalStatus $state): string => $state->label())
|
||||
@@ -72,6 +77,7 @@ public function table(Table $table): Table
|
||||
])
|
||||
->filters([
|
||||
SelectFilter::make('status')
|
||||
->label(__('hr.fields.status'))
|
||||
->options(ApprovalStatus::class),
|
||||
TrashedFilter::make(),
|
||||
])
|
||||
|
||||
@@ -42,15 +42,17 @@ public function form(Schema $schema): Schema
|
||||
return $schema
|
||||
->components([
|
||||
Select::make('type')
|
||||
->label(__('hr.fields.type'))
|
||||
->options(VacationType::class)
|
||||
->required()
|
||||
->native(false),
|
||||
HrForm::leaveDatePicker('start_date', __(hr.fields.start_date)),
|
||||
HrForm::leaveDatePicker('end_date', __(hr.fields.end_date)),
|
||||
HrForm::leaveDatePicker('start_date', __('hr.fields.start_date')),
|
||||
HrForm::leaveDatePicker('end_date', __('hr.fields.end_date')),
|
||||
DatePicker::make('return_date')
|
||||
->label(__('hr.fields.return_date')),
|
||||
HrForm::leaveDaysDisplay(),
|
||||
Textarea::make('reason')
|
||||
->label(__('hr.fields.reason'))
|
||||
->rows(3)
|
||||
->columnSpanFull(),
|
||||
HrForm::fileUpload('attachment_path')
|
||||
@@ -66,20 +68,25 @@ public function table(Table $table): Table
|
||||
->recordTitleAttribute('start_date')
|
||||
->columns([
|
||||
TextColumn::make('type')
|
||||
->label(__('hr.fields.type'))
|
||||
->badge()
|
||||
->color(fn (VacationType $state): string => $state->color())
|
||||
->formatStateUsing(fn (VacationType $state): string => $state->label())
|
||||
->sortable(),
|
||||
TextColumn::make('start_date')
|
||||
->label(__('hr.fields.start_date'))
|
||||
->date()
|
||||
->sortable(),
|
||||
TextColumn::make('end_date')
|
||||
->label(__('hr.fields.end_date'))
|
||||
->date()
|
||||
->sortable(),
|
||||
TextColumn::make('days')
|
||||
->label(__('hr.fields.days'))
|
||||
->numeric()
|
||||
->sortable(),
|
||||
TextColumn::make('status')
|
||||
->label(__('hr.fields.status'))
|
||||
->badge()
|
||||
->color(fn (ApprovalStatus $state): string => $state->color())
|
||||
->formatStateUsing(fn (ApprovalStatus $state): string => $state->label())
|
||||
@@ -90,8 +97,10 @@ public function table(Table $table): Table
|
||||
])
|
||||
->filters([
|
||||
SelectFilter::make('status')
|
||||
->label(__('hr.fields.status'))
|
||||
->options(ApprovalStatus::class),
|
||||
SelectFilter::make('type')
|
||||
->label(__('hr.fields.type'))
|
||||
->options(VacationType::class),
|
||||
TrashedFilter::make(),
|
||||
])
|
||||
|
||||
@@ -4,10 +4,11 @@
|
||||
|
||||
use App\Enums\EmploymentStatus;
|
||||
use App\Enums\Gender;
|
||||
use App\Filament\Support\HrForm;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Support\RawJs;
|
||||
use App\Filament\Support\HrForm;
|
||||
use App\Support\Countries;use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Schemas\Components\Tabs;
|
||||
use Filament\Schemas\Components\Tabs\Tab;
|
||||
@@ -29,26 +30,43 @@ public static function configure(Schema $schema): Schema
|
||||
->avatar()
|
||||
->imageEditor(),
|
||||
TextInput::make('employee_number')
|
||||
->required()
|
||||
->maxLength(50)
|
||||
->unique(ignoreRecord: true),
|
||||
->label(__('hr.fields.employee_number'))
|
||||
->disabled()
|
||||
->dehydrated(false)
|
||||
->visibleOn('edit'),
|
||||
TextInput::make('full_name')
|
||||
->label(__('hr.fields.full_name'))
|
||||
->required()
|
||||
->maxLength(255),
|
||||
TextInput::make('national_id')
|
||||
Select::make('national_id')
|
||||
->label(__('hr.fields.national_id'))
|
||||
->maxLength(50),
|
||||
->options(fn (): array => Countries::options())
|
||||
->searchable()
|
||||
->native(false)
|
||||
->default(Countries::default())
|
||||
->required(),
|
||||
|
||||
Select::make('gender')
|
||||
->label(__('hr.fields.gender'))
|
||||
->options(Gender::class)
|
||||
->required()
|
||||
->native(false),
|
||||
|
||||
DatePicker::make('birth_date')
|
||||
->required(),
|
||||
->label(__('hr.fields.birth_date'))
|
||||
->required()
|
||||
->native(false),
|
||||
|
||||
TextInput::make('phone')
|
||||
->tel()
|
||||
->default(config('hr.default_phone'))
|
||||
->label(__('hr.fields.phone'))
|
||||
->prefix('+993')
|
||||
->mask(RawJs::make(<<<'JS'
|
||||
'99 99-99-99'
|
||||
JS))
|
||||
->required(),
|
||||
|
||||
Textarea::make('address')
|
||||
->label(__('hr.fields.address'))
|
||||
->rows(3)
|
||||
->columnSpanFull(),
|
||||
])
|
||||
@@ -56,29 +74,40 @@ public static function configure(Schema $schema): Schema
|
||||
Tab::make(__('hr.tabs.employment'))
|
||||
->schema([
|
||||
Select::make('department_id')
|
||||
->label(__('hr.fields.department'))
|
||||
->relationship('department', 'name')
|
||||
->searchable()
|
||||
->preload()
|
||||
->required(),
|
||||
Select::make('position_id')
|
||||
->label(__('hr.fields.position'))
|
||||
->relationship('position', 'name')
|
||||
->searchable()
|
||||
->preload()
|
||||
->required(),
|
||||
Select::make('shift_id')
|
||||
->label(__('hr.fields.shift'))
|
||||
->relationship('shift', 'name')
|
||||
->searchable()
|
||||
->preload()
|
||||
->required(),
|
||||
Select::make('employment_status')
|
||||
->label(__('hr.fields.employment_status'))
|
||||
->options(EmploymentStatus::class)
|
||||
->default(EmploymentStatus::Active)
|
||||
->required()
|
||||
->native(false),
|
||||
DatePicker::make('hire_date')
|
||||
->required(),
|
||||
DatePicker::make('termination_date'),
|
||||
->label(__('hr.fields.hire_date'))
|
||||
->required()
|
||||
->native(false),
|
||||
|
||||
DatePicker::make('termination_date')
|
||||
->label(__('hr.fields.termination_date'))
|
||||
->native(false),
|
||||
|
||||
Textarea::make('notes')
|
||||
->label(__('hr.fields.notes'))
|
||||
->rows(4)
|
||||
->columnSpanFull(),
|
||||
])
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
use App\Models\Employee;
|
||||
use App\Models\Vacation;
|
||||
use App\Services\Employee\EmployeeStatisticsService;
|
||||
use App\Support\Countries;
|
||||
use Filament\Infolists\Components\ImageEntry;
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Schemas\Components\Section;
|
||||
@@ -38,18 +39,24 @@ public static function configure(Schema $schema): Schema
|
||||
->columnSpanFull(),
|
||||
TextEntry::make('employee_number')
|
||||
->label(__('hr.fields.employee_number')),
|
||||
TextEntry::make('full_name'),
|
||||
TextEntry::make('full_name')
|
||||
->label(__('hr.fields.full_name')),
|
||||
TextEntry::make('national_id')
|
||||
->label(__('hr.fields.national_id'))
|
||||
->formatStateUsing(fn (?string $state): string => Countries::name($state) ?? $state ?? '—')
|
||||
->placeholder('—'),
|
||||
TextEntry::make('gender')
|
||||
->label(__('hr.fields.gender'))
|
||||
->badge()
|
||||
->color(fn (Gender $state): string => $state->color())
|
||||
->formatStateUsing(fn (Gender $state): string => $state->label()),
|
||||
TextEntry::make('birth_date')
|
||||
->label(__('hr.fields.birth_date'))
|
||||
->date(),
|
||||
TextEntry::make('phone'),
|
||||
TextEntry::make('phone')
|
||||
->label(__('hr.fields.phone')),
|
||||
TextEntry::make('address')
|
||||
->label(__('hr.fields.address'))
|
||||
->placeholder('—')
|
||||
->columnSpanFull(),
|
||||
])
|
||||
@@ -69,6 +76,7 @@ public static function configure(Schema $schema): Schema
|
||||
->badge()
|
||||
->color('gray'),
|
||||
TextEntry::make('employment_status')
|
||||
->label(__('hr.fields.employment_status'))
|
||||
->badge()
|
||||
->color(fn (EmploymentStatus $state): string => $state->color())
|
||||
->formatStateUsing(fn (EmploymentStatus $state): string => $state->label())
|
||||
@@ -92,6 +100,7 @@ public static function configure(Schema $schema): Schema
|
||||
? $record->hire_date->diffForHumans(now(), true)
|
||||
: '—'),
|
||||
TextEntry::make('notes')
|
||||
->label(__('hr.fields.notes'))
|
||||
->placeholder('—')
|
||||
->columnSpanFull(),
|
||||
])
|
||||
@@ -146,16 +155,16 @@ public static function configure(Schema $schema): Schema
|
||||
TextEntry::make('leave_balance_taken')
|
||||
->label(__('hr.fields.days_taken'))
|
||||
->state(fn (Employee $record): int => app(EmployeeStatisticsService::class)->summary($record)->vacationTaken)
|
||||
->suffix(' ' . __('hr.messages.days_suffix')),
|
||||
->suffix(' '.__('hr.messages.days_suffix')),
|
||||
TextEntry::make('leave_balance_remaining')
|
||||
->label(__('hr.fields.days_remaining'))
|
||||
->state(fn (Employee $record): int => app(EmployeeStatisticsService::class)->summary($record)->vacationRemaining)
|
||||
->suffix(' ' . __('hr.messages.days_suffix'))
|
||||
->suffix(' '.__('hr.messages.days_suffix'))
|
||||
->color('success'),
|
||||
TextEntry::make('leave_balance_total')
|
||||
->label(__('hr.fields.annual_allowance'))
|
||||
->state(fn (): int => (int) config('hr.annual_leave_days'))
|
||||
->suffix(' ' . __('hr.messages.days_suffix')),
|
||||
->suffix(' '.__('hr.messages.days_suffix')),
|
||||
])
|
||||
->columns(3),
|
||||
Section::make(__('hr.sections.upcoming_approved_leave'))
|
||||
|
||||
@@ -4,9 +4,11 @@
|
||||
|
||||
use App\Enums\EmploymentStatus;
|
||||
use App\Enums\Gender;
|
||||
use App\Exports\EmployeesExport;
|
||||
use App\Filament\Support\ExportExcelAction;
|
||||
use App\Models\Department;
|
||||
use App\Models\Employee;
|
||||
use App\Filament\Support\ExportExcelAction;
|
||||
use App\Support\Countries;
|
||||
use Filament\Actions\BulkAction;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
@@ -32,18 +34,22 @@ public static function configure(Table $table): Table
|
||||
->searchable()
|
||||
->sortable(),
|
||||
TextColumn::make('full_name')
|
||||
->label(__('hr.fields.full_name'))
|
||||
->searchable()
|
||||
->sortable(),
|
||||
TextColumn::make('national_id')
|
||||
->label(__('hr.fields.national_id'))
|
||||
->formatStateUsing(fn (?string $state): ?string => Countries::name($state) ?? $state)
|
||||
->searchable()
|
||||
->toggleable(),
|
||||
TextColumn::make('gender')
|
||||
->label(__('hr.fields.gender'))
|
||||
->badge()
|
||||
->color(fn (Gender $state): string => $state->color())
|
||||
->formatStateUsing(fn (Gender $state): string => $state->label())
|
||||
->searchable(),
|
||||
TextColumn::make('phone')
|
||||
->label(__('hr.fields.phone'))
|
||||
->searchable()
|
||||
->toggleable(),
|
||||
TextColumn::make('department.name')
|
||||
@@ -72,21 +78,26 @@ public static function configure(Table $table): Table
|
||||
->searchable()
|
||||
->sortable(),
|
||||
TextColumn::make('hire_date')
|
||||
->label(__('hr.fields.hire_date'))
|
||||
->date()
|
||||
->sortable(),
|
||||
TextColumn::make('termination_date')
|
||||
->label(__('hr.fields.termination_date'))
|
||||
->date()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('created_at')
|
||||
->label(__('hr.fields.created_at'))
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('updated_at')
|
||||
->label(__('hr.fields.updated_at'))
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('deleted_at')
|
||||
->label(__('hr.fields.deleted_at'))
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
@@ -118,7 +129,7 @@ public static function configure(Table $table): Table
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
ExportExcelAction::bulk('exportSelected', \App\Exports\EmployeesExport::class, 'employees.xlsx'),
|
||||
ExportExcelAction::bulk('exportSelected', EmployeesExport::class, 'employees.xlsx'),
|
||||
BulkAction::make('changeDepartment')
|
||||
->label(__('hr.actions.change_department'))
|
||||
->icon('heroicon-o-building-office-2')
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Resources\Explanations\Pages;
|
||||
|
||||
use App\Filament\Resources\Explanations\ExplanationResource;
|
||||
use BokshornIt\FilamentActivityTimeline\Actions\ActivityTimelineAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
@@ -13,6 +14,7 @@ class ViewExplanation extends ViewRecord
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
ActivityTimelineAction::make(),
|
||||
EditAction::make(),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -16,12 +16,15 @@ public static function configure(Schema $schema): Schema
|
||||
->components([
|
||||
HrForm::employeeSelect(),
|
||||
DatePicker::make('explanation_date')
|
||||
->label(__('hr.fields.explanation_date'))
|
||||
->required()
|
||||
->default(now()),
|
||||
TextInput::make('reason')
|
||||
->label(__('hr.fields.reason'))
|
||||
->required()
|
||||
->maxLength(255),
|
||||
Textarea::make('description')
|
||||
->label(__('hr.fields.description'))
|
||||
->required()
|
||||
->rows(4)
|
||||
->columnSpanFull(),
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Filament\Resources\Explanations\Schemas;
|
||||
|
||||
use App\Models\Explanation;
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class ExplanationInfolist
|
||||
@@ -12,24 +15,46 @@ public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextEntry::make('employee.id')
|
||||
->label(__('hr.fields.employee')),
|
||||
TextEntry::make('explanation_date')
|
||||
->date(),
|
||||
TextEntry::make('reason'),
|
||||
TextEntry::make('description')
|
||||
->columnSpanFull(),
|
||||
TextEntry::make('attachment_path')
|
||||
->placeholder('-'),
|
||||
TextEntry::make('created_at')
|
||||
->dateTime()
|
||||
->placeholder('-'),
|
||||
TextEntry::make('updated_at')
|
||||
->dateTime()
|
||||
->placeholder('-'),
|
||||
TextEntry::make('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),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -24,12 +24,15 @@ public static function configure(Table $table): Table
|
||||
->searchable()
|
||||
->sortable(),
|
||||
TextColumn::make('explanation_date')
|
||||
->label(__('hr.fields.explanation_date'))
|
||||
->date()
|
||||
->sortable(),
|
||||
TextColumn::make('reason')
|
||||
->label(__('hr.fields.reason'))
|
||||
->searchable()
|
||||
->limit(40),
|
||||
TextColumn::make('description')
|
||||
->label(__('hr.fields.description'))
|
||||
->limit(50)
|
||||
->toggleable(),
|
||||
IconColumn::make('attachment_path')
|
||||
@@ -38,14 +41,17 @@ public static function configure(Table $table): Table
|
||||
->trueIcon('heroicon-o-paper-clip')
|
||||
->falseIcon('heroicon-o-minus'),
|
||||
TextColumn::make('created_at')
|
||||
->label(__('hr.fields.created_at'))
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('updated_at')
|
||||
->label(__('hr.fields.updated_at'))
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('deleted_at')
|
||||
->label(__('hr.fields.deleted_at'))
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Resources\Gifts\Pages;
|
||||
|
||||
use App\Filament\Resources\Gifts\GiftResource;
|
||||
use BokshornIt\FilamentActivityTimeline\Actions\ActivityTimelineAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
@@ -13,6 +14,7 @@ class ViewGift extends ViewRecord
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
ActivityTimelineAction::make(),
|
||||
EditAction::make(),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -16,13 +16,16 @@ public static function configure(Schema $schema): Schema
|
||||
->components([
|
||||
HrForm::employeeSelect(),
|
||||
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()
|
||||
->maxLength(255),
|
||||
TextInput::make('value')
|
||||
->label(__('hr.fields.value'))
|
||||
->required()
|
||||
->numeric()
|
||||
->prefix('TMT')
|
||||
@@ -30,6 +33,7 @@ public static function configure(Schema $schema): Schema
|
||||
->step(0.01)
|
||||
->default(0),
|
||||
Textarea::make('reason')
|
||||
->label(__('hr.fields.reason'))
|
||||
->rows(3)
|
||||
->columnSpanFull(),
|
||||
]);
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Filament\Resources\Gifts\Schemas;
|
||||
|
||||
use App\Models\Gift;
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class GiftInfolist
|
||||
@@ -12,25 +15,44 @@ public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextEntry::make('employee.id')
|
||||
->label(__('hr.fields.employee')),
|
||||
TextEntry::make('gift_date')
|
||||
->date(),
|
||||
TextEntry::make('gift_name'),
|
||||
TextEntry::make('value')
|
||||
->numeric(),
|
||||
TextEntry::make('reason')
|
||||
->placeholder('-')
|
||||
->columnSpanFull(),
|
||||
TextEntry::make('created_at')
|
||||
->dateTime()
|
||||
->placeholder('-'),
|
||||
TextEntry::make('updated_at')
|
||||
->dateTime()
|
||||
->placeholder('-'),
|
||||
TextEntry::make('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),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,7 @@ public static function configure(Table $table): Table
|
||||
->searchable()
|
||||
->sortable(),
|
||||
TextColumn::make('gift_date')
|
||||
->label(__('hr.fields.gift_date'))
|
||||
->date()
|
||||
->sortable(),
|
||||
TextColumn::make('gift_name')
|
||||
@@ -30,20 +31,25 @@ public static function configure(Table $table): Table
|
||||
->searchable()
|
||||
->sortable(),
|
||||
TextColumn::make('value')
|
||||
->label(__('hr.fields.value'))
|
||||
->money('TMT')
|
||||
->sortable(),
|
||||
TextColumn::make('reason')
|
||||
->label(__('hr.fields.reason'))
|
||||
->limit(40)
|
||||
->toggleable(),
|
||||
TextColumn::make('created_at')
|
||||
->label(__('hr.fields.created_at'))
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('updated_at')
|
||||
->label(__('hr.fields.updated_at'))
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('deleted_at')
|
||||
->label(__('hr.fields.deleted_at'))
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Resources\Positions\Pages;
|
||||
|
||||
use App\Filament\Resources\Positions\PositionResource;
|
||||
use BokshornIt\FilamentActivityTimeline\Actions\ActivityTimelineAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
@@ -13,6 +14,7 @@ class ViewPosition extends ViewRecord
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
ActivityTimelineAction::make(),
|
||||
EditAction::make(),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -13,9 +13,11 @@ public static function configure(Schema $schema): Schema
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('name')
|
||||
->label(__('hr.fields.name'))
|
||||
->required()
|
||||
->maxLength(255),
|
||||
Textarea::make('description')
|
||||
->label(__('hr.fields.description'))
|
||||
->rows(3)
|
||||
->columnSpanFull(),
|
||||
]);
|
||||
|
||||
@@ -12,17 +12,22 @@ public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextEntry::make('name'),
|
||||
TextEntry::make('name')
|
||||
->label(__('hr.fields.name')),
|
||||
TextEntry::make('description')
|
||||
->label(__('hr.fields.description'))
|
||||
->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 (Position $record): bool => $record->trashed()),
|
||||
]);
|
||||
|
||||
@@ -19,21 +19,26 @@ public static function configure(Table $table): Table
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('name')
|
||||
->label(__('hr.fields.name'))
|
||||
->searchable()
|
||||
->sortable(),
|
||||
TextColumn::make('description')
|
||||
->label(__('hr.fields.description'))
|
||||
->searchable()
|
||||
->limit(50)
|
||||
->toggleable(),
|
||||
TextColumn::make('created_at')
|
||||
->label(__('hr.fields.created_at'))
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('updated_at')
|
||||
->label(__('hr.fields.updated_at'))
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('deleted_at')
|
||||
->label(__('hr.fields.deleted_at'))
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Resources\Shifts\Pages;
|
||||
|
||||
use App\Filament\Resources\Shifts\ShiftResource;
|
||||
use BokshornIt\FilamentActivityTimeline\Actions\ActivityTimelineAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
@@ -13,6 +14,7 @@ class ViewShift extends ViewRecord
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
ActivityTimelineAction::make(),
|
||||
EditAction::make(),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -14,25 +14,25 @@ public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TimePicker::make('starts_at')
|
||||
->label(__('hr.fields.starts_at'))
|
||||
->required()
|
||||
->seconds(false),
|
||||
TimePicker::make('ends_at')
|
||||
->label(__('hr.fields.ends_at'))
|
||||
->required()
|
||||
->seconds(false),
|
||||
|
||||
TextInput::make('name')
|
||||
->label(__('hr.fields.name'))
|
||||
->required()
|
||||
->maxLength(255),
|
||||
TextInput::make('code')
|
||||
->required()
|
||||
->maxLength(50)
|
||||
->unique(ignoreRecord: true),
|
||||
TimePicker::make('starts_at')
|
||||
->label(__('hr.fields.starts_at'))
|
||||
->required()
|
||||
->seconds(false),
|
||||
TimePicker::make('ends_at')
|
||||
->label(__('hr.fields.ends_at'))
|
||||
->required()
|
||||
->seconds(false),
|
||||
|
||||
Textarea::make('description')
|
||||
->rows(3)
|
||||
->columnSpanFull(),
|
||||
Toggle::make('is_active')
|
||||
->label(__('hr.fields.description'))
|
||||
->rows(3),
|
||||
|
||||
Toggle::make('is_active')
|
||||
->label(__('hr.fields.active'))
|
||||
->default(true)
|
||||
->required(),
|
||||
|
||||
@@ -13,26 +13,35 @@ public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextEntry::make('name'),
|
||||
TextEntry::make('code'),
|
||||
TextEntry::make('name')
|
||||
->label(__('hr.fields.name')),
|
||||
TextEntry::make('code')
|
||||
->label(__('hr.fields.code')),
|
||||
TextEntry::make('starts_at')
|
||||
->label(__('hr.fields.starts_at'))
|
||||
->time()
|
||||
->placeholder('-'),
|
||||
TextEntry::make('ends_at')
|
||||
->label(__('hr.fields.ends_at'))
|
||||
->time()
|
||||
->placeholder('-'),
|
||||
TextEntry::make('description')
|
||||
->label(__('hr.fields.description'))
|
||||
->placeholder('-')
|
||||
->columnSpanFull(),
|
||||
IconEntry::make('is_active')
|
||||
->label(__('hr.fields.status'))
|
||||
->boolean(),
|
||||
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 (Shift $record): bool => $record->trashed()),
|
||||
]);
|
||||
|
||||
@@ -20,9 +20,11 @@ public static function configure(Table $table): Table
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('name')
|
||||
->label(__('hr.fields.name'))
|
||||
->searchable()
|
||||
->sortable(),
|
||||
TextColumn::make('code')
|
||||
->label(__('hr.fields.code'))
|
||||
->searchable()
|
||||
->sortable(),
|
||||
TextColumn::make('starts_at')
|
||||
@@ -34,6 +36,7 @@ public static function configure(Table $table): Table
|
||||
->time()
|
||||
->sortable(),
|
||||
TextColumn::make('description')
|
||||
->label(__('hr.fields.description'))
|
||||
->limit(50)
|
||||
->toggleable(),
|
||||
TextColumn::make('is_active')
|
||||
@@ -43,14 +46,17 @@ public static function configure(Table $table): Table
|
||||
->color(fn (bool $state): string => $state ? 'success' : 'danger')
|
||||
->sortable(),
|
||||
TextColumn::make('created_at')
|
||||
->label(__('hr.fields.created_at'))
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('updated_at')
|
||||
->label(__('hr.fields.updated_at'))
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('deleted_at')
|
||||
->label(__('hr.fields.deleted_at'))
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Resources\SickLeaves\Pages;
|
||||
|
||||
use App\Filament\Resources\SickLeaves\SickLeaveResource;
|
||||
use BokshornIt\FilamentActivityTimeline\Actions\ActivityTimelineAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
@@ -13,6 +14,7 @@ class ViewSickLeave extends ViewRecord
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
ActivityTimelineAction::make(),
|
||||
EditAction::make(),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -12,14 +12,23 @@ class SickLeaveForm
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->columns(3)
|
||||
->components([
|
||||
HrForm::employeeSelect(),
|
||||
HrForm::leaveDatePicker('start_date', __(hr.fields.start_date)),
|
||||
HrForm::leaveDatePicker('end_date', __(hr.fields.end_date)),
|
||||
HrForm::leaveDaysDisplay(),
|
||||
HrForm::leaveDatePicker('start_date', __('hr.fields.start_date'))
|
||||
->native(false),
|
||||
HrForm::leaveDatePicker('end_date', __('hr.fields.end_date'))
|
||||
->native(false),
|
||||
|
||||
TextInput::make('medical_institution')
|
||||
->maxLength(255),
|
||||
->label(__('hr.fields.institution'))
|
||||
->maxLength(255)
|
||||
->columnSpan(2),
|
||||
|
||||
HrForm::leaveDaysDisplay(),
|
||||
|
||||
Textarea::make('reason')
|
||||
->label(__('hr.fields.reason'))
|
||||
->rows(3)
|
||||
->columnSpanFull(),
|
||||
HrForm::fileUpload('document_path')
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Filament\Resources\SickLeaves\Schemas;
|
||||
|
||||
use App\Models\SickLeave;
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class SickLeaveInfolist
|
||||
@@ -12,30 +15,55 @@ public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextEntry::make('employee.id')
|
||||
->label(__('hr.fields.employee')),
|
||||
TextEntry::make('start_date')
|
||||
->date(),
|
||||
TextEntry::make('end_date')
|
||||
->date(),
|
||||
TextEntry::make('days')
|
||||
->numeric(),
|
||||
TextEntry::make('medical_institution')
|
||||
->placeholder('-'),
|
||||
TextEntry::make('reason')
|
||||
->placeholder('-')
|
||||
->columnSpanFull(),
|
||||
TextEntry::make('document_path')
|
||||
->placeholder('-'),
|
||||
TextEntry::make('created_at')
|
||||
->dateTime()
|
||||
->placeholder('-'),
|
||||
TextEntry::make('updated_at')
|
||||
->dateTime()
|
||||
->placeholder('-'),
|
||||
TextEntry::make('deleted_at')
|
||||
->dateTime()
|
||||
->visible(fn (SickLeave $record): bool => $record->trashed()),
|
||||
Section::make(__('hr.sections.basic_info'))
|
||||
->schema([
|
||||
TextEntry::make('employee.full_name')
|
||||
->label(__('hr.fields.employee')),
|
||||
])
|
||||
->columns(1),
|
||||
Section::make(__('hr.sections.dates'))
|
||||
->schema([
|
||||
TextEntry::make('start_date')
|
||||
->label(__('hr.fields.start_date'))
|
||||
->date('d.m.Y'),
|
||||
TextEntry::make('end_date')
|
||||
->label(__('hr.fields.end_date'))
|
||||
->date('d.m.Y'),
|
||||
TextEntry::make('days')
|
||||
->label(__('hr.fields.days'))
|
||||
->suffix(' '.__('hr.messages.days_suffix')),
|
||||
])
|
||||
->columns(2),
|
||||
Section::make(__('hr.sections.medical_details'))
|
||||
->schema([
|
||||
TextEntry::make('medical_institution')
|
||||
->label(__('hr.fields.institution'))
|
||||
->placeholder('—'),
|
||||
TextEntry::make('document_path')
|
||||
->label(__('hr.fields.medical_document'))
|
||||
->formatStateUsing(fn (?string $state): string => filled($state) ? basename($state) : '—'),
|
||||
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 (SickLeave $record): bool => $record->trashed()),
|
||||
])
|
||||
->columns(2),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -24,15 +24,19 @@ public static function configure(Table $table): Table
|
||||
->searchable()
|
||||
->sortable(),
|
||||
TextColumn::make('start_date')
|
||||
->label(__('hr.fields.start_date'))
|
||||
->date()
|
||||
->sortable(),
|
||||
TextColumn::make('end_date')
|
||||
->label(__('hr.fields.end_date'))
|
||||
->date()
|
||||
->sortable(),
|
||||
TextColumn::make('days')
|
||||
->label(__('hr.fields.days'))
|
||||
->numeric()
|
||||
->sortable(),
|
||||
TextColumn::make('medical_institution')
|
||||
->label(__('hr.fields.institution'))
|
||||
->searchable()
|
||||
->toggleable(),
|
||||
IconColumn::make('document_path')
|
||||
@@ -42,14 +46,17 @@ public static function configure(Table $table): Table
|
||||
->falseIcon('heroicon-o-document')
|
||||
->sortable(),
|
||||
TextColumn::make('created_at')
|
||||
->label(__('hr.fields.created_at'))
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('updated_at')
|
||||
->label(__('hr.fields.updated_at'))
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('deleted_at')
|
||||
->label(__('hr.fields.deleted_at'))
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Resources\UnpaidLeaves\Pages;
|
||||
|
||||
use App\Filament\Resources\UnpaidLeaves\UnpaidLeaveResource;
|
||||
use BokshornIt\FilamentActivityTimeline\Actions\ActivityTimelineAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
@@ -13,6 +14,7 @@ class ViewUnpaidLeave extends ViewRecord
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
ActivityTimelineAction::make(),
|
||||
EditAction::make(),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -13,10 +13,13 @@ public static function configure(Schema $schema): Schema
|
||||
return $schema
|
||||
->components([
|
||||
HrForm::employeeSelect(),
|
||||
HrForm::leaveDatePicker('start_date', __(hr.fields.start_date)),
|
||||
HrForm::leaveDatePicker('end_date', __(hr.fields.end_date)),
|
||||
HrForm::leaveDatePicker('start_date', __('hr.fields.start_date'))
|
||||
->native(false),
|
||||
HrForm::leaveDatePicker('end_date', __('hr.fields.end_date'))
|
||||
->native(false),
|
||||
HrForm::leaveDaysDisplay(),
|
||||
Textarea::make('reason')
|
||||
->label(__('hr.fields.reason'))
|
||||
->rows(3)
|
||||
->columnSpanFull(),
|
||||
]);
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Filament\Resources\UnpaidLeaves\Schemas;
|
||||
|
||||
use App\Enums\ApprovalStatus;
|
||||
use App\Models\UnpaidLeave;
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class UnpaidLeaveInfolist
|
||||
@@ -12,34 +16,61 @@ public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextEntry::make('employee.id')
|
||||
->label(__('hr.fields.employee')),
|
||||
TextEntry::make('start_date')
|
||||
->date(),
|
||||
TextEntry::make('end_date')
|
||||
->date(),
|
||||
TextEntry::make('days')
|
||||
->numeric(),
|
||||
TextEntry::make('reason')
|
||||
->placeholder('-')
|
||||
->columnSpanFull(),
|
||||
TextEntry::make('status')
|
||||
->badge(),
|
||||
TextEntry::make('approved_by')
|
||||
->numeric()
|
||||
->placeholder('-'),
|
||||
TextEntry::make('approved_at')
|
||||
->dateTime()
|
||||
->placeholder('-'),
|
||||
TextEntry::make('created_at')
|
||||
->dateTime()
|
||||
->placeholder('-'),
|
||||
TextEntry::make('updated_at')
|
||||
->dateTime()
|
||||
->placeholder('-'),
|
||||
TextEntry::make('deleted_at')
|
||||
->dateTime()
|
||||
->visible(fn (UnpaidLeave $record): bool => $record->trashed()),
|
||||
Section::make(__('hr.sections.basic_info'))
|
||||
->schema([
|
||||
TextEntry::make('employee.full_name')
|
||||
->label(__('hr.fields.employee')),
|
||||
TextEntry::make('status')
|
||||
->label(__('hr.fields.status'))
|
||||
->badge()
|
||||
->color(fn (ApprovalStatus $state): string => $state->color())
|
||||
->formatStateUsing(fn (ApprovalStatus $state): string => $state->label()),
|
||||
])
|
||||
->columns(2),
|
||||
Section::make(__('hr.sections.dates'))
|
||||
->schema([
|
||||
TextEntry::make('start_date')
|
||||
->label(__('hr.fields.start_date'))
|
||||
->date('d.m.Y'),
|
||||
TextEntry::make('end_date')
|
||||
->label(__('hr.fields.end_date'))
|
||||
->date('d.m.Y'),
|
||||
TextEntry::make('days')
|
||||
->label(__('hr.fields.days'))
|
||||
->suffix(' '.__('hr.messages.days_suffix')),
|
||||
])
|
||||
->columns(2),
|
||||
Section::make(__('hr.sections.approval'))
|
||||
->schema([
|
||||
TextEntry::make('reason')
|
||||
->label(__('hr.fields.reason'))
|
||||
->placeholder('—')
|
||||
->columnSpanFull(),
|
||||
TextEntry::make('approved_by')
|
||||
->label(__('hr.fields.approved_by'))
|
||||
->formatStateUsing(fn ($state, UnpaidLeave $record): string => $record->approver?->name ?? '—'),
|
||||
])
|
||||
->columns(2),
|
||||
Section::make(__('hr.sections.metadata'))
|
||||
->schema([
|
||||
TextEntry::make('approved_at')
|
||||
->label(__('hr.fields.approved_at'))
|
||||
->dateTime('d.m.Y H:i')
|
||||
->placeholder('—'),
|
||||
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 (UnpaidLeave $record): bool => $record->trashed()),
|
||||
])
|
||||
->columns(2),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -32,15 +32,19 @@ public static function configure(Table $table): Table
|
||||
->searchable()
|
||||
->sortable(),
|
||||
TextColumn::make('start_date')
|
||||
->label(__('hr.fields.start_date'))
|
||||
->date()
|
||||
->sortable(),
|
||||
TextColumn::make('end_date')
|
||||
->label(__('hr.fields.end_date'))
|
||||
->date()
|
||||
->sortable(),
|
||||
TextColumn::make('days')
|
||||
->label(__('hr.fields.days'))
|
||||
->numeric()
|
||||
->sortable(),
|
||||
TextColumn::make('status')
|
||||
->label(__('hr.fields.status'))
|
||||
->badge()
|
||||
->color(fn (ApprovalStatus $state): string => $state->color())
|
||||
->formatStateUsing(fn (ApprovalStatus $state): string => $state->label())
|
||||
@@ -50,24 +54,29 @@ public static function configure(Table $table): Table
|
||||
->label(__('hr.fields.approved_by'))
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('approved_at')
|
||||
->label(__('hr.fields.approved_at'))
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('created_at')
|
||||
->label(__('hr.fields.created_at'))
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('updated_at')
|
||||
->label(__('hr.fields.updated_at'))
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('deleted_at')
|
||||
->label(__('hr.fields.deleted_at'))
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
SelectFilter::make('status')
|
||||
->label(__('hr.fields.status'))
|
||||
->options(ApprovalStatus::class),
|
||||
Filter::make('date_range')
|
||||
->label(__('hr.fields.date_range'))
|
||||
|
||||
@@ -16,6 +16,7 @@ public static function configure(Schema $schema): Schema
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('name')
|
||||
->label(__('hr.fields.name'))
|
||||
->required()
|
||||
->maxLength(255),
|
||||
TextInput::make('email')
|
||||
@@ -25,6 +26,7 @@ public static function configure(Schema $schema): Schema
|
||||
->maxLength(255)
|
||||
->unique(ignoreRecord: true),
|
||||
TextInput::make('password')
|
||||
->label(__('hr.fields.password'))
|
||||
->password()
|
||||
->dehydrateStateUsing(fn (?string $state): ?string => filled($state) ? Hash::make($state) : null)
|
||||
->dehydrated(fn (?string $state): bool => filled($state))
|
||||
@@ -43,6 +45,7 @@ public static function configure(Schema $schema): Schema
|
||||
->required()
|
||||
->default(config('hr.default_locale')),
|
||||
Select::make('roles')
|
||||
->label(__('hr.fields.roles'))
|
||||
->relationship('roles', 'name')
|
||||
->multiple()
|
||||
->preload()
|
||||
|
||||
@@ -11,16 +11,20 @@ public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextEntry::make('name'),
|
||||
TextEntry::make('name')
|
||||
->label(__('hr.fields.name')),
|
||||
TextEntry::make('email')
|
||||
->label(__('hr.fields.email_address')),
|
||||
TextEntry::make('email_verified_at')
|
||||
->label(__('hr.fields.email_verified_at'))
|
||||
->dateTime()
|
||||
->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('department.name')
|
||||
|
||||
@@ -16,22 +16,27 @@ public static function configure(Table $table): Table
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('name')
|
||||
->label(__('hr.fields.name'))
|
||||
->searchable(),
|
||||
TextColumn::make('email')
|
||||
->label(__('hr.fields.email_address'))
|
||||
->searchable(),
|
||||
TextColumn::make('email_verified_at')
|
||||
->label(__('hr.fields.email_verified_at'))
|
||||
->dateTime()
|
||||
->sortable(),
|
||||
TextColumn::make('created_at')
|
||||
->label(__('hr.fields.created_at'))
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('updated_at')
|
||||
->label(__('hr.fields.updated_at'))
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('department.name')
|
||||
->label(__('hr.fields.department'))
|
||||
->searchable(),
|
||||
])
|
||||
->filters([
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Resources\Vacations\Pages;
|
||||
|
||||
use App\Filament\Resources\Vacations\VacationResource;
|
||||
use BokshornIt\FilamentActivityTimeline\Actions\ActivityTimelineAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
@@ -13,6 +14,7 @@ class ViewVacation extends ViewRecord
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
ActivityTimelineAction::make(),
|
||||
EditAction::make(),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -17,15 +17,20 @@ public static function configure(Schema $schema): Schema
|
||||
->components([
|
||||
HrForm::employeeSelect(),
|
||||
Select::make('type')
|
||||
->label(__('hr.fields.type'))
|
||||
->options(VacationType::class)
|
||||
->required()
|
||||
->native(false),
|
||||
HrForm::leaveDatePicker('start_date', __(hr.fields.start_date)),
|
||||
HrForm::leaveDatePicker('end_date', __(hr.fields.end_date)),
|
||||
HrForm::leaveDatePicker('start_date', __('hr.fields.start_date'))
|
||||
->native(false),
|
||||
HrForm::leaveDatePicker('end_date', __('hr.fields.end_date'))
|
||||
->native(false),
|
||||
DatePicker::make('return_date')
|
||||
->label(__('hr.fields.return_date')),
|
||||
->label(__('hr.fields.return_date'))
|
||||
->native(false),
|
||||
HrForm::leaveDaysDisplay(),
|
||||
Textarea::make('reason')
|
||||
->label(__('hr.fields.reason'))
|
||||
->rows(3)
|
||||
->columnSpanFull(),
|
||||
HrForm::fileUpload('attachment_path')
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Filament\Resources\Vacations\Schemas;
|
||||
|
||||
use App\Enums\ApprovalStatus;
|
||||
use App\Enums\VacationType;
|
||||
use App\Models\Vacation;
|
||||
use Filament\Infolists\Components\ImageEntry;
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class VacationInfolist
|
||||
@@ -12,41 +18,73 @@ public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextEntry::make('employee.id')
|
||||
->label(__('hr.fields.employee')),
|
||||
TextEntry::make('type')
|
||||
->badge(),
|
||||
TextEntry::make('start_date')
|
||||
->date(),
|
||||
TextEntry::make('end_date')
|
||||
->date(),
|
||||
TextEntry::make('return_date')
|
||||
->date()
|
||||
->placeholder('-'),
|
||||
TextEntry::make('days')
|
||||
->numeric(),
|
||||
TextEntry::make('status')
|
||||
->badge(),
|
||||
TextEntry::make('reason')
|
||||
->placeholder('-')
|
||||
->columnSpanFull(),
|
||||
TextEntry::make('attachment_path')
|
||||
->placeholder('-'),
|
||||
TextEntry::make('approved_by')
|
||||
->numeric()
|
||||
->placeholder('-'),
|
||||
TextEntry::make('approved_at')
|
||||
->dateTime()
|
||||
->placeholder('-'),
|
||||
TextEntry::make('created_at')
|
||||
->dateTime()
|
||||
->placeholder('-'),
|
||||
TextEntry::make('updated_at')
|
||||
->dateTime()
|
||||
->placeholder('-'),
|
||||
TextEntry::make('deleted_at')
|
||||
->dateTime()
|
||||
->visible(fn (Vacation $record): bool => $record->trashed()),
|
||||
Section::make(__('hr.sections.basic_info'))
|
||||
->schema([
|
||||
TextEntry::make('employee.full_name')
|
||||
->label(__('hr.fields.employee')),
|
||||
TextEntry::make('type')
|
||||
->label(__('hr.fields.type'))
|
||||
->badge()
|
||||
->color(fn (VacationType $state): string => $state->color())
|
||||
->formatStateUsing(fn (VacationType $state): string => $state->label()),
|
||||
TextEntry::make('status')
|
||||
->label(__('hr.fields.status'))
|
||||
->badge()
|
||||
->color(fn (ApprovalStatus $state): string => $state->color())
|
||||
->formatStateUsing(fn (ApprovalStatus $state): string => $state->label()),
|
||||
])
|
||||
->columns(3),
|
||||
Section::make(__('hr.sections.dates'))
|
||||
->schema([
|
||||
TextEntry::make('start_date')
|
||||
->label(__('hr.fields.start_date'))
|
||||
->date('d.m.Y'),
|
||||
TextEntry::make('end_date')
|
||||
->label(__('hr.fields.end_date'))
|
||||
->date('d.m.Y'),
|
||||
TextEntry::make('return_date')
|
||||
->label(__('hr.fields.return_date'))
|
||||
->date('d.m.Y')
|
||||
->placeholder('—'),
|
||||
TextEntry::make('days')
|
||||
->label(__('hr.fields.days'))
|
||||
->suffix(' '.__('hr.messages.days_suffix')),
|
||||
])
|
||||
->columns(2),
|
||||
Section::make(__('hr.sections.approval'))
|
||||
->schema([
|
||||
TextEntry::make('reason')
|
||||
->label(__('hr.fields.reason'))
|
||||
->placeholder('—')
|
||||
->columnSpanFull(),
|
||||
TextEntry::make('attachment_path')
|
||||
->label(__('hr.fields.attachment'))
|
||||
->formatStateUsing(fn (?string $state): string => filled($state) ? basename($state) : '—'),
|
||||
TextEntry::make('approved_by')
|
||||
->label(__('hr.fields.approved_by'))
|
||||
->formatStateUsing(fn ($state, Vacation $record): string => $record->approver?->name ?? '—'),
|
||||
])
|
||||
->columns(2),
|
||||
Section::make(__('hr.sections.metadata'))
|
||||
->schema([
|
||||
TextEntry::make('approved_at')
|
||||
->label(__('hr.fields.approved_at'))
|
||||
->dateTime('d.m.Y H:i')
|
||||
->placeholder('—'),
|
||||
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 (Vacation $record): bool => $record->trashed()),
|
||||
])
|
||||
->columns(2),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -34,21 +34,26 @@ public static function configure(Table $table): Table
|
||||
->searchable()
|
||||
->sortable(),
|
||||
TextColumn::make('type')
|
||||
->label(__('hr.fields.type'))
|
||||
->badge()
|
||||
->color(fn (VacationType $state): string => $state->color())
|
||||
->formatStateUsing(fn (VacationType $state): string => $state->label())
|
||||
->searchable()
|
||||
->sortable(),
|
||||
TextColumn::make('start_date')
|
||||
->label(__('hr.fields.start_date'))
|
||||
->date()
|
||||
->sortable(),
|
||||
TextColumn::make('end_date')
|
||||
->label(__('hr.fields.end_date'))
|
||||
->date()
|
||||
->sortable(),
|
||||
TextColumn::make('days')
|
||||
->label(__('hr.fields.days'))
|
||||
->numeric()
|
||||
->sortable(),
|
||||
TextColumn::make('status')
|
||||
->label(__('hr.fields.status'))
|
||||
->badge()
|
||||
->color(fn (ApprovalStatus $state): string => $state->color())
|
||||
->formatStateUsing(fn (ApprovalStatus $state): string => $state->label())
|
||||
@@ -58,26 +63,32 @@ public static function configure(Table $table): Table
|
||||
->label(__('hr.fields.approved_by'))
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('approved_at')
|
||||
->label(__('hr.fields.approved_at'))
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('created_at')
|
||||
->label(__('hr.fields.created_at'))
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('updated_at')
|
||||
->label(__('hr.fields.updated_at'))
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('deleted_at')
|
||||
->label(__('hr.fields.deleted_at'))
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
SelectFilter::make('status')
|
||||
->label(__('hr.fields.status'))
|
||||
->options(ApprovalStatus::class),
|
||||
SelectFilter::make('type')
|
||||
->label(__('hr.fields.type'))
|
||||
->options(VacationType::class),
|
||||
Filter::make('date_range')
|
||||
->label(__('hr.fields.date_range'))
|
||||
|
||||
@@ -26,6 +26,7 @@ public static function fileUpload(string $name): FileUpload
|
||||
public static function employeeSelect(): Select
|
||||
{
|
||||
return Select::make('employee_id')
|
||||
->label(__('hr.fields.employee'))
|
||||
->relationship('employee', 'full_name')
|
||||
->searchable()
|
||||
->preload()
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class SetLocale
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param Closure(Request): (Response) $next
|
||||
*/
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
if (! $request->user()) {
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
$locale = $request->user()->locale;
|
||||
|
||||
if (isset($locale)) {
|
||||
app()->setLocale($locale);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
@@ -6,12 +6,13 @@
|
||||
|
||||
use App\Enums\BonusType;
|
||||
use App\Models\Concerns\LogsHrActivity;
|
||||
use BokshornIt\FilamentActivityTimeline\Contracts\ProvidesActivityTitle;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Bonus extends Model
|
||||
class Bonus extends Model implements ProvidesActivityTitle
|
||||
{
|
||||
use HasFactory;
|
||||
use LogsHrActivity;
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
namespace App\Models\Concerns;
|
||||
|
||||
use BokshornIt\FilamentActivityTimeline\Contracts\ProvidesActivityTitle;
|
||||
use Spatie\Activitylog\LogOptions;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
|
||||
@@ -18,4 +19,29 @@ public function getActivitylogOptions(): LogOptions
|
||||
->logOnlyDirty()
|
||||
->dontSubmitEmptyLogs();
|
||||
}
|
||||
|
||||
public function activityTitle(): ?string
|
||||
{
|
||||
foreach (['full_name', 'name', 'title', 'gift_name', 'employee_number'] as $attribute) {
|
||||
$value = $this->getAttribute($attribute);
|
||||
|
||||
if (filled($value)) {
|
||||
return (string) $value;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->getAttribute('employee_id')) {
|
||||
$employeeName = $this->relationLoaded('employee')
|
||||
? $this->employee?->full_name
|
||||
: $this->employee()->value('full_name');
|
||||
|
||||
if (filled($employeeName)) {
|
||||
return (string) $employeeName;
|
||||
}
|
||||
}
|
||||
|
||||
$key = $this->getKey();
|
||||
|
||||
return $key !== null ? '#'.$key : null;
|
||||
}
|
||||
}
|
||||
@@ -5,13 +5,14 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Concerns\LogsHrActivity;
|
||||
use BokshornIt\FilamentActivityTimeline\Contracts\ProvidesActivityTitle;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class Department extends Model
|
||||
class Department extends Model implements ProvidesActivityTitle
|
||||
{
|
||||
use HasFactory;
|
||||
use LogsHrActivity;
|
||||
|
||||
@@ -6,12 +6,13 @@
|
||||
|
||||
use App\Enums\DisciplinarySeverity;
|
||||
use App\Models\Concerns\LogsHrActivity;
|
||||
use BokshornIt\FilamentActivityTimeline\Contracts\ProvidesActivityTitle;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class DisciplinaryReport extends Model
|
||||
class DisciplinaryReport extends Model implements ProvidesActivityTitle
|
||||
{
|
||||
use HasFactory;
|
||||
use LogsHrActivity;
|
||||
|
||||
+34
-1
@@ -7,13 +7,14 @@
|
||||
use App\Enums\EmploymentStatus;
|
||||
use App\Enums\Gender;
|
||||
use App\Models\Concerns\LogsHrActivity;
|
||||
use BokshornIt\FilamentActivityTimeline\Contracts\ProvidesActivityTitle;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Employee extends Model
|
||||
class Employee extends Model implements ProvidesActivityTitle
|
||||
{
|
||||
use HasFactory;
|
||||
use LogsHrActivity;
|
||||
@@ -48,6 +49,38 @@ protected function casts(): array
|
||||
];
|
||||
}
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::saving(function (Employee $employee): void {
|
||||
if (blank($employee->employee_number)) {
|
||||
$employee->employee_number = static::generateUniqueEmployeeNumber();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static function generateUniqueEmployeeNumber(): string
|
||||
{
|
||||
$prefix = (string) config('hr.employee_number.prefix', 'EMP-');
|
||||
$padding = (int) config('hr.employee_number.padding', 5);
|
||||
|
||||
$latestNumber = static::withTrashed()
|
||||
->where('employee_number', 'like', $prefix.'%')
|
||||
->pluck('employee_number')
|
||||
->map(function (string $number) use ($prefix): ?int {
|
||||
if (! preg_match('/^'.preg_quote($prefix, '/').'(\d+)$/', $number, $matches)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (int) $matches[1];
|
||||
})
|
||||
->filter()
|
||||
->max();
|
||||
|
||||
$next = ($latestNumber ?? 0) + 1;
|
||||
|
||||
return $prefix.str_pad((string) $next, $padding, '0', STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
public function department(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Department::class);
|
||||
|
||||
@@ -6,12 +6,13 @@
|
||||
|
||||
use App\Enums\DocumentType;
|
||||
use App\Models\Concerns\LogsHrActivity;
|
||||
use BokshornIt\FilamentActivityTimeline\Contracts\ProvidesActivityTitle;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class EmployeeDocument extends Model
|
||||
class EmployeeDocument extends Model implements ProvidesActivityTitle
|
||||
{
|
||||
use HasFactory;
|
||||
use LogsHrActivity;
|
||||
|
||||
@@ -5,12 +5,13 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Concerns\LogsHrActivity;
|
||||
use BokshornIt\FilamentActivityTimeline\Contracts\ProvidesActivityTitle;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Explanation extends Model
|
||||
class Explanation extends Model implements ProvidesActivityTitle
|
||||
{
|
||||
use HasFactory;
|
||||
use LogsHrActivity;
|
||||
|
||||
+2
-1
@@ -5,12 +5,13 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Concerns\LogsHrActivity;
|
||||
use BokshornIt\FilamentActivityTimeline\Contracts\ProvidesActivityTitle;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Gift extends Model
|
||||
class Gift extends Model implements ProvidesActivityTitle
|
||||
{
|
||||
use HasFactory;
|
||||
use LogsHrActivity;
|
||||
|
||||
@@ -5,12 +5,13 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Concerns\LogsHrActivity;
|
||||
use BokshornIt\FilamentActivityTimeline\Contracts\ProvidesActivityTitle;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Position extends Model
|
||||
class Position extends Model implements ProvidesActivityTitle
|
||||
{
|
||||
use HasFactory;
|
||||
use LogsHrActivity;
|
||||
|
||||
+35
-1
@@ -5,12 +5,14 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Concerns\LogsHrActivity;
|
||||
use BokshornIt\FilamentActivityTimeline\Contracts\ProvidesActivityTitle;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class Shift extends Model
|
||||
class Shift extends Model implements ProvidesActivityTitle
|
||||
{
|
||||
use HasFactory;
|
||||
use LogsHrActivity;
|
||||
@@ -34,6 +36,38 @@ protected function casts(): array
|
||||
];
|
||||
}
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::saving(function (Shift $shift): void {
|
||||
if (blank($shift->code) && filled($shift->name)) {
|
||||
$shift->code = static::generateUniqueCodeFromName(
|
||||
$shift->name,
|
||||
$shift->id,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static function generateUniqueCodeFromName(string $name, ?int $ignoreId = null): string
|
||||
{
|
||||
$base = Str::upper(Str::slug($name));
|
||||
|
||||
$query = static::query()
|
||||
->when($ignoreId, fn ($query) => $query->where('id', '!=', $ignoreId));
|
||||
|
||||
if (! $query->clone()->where('code', $base)->exists()) {
|
||||
return $base;
|
||||
}
|
||||
|
||||
$maxSuffix = $query->clone()
|
||||
->where('code', 'like', "{$base}-%")
|
||||
->pluck('code')
|
||||
->map(fn (string $code): int => (int) Str::after($code, "{$base}-"))
|
||||
->max();
|
||||
|
||||
return "{$base}-".(($maxSuffix ?? 0) + 1);
|
||||
}
|
||||
|
||||
public function employees(): HasMany
|
||||
{
|
||||
return $this->hasMany(Employee::class);
|
||||
|
||||
@@ -5,12 +5,13 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Concerns\LogsHrActivity;
|
||||
use BokshornIt\FilamentActivityTimeline\Contracts\ProvidesActivityTitle;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class SickLeave extends Model
|
||||
class SickLeave extends Model implements ProvidesActivityTitle
|
||||
{
|
||||
use HasFactory;
|
||||
use LogsHrActivity;
|
||||
|
||||
@@ -6,12 +6,13 @@
|
||||
|
||||
use App\Enums\ApprovalStatus;
|
||||
use App\Models\Concerns\LogsHrActivity;
|
||||
use BokshornIt\FilamentActivityTimeline\Contracts\ProvidesActivityTitle;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class UnpaidLeave extends Model
|
||||
class UnpaidLeave extends Model implements ProvidesActivityTitle
|
||||
{
|
||||
use HasFactory;
|
||||
use LogsHrActivity;
|
||||
|
||||
@@ -7,12 +7,13 @@
|
||||
use App\Enums\ApprovalStatus;
|
||||
use App\Enums\VacationType;
|
||||
use App\Models\Concerns\LogsHrActivity;
|
||||
use BokshornIt\FilamentActivityTimeline\Contracts\ProvidesActivityTitle;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Vacation extends Model
|
||||
class Vacation extends Model implements ProvidesActivityTitle
|
||||
{
|
||||
use HasFactory;
|
||||
use LogsHrActivity;
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
use Illuminate\Foundation\Auth\User as AuthUser;
|
||||
use Spatie\Activitylog\Models\Activity;
|
||||
|
||||
class ActivityPolicy
|
||||
{
|
||||
use HandlesAuthorization;
|
||||
|
||||
public function viewAny(AuthUser $user): bool
|
||||
{
|
||||
if ($this->canAccessAuditLog($user)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return $user->can('ViewAny:Activity');
|
||||
}
|
||||
|
||||
public function view(AuthUser $user, Activity $activity): bool
|
||||
{
|
||||
if ($this->canAccessAuditLog($user)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return $user->can('View:Activity');
|
||||
}
|
||||
|
||||
public function create(AuthUser $user): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function update(AuthUser $user, Activity $activity): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function delete(AuthUser $user, Activity $activity): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function deleteAny(AuthUser $user): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function forceDelete(AuthUser $user, Activity $activity): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function forceDeleteAny(AuthUser $user): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function restore(AuthUser $user, Activity $activity): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function restoreAny(AuthUser $user): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function replicate(AuthUser $user, Activity $activity): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function reorder(AuthUser $user): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function canAccessAuditLog(AuthUser $user): bool
|
||||
{
|
||||
if (! $user instanceof User) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $user->hasRole(['super_admin', 'administrator', 'hr_manager']);
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,7 @@
|
||||
use App\Observers\SickLeaveObserver;
|
||||
use App\Observers\UnpaidLeaveObserver;
|
||||
use App\Observers\VacationObserver;
|
||||
use App\Policies\ActivityPolicy;
|
||||
use App\Policies\BonusPolicy;
|
||||
use App\Policies\DepartmentPolicy;
|
||||
use App\Policies\DisciplinaryReportPolicy;
|
||||
@@ -37,10 +38,10 @@
|
||||
use App\Policies\VacationPolicy;
|
||||
use BezhanSalleh\LanguageSwitch\Events\LocaleChanged;
|
||||
use BezhanSalleh\LanguageSwitch\LanguageSwitch;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Spatie\Activitylog\Models\Activity;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
@@ -70,6 +71,7 @@ public function boot(): void
|
||||
Gate::policy(Gift::class, GiftPolicy::class);
|
||||
Gate::policy(EmployeeDocument::class, EmployeeDocumentPolicy::class);
|
||||
Gate::policy(User::class, UserPolicy::class);
|
||||
Gate::policy(Activity::class, ActivityPolicy::class);
|
||||
|
||||
Vacation::observe(VacationObserver::class);
|
||||
SickLeave::observe(SickLeaveObserver::class);
|
||||
|
||||
@@ -4,13 +4,18 @@
|
||||
|
||||
namespace App\Providers\Filament;
|
||||
|
||||
use BezhanSalleh\FilamentShield\FilamentShieldPlugin;
|
||||
use App\Enums\NavigationGroup;
|
||||
use App\Enums\NavigationGroup as NavigationGroupEnum;
|
||||
use App\Filament\ActivityTimeline\AuditLogResource;
|
||||
use App\Filament\Pages\Dashboard;
|
||||
use App\Models\User;
|
||||
use BezhanSalleh\FilamentShield\FilamentShieldPlugin;
|
||||
use BokshornIt\FilamentActivityTimeline\ActivityTimelinePlugin;
|
||||
use Filament\FontProviders\GoogleFontProvider;
|
||||
use Filament\Http\Middleware\Authenticate;
|
||||
use Filament\Http\Middleware\AuthenticateSession;
|
||||
use Filament\Http\Middleware\DisableBladeIconComponents;
|
||||
use Filament\Http\Middleware\DispatchServingFilamentEvent;
|
||||
use Filament\Navigation\NavigationGroup as FilamentNavigationGroup;
|
||||
use Filament\Panel;
|
||||
use Filament\PanelProvider;
|
||||
use Filament\Support\Colors\Color;
|
||||
@@ -20,7 +25,6 @@
|
||||
use Illuminate\Routing\Middleware\SubstituteBindings;
|
||||
use Illuminate\Session\Middleware\StartSession;
|
||||
use Illuminate\View\Middleware\ShareErrorsFromSession;
|
||||
use Filament\FontProviders\GoogleFontProvider;
|
||||
|
||||
class AdminPanelProvider extends PanelProvider
|
||||
{
|
||||
@@ -39,7 +43,14 @@ public function panel(Panel $panel): Panel
|
||||
'gray' => Color::Slate,
|
||||
])
|
||||
->font('Inter', provider: GoogleFontProvider::class)
|
||||
->navigationGroups(NavigationGroup::class)
|
||||
->navigationGroups(
|
||||
collect(NavigationGroupEnum::cases())
|
||||
->mapWithKeys(fn (NavigationGroupEnum $case): array => [
|
||||
$case->name => FilamentNavigationGroup::make()
|
||||
->label(fn (): ?string => $case->getLabel()),
|
||||
])
|
||||
->all(),
|
||||
)
|
||||
->discoverResources(in: app_path('Filament/Resources'), for: 'App\Filament\Resources')
|
||||
->discoverPages(in: app_path('Filament/Pages'), for: 'App\Filament\Pages')
|
||||
->pages([
|
||||
@@ -49,7 +60,17 @@ public function panel(Panel $panel): Panel
|
||||
->widgets([])
|
||||
->plugins([
|
||||
FilamentShieldPlugin::make()
|
||||
->navigationGroup(NavigationGroup::System),
|
||||
->navigationGroup(NavigationGroupEnum::System),
|
||||
ActivityTimelinePlugin::make()
|
||||
->resource(AuditLogResource::class)
|
||||
->navigationIcon('heroicon-o-clipboard-document-list')
|
||||
->navigationSort(3)
|
||||
->causerIcons([
|
||||
User::class => 'heroicon-m-user',
|
||||
])
|
||||
->systemCauserIcon('heroicon-m-cog-6-tooth')
|
||||
->subjectLabelNamespace('hr.audit')
|
||||
->fieldLabelNamespace('changes'),
|
||||
])
|
||||
->middleware([
|
||||
EncryptCookies::class,
|
||||
|
||||
@@ -6,8 +6,10 @@
|
||||
|
||||
use App\DTOs\EmployeeSummaryDto;
|
||||
use App\Enums\ApprovalStatus;
|
||||
use App\Enums\VacationType;
|
||||
use App\Models\Employee;
|
||||
use App\Services\Vacation\VacationBalanceService;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class EmployeeStatisticsService
|
||||
{
|
||||
@@ -15,6 +17,25 @@ public function __construct(
|
||||
private readonly VacationBalanceService $vacationBalanceService,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @param Builder<Employee> $query
|
||||
* @return Builder<Employee>
|
||||
*/
|
||||
public function applyTableAggregates(Builder $query, ?int $year = null): Builder
|
||||
{
|
||||
$year ??= (int) now()->year;
|
||||
|
||||
return $query
|
||||
->with(['department', 'position'])
|
||||
->withCount(['sickLeaves', 'unpaidLeaves', 'disciplinaryReports', 'explanations', 'gifts'])
|
||||
->withSum('bonuses', 'amount')
|
||||
->withSum(['vacations as annual_vacation_days_taken' => fn (Builder $vacationQuery): Builder => $vacationQuery
|
||||
->where('type', VacationType::Annual)
|
||||
->where('status', ApprovalStatus::Approved)
|
||||
->whereYear('start_date', $year),
|
||||
], 'days');
|
||||
}
|
||||
|
||||
public function summary(Employee $employee): EmployeeSummaryDto
|
||||
{
|
||||
return new EmployeeSummaryDto(
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
use App\Models\Employee;
|
||||
use App\Models\Position;
|
||||
use App\Models\Shift;
|
||||
use App\Support\Countries;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
@@ -22,9 +23,9 @@ class EmployeeImportTransformer
|
||||
public function toAttributes(EmployeeRowDto $dto): array
|
||||
{
|
||||
return [
|
||||
'employee_number' => $dto->employeeNumber,
|
||||
'employee_number' => $dto->employeeNumber !== '' ? $dto->employeeNumber : null,
|
||||
'full_name' => $dto->fullName,
|
||||
'national_id' => $dto->nationalId,
|
||||
'national_id' => $this->resolveNationality($dto->nationalId),
|
||||
'gender' => $this->resolveGender($dto->gender),
|
||||
'birth_date' => $this->parseDate($dto->birthDate),
|
||||
'phone' => $dto->phone ?? config('hr.default_phone'),
|
||||
@@ -45,10 +46,6 @@ public function validate(EmployeeRowDto $dto): array
|
||||
{
|
||||
$errors = [];
|
||||
|
||||
if ($dto->employeeNumber === '') {
|
||||
$errors[] = 'Employee number is required.';
|
||||
}
|
||||
|
||||
if ($dto->fullName === '') {
|
||||
$errors[] = 'Full name is required.';
|
||||
}
|
||||
@@ -65,22 +62,42 @@ public function validate(EmployeeRowDto $dto): array
|
||||
$errors[] = "Shift \"{$dto->shift}\" was not found.";
|
||||
}
|
||||
|
||||
if ($dto->nationalId && $this->resolveNationality($dto->nationalId) === null) {
|
||||
$errors[] = "Nationality \"{$dto->nationalId}\" was not found.";
|
||||
}
|
||||
|
||||
return $errors;
|
||||
}
|
||||
|
||||
public function isDuplicate(EmployeeRowDto $dto): bool
|
||||
{
|
||||
return Employee::query()
|
||||
->where(function ($query) use ($dto): void {
|
||||
$query->where('employee_number', $dto->employeeNumber);
|
||||
$hasEmployeeNumber = $dto->employeeNumber !== '';
|
||||
$nationality = $this->resolveNationality($dto->nationalId);
|
||||
|
||||
if ($dto->nationalId) {
|
||||
$query->orWhere('national_id', $dto->nationalId);
|
||||
if (! $hasEmployeeNumber && $nationality === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return Employee::query()
|
||||
->where(function ($query) use ($dto, $hasEmployeeNumber, $nationality): void {
|
||||
if ($hasEmployeeNumber) {
|
||||
$query->where('employee_number', $dto->employeeNumber);
|
||||
}
|
||||
|
||||
if ($nationality !== null) {
|
||||
$hasEmployeeNumber
|
||||
? $query->orWhere('national_id', $nationality)
|
||||
: $query->where('national_id', $nationality);
|
||||
}
|
||||
})
|
||||
->exists();
|
||||
}
|
||||
|
||||
private function resolveNationality(?string $value): ?string
|
||||
{
|
||||
return Countries::resolve($value);
|
||||
}
|
||||
|
||||
private function resolveGender(?string $value): ?Gender
|
||||
{
|
||||
if ($value === null) {
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Support;
|
||||
|
||||
class Countries
|
||||
{
|
||||
public const DEFAULT = 'TM';
|
||||
|
||||
/**
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public static function codes(): array
|
||||
{
|
||||
/** @var array{codes: array<int, string>} $config */
|
||||
$config = config('countries');
|
||||
|
||||
return $config['codes'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function options(?string $locale = null): array
|
||||
{
|
||||
$locale ??= app()->getLocale();
|
||||
$options = [];
|
||||
|
||||
foreach (self::codes() as $code) {
|
||||
$name = self::name($code, $locale);
|
||||
|
||||
if ($name !== null) {
|
||||
$options[$code] = $name;
|
||||
}
|
||||
}
|
||||
|
||||
uasort($options, fn (string $a, string $b): int => strcasecmp($a, $b));
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
public static function name(?string $code, ?string $locale = null): ?string
|
||||
{
|
||||
if ($code === null || $code === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
$code = strtoupper($code);
|
||||
$locale ??= app()->getLocale();
|
||||
|
||||
$name = self::translation($code, $locale);
|
||||
|
||||
if ($name === null && $locale !== 'en') {
|
||||
$name = self::translation($code, 'en');
|
||||
}
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
public static function isValid(?string $code): bool
|
||||
{
|
||||
if ($code === null || $code === '') {
|
||||
return false;
|
||||
}
|
||||
|
||||
return in_array(strtoupper($code), self::codes(), true);
|
||||
}
|
||||
|
||||
public static function resolve(?string $value, ?string $locale = null): ?string
|
||||
{
|
||||
if ($value === null || trim($value) === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
$value = trim($value);
|
||||
$upper = strtoupper($value);
|
||||
|
||||
if (self::isValid($upper)) {
|
||||
return $upper;
|
||||
}
|
||||
|
||||
$locale ??= app()->getLocale();
|
||||
|
||||
foreach (self::codes() as $code) {
|
||||
$name = self::name($code, $locale);
|
||||
|
||||
if ($name !== null && strcasecmp($name, $value) === 0) {
|
||||
return $code;
|
||||
}
|
||||
}
|
||||
|
||||
if ($locale !== 'en') {
|
||||
foreach (self::codes() as $code) {
|
||||
$name = self::name($code, 'en');
|
||||
|
||||
if ($name !== null && strcasecmp($name, $value) === 0) {
|
||||
return $code;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static function translation(string $code, string $locale): ?string
|
||||
{
|
||||
$path = lang_path("{$locale}/countries.php");
|
||||
|
||||
if (! is_file($path)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/** @var array<string, string> $names */
|
||||
$names = require $path;
|
||||
|
||||
return $names[$code] ?? null;
|
||||
}
|
||||
|
||||
public static function default(): string
|
||||
{
|
||||
return self::DEFAULT;
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -4,6 +4,7 @@
|
||||
use Illuminate\Foundation\Configuration\Exceptions;
|
||||
use Illuminate\Foundation\Configuration\Middleware;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Middleware\SetLocale;
|
||||
|
||||
return Application::configure(basePath: dirname(__DIR__))
|
||||
->withRouting(
|
||||
@@ -12,7 +13,7 @@
|
||||
health: '/up',
|
||||
)
|
||||
->withMiddleware(function (Middleware $middleware): void {
|
||||
//
|
||||
// $middleware->web(SetLocale::class);
|
||||
})
|
||||
->withExceptions(function (Exceptions $exceptions): void {
|
||||
$exceptions->shouldRenderJsonWhen(
|
||||
|
||||
Loaded 100 of 124 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user