Location: PHPKode > projects > Total ISP > total-isp/permanent-check.php
<?
include "./auth.inc.php";

if (!$order)
	$order="ExpireDate";

$sql = "SELECT MasterAccounts.CustomerID as ID, FirstName, LastName, Login, ExpireDate, AutoBill,MaxConnectTime,
	TO_DAYS(ExpireDate)-TO_DAYS(now()) as tdays,
	TO_DAYS(now()) - TO_DAYS(LastUse) as ldays
	FROM MasterAccounts, SubAccounts
	WHERE MasterAccounts.CustomerID = SubAccounts.CustomerID
	AND AccountType='permanent'
	ORDER BY $order DESC";

$res = mysql_query($sql);


?><HTML>
<HEAD>
</HEAD>
<BODY bgcolor=white>
<BR>
<H2>IPAD Accounts.</H2>
<TABLE border=0>
<TR><TH>Name</TH><TH>Login</TH>
<TH><A HREF="IPAD-check.php?order=ExpireDate">Expire Date</A></TH>
<TH><A Href="IPAD-check.php?order=MaxConnectTime">MaxCon</A></TH>
<TH>Last Payment</TH></TR>
<?

while ($row = mysql_fetch_array($res)){
	if ($i++%2)
		$bgcolor="#EEEEEE";
	else
		$bgcolor="#FFFFFF";
	print "<TR bgcolor=$bgcolor>";
	print "<TD><A HREF=\"user.php?ID=$row[ID]\">$row[FirstName] $row[LastName]</TD>";
	print "<TD>$row[Login]</TD>";
	if ($row[tdays] < 1){
		$fontcolor = "RED";
	}else{
		$fontcolor = "BLACK";
	}
	
	if ($row[tdays] > 31){
		$fontcolor = "BLUE";
	}

	

	print "<TD><FONT COLOR=$fontcolor>$row[ExpireDate] ($row[tdays])";
	if ($row[ldays]>30)
		print " <IMG SRC=\"sad.gif\"> ";
	print "</TD>";

	#if ($row[AutoBill] > 0){
	#	$asql = "SELECT PlanName FROM PlanTypes WHERE PlanID = $row[AutoBill]";
	#	$ares = mysql_query($asql);
	#	print mysql_error();
	#	print "<TD>".mysql_result($ares,0)."</TD>";
	#}else{
	#	print "<TD><B>No AutoBill!</B></TD>";
	#}

	print "<TD>$row[MaxConnectTime]</TD>";

	print "<TD>";
	$psql = "SELECT to_days(now()) - to_days(PaymentDate), Purchase
		FROM Payments 
		WHERE CustomerID=$row[ID]
		ORDER BY PaymentDate DESC
		LIMIT 1";
	$pres = mysql_query($psql);
	if (mysql_num_rows($pres)){
		$prow = mysql_fetch_row($pres);
		print "$prow[1] ($prow[0])";
	}else{
		print '&nbsp;';
	}
	print "</TD>";	

	print "</tr>\n";

}
?></TABLE>

<IMG SRC="sad.gif"> indicates an account that has not been used in 30 days.

</body>
</html>
Return current item: Total ISP