<nav class="navbar navbar-default navbar-fixed-top">
  <!-- Brand and toggle get grouped for better mobile display -->
  <div class=" navbar-header">
    <button type="button" data-target="#navbarCollapse" data-toggle="collapse" class="navbar-toggle">
      <span class="sr-only">Toggle navigation</span>
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
    </button>

  </div>
  <!-- Collection of nav links, forms, and other content for toggling -->
  <div id="navbarCollapse" class="collapse navbar-collapse">
    <ul class="nav navbar-nav">
      <li><a href=""><img src="logo.png" width="50px" alt=""></a></li>
      <li><a href="./">Beranda</a></li>
      
      
       <?php if ($_SESSION['leveluser'] == 'admin') { ?>
        <li class="dropdown">
          <a data-toggle="dropdown" class="dropdown-toggle" href="#">Laporan Transaksi<b class="caret"></b></a>
          <ul class="dropdown-menu">
            <li><a href="?module=transaksiharian">Transaksi Harian</a></li>
            <li><a href="?module=lap-transaksiharian">Laporan Transaksi Harian</a></li>
            <li><a href="?module=rekap-lap-transaksiharian">Rekap Transaksi Harian</a></li>
            <li><a href="?module=perencanaan">Laporan Perencanaan</a></li>
            <li><a href="?module=realisasi-anggaran">Laporan Realisasi Perencanaan</a></li>
            <li><a href="?module=hutang-tagihan">Laporan Tagihan/Hutang</a></li>
            <li><a href="?module=lap-uangawal">Laporan Uang Awal</a></li>
            <li><a href="?module=lap-bawauang">Laporan Bawa Uang</a></li>
            <li><a href="?module=transaksi-piutang">Laporan Piutang</a></li>
            <!-- <li><a href="?module=penyesuaianharian">Penyesuaian Harian</a></li>
            <li><a href="?module=penyesuaianharianreal">Penyesuaian Harian REAL</a></li> -->
            <li><a href="?module=buku_besar">
              <font style="color: brown;"><b>Buku besar</b></font>
            </a></li>
            <li><a href="?module=buku_besar_tahunan">
              <font style="color: brown;"><b>Buku besar Tahunan</b></font>
            </a></li>
           
        </ul>
      </li>
   

      <?php }else{ ?>
      
             <li class="dropdown">
        <a data-toggle="dropdown" class="dropdown-toggle" href="#"><b>Laporan Transaksi</b></a>
        <ul class="dropdown-menu">
        <li><a href="?module=transaksiharian">Transaksi Harian</a></li>
        <li><a href="?module=lap-transaksiharian">Laporan Transaksi Harian</a></li>
        <li><a href="?module=transaksi-piutang">Piutang</a></li>
        </ul>
      </li>
      <?php } ?>
      
      
      
      
      
      
       <?php if ($_SESSION['leveluser'] == 'admin') { ?>
      <li><a href="?module=laporankas"> <b>LAPORAN KAS</b></a></li>
      <?php } ?>


      <li class="dropdown">
        <a data-toggle="dropdown" class="dropdown-toggle" href="#"><b>LAPORAN</b><b class="caret"></b></a>
        <ul class="dropdown-menu">
          <?php
          $divisiQuery = mysqli_query($conn, "SELECT * FROM jenis_divisi ORDER BY nama_divisi");
          while ($divisi = mysqli_fetch_array($divisiQuery)) {
           
           
           ?>
           <li class="dropdown-submenu1">
               <a href="#" class="dropdown-toggle1" data-toggle="dropdown1">Div. <?php echo $divisi['nama_divisi'] ?></a>
              <ul class="dropdown-menu1" style="background-color: #e0f7fa;">
                 <?php
                   
                  $query = mysqli_query($conn, "SELECT * FROM jenis_transaksi WHERE id_jenis > 1 AND id_divisi= $divisi[id_divisi] ORDER BY nama_jenis");
                  while ($row = mysqli_fetch_array($query)) {
                    echo "<a href='?module=transaksi&type=$row[id_jenis]'><li>$row[nama_jenis]</li></a>";
                  }
                  
                  
                  ?>
              </ul>
              </li>
          <?php } ?>
          
        </ul>
      </li>

      <li class="dropdown">
        <a data-toggle="dropdown" class="dropdown-toggle" href="#">Pemb. Santri Pondok <b class="caret"></b></a>
        <ul class="dropdown-menu">
          <li><a href="?module=lap-spp">Tagihan infaq bulanan/SPP</a></li>
          <!-- <li><a href="?module=pembayaran-dam">Dana awal masuk</a></li> -->
          <li><a href="?module=lap-dam">Tagihan Dana awal masuk</a></li>
          <li><a href="?module=lap-dut">Tagihan Daftar Ulang Tahunan</a></li>
          <li><a href="?module=transaksi-santri">Uang saku Santri</a></li>
        </ul>
      </li>
      
      <li class="dropdown">
        <a data-toggle="dropdown" class="dropdown-toggle" href="#">Pemb. SD UMUM <b class="caret"></b></a>
        <ul class="dropdown-menu">
          <li><a href="?module=lap-spp-sd">SPP Bulanan</a></li>
          <!-- <li><a href="?module=pembayaran-dam">Dana awal masuk</a></li> -->
          <li><a href="?module=lap-dam-sd">Tagihan Biaya awal masuk</a></li>
          <li><a href="?module=lap-dut-sd">Tagihan Daftar Ulang Tahunan</a></li>
         </ul>
      </li>

      <li class="dropdown">
        <a data-toggle="dropdown" class="dropdown-toggle" href="#">Pemb. Rumah Tahfidz <b class="caret"></b></a>
        <ul class="dropdown-menu">
          <!-- <li><a href="?module=pembayaran-spp-rt-pagi">Rumah Tahfidz Pagi</a></li> -->
          <li><a href="?module=lap-spp-rt-pagi">Tagihan SPP Rumah Tahfidz Pagi</a></li>
          <li><a href="?module=lap-dam-rt-pagi">Tagihan DAM Rumah Tahfidz Pagi</a></li>
          <!-- <li><a href="?module=pembayaran-spp-rt-sore">Rumah Tahfidz Sore</a></li> -->
          <li><a href="?module=lap-spp-rt-sore">Tagihan SPP Rumah Tahfidz Sore</a></li>
          <li><a href="?module=infaq-harian-rt">Infaq harian Rumah tahfidz</a></li>
        </ul>
      </li>

      <li class="dropdown">
        <a data-toggle="dropdown" class="dropdown-toggle" href="#">Pemb. Donatur <b class="caret"></b></a>
        <ul class="dropdown-menu">
          <li><a href="?module=pembayaran-donatur-tetap">Donatur Tetap</a></li>
          <li><a href="?module=pembayaran-donatur-tdk-tetap">Donatur Tidak Tetap</a></li>
        </ul>
      </li>

      <li class="dropdown">
        <a data-toggle="dropdown" class="dropdown-toggle" href="#">Data Induk <b class="caret"></b></a>
        <ul class="dropdown-menu">
          <li>
            <a href="?module=santri"></i>Data Santri Pondok</a>
          </li>
          <li>
            <a href="?module=cek-data-santri"></i>Cek Kelengkapan Data Santri Pondok</a>
          </li>
          <li>
            <a href="?module=data-kelas-santri"></i>Data Kelas Umum Santri</a>
          </li>
          <li>
            <a href="?module=cetak-kartu"></i>Cetak Kartu Santri</a>
          </li>
          <li>
            <a href="?module=santri-junio"></i>Export tagihan santri junio</a>
          </li>
          <li>
            <a href="?module=santri_sd"></i>Data Santri SD Umum</a>
          </li>
          <li>
            <a href="?module=santri-rt"></i>Data Santri Rmh Tahfidz</a>
          </li>
          <li>
            <a href="?module=donatur"></i>Data Donatur Tetap</a>
          </li>
          <li>
            <a href="?module=pekerja"></i>Data Pekerja</a>
          </li>
        </ul>
      </li>

      <?php

      $anon = mysqli_query($conn, "SELECT * FROM transaksi WHERE id_transaksi='' OR 
      debit=0 AND kredit=0 OR id_jenis='' OR id_pegawai='' OR jenis_kas=''");
      $anonim = mysqli_num_rows($anon);


      ?>

      <?php if ($_SESSION['leveluser'] == 'admin') { ?>
        <li class="dropdown">
          <a data-toggle="dropdown" class="dropdown-toggle" href="#">Pengaturan <b class="caret"></b></a>
          <ul class="dropdown-menu">
            <li><a href="?module=jenis-donasi">Jenis Donasi</a></li>
            <li><a href="?module=type-transaksi">Jenis Transaksi</a></li>
            <li><a href="?module=sub-kategori">Sub Kategori kas</a></li>
            <li><a href="?module=jenis-rt">Jenis Rumah Tahfidz</a></li>
            <li><a href="?module=pengaturan">Data sekolah </a></li>
            <li><a href="?module=pengaturan&aksi=print">Printer </a></li>
            <li><a href="?module=pegawai">Data Akun</a></li>
            <li><a href="?module=akses_edit">akses edit transaksi</a></li>
            <li><a href="?module=mac">akses mac perangkat</a></li>
            <li><a href="?module=history_login">History Login</a></li>
            <li><a href="?module=log_detail">History Aktivitas</a></li>
            <li><a href="?module=data_anonim">Data transaksi anonim [<?php echo $anonim; ?>]</a></li>
            <li><a href="?module=databasesikeung">Backup Database</a></li>
          </ul>
        </li>
      <?php } ?>

 <li class="dropdown">
        <a data-toggle="dropdown" class="dropdown-toggle" href="#"><span class="glyphicon glyphicon-user"></span> <?php echo $_SESSION['namalengkap']; ?> <b class="caret"></b></b></a>
        <ul class="dropdown-menu">
          <li><a href="?module=akun">Akun</a></li>
          <li><a class="btn" onclick="logout();"><span class="glyphicon glyphicon-log-in"></span> Logout</a></li>
        </ul>
      </li>

    </ul>

    <!--<ul class="nav navbar-nav navbar-right">-->

     
      
    <!--</ul>-->



  </div>
</nav>
<style>
    .dropdown-submenu1 {
  position: ;

}

.dropdown-submenu1 > .dropdown-menu1 {
  top: 0;
  left: 100%;
  margin-top: -6px;
  margin-left: 0;
  display: none;
  background-color: #e0f7fa;
}

.dropdown-submenu1:hover > .dropdown-menu1 {
  display: block;
  
}

.dropdown-submenu1 > a:after {
  display: block;
  content: " ";
  float: right;
  width: 0;
  height: 0;
  border-color: transparent;
  border-style: solid;
  border-width: 5px 0 5px 5px;
  border-left-color: #ccc;
  margin-top: 5px;
  margin-right: -10px;
  background-color: #e0f7fa;
  
}

.dropdown-submenu1:hover > a:after {
  border-left-color: #fff;
  background-color: #1e81b0;
}
</style>
<script>
  function logout() {
    Swal.fire({
      title: 'Yakin akan keluar?',
      showCancelButton: true,
      showConfirmButton: false,
      showDenyButton: true,
      denyButtonText: `Keluar`,
    }).then((result) => {
      /* Read more about isConfirmed, isDenied below */
      if (result.isConfirmed) {
        document.location = 'logout.php'
      } else if (result.isDenied) {
        document.location = 'logout.php'
      }
    })
  }
</script>