<?php
include_once '../includes/processes.php';
$Process = new Login_Process;

$pageLink = basename($_SERVER['REQUEST_URI']);
$Process->check_status($pageLink);
if($_SESSION['dept_id']!=7) {
	
	header("location:../");
}
?>
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Repair Track Sheet</title>
	<link rel="icon" type="image/ico" href="img/airicon.ico"/>
    <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet"  href="css/customstyle.css">
  </head>
  <body>
    <header>
    <div class="navbar navbar-default navbar-fixed-top navbar-dark bg-primary">
      <div class="container">
        <div class="navbar-header">
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#example">
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </button>
          <a href="" class="navbar-brand">Repair Track Sheet</a>
        </div>
        <div class="collapse navbar-collapse" id="example">
          <ul class="nav navbar-nav">
            <li><a href="index.php"><span  class="glyphicon glyphicon-home"></span> Home</a></li>
            <li><a href="display.php"><span class="glyphicon glyphicon-list-alt"></span> View List</a></li>
          </ul>
           <form action="search.php" method="POST" class="navbar-form navbar-right" role="search">
            <div class="form-group">
              <input type="text" name="search" class="form-control" placeholder="Search Here">
            </div>
            <button name="submit" type="submit" class="btn btn-primary "><span class="glyphicon glyphicon-search"></span></button>
          </form>
		  </ul>
        </div>
      </div>
    </div>
    </header>
    <div class="container padding-top-120">
    <div class="table-responsive">
    <table class="table table-bordered table-hover table-condensed" id="myTable">
    <thead>
      <tr class="info">
            <th>S/n</th>
            <th>Name of item</th>
            <th>Serial number</th>
            <th>Originating station/user</th>
            <th>Date in</th>
            <th>Problem</th>
            <th>Date sent to procurement</th>
            <th>Work done</th>
            <th>Date returned from procurement</th>
            <th>Date returned to station/user</th>
            <th>Remark</th>
      </tr>
    </thead>
      <tbody>
	  <?php
	  if (isset($_POST['submit'])){

$search = ($_POST['search']);
$resultset = $connect->query("SELECT * FROM repair_list WHERE serial_number LIKE '%$search%' OR name_of_item LIKE '%$search%' OR originating_station LIKE '%$search%'
OR problem LIKE '%$search%' OR work_done LIKE '%$search%' OR remark LIKE '%$search%'");
if ($resultset->num_rows>0){
 while($display =$resultset->fetch_assoc())
 {
	 echo "<tr>";
	echo "<td>".$display['id']."</td>";
	echo "<td>".$display['name_of_item']. "</td>";
	echo "<td>".$display['serial_number']. "</td>";
	echo "<td>".$display['originating_station']. "</td>";
	echo "<td>".$display['date_in']. "</td>";
	echo "<td>".$display['problem']. "</td>" ;
	echo "<td>".$display['date_sent']. "</td>";
	echo "<td>".$display['work_done']. "</td>";
	echo "<td>".$display['date_returned']. "</td>";
	echo "<td>".$display['date_returned_to']. "</td>";
	echo "<td>".$display['remark']. "</td>";
	echo "</tr>";
}
}else{
	 echo"<br />";
			 echo '<div class="alert alert-danger">
			       <a href="#" class="close" data-dismiss="alert">&times;</a>
				   No result found
				   </div>';
}
	  }
?>
	  </tbody>
    </table>
    </div>
    </div>
     <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <script src="bootstrap/js/bootstrap.min.js"></script>
	<script src="table/js/jquery.js"></script>
	<script src="table/js/jquery.dataTables.js"></script>
	<script src="table/js/dataTables.bootstrap.js"></script>

	<script>
	    $(".table").DataTable();
	</script>

  </body>
</html>
