<head>

<!--style sheets-->


<!--jscript-->
<script language="JavaScript" src="../jscript/numbers_only_decimal.js"  type="text/javascript"></script>  
<script>
    $(document).ready(function(){
        //iterate through each textboxes and add keyup
        //handler to trigger sum event
        $(".text100").each(function() {
             $(this).keyup(function(){
                calculateSum();
            });
        });
 
    });
 
    function calculateSum() {
         var sum = 0;
        //iterate through each textboxes and add the values
        $(".text100").each(function() {
             //add only if the value is number
            if(!isNaN(this.value) && this.value.length!=0) {
                sum += parseFloat(this.value);
            }
         });
        //.toFixed() method will roundoff the final sum to 2 decimal places
        $("#sum").html(sum.toFixed(2));
		
    }
</script>
<script>
    $(document).ready(function(){
        //iterate through each textboxes and add keyup
        //handler to trigger sum event
        $(".text100a").each(function() {
             $(this).keyup(function(){
                calculateSum2();
            });
        });
 
    });
 
    function calculateSum2() {
         var sum2 = 0;
        //iterate through each textboxes and add the values
        $(".text100a").each(function() {
             //add only if the value is number
            if(!isNaN(this.value) && this.value.length!=0) {
                sum2 += parseFloat(this.value);
            }
         });
        //.toFixed() method will roundoff the final sum to 2 decimal places
        $("#sum2").html(sum2.toFixed(2));
		
    }
</script>
<?php

$table_name = $_SESSION['db_prefix']."_store_items";
$timber_query = "SELECT store_item_id, item_name, class, width, depth, length FROM $table_name WHERE subCategory='Timber' AND class='S5' AND width > '75' GROUP BY width";
$timber_result = mySQL_query($timber_query);
$timber_num = mysql_num_rows($timber_result);

$table_name = $_SESSION['db_prefix']."_store_items";
$timber2_query = "SELECT store_item_id, item_name, class, width, depth, length FROM $table_name WHERE subCategory='Timber' AND class='S7' GROUP BY width";
$timber2_result = mySQL_query($timber2_query);
$timber2_num = mysql_num_rows($timber2_result);

?>
</head>
<?php include('../include/wait.php') ?>
<link href="../css/wait.css" rel="stylesheet" type="text/css">

<body onLoad="MM_showHideLayers('wait','','hide'); calculateSum();" onFocus="MM_showHideLayers('wait','','hide'); calculateSum2();"  >
<div class="page_middle_frame">
<form action="captureJobWizbase.php?p=4&s=3" method="post">
  <table id="tableMain" width="595">
    <!--begin of tableMain-->
    <tr>
      <td><!--center of tableMain-->
        
        <div class="wizard_frame" onMouseOver="calculateSum()" onMouseMove="calculateSum2()";  >
          <table width="600" border="0" >
            <tr>
              <td width="125" height="37"><label class="label_std">timber item</label></td>
              <td colspan="3"><label class="label_std">total length in m</label></td>
            </tr>
            <?php 
				  $i=0;
				  $_SESSION['list_1'] = $timber_num;
				  while ($i<$timber_num) {
						$width = mysql_result($timber_result, $i, "width");  
						$depth = mysql_result($timber_result, $i, "depth");
						$class = mysql_result($timber_result, $i, "class");
						$_SESSION['timber_width_'.$i] = $width;
						$_SESSION['timber_depth_'.$i] = $depth;
						$_SESSION['timber_class_'.$i] = $class;
						$_SESSION['type_'.$i]=$depth."x".$width." (".$class.")";
						
						$table_name = $_SESSION['db_prefix']."_timber_meter_price";
						$meter_price_query = "SELECT price FROM $table_name WHERE timber = '".$_SESSION['type_'.$i]."'  ";
						$meter_price_result = mySQL_query($meter_price_query);
						$_SESSION['meter_price_'.$i] = mysql_result($meter_price_result, 0, "price");
				 ?>
            <tr>
              <td><label class="label_std" ><?php echo $_SESSION['type_'.$i] ?></label></td>
              <td colspan="3"><label for="textfield"></label>
                <input name="length_text_<?php echo $i?>" type="text" class="text100" id="length_text_<?php echo $i?>" style="text-align:right" onKeyPress="return isNumberKey(event)" onChange=" this.value = this.value.replace (/(\...).*/, '$1')" value="<?php echo $_SESSION['length_'.$i] ?>"  onMouseOut="calculateSum()" onMouseOver="calculateSum()" autocomplete="off" autofocus>
                &nbsp;&nbsp;
                <label class="label_std">m</label></td>
            </tr>
            <?php
			  $i++;
             }
             ?>
            <tr id="summation2">
              <td>&nbsp;</td>
              <td width="206" align="right"><label class="label_std">Total S5</label></td>
              <td width="66" align="right"><label class="label_std">
                <label class="txt3"><span id="sum">0</span></label>
                &nbsp;m
                </label></td>
              <td width="185" align="right"><label class="label_std">Estimated:&nbsp;&nbsp;<?php echo number_format($_SESSION['S5'], 2, '.', ',') ?> m</label></td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td colspan="3">&nbsp;</td>
            </tr>
            <?php 
				  $j=0;
				  $_SESSION['list_2'] = $timber2_num; 
				  while ($j<$timber2_num) {
						$width2 = mysql_result($timber2_result, $j, "width");  
						$depth2 = mysql_result($timber2_result, $j, "depth");
						$class2 = mysql_result($timber2_result, $j, "class");
						$_SESSION['timber2_width_'.$j] = $width2;
						$_SESSION['timber2_depth_'.$j] = $depth2;
						$_SESSION['timber2_class_'.$j] = $class2;
						$_SESSION['type2_'.$j]=$depth2."x".$width2." (".$class2.")";
						
						$table_name = $_SESSION['db_prefix']."_timber_meter_price";
						$meter_price_query = "SELECT price FROM $table_name WHERE timber = '".$_SESSION['type2_'.$j]."'  ";
						$meter_price_result = mySQL_query($meter_price_query);
						$_SESSION['meter_price2_'.$j] = mysql_result($meter_price_result, 0, "price");
				 ?>
            <tr>
              <td><label class="label_std"><?php echo $_SESSION['type2_'.$j] ?></label></td>
              <td colspan="3"><label for="textfield"></label>
                <input name="length2_text_<?php echo $j?>" type="text" class="text100a" id="length2_text_<?php echo $j?>" style="text-align:right" onKeyPress="return isNumberKey(event)" onChange=" this.value = this.value.replace (/(\...).*/, '$1')" value="<?php echo $_SESSION['length2_'.$j] ?>" onMouseOut="calculateSum2()" onMouseOver="calculateSum2()" autocomplete="off" onBlur="<?php if ($j==$timber2_num-1) { ?> document.getElementById('next_button').focus();<?php } ?>">
                &nbsp;&nbsp;
                <label class="label_std">m</label></td>
            </tr>
            <?php
			  $j++;
             }
             ?>
            <tr id="summation">
              <td>&nbsp;</td>
              <td align="right"><label class="label_std">Total S7</label></td>
              <td align="right"><label class="label_std">
                <label class="txt3"><span id="sum2">0</span></label>
                &nbsp;m
                </label></td>
              <td align="right"><label class="label_std">Estimated:&nbsp;&nbsp;<?php echo number_format($_SESSION['S7'], 2, '.', ',') ?> m</label></td>
            </tr>
          </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=2');return document.MM_returnValue" /></td>
            <td width="115">&nbsp;</td>
            <td width="99"><input name="p" type="hidden" id="p" value="3" />
              <input name="s" type="hidden" id="s" value="3" /></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>
<script>
    $(document).ready(function(){
        //iterate through each textboxes and add keyup
        //handler to trigger sum event
        $(".text100").each(function() {
             $(this).keyup(function(){
                calculateSum();
            });
        });
 
    });
	
	$(document).ready(function(){
        //iterate through each textboxes and add keyup
        //handler to trigger sum event
        $(".text100").each(function() {
             $(this).mousedown(function(){
                calculateSum();
            });
        });
 
    });
 
    function calculateSum() {
         var sum = 0;
        //iterate through each textboxes and add the values
        $(".text100").each(function() {
             //add only if the value is number
            if(!isNaN(this.value) && this.value.length!=0) {
                sum += parseFloat(this.value);
            }
         });
        //.toFixed() method will roundoff the final sum to 2 decimal places
        $("#sum").html(sum.toFixed(2));
		
    }
</script> 
<script>
    $(document).ready(function(){
        //iterate through each textboxes and add keyup
        //handler to trigger sum event
        $(".text100a").each(function() {
             $(this).keyup(function(){
                calculateSum2();
            });
        });
 
    });
	
	$(document).ready(function(){
        //iterate through each textboxes and add keyup
        //handler to trigger sum event
        $(".text100a").each(function() {
             $(this).mousedown(function(){
                calculateSum2();
            });
        });
 
    });
 
    function calculateSum2() {
         var sum2 = 0;
        //iterate through each textboxes and add the values
        $(".text100a").each(function() {
             //add only if the value is number
            if(!isNaN(this.value) && this.value.length!=0) {
                sum2 += parseFloat(this.value);
            }
         });
        //.toFixed() method will roundoff the final sum to 2 decimal places
        $("#sum2").html(sum2.toFixed(2));
	}
</script>
</body>
