<?php 
if ($_SESSION['order_no']=='') {
?>
<script language="javascript" type="text/javascript">
          needToConfirm = false;
          window.location="store_no_return.php";
</script>
<?php
}
else {
$cust_id = $_SESSION['cust_id']; 
	
$table_name = $_SESSION['db_prefix']."_order_lines";
$line_query = "SELECT *  FROM $table_name WHERE order_no = '".$_SESSION['order_no']."'";
$line_result = mySQL_query($line_query);
$line_num = mysql_num_rows($line_result);	


?>
</head>
<?php include('../include/wait.php') ?>

<body onLoad="MM_showHideLayers('wait','','hide')" onFocus="MM_showHideLayers('wait','','hide');"  onBlur="MM_showHideLayers('wait','','hide');">
<div class="wizard_page_middle_frame">
<div class="wizard_frame">
<?php 
	include ('../include/customer_block.php');
?><br>

<table width="650" id="table_display" >
  <tr>
    <td width="135">Delivery date:</td>
    <td width="125"><?php echo date("d-m-Y", strtotime($_SESSION['deliver_date'])) ?></td>
    <td width="98">Time:</td>
    <td width="272"><?php echo $_SESSION['hour'].':'.$_SESSION['min'] ?> </td>
  </tr>
  <tr>
    <td>Delivery address:</td>
    <td colspan="3"><?php echo $_SESSION['delivery_address'] ?></td>
    </tr>
  <tr>
    <td>Deliver vehicle reg:</td>
    <td><?php echo $_SESSION['vehicle'] ?></td>
    <td>Delivered by:</td>
    <td><?php echo $_SESSION['driver'] ?></td>
  </tr>
</table>

</div>

<form id="feedbackform" method="get" action="deliver_tilesWiz6.php" >
<div class="wizard_frame">
  <table width="650" id="table_display" >
    <tr>
      <td height="26" colspan="2" align="left" valign="top">Item</td>
      <td width="136" align="center" valign="top">Group</td>
      <td width="86" align="center" valign="top">Deliver</td>
      <td width="86" align="center" valign="top">Relacement</td>
      <td colspan="2" align="center" valign="top">Batch codes</td>
      </tr>
    <?php
				$i=0;
				
				 while ($i<$line_num){
					 $a0 = mysql_result($line_result, $i, "order_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");
					
					 $a6 = mysql_result($line_result, $i, "quantity");
					 $a5 = mysql_result($line_result, $i, "delivered");
					
				
					$table_name = $_SESSION['db_prefix']."_tile_deliver_lines_temp";
					$quantity_query = "SELECT quantity, batch_1, batch_2, replace_qty FROM $table_name WHERE order_reference = '".$_SESSION['order_reference']."' AND store_item_id = '".$a1."' AND user_name = '".$_SESSION['username']."'"; 
					$quantity_result = mySQL_query($quantity_query);
					$quantity_num = mysql_num_rows($quantity_result);
					if ( $quantity_num> 0) {
					        $a8 = mysql_result($quantity_result, 0, "quantity");
							$a9 = mysql_result($quantity_result, 0, "batch_1");
							$a10 = mysql_result($quantity_result, 0, "batch_2");
							$a11 = mysql_result($quantity_result, 0, "replace_qty");
					}
					else { 
					$a8 = '';
					$a9 = '';
					$a10 = '';
					$a11 = '';
					}
					 
				 ?>
    <tr>
      <td colspan="2" valign="middle"><?php echo $a1a ?>
        <input type="hidden" name="store_item_id<?php echo $i?>" id="store_item_id<?php echo $i?>" value="<?php echo $a1 ?>"></td>
      <td valign="middle"><?php echo $a4a ?></td>
      <td align="right" valign="middle"><?php echo $a8 ?></td>
      <td align="right" valign="middle"><?php echo $a11 ?></td>
      <td width="46" align="center" valign="middle"><?php echo $a9 ?></td>
      <td width="42" align="center" valign="middle"><?php echo $a10 ?></td>
    </tr>
    <?php 
			   // $a6_total=$a6_total+$a6;
				$i++;
				 }
				 ?>
    <?php 
	$table_name = $_SESSION['db_prefix']."_tile_deliver_lines_temp";
					$quantity_query = "SELECT pallets  FROM $table_name WHERE order_reference = '".$_SESSION['order_reference']."' AND pallets > 0 AND user_name = '".$_SESSION['username']."'"; 
					$quantity_result = mySQL_query($quantity_query);
					$quantity_num = mysql_num_rows($quantity_result);
					if ( $quantity_num> 0) {
					        $a9 = mysql_result($quantity_result, 0, "pallets");
					}
					else { 
					$a9 = '';
					}
	?>             
    <tr>
      <td colspan="2" align="left" valign="middle"> Pallets</td>
      <td align="left" valign="middle"><input name="pallets_text" type="hidden" value="<?php echo $a9 ?>"></td>
      <td align="right" valign="middle"><?php echo $a9 ?></td>
      <td align="right" valign="middle">&nbsp;</td>
      <td align="right" valign="middle">&nbsp;</td>
      <td align="right" valign="middle">&nbsp;</td>
    </tr>
  </table>
  <br>
    <br>
<br>
</div>
    <div class="wizard_frame">
      <input name="s" type="hidden" id="s" value="4" />
          <input name="p" type="hidden" id="p" value="4" />
          <label class="label_std">If you want to make changes use the 'Prev' button to go back. <br />
            Click 'New' to make a new entry or to finish the wizard click 'Finish'.</label>
        </div>
        <div class="wizard_frame">
      <table width="590" height="50" align="center" id="table_button_bar">
          <tr>
            <td width="117"><input type="button" name="lastprev_button" class="imagebutton" value="Prev" onClick="needToConfirm = false;   MM_showHideLayers('wait','','show'); MM_goToURL('parent','deliver_tilesWizbase.php?s=&p=2');return document.MM_returnValue" /></td>
            <td width="115">&nbsp;</td>
            <td width="99"><input name="cancelbutton" type="button" class="imagebutton" id="cancelbutton" onClick="javascript:cancel_confirmation(1, '../store/store_main.php?date=0&subCatSelect=Tiles'); needToConfirm = false;" value="Cancel" /></td>
            <td width="125"><input type="submit" name="new_button" class="imagebutton" id="new_button" value="New" onClick="needToConfirm = false; MM_showHideLayers('wait','','show');" /></td>
            <td width="110"><input  name="finish_button" type="submit" class="imagebutton" id="finish_button" value="Finish" onClick="needToConfirm = false; MM_showHideLayers('wait','','show');"  /></td>
          </tr>
        </table>
        </div>
  
  
</form>
</div>


<?php
}
?>