diff --git a/admin/judges_teams.php b/admin/judges_teams.php
index 8b5cd385..aa7a6ab2 100644
--- a/admin/judges_teams.php
+++ b/admin/judges_teams.php
@@ -350,6 +350,8 @@ function switchjudgeinfo()
$teams=array();
while($r=mysql_fetch_object($q))
{
+ $teamnumbers[$r->num]=1;
+
if($r->id!=$lastteamid)
{
$teams[$r->id]['id']=$r->id;
@@ -367,17 +369,20 @@ function switchjudgeinfo()
}
//echo nl2br(print_r($teams,true));
- if($lastteamnum==-1) $newteamid=1;
- else $newteamid=$lastteamnum+1;
-
+ //start at 1, and find the next available team number
+ $newteamnum=1;
+ while($teamnumbers[$newteamnum]==1)
+ {
+ $newteamnum++;
+ }
echo "
";
diff --git a/admin/reports.php b/admin/reports.php
index b8161104..b676c6cf 100644
--- a/admin/reports.php
+++ b/admin/reports.php
@@ -46,5 +46,12 @@ echo "";
echo i18n("Judges List").": ";
echo "Judge List (CSV) ";
+ echo "
";
+ echo i18n("Judging Teams").": ";
+ echo "List (CSV) ";
+ echo "List (PDF) ";
+ echo "Team View (CSV) ";
+ echo "Team View (PDF) ";
+
send_footer();
?>
diff --git a/admin/reports_judges_teams.php b/admin/reports_judges_teams.php
new file mode 100644
index 00000000..2e4d07b6
--- /dev/null
+++ b/admin/reports_judges_teams.php
@@ -0,0 +1,109 @@
+
+/*
+ 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');
+ require("../lpdf.php");
+ require("../lcsv.php");
+
+ $type=$_GET['type'];
+
+ if($type=="pdf")
+ {
+
+ $rep=new lpdf( i18n($config['fairname']),
+ i18n("Judging Teams"),
+ $_SERVER['DOCUMENT_ROOT'].$config['SFIABDIRECTORY']."/data/logo-200.gif"
+ );
+
+ $rep->newPage();
+ $rep->setFontSize(11);
+ }
+ else if($type=="csv")
+ {
+ $rep=new lcsv(i18n("Judging Teams"));
+ }
+
+ $q=mysql_query("SELECT judges_teams.id,
+ judges_teams.num,
+ judges_teams.name,
+ judges.id AS judges_id,
+ judges.firstname,
+ judges.lastname,
+ judges_teams_link.captain
+
+ FROM
+ judges,
+ judges_teams,
+ judges_teams_link
+ WHERE
+ judges_teams.year='".$config['FAIRYEAR']."' AND
+ judges_teams_link.judges_id=judges.id AND
+ judges_teams_link.judges_teams_id=judges_teams.id
+ ORDER BY
+ name,
+ num,
+ captain DESC,
+ lastname,
+ firstname");
+
+ $lastteamid=-1;
+ $lastteamnum=-1;
+ echo mysql_error();
+ $teams=array();
+ while($r=mysql_fetch_object($q))
+ {
+ if($r->id!=$lastteamid)
+ {
+ $teams[$r->id]['id']=$r->id;
+ $teams[$r->id]['num']=$r->num;
+ $teams[$r->id]['name']=$r->name;
+ $lastteamid=$r->id;
+ $lastteamnum=$r->num;
+ }
+ $teams[$lastteamid]['members'][]=array(
+ "id"=>$r->judges_id,
+ "firstname"=>$r->firstname,
+ "lastname"=>$r->lastname,
+ "captain"=>$r->captain
+ );
+ }
+
+ $table=array();
+
+ $table['header']=array(i18n("Team Num"),i18n("Team Name"),i18n("Captain"),i18n("First Name"),i18n("Last Name"));
+ $table['widths']=array(0.5, 1.5, 0.8, 2.0, 2.0);
+ $table['dataalign']=array("left","left","center","left","left");
+
+ foreach($teams AS $team)
+ {
+ foreach($team['members'] AS $member)
+ {
+ $table['data'][]=array($team['num'],$team['name'],$member['captain'],$member['firstname'],$member['lastname']);
+ }
+ }
+
+ $rep->addTable($table);
+ $rep->output();
+?>
diff --git a/admin/reports_judges_teams_view.php b/admin/reports_judges_teams_view.php
new file mode 100644
index 00000000..128bc35e
--- /dev/null
+++ b/admin/reports_judges_teams_view.php
@@ -0,0 +1,116 @@
+
+/*
+ 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');
+ require("../lpdf.php");
+ require("../lcsv.php");
+
+ $type=$_GET['type'];
+
+ if($type=="pdf")
+ {
+
+ $rep=new lpdf( i18n($config['fairname']),
+ i18n("Judging Teams View"),
+ $_SERVER['DOCUMENT_ROOT'].$config['SFIABDIRECTORY']."/data/logo-200.gif"
+ );
+
+ $rep->newPage();
+ $rep->setFontSize(11);
+ }
+ else if($type=="csv")
+ {
+ $rep=new lcsv(i18n("Judging Teams View"));
+ }
+
+ $q=mysql_query("SELECT judges_teams.id,
+ judges_teams.num,
+ judges_teams.name,
+ judges.id AS judges_id,
+ judges.firstname,
+ judges.lastname,
+ judges_teams_link.captain
+
+ FROM
+ judges,
+ judges_teams,
+ judges_teams_link
+ WHERE
+ judges_teams.year='".$config['FAIRYEAR']."' AND
+ judges_teams_link.judges_id=judges.id AND
+ judges_teams_link.judges_teams_id=judges_teams.id
+ ORDER BY
+ name,
+ num,
+ captain DESC,
+ lastname,
+ firstname");
+
+ $lastteamid=-1;
+ $lastteamnum=-1;
+ echo mysql_error();
+ $teams=array();
+ while($r=mysql_fetch_object($q))
+ {
+ if($r->id!=$lastteamid)
+ {
+ $teams[$r->id]['id']=$r->id;
+ $teams[$r->id]['num']=$r->num;
+ $teams[$r->id]['name']=$r->name;
+ $lastteamid=$r->id;
+ $lastteamnum=$r->num;
+ }
+ $teams[$lastteamid]['members'][]=array(
+ "id"=>$r->judges_id,
+ "firstname"=>$r->firstname,
+ "lastname"=>$r->lastname,
+ "captain"=>$r->captain
+ );
+ }
+
+ foreach($teams AS $team)
+ {
+ $table=array();
+
+ $table['header']=array(i18n("Captain"),i18n("First Name"),i18n("Last Name"));
+ $table['widths']=array( 1.0, 3.0, 3.0);
+ $table['dataalign']=array("center","left","left");
+
+ $rep->heading($team['name']." (".$team['num'].")");
+
+ foreach($team['members'] AS $member)
+ {
+ $table['data'][]=array($member['captain'],$member['firstname'],$member['lastname']);
+ }
+
+ $rep->addTable($table);
+ $rep->nextline();
+
+ unset($table);
+
+ }
+
+ $rep->output();
+?>
diff --git a/lcsv.php b/lcsv.php
index 23fd3dcb..762c34fc 100644
--- a/lcsv.php
+++ b/lcsv.php
@@ -88,6 +88,18 @@ class lcsv
}
}
+ function heading($str)
+ {
+ $this->csvdata.=$str;
+ $this->csvdata.=$this->newline();
+ }
+
+ function nextline()
+ {
+ $this->csvdata.=$this->newline();
+
+ }
+
function output()
{