<?
#GST-approved.
function CCshow($cc){
$cc=trim($cc);
if ($cc=="")
$cr="???? ???? ???? ????";
else{
if (!ereg(" ",$cc)){
$cr=substr($cc,0,4)." ";
$cr=$cr.substr($cc,4,4)." ";
$cr=$cr.substr($cc,8,4)." ";
$cr=$cr.substr($cc,12);
}else{
$cr=$cc;
}
}
return $cr;
}
#if (!$CustomerID){
# header ("Location: frmain.php");
# exit;
#}
include "mysql.inc.php";
$sql="SELECT FirstName, LastName, Invoices.CustomerID AS ID, CreditCardNumbor,Reseller,
DATE_FORMAT(CreditCardExp,'%m/%y') AS exp, credit,identifier,
PaymentID, DATE_FORMAT(PaymentDate,'%e/%c/%Y %T') AS PDate, PaymentAmount,GST,
PaymentType,ResellerPayment,Purchase, to_days(now())-to_days(PaymentDate) as cdays
FROM Invoices,MasterAccounts WHERE
Invoices.CustomerID=MasterAccounts.CustomerID
AND Credit >0
ORDER BY PaymentDate DESC";
$result=mysql_query($sql);
if (mysql_error())
print mysql_error();
#$usql="SELECT FirstName, LastName FROM MasterAccounts WHERE
#CustomerID=$CustomerID";
#echo $usql;
#$ures=mysql_query($usql);
#$uname=mysql_fetch_row($ures);
?><HTML>
<HEAD>
<TITLE>View Payments</TITLE>
</HEAD>
<BODY>
<center>
<FORM action="invoicepost.php" METHOD=POST>
<TABLE WIDTH=95% border=1>
<TR><TH>Name</TH><TH>Get</TH><TH>Date</TH><TH>Amount</TH><TH>Payment
Type</TH><TH>Purchase</TH><TH>Reseller</TH><th>Identifier</TH><TH>Status</TH></TR>
<?
while ($row=mysql_fetch_array($result)){
$i++;
if ($row[cdays]>6)
$f="<FONT COLOR=RED>";
else
$f="";
$cost = number_format($row[PaymentAmount]+$row[GST],2);
print "<TR><TD><A HREF=\"user.php?ID=$row[ID]\">$f$row[FirstName] $row[LastName]</A></TD>";
print "<TD><A HREF=\"taxpdf.php?PaymentID=$row[PaymentID]&PayTable=Invoices&print=1&CustomerID=$row[ID]\">Print</A> ";
print "<A HREF=\"taxpdf.php?PaymentID=$row[PaymentID]&PayTable=Invoices&download=1&CustomerID=$row[ID]\">Download</A> ";
print "<TD NOWRAP>$f$row[PDate]</TD><TD>$f$cost</TD><TD>";
if (ereg("Credit Card",$row[PaymentType])||ereg("AutoBill",$row[PaymentType])){
print "<B>";
print CCshow($row[CreditCardNumbor]);
print "</B> ";
if ($row[CreditCardNumbor])
print "Exp: <B>$row[exp]</B>";
}else{
print $row[PaymentType];
}
print "</TD>";
print "<TD>$row[Purchase]</TD><TD>";
$rsql="SELECT DealerName FROM Dealer WHERE DealerID=$row[Reseller]";
$rres=0;
$rres=mysql_query($rsql);
#print $rres;
if ($rres){
$rr=mysql_fetch_row($rres);
print $rr[0];
}
else
print " ";
print "</TD><TD>$row[identifier]";
#print "</TD><TD><INPUT TYPE=checkbox NAME=\"keep[$i]\" checked></TD></TR>";
print "</TD><TD>";
?>
<SELECT Name="Status[<? echo $i ?>]">
<OPTION value="1"<? if ($row[credit]==1) print " selected";
?>>Pending</OPTION>
<OPTION value="2"<? if ($row[credit]==2) print " selected";?>>Declined</OPTION>
<OPTION value="-1">Cancel</OPTION>
<OPTION value="10">Paid</OPTION>
</SELECT>
<?
print "<INPUT TYPE=HIDDEN NAME=\"PaymentID[$i]\" VALUE=\"$row[PaymentID]\">";
$pt=$pt+$row[PaymentAmount];
}
?></TABLE>
<INPUT TYPE=SUBMIT VALUE="Save">
</FORM>
</CENTER>
<H3>Brief Explanation of Terms:</H3>
A Number in the payment type is a credit card number waiting to be
processed.
<BR>If you make any changes to the Status, remember to save before
going anywhere else!
<BR><BR>
<LI><B>Pending</B> is a payment waiting to be processed.</LI>
<LI><B>Declined</B> is a payment that has been processed but did not go
through. If it is a cheque we may also need to charge a dishonour
fee.</LI>
<LI><B>Paid</B> is what we want. A successful transaction.</LI>
<LI><B>Cancel</B> is when a user has no intention of paying, or the
transaction is repeatedly declined. You must manually remove the hours
added.</LI>
</BODY>
</HTML>