<ul class="navbar-nav bg-gradient-primary2 sidebar sidebar-dark accordion" id="accordionSidebar">

  <!-- Sidebar - Brand -->
  <a class="sidebar-brand d-flex align-items-center justify-content-center" href="index.html">
    <div class="sidebar-brand-text mx-3"><?= $main_capital_name; ?></div>
  </a>

  <!-- Divider -->
  <hr class="sidebar-divider my-0">

  <!-- Nav Item - Dashboard -->
  <li class="nav-item">
    <a class="nav-link" href="florence">
      <i class="fas fa-fw fa-home"></i>
      <span>Dashboard</span></a>
  </li>

  <!-- Nav Item - Dashboard -->
  <li class="nav-item">
    <a class="nav-link" class="dropdown-item" href="admin_withdrawal">
      <i class="fas fa-fw fa-wallet"></i>
      <span>Transactions</span></a>
  </li>

  <!-- Nav Item - Dashboard -->
  <li class="nav-item">
    <a class="nav-link" class="dropdown-item" href="admin_view_cheque">
      <i class="fas fa-fw fa-chess-queen"></i>
      <span>View Cheques</span></a>
  </li>

  <!-- Nav Item - Dashboard -->
  <li class="nav-item">
    <a class="nav-link" class="dropdown-item" href="admin-cot-code">
      <i class="fas fa-fw fa-key"></i>
      <span>Generate COT Code</span></a>
  </li>

  <!-- Nav Item - Dashboard -->
  <li class="nav-item">
    <a class="nav-link" class="dropdown-item" href="admin-vat-code">
      <i class="fas fa-fw fa-key"></i>
      <span>Generate VAT Code</span></a>
  </li>

  <!-- Nav Item - Dashboard -->
  <li class="nav-item">
    <a class="nav-link" class="dropdown-item" href="admin-imf-code">
      <i class="fas fa-fw fa-key"></i>
      <span>Generate IMF Code</span></a>
  </li>

  <!-- Nav Item - Dashboard -->
  <li class="nav-item">
    <a class="nav-link" class="dropdown-item" href="admin-otf-code">
      <i class="fas fa-fw fa-key"></i>
      <span>Generate OTF Code</span></a>
  </li>

  <!-- Nav Item - Dashboard -->
  <li class="nav-item">
    <a class="nav-link" class="dropdown-item" href="#" data-toggle="modal" data-target="#changePassword">
      <i class="fas fa-fw fa-lock"></i>
      <span>Change Admin Password</span></a>
  </li>

  <!-- Nav Item - Logout -->
  <li class="nav-item">
    <a class="nav-link" class="dropdown-item" href="#" data-toggle="modal" data-target="#logoutModal">
      <i class="fas fa-fw fa-power-off"></i>
      <span>Logout</span></a>
  </li>

  <!-- Divider -->
  <hr class="sidebar-divider">

  <!-- Sidebar Toggler (Sidebar) -->
  <div class="text-center d-none d-md-inline">
    <button class="rounded-circle border-0" id="sidebarToggle"></button>
  </div>

</ul>

<!-- Logout Modal-->
<div class="modal fade" id="logoutModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">Ready to Leave?</h5>
        <button class="close" type="button" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">×</span>
        </button>
      </div>
      <div class="modal-body">Select "Logout" below if you are ready to end your current session with us.</div>
      <div class="modal-footer">
        <button class="btn btn-secondary" type="button" data-dismiss="modal">Cancel</button>
        <a class="btn btn-primary" href="../logout">Logout</a>
      </div>
    </div>
  </div>
</div>

<!-- Change Password Modal-->
<div class="modal fade" id="changePassword" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title text-primary" id="exampleModalLabel"><i class="fa fa-lock"></i> Change Admin Password </h5>
        <button class="close" type="button" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">×</span>
        </button>
      </div>
      <form method="POST" action="florence">
        <div class="modal-body">
          <small>Note: By changing the value in the text field below, you would be changing the administrator password. The username remains the same (admin).</small>
          <?php
          require_once("../conn.php");

          $sql2 = "SELECT password FROM admin_pass LIMIT 1";
          $result2 = $dbconfig->query($sql2);

          if ($result2->num_rows > 0) {
            // output data of each row
            while ($row2 = $result2->fetch_assoc()) {
              echo '
                <div class="form-group">
                  <label for="email">Administrator Password:</label>
                  <input type="text" class="form-control" name="pass" value="' . $row2['password'] . '" placeholder="Admin Password..." required>
                </div>
              ';
            }
          }
          ?>
        </div>
        <div class="modal-footer">
          <button class="btn btn-secondary btn-sm" type="button" data-dismiss="modal">Cancel</button>
          <button type="submit" name="update_pass" class="btn btn-primary btn-sm">Change Password</button>
        </div>
      </form>
    </div>
  </div>
</div>

<?php

if (isset($_GET['logout'])) {
  if (session_destroy()) {
    header("Location: login");
  }
}

?>
