2005-05-04 21:23:00 +00:00
|
|
|
<?
|
|
|
|
require("../common.inc.php");
|
2007-11-21 17:02:09 +00:00
|
|
|
require_once("../user.inc.php");
|
2010-07-13 03:30:17 +00:00
|
|
|
user_auth_required('admin');
|
2005-05-04 21:23:00 +00:00
|
|
|
require("../lpdf.php");
|
|
|
|
require("../lcsv.php");
|
|
|
|
|
2007-11-15 20:25:05 +00:00
|
|
|
if($_GET['year']) $foryear=$_GET['year'];
|
|
|
|
else $foryear=$config['FAIRYEAR'];
|
|
|
|
|
2007-12-17 23:20:21 +00:00
|
|
|
if($_GET['awardtype']=="All") $awardtype="";
|
|
|
|
else if($_GET['awardtype']) $awardtype=" AND award_types.type='".mysql_escape_string($_GET['awardtype'])."'";
|
2007-11-15 20:25:05 +00:00
|
|
|
else $awardtype="";
|
|
|
|
|
2007-12-17 23:20:21 +00:00
|
|
|
if($_GET['show_unawarded_awards']=="on") $show_unawarded_awards="yes";
|
|
|
|
else $show_unawarded_awards="no";
|
|
|
|
|
|
|
|
if($_GET['show_unawarded_prizes']=="on") $show_unawarded_prizes="yes";
|
|
|
|
else $show_unawarded_prizes="no";
|
|
|
|
|
2008-02-29 07:10:08 +00:00
|
|
|
$show_pronunciation= ($_GET['show_pronunciation'] == 'on') ? TRUE : FALSE;
|
2010-04-10 07:09:07 +00:00
|
|
|
$group_by_prize= ($_GET['group_by_prize'] == 'on') ? true : false;
|
2008-02-29 07:10:08 +00:00
|
|
|
|
|
|
|
if(is_array($_GET['show_category'])) {
|
|
|
|
$show_category = array();
|
|
|
|
foreach($_GET['show_category'] as $id=>$val) {
|
2010-04-14 14:59:17 +00:00
|
|
|
$show_category[] = "award_awards_projectcategories.projectcategories_id='$id'";
|
2010-04-14 14:26:11 +00:00
|
|
|
}
|
2008-02-29 07:10:08 +00:00
|
|
|
$and_categories = join(' OR ', $show_category);
|
|
|
|
} else {
|
|
|
|
$and_categories = '1';
|
|
|
|
}
|
|
|
|
|
2010-03-02 22:50:49 +00:00
|
|
|
$show_criteria = ($_GET['show_criteria']=='on') ? true : false;
|
|
|
|
|
2005-05-04 21:23:00 +00:00
|
|
|
$type=$_GET['type'];
|
|
|
|
if(!$type) $type="pdf";
|
|
|
|
|
2010-03-22 02:22:04 +00:00
|
|
|
$scriptformat=$_GET['scriptformat'];
|
|
|
|
if(!$scriptformat) $scriptformat="default";
|
|
|
|
|
2010-03-23 17:30:19 +00:00
|
|
|
if($type=="pdf") {
|
2005-05-04 21:23:00 +00:00
|
|
|
$rep=new lpdf( i18n($config['fairname']),
|
|
|
|
i18n("Awards Ceremony Script"),
|
|
|
|
$_SERVER['DOCUMENT_ROOT'].$config['SFIABDIRECTORY']."/data/logo-200.gif"
|
|
|
|
);
|
|
|
|
|
|
|
|
$rep->newPage();
|
2010-03-23 17:30:19 +00:00
|
|
|
if($scriptformat=="default") $rep->setFontSize(12);
|
2010-03-22 02:22:04 +00:00
|
|
|
if($scriptformat=="formatted") $rep->setFontSize(14);
|
2005-05-04 21:23:00 +00:00
|
|
|
}
|
2010-03-23 17:30:19 +00:00
|
|
|
else if($type=="csv") {
|
2006-10-15 21:33:32 +00:00
|
|
|
$rep=new lcsv(i18n("Awards Ceremony Script"));
|
2005-05-04 21:23:00 +00:00
|
|
|
}
|
|
|
|
$q=mysql_query("SELECT
|
|
|
|
award_awards.id,
|
|
|
|
award_awards.name,
|
2007-02-12 22:30:43 +00:00
|
|
|
award_awards.presenter,
|
2007-11-23 21:21:37 +00:00
|
|
|
award_awards.description,
|
2010-03-02 22:50:49 +00:00
|
|
|
award_awards.criteria,
|
2005-05-04 21:23:00 +00:00
|
|
|
award_awards.order AS awards_order,
|
2007-11-15 20:25:05 +00:00
|
|
|
award_types.type,
|
2009-09-09 00:26:12 +00:00
|
|
|
sponsors.organization
|
2005-05-04 21:23:00 +00:00
|
|
|
FROM
|
|
|
|
award_awards,
|
2007-11-15 20:25:05 +00:00
|
|
|
award_types,
|
2010-04-14 14:59:17 +00:00
|
|
|
sponsors,
|
|
|
|
award_awards_projectcategories
|
2005-05-04 21:23:00 +00:00
|
|
|
WHERE
|
2007-11-15 20:25:05 +00:00
|
|
|
award_awards.year='$foryear'
|
|
|
|
AND award_types.year='$foryear'
|
2005-05-04 21:23:00 +00:00
|
|
|
AND award_awards.award_types_id=award_types.id
|
2009-09-09 00:26:12 +00:00
|
|
|
AND award_awards.sponsors_id=sponsors.id
|
2010-04-14 14:59:17 +00:00
|
|
|
AND award_awards.id=award_awards_projectcategories.award_awards_id
|
2006-02-01 05:06:48 +00:00
|
|
|
AND award_awards.excludefromac='0'
|
2010-04-14 14:59:17 +00:00
|
|
|
AND ($and_categories)
|
2007-11-15 20:25:05 +00:00
|
|
|
$awardtype
|
2010-04-14 14:59:17 +00:00
|
|
|
GROUP BY award_awards.id
|
2005-05-04 21:23:00 +00:00
|
|
|
ORDER BY awards_order");
|
|
|
|
|
|
|
|
echo mysql_error();
|
2010-04-10 07:09:07 +00:00
|
|
|
// echo "<pre>";
|
|
|
|
if(!mysql_num_rows($q)) {
|
|
|
|
$rep->output();
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
$awards = array();
|
|
|
|
|
|
|
|
while($r=mysql_fetch_object($q)) {
|
2010-03-23 17:30:19 +00:00
|
|
|
|
2010-04-10 07:09:07 +00:00
|
|
|
$pq=mysql_query("SELECT
|
2005-05-04 21:23:00 +00:00
|
|
|
award_prizes.prize,
|
|
|
|
award_prizes.number,
|
|
|
|
award_prizes.id,
|
|
|
|
award_prizes.cash,
|
|
|
|
award_prizes.scholarship,
|
|
|
|
winners.projects_id,
|
|
|
|
projects.projectnumber,
|
|
|
|
projects.title,
|
2008-02-29 07:10:08 +00:00
|
|
|
projects.projectcategories_id,
|
2005-05-04 21:23:00 +00:00
|
|
|
projects.registrations_id AS reg_id
|
|
|
|
FROM
|
|
|
|
award_prizes
|
|
|
|
LEFT JOIN winners ON winners.awards_prizes_id=award_prizes.id
|
|
|
|
LEFT JOIN projects ON projects.id=winners.projects_id
|
|
|
|
WHERE
|
2010-04-10 07:09:07 +00:00
|
|
|
award_awards_id='{$r->id}'
|
2007-11-15 20:25:05 +00:00
|
|
|
AND award_prizes.year='$foryear'
|
2006-02-01 05:06:48 +00:00
|
|
|
AND award_prizes.excludefromac='0'
|
2005-05-04 21:23:00 +00:00
|
|
|
ORDER BY
|
2010-03-23 17:30:19 +00:00
|
|
|
`order`,
|
|
|
|
projects.projectnumber");
|
2005-05-04 21:23:00 +00:00
|
|
|
echo mysql_error();
|
2007-12-17 17:35:19 +00:00
|
|
|
|
2010-04-10 07:09:07 +00:00
|
|
|
$r->winners = array();
|
2010-04-14 14:26:11 +00:00
|
|
|
$r->awarded_count = 0;
|
2010-04-10 07:09:07 +00:00
|
|
|
while($w = mysql_fetch_object($pq)) {
|
2010-04-14 14:26:11 +00:00
|
|
|
if($w->projects_id)
|
|
|
|
{
|
|
|
|
$r->awarded_count++;
|
|
|
|
}
|
2010-04-10 07:09:07 +00:00
|
|
|
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);
|
2007-12-17 17:35:19 +00:00
|
|
|
break;
|
2005-05-04 21:23:00 +00:00
|
|
|
}
|
|
|
|
}
|
2010-04-10 07:09:07 +00:00
|
|
|
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);
|
2007-12-17 17:35:19 +00:00
|
|
|
}
|
2010-04-10 07:09:07 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
// echo "Add non-div winner\n";
|
|
|
|
$r->winners[] = $w;
|
2010-03-22 02:22:04 +00:00
|
|
|
}
|
2010-04-10 07:09:07 +00:00
|
|
|
}
|
|
|
|
|
2010-04-14 14:26:11 +00:00
|
|
|
if($show_unawarded_awards=="no" && $r->awarded_count == 0) {
|
2010-04-10 07:09:07 +00:00
|
|
|
/* No winners */
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if($r->type == 'Divisional' && $group_by_prize == true) {
|
|
|
|
/* Do nothing */
|
|
|
|
} else {
|
|
|
|
$awards[] = $r;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// echo '<pre>'; 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();
|
|
|
|
|
2010-04-14 14:26:11 +00:00
|
|
|
if($r->awarded_count == 0)
|
|
|
|
{
|
|
|
|
$rep->addText("Not awarded");
|
|
|
|
}
|
|
|
|
|
2010-04-10 07:09:07 +00:00
|
|
|
$prevprizeid=-1;
|
|
|
|
|
|
|
|
foreach($r->winners as $pr) {
|
|
|
|
|
2010-03-23 17:30:19 +00:00
|
|
|
if($pr->projectnumber || $show_unawarded_prizes=="yes") {
|
|
|
|
if($prevprizeid!=$pr->id) {
|
2007-12-17 17:35:19 +00:00
|
|
|
$prizetext=$pr->prize;
|
|
|
|
|
2010-03-23 17:30:19 +00:00
|
|
|
if($pr->cash || $pr->scholarship) {
|
2007-12-17 17:35:19 +00:00
|
|
|
$prizetext.=" (";
|
|
|
|
if($pr->cash && $pr->scholarship)
|
|
|
|
$prizetext.="\$$pr->cash cash / \$$pr->scholarship scholarship";
|
|
|
|
else if($pr->cash)
|
|
|
|
$prizetext.= "\$$pr->cash cash";
|
|
|
|
else if($pr->scholarship)
|
|
|
|
$prizetext.= "\$$pr->scholarship scholarship";
|
|
|
|
$prizetext.= ")";
|
|
|
|
|
|
|
|
}
|
2010-03-23 17:30:19 +00:00
|
|
|
if($scriptformat=="default")
|
|
|
|
$rep->addText($prizetext);
|
|
|
|
if($scriptformat=="formatted") {
|
2010-03-22 02:22:04 +00:00
|
|
|
$rep->setFontBold();
|
|
|
|
$rep->addText($prizetext);
|
|
|
|
$rep->setFontNormal();
|
|
|
|
$rep->nextline();
|
|
|
|
}
|
2007-12-17 17:35:19 +00:00
|
|
|
|
|
|
|
$prevprizeid=$pr->id;
|
|
|
|
}
|
2005-05-04 21:23:00 +00:00
|
|
|
|
2010-03-23 17:30:19 +00:00
|
|
|
if($pr->projectnumber) {
|
|
|
|
if($scriptformat=="default")
|
|
|
|
$rep->addText( " ($pr->projectnumber) $pr->title");
|
2005-05-04 21:23:00 +00:00
|
|
|
|
2007-12-17 17:35:19 +00:00
|
|
|
$sq=mysql_query("SELECT students.firstname,
|
|
|
|
students.lastname,
|
2008-02-29 07:10:08 +00:00
|
|
|
students.pronunciation,
|
2007-12-17 17:35:19 +00:00
|
|
|
students.schools_id,
|
|
|
|
schools.school
|
|
|
|
FROM
|
|
|
|
students,
|
|
|
|
schools
|
|
|
|
WHERE
|
|
|
|
students.registrations_id='$pr->reg_id'
|
|
|
|
AND students.schools_id=schools.id
|
|
|
|
");
|
|
|
|
|
|
|
|
$students=" Students: ";
|
|
|
|
$studnum=0;
|
2008-02-29 07:10:08 +00:00
|
|
|
$pronounce = "";
|
2010-04-14 14:26:11 +00:00
|
|
|
$rawpronounce = "";
|
2010-03-23 17:30:19 +00:00
|
|
|
while($studentinfo=mysql_fetch_object($sq)) {
|
2007-12-17 17:35:19 +00:00
|
|
|
if($studnum>0) $students.=", ";
|
|
|
|
$students.="$studentinfo->firstname $studentinfo->lastname";
|
2008-02-29 07:10:08 +00:00
|
|
|
|
|
|
|
if($studnum>0) $pronounce .= ", ";
|
|
|
|
$pronounce .= "\"{$studentinfo->pronunciation}\"";
|
2010-04-14 14:26:11 +00:00
|
|
|
$rawpronounce .= "{$studentinfo->pronunciation}";
|
2008-02-29 07:10:08 +00:00
|
|
|
|
2010-03-22 02:22:04 +00:00
|
|
|
$student_winner[$studnum] = "$studentinfo->firstname $studentinfo->lastname";
|
|
|
|
$student_win_pronunc[$studnum] = "$studentinfo->pronunciation";
|
2010-04-10 03:45:03 +00:00
|
|
|
$student_school[$studnum] = $studentinfo->school;
|
2007-12-17 17:35:19 +00:00
|
|
|
$studnum++;
|
|
|
|
}
|
2008-02-29 07:10:08 +00:00
|
|
|
|
2010-03-23 17:30:19 +00:00
|
|
|
if($scriptformat=="default") {
|
2010-03-22 02:22:04 +00:00
|
|
|
$rep->addText($students);
|
2010-04-14 14:26:11 +00:00
|
|
|
if(trim($rawpronounce) != "" && $show_pronunciation == TRUE)
|
|
|
|
$rep->addText(" Pronunciation: $pronounce");
|
2010-04-10 03:45:03 +00:00
|
|
|
$rep->addText(" School: {$student_school[0]}");
|
2010-03-22 02:22:04 +00:00
|
|
|
}
|
2010-03-23 17:30:19 +00:00
|
|
|
if($scriptformat=="formatted") {
|
2010-03-22 02:22:04 +00:00
|
|
|
$rep->addTextX("$pr->projectnumber",0.5);
|
2010-04-10 03:45:03 +00:00
|
|
|
for($x=0; $x<$studnum; $x++) {
|
|
|
|
$rep->addTextX($student_winner[$x],1.4);
|
|
|
|
$rep->addTextX($student_school[$x],5.5);
|
2010-04-10 03:56:53 +00:00
|
|
|
if($show_pronunciation == TRUE && $student_win_pronunc[$x]) {
|
|
|
|
$rep->nextline();
|
|
|
|
$rep->addTextX("({$student_win_pronunc[$x]})",2.0);
|
|
|
|
}
|
2010-03-23 17:30:19 +00:00
|
|
|
if($type=="pdf")
|
|
|
|
$rep->nextline();
|
2010-03-22 02:22:04 +00:00
|
|
|
}
|
|
|
|
if(($studnum==1) && ($type == "csv")) $rep->addTextX("");
|
|
|
|
if(($studnum==1) && ($type == "csv")) $rep->addTextX("");
|
2010-04-10 03:45:03 +00:00
|
|
|
$rep->addText($pr->title,'left', 1.4);
|
2010-03-22 02:22:04 +00:00
|
|
|
if($type=="pdf") $rep->nextline();
|
|
|
|
$rep->nextline();
|
|
|
|
}
|
2007-12-17 17:35:19 +00:00
|
|
|
}
|
2010-03-23 17:30:19 +00:00
|
|
|
else {
|
2007-12-17 17:35:19 +00:00
|
|
|
$rep->addText(" Prize not awarded");
|
2005-05-04 21:23:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$rep->nextLine();
|
|
|
|
}
|
|
|
|
|
|
|
|
$rep->output();
|
|
|
|
?>
|