<?php include('../conn.php');
if (isset($_GET['item'])) {
$orderid= $_GET['item']; }
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>checkout Customer</title>
    <style>
        
    </style>
</head>
<?php include("../common/head.php");


$sql="select * from hotel_bookink WHERE orderid='$orderid'";
$result = mysqli_query($conn,$sql)or die( mysqli_error($conn));
    $row=mysqli_fetch_array($result) ;

    $data=$row['id'];
$name=$row['customer_name'];
    $room=$row['room'];
    $contact=$row['contact'];
    $location=$row['location'];
    $start=$row['start'];
    $status=$row['status'];
    $end=$row['end'];
    $date=$row['date'];
    $days=$row['days'];
    $time=$row['time'];
    $payment=$row['payment_method'];
    $amount_paid=$row['amount_paid'];
    $orderid=$row['orderid'];
    $today= date("F j, Y");
    $time=date("h:ia");
?>
<div class="activate-item text-center m-5">
    <h4>checkout Customer</h4>
     <form  method="post">
        <input type="text" name="customer" value="<?php echo $name?>" disabled>
        <input type="text" name="checkout" value="<?php echo $today?>" disabled>
        <input type="text" name="time" value="<?php echo $time?>" disabled>
        <input type="hidden" name="orderid" value="<?php echo $orderid?>">
        <input type="hidden" name="by" value="<?php echo $id_user?>">
        <button name="submit" class=" btn btn-danger btn-sm m-2">Yes</button>
        <button data-dismiss="modal" class=" btn btn-success btn-sm m-2">No</button>
    </form>
     </div>
</body>
</html>

<?php 





if(isset($_POST['submit'])){
 
echo $_POST['customer'];
     $name=$_POST['customer'];
     $checkout=$_POST['checkout'];
    $time=$_POST['time'];
     $orderids=$_POST['orderid'];
     $date=$_POST['date'];
     $by=$_POST['by'];

     $sql0 = "UPDATE `hotel_bookink` SET `status`=1 WHERE orderid= '$orderid'";
     if(mysqli_query($conn,$sql0)){

     }
     else{
       echo 'Error: '.mysqli_error($conn);
     }

     $sql1 = "INSERT INTO `checkout`( `orderid`,`date`,`time`,`checkout`,`by`) VALUES ('$orderids','$date','$time','$checkout','$by')";
    if(mysqli_query($conn,$sql1)){ 
       echo"<script>alert('Customer was successfully checkout'); window.location.href='../hotel'</script>";
} 
else{
   echo 'Error: '.mysqli_error($conn);
 }
     
}