add new ststs feature
This commit is contained in:
@@ -2,17 +2,44 @@
|
||||
|
||||
namespace App\Controllers\View;
|
||||
|
||||
use App\Models\StatsModel;
|
||||
use App\Controllers\BaseController;
|
||||
use App\Services\AcademicStatisticsService;
|
||||
|
||||
class StatsController extends BaseController
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$model = new StatsModel();
|
||||
$data['stats'] = $model->getStats();
|
||||
$schoolYear = $this->currentSchoolYearName();
|
||||
$statistics = (new AcademicStatisticsService())->forSchoolYear($schoolYear);
|
||||
|
||||
return view('stats_view', $data);
|
||||
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()
|
||||
|
||||
Reference in New Issue
Block a user