<?php


include('../conn.php');
$page='Print facility Reciept';
include('../common/head.php');




if (isset($_GET['item'])) {
    $order= $_GET['item'];
    $orderid=$order;
 


    $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'];


    
    $sql6="select * from tax where status='1'";
    $result6 = mysqli_query($conn,$sql6)or die( mysqli_error($conn));
    while ($row6=mysqli_fetch_array($result6)) {
    $data=$row6['id'];
    $tax=$row6['tax'];
    $percent=$row6['percent']; 
    }
    
    $sql7="SELECT  sum(percent) FROM tax  WHERE status='1'";
      $result7 = mysqli_query($conn,$sql7)or die( mysqli_error($conn));
      $row7=mysqli_fetch_array($result7) ;
      
          $total_tax= $row7[0];
    
      
    
          $real_id=substr($orderid,-2);
          $ord = sprintf('%03d',$real_id); 

    $discount=0;
    
$total_tax_payable=$amount_paid*$total_tax/100;
$amount_payable=$amount_paid+$total_tax_payable;

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



}

       




?>

<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@500&display=swap" rel="stylesheet">

<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;
font-family: 'Roboto', sans-serif ! 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:18px;
  color:black !important;
    }

 
</style>
<div class="container">
<div class="row">

        <div class="col-lg-12">
            <div class="card">
                <div class="card-body">
                <?php include('recipt_head.php') ?>

                    <hr class="my-4">

                    <div class="row">
                        <div class="col-sm-12">
                            <div class="">
                                <h5 class="font-size-16 mb-1">Billed To:</h5>
                                <h5 class="font-size-15 mb-1"><?php echo $name ?></h5>
                                <p><?php echo $contact ?></p>
                                <h5 class="font-size-15 mb-1">Payment method: <?php echo $payment ?></h5>
                            </div>
                        </div>
                        <!-- end col -->
                        <div class="col-sm-12">
                            <div class=" text-sm-end">
                                <div class="mt-4">
                                    <h5 class="font-size-15 mb-1">Receipts Date:</h5>
                                    <p><?php echo $date." ".$time ?></p>
                                </div>
                                <div class="mt-4">
                                    <h5 class="font-size-15 mb-1">Order No:</h5>
                                    <p>#<?php echo $ord?></p>
                                </div>
                            </div>
                        </div>
                        <!-- end col -->
                    </div>
                    <!-- end row -->
                    
                    <div class="py-2">
                        <h5 class="font-size-15">Order Summary</h5>
                        <div class="table-responsive">
                            <table  style="width:300px" class="table align-middle table-nowrap table-centered mb-0">
                                <thead>
                                    <tr>
                                        
                                    <th >Room </th>
                                        <th>Checkin</th>
                                        <th>checkout</th>
                                        <th>Price</th>
                                    </tr>
                                </thead><!-- end thead -->
                                <tbody>
                                <tr style="display:;">
                                        <td ><?php echo $room?></td>
                                        <td><?php echo $start?></td>
                                        <td><?php echo $end?></td>
                                        <td><?php echo $currency ?><?php echo number_format($amount_paid,2)?></td>
                                        
                                      
                                    </tr>
                                    <!-- end tr -->
                                 <?php
                                 
$sql12="select * from tax where status='1'";
$result12 = mysqli_query($conn,$sql12)or die( mysqli_error($conn));
while ($row12=mysqli_fetch_array($result12)) {
$data=$row12['id'];
$tax=$row12['tax'];
$percent=$row12['percent']; 

$sql10="SELECT  sum(percent) FROM tax  WHERE status='1'";
  $result10 = mysqli_query($conn,$sql10)or die( mysqli_error($conn));
  $row10=mysqli_fetch_array($result10) ;
  
      $total_tax= $row10[0];





  ?>
                    
                                    <!-- end tr -->
                                    <tr>
                                        <th scope="row" colspan="2" class="border-0 ">
                                        <?php  echo $tax?> </th>
                                        <td class="border-0 "><?php echo  $percent ?>%</td>
                                    </tr>

                                    <?php }?>
                                    <!-- end tr -->
                                    <tr>
                                        <th scope="row" colspan="2" class="border-0 ">Total</th>
                                        <td class="border-0 "><b class="m-0 fw-semibold"><?php echo $currency ?><?php echo number_format($amount_payable,2)?></b></td>
                                    </tr>
                                    <!-- end tr -->
                                </tbody><!-- end tbody -->
                            </table><!-- end table -->
                            <?php include('recipt_footer.php') ?>
                        </div>
                        <!-- end table responsive -->
                        <div class="d-print-none mt-4">
                        <div class="pament-button text-center">
              
                            <div class="float-end">
                                <a href="javascript:window.print()" class="btn btn-success me-1"><i class="fa fa-print"></i></a>
                                <a href="../hotel" class="btn btn-primary btn-sm">Back Home</a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            

        </div><!-- end col -->
     
    </div>
</div>
