<?php
include("../include/session.php");
if( !$session->isAdmin() && !$session->isRadstoneStoreUser() ){
	//header("Location: ../Store/storeMenu.php");?>
<script language="javascript" type="text/javascript">
        <!--
		  window.location="denied.php";
        -->
       </script>
<?php 
}else{
	
	include("../storeHeader.php");
	
	$nameQuery = "SELECT productName FROM products WHERE productId = '".$_SESSION['productId']."'" ;
	$nameResult = execsql($nameQuery);
	$nameNum = mysql_num_rows($nameResult);
	if ($nameNum==1) {
	$_SESSION['productName'] = mysql_result($nameResult, 0, "productName");
	}
	
	
	
	
	//$_SESSION['ContactText'];
	$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['store'] = $_GET['store_group'];
		if ($_SESSION['changed'] == $_SESSION['store']) {
			     $_SESSION['changed']= $_SESSION['store'];
		}
		else {
			$_SESSION['productId'] ="";
	 		$_SESSION['productName'] ="";
	 		$_SESSION['accountNo'] ="";
    		$_SESSION['supplierName'] = "";
	 		$_SESSION['deliveryNote'] = "";
	 		$_SESSION['quantity'] = "";
	 		$_SESSION['price'] = "";
	 		$_SESSION['receiveDate']  = date('Y-m-d');
			$_SESSION['changed']= $_SESSION['store'];
		}
		
		
		if ($_SESSION['store'] == "Store Item") {
			   $_SESSION['sub_cat'] = $_GET['sub_cat_group'];
			      if ($_SESSION['changed2'] == $_SESSION['sub_cat']) {
		                 $_SESSION['changed2'] = $_SESSION['sub_cat'];
				 }
				  else {
			$_SESSION['productId'] ="";
	 		$_SESSION['productName'] ="";
	 		$_SESSION['accountNo'] ="";
    		$_SESSION['supplierName'] = "";
	 		$_SESSION['deliveryNote'] = "";
	 		$_SESSION['quantity'] = "";
	 		$_SESSION['price'] = "";
	 		$_SESSION['receiveDate']  = date('Y-m-d');
			$_SESSION['changed2'] = $_SESSION['sub_cat'];
		}
				  
		    }
	};
	
	if($s==2) {
	 $_SESSION['productId'] = $_GET['productText'];	
	// $_SESSION['productName'] = $_GET['productText'];
	 $_SESSION['quantity'] = $_GET['quantityText'];
	 if ($_SESSION['store'] != "Tiles and Accessories") {
	    $_SESSION['price'] = $_GET['priceText'];
	 }
	 if ($_SESSION['store'] == "Tiles and Accessories") {
	   $priceQuery = "SELECT price FROM products WHERE productId = '".$_SESSION['productId']."'" ;
	   $priceResult = execsql($priceQuery);
	   $_SESSION['price'] = mysql_result($priceResult, 0, "price");
	 };
	};
	
	if($s==3) {
	   if ($_SESSION['store'] != "Tiles and Accessories") {
	        $_SESSION['accountNo'] = $_GET['accountNo'];
	   }
	   $supNameQuery = "SELECT account_name FROM rad_suppliers WHERE account_no = '".$_SESSION['accountNo']."'" ;
	   $supNameResult = execsql($supNameQuery);
	   $supNameNum = mysql_num_rows($supNameResult);
	   if ($supNameNum==1) {
	     $_SESSION['supplierName'] = mysql_result($supNameResult, 0, "account_name");
		 $_SESSION['deliveryNote'] = $_GET['delnoteText'];
	  }
	  
	  if ($_SESSION['store'] == "Tiles and Accessories") {
	        $_SESSION['supplierName'] = "Radstone";
	   }
	  
	   
	   $_SESSION['receiveDate'] = $_GET['receiveDate'];
	 
	};
	
	if($s==4) {
	 
	}
	
	?>
<script language="JavaScript" src="gen_validatorv4.js"  type="text/javascript" xml:space="preserve"></script>
<!--form validation-->
<script type="text/javascript" src="../css/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="../css/wizard.css" />
<script language="javascript" type="text/javascript" >
<!--
function confirmRefresh() {
var okToRefresh = confirm("Do you really want to cancel this entry?");
var url='showAllProducts.php?cat=Tiles and Accessories&productSelect=All&colorSelect=All'
if (okToRefresh)
	{
			window.location=url;
	}
}
// -->
</script>
<script language="JavaScript">
  var needToConfirm = true;
  window.onbeforeunload = confirmExit;
  function confirmExit()
  {
    if (needToConfirm)
      return "You did not finish the wizard.\nIf you leave now your data will not be saved.";
  }
function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}
</script>
<table id="tableMain" width="595">
  <!--begin of tableMain-->
  <tr>
    <td ><div class="headerbox2">Receiving products / store items</div>
      <br />
      <p class="stepbar">
        <?php if ($_SESSION['p']==1) { echo "<label class=step>"; }  else { echo"<label class=stepd>"; } ?>
        Step 1<br />
        <font size="1">Store</font>
        </label>
        <?php if ($_SESSION['p']==2) { echo "<label class=step>"; }  else { echo"<label class=stepd>"; } ?>
        Step 2<br />
        <font size="1">Product</font>
        </label>
        <?php if ($_SESSION['p']==3) { echo "<label class=step>"; }  else { echo"<label class=stepd>"; } ?>
        Step 3<br />
        <font size="1">Supplier</font>
        </label>
        <?php if ($_SESSION['p']==4) { echo "<label class=step>"; }  else { echo"<label class=stepd>"; } ?>
        Step 4<br />
        <font size="1">Finish</font>
        </label>
        
        <label class="steptext">
          <?php if ($_SESSION['p']==1) { echo "Select store."; } else { echo "Receiving of: &nbsp;&nbsp;&nbsp;&nbsp; ".$_SESSION['store']; } ?>
        </label>
      </p>
      <br /></td>
    <!--center of tableMain-->
  </tr>
  <tr>
    <td><!--center of tableMain-->
      <?php 
	if ($_SESSION['p']==1) { include("deliveryWiz1.php"); }
	if ($_SESSION['p']==2) { include("deliveryWiz2.php"); }
	if ($_SESSION['p']==3) { include("deliveryWiz3.php"); }
	if ($_SESSION['p']==4) { include("deliveryWiz4.php"); }
	if ($_SESSION['p']==5) { include("deliveryWiz5.php"); }
    ?></td>
  </tr>
</table>
<?php

	}
	include("../footer.php");

?>
