<?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">

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <script src="bootstrap/js/bootstrap.min.js"></script>
    
  </head>
  <body>
          <?php $Process->navigation("add_item"); ?>

    </header> 
    <div class="container padding-top-120">
    <div class="col-md-6 col-md-offset-2">
    <div class="panel panel-primary">
    <div class="panel-heading font-weight-bold initialism">Add item</div>
      <div class="panel-body">
	  
      <ul class="nav nav-tabs">
	  <li class=""><a href="add_item.php">User Status</a></li>
	  <li class=""><a href="location.php">Location</a></li>
	  <li class=""><a href="device.php">Device</a></li>
	  <li class="active"><a href="brand.php">Brand</a></li>
	  <li class=""><a href="asset_tag.php">Asset Tag</a></li>
	  </ul></br>
 <div class="table table-responsive">
  
  <div id="live_data"></div>
  </div>
      </div>
    </div>
    </div>
    </div>


  <script>  
 $(document).ready(function(){  
      function fetch_data()  
      {  
           $.ajax({  
                url:"select_brand.php",  
                method:"POST",  
                success:function(data){  
                     $('#live_data').html(data);  
                }  
           });  
      }  
      fetch_data();  
      $(document).on('click', '#btn_add', function(){  
           var brand_admin = $('#brand_admin').text();    
           if(brand_admin == '')  
           {  
                alert("Enter Brand");  
                return false;  
           }  
           $.ajax({  
                url:"insert_brand.php",  
                method:"POST",  
                data:{brand_admin:brand_admin},  
                dataType:"text",  
                success:function(data)  
                {  
                     alert(data);  
                     fetch_data();  
                }  
           })  
      });  
      function edit_data(id, text, column_name)  
      {  
           $.ajax({  
                url:"edit_brand.php",  
                method:"POST",  
                data:{id:id, text:text, column_name:column_name},  
                dataType:"text",  
                success:function(data){  
                     alert(data);  
                }  
           });  
      }  
      $(document).on('blur', '.brand_admin', function(){  
           var id = $(this).data("id1");  
           var brand_admin = $(this).text();  
           edit_data(id, brand_admin, "brand_admin");  
      });   
      $(document).on('click', '.btn_delete', function(){  
           var id=$(this).data("id3");  
           if(confirm("Are you sure you want to delete this?"))  
           {  
                $.ajax({  
                     url:"delete1_brand.php",  
                     method:"POST",  
                     data:{id:id},  
                     dataType:"text",  
                     success:function(data){  
                          alert(data);  
                          fetch_data();  
                     }  
                });  
           }  
      });  
 });  
 </script>
  </body>
</html>