<?php
	include("../../include/session.php");
	include("../../include/db.php");
	if( !$session->isAdmin() && !$session->isRadstoneReceptionUser()){
	//header("Location: ../Store/storeMenu.php");?>
	<script language="javascript" type="text/javascript">
        <!--
		  window.location="denied.php";
        -->
    </script>
    
	   <?php 
	   
	}else{
		$saleId = mysql_real_escape_string($_GET['saleId']);
		$orderNo = mysql_real_escape_string($_GET['orderNo']);
		$custNo = mysql_real_escape_string($_GET['custNo']);
		$orderDate = mysql_real_escape_string($_GET['orderDate']);
		$loc = mysql_real_escape_string($_GET['loc']);
		$delDate = mysql_real_escape_string($_GET['delDate']);
	    
		$q = "SELECT productId, quantity FROM nam_orders WHERE saleId = '$saleId'";
		$r = execsql($q);
		$update = mysql_result($r, 0, "quantity");
		$productId = mysql_result($r, 0, "productId");
		
		$qUP = "UPDATE nam_products SET reserved = reserved - $update WHERE productId = '$productId'";
		execsql($qUP);
		
		$qS = "DELETE FROM nam_orders WHERE saleId = '$saleId'";
		execsql($qS);
		$qty = "--";
		if ($loc=="edit") {
		  header("Location: ../editOrders.php?OrderNoText=". $orderNo."&CustNoText=". $custNo."&productID=".'--'."&quantityText=".$qty."&date1=".$orderDate."&delDate=".$delDate);
		  }
		else  {
		  header("Location: ../makeOrders.php?OrderNoText=". $orderNo."&CustNoText=". $custNo."&productID=".'--'."&quantityText=".$qty."&date1=".$orderDate."&delDate=".$delDate);
		  }
	
	}	
	
	?>