<head>
<script language="javascript" src="../jscript/calendar.js"></script>
<?php
  
	
?>
</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="form1" method="get" action="receivingTimberWizbase.php">
  <table id="tableMain" width="595">
    <!--begin of tableMain-->
    <tr>
      <td><!--center of tableMain-->
        
        <table width=595 border="0" align="center" cellpadding="10" cellspacing="0" bordercolor="#0066FF" border-collapse="collapse">
          <tr>
            <td width="525" valign="top" ><div class="wizard_frame"><br />
                <table width="600" border="0">
                  <?php 
				  $i=0;
				 					  				
					  $table_name = $_SESSION['db_prefix']."_store_items";
					  $size_query = "SELECT store_item_id, width, depth, class FROM $table_name WHERE subCategory='timber' AND class='S5'  GROUP BY `depth`, `width` , `class`  ";
					  $size_result = mySQL_query($size_query);
					  $size_num = mysql_num_rows($size_result);
					 
					  $n=0;	
					  
					  while ($n<$size_num) {
						$width = mysql_result($size_result, $n, "width");  
						$depth = mysql_result($size_result, $n, "depth");
						$class = mysql_result($size_result, $n, "class");
						
						$table_name = $_SESSION['db_prefix']."_store_items";
						$name_query = "SELECT store_item_id, width, depth, length, class FROM $table_name WHERE subCategory='timber' AND width = '".$width."' AND depth = '".$depth."'  AND class='S5' ORDER BY length ASC";
						//echo $name_query;
						
						$name_result = mySQL_query($name_query);
						$name_num = mysql_num_rows($name_result);
					  ?>
                  <tr>
                    <td colspan="5">&nbsp;</td>
                  </tr>
                  <tr>
                    <td width="229" colspan="5"><label class="label_std" style="font-size:14px;"><?php echo $depth." x ".$width."&nbsp;(".$class.")" ?></label></td>
                  </tr>
                </table>
                <table  width="600" border="0">
                  <?php	
					  $d=0;    
					  $k=0;
					  
					  while ($k<$name_num) {
					  
					  ?>
                  <tr>
                    <?php
					  $c=0;
					  
					  while ($c<8) {
						  //echo ">>> c=".$c."  d=".$d;
						if ($d<$name_num) {  
						$a1 = mysql_result($name_result, $d, "store_item_id"); 
						
						//$a2 = mysql_result($name_result, 0, "item_name");
					  	//$a3 = mysql_result($name_result, $d, "checked"); 
						
					  	$a4 = mysql_result($name_result, $d, "width"); 
					  	$a5 = mysql_result($name_result, $d, "depth"); 
					  	$a6 = mysql_result($name_result, $d, "length");
						$a7 = mysql_result($name_result, $d, "class");
						$a3='no';
						$table_name = $_SESSION['db_prefix']."_receive_store_lines_temp";
						$check_query = "SELECT receive_line_id FROM $table_name WHERE user =  '".$_SESSION['username']."' AND store_item_id='".$a1."'  ";
						$check_result = mySQL_query($check_query);
						$check_num = mysql_num_rows($check_result);
						if ($check_num!=0) {
							$a3='yes';
						}
						//echo "<br>".$a7.$a1;
						$i++;
						}
						else {
							$a1 = "";
							//$a2 = "";
					  		$a3 = "";
					  		$a4 = "";
					  		$a5 = "";
					  		$a6 = "";
							$c++;
							$k++;
							$d++;
						}
					 
                    if ($d<$name_num) {  ?>
                    <td width='60' align="left"><input type="checkbox" name="<?php echo "check".$i ?>" id="<?php echo "check".$i ?>" value="<?php echo $a1 ?>" <?php if ($a3=='yes') { ?>  checked="checked" <?php } ?>  >
                      <?php  echo $a6; ?>
                      &nbsp;
                      <input type="hidden" name="<?php echo "item_no".$i ?>" id="<?php echo "item_no".$i ?>" value="<?php echo $a1 ?>">
                      &nbsp; </td>
                    <?php
					}
					else { ?>
                    <td width='60' align="left"></td>
                    <?php
					}
					$c++;
					$d++;
					  }
					  ?>
                  </tr>
                  <?php
				  $k++;
				  
				  	}  $d++;
				  $n++;
				  $_SESSION['list_no_2'] = $i+1;
				  }
				  
				  ?>
                </table>
                <br />
                <br />
                <br />
              </div>
              <br />
              <br>
              <br>
              <div class="wizard_frame"><br />
                <table width="600" border="0">
                  <?php 
				  $v=0;
				 					  				
					  $table_name = $_SESSION['db_prefix']."_store_items";
					  $size2_query = "SELECT store_item_id, width, depth, class FROM $table_name WHERE subCategory='timber' AND class='S7'  GROUP BY `depth`, `width` , `class`  ";
					  $size2_result = mySQL_query($size2_query);
					  $size2_num = mysql_num_rows($size2_result);
					 
					  $w=0;	
					  
					  while ($w<$size2_num) {
						$width = mysql_result($size2_result, $w, "width");  
						$depth = mysql_result($size2_result, $w, "depth");
						$class = mysql_result($size2_result, $w, "class");
						
						$table_name = $_SESSION['db_prefix']."_store_items";
						$name2_query = "SELECT store_item_id, width, depth, length FROM $table_name WHERE subCategory='timber' AND width = '".$width."' AND depth = '".$depth."'  AND class='S7' ORDER BY length ASC";
						//echo $wame_query;
						
						$name2_result = mySQL_query($name2_query);
						$name2_num = mysql_num_rows($name2_result);
					  ?>
                  <tr>
                    <td colspan="5">&nbsp;</td>
                  </tr>
                  <tr>
                    <td width="229" colspan="5"><label class="label_std" style="font-size:14px;"><?php echo $depth." x ".$width."&nbsp;(".$class.")" ?></label></td>
                  </tr>
                </table>
                <table>
                  <?php	
					  $x=0;    
					  $y=0;
					  
					  while ($y<$name2_num) {
					  
					  ?>
                  <tr>
                    <?php
					  $z=0;
					  
					  while ($z<8) {
						  //echo ">>> c=".$z."  d=".$x;
						if ($x<$name2_num) {  
						$p1 = mysql_result($name2_result, $x, "store_item_id"); 
						//$a2 = mysql_result($name2_result, 0, "item_name");
					  	//$a3 = mysql_result($name2_result, $x, "checked"); 
						
					  	$p4 = mysql_result($name2_result, $x, "width"); 
					  	$p5 = mysql_result($name2_result, $x, "depth"); 
					  	$p6 = mysql_result($name2_result, $x, "length");
						$p3='no';
						$table_name = $_SESSION['db_prefix']."_receive_store_lines_temp";
						$check2_query = "SELECT receive_line_id FROM $table_name WHERE user =  '".$_SESSION['username']."' AND store_item_id='".$p1."'  ";
						$check2_result = mySQL_query($check2_query);
						$check2_num = mysql_num_rows($check2_result);
						if ($check2_num!=0) {
							$p3='yes';
						}
						
						$v++;
						}
						else {
							$p1 = "";
							//$a2 = "";
					  		$p3 = "";
					  		$p4 = "";
					  		$p5 = "";
					  		$p6 = "";
							$z++;
							$y++;
							$x++;
						}
					 
                    if ($x<$name2_num) {  ?>
                    <td width='60' align="left"><input type="checkbox" name="<?php echo "block".$v ?>" id="<?php echo "block".$v ?>" value="<?php echo $p1 ?>" <?php if ($p3=='yes') { ?>  checked="checked" <?php } ?>  >
                      <?php echo $p6; ?>&nbsp;
                      <input type="hidden" name="<?php echo "item_block".$v ?>" id="<?php echo "item_block".$v ?>" value="<?php echo $p1 ?>">
                      &nbsp; </td>
                    <?php
					}
					else { ?>
                    <td width='60' align="left"></td>
                    <?php
					}
					$z++;
					$x++;
					  }
					  ?>
                  </tr>
                  <?php
				  $y++;
				  
				  	}  $x++;
				  $w++;
				  $_SESSION['list_no_5'] = $v+1;
				  }
				  
				  ?>
                </table>
                <br />
                <br />
                <br />
              </div></td>
            <!--center of tableMain--> 
          </tr>
          <tr>
            <td><!--center of tableMain-->
              
              <table width="660" height="50" align="left" cellpadding="20"  id="table_button_bar">
                <tr>
                  <td width="117"><input type="button" name="lastprev_button" class="imagebutton" value="Prev" onClick="needToConfirm = false; MM_goToURL('parent','receivingTimberWizbase.php?s=&p=1'); return document.MM_returnValue; MM_showHideLayers('wait','','show');" tabindex="3"/></td>
                  <td width="115">&nbsp;</td>
                  <td width="99"><input name="p" type="hidden" id="p" value="2" />
                    <input name="s" type="hidden" id="s" value="2" />
                    </span></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="2"/></td>
                  <td width="110" align="right"><input type="submit" name="next_button" class="imagebutton" value="Next" onClick="needToConfirm = false; MM_showHideLayers('wait','','show');" tabindex="1" /></td>
                </tr>
              </table></td>
          </tr>
        </table>
  </table>
  <!--end of tableMain-->
</form>
</div>
</body>
