<?
//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/>.
?>
<?
include("../include/constants.php"); mysql_free_result($res);
session_start();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Page</title>
<?
$objConnection1=mysql_connect(DB_SERVER, DB_USER, DB_PASS);
mysql_select_db(DB_NAME);
list($Nowdate,$NowTime)=explode(" ",date("Y-m-d"));
// $objConnection1 is of type "ADODB.Connection"
// $MenuList is of type "ADODB.Recordset"
$sqlstmt="SELECT class.`Class`, minorcustomer.`Class$`, minorcustomer.`LastName`, minorcustomer.`FirstName`, break.`BreakID`, break.`Break`, break.`~SiteID$`, customersandorders.`OrderDate`, itemtype.`ItemType`, menuitem.`Item`, menuitem.`Cost`, customersandorders.`Quantity`, customersandorders.`Active_L2`, transactions.`TransactionNumber`, IsNull(`PrintDate`) AS Printed, transactions.`TransactionID` FROM ((class INNER JOIN minorcustomer ON class.`ClassID` = minorcustomer.`Class$`) INNER JOIN ((itemtype INNER JOIN menuitem ON itemtype.`ItemTypeID` = menuitem.`ItemType$`) INNER JOIN (customersandorders INNER JOIN Break ON customersandorders.`Break$` = break.`BreakID`) ON menuitem.`MenuItemID` = customersandorders.`MenuItem$`) ON minorcustomer.`CustomerID` = customersandorders.`MinorCustomerC$`) INNER JOIN transactions ON (customersandorders.`MinorCustomerC$` = transactions.`MinorAccountID`) AND (customersandorders.`Break$` = transactions.`BreakID`) AND (customersandorders.`OrderDate` = transactions.`TargetDate`) WHERE (((break.`BreakID`)=".$_GET["BreakID"].") AND ((customersandorders.`OrderDate`)='".$_GET["date"]."') AND ((transactions.`TransactionNumber`)=1) AND ((break.`~SiteID$`)=".$_SESSION["SiteID"].") AND ((IsNull(`PrintDate`))=".$_GET["printed"].")) ORDER BY class.`Class`, transactions.`TransactionID`, itemtype.`ItemType`, menuitem.`Item`;";
//break;
//echo $sqlstmt;
//echo "<br>";
//response.Write "<br/>"
$SearchList=mysql_query($sqlstmt);
$SearchListnum=mysql_numrows($SearchList);
$sqlstmt="UPDATE transactions INNER JOIN MajorCustomer ON transactions.`MajorAccountID` = MajorCustomer.`CustomerID` SET transactions.`PrintDate` = '".$Nowdate."' WHERE (((transactions.`TargetDate`)='".$_GET["date"]."') AND ((transactions.`BreakID`)=".$_GET["BreakID"].") AND ((MajorCustomer.`~SiteID$`)=".$_SESSION['SiteID'].") AND ((transactions.`TransactionNumber`)=1));";
//echo $SearchListnum;
mysql_query(($sqlstmt),$objConnection1);
?>
</head>
<body>
<table style="width:500px" border="1">
<?
$StName=-120;
$i=0;
while($i<$SearchListnum)
{
list($Orderdate,$OrderTime)=explode(" ",mysql_result($SearchList,$i,"OrderDate"));
if ($StName!=mysql_result($SearchList,$i,"TransactionID"))
{
if ($StName!=-120)
{
?>
<tr><td colspan="6" align=right><? echo "$".$TotalCost;?></td></tr>
<? } ?>
<tr>
<td colspan=6 >
<?
$TotalCost=0;
print mysql_result($SearchList,$i,"Class")." : ";
print mysql_result($SearchList,$i,"FirstName")." ";
print mysql_result($SearchList,$i,"lastname")." ";
print mysql_result($SearchList,$i,"TransactionID")." ";
print mysql_result($SearchList,$i,"Break")." order for ".$Orderdate;
$StName=mysql_result($SearchList,$i,"TransactionID");
} ?></td>
<td >
</td>
<td>
</td>
<td >
</td>
<td >
</td>
</tr>
<tr> <td></td>
<td >
<? echo mysql_result($SearchList,$i,"Item");?></td>
<td>
</td>
<td >
<? echo "$".mysql_result($SearchList,$i,"Cost");?></td>
<td >
<? echo mysql_result($SearchList,$i,"Quantity");?></td>
<td align=right >
<? echo "$".mysql_result($SearchList,$i,"Cost")*mysql_result($SearchList,$i,"Quantity");?>
<? $TotalCost=$TotalCost+mysql_result($SearchList,$i,"Cost")*mysql_result($SearchList,$i,"Quantity");?>
</td>
</tr>
<? $i++;
} ?>
<tr><td colspan="6" align=right><? echo "$".$TotalCost;?></td></tr>
</table>
</body>
</html>