Location: PHPKode > projects > Total ISP > total-isp/callweekall.php
<?include "./auth.inc.php";
if (!$n)
	$n=20;

if (!$order)
	$order='top';

if (!$type)
	$type='bytes';

if (!$year)
	$year=date("Y");

if ($archive)
        $radacct = 'radacctarchive';
else
        $radacct = 'radacct';

$red=56000000;


function weekofyear() {
        $d = 1;
        while (date("w",mktime(0,0,0,1,$d,date("Y"))) != 1) {
                $d++;
        };
        return(floor((date("z")-$d+7)/7.0)+1);
}


if (!$week)
	$week=weekofyear()-1;

?>
<HTML>
<HEAD></HEAD>
<BODY bgcolor=white>
<FORM>
<P><SELECT NAME=order><option value="top"<?
	if ($order=='top')
		print " selected";
?>>Top</option>
<option value="bottom""<?
        if ($order=='bottom')
                print " selected";
?>>Bottom</option> 
</SELECT>
 
<INPUT TYPE=TEXT SIZE=4 NAME=n value="<? echo $n ?>"> 

<SELECT NAME="type">
<option value="bytes"<? if ($type=='bytes') print " SELECTED"; ?>>Downloaders</option>
<option value="ibytes"<? if ($type=='ibytes') print " SELECTED"; ?>>Uploaders</option>
<option value="atime"<? if ($type=='atime') print " SELECTED"; ?>>Time Users</option>
<option value="calls"<? if ($type=='calls') print " SELECTED"; ?>>Callers</option>

</SELECT>
for Week
<INPUT TYPE=TEXT Name=week SIZE=2 VALUE="<? echo $week ?>">

Year 
<SELECT NAME="year">
<option value="1998"<? if ($year=='1998') print " selected"; ?>>1998</option>
<option value="1999"<? if ($year=='1999') print " selected"; ?>>1999</option>
<option value="2000"<? if ($year=='2000') print " selected"; ?>>2000</option>
<option value="2001"<? if ($year=='2001') print " selected"; ?>>2001</option>

</SELECT>
Payments
<input type=checkbox name=recentpay <? if ($recentpay) print "checked"; ?>>

<INPUT TYPE=SUBMIT VALUE="Change">
<?
include "./hms.inc.php";
include "./mysql.inc.php";

if ($order=='top')
	$DESC='DESC';
else
	$DESC='';


$sql="SELECT UserName, sum(AcctOutputOctets) as bytes,
sum(AcctSessionTime) as atime, sum(AcctInputOctets) as ibytes, count(UserName) as calls, AccountType 
FROM $radacct, SubAccounts WHERE WeekNumber=$week AND YEAR(realtime)=$year And Login=UserName GROUP BY UserName ORDER BY
$type $DESC
LIMIT $n";

$result=mysql_query($sql);
?><TABLE border=1>
<TR><TH>UserName</TH><TH>Account Type</TH><TH>MB Out</TH><TH>Time</TH><TH>%33.6</TH><TH>Mb In</TH><TH>Calls</TH>
<? if ($recentpay) print "<TD>Days since last Payment</TD>"; ?>
</TR>
<?
while ($row=mysql_fetch_row($result)){
	print "<TR>";
	print "<TD><A HREF=\"jump.php?username=$row[0]\">$row[0]</A></TD>";
	print "<TD>$row[5]</TD><TD>";
	if ($row[1] > $red)
		print "<FONT COLOR=RED>";
	print intval($row[1]/1000000);
	print "</TD><TD>";
	print hhms($row[2]);
	print "</TD><TD>";
	if ($row[2])
	$percent=intval(100*($row[1]/$row[2])/4200);
	if ($percent>40)
		print "<FONT COLOR=RED>";
	print $percent." %";
	if ($row[1])
	printf("<FONT SIZE=-2> (%01.2f)",$row[3]/$row[1]);
	print "</TD><TD>";
	print intval($row[3]/1000000);
	print "</TD><TD>";
	print $row[4];
	print "</TD>";
	if ($recentpay){
		#look for payments in the last week?
		$psql = "SELECT TO_DAYS(now())-TO_DAYS(PaymentDate), Purchase FROM Payments, SubAccounts 
		WHERE SubAccounts.CustomerID=Payments.CustomerID
		AND Login='$row[0]' ORDER BY PaymentDate DESC LIMIT 1";
		$pres = mysql_query($psql);
		#print mysql_error();
		if (mysql_num_rows($pres)){
			$ndays = mysql_result($pres,0);
			print "<TD>";
			if ($ndays < 9)
				print "($ndays) ".mysql_result($pres,0,1);
			else
				print $ndays;
			print "</TD>";
		}
	}
	print "</TR>";

}
?>
</TABLE>

<A HREF="cvimage.php?week=<? echo $week ?>">See Call Volume Graph</A> 

</BODY>
</HTML>

Return current item: Total ISP