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

$pageLink = basename($_SERVER['REQUEST_URI']);
$Process->check_status($pageLink);

$Process->check_status($pageLink);
$dbLink = $Process->connect_db();
?>
<!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">
      <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 class="active"><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>Item</th>
            <th>Serial number</th>
            <th>Source</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 source</th>
            <th>Remark</th>
            <th>Update</th>
      </tr>
    </thead>
      <tbody>
		<?php

			$runQ = $Process->RunQuery("SELECT * FROM repair_list ORDER BY id asc",$dbLink);
			
			while($fetchData = $runQ->fetch()){
				echo "<tr><form action='update_table.php' method='post'>";
				echo "<td>
				<input type='hidden' name='id' value='".$fetchData->id."'  />".$fetchData->id."</td>";
				echo "<td>".$fetchData->name_of_item. "</td>";
				echo "<td>".$fetchData->serial_number. "</td>";
				echo "<td>".$fetchData->originating_station. "</td>";
				echo "<td>".$fetchData->date_in. "</td>";
				echo "<td>".$fetchData->problem. "</td>" ;
				echo "<td>".$fetchData->date_sent. "</td>";
				echo "<td>".$fetchData->work_done. "</td>";
				echo "<td>".$fetchData->date_returned. "</td>";
				echo "<td>".$fetchData->date_returned_to. "</td>";
				echo "<td>".$fetchData->remark. "</td>";
				echo "<td><input type=submit name='update' value=Update class='btn btn-xs btn-primary' /></td>";
				echo "</form></tr>";
			}
		?>
	  </tbody>
    </table>
    </div>
	<form action="excel.php" method="post" class="padding-top-20 magin-top-35" >
	<button name="export_excel" type="submit" class="btn btn-success">
		<span class="glyphicon glyphicon-save "> Download</span>
	</button>
	</form>
    </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>
