diff --git a/admin/index.php b/admin/index.php
index 4076aed..532ce0d 100644
--- a/admin/index.php
+++ b/admin/index.php
@@ -34,6 +34,8 @@
echo "Awards Management
";
echo "Judging Management
";
echo "
";
+ echo "Enter Winning Projects
";
+ echo "
";
echo "Communication (Send Emails)
";
send_footer();
diff --git a/admin/reports.php b/admin/reports.php
index df1f006..2bb1328 100644
--- a/admin/reports.php
+++ b/admin/reports.php
@@ -76,5 +76,10 @@ echo "";
echo "CSV ";
echo "PDF ";
+ echo "
";
+ echo "
";
+ echo i18n("Award Ceremony Script").": ";
+ echo "PDF ";
+ echo "CSV ";
send_footer();
?>
diff --git a/admin/reports_acscript.php b/admin/reports_acscript.php
new file mode 100644
index 0000000..0f89eba
--- /dev/null
+++ b/admin/reports_acscript.php
@@ -0,0 +1,131 @@
+
+ require("../common.inc.php");
+ auth_required('admin');
+ require("../lpdf.php");
+ require("../lcsv.php");
+
+ $type=$_GET['type'];
+ if(!$type) $type="pdf";
+
+ if($type=="pdf")
+ {
+
+ $rep=new lpdf( i18n($config['fairname']),
+ i18n("Awards Ceremony Script"),
+ $_SERVER['DOCUMENT_ROOT'].$config['SFIABDIRECTORY']."/data/logo-200.gif"
+ );
+
+ $rep->newPage();
+ $rep->setFontSize(11);
+ }
+ else if($type=="csv")
+ {
+ $rep=new lcsv(i18n("Checkin List"));
+ }
+ $q=mysql_query("SELECT
+ award_awards.id,
+ award_awards.name,
+ award_awards.order AS awards_order,
+ award_types.type
+ FROM
+ award_awards,
+ award_types
+ WHERE
+ award_awards.year='".$config['FAIRYEAR']."'
+ AND award_awards.award_types_id=award_types.id
+ ORDER BY awards_order");
+
+ echo mysql_error();
+
+ if(mysql_num_rows($q))
+ {
+ while($r=mysql_fetch_object($q))
+ {
+ $rep->heading("$r->name ($r->type)");
+
+ $pq=mysql_query("SELECT
+ award_prizes.prize,
+ award_prizes.number,
+ award_prizes.id,
+ award_prizes.cash,
+ award_prizes.scholarship,
+ winners.projects_id,
+ projects.projectnumber,
+ projects.title,
+ 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
+ award_awards_id='$r->id'
+ AND award_prizes.year='".$config['FAIRYEAR']."'
+ ORDER BY
+ `order`");
+ echo mysql_error();
+ $prevprizeid=-1;
+ while($pr=mysql_fetch_object($pq))
+ {
+ if($prevprizeid!=$pr->id)
+ {
+ $prizetext=$pr->prize;
+
+ if($pr->cash || $pr->scholarship)
+ {
+ $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.= ")";
+
+ }
+ $rep->addText($prizetext);
+
+ $prevprizeid=$pr->id;
+ }
+
+ if($pr->projectnumber)
+ {
+ $rep->addText( " ($pr->projectnumber) $pr->title");
+
+ $sq=mysql_query("SELECT students.firstname,
+ students.lastname,
+ 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;
+ while($studentinfo=mysql_fetch_object($sq))
+ {
+ if($studnum>0) $students.=", ";
+ $students.="$studentinfo->firstname $studentinfo->lastname";
+ $studnum++;
+
+ //we will assume that they are coming from the same school, so lets just grab the last students school
+ //and use it.
+ $school=$studentinfo->school;
+ }
+ $rep->addText($students);
+ $rep->addText(" School: $school");
+ }
+ else
+ {
+ $rep->addText(" Prize not awarded");
+ }
+ }
+ $rep->nextLine();
+ }
+
+ }
+ $rep->output();
+?>
diff --git a/admin/winners.php b/admin/winners.php
new file mode 100644
index 0000000..99e7bd1
--- /dev/null
+++ b/admin/winners.php
@@ -0,0 +1,373 @@
+
+/*
+ This file is part of the 'Science Fair In A Box' project
+ SFIAB Website: http://www.sfiab.ca
+
+ Copyright (C) 2005 Sci-Tech Ontario Inc
+ Copyright (C) 2005 James Grant
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation, version 2.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+?>
+
+ require("../common.inc.php");
+ auth_required('admin');
+
+ send_header("Administration - Award Winners");
+
+ if($_GET['award_sponsors_id']) $award_sponsors_id=$_GET['award_sponsors_id'];
+ else if($_POST['award_sponsors_id']) $award_sponsors_id=$_POST['award_sponsors_id'];
+
+ if($_GET['award_types_id']) $award_types_id=$_GET['award_types_id'];
+ else if($_POST['award_types_id']) $award_types_id=$_POST['award_types_id'];
+
+
+
+echo "<< ".i18n("Back to Administration")."\n";
+
+if($_GET['edit']) $edit=$_GET['edit'];
+if($_POST['edit']) $edit=$_POST['edit'];
+
+if($_GET['action']) $action=$_GET['action'];
+if($_POST['action']) $action=$_POST['action'];
+
+if($action=="addwinner")
+{
+ if($_POST['winner'])
+ {
+ //first check how many we are allowed to have
+ $q=mysql_query("SELECT number FROM award_prizes WHERE id='".$_POST['prize_id']."'");
+ echo mysql_Error();
+ $r=mysql_fetch_object($q);
+ $number=$r->number;
+
+ $q=mysql_query("SELECT COUNT(*) AS count FROM winners WHERE awards_prizes_id='".$_POST['prize_id']."'");
+ echo mysql_Error();
+ $r=mysql_fetch_object($q);
+ $count=$r->count;
+
+ if($count<$number)
+ {
+ mysql_query("INSERT INTO winners (awards_prizes_id,projects_id,year) VALUES ('".$_POST['prize_id']."','".$_POST['winner']."','".$config['FAIRYEAR']."')");
+ echo happy(i18n("Winning project added"));
+ }
+ else
+ {
+ echo error(i18n("This prize cannot accept any more winners. Maximum: %1",array($number)));
+ }
+ }
+ $action="edit";
+}
+
+if($action=="delete")
+{
+ if($_GET['prize_id'] && $_GET['project_id'])
+ {
+ mysql_query("DELETE FROM winners WHERE awards_prizes_id='".$_GET['prize_id']."' AND projects_id='".$_GET['project_id']."'");
+ echo happy(i18n("Winning project removed"));
+ }
+ $action="edit";
+}
+
+if($action=="edit" && $edit)
+{
+ echo "<< Back to Winners List
";
+ $q=mysql_query("SELECT
+ award_awards.id,
+ award_awards.name,
+ award_awards.order AS awards_order,
+ award_types.type
+ FROM
+ award_awards,
+ award_types
+ WHERE
+ award_awards.year='".$config['FAIRYEAR']."'
+ AND award_awards.award_types_id=award_types.id
+ AND award_awards.id='$edit'
+ ");
+
+ echo mysql_error();
+
+ if($r=mysql_fetch_object($q))
+ {
+
+ echo "
";
+ $prjq=mysql_query("SELECT
+ award_awards.id,
+ award_awards_projectcategories.projectcategories_id,
+ award_awards_projectdivisions.projectdivisions_id,
+ projects.projectnumber,
+ projects.title,
+ projects.id AS projects_id
+ FROM
+ award_awards,
+ award_awards_projectcategories,
+ award_awards_projectdivisions,
+ projects
+ WHERE
+ award_awards.id='$r->id'
+ AND award_awards.id=award_awards_projectcategories.award_awards_id
+ AND award_awards.id=award_awards_projectdivisions.award_awards_id
+ AND projects.projectcategories_id=award_awards_projectcategories.projectcategories_id
+ AND projects.projectdivisions_id=award_awards_projectdivisions.projectdivisions_id
+ AND projects.projectnumber is not null
+ AND projects.year='".$config['FAIRYEAR']."'
+ ORDER BY
+ projectnumber
+ ");
+ echo mysql_error();
+ $projects=array();
+ while($prjr=mysql_fetch_object($prjq))
+ {
+ $projects[$prjr->projects_id]=array(
+ "id"=>$prjr->projects_id,
+ "projectnumber"=>$prjr->projectnumber,
+ "title"=>$prjr->title
+ );
+ }
+
+ $winq=mysql_query("SELECT
+ winners.projects_id
+ FROM
+ winners,award_prizes,award_awards
+ WHERE
+ award_awards.id='$r->id'
+ AND award_prizes.award_awards_id=award_awards.id
+ AND winners.awards_prizes_id=award_prizes.id
+ ORDER BY
+ projects_id
+ ");
+ echo mysql_error();
+ $alreadywinners=array();
+ while($winr=mysql_fetch_object($winq))
+ {
+ $alreadywinners[]=$winr->projects_id;
+ }
+ //print_r($alreadywinners);
+ /*
+ echo "projects:";
+ echo nl2br(print_r($projects,true));
+ echo "
";
+ */
+
+// echo "";
+ echo "";
+ echo " $r->type - \n";
+ echo " $r->name \n";
+ echo "";
+ echo "
";
+
+ $pq=mysql_query("SELECT
+ award_prizes.prize,
+ award_prizes.number,
+ award_prizes.id,
+ award_prizes.cash,
+ award_prizes.scholarship,
+ winners.projects_id,
+ projects.projectnumber,
+ projects.title
+ FROM
+ award_prizes
+ 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'
+ AND award_prizes.year='".$config['FAIRYEAR']."'
+ ORDER BY
+ `order`");
+ echo mysql_error();
+ $prevprizeid=-1;
+ while($pr=mysql_fetch_object($pq))
+ {
+ if($prevprizeid!=$pr->id)
+ {
+ echo "
";
+ echo " ";
+ echo " ";
+ echo "";
+ echo "$pr->prize";
+ if($pr->cash || $pr->scholarship)
+ {
+ echo " (";
+ if($pr->cash && $pr->scholarship)
+ echo "\$$pr->cash cash / \$$pr->scholarship scholarship";
+ else if($pr->cash)
+ echo "\$$pr->cash cash";
+ else if($pr->scholarship)
+ echo "\$$pr->scholarship scholarship";
+ echo ")";
+
+ }
+
+ $cq=mysql_query("SELECT COUNT(*) AS count FROM winners WHERE awards_prizes_id='$pr->id'");
+ echo mysql_Error();
+ $cr=mysql_fetch_object($cq);
+ $count=$cr->count;
+
+ if($count<$pr->number) $color="red"; else $color="green";
+ echo " [".$count."/".$pr->number."]";
+ echo "";
+ $prevprizeid=$pr->id;
+
+ if($count<$pr->number)
+ {
+ echo "";
+ }
+ else
+ echo "
";
+
+ }
+
+ if($pr->projectnumber)
+ {
+ echo " ";
+ echo " ";
+ echo " ";
+ echo " ";
+ echo "id&project_id=$pr->projects_id\">";
+ echo " ($pr->projectnumber) $pr->title";
+ echo "
";
+ }
+ }
+
+ }
+}
+else
+{
+
+ $q=mysql_query("SELECT
+ award_awards.id,
+ award_awards.name,
+ award_awards.order AS awards_order,
+ award_types.type
+ FROM
+ award_awards,
+ award_types
+ WHERE
+ award_awards.year='".$config['FAIRYEAR']."'
+ AND award_awards.award_types_id=award_types.id
+ ORDER BY awards_order");
+
+ echo mysql_error();
+
+ if(mysql_num_rows($q))
+ {
+ echo "
";
+ echo i18n("Choose an award to assign winners");
+ echo "
";
+ echo "
";
+ while($r=mysql_fetch_object($q))
+ {
+ echo "id\">";
+// echo "";
+ echo " $r->type - \n";
+ echo " $r->name \n";
+ echo "";
+ echo "
";
+
+ $pq=mysql_query("SELECT
+ award_prizes.prize,
+ award_prizes.number,
+ award_prizes.id,
+ award_prizes.cash,
+ award_prizes.scholarship,
+ winners.projects_id,
+ projects.projectnumber,
+ projects.title
+ FROM
+ award_prizes
+ 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'
+ AND award_prizes.year='".$config['FAIRYEAR']."'
+ ORDER BY
+ `order`");
+ echo mysql_error();
+ $prevprizeid=-1;
+ while($pr=mysql_fetch_object($pq))
+ {
+ if($prevprizeid!=$pr->id)
+ {
+ echo " ";
+ echo " ";
+ echo "";
+ echo "$pr->prize";
+ if($pr->cash || $pr->scholarship)
+ {
+ echo " (";
+ if($pr->cash && $pr->scholarship)
+ echo "\$$pr->cash cash / \$$pr->scholarship scholarship";
+ else if($pr->cash)
+ echo "\$$pr->cash cash";
+ else if($pr->scholarship)
+ echo "\$$pr->scholarship scholarship";
+ echo ")";
+
+ }
+ $cq=mysql_query("SELECT COUNT(*) AS count FROM winners WHERE awards_prizes_id='$pr->id'");
+ echo mysql_Error();
+ $cr=mysql_fetch_object($cq);
+ $count=$cr->count;
+
+ if($count<$pr->number) $color="red"; else $color="green";
+ echo " [".$count."/".$pr->number."]";
+ echo "";
+ echo "
";
+ $prevprizeid=$pr->id;
+ }
+
+ if($pr->projectnumber)
+ {
+ echo " ";
+ echo " ";
+ echo " ";
+ echo " ";
+ echo "($pr->projectnumber) $pr->title";
+ echo "
";
+ }
+ else
+ {
+ /*
+ echo " ";
+ echo " ";
+ echo " ";
+ echo " ";
+ echo "No winner(s) specified";
+ */
+ }
+ }
+ echo "
";
+ }
+
+ }
+}
+
+ send_footer();
+
+?>
diff --git a/db/db.update.5.sql b/db/db.update.5.sql
index 3258a35..9fbba5f 100644
--- a/db/db.update.5.sql
+++ b/db/db.update.5.sql
@@ -1 +1,13 @@
ALTER TABLE `award_awards` ADD `presenter` VARCHAR( 128 ) NOT NULL AFTER `criteria` ;
+CREATE TABLE `winners` (
+ `id` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
+ `awards_prizes_id` INT UNSIGNED NOT NULL ,
+ `projects_id` INT UNSIGNED NOT NULL ,
+ `year` INT UNSIGNED NOT NULL ,
+ PRIMARY KEY ( `id` )
+);
+ALTER TABLE winners ADD UNIQUE (
+ awards_prizes_id,
+ projects_id,
+ year
+);
diff --git a/lpdf.php b/lpdf.php
index 33cbb9a..ddecc30 100644
--- a/lpdf.php
+++ b/lpdf.php
@@ -52,6 +52,8 @@ class lpdf
var $current_nametag_col_index=0;
var $current_nametag_row_index=1;
+ var $currentFontSize=12;
+
function loc($inch)
{
return $inch*72;
@@ -117,7 +119,12 @@ class lpdf
pdf_setlinewidth($this->pdf,0.3);
if($this->page_style=="normal")
+ {
$this->addHeaderAndFooterToPage();
+ //make sure we set the font back to whatever it used to be
+ //because adding header/footer changes the fontsize
+ $this->setFontSize($this->currentFontSize);
+ }
}
function vspace($space)
@@ -161,7 +168,11 @@ class lpdf
if(!$nl)
$this->yloc-=$lineheight/72;
+
+
$nr=pdf_show_boxed($this->pdf,$textstr, $this->loc($this->page_margin),$this->loc($this->yloc),$this->loc($this->content_width),$lineheight,$align,null);
+ if($this->yloc< (0.9 + $lineheight/72) )
+ $this->newPage();
if($nr==$prevnr)
{
@@ -333,7 +344,7 @@ class lpdf
//12/72 is height of the heading
//4/72 is the space under the heading
if($this->yloc< (1.1 + 12/72 + 4/72) )
- $this->newPage($this->page_width,$this->page_height);
+ $this->newPage();
pdf_setfont($this->pdf,$this->headerfont,12);
//move down the full line height