<?
//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/>.
session_start();
if ($_SESSION['userlevel']>=3)
{
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Untitled Page</title>
<?
include("../include/constants.php"); mysql_free_result();
//echo "site=".$_SESSION['SiteID'];
list($Nowdate,$NowTime)=explode(" ",date("Y-m-d"));
$SearchHandle=0;
if (strlen(${"SearchHandle"})>0)
{
$SearchHandle=$_POST["SearchHandle"];
}
// $objConnection1 is of type "ADODB.Connection"
// $objRecordset1 is of type "ADODB.Recordset"
//objRecordset1.CursorLocation = adUseClient
$objConnection1 = mysql_connect(DB_SERVER, DB_USER, DB_PASS);
mysql_select_db(DB_NAME);
if ($_POST["Add"]!="")
{
$SQLstmt="INSERT INTO transactions (`TransactionNumber`,`TransactionDate`,`TargetDate`,`TransactionDescription`,`AdminID`,`MajorAccountID`,`DepositAmount`,`~SiteID\$` ) VALUES(0,'".$Nowdate."','".$Nowdate."','".$_POST["Description"]."',".$_SESSION['CustomerID'].",".$_POST["SearchHandle"].",".$_POST["Amount"].",".$_SESSION['SiteID'].");";
mysql_query(($SQLstmt),$objConnection1);
$sqlstmnt="UPDATE majorcustomer SET majorcustomer.`Credit_L2` = `Credit_L2`+".$_POST["Amount"]." WHERE (((majorcustomer.CustomerID)=".$_POST["SearchHandle"]."));";
//echo $sqlstmnt;
mysql_query(($sqlstmnt),$objConnection1);
}
$SQLStmnt="SELECT majorcustomer.`CustomerID`, concat(`LastName`,', ',`FirstName`,' - ',`UserName_L2`) AS `Name`, majorcustomer.`UserName_L2` FROM majorcustomer where (`~SiteID\$`=".$_SESSION['SiteID'].") ORDER BY concat(`LastName`,', ',`FirstName`);";
//echo $SQLStmnt;
$MajorCust=mysql_query($SQLStmnt);
$i=0;
$MajorCustnum=mysql_numrows($MajorCust);
;
if ($SearchHandle>0)
{
$SQLStmnt="SELECT concat(majorcustomer.`LastName`,', ',majorcustomer.`FirstName`) AS `MajorName`, transactions.`TransactionID`, transactions.`TransactionNumber`, transactions.`TransactionDate`, transactions.`TargetDate`, Break.`Break`, concat(minorcustomer.`LastName`,', ',minorcustomer.`FirstName`) AS `MinorName`, transactions.`TransactionDescription`, transactions.`WithdrawalAmount`, transactions.`DepositAmount`, transactions.`MajorAccountID`, transactions.`MinorAccountID`, transactions.`AdminID` FROM ((transactions LEFT JOIN Break ON transactions.BreakID = Break.BreakID) LEFT JOIN minorcustomer ON transactions.MinorAccountID = minorcustomer.CustomerID) INNER JOIN majorcustomer ON transactions.`MajorAccountID` = MajorCustomer.`CustomerID` WHERE (transactions.`MajorAccountID`=".$SearchHandle.") AND (transactions.`TransactionDate`='".$Nowdate."') AND (transactions.`DepositAmount` > 0);";
$objRecordset1=mysql_query($SQLStmnt);
$objRecordset1num=mysql_numrows($objRecordset1);
;
}
?>
</head>
<body>
<button id="Return2Cal" onclick="window.location.href='../index.php';return true;" style="width: 190px">Return to Main Menu</button>
<form method="post" action="payother.php">
<table border="1" cellpadding="1">
<tr>
<td >
Select Customer:
</td>
<? ?>
<td ><select name="SearchHandle">
<option selected="selected" value="-1">Not Selected</option>
<?
$i=0;
while($i < $MajorCustnum)
{
if (mysql_result($MajorCust,$i,"CustomerID")==$SearchHandle)
{
?>
<option selected="selected" value="<? echo mysql_result($MajorCust,$i,"CustomerID");?>"><? echo mysql_result($MajorCust,$i,"Name");?></option>
<?
}
else
{
?>
<option value="<? echo mysql_result($MajorCust,$i,"CustomerID");?>"><? echo mysql_result($MajorCust,$i,"Name");?></option>
<?
}
$i++;
}
?>
</select>
</td>
<td >Enter Amount to add:
</td>
<td >
<input name="Amount" id="Amount" type="text" />
</td>
</tr>
<tr>
<td >Enter Payment Details<br />(Chq or Receipt No.)
</td>
<td><input name="Description" id="Description" type="text" />
</td>
<td >
</td>
<td >
<input type="submit" name="Add" value="Add" style="width:35"></td>
</tr>
</table>
<? if ($SearchHandle!=0)
{
if ($objRecordset1num>0)
{
$i=0;
?>
<table>
<? while($i < $objRecordset1num)
{
?>
<tr>
<td>
<? echo mysql_result($objRecordset1,$i,"TransactionDescription");?>
</td>
<td>
<? echo mysql_result($objRecordset1,$i,"DepositAmount");?>
</td>
</tr>
<? $i++;
}
?>
</table>
<? }
} ?>
</form>
</body>
</html>
<?}?>