60 lines
1.5 KiB
PHP
60 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Controllers\View;
|
|
|
|
use App\Controllers\BaseController;
|
|
use App\Services\AcademicStatisticsService;
|
|
|
|
class StatsController extends BaseController
|
|
{
|
|
public function index()
|
|
{
|
|
$schoolYear = $this->currentSchoolYearName();
|
|
$statistics = (new AcademicStatisticsService())->forSchoolYear($schoolYear);
|
|
|
|
return view('administrator/stats', [
|
|
'schoolYear' => $schoolYear,
|
|
'statistics' => $statistics,
|
|
'canViewFinancialStats' => $this->canViewFinancialStats(),
|
|
]);
|
|
}
|
|
|
|
private function canViewFinancialStats(): bool
|
|
{
|
|
$roles = array_map(
|
|
static fn ($role): string => strtolower(trim((string) $role)),
|
|
array_filter(array_merge((array) session()->get('roles'), [session()->get('role')]))
|
|
);
|
|
|
|
if ((bool) array_intersect(array_unique($roles), [
|
|
'admin',
|
|
'administrator',
|
|
'administrative staff',
|
|
'principal',
|
|
])) {
|
|
return true;
|
|
}
|
|
|
|
helper('auth');
|
|
$userId = (int) (session()->get('user_id') ?? 0);
|
|
|
|
return $userId > 0 && function_exists('has_permission')
|
|
&& has_permission($userId, 'view_financial_reports');
|
|
}
|
|
|
|
public function calendar()
|
|
{
|
|
return view('/calendars');
|
|
}
|
|
|
|
public function support()
|
|
{
|
|
return view('/support');
|
|
}
|
|
|
|
public function contactUs()
|
|
{
|
|
return view('/contact_us');
|
|
}
|
|
}
|