<?php
include('buiapp/partials/header.php');
 $username = $_SESSION['staff_session'];
$cookie_name = "username";
$cookie_value = password_hash($username, PASSWORD_DEFAULT);
setcookie($cookie_name, $cookie_value);
include ('buiapp/phpClasses/functions.php');
if (isset($_SESSION['staff_session'])) {
    $username = $_SESSION['staff_session'];
	$csession =  currentSession();
		$role = getrole($username, $csession);
		include('header.php');
		
		if(!isset($_COOKIE[$cookie_name])) {
		    
//cookiemail($username);
} else {
      
}

} else {
    	if(!isset($_COOKIE[$cookie_name])) {
     // cookiemail($username);
} else {
     
}
    header('Location: index.php');
    
    exit();
}
?>
<style type="text/css">
table.table-bordered{
    border:1px solid black;
    margin-top:20px;
  }
table.table-bordered > thead > tr > th{
    border:1px solid black;
	background-color: black;
	color: white;
}
table.table-bordered > tbody > tr > td{
    border:1px solid black;
}
table.table-bordered > tfoot > tr > td{
    border:1px solid black;
}

</style>


  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
         <?php
	   $curs = currentSession();
	  $rid = getunit($username);
	  
		
		    echo "$rid's Dashboard";
	  ?>
        <small>Bowen University Iwo</small>
      </h1>
      <ol class="breadcrumb">
	 <?php  $url = htmlspecialchars($_SERVER['HTTP_REFERER']); echo " <li><a href='$url'><i class='fa fa-arrow'></i>Back</a></li>";?>
	

       
        <li class="active">Dashboard</li>
      </ol>
    </section>

    <!-- Main content -->
    <section class="content container-fluid" style="background-image: url('images/logo2.png'); background-repeat: no-repeat; background-attachment: fixed; background-position: center; ">


         <div class="row">
        <div class="col">
          <!-- Custom Tabs -->
          <div class="nav-tabs-custom">
            <ul class="nav nav-tabs">
              <li class="active"><a href="#tab_1" data-toggle="tab">All Staff</a></li>
              <li><a href="mailbox.php">Mail</a></li>

            </ul>
            <div class="tab-content">
						  <div class="tab-pane active" id="tab_1">
                     			<div class="table-responsive">
              <table id="example1" class="table table-bordered ">
                <thead >
                <tr>
				<th>Select</th>
					<th>S/N</th>
               
                                    <th>Name</th>
                                   
                                    <th>Programme</th>
                                    <th>College</th>
									<th>Level</th>
									<th>Sex</th>
									<th>Action</th>
									
									
                
             
                </tr>
                </thead>
                <tbody>
				<?php
					$x = 1;
					$form = "<div style='display:none;'><form action='compose.php' method='post'>";
			
			  while ($row = mysqli_fetch_array($query2)) {
                                              
                                    echo '<tr>
									<td>';
									$sid = $row['staffsId'];
									$tempform = "<input type='checkbox' name='mulsendt[]' onclick= checkit('check$x') value='$sid'>"; 
									echo $tempform;
									$tempform2 = '<input type="checkbox" name="mulsend[]" id="check'.$x.'" value="'.$row['staffsId'].'">'; 
									$form .= $tempform2;
									
									echo '</td>
					<td>' . $x . '</td>
					<td>'.  ucwords(strtolower($row['firstname']))." ".ucwords(strtolower($row['middlename']))." ".ucwords(strtolower($row['lastname'])) .' </td>
				
					<td>'.  getcoursename($row['Departments_DepartmentCode']).' </td>
					<td>'.  ucwords(strtolower(getcoursefaculty($row['faculty']))).' </td>
					<td>'.  $row['staff_level'].' </td>
					<td>'.  $row['sex'].' </td>
                                        <td><form action="compose.php" method="post" ><input type="hidden" name="sendto" value="'.$row['staffsId'].'"> <button class="btn btn-info btn-sm"> Send Mail </button> </form></td>
				</tr>';
										$x++;
                                            }
											
				
				?>
             
                
				
				
              
                </tbody>
				<tfoot>
					<th>Select All <input type="checkbox"   name="selectall" id="checkAll"></th>
					<th>S/N</th>
               
                                    <th>Name</th>
                                    
                                    <th>Programme</th>
                                    <th>College</th>
									<th>Level</th>
									<th>Sex</th>
									
				</tfoot>
				
               
              </table>
			</div>
              </div>
			                <div class="tab-pane" id="tab_2">

              </div>
			  
            
            

			  
			 
              <!-- /.tab-pane -->

            </div>
            <!-- /.tab-content -->
          </div>
          <!-- nav-tabs-custom -->
        </div>
        <!-- /.col -->

   
      </div>











    </section>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->

  <!-- Main Footer -->
  <footer class="main-footer">
    <!-- To the right -->
    <div class="pull-right hidden-xs">
   
    </div>
    <!-- Default to the left -->
    <strong>Copyright &copy; 2019 <a href="#">Bowen University</a>.</strong> All rights reserved.
  </footer>


  <!-- /.control-sidebar -->
  <!-- Add the sidebar's background. This div must be placed
  immediately after the control sidebar -->
  <div class="control-sidebar-bg"></div>
</div>
<!-- ./wrapper -->

<!-- REQUIRED JS SCRIPTS -->

<!-- jQuery 3 -->
<script src="bower_components/jquery/dist/jquery.min.js"></script>
<!-- Bootstrap 3.3.7 -->
<script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="bower_components/datatables.net/js/jquery.dataTables.min.js"></script>
<script src="bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
<!-- jQuery UI 1.11.4 -->
<script src="bower_components/jquery-ui/jquery-ui.min.js"></script>
<!-- Slimscroll -->
<script src="bower_components/jquery-slimscroll/jquery.slimscroll.min.js"></script>
<!-- FastClick -->
<script src="bower_components/fastclick/lib/fastclick.js"></script>
<!-- AdminLTE App -->
<script src="dist/js/adminlte.min.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="dist/js/demo.js"></script>
<!-- fullCalendar -->
<script src="bower_components/moment/moment.js"></script>
<script src="bower_components/fullcalendar/dist/fullcalendar.min.js"></script>
<!-- Page specific script -->
<script>






   var table =  $('#example1').DataTable();
	$('#example3').DataTable();
	
	
   


  
  $("#checkAll").click(function(){
    $('input:checkbox').not(this).prop('checked', this.checked);
	
	
	
});

function checkit(id){
	 var checked = $('#'+id+':checked').length > 0;
		
		if(checked == true){
			
			$('#'+id).prop('checked', false);
		}else{
			$('#'+id).prop('checked', true);
		}
		
	
	

	
}



</script>
</body>
</html>