<?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:../");
}
 require 'db_config/config.php';

?>
<!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>I.T Asset Listing</title>

    <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet"  href="customstyle.css">

    
  </head>
  <body>
    <header>
    <div class="navbar navbar-default navbar-fixed-top navbar-inverse">
      <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">Asset Listing</a>
        </div>
        <div class="collapse navbar-collapse" id="example">
          <ul class="nav navbar-nav">
            <li><a href="homepage.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>
            <li><a href="update_page.php"><span class="glyphicon glyphicon-pencil"></span> Update List</a></li>
			            <li><a href="advance_search.php"><span class="glyphicon glyphicon-search"></span> Advance Search</a></li>

             <li>
            <a href="#" class="dropdown-toggle" data-toggle="dropdown">
            <span class="glyphicon glyphicon-user"></span> Super Admin
            <span class="caret"></span>
            </a>
            <ul class="dropdown-menu">
              <li><a href="add_user.php"><span class="glyphicon glyphicon-plus-sign"></span> Add User</a></li>
              <li><a href="view_user.html"><span class="glyphicon glyphicon-list-alt"></span> View User</a></li>   
              <li><a href="add_item.php"><span class="glyphicon glyphicon-shopping-cart"></span> Add item</a></li>              
			  
            </ul>
            </li>
          </ul>
          <form action="search.php" method="POST" class="navbar-form navbar-left" role="search">
            <div class="form-group">
              <input type="text" name="search" class="form-control" placeholder="Search Here">
            </div>
            <button  type="submit" class="btn btn-primary " name="submit"><span class="glyphicon glyphicon-search"></span></button>
          </form>
		   <ul class="nav navbar-nav  navbar-left " >
		   <li>
		   <form action="homepage.php" method="POST" class="navbar-form">
            <a href="" class="dropdown-toggle" data-toggle="dropdown">
           <span class="glyphicon glyphicon-user"><?php
           
			?></span>            <span class="caret"></span>
            </a>
            <ul class="dropdown-menu">
              <li><a href="change_password.php"><span class="glyphicon glyphicon-wrench"></span> Change password</a></li>
			  <li class="divider"></li>
				<li>
				<button name="logout" type="submit" class="btn btn-danger  btn-group-justified">
				<span class="glyphicon glyphicon-log-out ">Logout</span>
				</button>
				</li>
            </ul>
			</form>
		  </ul>
		  <?php
        if(isset($_POST['logout']))	 
		{
			session_destroy();
			header('location:index.php');
		}
	 
	 ?>
        </div>
      </div>
    </div>
    </header> 
    <div class="container padding-top-120">
	<form>
      <div class="table-responsive">
    <table class="table table-bordered table-hover table-condensed">
    <thead>
      <tr>
            <th>ID</th>
            <th>USER</th>
            <th>USER STATUS</th>
            <th>DESIGNATION</th>
            <th>DEVICE</th>
            <th>BRAND</th>
            <th>MODEL NUMBER</th>
            <th>LOCATION</th>
            <th>ASSET TAGGING</th>
            <th>ASSET TAG </th>
            <th>DATE</th>
      </tr>
    </thead>
      <tbody>
	  <?php

if (isset($_POST['submit'])){
//$connect =mysqli_connect("localhost","root","hesoyam73","it") or die ("Unable To Connect");
 require 'db_config/config.php';

$search = ($_POST['search']);
$resultset = $connect->query("SELECT * FROM asset_info WHERE user LIKE '%$search%' OR asset_tagging LIKE '%$search%' OR designation LIKE '%$search%' 
OR device LIKE '%$search%' OR brand LIKE '%$search%' OR model_num LIKE '%$search%' OR date LIKE '%$search%'");
if ($resultset->num_rows>0){
 while($rows =$resultset->fetch_assoc())
 {   $id =$rows['id'];
	 $user =$rows['user'];
	 $user_status=$rows['user_status'];
	 $designation=$rows['designation'];	 
	 $device =$rows['device'];
	 $brand =$rows['brand'];
	 $model_num =$rows['model_num'];
	 $location =$rows['location'];
	 $asset_tagging =$rows['asset_tagging'];
	 $asset_tag =$rows['asset_tag'];
	 $date =$rows['date'];

	 
	
	 echo "<tr>";
	echo "<td>".$rows['id']."</td>";
	echo "<td>".$rows['user']."</td>";
	echo "<td>".$rows['user_status']."</td>";
	echo "<td>".$rows['designation']."</td>";
	echo "<td>".$rows['device']."</td>";
	echo "<td>".$rows['brand']."</td>";
	echo "<td>".$rows['model_num']."</td>";
	echo "<td>".$rows['location']."</td>";
	echo "<td>".$rows['asset_tagging']."</td>";
	echo "<td>".$rows['asset_tag']."</td>";
	echo "<td>".$rows['date']."</td>";

	 	 echo "</tr>";

 }
}else{
	//echo '<script type="text/javascript"> alert("No Result Found") </script>';
	 echo "<br />";
			 echo '<div class="alert alert-danger">
			       <a href="#" class="close" data-dismiss="alert">&times;</a>
				   No result found
				   </div>';
}
}
?>
	  </tbody>
    </table>
    </div>
	</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>
  </body>
</html>