<?php 
ob_start();
session_start();
include('../dbconnect.php');
if( !isset($_SESSION['user']) ) {
 header("Location: ../index.php");
 exit;
}
if($_SESSION['userlevel'] != 'admin'){
  header("Location: ../accessdenied.php");
}
$user = $_SESSION['user'];
$sqla = "SELECT * FROM account WHERE userid = '$user'";
$resulta = mysqli_query($conn, $sqla);
$rowa  = mysqli_fetch_assoc($resulta);
$acclevel = $rowa['level'];
$accstat = $rowa['status'];

$sqlb = "SELECT * FROM empinfo WHERE empid = '$user'";
$resultb = mysqli_query($conn, $sqlb);
$rowb = mysqli_fetch_assoc($resultb);
$pic = $rowb['picture'];
$accountname = $rowb['firstname'].' '.$rowb['surname'];
if(empty($pic)){
  $pic = "profile.png";
  $accountname = $rowa['level'];
}



?>
<title>SB Admin - Blank Page</title>

<!-- Bootstrap core CSS-->
<link href="../vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">

<!-- Custom fonts for this template-->
<link href="../vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">

<!-- Page level plugin CSS-->
<link href="../vendor/datatables/dataTables.bootstrap4.css" rel="stylesheet">

<!-- Custom styles for this template-->
    <link href="../css/sb-admin.css" rel="stylesheet">
    <link href="../css/style.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    <nav class="navbar navbar-expand navbar-dark bg-dark static-top">

<a class="navbar-brand mr-1" href="dashboard.php">Admin</a>

<button class="btn btn-link btn-sm text-white order-1 order-sm-0" id="sidebarToggle" href="#">

  <i class="fas fa-bars"></i>


  
</button>




<!-- Navbar -->
<ul class="navbar-nav  ml-auto mr-0 mr-md-3 my-2 my-md-0">
 
  <li class="nav-item dropdown no-arrow">
    <a class="nav-link dropdown-toggle" href="#" id="userDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
      <img src = "../files/pictures/<?php echo $pic;?>" class="rounded-circle" height="25" width="25"> &nbsp <?php echo $accountname ?> &nbsp<i class="fa fa-sort-down"></i>
    </a>
    <div class="dropdown-menu dropdown-menu-right" aria-labelledby="userDropdown">
    <a class="dropdown-item" href="useraccount.php"> <i class="fas fa-user"></i> User Profile</a>
    <!--
      <a class="dropdown-item" href="#">Settings</a>
      <a class="dropdown-item" href="#">Activity Log</a>

      -->
      <div class="dropdown-divider"></div>
      <a class="dropdown-item" href="#" data-toggle="modal" data-target="#logoutModal"><i class="fas fa-sign-out-alt"></i> Logout  </a>
    </div>
  </li>
</ul>

</nav>

 <!-- 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.</div>
          <div class="modal-footer">
            <button class="btn btn-secondary" type="button" data-dismiss="modal">Cancel</button>
            <a class="btn btn-primary" href="../logout.php?logout" >Logout</a>
          </div>
        </div>
      </div>
    </div>