<?php 
require("php_con.php");
if(isset($_COOKIE['user_id'])){
	$current_user_qury=mysqli_query($connation,"SELECT * FROM user_details WHERE user_id='$_COOKIE[user_id]'");
	$current_user_resalt=mysqli_fetch_array($current_user_qury);
}
else{
	echo "<script>window.location='logout';</script>";
}

if(isset($_GET['remove'])){
	$hbd_id=mysqli_real_escape_string($connation,$_GET['remove']);
	if(mysqli_query($connation,"DELETE FROM hold_bill_details WHERE hbd_id='$hbd_id'")){
		echo "<script>window.location='ajax_current_hold_bill.php';</script>";
	}
}
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<link href="icon/css/font-awesome.css" rel="stylesheet" type="text/css">
<link href="icon/css/font-awesome.min.css" rel="stylesheet" type="text/css">
<link href="data_table/css/bootstrap.css" rel="stylesheet" type="text/css">
<link href="cus_css.css" rel="stylesheet" type="text/css">
</head>

<body>
	
<table class="table table-sm table-bordered">
  <tbody>
    <tr class="table-active">
      <td>&nbsp;</td>
      <td>Mobile</td>
      <td>Name</td>
		<td>Remark</td>
      <td>Add Time</td>
      <td>Create by</td>
    </tr>
<?php 
$list_qury=mysqli_query($connation,"SELECT *,CONCAT(ud.user_fname,' ',ud.user_lname) AS u_name
FROM hold_bill_details hbd INNER JOIN user_details ud ON hbd.hbd_add_user=ud.user_id
ORDER BY hbd.hbd_id ASC");
while($list_resalt=mysqli_fetch_assoc($list_qury)){
?>
    <tr>
      <td align="center">
		<a href="poin-of-sale?bill_id=<?php echo $list_resalt['hbd_temp_id']; ?>" class="btn btn-sm btn-dark" target="_parent"><i class="fa fa-edit"></i></a>
		 <?php if($current_user_resalt['user_type']==1){ ?><a href="ajax_current_hold_bill.php?remove=<?php echo $list_resalt['hbd_id']; ?>" class="btn btn-sm btn-danger" onClick="return confirm('Are your sure?');"><i class="fa fa-trash"></i></a><?php } ?>
		</td>
      <td><?php echo "0".(int)$list_resalt['hbd_mobile']; ?></td>
      <td><?php echo $list_resalt['hbd_name']; ?></td>
		<td><?php echo $list_resalt['hbd_remark']; ?></td>
      <td><?php echo date("Y-m-d h:i:s A",strtotime($list_resalt['hbd_add_date']." ".$list_resalt['hbd_add_time'])); ?></td>
      <td><?php echo $list_resalt['u_name']; ?></td>
    </tr>
<?php } ?>
  </tbody>
</table>

	
</body>
</html>