<?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['receive_date'] = $_GET['receive_date'];	
		$_SESSION['transport'] = $_GET['transport_text'];
		$_SESSION['value'] = $_GET['value_text'];
		$_SESSION['currency'] = $_GET['currency_select'];
	   		
		$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) {
	 
	}
	
	if($s==3) {
	   
	 
	};
	
	if($s==4) {
	 
	}
	
	if($s==10) {
		$category = $_GET['category'];
		$sub_category = $_GET['sub_category'];
		$store_item_id = $_GET['store_item_select'];
		$quantity = $_GET['quantity_text'];
		$price = $_GET['price_text'];
		
		$table_name = $_SESSION['db_prefix']."_receive_store_lines_temp";
		$receive_query = "INSERT INTO $table_name (`category`, `sub_category`, `store_item_id`, `quantity`, `price`, user) VALUES ('".$category."', '".$sub_category."', '".$store_item_id."', '".$quantity."', '".$price."', '".$_SESSION['username']."' ) ";
		execsql($receive_query);
		
		if (isset($_GET['next_add_button']) )
	   { ?>
<script>
	   editwindow=dhtmlmodal.open('editBox', 'iframe', '../edit_windows/receival_add.php?category=&sub_category=', 'Add item', 'width=500px,height=250px,center=1,resize=0,scrolling=0')
needToConfirm = false;
		</script>
<?php		 
	   }
		
	}
	
	if($s==11) {
		$receive_line_id = $_GET['receive_line_id'];
		$quantity = $_GET['quantity_text'];
		$price = $_GET['price_text'];
				
		$table_name = $_SESSION['db_prefix']."_receive_store_lines_temp";
		
		
		$receive_edit_query = "UPDATE $table_name SET quantity='".$quantity."', price='".$price."' WHERE receive_line_id = '".$receive_line_id."' ";
		execsql($receive_edit_query);
	}
	
	if($s==12) {
		$receive_line_id = $_GET['receive_line_id'];
		
		$table_name = $_SESSION['db_prefix']."_receive_store_lines_temp";
		$delete_query = "DELETE FROM $table_name WHERE receive_line_id = '".$receive_line_id."' "; 
		execsql($delete_query);
	}
	
	?>

<!--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/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>
</head

><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 store items </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 />
                  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>
        </td>
      <!--center of tableMain--> 
    </tr>
    <tr>
      <td><!--center of tableMain-->
        
        <?php 
	if ($_SESSION['p']==1) { include("receivingWiz1.php"); }
	if ($_SESSION['p']==2) { include("receivingWiz2.php"); }
	if ($_SESSION['p']==3) { include("receivingWiz4.php"); }
	
    ?></td>
    </tr>
  </table>
</div>
<?php include ('../navigation/side_bar.php'); ?>

</body>
