<?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 tab  le-bordered table-hover table-condensed">
  <div id="live_data"></div>
   
    </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>
	$(document).ready(function(){
		function fetch_data()
		{
			$.ajax({
				url:"select.php",
				method:"POST",
				success:function(data){
					$('#live_data').html(data);
				}
			});
		}

    fetch_data();
    $(document).on('click','#btn_add',function(){
       var first_name =$('#first_name').text();
       var last_name = $('#last_name').text();
       if(first_name=='')
       {
          alert("Enter First Name");
          return false;
       }
       if(last_name =='')
       {
        alert("Enter last Name");
        return false;
       }

        $.ajax({
          url:"insert.php"
          method:"POST",
          data:{first_name:first_name, last_name:last_name},
          dataType:"text",
          success:function(data){
            alert(data);
            fetch_data;
          }
        })
    })
	});
	
	</script>
  </body>
</html>