<?php
if(session_status() == PHP_SESSION_NONE) session_start();
$role = strtolower($_SESSION['role'] ?? '');
$full_name = $_SESSION['full_name'] ?? 'User';
$current_url = $_SERVER['REQUEST_URI'];
?>

<aside class="main-sidebar sidebar-light-blue elevation-4">
  <a href="/arsip-pagamento/dashboard.php" class="brand-link d-flex align-items-center p-2">
    <img src="/arsip-pagamento/logo-inddica.png" alt="Logo" 
         style="width:40px; height:40px; object-fit:contain;">
    <span class="brand-text font-weight-bold ml-2">Finance System</span>
  </a>
  <div class="sidebar">
    <div class="user-panel mt-3 pb-3 mb-3 d-flex">
      <div class="info">
        <a href="#" class="d-block"><?= $full_name ?> (<?= $role ?>)</a>
      </div>
    </div>
    <nav class="mt-2">
      <ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu">
      

        <li class="nav-item">
          <a href="/arsip-pagamento/dashboard.php" class="nav-link <?= strpos($current_url, '/dashboard.php')!==false ? 'active' : '' ?>">
            <i class="fas fa-tachometer-alt nav-icon"></i><p>Dashboard</p>
          </a>
        </li>
       <?php if($role=='admin'){ ?>
  <li class="nav-item">
    <a href="/arsip-pagamento/admin/upload.php" class="nav-link <?= strpos($current_url, '/admin/upload.php')!==false ? 'active' : '' ?>">
      <i class="fas fa-upload nav-icon"></i><p>Upload Dokumentu Finance</p>
    </a>
  </li>
  <li class="nav-item">
    <a href="/arsip-pagamento/admin/daftar_dokumen.php" class="nav-link <?= strpos($current_url, '/admin/daftar_dokumen.php')!==false ? 'active' : '' ?>">
      <i class="fas fa-file-alt nav-icon"></i><p>Lista Dokumentu Finance</p>
    </a>
  </li>
<?php } ?>

<?php if($role=='dct'){ ?>
  <li class="nav-item">
    <a href="/arsip-pagamento/dct/verifikasi.php" class="nav-link <?= strpos($current_url, '/dct/verifikasi.php')!==false ? 'active' : '' ?>">
      <i class="fas fa-check nav-icon"></i><p>Verifikasaun Finance</p>
    </a>
  </li>
<?php } ?>

<?php if($role=='dfo'){ ?>
  <li class="nav-item">
    <a href="/arsip-pagamento/dfo/verifikasi.php" class="nav-link <?= strpos($current_url, '/dfo/verifikasi.php')!==false ? 'active' : '' ?>">
      <i class="fas fa-check nav-icon"></i><p>Verifikasaun Finance (DFO)</p>
    </a>
  </li>
<?php } ?>

<?php if($role=='rejistu_transaksaun_pagamento'){ ?>
  <li class="nav-item">
    <a href="/arsip-pagamento/rejistu_transaksaun_pagamento/verifikasi.php" class="nav-link <?= strpos($current_url, '/rejistu_transaksaun_pagamento/verifikasi.php')!==false ? 'active' : '' ?>">
      <i class="fas fa-check-double nav-icon"></i><p>Verifikasaun Arkivu Finance</p>
    </a>
  </li>
  <li class="nav-item">
    <a href="/arsip-pagamento/rejistu_transaksaun_pagamento/daftar_arsip.php" class="nav-link <?= strpos($current_url, '/rejistu_transaksaun_pagamento/daftar_arsip.php')!==false ? 'active' : '' ?>">
      <i class="fas fa-archive nav-icon"></i><p>Lista Arkivu Finance</p>
    </a>
  </li>
<?php } ?>

<?php if($role=='director'){ ?>
  <li class="nav-item">
    <a href="/arsip-pagamento/director/laporan.php" class="nav-link <?= strpos($current_url, '/director/laporan.php')!==false ? 'active' : '' ?>">
      <i class="fas fa-file-alt nav-icon"></i><p>Relatoriu Rejistu Finance</p>
    </a>
  </li>
<?php } ?>
        <li class="nav-item">
          <a href="/arsip-pagamento/logout.php" class="nav-link">
            <i class="fas fa-sign-out-alt nav-icon"></i><p>Logout</p>
          </a>
        </li>
      </ul>
    </nav>
  </div>
</aside>
