<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<?php
include ("../navigation/header.php");
include ("../navigation/production_sidebar.php");
?>

<?php
		
	$s = $_GET['s'];
	$p = $_GET['p'];
	$_SESSION['p']=$p;
	$_SESSION['s']=$s;
	
	
	if (isset($_GET['prev_button']) )
	   {
		 $_SESSION['p']= $_SESSION['p']-1;
	   }
		 
	if (isset($_GET['next_button']) )
	  {
		$_SESSION['p']=$_SESSION['p']+1;
	  }
	
		
	if ($s==1) {
		  $_SESSION['sub_category'] = $_GET['category'];
		  $_SESSION['product_item_id'] = $_GET['product_item_id_select'];
		  
		  $table_name = $_SESSION['db_prefix']."_product_store";
		  $name_query = "SELECT item_name FROM $table_name WHERE product_item_id = '".$_SESSION['product_item_id']."'  ";
		  $name_result = $con->query($name_query);
		  $row = mysqli_fetch_assoc($name_result);
		  $_SESSION['mix_design'] = $row['item_name'];
	  
	};

	if($s==2) {
		$table_name = $_SESSION['db_prefix']."_mix_design_lines_temp";
		$delete_query = "DELETE FROM $table_name WHERE mix_design = '".$_SESSION['mix_design']."' AND user_name = '".$_SESSION['username']."' "; 
		$delete_result = $con->query($delete_query);
		$line_num = $_GET['line_num'];
		$i=0;
		while ($i < $line_num) {
						
			$store_item_id = $_GET['store_item_id'.$i];
			if ($store_item_id!='---') {
			$quantity = $_GET['quantity_text'.$i];
			$table_name = $_SESSION['db_prefix']."_store_items";
			$name_query = "SELECT subCategory, item_name  FROM $table_name WHERE store_item_id = '".$store_item_id."'  ";
			$name_result = $con->query($name_query);
			$row = mysqli_fetch_assoc($name_result);
			$item_name = $row['item_name'];
			$sub_category = $row['subCategory'];
			
			$table_name = $_SESSION['db_prefix']."_mix_design_lines_temp";
			$mix_query = "INSERT INTO $table_name (sub_category, store_item_id, quantity, mix_design, user_name) VALUES ('".$sub_category."', '".$store_item_id."', '".$quantity."', '".$_SESSION['mix_design']."', '".$_SESSION['username']."'  ) ";
			$mix_result = $con->query($mix_query);
			}
			$i++;
		}
		$_SESSION['number'] = $_GET['number_text'];
		$table_name = $_SESSION['db_prefix']."_packaging_design";
		$packaging_query = "SELECT packaging_design FROM $table_name WHERE design_no = '".$_SESSION['packaging']."' ";
		$packaging_result = $con->query($packaging_query);
		$row = mysqli_fetch_assoc($packaging_result);
		$_SESSION['packaging_name'] = $row['packaging_design'];
		
		
		$_SESSION['shelf_life'] = $_GET['shelf_life_select'];
		}
		
		
	 
	if($s==3) {
	
	
	};
	
	
	?>
    
<!--style sheets-->
<link rel="stylesheet" type="text/css" href="../css/wizard.css" />
<link href="../css/wait.css" rel="stylesheet" type="text/css">  
<link rel="stylesheet" href="../window/dhtmlwindow.css" type="text/css" />
<link rel="stylesheet" href="../window/modal.css" type="text/css" />

<!--jscript-->
<script type="text/javascript" src="../window/dhtmlwindow.js"></script>
<script type="text/javascript" src="../window/modal.js"></script>
<script language="JavaScript" src="../jscript/gen_validatorv4.js"  type="text/javascript" xml:space="preserve"></script>
<script language="JavaScript" src="../jscript/cancel_confirmation.js"  type="text/javascript"></script>
<script language="JavaScript" src="../jscript/confirm_exit.js"  type="text/javascript"></script>    
<script language="JavaScript" src="../jscript/show_hide_layers.js"  type="text/javascript"></script>
<script language="JavaScript" src="../jscript/go_to_url.js"  type="text/javascript"></script>   
<script language="JavaScript" src="../jscript/alert_message.js"  type="text/javascript"></script>
 


</head>

<body>
<div class="main_frame">

<table id="tableMain" width="595">
  <!--begin of tableMain-->
  <tr>
    <td >
    <div class="page_head_frame">
      <table width="678" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="547"><label class="label_page_head">New mix recipe <?php echo $_SESSION['mix_design'] ?></label>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </td>
          <td width="131" align="center"><b>&nbsp;</b></td>
        </tr>
    </table>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>
      <br /><br /><br /><br />

      <div class="wizard_paging_frame">
      <table align="left">
      <tr>
      <td>
      <?php if ($_SESSION['p']==1) { ?>
      <div class="active_step_frame"><div class="active_step_head_label">&nbsp;1</div>
      <div class="active_step_label"><br /><br /><br />Select mix design</div></div>
      <?php } else { ?>
      <div class="de_active_step_frame"><div class="de_active_step_head_label">&nbsp;1</div>
      <div class="de_active_step_label"><br /><br /><br />Select mix design</div></div>
      <?php } ?>
      
      </td>
      <td>
      <?php if ($_SESSION['p']==2) { ?>
      <div class="active_step_frame"><div class="active_step_head_label">&nbsp;2</div>
      <div class="active_step_label"><br /><br /><br />Components</div></div>
      <?php } else { ?>
      <div class="de_active_step_frame"><div class="de_active_step_head_label">&nbsp;2</div>
      <div class="de_active_step_label"><br /><br /><br />Components</div></div>
      <?php } ?>
     </td>
      <td>
      <?php if ($_SESSION['p']==3) { ?>
      <div class="active_step_frame"><div class="active_step_head_label">&nbsp;3</div>
      <div class="active_step_label"><br /><br /><br />Finish</div></div>
      <?php } else { ?>
      <div class="de_active_step_frame"><div class="de_active_step_head_label">&nbsp;3</div>
      <div class="de_active_step_label"><br /><br /><br />Finish</div></div>
      <?php } ?>
      </td>
      
      </tr>
      </table>
      </div>
      <br /></td>
    <!--center of tableMain-->
  </tr>
  <tr>
    <td><!--center of tableMain-->
      <?php 
	if ($_SESSION['p']==1) { include("new_mix_designWiz1.php"); }
	if ($_SESSION['p']==2) { include("new_mix_designWiz2.php"); }
	if ($_SESSION['p']==3) { include("new_mix_designWiz5.php"); }
	
    ?></td>
  </tr>
</table>

</div>

<?php include ('../navigation/side_bar.php'); ?>

</body>
</html>