
<head>
<script type="text/javascript" src="../jscript/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="../css/wizard.css" />

<?php

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

$job_no = $_SESSION['job_no'];
$quote='no';
$table_name = $_SESSION['db_prefix']."_captured_jobs";
$job_query = "SELECT * FROM $table_name WHERE job_no = '".$job_no."' ";
$job_result = mySQL_query($job_query);
$cust_id = mysql_result($job_result, 0, "cust_id");	

$table_name = $_SESSION['db_prefix']."_captured_jobs";
$job_query = "SELECT *  FROM $table_name WHERE job_no = '".$_SESSION['job_no']."' ";
$job_result = mySQL_query($job_query);
$designer=mysql_result($job_result, 0, "designer");
$quote_note=mysql_result($job_result, 0, "quote_note");

$table_name = $_SESSION['db_prefix']."_supply_customer_temp";
$trusses_query = "SELECT job_no, truss_type, timber_type, quantity, user FROM $table_name WHERE job_no = '".$_SESSION['job_no']."' AND timber_type = 'Trusses' AND user =  '".$_SESSION['username']."' AND quantity > 0 ";
$trusses_result = mySQL_query($trusses_query);
$trusses_num = mysql_num_rows($trusses_result);


$table_name = $_SESSION['db_prefix']."_supply_customer_temp";
$summary_query = "SELECT * FROM $table_name WHERE job_no = '".$_SESSION['job_no']."' AND truss_type = 'bracing' AND user =  '".$_SESSION['username']."' AND quantity > 0";
$summary_result = mySQL_query($summary_query);
$summary_num = mysql_num_rows($summary_result);
//echo '<br>'.$summary_query;

$table_name = $_SESSION['db_prefix']."_supply_customer_temp";
$summary2_query = "SELECT * FROM $table_name WHERE job_no = '".$_SESSION['job_no']."' AND truss_type = 'sundries' AND user =  '".$_SESSION['username']."' AND quantity > 0";
$summary2_result = mySQL_query($summary2_query);
$summary2_num = mysql_num_rows($summary2_result);
//echo '<br>'.$summary_query;

$table_name = $_SESSION['db_prefix']."_supply_customer_temp";
$summary3_query = "SELECT * FROM $table_name WHERE job_no = '".$_SESSION['job_no']."' AND truss_type = 'laminated' AND user =  '".$_SESSION['username']."' AND quantity > 0";
$summary3_result = mySQL_query($summary3_query);
$summary3_num = mysql_num_rows($summary3_result);


$table_name = $_SESSION['db_prefix']."_supply_customer_temp";
$mitek_query = "SELECT job_no, truss_type, store_item_id, timber_type, quantity, user, extra FROM $table_name WHERE job_no = '".$_SESSION['job_no']."' AND truss_type = 'Mitek' AND user =  '".$_SESSION['username']."' AND quantity > 0";
$mitek_result = mySQL_query($mitek_query);
$mitek_num = mysql_num_rows($mitek_result);

$table_name = $_SESSION['db_prefix']."_supply_customer_temp";
$additional_query = "SELECT job_no, truss_type, store_item_id, timber_type, quantity, user, extra FROM $table_name WHERE job_no = '".$_SESSION['job_no']."' AND truss_type = 'Additional' AND user =  '".$_SESSION['username']."' AND quantity > 0";
$additional_result = mySQL_query($additional_query);
$additional_num = mysql_num_rows($additional_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="page_middle_frame">
<form id="feedbackform" method="get" action="deliverJobWiz8.php" >
<div class="wizard_frame">
<?php 
		include ('../include/customer_block.php');
		echo '<br>';
		include ('../include/job_block.php')
		?>
</div>
  <div class="wizard_frame">
          <table width="646" align="left" id="table_details_display" >
              <tr>
                <td width="136" align="left" valign="top"></td>
                <td colspan="3" align="left" valign="top"></td>
              </tr>
             <tr>
                <td align="left" valign="top">Delivery address:</td>
                <td width="215" align="left" valign="top"><?php echo $_SESSION['delivery_address']; ?></td>
                <td width="92" align="left" valign="top">Time:</td>
                <td width="183" align="left" valign="top"><?php echo $_SESSION['hour'].":".$_SESSION['min']; ?></td>
            </tr>
             <tr>
               <td align="left" valign="top">Vehicle:</td>
               <td align="left" valign="top"><?php echo $_SESSION['vehicle']; ?></td>
               <td align="left" valign="top">Driver:</td>
               <td align="left" valign="top"><?php echo $_SESSION['driver']; ?></td>
             </tr>
    </table><br>
<br>
<br>
<br>
<br>
<br>

    <table width="646" align="left" id="table_details_display_grey" > 
              <tr >
                <td width="350" align="left" valign="top"><b>
                  <label class="label_std">Item</label>
                </b></td>
                <td width="96" align="left" valign="top"><b>Deliver qty</b></td>
                <td width="184" align="left" valign="top"><b>Deliver mtrs</b></td>
              </tr>
           
               
    </table>
  </div>
<?php if ($trusses_num!=0) { ?>
<div class="wizard_frame">
  <table width="646" align="left" id="table_details_display" > 
              <tr style="border-bottom-style:double;">
                <td colspan="2" align="left" valign="top"><label class="label_std">Trusses:</label></td>
              </tr>
              <?php 
				  $i=0;
				  
				  while ($i<$trusses_num) {
				  		$a1 = mysql_result($trusses_result, $i, "truss_type");
						$a2 = mysql_result($trusses_result, $i, "quantity"); 			
				 ?>
             <tr>
               <td width="350"><?php echo $a1 ?></td>
               <td width="284"><?php echo $a2 ?>&nbsp;no</td>
             </tr>
             <?php
			  $i++;
             }
             ?>
               
    </table>
</div>
<?php } 
if ($summary_num!=0) {?>
  <div class="wizard_frame">
 <table width="646" align="left" id="table_details_display" > 
              <tr>
                <td colspan="4" align="left" valign="top" ><label class="label_std">Bracing timber:</label></td>
              </tr>
               <?php 
				  $k=0;
				  $temp_name='';
				  while ($k<$summary_num) { 
					    $c1 = mysql_result($summary_result, $k, "timber_type");
						$c2 = mysql_result($summary_result, $k, "store_item_id");
						$table_name = $_SESSION['db_prefix']."_store_items";
							$name_query = "SELECT length FROM $table_name WHERE  store_item_id = '".$c2."' ";
							$name_result = mySQL_query($name_query);
							$c2a = mysql_result($name_result, 0, "length");
						$c3 = mysql_result($summary_result, $k, "tot_length"); 
						$c4 = mysql_result($summary_result, $k, "quantity"); 
						$c5 = mysql_result($summary_result, $k, "extra"); 
						
						
				 ?>
             <tr <?php if ( $temp_name!=$c1) {?>style="border-top:double;"<?php } ?><?php if ($c5=='yes') { ?> bgcolor="#FFE1D2" <?php } ?>>
               <td width="235"><?php if ($temp_name!=$c1) echo $c1; ?>
                  <?php $temp_name=$c1;?></td>
               <td width="111"><?php echo $c2a ?></td>
               <td width="96"><?php echo $c4 ?> no</td>
               <td width="184"><?php echo $c3 ?>&nbsp;m</td>
             </tr>
              <?php
			  $k++;
             }
             ?>
    </table> <br>
 </div>
 <?php } 
if ($summary2_num!=0) {?>
 <div class="wizard_frame">
 <table width="646" align="left" id="table_details_display" >
   <tr>
     <td colspan="4" align="left" valign="top"><label class="label_std">Sundries timber:</label></td>
   </tr>
   <?php 
				  $k=0;
				  $temp_name='';
				  while ($k<$summary2_num) { 
					    $c1 = mysql_result($summary2_result, $k, "timber_type");
						$c2 = mysql_result($summary2_result, $k, "store_item_id");
						$table_name = $_SESSION['db_prefix']."_store_items";
							$name_query = "SELECT length FROM $table_name WHERE  store_item_id = '".$c2."' ";
							$name_result = mySQL_query($name_query);
							$c2a = mysql_result($name_result, 0, "length");
						$c3 = mysql_result($summary2_result, $k, "tot_length"); 
						$c4 = mysql_result($summary2_result, $k, "quantity"); 
						$c5 = mysql_result($summary2_result, $k, "extra");  
						
				 ?>
   <tr <?php if ( $temp_name!=$c1) {?>style="border-top:double;"<?php } ?><?php if ($c5=='yes') { ?> bgcolor="#FFE1D2" <?php } ?>>
     <td width="235"><?php if ($temp_name!=$c1) echo $c1; ?>
       <?php $temp_name=$c1;?></td>
     <td width="111"><?php echo $c2a ?></td>
     <td width="96"><?php echo $c4 ?> no</td>
     <td width="184"><?php echo $c3 ?>&nbsp;m</td>
   </tr>
   <?php
			  $k++;
             }
             ?>
 </table>
 <br>
<br>
</div>
<?php } 
if ($summary3_num!=0) {?>
 <div class="wizard_frame">
 <table width="646" align="left" id="table_details_display" >
   <tr>
     <td colspan="4" align="left" valign="top"><label class="label_std">Laminated beams:</label></td>
   </tr>
   <?php 
				  $k=0;
				  $temp_name='';
				  while ($k<$summary3_num) { 
					    $c1 = mysql_result($summary3_result, $k, "timber_type");
						$c2 = mysql_result($summary3_result, $k, "store_item_id");
						$table_name = $_SESSION['db_prefix']."_store_items";
							$name_query = "SELECT length FROM $table_name WHERE  store_item_id = '".$c2."' ";
							$name_result = mySQL_query($name_query);
							$c2a = mysql_result($name_result, 0, "length");
						$c3 = mysql_result($summary3_result, $k, "tot_length"); 
						$c4 = mysql_result($summary3_result, $k, "quantity"); 
						$c5 = mysql_result($summary3_result, $k, "extra");  
						
				 ?>
   <tr <?php if ( $temp_name!=$c1) {?>style="border-top:double;"<?php } ?><?php if ($c5=='yes') { ?> bgcolor="#FFE1D2" <?php } ?>>
     <td width="235"><?php if ($temp_name!=$c1) echo $c1; ?>
       <?php $temp_name=$c1;?></td>
     <td width="111"><?php echo $c2a ?></td>
     <td width="96">&nbsp;</td>
     <td width="184"><?php echo $c3 ?>&nbsp;m</td>
   </tr>
   <?php
			  $k++;
             }
             ?>
 </table>
 <br>
<br>
</div>
<?php } 

if ($mitek_num!=0) {?>
  <div class="wizard_frame">
    <table width="646" align="left" id="table_details_display"  > 
              <tr style="border-bottom-style:double;" >
                <td colspan="2" align="left" valign="top" ><label class="label_std">Mitek products:</label></td>
              </tr>
               <?php 
				  $j=0;
				  while ($j<$mitek_num) { 
					    $b1 = mysql_result($mitek_result, $j, "timber_type");
						$b2 = mysql_result($mitek_result, $j, "store_item_id");
							$table_name = $_SESSION['db_prefix']."_store_items";
							$name_query = "SELECT item_name FROM $table_name WHERE  store_item_id = '".$b2."' ";
							$name_result = mySQL_query($name_query);
							$b2a = mysql_result($name_result, 0, "item_name");
						$b3 = mysql_result($mitek_result, $j, "quantity");  
						$b4 = mysql_result($mitek_result, $j, "extra"); 
						
				 ?>
             <tr <?php if ($b4=='yes') { ?> bgcolor="#FFE1D2" <?php } ?>>
               <td width="350" ><?php echo $b2a ?></td>
               <td width="284"><?php echo $b3 ?>&nbsp;no</td>
             </tr>
              <?php
				
			  $j++;
             }
             ?>
           </table></div>
<?php } 
if ($additional_num!=0) {?>        
  <div class="wizard_frame">
 <table width="646" align="left" id="table_details_display" > 
              <tr style="border-bottom-style:double;">
                <td colspan="2" align="left" valign="top"><label class="label_std">Additional sundries:</label></td>
              </tr>
               <?php 
				  $n=0;
				  while ($n<$additional_num) { 
					    $e1 = mysql_result($additional_result, $n, "timber_type");
						$e2 = mysql_result($additional_result, $n, "store_item_id");
						$table_name = $_SESSION['db_prefix']."_store_items";
							$name_query = "SELECT item_name FROM $table_name WHERE  store_item_id = '".$e2."' ";
							$name_result = mySQL_query($name_query);
							$e2a = mysql_result($name_result, 0, "item_name");
						$e3 = mysql_result($additional_result, $n, "quantity"); 
						$e4 = mysql_result($additional_result, $n, "extra");  
						
				 ?>
             <tr <?php if ($e4=='yes') { ?> bgcolor="#FFE1D2" <?php } ?>>
               <td width="350"><?php echo $e2a ?></td>
               <td width="284"><?php echo $e3 ?>&nbsp;no</td>
             </tr>
              <?php
				
			  $n++;
             }
             ?>
             </table></div>
             <?php } ?>
              <br />
<br />

  <div class="wizard_frame">
              <label class="label_std">If you want to make changes use the 'Prev' button to go back. <br />
              To finish the wizard click 'Finish'.</label>
           </div>
       <div class="button_bar_frame">
              <table width="675" 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_goToURL('parent','deliverJobWizbase.php?s=&p=6'); return document.MM_returnValue; MM_showHideLayers('wait','','show');" tabindex="2" /></td>
                  <td width="115">
                    <input name="s" type="hidden" id="s" value="7" />
                    <input name="p" type="hidden" id="p" value="7" /></td>
                  <td width="99">&nbsp;</td>
                  <td width="125" align="right"><input name="cancelbutton" type="button" class="imagebutton" id="cancelbutton" onClick="needToConfirm = false; cancel_confirmation(1, '../store/store_main.php');" value="Cancel"  tabindex="3"/></td>
                  <td width="110" align="right"><input  name="finish_button" type="submit" class="imagebutton" id="finish_button" value="Finish" onClick="needToConfirm = false; MM_showHideLayers('wait','','show');"   tabindex="1"/></td>
                </tr>
              </table>
              </div>
 
  
</form>
</div>

<?php
}
?>

