<?php
ob_start();
include "head.php";?>
    <?php
	//include "dbfunction.php";
	include "dbconfig.php";
  $invoice_no =$_GET['invoice_no'];
  $sql="SELECT bookings.pickup_date,bookings.id AS booking_id,bookings.comments, bookings.parking,bookings.driver_id, bookings.drop_address,bookings.drop_post_code, bookings.waiting_charges,bookings.fare,bookings.total_fare,bookings.waiting_time, bookings.hours,bookings.mins,bookings.other,sum(bookings.total_fare) as Total,
customers.id AS customer_id, customers.name AS customer_name,customers.address1,customers.post_code,customers.city, customers.mobile, payment_type.name AS payment_type, employees.first_name AS driver, vehicles.make as vehicle, company_contact.name as company_contact,
invoices.invoice_no,invoices.nett,invoices.vat,invoices.gross,invoices.date as invoice_date
FROM 
bookings
LEFT JOIN invoices ON bookings.invoice_no=invoices.invoice_no
LEFT JOIN customers ON bookings.customer_id = customers.id 
LEFT JOIN payment_type ON bookings.payment_type = payment_type.id 
LEFT JOIN employees ON bookings.driver_id = employees.id 
LEFT JOIN vehicles ON bookings.vehicle_id = vehicles.id 
LEFT JOIN company_contact ON customers.id = company_contact.customer_id 
WHERE invoices.invoice_no=$invoice_no
GROUP BY bookings.id
";
// $customer_id=$_GET['company_id'];
//WHERE customers.id=$customer_id GROUP BY bookings.id
$res=mysqli_query($con,$sql);
$rowcount=mysqli_num_rows($res);
$client=mysqli_query($con,$sql);
$invoice=mysqli_fetch_assoc($client)
?>
    
<style>table{ table-layout:fixed; } table td{ word-wrap:break-word; width:30px; }</style>
</head>

<body>

<form method="post" action="create_reciept.php"> 
  <?php
  $incoice='
<div class="panel panel-primary col-md-10 col-md-offset-1" style="margin-top:20px;">
<div class="panel-heading">Sales Invoice</div>
  <div class="panel-body">';?>
  						<?php
  						$customer_name=$invoice['customer_name'];
                        $address1=$invoice['address1'];
                        $post_code=$invoice['post_code'];
						$invoice['invoice_no'];
                        $invoice['invoice_date'];
						?>
                          
                      <div class="col-md-12">
                      	<div class="col-md-3">
                                    <p><b> Limo Chauffeurs Ltd. </b></p>
                                        <p>12 Lampton Park Road, </p><p>Hounslow,</p>
                                             TW3 4HS</p>
                                    </div>
                          <div class="col-md-3">
                                        <p>Phone: +44 (0)7808939220<br>
                                            Email : info@limochauffeurs.com</p>
                                    </div>
                           <div class="col-md-3">
                           <p><b>Invoice To</b></p>
                                
                           
                           <?php
  								$incoice.='<p>$customer_name=</p>
                                     
                                    <input type="hidden" name="customer_name" value="'.$customer_name.'"/>
                                    <p>
                                    
                                    <input type="hidden" name="company_post_code" value="'.$post_code.'"/>
                                </p>
                            </div>
                            <div class="col-md-3 inv-label">
                        <p>Invoice No:'.$invoice_no.'<br>
                        <input type="hidden" name="invoice_no" value=" "/>
                                            Date : '.$invoice_date.'</p>
                                  <input type="hidden" name="invoice_date" value=" "/>
                                </div>
                       </div>
					 </div>
                        ';?>                       
                      
                      <?php $invoice=
					 '
                     
                        
                       <table  style="font-family:Montserrat; font-size:13px;" id="invoice_table" class="table table-responsive list_jobs table-hover table-bordered table-striped table-info" cellspacing="0" border="1">

        <thead>
			
            <tr class="btn-primary" style="padding:10px;">
                           <th>Job ID</th>
                           <th>Pickup Date</th>
                           <th>Pickup Time</th>
                           <th>Passenger</th>
                           <th>Pickup From</th>
                           
                           <th>Drop To</th>
                            <th>Driver</th>
                           <th>Waiting Time</th>
                           <th style="text-align:right;">Waiting Charges</th>
                           <th style="text-align:right;">Parking</th>
                           <th style="text-align:right;">Fare</th>
                           <th style="text-align:right;">other</th>
                           <th style="text-align:right;">Total Fare</th>
                          
            </tr>

        </thead>

        <tfoot>

            <tr class="btn-primary">
                          <th>Job ID</th>
                           <th>Pickup Date</th>
                           <th>Pickup Time</th>
                           <th>Passenger</th>
                           <th>Pickup From</th>
                           
                           <th>Drop To</th>
                            <th>Driver</th>
                            <th>Waiting Time</th>
                            <th style="text-align:right;">Waiting Charges</th>
                           <th style="text-align:right;">Parking</th>
                           <th style="text-align:right;">Fare</th>
                           <th style="text-align:right;">other</th>
                           <th style="text-align:right;">Total Fare</th>

        </tfoot>

        <tbody>
        ';?>

        <?php

                while($job=mysqli_fetch_assoc($res))

                  {
					  //echo $job['payment_type'];
					  //exit;
					 $booking_id=$job['booking_id'];
					 $date=$date("d/m/y", strtotime($job['pickup_date']));
					 $time=$job['hours'].":".$job['mins'];
					 $company_contact=$job['company_contact'];
					 $address=$job['address1'].",".$job['city'].",".$job['post_code'];
					 $drop_address=$job['drop_address'].",".$job['drop_post_code'];
					 $driver=$job['driver'];
					 $waiting_time=$job['waiting_time'];
					 $waiting_charges=$job['waiting_charges'];
					 $parking=$job['parking'];
					 $fare=$job['fare'];
					 $other=$job['other'];
					 $total_fare=$job['total_fare'];
					 $company_contact=$job['company_contact'];
					 $company_contact=$job['company_contact'];
					 ?>
                      <tr>
                     <?php
					 
					 $invoice=
					 '
                           <td><input name="booking_id[]" type="hidden" value=" $booking_id"><label>'.$booking_id.'</label></td>
						   <td><input name="booking_id[]" type="hidden" value=" $booking_id"><label>'.$date.'</label></td>
						   <td><input name="booking_id[]" type="hidden" value=" $booking_id"><label>'.$time.'</label></td>
						   <td><input name="booking_id[]" type="hidden" value=" $booking_id"><label>'.$company_contact.'</label></td>
						   <td><input name="booking_id[]" type="hidden" value=" $booking_id"><label>'.$address.'</label></td>
						   <td><input name="booking_id[]" type="hidden" value=" $booking_id"><label>'.$drop_address.'</label></td>
						   <td><input name="booking_id[]" type="hidden" value=" $booking_id"><label>'.$driver.'</label></td>
						   <td><input name="booking_id[]" type="hidden" value=" $booking_id"><label>'.$waiting_time.'</label></td>
						   <td><input name="booking_id[]" type="hidden" value=" $booking_id"><label>'.$waiting_charges.'</label></td>
						   <td><input name="booking_id[]" type="hidden" value=" $booking_id"><label>'.$parking.'</label></td>
						   <td><input name="booking_id[]" type="hidden" value=" $booking_id"><label>'.$fare.'</label></td>
						   <td><input name="booking_id[]" type="hidden" value=" $booking_id"><label>'.$other.'</label></td>
						   <td><input name="booking_id[]" type="hidden" value=" $booking_id"><label>'.$total_fare.'</label></td>
						   
					</tr>
					';	   
				  }//while loop?>
                           
                       </tbody>
                    </table>         
         
         
         
                       
</body>
</html>
