diff --git a/admin/reports_acscript.php b/admin/reports_acscript.php index 43af14e..21cc6b3 100644 --- a/admin/reports_acscript.php +++ b/admin/reports_acscript.php @@ -19,6 +19,7 @@ else $show_unawarded_prizes="no"; $show_pronunciation= ($_GET['show_pronunciation'] == 'on') ? TRUE : FALSE; + $group_by_prize= ($_GET['group_by_prize'] == 'on') ? true : false; if(is_array($_GET['show_category'])) { $show_category = array(); @@ -74,11 +75,17 @@ if(!$scriptformat) $scriptformat="default"; ORDER BY awards_order"); echo mysql_error(); +// echo "
"; - if(mysql_num_rows($q)) { - while($r=mysql_fetch_object($q)) { + if(!mysql_num_rows($q)) { + $rep->output(); + exit; + } + $awards = array(); - $pq=mysql_query("SELECT + while($r=mysql_fetch_object($q)) { + + $pq=mysql_query("SELECT award_prizes.prize, award_prizes.number, award_prizes.id, @@ -94,7 +101,7 @@ if(!$scriptformat) $scriptformat="default"; LEFT JOIN winners ON winners.awards_prizes_id=award_prizes.id LEFT JOIN projects ON projects.id=winners.projects_id WHERE - award_awards_id='$r->id' + award_awards_id='{$r->id}' AND award_prizes.year='$foryear' AND award_prizes.excludefromac='0' AND ($and_categories) @@ -103,42 +110,81 @@ if(!$scriptformat) $scriptformat="default"; projects.projectnumber"); echo mysql_error(); - if($show_unawarded_awards=="no") { - $skipAward=true; - while($pr=mysql_fetch_object($pq)) { - if($pr->projectnumber) { - $skipAward=false; + $r->winners = array(); + while($w = mysql_fetch_object($pq)) { + if($r->type == 'Divisional' && $group_by_prize==true) { + /* Search awards for an award name that matches this prize */ + $found = false; + foreach($awards as &$p_award) { + if($p_award->name == $w->prize) { + /* Match! Set the prize name to the award name, + * and add the prize to the award */ + $w->prize = $r->name; + $p_award->winners[] = $w; + $found = true; +// echo "Add to award {$p_award->name}: "; print_r($w); break; } } - if($skipAward) { - continue; + if($found == false) { + /* Make a new award and set it equal to the prize name */ + $n = $r->name; + $new_award = clone($r); + $new_award->name = $w->prize; + /* Now add the prize with the award's name */ + $w->prize = $n; + $new_award->winners[] = $w; + $awards[] = $new_award; +// echo "Create Award:"; print_r($new_award); } - mysql_data_seek($pq, 0); + + } else { +// echo "Add non-div winner\n"; + $r->winners[] = $w; } - if($scriptformat=="formatted") - $rep->newPage(); + } - if($scriptformat=="default") - $rep->heading("$r->name ($r->type)"); - if($scriptformat=="formatted") { - $rep->setFontBold(); - $rep->addText("$r->name ($r->type)"); - $rep->setFontNormal(); - } - if($r->type!="Divisional") - $rep->addText(i18n("Sponsored by: %1",array($r->organization))); - if($r->presenter) - $rep->addText(i18n("Presented by: %1",array($r->presenter))); - if($r->description) - $rep->addText(i18n("Description: %1",array($r->description))); - if($show_criteria) - $rep->addText(i18n("Criteria: %1",array($r->criteria))); + if($show_unawarded_awards=="no" && count($r->winners) == 0) { + /* No winners */ + continue; + } - if($scriptformat=="formatted") $rep->nextline(); - $prevprizeid=-1; - while($pr=mysql_fetch_object($pq)) { + if($r->type == 'Divisional' && $group_by_prize == true) { + /* Do nothing */ + } else { + $awards[] = $r; + } + } +// echo ''; print_r($awards); + + foreach($awards as $r) { + + if($scriptformat=="formatted") + $rep->newPage(); + + if($scriptformat=="default") + $rep->heading("$r->name ($r->type)"); + if($scriptformat=="formatted") { + $rep->setFontBold(); + $rep->addText("$r->name ($r->type)"); + $rep->setFontNormal(); + } + if($r->type!="Divisional") + $rep->addText(i18n("Sponsored by: %1",array($r->organization))); + if($r->presenter) + $rep->addText(i18n("Presented by: %1",array($r->presenter))); + if($r->description) + $rep->addText(i18n("Description: %1",array($r->description))); + if($show_criteria) + $rep->addText(i18n("Criteria: %1",array($r->criteria))); + + if($scriptformat=="formatted") $rep->nextline(); + + $prevprizeid=-1; + + foreach($r->winners as $pr) { + if($pr->projectnumber || $show_unawarded_prizes=="yes") { if($prevprizeid!=$pr->id) { $prizetext=$pr->prize; @@ -232,6 +278,5 @@ if(!$scriptformat) $scriptformat="default"; $rep->nextLine(); } - } $rep->output(); ?> diff --git a/admin/reports_ceremony.php b/admin/reports_ceremony.php index 21f5319..573f455 100644 --- a/admin/reports_ceremony.php +++ b/admin/reports_ceremony.php @@ -87,6 +87,8 @@ echo ""; echo " "; + echo " ".i18n("Show student name pronunciation").": "; echo ""; echo " ".i18n("Group divisional results by Prize (instead of Award Name). This groups all the honourable mentions in all divisions together, all the bronzes together, etc."). ": "; + echo "".i18n("Include the following age categories").": "; echo "";