<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php
include('../include/session.php');
$delivery_no = $_GET['delivery_no'];
if (isset($_GET['print_checkbox'])) { $p=1; } else { $p=0; } ;
   
		$table_name = $_SESSION['db_prefix']."_deliver_product";
		$quote_query = "SELECT *  FROM $table_name WHERE delivery_no = '".$delivery_no."'";
		$quote_result = $con->query($quote_query);
		$row = mysqli_fetch_assoc($quote_result);
		$cust_id = $row["cust_id"];
		$deliver_date = $row["deliver_date"];
		$del_col= $row["del_col"];
		$order_no= $row["order_no"];
		$pallets= $row["pallets"];
		$pallets_price=$row["pallets_price"];
		$delivery_address= $row["delivery_address"];		 
		$delivered_by= $row["delivered_by"];
		$delivery_time= $row["delivery_time"];	
		$vehicle_reg= $row["vehicle_reg"];				 
		
		$quote='no';
								
		$table_name = $_SESSION['db_prefix']."_deliver_product_lines";
		$line_query = "SELECT *  FROM $table_name WHERE delivery_no = '".$delivery_no."' ";
		$line_result = $con->query($line_query);
		$line_num = mysqli_num_rows($line_result);
	
$report_name = 'Delivery';
$report_no = $delivery_no;
?>

<!--style sheets-->
<link href="../css/print.css" rel="stylesheet" type="text/css" />
<link rel="shortcut icon" type="image/x-icon" href="../images/favicon.ico">
<title>Order delivery <?php echo $delivery_no ?></title>

</head>

<body>

<script>
window.onload = function () {
  window.print();
  setTimeout(function(){window.close();}, 100);
}
</script>

<div class="print_main_frame_2" style="float:left">



<br>

  <div class="print_standard_frame">
        <table width="700" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="483">Order no <?php echo $order_no ?> delivered to:</td>
    <td width="169">Delivery date: <?php echo date("d-m-Y", strtotime($deliver_date)) ?></td>
  </tr>
</table>
<br>

        <?php 
		include ('../include/customer_block.php');
		?>
         </div><br>
<br>
<div class="print_standard_frame">
<label class="print_header_label_std">Delivery address:</label><br>
<table width="600" id="table_display" >
  <tr>
    <td width="118">Plot no:</td>
    <td><?php echo $delivery_address ?></td>
    </tr>
  
</table>
</div>

<div class="print_standard_frame">
<label class="print_header_label_std">Items delivered:</label>
<br>
<br>
         <table width="600" id="table_display" >
           <tr>
             <td width="193" height="26" align="left" valign="top">Item</td>
             <td width="151" align="left" valign="top">Batch codes</td>
             <td width="36" align="left" valign="top">Unit</td>
             <td width="61" align="left" valign="top">Quantity</td>
             <?php if ($p==1) { ?>
             <td align="center" valign="top">Unit price</td>
             <td align="center" valign="top">Line total</td>
             <?php } ?>
           </tr>
           <?php
				$i=0;
				$a7_total=0;
				while($row = $line_result->fetch_assoc()) {
					$a0 = $row["delivery_line_id"];
					$a1 = $row["product_item_id"];
					$a2 = $row["quantity"];
					$a5 = $row["batch_code"];
					$a6 = $row["price"];
					
					$a7 = $a6 * $a2;
				 	
					$a7_total = $a7_total + $a7;
					
					
					 $table_name = $_SESSION['db_prefix']."_product_store";
						$item_query = "SELECT item_name, unit, subCategory FROM $table_name WHERE product_item_id = '".$a1."' ";
						$item_result = $con->query($item_query);
						$row = mysqli_fetch_assoc($item_result);
						$a1a = $row["item_name"];
						$a3a = $row["unit"];
						$a4a = $row["subCategory"];
					 
					 
										 
				 ?>
           <tr>
             <td valign="top"><?php echo $a1a ?></td>
             <td valign="top"><?php echo $a5 ?></td>
             <td valign="top"><?php echo $a3a ?></td>
             <td align="right" valign="top"><?php echo $a2 ?></td>
              <?php if ($p==1) { ?>
             <td width="54" align="right" valign="top"><?php echo number_format($a6, 2, '.', ',') ?></td>
             <td width="77" align="right" valign="top"><?php echo number_format($a7, 2, '.', ',') ?></td>
             <?php } ?>
           </tr>
           <?php 
			   $i++;
				 }
			
		$pallets_total =$pallets * $pallets_price; 
		$a7_total = $a7_total + $pallets_total;
				 ?>	 
				
           <tr>
             <td valign="top">Pallets</td>
             <td valign="top">&nbsp;</td>
             <td valign="top">&nbsp;</td>
             <td align="right" valign="top"><?php echo $pallets ?></td>
              <?php if ($p==1) { ?>
             <td align="right" valign="top"><?php echo number_format($pallets_price, 2, '.', ',') ?></td>
             <td align="right" valign="top"><?php echo number_format($pallets_total, 2, '.', ',') ?></td>
             <?php } ?>
           </tr>
            <?php if ($p==1) { ?>
           <tr>
             <td colspan="5" align="right" valign="top">Total:&nbsp;&nbsp;</td>
             <td align="right" valign="top"><?php echo number_format($a7_total, 2, '.', ',') ?></td>
           </tr>
           <?php } ?>       
         </table>
			<div align="left">
<img src="../images/info_blue.png" width="16" height="16">
<label class="label_info">Pallets to be refunded on return. / Offloading to be done by customer.</label>          
</div>
         </div>
         <br>
<div class="print_standard_frame">
<table width="600" id="table_display">
  <tr>
    <td width="113" height="36">Delivery by:</td>
    <td width="220"><?php echo $delivered_by ?></td>
    <td width="120">Received by:</td>
    <td width="199">&nbsp;</td>
  </tr>
  <tr>
    <td height="30">Registration no:</td>
    <td><?php echo $vehicle_reg ?></td>
    <td>Date:</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td height="30">Driver name:</td>
    <td>&nbsp;</td>
    <td>Customer name:</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td height="37">Driver sign:</td>
    <td>&nbsp;</td>
    <td>Customer sign:</td>
    <td>&nbsp;</td>
  </tr>
</table>

</div>         
<br>
</div>
 
  



</body>


