<?php


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



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


    $sql7 = "SELECT * FROM `pole` WHERE orderid='$orderid'";
    $result7 = mysqli_query($conn,$sql7)or die( mysqli_error($conn));
    $row7=mysqli_fetch_array($result7) ;

    $data=$row7['orderid'];
    $name=$row7['name'];
    $number=$row7['number'];
    $contact_person=$row7['contact_person'];
    $adults=$row7['adults'];
    $kids=$row7['kids'];
    $men_swim_trucks=$row7['men_swim_trucks'];
    $women_swim_trucks=$row7['women_swim_trucks'];
    $jackets=$row7['jackets'];
    $amount=$row7['amount'];
    $date=$row7['date'];
    $time=$row7['time'];
    $by=$row7['by'];
    $payment=$row7['payment_method'];
 

  
    if ($kids==0) {
        $kdisplay='none';
      }
      if ($adults==0) {
         $adisplay='none';
       }
       if ($men_swim_trucks==0) {
         $mdisplay='none';
       }
       if ($women_swim_trucks==0) {
         $wdisplay='none';
       }
       if ($jackets==0) {
         $jdisplay='none';
       }
 
 $per_adult=30;
 $per_kid=20;
 $men_swim=80;
 $women_swim=100;
 $jacket=10;
 
 $real_id=substr($orderid,-2);
 $ord = sprintf('%03d',$real_id);  
 
 $sql="select * from tax where status='1'";
 $result = mysqli_query($conn,$sql)or die( mysqli_error($conn));
 while ($row=mysqli_fetch_array($result)) {
 $data=$row['id'];
 $tax=$row['tax'];
 $percent=$row['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];
 
 
 
 
 $amount_per_adult=$per_adult*$adults;
 $amount_per_kid=$per_kid*$kids;
 $amount_men_swim=$men_swim*$men_swim_trucks;
 $amount_women_swim=$women_swim*$women_swim_trucks;
 $amount_jacket=$jacket*$jackets;
 
 
 
 $amount=$amount_per_adult+$amount_per_kid+$amount_men_swim+$amount_women_swim+$amount_jacket;
 $total_tax_payable=$amount*$total_tax/100;
 $amount_payable=$amount+$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 $number ?></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 >Item </th>
                                        <th>Qty</th>
                                        <th>Price</th>
                                    </tr>
                                </thead><!-- end thead -->
                                <tbody>
                                    <tr style="display:<?php echo $adisplay ?>;">
                                       
                                        <td >Adults</td>
                                        <td><?php echo $adults?></td>
                                        <td><?php echo $currency ?><?php echo number_format($amount_per_adult,2)?></td>
                                        
                                    </tr>
                                    <tr style="display:<?php echo $kdisplay ?>;">
                                       
                                        <td >Kids</td>
                                        <td><?php echo $kids?></td>
                                        <td><?php echo $currency ?><?php echo number_format($amount_per_kid,2)?></td>
                                        
                                    </tr>
                                    <tr  style="display:<?php echo $mdisplay ?>;" class="men">
                                       
                                        <td >Men swim truck</td>
                                        <td><?php echo $men_swim_trucks?></td>
                                        <td><?php echo $currency ?><?php echo number_format($amount_men_swim,2)?></td>
                                        
                                    </tr>
                                    <tr style="display:<?php echo $wdisplay ?>;">
                                      
                                        <td >women bathing suits</td>
                                        <td><?php echo $women_swim_trucks?></td>
                                        <td><?php echo $currency ?><?php echo number_format($amount_women_swim,2)?></td>
                                    </tr>
                                    <tr style="display:<?php echo $jdisplay ?>;">
                                       
                                        <td >Life Jackets Rental</td>
                                        <td><?php echo $jackets?></td>
                                        <td><?php echo $currency ?><?php echo number_format($amount_jacket,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];

$total_tax_payable=$amount*$total_tax/100;
$amount_payable=$amount+$total_tax_payable;




  ?>
                    
                    
                       

                     
                             
                                    <!-- 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="../pole" class="btn btn-primary btn-sm">Back Home</a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            

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