Breakout the stats for agecategory/division into a nicer-to-view table format

This commit is contained in:
james 2007-12-12 20:57:51 +00:00
parent 4c71598eab
commit e99b57c4fa

View File

@ -133,12 +133,14 @@ else $wherestatus="";
$stats_totalstudents=0;
$stats_divisions=array();
$stats_categories=array();
$stats_catdiv=array();
while($r=mysql_fetch_object($q))
{
$stats_totalprojects++;
$stats_divisions[$r->projectdivisions_id]++;
$stats_categories[$r->projectcategories_id]++;
$stats_catdiv[$r->projectcategories_id][$r->projectdivisions_id]++;
switch($r->status)
{
@ -209,17 +211,39 @@ else $wherestatus="";
echo "<tr><td><b>".i18n("Total Students").":</td><td align=\"right\"> $stats_totalstudents</td></tr>\n";
echo "<tr><td colspan=\"2\"><hr /></td></tr>";
echo "<tr><td colspan=\"2\"><h3>".i18n("Projects per age category")."</h3></td></tr>";
echo "<tr><td colspan=\"2\"><h3>".i18n("Projects per age category / division")."</h3></td></tr>";
$q=mysql_query("SELECT * FROM projectcategories WHERE year='".$config['FAIRYEAR']."' ORDER BY id");
while($r=mysql_fetch_object($q))
echo "<tr><td><b>".i18n($r->category).":</td><td align=\"right\">".($stats_categories[$r->id]?$stats_categories[$r->id]:"0")."</td></tr>\n";
$cats[$r->id]=$r->category;
echo "<tr><td colspan=\"2\"><hr /></td></tr>";
echo "<tr><td colspan=\"2\"><h3>".i18n("Projects per division")."</h3></td></tr>";
$q=mysql_query("SELECT * FROM projectdivisions WHERE year='".$config['FAIRYEAR']."' ORDER BY id");
while($r=mysql_fetch_object($q))
echo "<tr><td><b>".i18n($r->division).":</td><td align=\"right\">".($stats_divisions[$r->id]?$stats_divisions[$r->id]:"0")."</td></tr>\n";
$divs[$r->id]=$r->division;
echo "<tr><td colspan=\"2\">";
echo "<table class=\"tableview\">";
echo "<tr><td></td>";
foreach($cats AS $c=>$cn) {
echo "<th>$cn</th>";
}
echo "<th>".i18n("Total")."</th>";
echo "</tr>";
foreach($divs AS $d=>$dn) {
echo "<tr><td><b>$dn</b></td>";
foreach($cats AS $c=>$cn)
echo "<td align=\"center\">".($stats_catdiv[$c][$d]?$stats_catdiv[$c][$d]:0)."</td>";
echo "<td align=\"center\"><b>".($stats_divisions[$d]?$stats_divisions[$d]:0)."</b></td>";
echo "</tr>";
}
echo "<tr><td><b>".i18n("Total")."</b></td>";
foreach($cats AS $c=>$cn) {
echo "<td align=\"center\"><b>".($stats_categories[$c]?$stats_categories[$c]:0)."</b></td>";
}
echo "<td align=\"center\"><b>".($total_projects?$total_projects:0)."</b></td>";
echo "</tr>";
echo "</table>";
echo "</td></tr></table>";
echo "<br />";
echo i18n("Note: statistics reflect the numbers of the current 'Status' selected at the top of the page");