<?php

namespace App\Controllers;

class DashboardController
{
    public function admin()
    {
        if (!isset($_SESSION['user']) || $_SESSION['user']['level'] !== 'Admin') {
            header('Location: /');
            exit;
        }

        require_once __DIR__ . '/../Views/dashboard/admin.php';
    }

    public function pegawai()
    {
        if (!isset($_SESSION['user']) || $_SESSION['user']['level'] !== 'Pegawai') {
            header('Location: /');
            exit;
        }

        require_once __DIR__ . '/../Views/dashboard/pegawai.php';
    }

    public function staff()
    {
        if (!isset($_SESSION['user']) || $_SESSION['user']['level'] !== 'Staff') {
            header('Location: /');
            exit;
        }

        require_once __DIR__ . '/../Views/dashboard/staff.php';
    }

    public function pimpinan()
    {
        if (!isset($_SESSION['user']) || $_SESSION['user']['level'] !== 'Pimpinan') {
            header('Location: /');
            exit;
        }

        require_once __DIR__ . '/../Views/dashboard/pimpinan.php';
    }

    public function humas()
    {
        if (!isset($_SESSION['user']) || $_SESSION['user']['level'] !== 'Humas') {
            header('Location: /');
            exit;
        }

        require_once __DIR__ . '/../Views/dashboard/humas.php';
    }

    public function mahasiswa()
    {
        if (!isset($_SESSION['user']) || $_SESSION['user']['level'] !== 'Mahasiswa') {
            header('Location: /');
            exit;
        }

        require_once __DIR__ . '/../Views/dashboard/mahasiswa.php';
    }

    public function maba()
    {
        if (!isset($_SESSION['user']) || strtolower($_SESSION['user']['level']) !== 'maba') {
            header('Location: /');
            exit;
        }

        require_once __DIR__ . '/../Views/dashboard/maba.php';
    }

    public function dosen()
    {
        if (
            !isset($_SESSION['user']) ||
            !in_array(strtolower($_SESSION['user']['level']), ['dosen', 'dosen/kaprodi'])
        ) {
            header('Location: /');
            exit;
        }

        require_once __DIR__ . '/../Views/dashboard/dosen.php';
    }
	

}
