<?php
  $user = $_SESSION['user'] ?? null;
?>

<?php if ($user): ?>

<?php if ($user['level'] === 'Admin'): ?>

    <div class="modal fade" id="staticBackdropep" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-hidden="true">
      <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content border-0 shadow overflow-hidden">
          <div class="modal-header px-4">
            <h5 class="h6 modal-title fw-bold">Main Menu</h5><button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
          </div>
          <div class="modal-body p-4">
			<div class="nav p-4 ps-md-4 py-md-4 pe-md-0 bg-light flex-column delivery-tabs" id="v-pills-tab" role="tablist" aria-orientation="vertical">
				<a id="menu-beranda-admin" class="nav-link py-3 text-danger text-decoration-none" href="/dashboard/admin" role="tab" >
				<i class="bi bi-list"></i> Beranda
				</a>
				<a id="menu-profile-admin" class="nav-link py-3 text-danger text-decoration-none" href="/dashboard/admin-profil" role="tab">
				<i class="bi bi-person-fill"></i> Profile
				</a>
				<a id="menu-krs" class="nav-link py-3 text-danger text-decoration-none" href="/dashboard/admin-krs" role="tab">
				<i class="bi bi-newspaper"></i> Approv KRS
				</a>
				<a id="menu-khs" class="nav-link py-3 text-danger text-decoration-none" href="/dashboard/admin-khs" role="tab">
				<i class="bi bi-table"></i> Approv KHS
				</a>
				<a id="menu-ta-admin" class="nav-link py-3 text-danger text-decoration-none" href="/dashboard/admin-ta" role="tab">
				<i class="bi bi-person-workspace"></i> Pengaturan
				</a>
				<a id="menu-surat" class="nav-link py-3 text-danger text-decoration-none" href="/dashboard/admin-surat" role="tab">
				<i class="bi bi-envelope"></i> Surat-surat
				</a>
				<a href="/logout" class="nav-link py-3 text-danger text-decoration-none">
					<i class="bi bi-lock"></i> Logout
				</a>
			</div>
          </div>
        </div>
      </div>
    </div>
 
 <?php elseif ($user['level'] === 'Pegawai'): ?>

    <div class="modal fade" id="staticBackdropep" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-hidden="true">
      <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content border-0 shadow overflow-hidden">
          <div class="modal-header px-4">
            <h5 class="h6 modal-title fw-bold">Main Menu</h5><button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
          </div>
          <div class="modal-body p-4">
			<div class="nav p-4 ps-md-4 py-md-4 pe-md-0 bg-light flex-column delivery-tabs" id="v-pills-tab" role="tablist" aria-orientation="vertical">
				<a id="menu-beranda-pegawai" class="nav-link py-3 text-danger text-decoration-none" href="/dashboard/pegawai" role="tab">
				  <i class="bi bi-list"></i> Beranda
				</a>
				<a id="menu-profil-pegawai" class="nav-link py-3 text-danger text-decoration-none" href="/dashboard/pegawai-profil" role="tab">
				  <i class="bi bi-person-fill"></i> Profile
				</a>
				<a id="menu-data-mhs" class="nav-link py-3 text-danger text-decoration-none" href="/dashboard/pegawai-data-mhs" role="tab">
				  <i class="bi bi-people"></i> Data Mahasiswa
				</a>
				<a id="menu-jadwal-soal" class="nav-link py-3 text-danger text-decoration-none" href="/dashboard/pegawai-in-jadwal" role="tab">
				  <i class="bi bi-calendar-date"></i> Jadwal/Seting Soal
				</a>
				<a id="menu-data-alumni" class="nav-link py-3 text-danger text-decoration-none" href="/dashboard/pegawai-data-alumni" role="tab">
				  <i class="bi bi-mortarboard"></i> Data Alumni
				</a>
				<a id="menu-data-kip" class="nav-link py-3 text-danger text-decoration-none" href="/dashboard/pegawai-data-kip" role="tab">
				  <i class="bi bi-binoculars"></i> Data Survey KIP
				</a>
				<a id="menu-transkip" class="nav-link py-3 text-danger text-decoration-none" href="/dashboard/pegawai-transkip" role="tab">
				  <i class="bi bi-calculator"></i> Transkip Nilai
				</a>
				<a id="menu-mhs-akhir" class="nav-link py-3 text-danger text-decoration-none" href="/dashboard/pegawai-mhs-akhir" role="tab">
				  <i class="bi bi-person-workspace"></i> Mahasiswa Akhir
				</a>
        		<a id="menu-peg-manag" class="nav-link py-3 text-danger text-decoration-none" href="/dashboard/pegawai-ta" role="tab">
        		  <i class="bi bi-device-ssd"></i> Managemen Data
        		</a>				
				<a href="/logout" class="nav-link py-3 text-danger text-decoration-none">
				<i class="bi bi-lock"></i> Logout
				</a>
			</div>
          </div>
        </div>
      </div>
    </div>
    
<?php elseif ($user['level'] === 'Maba'): ?>

    <div class="modal fade" id="staticBackdropep" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-hidden="true">
      <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content border-0 shadow overflow-hidden">
          <div class="modal-header px-4">
            <h5 class="h6 modal-title fw-bold">Main Menu</h5><button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
          </div>
          <div class="modal-body p-4">
			<div class="nav p-4 ps-md-4 py-md-4 pe-md-0 bg-light flex-column delivery-tabs" id="v-pills-tab" role="tablist" aria-orientation="vertical">
 
				<a id="menu-beranda" class="nav-link py-3 text-danger text-decoration-none" href="/dashboard/maba" role="tab">
					<i class="bi bi-house"></i> Beranda
				</a>
                <a id="menu-profile-maba" class="nav-link py-3 text-danger text-decoration-none" href="/dashboard/maba-profile" role="tab">
                <i class="bi bi-person"></i> Profile
                </a>
                <a id="menu-ortu-maba" class="nav-link py-3 text-danger text-decoration-none" href="/dashboard/maba-orangtua" role="tab">
                <i class="bi bi-people"></i> Data Orang Tua
                </a>
                <a id="menu-kelas-maba" class="nav-link py-3 text-danger text-decoration-none" href="/dashboard/maba-pilihkelas" role="tab">
                <i class="bi bi-columns"></i> Pilih Kelas
                </a>
				<!--		
				<a id="menu-jadwal" class="nav-link py-3 text-danger text-decoration-none" href="/dashboard/mahasiswa-jadwal" role="tab">
					<i class="bi bi-calendar2-week"></i> Presensi & Jadwal
				</a>
				<a id="menu-ta" class="nav-link py-3 text-danger text-decoration-none" href="/dashboard/mahasiswa-ta" role="tab">
					<i class="bi bi-person-workspace"></i> Tugas akhir
				</a>
				<a id="menu-ajukan" class="nav-link py-3 text-danger text-decoration-none" href="/dashboard/mahasiswa-ajukan" role="tab">
					<i class="bi bi-send-plus"></i> Pengajuan
				</a>
				-->
				<a href="/logout" class="nav-link py-3 text-danger text-decoration-none">
					<i class="bi bi-lock"></i> Logout
				</a>
			</div>
          </div>
        </div>
      </div>
    </div>

<?php elseif ($user['level'] === 'Mahasiswa'): ?>				

    <div class="modal fade" id="staticBackdropep" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-hidden="true">
      <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content border-0 shadow overflow-hidden">
          <div class="modal-header px-4">
            <h5 class="h6 modal-title fw-bold">Main Menu</h5><button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
          </div>
          <div class="modal-body p-4">
			<div class="nav p-4 ps-md-4 py-md-4 pe-md-0 bg-light flex-column delivery-tabs" id="v-pills-tab" role="tablist" aria-orientation="vertical">

				<a id="menu-beranda" class="nav-link py-3 text-danger text-decoration-none" href="/dashboard/mahasiswa" role="tab">
					<i class="bi bi-house"></i> Beranda
				</a>
				<a id="menu-profile" class="nav-link py-3 text-danger text-decoration-none" href="/dashboard/mahasiswa-profile" role="tab">
					<i class="bi bi-person-fill"></i> Profile
				</a>
				<a id="menu-krs-khs" class="nav-link py-3 text-danger text-decoration-none" href="/dashboard/mahasiswa-krs" role="tab">
					<i class="bi bi-newspaper"></i> KRS/KHS
				</a>

				<a id="menu-soal" class="nav-link py-3 text-danger text-decoration-none" href="/dashboard/mahasiswa-soal" role="tab">
					<i class="bi bi-pc-display"></i> UTS/UAS
				</a>
						
				<a id="menu-jadwal" class="nav-link py-3 text-danger text-decoration-none" href="/dashboard/mahasiswa-jadwal" role="tab">
					<i class="bi bi-calendar2-week"></i> Presensi & Jadwal
				</a>
				<a id="menu-ta" class="nav-link py-3 text-danger text-decoration-none" href="/dashboard/mahasiswa-ta" role="tab">
					<i class="bi bi-person-workspace"></i> Tugas akhir
				</a>
				<a id="menu-ajukan" class="nav-link py-3 text-danger text-decoration-none" href="/dashboard/mahasiswa-ajukan" role="tab">
					<i class="bi bi-send-plus"></i> Pengajuan
				</a>
				<a href="/logout" class="nav-link py-3 text-danger text-decoration-none">
					<i class="bi bi-lock"></i> Logout
				</a>
			</div>
          </div>
        </div>
      </div>
    </div>

<?php elseif ($user['level'] === 'Dosen' || $user['level'] === 'Dosen/Kaprodi'): ?>   
				
    <div class="modal fade" id="staticBackdropep" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-hidden="true">
      <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content border-0 shadow overflow-hidden">
          <div class="modal-header px-4">
            <h5 class="h6 modal-title fw-bold">Main Menu</h5><button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
          </div>
          <div class="modal-body p-4">
			<div class="nav p-4 ps-md-4 py-md-4 pe-md-0 bg-light flex-column delivery-tabs" id="v-pills-tab" role="tablist" aria-orientation="vertical">
				  <a id="menu-beranda-dosen" class="nav-link py-3 text-danger text-decoration-none" href="/dashboard/dosen" role="tab">
					<i class="bi bi-list"></i> Beranda
				  </a>
				  <a id="menu-profile-dosen" class="nav-link py-3 text-danger text-decoration-none" href="/dashboard/dosen-profile" role="tab">
					<i class="bi bi-person-fill"></i> Profile
				  </a>
				  <a id="menu-absen" class="nav-link py-3 text-danger text-decoration-none" href="/dashboard/dosen-absen_mahasiswa" role="tab">
					<i class="bi bi-calendar"></i> Presensi Mahasiswa
				  </a>
				  <a id="menu-soal" class="nav-link py-3 text-danger text-decoration-none" href="/dashboard/dosen-upload-soal" role="tab">
					<i class="bi bi-patch-question"></i> Upload Soal
				  </a>
				  <a id="menu-koreksi" class="nav-link py-3 text-danger text-decoration-none" href="/dashboard/dosen-koreksi-soal" role="tab">
					<i class="bi bi-border-style"></i> Koreksi Jawaban
				  </a>   
				  <a id="menu-input-nilai" class="nav-link py-3 text-danger text-decoration-none" href="/dashboard/dosen-input-nilai" role="tab">
					<i class="bi bi-newspaper"></i> Input Nilai
				  </a>
			  <?php if ($user['level'] === 'Dosen/Kaprodi'): ?>
				<a id="menu-download-nilai" class="nav-link py-3 text-danger text-decoration-none" href="/dashboard/dosen-download-nilai" role="tab">
				  <i class="bi bi-people"></i> Download Nilai 
				</a>
			  <?php endif; ?>		  
				  <a id="menu-jadwal" class="nav-link py-3 text-danger text-decoration-none" href="/dashboard/dosen-jadwal" role="tab">
					<i class="bi bi-card-heading"></i> Jadwal Perkuliahan
				  </a>				  
				  <a href="/logout" class="nav-link py-3 text-danger text-decoration-none">
					<i class="bi bi-lock"></i> Logout
				  </a>
			</div>
          </div>
        </div>
      </div>
    </div> 
		

<?php endif; ?>
<?php endif; ?>

				<script>
			document.addEventListener('DOMContentLoaded', function() {
			  // Mendapatkan path URL setelah domain
			  const currentPath = window.location.pathname; // contoh: "/dashboard/mahasiswa-profile"

			  // Hapus kelas active dari semua nav-link
			  const navLinks = document.querySelectorAll('.nav-link');
			  navLinks.forEach(link => link.classList.remove('active'));

			  // Cek path dan aktifkan menu sesuai
			  if (currentPath === '/dashboard/mahasiswa' || currentPath === '/dashboard') {
				document.getElementById('menu-beranda')?.classList.add('active');
			  } else if (currentPath === '/dashboard/mahasiswa-profile') {
				document.getElementById('menu-profile')?.classList.add('active');
			  } else if (currentPath === '/dashboard/mahasiswa-krs' || currentPath === '/dashboard/mahasiswa-khs') {
				document.getElementById('menu-krs-khs')?.classList.add('active');
			  } else if (currentPath === '/dashboard/mahasiswa-jadwal') {
				document.getElementById('menu-jadwal')?.classList.add('active');
			  } else if (currentPath === '/dashboard/mahasiswa-ta') {
				document.getElementById('menu-ta')?.classList.add('active');
			  } else if (currentPath === '/dashboard/mahasiswa-ajukan' || currentPath === '/daftarskripsi' || currentPath === '/daftarwisuda' || currentPath === '/daftaryudisium') {
				document.getElementById('menu-ajukan')?.classList.add('active');
			  } else if (currentPath === '/dashboard/mahasiswa-soal' || currentPath === '/kerjakan-soal' || currentPath === '/dashboard/mahasiswa-mulai-ujian') {
				document.getElementById('menu-soal')?.classList.add('active');
			  }
			});

			</script>

