<head>
<?php 
if ($_SESSION['comp_name']=='') {
?>
<script language="javascript" type="text/javascript">
          needToConfirm = false;
          window.location="orders_no_return.php";
</script>
<?php
}
else {

$table_name = $_SESSION['db_prefix']."_order_lines_temp";
$line_query = "SELECT *  FROM $table_name WHERE  user_name =  '".$_SESSION['username']."'";
$line_result = mySQL_query($line_query);
$line_num = mysql_num_rows($line_result);


	$table_name = $_SESSION['db_prefix']."_customer";
    $customer_query = "SELECT comp_name, bag_box, box_no, postal_place, phone, contact_1, email_1  FROM $table_name WHERE cust_id = '".$_SESSION['cust_id']."' ";
	$customer_result = mySQL_query($customer_query);
	
    $b1 = mysql_result($customer_result, 0, "comp_name");
	$b2 = mysql_result($customer_result, 0, "bag_box");
	$b3 = mysql_result($customer_result, 0, "box_no");
	$b4 = mysql_result($customer_result, 0, "postal_place");
	$b5 = mysql_result($customer_result, 0, "phone");
	$b6 = mysql_result($customer_result, 0, "contact_1");
	$b7 = mysql_result($customer_result, 0, "email_1");
	
	
?>
<script language="JavaScript" src="../jscript/format.min.js"  type="text/javascript"></script>

</head>
<?php include('../include/wait.php') ?>
<body onLoad="MM_showHideLayers('wait','','hide'); " onFocus="MM_showHideLayers('wait','','hide');"  onBlur="MM_showHideLayers('wait','','hide');">
<div class="page_middle_frame">
<form id="feedbackform" method="get" action="newOrderWiz6.php" >
  <table width=595 border="0" align="center" cellpadding="10" cellspacing="0" bordercolor="#0066FF" border-collapse="collapse">
     <tr>
            <td width="525" >
             Order details:
               <table width="670" id="table_details_display">
                <tr>
                  <td>Order no:</td>
                  <td><?php echo $_SESSION['order_no'] ?></td>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                </tr>
                <tr>
                  <td width="123">Delivery date:</td>
                  <td width="205"><strong><?php if ($_SESSION['delivery_date']!='2000-01-01') { echo date("d-m-Y", strtotime($_SESSION['delivery_date'])); }else { echo 't.b.a.';} ?></strong></td>
                  <td width="109">Order date:</td>
                  <td width="213"><strong><?php echo date("d-m-Y", strtotime($_SESSION['order_date'])) ?></strong></td>
                </tr>
                <tr>
                  <td><?php if ($_SESSION['deliver_collect']=='deliver') {echo 'Deliver to:';} else {echo 'To be collected.';} ?></td>
                  <td colspan="3"><?php echo $_SESSION['project_no'].'&nbsp;&nbsp;'.$_SESSION['project_place'] ?></td>
                 </tr>
                <tr>
                  <td>Contact:</td>
                  <td><?php echo $_SESSION['deliver_contact'] ?></td>
                  <td>Cell/phone:</td>
                  <td><?php echo $_SESSION['deliver_phone'] ?></td>
                </tr>
              </table>
            
            <br />
            Ordered by:
            
              <table width="670" id="table_details_display">
                <tr>
                  <td width="123">Name:</td>
                  <td colspan="3"><?php echo  $b1 ?></td>
                </tr>
                <tr>
                  <td>Contact person:</td>
                  <td width="205"><?php echo $b5 ?></td>
                  <td width="109">Phone/cell:</td>
                  <td width="213"><?php echo $b6 ?></td>
                </tr><br />


                <tr>
                  <td>Address:</td>
                  <td colspan="3"><?php echo $b2." ".$b3.", ".$b4?></td>
                </tr>
                <tr>
                  <td>Telephone:</td>
                  <td><?php echo $b5 ?></td>
                  <td>e-mail:</td>
                  <td><?php echo $b7 ?></td>
                </tr>
              </table>
            
<br />
               Order details:
                
              
              <br>
              
              <table width="662" id="table_display" >
                <tr>
                  <td width="358" height="26" align="left" valign="middle">Item</td>
                  <td width="106" align="center" valign="middle">Group</td>
                  <td width="66" align="center" valign="middle">Unit</td>
                  <td width="112" align="center" valign="middle">Quantity</td>
                </tr>
                <?php
				$i=0;
				$sub_tot=0;
				$a5_total=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");
					 $a2 = mysql_result($line_result, $i, "quantity");
					 $a3 = mysql_result($line_result, $i, "price");
					 
					$a5=$a2*$a3;
					$a5_total=$a5_total+$a5;
					 
				 ?>
                <tr>
                  <td valign="middle"><?php echo $a1a ?></td>
                  <td valign="middle"><?php echo $a4a ?></td>
                  <td valign="middle"><?php echo $a3a ?></td>
                  <td align="right" valign="middle"><?php echo number_format($a2, 0, '.', ',') ?></td>
                </tr>
                <?php 
			   // $a6_total=$a6_total+$a6;
				$i++;
				 }
				 ?>
                <tr>
                  <td colspan="3" align="left" valign="middle">Pallets</td>
                  <td align="right" valign="middle"><?php echo $_SESSION['pallets'] ?></td>
                </tr>
              </table>
              <br />
<br />

            <div class="wizard_frame">
              <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>
       </td>
           
    </tr>
    <tr>
    <td>
          
              <table width="675" height="50" align="center" id="table_button_bar">
                <tr>
                  <td width="117" valign="top"><input type="button" name="lastprev_button" class="imagebutton" value="Prev" onClick="needToConfirm = false;MM_showHideLayers('wait','','show');MM_goToURL('parent','newOrderWizbase.php?s=&amp;p=3');return document.MM_returnValue" /></td>
                  <td width="115" valign="top">
                    <input name="s" type="hidden" id="s" value="5" />
                    <input name="p" type="hidden" id="p" value="5" />
                  </td>
                  <td width="99" valign="top"><input name="cancelbutton" type="button" class="imagebutton" id="cancelbutton" onClick="needToConfirm = false; cancel_confirmation(1, '../store/store_main.php?date='); " value="Cancel" /></td>
                  <td width="255" align="right" valign="top"><input type="submit" name="new_button" class="imagebutton" id="new_button" value="New" onClick="needToConfirm = false; MM_showHideLayers('wait','','show');" onMouseDown="MM_showHideLayers('wait','','show');"  />
                      <td width="65" align="right" valign="top"><input  name="finish_button" type="submit" class="imagebutton" id="finish_button" value="Finish" onClick="needToConfirm = false;MM_showHideLayers('wait','','show')"  />                                        
              </table></td>
          </tr>
  </table>
 
  
</form>
<?php
}
?>
</div>
</body>

