<%
//Copyright David Byrne 2007
//This file is part of eCanteen.
// eCanteen is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// eCanteen is distributed in the hope that it will be useful
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with eCanteen. If not, see <http://www.gnu.org/licenses/>.
%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<Title>Processing</Title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<?
include("../include/constants.php"); mysql_free_result($res);
session_start();
list($Nowdate,$NowTime)=explode(" ",date("Y-m-d"));
print $_GET["dDate"]."<BR/>";//datevalue(datestr)
//response.End
//check date is in future
if ($_GET["dDate"]<$Nowdate)
{
}
else
{
// $objConnection1 is of type "ADODB.Connection"
// $MenuList is of type "ADODB.Recordset"
$objConnection1 = mysql_connect(DB_SERVER, DB_USER, DB_PASS);
mysql_select_db(DB_NAME);
$sqlstmt="SELECT `BreakID`, `Break`, `BreakShortName`, `SortOrder`, `OrderCloseTime`, `Minutes`, `~SiteID$` FROM break WHERE (((BreakID)=".$_GET["BreakID"].") AND ((`~SiteID$`)=".$_SESSION['SiteID'].")) ORDER BY SortOrder;";
print $sqlstmt."<br>";
$SiteBreaks=mysql_query($sqlstmt);
$SiteBreaksnum=mysql_numrows($SiteBreaks);
//response.end
list($sbdate,$sbTime)=explode(" ",mysql_result($SiteBreaks,0,"OrderCloseTime"));
if (time()<=strtotime($sbTime) && $_GET["dDate"]==$Nowdate)
{
}
else
{
$sqlstmt="SELECT minorcustomer.CustomerID, minorcustomer.`MajorCustomerExtract$`, minorcustomer.Active_L2, majorcustomer.Credit_L2 FROM majorcustomer INNER JOIN minorcustomer ON majorcustomer.CustomerID = minorcustomer.`MajorCustomerExtract$` WHERE (((minorcustomer.CustomerID)=".$_GET["CustID"]."));";
$CheckMajor=mysql_query($sqlstmt);
if (mysql_result($CheckMajor,0,"MajorCustomerExtract$")!=$_SESSION['CustomerID'])
{
print "Not your charge.";
}
else
{
$sqlstmnt="SELECT transactions.`TransactionID`, transactions.`TargetDate`, transactions.`BreakID`, transactions.`MinorAccountID`, transactions.`MajorAccountID`, transactions.`WithdrawalAmount` FROM transactions WHERE (((transactions.`TransactionID`)=".$_GET["TransactionID"]."));";
$Totals=mysql_query($sqlstmnt);
$Refund=mysql_result($Totals,0,"WithdrawalAmount");
//refund to major account
$sqlstmnt="UPDATE majorcustomer SET majorcustomer.`Credit_L2` = `Credit_L2`+".$Refund." WHERE (((majorcustomer.CustomerID)=".mysql_result($Totals,0,"MajorAccountID")."));";
print $sqlstmnt."<br>";
//response.End
mysql_query(($sqlstmnt),$objConnection1);//change transaction to cancel
$sqlstmnt="UPDATE transactions SET transactions.`TransactionNumber`=0,transactions.`WithdrawalAmount`=0, transactions.`DepositAmount`=".$Refund." WHERE (((transactions.`TransactionID`)=".$_GET["TransactionID"].")); ";
mysql_query(($sqlstmnt),$objConnection1);
//sqlstmnt="INSERT INTO Transactions (TransactionNumber,TargetDate ,TransactionDate, TransactionDescription, AdminID, MajorAccountID, MinorAccountID, BreakID, WithdrawalAmount, DepositAmount ) "
//
//sqlstmnt=sqlstmnt&" VALUES(0, #"& Request.QueryString("dDate")&"#,#"&datestr&"#, 'Order Cancelled',0, "&session("customerid")&","&Request.QueryString("CustID")&", "&Request.QueryString("BreakID")&", 0, "&Refund&" ) "
print $sqlstmnt."<br>";
//objConnection1.execute(sqlstmnt)
//delete customer orders
$sqlstmnt="DELETE FROM customersandorders WHERE (((customersandorders.`MinorCustomerC$`)=".$_GET["CustID"].") AND ((customersandorders.`Break$`)=".$_GET["BreakID"].") AND ((customersandorders.`OrderDate`)='".$_GET["dDate"]."'));";
print $sqlstmnt;
//response.End
mysql_query(($sqlstmnt),$objConnection1);
$_SESSION['credit']=$_SESSION['credit']+$Refund;
mysql_close($objConnection1);
$objConnection1=null;
$objRecordset1=null;
//response.Redirect "usercalendar.asp?date="&Request.QueryString("dDate")&"&minor="&Request.QueryString("CustID")
}
}
}
?>
<script type="text/javascript">
if (<?echo $_GET["elSource"];?>==1)
{
xc=window.opener.location.href='usercalendar-sdates3.php?minor=<?echo $_GET["CustID"];?>&date=<?echo $_GET["dDate"];?>&minorname=<?echo $_GET["MinorName"];?>';
}else{
window.opener.location.href='QuikMenu.php?date=<?echo $_GET["dDate"];?>&minor=<?echo $_GET["CustID"];?>&BreakID=<?echo $_GET["BreakID"];?>&ItemStr=<?echo $_GET["Itemstr"];?>&Break=<?echo $_GET["BreakName"];?>&minorname=<?echo $_GET["MinorName"];?>';
//xc=window.opener.location.href='usercalendar-sdates3.php?minor=<?echo $_GET["CustID"];?>&date=<?echo $_GET["dDate"];?>&minorname=MinorName';
}
window.close();
</script>
<body >
</body>
</html>