<?php	
       
$table_name = $_SESSION['db_prefix']."_production_plan_lines";
$production_line_query = "SELECT * FROM $table_name WHERE production_no = '".$_SESSION['production_no']."' ";
$production_line_result = mySQL_query($production_line_query);
$_SESSION['production_line_num'] = mysql_num_rows($production_line_result);
  
?>


</head>

<body >
<div class="wizard_page_middle_frame">   
<form id="feedbackform" method="get" action="production_countWiz6.php">
             
     <div class="wizard_spacer_frame" style="height:170px;">
      <table width="650" id='table_details_display'>
      <thead>
        <tr>
          <td width="266">Product</td>
          <td width="76">Planned<br>
            skips/batch</td>
          <td width="86" align="center">Skip/batch<br>count</td>
          <td width="86" align="center">Estimated products</td>
          <td width="112" align="center">Counted wet<br>
            products</td>
        </tr>
       </thead>
       <?php
	   $i=0;
	   while ($i<$_SESSION['production_line_num']) {
		   $mix_design_no =  mysql_result($production_line_result, $i, "mix_design_no");
		   $mix_design_name = mysql_result($production_line_result, $i, "mix_design_name");
		   $skip_qty = mysql_result($production_line_result, $i, "skip_quantity");
		   			
					$table_name = $_SESSION['db_prefix']."_mix_design";
					$est_query = "SELECT est_qty FROM $table_name WHERE design_no = '". $mix_design_no."' ";
					$est_result = mySQL_query($est_query);
					$est_qty = mysql_result($est_result, 0, "est_qty");
			$total_est_qty = $est_qty * $skip_qty;
		   
		   $table_name = $_SESSION['db_prefix']."_production_count_temp";
			$produced_query = "SELECT skip_quantity, wet_quantity FROM $table_name WHERE production_no = '".$_SESSION['production_no']."' AND mix_design_no = '".$mix_design_no."' and user_name = '".$_SESSION['username']."'  ";
			$produced_result = mySQL_query($produced_query);
			$produced_num = mysql_num_rows($produced_result);
			if ($produced_num>0) {
			$skip_quantity = mysql_result($produced_result, 0, "skip_quantity");
			$wet_quantity = mysql_result($produced_result, 0, "wet_quantity");
			}
			else {
				$skip_quantity='';
				$wet_quantity='';
			}
		   
		  	$table_name = $_SESSION['db_prefix']."_production_count_temp";
			$produced_query = "SELECT skip_quantity, wet_quantity FROM $table_name WHERE production_no = '".$_SESSION['production_no']."' AND mix_design_no = '".$mix_design_no."' and user_name = '".$_SESSION['username']."'  ";
			$produced_result = mySQL_query($produced_query);
			$produced_num = mysql_num_rows($produced_result);
			$skip_quantity = mysql_result($produced_result, 0, "skip_quantity");
			$wet_quantity = mysql_result($produced_result, 0, "wet_quantity");
		   ?>	   
        <tr>
          <td><?php echo $mix_design_name ?><input name="mix_design_no<?php echo $i ?>" type="hidden" value="<?php echo $mix_design_no ?>"> </td>
          <td><?php echo $skip_qty ?></td>
          <td><?php echo number_format($skip_quantity, 1, '.', ',') ?></td>
          <td><?php echo number_format($total_est_qty, 0, '.', ',') ?></td>
          <td><?php echo number_format($wet_quantity, 0, '.', ',') ?></td>
        </tr>
        <?php
		$i++;
	   }
		?>
        <input name="production_line_num" type="hidden" value="<?php echo $_SESSION['production_line_num'] ?>">
      </table>
    </div>          
            <div class="wizard_frame">
              <table width="645" 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','production_countWizbase.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="5" />
                    <input name="s" type="hidden" id="s" value="5" />
                  </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?date=0');" value="Cancel" /></td>
                  <td width="110" align="right"><input type="submit" name="finish_button" class="imagebutton" value="Finish" onClick="needToConfirm = false; " /></td>
                </tr>
              </table>
    </div>
              
</form>
</div>
<!--form validation-->
  <script language="JavaScript" type="text/javascript" xml:space="preserve">
  var frmvalidator  = new Validator("feedbackform");
  frmvalidator.EnableMsgsTogether();
  frmvalidator.addValidation("item_select","req","Please select an item.");
</script>


	
 </body>