<?php
include("../include/session.php");
if( !$session->isAdmin() && !$session->isRadstoneReceptionUser() && !$session->isRadstoneStoreUser() ){
	//header("Location: ../Store/storeMenu.php");?>
<script language="javascript" type="text/javascript">
        <!--
		  window.location="denied.php";
        -->
       </script>
<?php 
}else{
	
	include("../storeHeader.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['category'] = $_GET['category_group'];
		
		if ($_SESSION['category'] == "Tiles and Accessories") { ?>
          <script language="javascript" type="text/javascript">
              window.location="outWizbase.php?p=0&s=0";
         </script>;
   <?php } else { 
		
		
		
		
		     if ($_SESSION['changed'] == $_SESSION['category']) {
				 $_SESSION['changed'] = $_SESSION['category'];
			 }
			 else  {
				  	     	$_SESSION['changed'] = "";
	 						$_SESSION['changed2'] = "";
							$_SESSION['productId'] ="";
	 						$_SESSION['productName'] ="";
							$_SESSION['productPrice'] ="";
     						$_SESSION['companyName'] = "";
	 						//$_SESSION['category'] = "";
	 						$_SESSION['subCategory'] = "";
							$_SESSION['rep'] = "";
	 						$_SESSION['reason'] = "";
	 						$_SESSION['regNo'] = "";
	 						$_SESSION['mileage'] = "";
	 						$_SESSION['quantity'] = "";
	 						$_SESSION['driver'] = "";
	 						$_SESSION['employee'] = "";
	 						$_SESSION['department'] = "";
	 						$_SESSION['issued_to'] = "";
							$_SESSION['changed'] = $_SESSION['category'];
			 }
				
		if ($_SESSION['category'] == "Store Item") {
			$_SESSION['subCategory'] = $_GET['sub_cat_group'];
		     if ($_SESSION['changed2'] == $_SESSION['subCategory']) {
				 $_SESSION['changed2'] = $_SESSION['subCategory'];
			 }
			 else  {
				  	        $_SESSION['changed'] = "";
	 						$_SESSION['changed2'] = "";
							$_SESSION['productId'] ="";
	 						$_SESSION['productName'] ="";
							$_SESSION['productPrice'] ="";
     						$_SESSION['companyName'] = "";
	 						//$_SESSION['category'] = "";
	 						//$_SESSION['subCategory'] = "";
							$_SESSION['rep'] = "";
	 						$_SESSION['reason'] = "";
	 						$_SESSION['regNo'] = "";
	 						$_SESSION['mileage'] = "";
	 						$_SESSION['quantity'] = "";
	 						$_SESSION['driver'] = "";
	 						$_SESSION['employee'] = "";
	 						$_SESSION['department'] = "";
	 						$_SESSION['issued_to'] = "";
						    $_SESSION['changed2'] = $_SESSION['subCategory'];
			 }
		}
				
	};
	}
	
	
	if($s==2) {

	$_SESSION['productId'] = $_GET['productId'];
	if ($_SESSION['productId']!='') {
	$productQuery = "SELECT  productName, price FROM products  WHERE productId = ".$_SESSION['productId'];
	$productResult = execsql($productQuery);
	$_SESSION['productName'] = mysql_result($productResult, 0, "productName");	
	$_SESSION['productPrice'] = mysql_result($productResult, 0, "price");
	}
	$_SESSION['quantity'] = $_GET['quantityText'];
	$_SESSION['order'] = $_GET['orderText'];
	$_SESSION['supplyDate'] = $_GET['supplyDate'];
	
	};
	
	
	
	if($s==3) {
	
	
	if ($_SESSION['subCategory']=="Fuel") {
	  $_SESSION['issued_to'] = "";
	  $_SESSION['regNo'] = $_GET['regNoSelect'];
	  $_SESSION['mileage'] = $_GET['mileageText'];
	  $_SESSION['account_no'] = $_GET['companySelect'];
	  $companyQuery = "SELECT  name FROM rad_tocotex  WHERE account_no = ".$_SESSION['account_no'];
	  $companyResult = execsql($companyQuery);
	  $_SESSION['companyName'] = mysql_result($companyResult, 0, "name");
	  
	  
	  $_SESSION['repId'] = $_GET['driverSelect'];
	  $driverQuery = "SELECT  first_name, last_name FROM rad_representatives  WHERE repId = '".$_SESSION['repId']."'";
	  $driverResult = execsql($driverQuery);
	  $_SESSION['driver'] = mysql_result($driverResult, 0, "first_name")." ".mysql_result($driverResult, 0, "last_name");
	  
	}
	else {
	  $_SESSION['issued_to'] = $_GET['issued_to_group'];
	  
	 
	 if ($_SESSION['issued_to']=="employee") {
	 $_SESSION['empId'] = $_GET['empSelect'];
	  $employeeQuery = "SELECT  empFNAme, empLName FROM employees  WHERE empId = '".$_SESSION['empId']."'";
	  $employeeResult = execsql($employeeQuery);
	  $_SESSION['employee'] = mysql_result($employeeResult, 0, "empFName")." ".mysql_result($employeeResult, 0, "empLName");
	 }
	  
	  
	  if ($_SESSION['issued_to']=="department") {
	  $_SESSION['department'] = $_GET['department_select'];
	  }
	  
	  if ($_SESSION['issued_to']=="representative") {
	  $_SESSION['repId'] = $_GET['repSelect'];
	  $repQuery = "SELECT  first_name, last_name FROM rad_representatives  WHERE repId = '".$_SESSION['repId']."'";
	  $repResult = execsql($repQuery);
	  $_SESSION['rep'] = mysql_result($repResult, 0, "first_name")." ".mysql_result($repResult, 0, "last_name");
	  }
	  
	  $_SESSION['account_no'] = $_GET['companySelect'];
	  $companyQuery = "SELECT  name FROM rad_tocotex  WHERE account_no = ".$_SESSION['account_no'];
	  $companyResult = execsql($companyQuery);
	  $_SESSION['companyName'] = mysql_result($companyResult, 0, "name");
	  
	  
	  
	}
	$_SESSION['notes'] = $_GET['notesText'];
	};
	
	if($s==4) {
	// $_SESSION['productSpecs'] = $_GET['specText'];
	}
	
	?>
<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">Delivery</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">Issued</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."; } 
		  if ($_SESSION['p']>2) { echo "Issueing product:&nbsp;&nbsp;&nbsp;&nbsp; ".$_SESSION['productName']; } 
		  ?>
        </label>
      </p>
      <br /></td>
    <!--center of tableMain-->
  </tr>
  <tr>
    <td><!--center of tableMain-->
      <?php 
	if ($_SESSION['p']==1) { include("issueWiz1.php"); }
	if ($_SESSION['p']==2) { include("issueWiz2.php"); }
	if ($_SESSION['p']==3) { include("issueWiz3.php"); }
	if ($_SESSION['p']==4) { include("issueWiz4.php"); }
	
    ?></td>
  </tr>
</table>
<?php

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

?>
