<head>

<!--jscript-->
<script language="JavaScript" src="../jscript/numbers_only.js"  type="text/javascript"></script>  

<?php

$table_name = $_SESSION['db_prefix']."_list_bracing";
$bracing_query = "SELECT * FROM $table_name ORDER BY item_name  ";
$bracing_result = mySQL_query($bracing_query);
$bracing_num = mysql_num_rows($bracing_result);

$table_name = $_SESSION['db_prefix']."_list_sundries";
$sundries_query = "SELECT * FROM $table_name ORDER BY item_name  ";
$sundries_result = mySQL_query($sundries_query);
$sundries_num = mysql_num_rows($sundries_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 name='form1' action="captureJobWizbase.php?p=6&s=5" method="post">
<table id="tableMain" width="595">
    <!--begin of tableMain-->
    <tr>
      <td><!--center of tableMain-->
         <div class="scroll_frame_medium" style="height:340px; width:640px;">
           <table width="600" border="0">
             <tr>
               <td colspan="2"><label class="label_std">Bracing</label></td>
               <td>&nbsp;</td>
             </tr>
             <?php 
			 $j=0;
			 $_SESSION['list_5a'] = $bracing_num;
			 while ($j<$bracing_num) {
				 $bracing_name = mysql_result($bracing_result, $j, "item_name");
				 $bracing_depth = mysql_result($bracing_result, $j, "depth");
				 $bracing_width = mysql_result($bracing_result, $j, "width");
				 $bracing_class = mysql_result($bracing_result, $j, "class");
				 $_SESSION['bracing_type_'.$j]=$bracing_depth."x".$bracing_width." (".$bracing_class.")";
				 
				 $table_name = $_SESSION['db_prefix']."_timber_meter_price";
				 $meter_price_query = "SELECT price FROM $table_name WHERE timber = '".$_SESSION['bracing_type_'.$j]."'  ";
				 $meter_price_result = mySQL_query($meter_price_query);
				 $meter_price_num = mysql_num_rows($meter_price_result);
				 if ($meter_price_num!=0) {
					 	 $_SESSION['bracing_meter_price_'.$j] = mysql_result($meter_price_result, 0, "price");
				 }
				 else {
					     $_SESSION['bracing_meter_price_'.$j]=0;
				 }
				 
				 
			 ?>
             <tr>
               <td width="244"><?php echo $bracing_name ?>
                 <input type="hidden" name="bracing_name.<?php echo $j ?>" id="bracing_name.<?php echo $j ?>" value="<?php echo $bracing_name ?>" />
                 <input type="hidden" name="bracing_depth.<?php echo $j ?>" id="bracing_depth.<?php echo $j ?>" value="<?php echo $bracing_depth ?>" />
                 <input type="hidden" name="bracing_width.<?php echo $j ?>" id="bracing_width.<?php echo $j ?>" value="<?php echo $bracing_width ?>" />
                 <input type="hidden" name="bracing_class.<?php echo $j ?>" id="bracing_class.<?php echo $j ?>" value="<?php echo $bracing_class ?>" /></td>
               <td width="146"><label for="textfield"></label>
                 <input name="bracing_qty.<?php echo $j ?>" type="text" class="text60" id="bracing_qty.<?php echo $j ?>" value="<?php echo $_SESSION['bracing_qty_'.$j]?>" onKeyPress="return numbersonly(this, event)" style="text-align:right" autocomplete="off" autofocus/>
                 <label class="label_std">m</label></td>
               <td width="196">&nbsp;</td>
             </tr>
             <?php
			 $j++;
			 }
			 ?>
             <tr>
               <td colspan="2">&nbsp;</td>
               <td>&nbsp;</td>
             </tr>
             <tr>
               <td colspan="2"><label class="label_std">Sundry Timbers</label></td>
               <td>&nbsp;</td>
             </tr>
             <?php 
			 $k=0;
			 $_SESSION['list_5b'] = $sundries_num;
			 while ($k<$sundries_num) {
				 $sundries_name = mysql_result($sundries_result, $k, "item_name");
				 $sundries_depth = mysql_result($sundries_result, $k, "depth");
				 $sundries_width = mysql_result($sundries_result, $k, "width");
				 $sundries_class = mysql_result($sundries_result, $k, "class");
				 $_SESSION['sundries_type_'.$k]=$sundries_depth."x".$sundries_width." (".$sundries_class.")";
				 
				 $table_name = $_SESSION['db_prefix']."_timber_meter_price";
				 $meter_price_query = "SELECT price FROM $table_name WHERE timber = '".$_SESSION['sundries_type_'.$k]."'  ";
				 $meter_price_result = mySQL_query($meter_price_query);
				 $meter_price_num = mysql_num_rows($meter_price_result);
				 if ($meter_price_num!=0) {
					 	 $_SESSION['sundries_meter_price_'.$k] = mysql_result($meter_price_result, 0, "price");
				 }
				 else {
					     $_SESSION['sundries_meter_price_'.$k]=0;
				 }
				 
			 ?>
             <tr>
               <td width="244"><?php echo $sundries_name ?>
                 <input type="hidden" name="sundries_name.<?php echo $k ?>" id="sundries_name.<?php echo $k ?>" value="<?php echo $sundries_name ?>" />
                 <input type="hidden" name="sundries_depth.<?php echo $k ?>" id="sundries_depth.<?php echo $k ?>" value="<?php echo $sundries_depth ?>" />
                 <input type="hidden" name="sundries_width.<?php echo $k ?>" id="sundries_width.<?php echo $k ?>" value="<?php echo $sundries_width ?>" />
                 <input type="hidden" name="sundries_class.<?php echo $k ?>" id="sundries_class.<?php echo $k ?>" value="<?php echo $sundries_class ?>" /></td>
               <td width="146"><input name="sundries_qty.<?php echo $k ?>" type="text" class="text60" id="sundries_qty.<?php echo $k ?>" value="<?php echo $_SESSION['sundries_qty_'.$k]?>" onKeyPress="return numbersonly(this, event)" style="text-align:right" autocomplete="off"onblur="<?php if ($k==$sundries_num-1) { ?> document.getElementById('next_button').focus();<?php } ?>">
                 <label class="label_std">m</label></td>
               <td width="196">&nbsp;</td>
             </tr>
             <?php
			 $k++;
			 }
			 ?>
           </table>
         </div>
      </td>
      </tr>
      <tr>
      <td><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','captureJobWizbase.php?s=&amp;p=4');return document.MM_returnValue" /></td>
          <td width="115">&nbsp;</td>
          <td width="99"><input name="p" type="hidden" id="p" value="5" />
            <input name="s" type="hidden" id="s" value="5" />
            </span></td>
          <td width="125" align="right"><input name="cancelbutton" type="button" class="imagebutton" id="cancelbutton" onClick="needToConfirm = false; cancel_confirmation(1, '../production/production_main.php');" value="Cancel" /></td>
          <td width="110" align="right"><input type="submit" name="next_button" id="next_button" class="imagebutton" value="Next" tabindex="0" onClick="needToConfirm = false; MM_showHideLayers('wait','','show')" /></td>
        </tr>
      </table></td>
      </tr>
      </table>
</form>
</div>
</body>      