<?php 
require("php_con.php");
require("check_user.php");

if(isset($_POST['add_hold_btn'])){
	$hbd_temp_id=mysqli_real_escape_string($connation,$_GET['bill_id']);
	$hbd_name=mysqli_real_escape_string($connation,$_POST['hbd_name']);
	$hbd_mobile=(int)mysqli_real_escape_string($connation,$_POST['hbd_mobile']);
	$hbd_remark=mysqli_real_escape_string($connation,$_POST['hbd_remark']);
	if(mysqli_query($connation,"INSERT INTO
	hold_bill_details (hbd_id, hbd_temp_id, hbd_name, hbd_mobile, hbd_remark, hbd_add_date, hbd_add_time, hbd_add_user)
	VALUES (NULL, '$hbd_temp_id', '$hbd_name', '$hbd_mobile', '$hbd_remark', '$current_date', '$current_time', '$_COOKIE[user_id]')")){
		echo "<script>window.location='poin-of-sale';</script>";
	}
}
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<link rel="icon" href="favicon.ico">
<title><?php echo $system_name; ?></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>
	
<p align="center" class="mt-4"><a href="poin-of-sale" class="btn btn-sm btn-dark"><i class="fa fa-arrow-circle-o-left"></i> Back to POS</a></p>
	
<?php
$hbd_temp_id=mysqli_real_escape_string($connation,$_GET['bill_id']);
$check_qury=mysqli_query($connation,"SELECT * FROM hold_bill_details WHERE hbd_temp_id='$hbd_temp_id'");
if(mysqli_num_rows($check_qury)>0){
?>
<div class="container"><div class="alert alert-danger text-center font-weight-bold">Allready hold this bill.</div></div>
<?php
exit();
}
?>
	
<h4 align="center">Create New Hold Bill</h4>
	
<form method="post" autocomplete="off">
<table class="table-sm m-auto">
  <tbody valign="top">
    <tr>
      <td>Name</td>
      <td><input name="hbd_name" type="text" autofocus="autofocus" required="required" class="form-control form-control-sm" id="hbd_name"></td>
    </tr>
    <tr>
      <td>Mobile</td>
      <td><input name="hbd_mobile" type="number" required="required" class="form-control form-control-sm" id="hbd_mobile"></td>
    </tr>
    <tr>
      <td>Remark</td>
      <td><textarea name="hbd_remark" rows="4" class="form-control form-control-sm" id="hbd_remark"></textarea></td>
    </tr>
    <tr>
      <td colspan="2" align="right"><button type="submit" name="add_hold_btn" class="btn btn-sm btn-success">Save</button></td>
    </tr>
  </tbody>
</table>
</form>
	
</body>
</html>