<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php
include ("../navigation/header.php");
include ("../navigation/store_sidebar.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['supplier_id'] = $_GET['supplier_id_select'];	
	   	$_SESSION['del_note'] = $_GET['del_note_text'];
		$_SESSION['value'] = $_GET['value_text'];	
		$_SESSION['transport'] = $_GET['transport_text'];	
		$_SESSION['receive_date'] = $_GET['receive_date'];	
		
	  
				
		$table_name = $_SESSION['db_prefix']."_suppliers";
		$name_query = "SELECT account_name FROM $table_name WHERE supplier_id = '".$_SESSION['supplier_id']."' ";
		$name_result = mySQL_query($name_query);
		$_SESSION['sup_name'] = mysql_result($name_result, 0, "account_name");
		
			     
	};
	
	if($s==2) {
		$i=0;
		//$_SESSION['list_no_2']=$_SESSION['list_no_2']+1;
		
		while ($i<$_SESSION['list_no_2']) {
				
	$store_item_id = $_GET['item_no'.$i];
		//echo $store_item_id."<br>";
		
		
		
		if(isset($_GET['check'.$i]) ) {
		$table_name2 = $_SESSION['db_prefix']."_receive_store_lines_temp";	
		$exist_query = "SELECT receive_line_id FROM $table_name2 WHERE  store_item_id = '".$store_item_id."'  AND user =  '".$_SESSION['username']."' ";
		$exist_result = mySQL_query($exist_query);
		$exist_num = mysql_num_rows($exist_result);		
        if ($exist_num==0) { 
		$table_name2 = $_SESSION['db_prefix']."_receive_store_lines_temp";		
		$check_query = "INSERT INTO $table_name2 (category, sub_category, store_item_id, user ) VALUES ('Direct materials', 'Mitek', '".$store_item_id."', '".$_SESSION['username']."' ) ";
		execsql($check_query);
		}
		}
		else {
			$table_name2 = $_SESSION['db_prefix']."_receive_store_lines_temp";	
			$delete_query = "DELETE FROM $table_name2 WHERE  store_item_id = '".$store_item_id."'  AND user =  '".$_SESSION['username']."' "; 
			execsql($delete_query);
		 }
		
		$i++;
		}
		
	    
		
	 
	}
	
	if($s==3) {
		$k=0;
		while ($k<$_SESSION['list_no_3']) {
			$store_item_id = $_POST['store_item_id'.$k]; 
			$quantity = $_POST['qty_text'.$k];
			$SA_price = $_POST['SA_price_text'.$k];
			$BW_price = $_POST['BW_price_text'.$k];
			$_SESSION['SA_price'.$k] = number_format($SA_price, 2, '.', ',');
			
			//$price = $_GET['price_text'.$k];
			$table_name = $_SESSION['db_prefix']."_receive_store_lines_temp";
			$qty_query = "UPDATE $table_name SET quantity = '".$quantity."', bulk_price = '".$SA_price."', price = '".$BW_price."'  WHERE   store_item_id = '".$store_item_id."'  AND  user =  '".$_SESSION['username']."' "; 
			execsql($qty_query);
			$k++;
		}
		
		 
	};
	

	
	
	?>
<!--style sheets-->
<link rel="stylesheet" type="text/css" href="../css/wizard.css" />
<!--reference to main.css removed-->
<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 type="text/javascript" src="../jscript/jquery.1.4.2.js"></script>
<script language="JavaScript" src="../jscript/confirm_exit.js"  type="text/javascript"></script>
<script language="JavaScript" src="../jscript/cancel_confirmation.js"  type="text/javascript"></script>
<script language="JavaScript" src="../jscript/show_hide_layers.js"  type="text/javascript"></script>

<body>
<div class="main_frame">
  <table id="tableMain" width="595">
    <!--begin of tableMain-->
    <tr>
      <td ><div class="page_head_frame">
          <label class="label_page_head">Receiving Mitek products</label>
          &nbsp;&nbsp;
          <label class="label_page_head_2"><?php echo $_SESSION['sup_name'] ?></label>
        </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 />
                  Supplier</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 />
                  Supplier</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 />
                  Items</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 />
                  Items</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 />
                  Quantity</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 />
                  Quantity</div>
              </div>
              <?php } ?></td>
            <td><?php if ($_SESSION['p']==4) { ?>
              <div class="active_step_frame">
                <div class="active_step_head_label">&nbsp;4</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;4</div>
                <div class="de_active_step_label"><br />
                  <br />
                  <br />
                  Finish</div>
              </div>
              <?php } ?></td>
          </tr>
        </table>
        </div>
        </td>
      <!--center of tableMain--> 
    </tr>
    <tr>
      <td><!--center of tableMain-->
        
        <?php 
	if ($_SESSION['p']==1) { include("receivingPlatesWiz1.php"); }
	if ($_SESSION['p']==2) { include("receivingPlatesWiz2.php"); }
	if ($_SESSION['p']==3) { include("receivingPlatesWiz3.php"); }
	if ($_SESSION['p']==4) { include("receivingPlatesWiz6.php"); }
	//if ($_SESSION['p']==5) { include("receivingPlatesWiz5.php"); }
//	if ($_SESSION['p']==6) { include("receivingPlatesWiz6.php"); }
    ?></td>
    </tr>
  </table>
</div>
<?php include ('../navigation/side_bar.php'); ?>

</body>
