<?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 rel="icon" type="image/ico" href="img/airicon.ico"/>
    <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet"  href="customstyle.css">

    
  </head>
  <body>
    <header>
      <?php require 'header.php'?>

    </header> 
    <div class="container padding-top-120">
     <div class="table-responsive">
    <table class="table table-bordered table-hover table-condensed">
    <thead>
      <tr class="info">
            <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>
            <th>Update</th>
            <th>Delete</th>

      </tr>
    </thead>
      <tbody>
	  
	  <?php

if (isset($_POST['search'])){
//$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 id LIKE '$search' OR user LIKE '%$search%' OR user_status LIKE '%$search%' OR asset_tag 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'];
	 $vidtronix =$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><form action=update.php method=post>";
	echo "<td><input type=text readonly name=id value='".$rows['id']."'</td>";
	echo "<td><input type=text name=user value='".$rows['user']."'</td>";
	echo "<td><input type=text name=user_status value='".$rows['user_status']."'</td>";
	echo "<td><input type=text name=designation value='".$rows['designation']."'</td>";
	echo "<td><input type=text name=device value='".$rows['device']."'</td>";
	echo "<td><input type=text name=brand value='".$rows['brand']."'</td>";
	echo "<td><input type=text name=model_num value='".$rows['model_num']."'</td>";
	echo "<td><input type=text name=location value='".$rows['location']."'</td>";
	echo "<td><input type=text name=asset_tagging value='".$rows['asset_tagging']."'</td>";
	echo "<td><input type=text name=asset_tag value='".$rows['asset_tag']."'</td>";
	echo "<td><input type=text name=date value='".$rows['date']."'</td>";
	//echo"<td><button class='btn btn-xs btn-success glyphicon glyphicon-pencil'><button></td>";
	echo "<td><input type=submit name='update' value=Update class='btn btn-xs btn-success' /></td>";
	echo "<td><input type=submit name='delete' value=Delete class='btn btn-xs btn-danger' /></td>";
	
	echo "</form></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>';
				    header("refresh:3; url=update_page.php");

}
}
?>
	  </tbody>
    </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>
  </body>
</html>