<?php $role = $this->session->userdata('role'); ?>

<!DOCTYPE html>
<html lang="id">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Accounting</title>
  <link rel="icon" href="<?= base_url('assets/img/accounting-color.png') ?>" type="image/png">

  <!-- Bootstrap 5 -->
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">

  <!-- Bootstrap Icons -->
  <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.css" rel="stylesheet">

  <!-- Google Font -->
  <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap" rel="stylesheet">
  <link href="<?= base_url('assets/css/style-custom.css'); ?>" rel="stylesheet">

  <script src="https://code.jquery.com/jquery-3.7.1.min.js"></script> 
  
  
  <link rel="stylesheet" href="https://cdn.datatables.net/1.13.6/css/dataTables.bootstrap5.min.css"> 
  <link rel="stylesheet" href="https://cdn.datatables.net/responsive/2.4.1/css/responsive.bootstrap5.min.css"> 
  <script src="https://cdn.datatables.net/1.13.6/js/jquery.dataTables.min.js"></script> 
  <script src="https://cdn.datatables.net/responsive/2.4.1/js/dataTables.responsive.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
  <script src="https://unpkg.com/html5-qrcode" type="text/javascript"></script>


  <!-- Daterange Picker -->
  <script type="text/javascript" src="https://cdn.jsdelivr.net/momentjs/latest/moment.min.js"></script>
  <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.min.js"></script>
  <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.css" />
  
    <!-- Select2 STABLE -->
    <link href="https://cdn.jsdelivr.net/npm/select2@4.0.13/dist/css/select2.min.css" rel="stylesheet" />
    <script src="https://cdn.jsdelivr.net/npm/select2@4.0.13/dist/js/select2.min.js"></script>
    
</head>

<body>

<!-- ───────────────────────── NAVBAR ───────────────────────── -->
<nav class="navbar navbar-expand-lg fixed-top">
  <div class="container">
    
    <!-- Mobile menu button -->
    <button class="btn text-white d-lg-none me-2" data-bs-toggle="offcanvas" data-bs-target="#mobileMenu">
      <i class="bi bi-list fs-3"></i>
    </button>

    <img src="<?= base_url('assets/img/accounting-white.png'); ?>" width="50px">

    <div class="collapse navbar-collapse d-none d-lg-flex">
      <ul class="navbar-nav ms-4">

        <!-- DASHBOARD -->
        <li class="nav-item">
          <a class="nav-link <?= ($active_menu == 'dashboard') ? 'active' : ''?>" href="<?= base_url(); ?>">
            <i class="bi bi-speedometer2"></i> Dashboard
          </a>
        </li>

        <li class="nav-item">
          <a class="nav-link <?= ($active_menu == 'jurnal') ? 'active' : ''?>" href="<?= base_url('jurnal'); ?>">
            <i class="bi bi-journal-plus"></i> Jurnal Umum
          </a>
        </li>
        
        <?php if($role == 'Admin'): ?>

        <li class="nav-item">
          <a class="nav-link <?= ($active_menu == 'buku_besar') ? 'active' : ''?>" href="<?= base_url('bukubesar'); ?>">
            <i class="bi bi-book"></i> Buku Besar
          </a>
        </li>

        <li class="nav-item dropdown">
          <a class="nav-link dropdown-toggle <?= in_array($active_menu, ['laba_rugi','neraca','neraca_saldo']) ? 'active' : '' ?>" href="#" data-bs-toggle="dropdown">
            <i class="bi bi-graph-up"></i> Laporan
          </a>
          <ul class="dropdown-menu">
            <li><a class="dropdown-item <?= ($active_menu == 'neraca_saldo') ? 'active' : '' ?>" href="<?= base_url('neracasaldo'); ?>">
              <i class="bi bi-clipboard-data me-2"></i> Neraca Saldo</a>
            </li>
            <li><a class="dropdown-item <?= ($active_menu == 'laba_rugi') ? 'active' : '' ?>" href="<?= base_url('labarugi'); ?>">
              <i class="bi bi-graph-up-arrow me-2"></i> Laba Rugi</a>
            </li>
            <li><a class="dropdown-item <?= ($active_menu == 'neraca') ? 'active' : '' ?>" href="<?= base_url('neraca'); ?>">
              <i class="bi bi-bar-chart-line me-2"></i> Neraca</a>
            </li>
          </ul>
        </li>
        
        <?php endif; ?>
        
        <li class="nav-item dropdown">
          <a class="nav-link dropdown-toggle <?= in_array($active_menu, ['accounts','basejurnal']) ? 'active' : '' ?>" href="#" data-bs-toggle="dropdown">
            <i class="bi bi-list-nested"></i> Daftar Akun
          </a>
          <ul class="dropdown-menu">
            
            <?php if($role == 'Admin'): ?>
            <li>
              <a class="dropdown-item <?= ($active_menu == 'accounts') ? 'active' : '' ?>" 
                 href="<?= base_url('accounts'); ?>">
                <i class="bi bi-list-nested"></i> Base Akun
              </a>
            </li>
            <?php endif; ?>
            
            <li>
              <a class="dropdown-item <?= ($active_menu == 'basejurnal') ? 'active' : '' ?>" 
                 href="<?= base_url('basejurnal'); ?>">
                <i class="bi bi-arrow-left-right"></i> Base Jurnal
              </a>
            </li>
          </ul>
        </li>

        <!--<li class="nav-item">-->
        <!--  <a class="nav-link <?= ($active_menu == 'asset') ? 'active' : ''?>" href="<?= base_url('asset'); ?>">-->
        <!--    <i class="bi bi-book"></i> Asset-->
        <!--  </a>-->
        <!--</li>-->
        
        <li class="nav-item dropdown">
          <a class="nav-link dropdown-toggle <?= in_array($active_menu, ['asset','lokasiasset']) ? 'active' : '' ?>" 
             href="#" data-bs-toggle="dropdown">
            <i class="bi bi-archive"></i> Asset
          </a>
        
          <ul class="dropdown-menu">
        
            <!-- Daftar Asset -->
            <li>
              <a class="dropdown-item <?= ($active_menu == 'asset') ? 'active' : '' ?>" 
                 href="<?= base_url('asset'); ?>">
                <i class="bi bi-archive me-2"></i> Daftar Asset
              </a>
            </li>
        
            <li><hr class="dropdown-divider"></li>
        
            <!-- Lokasi Asset -->
            <li>
              <a class="dropdown-item <?= ($active_menu == 'lokasiasset') ? 'active' : '' ?>" 
                 href="<?= base_url('lokasiasset'); ?>">
                <i class="bi bi-geo-alt me-2"></i> Lokasi Asset
              </a>
            </li>
        
          </ul>
        </li>

        <li class="nav-item dropdown">
          <a class="nav-link dropdown-toggle <?= in_array($active_menu, ['warehouses','items', 'kode_barang', 'draft_items']) ? 'active' : '' ?>" href="#" data-bs-toggle="dropdown">
            <i class="bi bi-box-seam"></i> Gudang
          </a>
          <ul class="dropdown-menu">
            <li>
              <a class="dropdown-item <?= ($active_menu == 'warehouses') ? 'active' : '' ?>" 
                 href="<?= base_url('warehouses'); ?>">
                <i class="bi bi-building me-2"></i> Daftar Gudang
              </a>
            </li><hr class="dropdown-divider">
            <li>
              <a class="dropdown-item <?= ($active_menu == 'draft_items') ? 'active' : '' ?>" 
                 href="<?= base_url('items/draft_items'); ?>">
                <i class="bi bi-truck me-2"></i> Daftar Pending
              </a>
            </li>
            <li>
              <a class="dropdown-item <?= ($active_menu == 'items') ? 'active' : '' ?>" 
                 href="<?= base_url('items'); ?>">
                <i class="bi bi-box me-2"></i> Daftar Barang
              </a>
            </li><hr class="dropdown-divider">
            <li>
              <a class="dropdown-item <?= ($active_menu == 'kode_barang') ? 'active' : '' ?>" 
                 href="<?= base_url('kodebarang'); ?>">
                <i class="bi bi-code me-2"></i> Daftar Kode Barang
              </a>
            </li>
          </ul>
        </li>

        <li class="nav-item dropdown">
          <a class="nav-link dropdown-toggle <?= in_array($active_menu, ['customers','invoice_unpaid','invoice_paid','payments','invoice_draft']) ? 'active' : '' ?>" href="#" data-bs-toggle="dropdown">
            <i class="bi bi-receipt"></i> Invoice
          </a>
          <ul class="dropdown-menu">
            <!-- Customers -->
            <li>
              <a class="dropdown-item <?= ($active_menu == 'customers') ? 'active' : '' ?>" href="<?= base_url('customers'); ?>">
                <i class="bi bi-people me-2"></i> Customers
              </a>
            </li>
            <li><hr class="dropdown-divider"></li>
            <!-- Draft -->
            <li>
              <a class="dropdown-item <?= ($active_menu == 'invoice_draft') ? 'active' : '' ?>" href="<?= base_url('invoices/draft'); ?>">
                <i class="bi bi-pencil-square me-2"></i> Draft Invoice
              </a>
            </li>
            <!-- Riwayat Invoice -->
            <li>
              <a class="dropdown-item <?= ($active_menu == 'invoice_paid') ? 'active' : '' ?>" href="<?= base_url('invoices/paid'); ?>">
                <i class="bi bi-check-circle me-2"></i> Riwayat Invoice
              </a>
            </li>
            <!-- Pembayaran -->
<!--             <li>
              <a class="dropdown-item <?= ($active_menu == 'payments') ? 'active' : '' ?>" href="<?= base_url('payments'); ?>">
                <i class="bi bi-cash-stack me-2"></i> Pembayaran
              </a>
            </li> -->
          </ul>
        </li>

        <li class="nav-item dropdown">
        
            <a class="nav-link dropdown-toggle <?= in_array($active_menu, ['employees','shift','holidays','attendance_monitoring','leave_requests','generate_schedule']) ? 'active' : '' ?>"
               href="#"
               data-bs-toggle="dropdown">
        
                <i class="bi bi-people-fill me-1"></i>
                Kepegawaian
        
            </a>
        
            <ul class="dropdown-menu shadow border-0 rounded-4 p-2">
                
                <li>
        
                    <a class="dropdown-item rounded-3 <?= ($active_menu == 'employees') ? 'active' : '' ?>"
                       href="<?= base_url('employees'); ?>">
        
                        <i class="bi bi-person-vcard-fill me-2"></i>
                        Data Karyawan
        
                    </a>
        
                </li>
        
                <li>
        
                    <a class="dropdown-item rounded-3 <?= ($active_menu == 'generate_schedule') ? 'active' : '' ?>"
                       href="<?= base_url('generateschedule'); ?>">
        
                        <i class="bi bi-calendar3-week-fill me-2"></i>
                        Jadwal Kerja
        
                    </a>
        
                </li>
                
                <li>
        
                    <a class="dropdown-item rounded-3 <?= ($active_menu == 'attendance_monitoring') ? 'active' : '' ?>"
                       href="<?= base_url('attendancemonitoring'); ?>">
        
                        <i class="bi bi-fingerprint me-2"></i>
                        Monitoring Absensi
        
                    </a>
        
                </li>
                
                <hr class="dropdown-divider">
                <li>
        
                    <a class="dropdown-item rounded-3 <?= ($active_menu == 'shift') ? 'active' : '' ?>"
                       href="<?= base_url('shifts'); ?>">
        
                        <i class="bi bi-alarm-fill me-2"></i>
                        Data Shift
        
                    </a>
        
                </li>
                
                <li>
        
                    <a class="dropdown-item rounded-3 <?= ($active_menu == 'holidays') ? 'active' : '' ?>"
                       href="<?= base_url('holidays'); ?>">
        
                        <i class="bi bi-calendar2-heart-fill me-2"></i>
                        Hari Libur
        
                    </a>
        
                </li>
                
                <li>
        
                    <a class="dropdown-item rounded-3 <?= ($active_menu == 'leave_requests') ? 'active' : '' ?>"
                       href="<?= base_url('leaverequests'); ?>">
        
                        <i class="bi bi-calendar-check-fill me-2"></i>
                        Cuti & Izin
        
                    </a>
        
                </li>
                
                <hr class="dropdown-divider">
                <li>
        
                    <a class="dropdown-item rounded-3 <?= ($active_menu == 'payroll') ? 'active' : '' ?>"
                       href="<?= base_url('payroll'); ?>">
        
                        <i class="bi bi-cash-stack me-2"></i>
                        Penggajihan
        
                    </a>
        
                </li>
        
            </ul>
        
        </li>
        
        <?php if($role == 'Admin'): ?>

        <li class="nav-item dropdown">
          <a class="nav-link dropdown-toggle <?= in_array($active_menu, ['umum','users']) ? 'active' : '' ?>" href="#" data-bs-toggle="dropdown">
            <i class="bi bi-gear"></i>
          </a>
          <ul class="dropdown-menu">
            <li><a class="dropdown-item <?= ($active_menu == 'umum') ? 'active' : '' ?>" href="<?= base_url('umum'); ?>">
              <i class="bi bi-sliders me-2"></i> Umum</a>
            </li>
            <li><a class="dropdown-item <?= ($active_menu == 'users') ? 'active' : '' ?>" href="<?= base_url('users'); ?>">
              <i class="bi bi-person-gear me-2"></i> Users</a>
            </li>
          </ul>
        </li>

        
        <?php endif; ?>

      </ul>

      <ul class="navbar-nav ms-auto">
        <li class="nav-item dropdown">
          <a class="btn btn-premium dropdown-toggle" href="#" data-bs-toggle="dropdown">
            <i class="bi bi-person-circle me-1"></i> <?= $this->session->username; ?>
          </a>
          <ul class="dropdown-menu dropdown-menu-end">
            <li><a class="dropdown-item <?= ($active_menu == 'profile') ? 'active' : '' ?>" href="<?= base_url('profile'); ?>">
              <i class="bi bi-person me-2"></i> Profile</a></li>
            <li><a class="dropdown-item" href="<?= base_url('auth/logout'); ?>">
              <i class="bi bi-box-arrow-right me-2"></i> Logout</a></li>
          </ul>
        </li>
      </ul>

    </div>
  </div>
</nav>

<div style="height: 70px;"></div>


<!-- ───────────────────────── SIDEBAR MOBILE ───────────────────────── -->
<div class="offcanvas offcanvas-start" tabindex="-1" id="mobileMenu">
  <div class="offcanvas-header">
    <span class="brand-mobile">🌿 Sekolah Islami</span>
    <button class="btn-close" data-bs-dismiss="offcanvas"></button>
  </div>

  <div class="offcanvas-body">
    <ul class="nav flex-column">

      <li class="nav-item">
        <a class="nav-link <?= ($active_menu == 'dashboard') ? 'active' : ''?>" href="<?= base_url(); ?>">
          <span class="menu-wrap"><i class="bi bi-speedometer2"></i> Dashboard</span>
        </a>
      </li>


    </ul>

    <div class="sidebar-divider"></div>

    <a href="<?= base_url('logout'); ?>" class="btn btn-logout">
      <i class="bi bi-box-arrow-right me-2"></i> Logout
    </a>

  </div>
</div>
