diff --git a/app/Filament/Pages/Dashboard.php b/app/Filament/Pages/Dashboard.php index c4790e8..55fffb2 100644 --- a/app/Filament/Pages/Dashboard.php +++ b/app/Filament/Pages/Dashboard.php @@ -2,6 +2,7 @@ namespace App\Filament\Pages; +use App\Filament\Widgets\Charts\BudgetRealizationChart; use App\Filament\Widgets\Charts\CooperationStatusChart; use App\Filament\Widgets\Stats\OverviewStats; use BezhanSalleh\FilamentShield\Traits\HasPageShield; @@ -24,6 +25,7 @@ public function getWidgets(): array { return [ OverviewStats::class, + BudgetRealizationChart::class, CooperationStatusChart::class, ]; } diff --git a/app/Filament/Widgets/Stats/OverviewStats.php b/app/Filament/Widgets/Stats/OverviewStats.php index cc801a1..0818300 100644 --- a/app/Filament/Widgets/Stats/OverviewStats.php +++ b/app/Filament/Widgets/Stats/OverviewStats.php @@ -38,6 +38,10 @@ protected function getStats(): array return $this->getCompanyStats($user); } + if ($user && $user->hasRole(RoleEnum::ADMIN_KEUANGAN->value)) { + return $this->getFinanceStats(); + } + $totalJournalists = Journalist::count(); $totalMedia = PartnerMedia::count(); $average = $totalMedia > 0 ? round($totalJournalists / $totalMedia, 1) : 0; @@ -168,4 +172,29 @@ private function getCompanyStats($user): array ->color($this->getRandomColor()), ]; } + + private function getFinanceStats(): array + { + return [ + Stat::make('Total Anggaran', 'Rp '.number_format(CooperationPayment::sum('amount'), 0, ',', '.')) + ->description('Total Nilai Kerjasama') + ->descriptionIcon('heroicon-o-banknotes') + ->color('success'), + + Stat::make('Realisasi Pembayaran', CooperationPayment::accepted()->count()) + ->description('Pembayaran Selesai') + ->descriptionIcon('heroicon-o-check-circle') + ->color('success'), + + Stat::make('Menunggu Pembayaran', CooperationPayment::pending()->count()) + ->description('Menunggu Tindakan') + ->descriptionIcon('heroicon-o-clock') + ->color('warning'), + + Stat::make('Pembayaran Ditolak', CooperationPayment::rejected()->count()) + ->description('Perlu Perhatian') + ->descriptionIcon('heroicon-o-x-circle') + ->color('danger'), + ]; + } } diff --git a/database/seeders/ShieldSeeder.php b/database/seeders/ShieldSeeder.php index dd684cd..00dc81d 100644 --- a/database/seeders/ShieldSeeder.php +++ b/database/seeders/ShieldSeeder.php @@ -680,12 +680,12 @@ public function run(): void "name": "Admin Keuangan", "guard_name": "web", "permissions": [ - "View:Analytic", - "ViewAny:Cooperation", "View:Cooperation", - "View:Dashboard" + "View:Dashboard", + + "View:OverviewStats" ] }, {