<?php


include('../conn.php');
include('../common/head.php');




if(isset($_POST['submit'])){
    $name=addslashes($_POST['name']);
    $number=$_POST['number'];
   $checkin=$_POST['checkin'];
    $checkout=$_POST['checkout'];
    $room=$_POST['room'];
    $date= date("F j, Y");
    $orderid=$_POST['orderid'];
    $by=$_POST['by'];
    $amount=$_POST['amount'];
    $total=$_POST['total'];
    $payment=$_POST['payment'];
    $days=$_POST['days'];
    $location='Hotel';
    $time=date("h:ia");




    if ($payment=='nun') {
        echo"<script>alert('Please Select payment method'); window.location.href='../hotel'</script>";
       }
       else {
    $sql = "SELECT `number` FROM `customers` WHERE `number`='".$number."'";
    $result = $conn->query($sql);
    
    if($result->num_rows >= 1) {
     
    } else {
       // Image db insert sql
       $sql = "INSERT INTO `customers`(`fname`, `number`, `date`,`by`) VALUES ('$name','$number','$date','$by')";
       if(mysqli_query($conn,$sql)){


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

    }
 

   
$sql = "SELECT `orderid` FROM `hotel_bookink` WHERE `orderid`='".$orderid."'";
$result = $conn->query($sql);

if($result->num_rows >= 1) {
    echo"<script>alert('You can not Submit one order two times'); window.location.href='../hotel'</script>";
 
} else {


    $sql1 = "INSERT INTO `hotel_bookink`( `orderid`, `room`, `start`, `end`, `days`, `amount_paid`,`payment_method`, `customer_name`, `contact`,`location`, `date`, `time`,`by`) VALUES ('$orderid','$room','$checkin','$checkout','$days','$total','$payment','$name','$number','$location','$date','$time','$by')";
    if(mysqli_query($conn,$sql1)){ 
       echo"<script>alert('Print reciept'); window.location.href='../print/hotel_print.php?item=$orderid'</script>";
} 
else{
   echo 'Error: '.mysqli_error($conn);
 }
}

       }
}

$sql1="SELECT * FROM currency ";
$result1 = mysqli_query($conn,$sql1)or die( mysqli_error($conn));
$row1=mysqli_fetch_array($result1) ;
$currency=$row1['curency'];


?>



<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.1/css/all.min.css" integrity="sha256-2XFplPlrFClt0bIdPgpz8H7ojnk10H69xRqd9+uTShA=" crossorigin="anonymous" />
<style>
    body{margin-top:20px;
background-color:#eee;
color:black !important;
}

.card {
    box-shadow: 0 20px 27px 0 rgb(0 0 0 / 5%);
}
.card {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    word-wrap: break-word;
    background-color: #fff;
    background-clip: border-box;
    border: 0 solid rgba(0,0,0,.125);
    border-radius: 1rem;}



        
        table, th, td {

  border-collapse: collapse;
  font-size:16px;
  color:black !important;
    }

 
</style>
