<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php
include ("../navigation/header.php");

$page_name = "Stores-main";
include ("../navigation/access.php");

if ($permission_num==1) {

include ("../navigation/store_sidebar.php");

$delivery_no = $_GET['delivery_no'];

   
		$table_name = $_SESSION['db_prefix']."_tile_deliver";
		$quote_query = "SELECT *  FROM $table_name WHERE delivery_no = '".$delivery_no."'";
		$quote_result = mySQL_query($quote_query);
		$cust_id=mysql_result($quote_result, 0, "cust_id");
		$deliver_date=mysql_result($quote_result, 0, "deliver_date");
		$del_col=mysql_result($quote_result, 0, "del_col");
		$order_no=mysql_result($quote_result, 0, "order_no");
		$pallets=mysql_result($quote_result, 0, "pallets");
		$delivery_address=mysql_result($quote_result, 0, "delivery_address");			 
		$delivered_by=mysql_result($quote_result, 0, "delivered_by");
		$delivery_time=mysql_result($quote_result, 0, "delivery_time");	
		$vehicle_reg=mysql_result($quote_result, 0, "vehicle_reg");	
		
		
				
		$table_name = $_SESSION['db_prefix']."_tile_deliver_lines";
		$line_query = "SELECT *  FROM $table_name WHERE delivery_no = '".$delivery_no."' AND quantity > 0 ";
		$line_result = mySQL_query($line_query);
		$line_num = mysql_num_rows($line_result);
	
	//$quote_no = $order_no;
	
?>

<!--jscript-->
<script language="JavaScript" src="../jscript/numbers_only.js"  type="text/javascript"></script>
<script type="text/javascript">
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
</script>
</head>

<body>

<div class="main_frame" >
  <div class="page_head_frame">
        <table width="650" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="483"><label class="label_page_head">Delivery note</label></td>
            <td width="167" align="right"><label class="label_page_head_2">Delivery no <?php echo $delivery_no?>
</label></td>
          </tr>
        </table>
  </div><br />
<div class="page_middle_frame">
<div class="wizard_frame">

</div>
<br>

         <div class="wizard_frame">
         <table width="652" 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>

        <?php 
		include ('../include/customer_block.php');
		?>
         </div><br>
         Delivery address:
         <table width="650" id="table_display" >
  <tr>
    <td width="118">Delivery addres:</td>
    <td colspan="3"><?php echo $delivery_address ?></td>
    </tr>
  <tr>
    <td>Delivery made by:</td>
    <td>&nbsp;&nbsp;</td>
    <td>Delivery time:</td>
    <td><?php echo $delivery_time ?></td>
    </tr>
  <tr>
    <td>Driver:</td>
    <td width="156"><?php echo $delivered_by ?></td>
    <td width="116">Vehicle reg:</td>
    <td width="240"><?php echo $vehicle_reg ?></td>
  </tr>
    </table>

<br>
<div class="wizard_frame">
Items delivered:
         <table width="650" id="table_display" >
           <tr>
             <td width="298" height="26" align="left" valign="top">Item</td>
             <td width="106" align="left" valign="top">Group</td>
             <td width="50" align="left" valign="top">Unit</td>
             <td width="56" align="left" valign="top">Quantity</td>
             <td width="56" align="left" valign="top">Replacement</td>
             <td colspan="2" align="center" valign="top">Batch codes</td>
           </tr>
           <?php
				$i=0;
				$sub_tot=0;
				$a5_total=0;
				 while ($i<$line_num){
					 $a0 = mysql_result($line_result, $i, "delivery_line_id");
					 $a1 = mysql_result($line_result, $i, "store_item_id");
					 $table_name = $_SESSION['db_prefix']."_store_items";
						$item_query = "SELECT item_name, unit, subCategory FROM $table_name WHERE store_item_id = '".$a1."' ";
						$item_result = mySQL_query($item_query);
						$a1a = mysql_result($item_result, 0, "item_name");
						$a3a = mysql_result($item_result, 0, "unit");
						$a4a = mysql_result($item_result, 0, "subCategory");
					 $a2 = mysql_result($line_result, $i, "quantity");
					 $a5 = mysql_result($line_result, $i, "batch_1");
					 $a6 = mysql_result($line_result, $i, "batch_2");
					 $a7 = mysql_result($line_result, $i, "replace_qty");
					 
			?>
           <tr>
             <td valign="top"><?php echo $a1a ?></td>
             <td valign="top"><?php echo $a4a ?></td>
             <td valign="top"><?php echo $a3a ?></td>
             <td valign="top"><?php echo $a2 ?></td>
             <td align="right" valign="top"><?php echo $a7 ?></td>
             <td width="56" align="center" valign="top"><?php echo $a5 ?></td>
             <td width="56" align="center" valign="top"><?php echo $a6 ?></td>
           </tr>
           <?php 
			   // $a6_total=$a6_total+$a6;
				$i++;
				 }
				 ?>
          
           <tr>
             <td valign="top">&nbsp;</td>
             <td valign="top">Pallets</td>
             <td valign="top">&nbsp;</td>
             <td valign="top"><?php echo $pallets ?></td>
             <td valign="top">&nbsp;</td>
             <td valign="top">&nbsp;</td>
             <td valign="top">&nbsp;</td>
           </tr>       
         </table>
         </div>
         <br>
<br>


    <table width="642" height="50" align="left" id="table_button_bar">
        <tr>
          <td width="117"><a href="tile_deliver_print.php?delivery_no=<?php echo $delivery_no ?>" target="_blank"><input type="button" name="print_button" id="print_button" value="Print" class="imagebutton"></a></td>
          <td width="115">&nbsp;</td>
          <td width="158" align="right"><input name="p" type="hidden" id="p" value="2" />
            <input name="s" type="hidden" id="s" value="2" />
            </span></td>
          <td width="66" align="right">&nbsp;</td>
          <td width="162" align="right"><input type="button" name="close_button" id="close_button" value="Close" class="imagebutton" onClick="MM_goToURL('parent','store_main.php?date=&subCatSelect=Tiles');return document.MM_returnValue" ></td>
        </tr>
      </table>

</div>
</div>    
  
</div>


</body>
<?php } else { ?>
<script> needToConfirm = false; </script>
<?php
    $_SESSION['denied_return'] = "store/store_main.php?date=0&subCatSelect=Tiles";	?>
<body onLoad="accessdenied(); return false">
</body>
<?php }
?>
<?php include ('../navigation/side_bar.php'); ?>