<?php $activePage = basename($_SERVER['PHP_SELF'], ".php");
$sql = "SELECT * FROM admin WHERE id = '".$_SESSION['admin']."'";
	$query = $conn->query($sql);
	$admin = $query->fetch_assoc(); ?>
<nav class="navbar top-navbar col-lg-12 col-12 p-0">
  <div class="container-fluid">
	<div class="text-center navbar-brand-wrapper d-flex align-items-center justify-content-start">
	  <a class="navbar-brand brand-logo" href="index.php"><img style="width: 115px;height:140px;" src="assets/images/logo.png" alt="logo" /></a>
	  <a class="navbar-brand brand-logo-mini" href="index.php"><img style="width: 115px;height:140px;" src="assets/images/logo.png" alt="logo" /></a>
	</div>
	<div class="text-center navbar-menu-wrapper d-none d-lg-block d-flex align-items-center justify-content-center">
	  <span style="text-transform:uppercase;font-size: 30px;font-weight: bold;color: #000;">military engineer services <br> HISAR/ALWAR</span>
	</div>
	<div class="navbar-brand-wrapper d-flex align-items-center justify-content-end">
	  <a class="navbar-brand brand-logo d-none d-lg-block" href="index.php"><img style="width: 115px;height:auto;" src="assets/images/logo-right.png" alt="logo" /></a>
	  <button class="navbar-toggler navbar-toggler-right d-lg-none align-self-center" type="button" data-toggle="horizontal-menu-toggle">
		<i class="fa fa-bars text-white"></i>
	  </button>
	</div>
  </div>
</nav>
<p class="text-center p-0 m-1 fw-bolder">Login Date : <?php echo date('d/m/Y'); ?></p>
<nav class="bottom-navbar">
  <div class="container-fluid">
	<ul class="nav page-navigation">
	    <?php if($_SESSION['admintype'] == 'super') { ?>
	    <li class="nav-item <?= (($activePage == 'report')) ? 'active':''; ?>">
		<a class="nav-link" href="report.php">
		  <span class="menu-title">Dashboard</span>
		</a>
	  </li>
	    <?php } else { ?>
	  <li class="nav-item <?= (($activePage == 'dashboard')) ? 'active':''; ?>">
		<a class="nav-link" href="dashboard.php">
		  <span class="menu-title">TODAY COMPLAINTS</span>
		</a>
	  </li>
	  <li class="nav-item <?= (($activePage == 'complaints')) ? 'active':''; ?>">
		<a class="nav-link" href="complaints.php">
		  <span class="menu-title">COMPLAINTS </span>
		</a>
	  </li>
	  <?php if($_SESSION['admintype'] == 'admin') { ?>
	 <!-- <li class="nav-item <?= (($activePage == 'departments')||($activePage == 'addDepartment')) ? 'active':''; ?>">-->
		<!--<a class="nav-link" href="JAVASCRIPT:">-->
		<!--  <span class="menu-title">OFFICER MASTER DATA</span>&nbsp;-->
		<!--<i class="fa fa-caret-down"></i>-->
		<!--</a>-->
		<!--  <div class="submenu">-->
  <!--            <ul class="submenu-item">-->
  <!--              <li class="nav-item"><a class="nav-link <?= (($activePage == 'departments')) ? 'active':''; ?>" href="departments.php">ALL OFFICER MASTER DATA</a></li>-->
  <!--              <li class="nav-item"><a class="nav-link <?= (($activePage == 'addDepartment')) ? 'active':''; ?>" href="addDepartment.php">ADD OFFICER MASTER DATA</a></li>-->
  <!--            </ul>-->
  <!--          </div>-->
	 <!-- </li>-->
	  <?php } ?>
	  <li class="nav-item <?= (($activePage == 'engineer')||($activePage == 'addEngineer')) ? 'active':''; ?>">
		<a class="nav-link" href="JAVASCRIPT:">
		  <span class="menu-title">ENGINEERS/TRADESMAN</span>&nbsp;
		<i class="fa fa-caret-down"></i>
		</a>
		  <div class="submenu">
              <ul class="submenu-item">
                <li class="nav-item"><a class="nav-link <?= (($activePage == 'engineer')) ? 'active':''; ?>" href="engineer.php">ALL ENGINEERS/TRADESMAN</a></li>
                <li class="nav-item"><a class="nav-link <?= (($activePage == 'addEngineer')) ? 'active':''; ?>" href="addEngineer.php">ADD ENGINEERS/TRADESMAN</a></li>
              </ul>
            </div>
	  </li>
	  <?php if(in_array(($_SESSION['role'] ?? ''), array('super_admin', 'ge_admin', 'department_admin'), true)) { ?>
	  <li class="nav-item <?= (($activePage == 'super')||($activePage == 'addSuper')) ? 'active':''; ?>">
		<a class="nav-link" href="JAVASCRIPT:">
		  <span class="menu-title"> ADMIN Master </span>&nbsp;
		<i class="fa fa-caret-down"></i>
		</a>
		  <div class="submenu">
              <ul class="submenu-item">
                <!--<li class="nav-item"><a class="nav-link <?= (($activePage == 'super')) ? 'active':''; ?>" href="super.php">ALL SUPER ADMIN</a></li>-->
                <li class="nav-item"><a class="nav-link <?= (($activePage == 'addSuper')) ? 'active':''; ?>" href="addSuper.php"> Manage Admin </a></li>
              </ul>
            </div>
	  </li>
	  <?php } ?>
	  <li class="nav-item <?= (($activePage == 'complaints1')||($activePage == 'complaint-reg')) ? 'active':''; ?>">
		<a class="nav-link" href="JAVASCRIPT:">
		  <span class="menu-title">REPORTS</span>&nbsp;
		<i class="fa fa-caret-down"></i>
		</a>
		  <div class="submenu">
              <ul class="submenu-item">
        	    <li class="nav-item"><a href="complaints1.php" class="nav-link<?= (($activePage == 'complaints1')) ? 'active':''; ?>">ALL COMPLAINTS</a></li>
        	    <li class="nav-item"><a href="complaint-reg.php" class="nav-link<?= (($activePage == 'complaint-reg')) ? 'active':''; ?>">COMPLAINT SUMMARY REGISTER</a></li>
              </ul>
            </div>
	  </li>
	  <?php if($_SESSION['admintype'] == 'admin') { ?>
	  <li class="nav-item <?= (($activePage == 'aboutus')||($activePage == 'building')||($activePage == 'comp')||($activePage == 'editComp')||($activePage == 'addComp')||($activePage == 'addBuilding')||($activePage == 'editBuilding')||($activePage == 'subdivision')||($activePage == 'addSubdivision')||($activePage == 'editSubdivision')) ? 'active':''; ?>">
		<a class="nav-link" href="JAVASCRIPT:">
		  <span class="menu-title">SETTINGS</span>&nbsp;
		<i class="fa fa-caret-down"></i>
		</a>
		  <div class="submenu">
              <ul class="submenu-item">
        	    <li class="nav-item"><a href="aboutus.php" class="nav-link<?= (($activePage == 'aboutus')) ? 'active':''; ?>">UPDATE ABOUTUS</a></li>
        	    <li class="nav-item"><a href="updatehelp.php" class="nav-link<?= (($activePage == 'updatehelp')) ? 'active':''; ?>">UPDATE HELP</a></li>
        	    <li class="nav-item"><a href="updatecontact.php" class="nav-link<?= (($activePage == 'updatecontact')) ? 'active':''; ?>">UPDATE CONTACT US</a></li>
        	    <li class="nav-item"><a href="building.php" class="nav-link<?= (($activePage == 'building')||($activePage == 'editBuilding')) ? 'active':''; ?>">ALL BUILDINGS</a></li>
        	    <li class="nav-item"><a href="addBuilding.php" class="nav-link<?= (($activePage == 'addBuilding')) ? 'active':''; ?>">ADD BUILDINGS</a></li>
        	    <li class="nav-item"><a href="subdivision.php" class="nav-link<?= (($activePage == 'subdivision')||($activePage == 'editSubdivision')) ? 'active':''; ?>">ALL SUBDIVISIONS</a></li>
        	    <li class="nav-item"><a href="addSubdivision.php" class="nav-link<?= (($activePage == 'addSubdivision')) ? 'active':''; ?>">ADD SUBDIVISION</a></li>
        	    <li class="nav-item"><a href="comp.php" class="nav-link<?= (($activePage == 'comp')||($activePage == 'editComp')) ? 'active':''; ?>">ALL COMPLAINTS LIST</a></li>
        	    <li class="nav-item"><a href="addComp.php" class="nav-link<?= (($activePage == 'addComp')) ? 'active':''; ?>">ADD COMPLAINT LIST</a></li>
              </ul>
            </div>
	  </li>
	  <?php }} ?>
	  <?php
	    $stockRole = $_SESSION['role'] ?? '';
	    $stockAllowed = in_array($stockRole, array('super_admin', 'ge_admin', 'bso', 'department_admin', 'contractor'), true) || ($_SESSION['admintype'] ?? '') == 'admin';
	    if ($stockAllowed) {
	  ?>
	  <li class="nav-item <?= (($activePage == 'stockMaterials')||($activePage == 'stockReceive')||($activePage == 'stockTransfer')||($activePage == 'stockReport')) ? 'active':''; ?>">
		<a class="nav-link" href="JAVASCRIPT:">
		  <span class="menu-title">STOCK</span>&nbsp;
		<i class="fa fa-caret-down"></i>
		</a>
		  <div class="submenu">
              <ul class="submenu-item">
                <?php if(in_array($stockRole, array('super_admin', 'ge_admin', 'bso'), true) || ($_SESSION['admintype'] ?? '') == 'admin') { ?>
                <li class="nav-item"><a class="nav-link <?= (($activePage == 'stockMaterials')) ? 'active':''; ?>" href="stockMaterials.php">MATERIAL MASTER</a></li>
                <li class="nav-item"><a class="nav-link <?= (($activePage == 'stockReceive')) ? 'active':''; ?>" href="stockReceive.php">RECEIVE STOCK</a></li>
                <?php } ?>
                <li class="nav-item"><a class="nav-link <?= (($activePage == 'stockTransfer')) ? 'active':''; ?>" href="stockTransfer.php">TRANSFER / RETURN</a></li>
                <li class="nav-item"><a class="nav-link <?= (($activePage == 'stockReport')) ? 'active':''; ?>" href="stockReport.php">STOCK REPORT</a></li>
              </ul>
            </div>
	  </li>
	  <?php } ?>
	  <li class="nav-item profilelistingnav<?= (($activePage == 'profile')) ? ' active':''; ?>" style="">
		<a class="nav-link" href="JAVASCRIPT:">
		    <?php if($_SESSION['admintype'] == 'super') { ?>
		  <span class="menu-title">Welcome <?php echo $_SESSION['adminname']; ?></span>&nbsp;
		  <?php } else { ?>
		  <span class="menu-title">Welcome <?php echo $_SESSION['adminname']; ?> (<?php echo $admin['designation']; ?>)</span>&nbsp;
		  <?php } ?>
		<i class="fa fa-caret-down"></i>
		</a>
		  <div class="submenu">
              <ul class="submenu-item">
                <li class="nav-item"><a class="nav-link <?= (($activePage == 'profile')) ? 'active':''; ?>" href="profile.php">Update Profile</a></li>
                <li class="nav-item"><a class="nav-link" href="logout.php">Logout</a></li>
              </ul>
            </div>
	  </li>
	</ul>
  </div>
</nav>
