<aside class="left-sidebar">
    <div class="scroll-sidebar">
        <nav class="sidebar-nav">
            <ul id="sidebarnav">
                <li class="user-pro">
                    <a class="has-arrow waves-effect waves-dark" href="javascript:void(0)" aria-expanded="false">
                        <img src="../assets/images/users/user.png" alt="user-img" class="img-circle">
                        <span class="hide-menu"><?php echo htmlspecialchars($user_name); ?></span>
                    </a>
                    <ul aria-expanded="false" class="collapse">
                        <li><a href="change_password.php"><i class="ti-user"></i> Ubah Kata Laluan</a></li>
                        <!-- <li><a href="logout.php"><i class="fa fa-power-off"></i> Log Keluar</a></li> -->
                    </ul>
                </li>

                <li class="nav-small-cap"><a href="dashboard.php" class="waves-effect waves-dark">:: Halaman Utama ::</a></li>

                <!-- Jabatan -->
                <?php if (checkRole('superadmin')): ?>
                <li>
                    <a class="has-arrow waves-effect waves-dark" href="javascript:void(0)" aria-expanded="false">
                        <i class="icon-note"></i><span class="hide-menu">Jabatan</span>
                    </a>
                    <ul aria-expanded="false" class="collapse">
                        <li><a href="add_jabatan.php">Tambah Jabatan</a></li>
                        <li><a href="view_jabatan.php">Senarai Jabatan</a></li>
                    </ul>
                </li>
                <?php endif; ?>

                <!-- Bahagian -->
                <?php if (checkRole('superadmin')): ?>
                <li>
                    <a class="has-arrow waves-effect waves-dark" href="javascript:void(0)" aria-expanded="false">
                        <i class="icon-doc"></i><span class="hide-menu">Bahagian</span>
                    </a>
                    <ul aria-expanded="false" class="collapse">
                        <li><a href="add_bahagian.php">Tambah Bahagian</a></li>
                        <li><a href="view_bahagian.php">Senarai Bahagian</a></li>
                    </ul>
                </li>
                <?php endif; ?>

                <!-- Kategori -->
                <?php if (checkRoles(['superadmin', 'admin'])): ?>
                <li>
                    <a class="has-arrow waves-effect waves-dark" href="javascript:void(0)" aria-expanded="false">
                        <i class="icon-bag"></i><span class="hide-menu">Kategori</span>
                    </a>
                    <ul aria-expanded="false" class="collapse">
                        <li><a href="add_kategori.php">Tambah Kategori</a></li>
                        <li><a href="view_kategori.php">Senarai Kategori</a></li>
                    </ul>
                </li>
                <?php endif; ?>

                <!-- Sub-Kategori -->
                <?php if (checkRoles(['superadmin', 'admin'])): ?>
                <li>
                    <a class="has-arrow waves-effect waves-dark" href="javascript:void(0)" aria-expanded="false">
                        <i class="ti-layout-grid2"></i><span class="hide-menu">Sub-Kategori</span>
                    </a>
                    <ul aria-expanded="false" class="collapse">
                        <li><a href="add_sub.php">Tambah Sub-Kategori</a></li>
                        <li><a href="view_sub.php">Senarai Sub-Kategori</a></li>
                    </ul>
                </li>
                <?php endif; ?>

                <!-- Surat / Memo -->
                <?php if (checkRoles(['superadmin', 'staf', 'admin'])): ?>
                <li>
                    <a class="has-arrow waves-effect waves-dark" href="javascript:void(0)" aria-expanded="false">
                        <i class="ti-email"></i><span class="hide-menu">Surat / Memo</span>
                    </a>
                    <ul aria-expanded="false" class="collapse">
                        <li><a href="add_norujukan.php">Tambah Surat/Memo</a></li>
                        <li><a href="view_norujukan.php">Senarai Surat/Memo</a></li>
                    </ul>
                </li>
                <?php endif; ?>

                <!-- Pengguna -->
                <?php if (checkRole('superadmin')): ?>
                <li>
                    <a class="has-arrow waves-effect waves-dark" href="javascript:void(0)" aria-expanded="false">
                        <i class="far fa-user"></i><span class="hide-menu">Pengguna</span>
                    </a>
                    <ul aria-expanded="false" class="collapse">
                        <li><a href="add_user.php">Tambah Pengguna Baru</a></li>
                        <li><a href="view_user.php">Senarai Pengguna</a></li>
                    </ul>
                </li>
                <?php endif; ?>
                <li><a href="logout.php"><i class="fa fa-power-off"></i> Log Keluar</a></li>
            </ul>
        </nav>
    </div>
</aside>