$o.="\t<tr><td align=\"center\" colspan=\"2\">".$dfout[8]." used of ".$dfout[7]." (".$dfout[9]." available)</td></tr>\n";
$o.="\t<tr><td align=\"center\" colspan=\"2\">".floor($dfout[8]/1024)."GB used of ".floor($dfout[7]/1024)."GB (".floor($dfout[10]/1024)."GB available)</td></tr>\n";
$max=10;//Set this to number of users to display in chart
$smarty->assign('title',"Printer Statistics");
$smarty->assign('title',"Printer Statistics");
$sucsDB=NewADOConnection('postgres8');
$sucsDB=NewADOConnection('postgres8');
$sucsDB->Connect('dbname=sucs user=apache');
$sucsDB->Connect('dbname=sucs user=apache');
$sucsDB->SetFetchMode(ADODB_FETCH_ASSOC);
$sucsDB->SetFetchMode(ADODB_FETCH_ASSOC);
$out="<img src=\"/images/printer.graph.php\" alt=\"pie chart of top 12 printer users\"/>";
// $out="<img src=\"/images/printer.graph.php\" alt=\"pie chart of top 12 printer users\"/>";
$table="<table border=1 cellpadding=3>\n<tr>\n<th>Username</th>\n<th>Pages</th>\n<th>Projected Monthly Usage</th>\n<th>Printed This Month</th>\n<th>What it would cost in the library</th></tr>\n";
$table="<table border=1 cellpadding=3>\n<tr>\n<th>Username</th>\n<th>Pages</th>\n<th>Projected Monthly Usage</th>\n<th>Printed This Month</th>\n<th>What it would cost in the library</th></tr>\n";
//pull in all the current users (ie not old) who have printed stuff
//pull in all the current users (ie not old) who have printed stuff
//output the dates of the first and last prints recorded
//output the dates of the first and last prints recorded
$out.="<p>First Data - ".$date['first'][weekday].", ".$date['first'][mday]." ".$date['first'][month]." ".$date['first'][year].", at ".$date['first'][hours].":".$date['first'][minutes].":".$date['first'][seconds]."<br />";
$out.="Last Data - ".$date['last'][weekday].", ".$date['last'][mday]." ".$date['last'][month]." ".$date['last'][year].", at ".$date['last'][hours].":".$date['last'][minutes].":".$date['last'][seconds]."</p>";
$out.="<p>First Data - ".$date['first'][weekday].", ".$date['first'][mday]." ".$date['first'][month]." ".$date['first'][year].", at ".sprintf("%02d:%02d:%02d",$date['first'][hours],$date['first'][minutes],$date['first'][seconds])."<br />";
$out.="Last Data - ".$date['last'][weekday].", ".$date['last'][mday]." ".$date['last'][month]." ".$date['last'][year].", at ".sprintf("%02d:%02d:%02d",$date['last'][hours],$date['last'][minutes],$date['last'][seconds])."</p>";
//do some silly maths to work out lots of silly things
//do some silly maths to work out lots of silly things
$paperarea=round(0.21*0.297*$total,3);//area of paper
$paperarea=round(0.21*0.297*$total,3);//area of paper
$paperweight=round($paperarea*.08,3);//how much that would weigh
$paperweight=round($paperarea*.08,3);//how much that would weigh
$numtrees=round($paperweight/730.296,6);//*very* roughly how many trees that would be
$numtrees=round($paperweight/730.296,6);//*very* roughly how many trees that would be
$cost=round(0.1*$total,2);
$cost=sprintf("£%01.2f",round(0.1*$total,2));
$out.="<p>That's ".$paperarea."m<sup>2</sup> of paper, weighing ".$paperweight."kg!<br>\n";
$out.="<p>That's ".$paperarea."m<sup>2</sup> of paper, weighing ".$paperweight."kg!<br>\n";
$out.="This is equivalent to approximately ".$numtrees." trees.<br>\n";
$out.="This is equivalent to approximately ".$numtrees." trees.<br>\n";
$out.="That would have cost our members a grand total of £".$cost." if it were printed in the library.. not bad for £5!";
$out.="That would have cost our members a grand total of ".$cost." if it were printed in the library.. not bad for £5!";
//done
//done
$out.="<p>Note: The number of pages is the number spooled and may be more than the actual number printed</p>";
$out.="<p>Note: The number of pages is the number spooled and may be more than the actual number printed</p>";