48 lines
1.7 KiB
PHP
48 lines
1.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Filament\Resources\Employees\Widgets;
|
|
|
|
use App\Models\Employee;
|
|
use App\Services\Employee\EmployeeStatisticsService;
|
|
use Filament\Widgets\StatsOverviewWidget;
|
|
use Filament\Widgets\StatsOverviewWidget\Stat;
|
|
|
|
class EmployeeStatsWidget extends StatsOverviewWidget
|
|
{
|
|
public ?Employee $record = null;
|
|
|
|
protected function getStats(): array
|
|
{
|
|
if (! $this->record instanceof Employee) {
|
|
return [];
|
|
}
|
|
|
|
$summary = app(EmployeeStatisticsService::class)->summary($this->record);
|
|
|
|
return [
|
|
Stat::make('Vacation Taken', (string) $summary->vacationTaken)
|
|
->description("{$summary->vacationRemaining} days remaining")
|
|
->descriptionIcon('heroicon-o-calendar')
|
|
->color('primary')
|
|
->icon('heroicon-o-sun'),
|
|
Stat::make('Sick Leaves', (string) $summary->sickLeaveCount)
|
|
->description('Total records')
|
|
->descriptionIcon('heroicon-o-heart')
|
|
->color('warning')
|
|
->icon('heroicon-o-heart'),
|
|
Stat::make('Disciplinary Reports', (string) $summary->reportsCount)
|
|
->description('On file')
|
|
->descriptionIcon('heroicon-o-exclamation-triangle')
|
|
->color('danger')
|
|
->icon('heroicon-o-exclamation-triangle'),
|
|
Stat::make('Total Bonuses', number_format($summary->bonusesTotal, 2).' TMT')
|
|
->description("{$summary->giftsCount} gifts received")
|
|
->descriptionIcon('heroicon-o-gift')
|
|
->color('success')
|
|
->icon('heroicon-o-banknotes'),
|
|
];
|
|
}
|
|
}
|