
<?php
$special_orders='no';
$temp_table_name = $_SESSION['db_prefix']."_mix_design_lines_temp";
include('../include/ingredient_select_header_mix_design.php');


$table_name = $_SESSION['db_prefix']."_packaging_design";
$position_query = "SELECT design_no, packaging_design FROM $table_name ORDER BY packaging_design ASC";
$arrId0 = array ();
$arrName0 = array ();
$position_result = $con->query($position_query);
if ($position_result!="") {
	$position_num = mysqli_num_rows($position_result);
	$b = 0;
while ($b < $position_num) {
		$row = mysqli_fetch_assoc($position_result);
		$arrId0[$b] = $row['design_no'];
		$arrName0[$b] = $row['packaging_design'];
		$b++;
	}
	}

?>

<script>
function total_weight() {
	var line_weight = 0;
	var total_weight = 0;
	var line_num  = 1;
		
	var rowCount = dataTable.rows.length;
    var line_no = rowCount-1;
		
	i=0;
	while (i < line_no) {
	 line_weight = parseFloat(document.getElementById('kg_text'+i).value).toFixed(2);
	 total_weight = parseFloat(total_weight) + parseFloat(line_weight);
	 i++;
	}
	
	document.getElementById('total_weight_text').value = parseFloat(total_weight).toFixed(2);
	document.getElementById('total_perc_text').value = parseFloat(total_weight).toFixed(2) / 10; 
	
	if (document.getElementById('total_perc_text').value != 100) {
		  document.getElementById('total_weight_text').style.color ='red';
		  document.getElementById('total_perc_text').style.color ='red';
		  } 
	else {
		  document.getElementById('total_weight_text').style.color ='green';
		  document.getElementById('total_perc_text').style.color ='green';
	} 
	
	}
</script>
 
</head>
<?php include('../include/wait.php') ?>


<body onLoad="initCS(); MM_showHideLayers('wait','','hide'); total_weight(); " onFocus="MM_showHideLayers('wait','','hide'); "  onBlur="MM_showHideLayers('wait','','hide');">
<div class="page_middle_frame">
<form id="form1" name="form1" method="get" action="new_dry_feed_designWizbase.php" >
<img src="../images/info_blue.png" width="32" height="32">
A batch weights 1000kg. Ingredients are entered by percentage and will show the weight. The batch ingredients should be 100% which is 1000 kg.
<br>
<?php
$line_num=0;
include('../include/ingredient_select_table_mix_design.php');
include('../include/packaging_select_table_mix_design.php');

?>
<div class="wizard_frame">
Total batch weight:&nbsp;&nbsp;&nbsp;<input name="total_weight_text" id="total_weight_text" type="text"  class="text60";  style="border:hidden;" readonly>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;( <input name="total_perc_text" id="total_perc_text" type="text"   class="text40"; style="border:hidden;" >
% )
<br>
Estimated number of items to be produced with this mix design:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  <input name="number_text" id="number_text" type="text" onKeyPress="return numbersonly(this, event)" class='text60'; value="<?php echo $_SESSION['number'] ?>"><br>
<br>
Shelf life:&nbsp;&nbsp;&nbsp;&nbsp; 
<select name="shelf_life_select" id="shelf_life_select" class="select50">
  <option value="1">1</option>
  <option value="2">2</option>
  <option value="3">3</option>
  <option value="4">4</option>
  <option value="<?php echo $_SESSION['shelf_life'] ?>" selected="selected"><?php echo $_SESSION['shelf_life'] ?></option>
</select>
year&nbsp;&nbsp;
<!--Packing design to be used:&nbsp;&nbsp;
<select name="packaging_select" class="selectbox160" >
  <option value="<?php echo $_SESSION['packaging_name'] ?>"><?php echo $_SESSION['packaging_name'] ?></option>
  <option value="  "> </option>
  <?php
        	for ($i = 0; $i < count($arrId0); $i++) {
    		echo "<option value=".$arrId0[$i].">".$arrName0[$i]."</option>";
		}	
?>
</select>-->

<br><br>

</div>
  <table width="590" height="50" align="left" 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','new_dry_feed_designWizbase.php?s=&amp;p=1');return document.MM_returnValue" /></td>
            <td width="82"><input name="error" type="hidden" id="error" value="0" />
              <input name="p" type="hidden" id="p" value="2" />
              <input name="s" type="hidden" id="s" value="2" /></td>
            <td width="132">&nbsp;</td>
            <td width="125" align="left"><input name="cancelbutton" type="button" class="imagebutton" id="cancelbutton" onClick="needToConfirm = false; cancel_confirmation(1, '../dry_feed/dry_feed_main.php?date=0&subCatSelect=Tiles');" value="Cancel" /></td>
            <td width="110" align="left"><input type="submit" name="next_button" id="next_button" class="imagebutton" value="Next" onClick="needToConfirm = false; MM_showHideLayers('wait','','show'); validate();  " tabindex="5" /></td>
          </tr>
        </table>
</form>

<!--form validation-->
  <script language="JavaScript" type="text/javascript" xml:space="preserve">
  var frmvalidator  = new Validator("form1");
  frmvalidator.EnableMsgsTogether();
     
  for (i = 0; i < 50; i++) {
	frmvalidator.addValidation("store_item_text"+i,"req","- store item on line "+(i+1)+".");
	frmvalidator.addValidation("quantity_text"+i,"req","- percentage on line "+(i+1)+".");
    
    if (document.getElementById('total_perc_text').value > 100 ) {
    frmvalidator.addValidation("total_perc_text","req","- total_perc_text design.");	
    }
	
	frmvalidator.addValidation("number_text","req","- estimated number.");
	
 }
    
  </script>

</div>

</body>