2005-02-23 14:55:01 +00:00
|
|
|
<?
|
|
|
|
/*
|
|
|
|
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 <info@scitechontario.org>
|
|
|
|
Copyright (C) 2005 James Grant <james@lightbox.org>
|
|
|
|
|
|
|
|
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");
|
2007-11-18 23:50:23 +00:00
|
|
|
user_auth_required('committee', 'admin');
|
2005-02-23 14:55:01 +00:00
|
|
|
require("../lpdf.php");
|
|
|
|
require("../lcsv.php");
|
2006-07-11 20:22:42 +00:00
|
|
|
require("../questions.inc.php");
|
2005-02-23 14:55:01 +00:00
|
|
|
|
|
|
|
if(!$_GET['type']) $type="csv";
|
|
|
|
else $type=$_GET['type'];
|
|
|
|
|
|
|
|
if($type=="pdf")
|
|
|
|
{
|
|
|
|
$rep=new lpdf( i18n($config['fairname']),
|
|
|
|
i18n("Judge List"),
|
|
|
|
$_SERVER['DOCUMENT_ROOT'].$config['SFIABDIRECTORY']."/data/logo-200.gif"
|
|
|
|
);
|
|
|
|
|
|
|
|
$rep->newPage();
|
|
|
|
$rep->setFontSize(11);
|
|
|
|
}
|
|
|
|
else if($type=="csv")
|
|
|
|
{
|
|
|
|
$rep=new lcsv(i18n("Judge List"));
|
|
|
|
}
|
|
|
|
|
|
|
|
$table=array();
|
2005-03-09 20:33:16 +00:00
|
|
|
$table['header']=array( i18n("ID"),
|
|
|
|
i18n("Last Name"),
|
2005-02-23 14:55:01 +00:00
|
|
|
i18n("First Name"),
|
|
|
|
i18n("Email"),
|
|
|
|
i18n("Phone Home"),
|
|
|
|
i18n("Phone Work"),
|
|
|
|
i18n("Phone Work Ext"),
|
|
|
|
i18n("Phone Cell"),
|
2006-03-28 23:48:08 +00:00
|
|
|
i18n("Languages"),
|
2005-02-23 14:55:01 +00:00
|
|
|
i18n("Organization"),
|
|
|
|
i18n("Address 1"),
|
|
|
|
i18n("Address 2"),
|
|
|
|
i18n("City"),
|
|
|
|
i18n("Province"),
|
|
|
|
i18n("Postal Code"),
|
2005-03-29 20:44:28 +00:00
|
|
|
i18n("Highest PostSecDeg"),
|
2005-02-23 14:55:01 +00:00
|
|
|
i18n("Professional Quals"),
|
|
|
|
i18n("Expertise Other"));
|
|
|
|
|
2006-07-11 20:22:42 +00:00
|
|
|
/* Append headers for all the custom questions */
|
|
|
|
$qs=questions_load_questions('judgereg', $config['FAIRYEAR']);
|
|
|
|
$keys = array_keys($qs);
|
|
|
|
foreach($keys as $qid) {
|
|
|
|
$table['header'][] = i18n($qs[$qid]['db_heading']);
|
|
|
|
}
|
|
|
|
|
2005-03-30 16:04:32 +00:00
|
|
|
|
2006-02-07 20:19:56 +00:00
|
|
|
//grab the list of divisions, because the last fields of the table will be the sub-divisions
|
|
|
|
$q=mysql_query("SELECT * FROM projectcategories WHERE year='".$config['FAIRYEAR']."' ORDER BY id");
|
|
|
|
$numcats=mysql_num_rows($q);
|
|
|
|
$catheadings=array();
|
|
|
|
while($r=mysql_fetch_object($q))
|
|
|
|
{
|
|
|
|
$cats[]=$r->id;
|
|
|
|
$catheadings[]="$r->category (out of 5)";
|
|
|
|
}
|
2005-03-30 16:04:32 +00:00
|
|
|
//grab the list of divisions, because the last fields of the table will be the sub-divisions
|
2005-11-26 18:59:44 +00:00
|
|
|
$q=mysql_query("SELECT * FROM projectdivisions WHERE year='".$config['FAIRYEAR']."' ORDER BY id");
|
2005-03-30 16:04:32 +00:00
|
|
|
$divheadings=array();
|
|
|
|
while($r=mysql_fetch_object($q))
|
|
|
|
{
|
|
|
|
$divs[]=$r->id;
|
|
|
|
$divheadings[]="$r->division (out of 5)";
|
|
|
|
$divheadings[]="$r->division subdivisions";
|
|
|
|
}
|
|
|
|
|
|
|
|
//now append the arrays together
|
2006-02-07 20:19:56 +00:00
|
|
|
$table['header']=array_merge($table['header'],array_merge($catheadings,$divheadings));
|
2005-03-30 16:04:32 +00:00
|
|
|
|
|
|
|
|
2005-02-23 14:55:01 +00:00
|
|
|
//fill these in if we ever make this PDFable
|
|
|
|
$table['widths']=array();
|
|
|
|
$table['dataalign']=array();
|
|
|
|
|
2005-03-29 20:44:28 +00:00
|
|
|
$q=mysql_query("SELECT
|
2006-02-07 20:19:56 +00:00
|
|
|
judges.*
|
2005-03-29 20:44:28 +00:00
|
|
|
FROM
|
|
|
|
judges,
|
2005-03-29 20:51:37 +00:00
|
|
|
judges_years
|
2005-03-29 20:44:28 +00:00
|
|
|
WHERE
|
|
|
|
judges.complete='yes' AND
|
|
|
|
judges_years.year='".$config['FAIRYEAR']."' AND
|
2006-02-07 20:19:56 +00:00
|
|
|
judges.id=judges_years.judges_id
|
2005-03-29 20:44:28 +00:00
|
|
|
ORDER BY
|
|
|
|
lastname,
|
|
|
|
firstname");
|
2005-02-23 14:55:01 +00:00
|
|
|
while($r=mysql_fetch_object($q))
|
|
|
|
{
|
2005-03-29 21:09:34 +00:00
|
|
|
$expertise_other=str_replace("\n"," ",$r->expertise_other);
|
|
|
|
$expertise_other=str_replace("\r","",$expertise_other);
|
|
|
|
|
2006-02-07 20:19:56 +00:00
|
|
|
$subdivq=mysql_query("SELECT judges_expertise.*,
|
|
|
|
projectsubdivisions.subdivision,
|
|
|
|
projectsubdivisions.projectdivisions_id AS parent_id
|
|
|
|
FROM judges_expertise
|
|
|
|
LEFT JOIN projectsubdivisions ON judges_expertise.projectsubdivisions_id=projectsubdivisions.id
|
|
|
|
WHERE
|
|
|
|
judges_id='$r->id' AND
|
|
|
|
judges_expertise.year='".$config['FAIRYEAR']."'
|
|
|
|
ORDER BY
|
|
|
|
projectdivisions_id,
|
|
|
|
projectsubdivisions_id");
|
2005-03-30 16:07:33 +00:00
|
|
|
if(isset($judge_divs)) unset($judge_divs); $judge_divs=array();
|
|
|
|
if(isset($judge_subdivs)) unset($judge_subdivs); $judge_subdivs=array();
|
|
|
|
if(isset($divdata)) unset($divdata); $divdata=array();
|
2006-02-07 20:19:56 +00:00
|
|
|
if(isset($catdata)) unset($catdata); $catdata=array();
|
2005-03-30 16:07:33 +00:00
|
|
|
|
2005-03-30 16:04:32 +00:00
|
|
|
while($subdivr=mysql_fetch_object($subdivq))
|
|
|
|
{
|
|
|
|
if($subdivr->projectdivisions_id)
|
|
|
|
{
|
|
|
|
$judge_divs[$subdivr->projectdivisions_id]=$subdivr->val;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
$judge_subdivs[$subdivr->parent_id][]=$subdivr->subdivision;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
foreach($divs as $div)
|
|
|
|
{
|
|
|
|
$divdata[]=$judge_divs[$div];
|
|
|
|
if(count($judge_subdivs[$div]))
|
|
|
|
$divdata[]=implode(",",$judge_subdivs[$div]);
|
|
|
|
else
|
|
|
|
$divdata[]="";
|
|
|
|
}
|
|
|
|
|
2006-02-07 20:19:56 +00:00
|
|
|
|
|
|
|
$catprefq=mysql_query("SELECT judges_catpref.rank, projectcategories.category
|
|
|
|
FROM judges_catpref,
|
|
|
|
projectcategories
|
|
|
|
WHERE
|
|
|
|
projectcategories.year='".$config['FAIRYEAR']."' AND
|
|
|
|
judges_catpref.year='".$config['FAIRYEAR']."' AND
|
|
|
|
judges_catpref.judges_id='".$r->id."' AND
|
|
|
|
judges_catpref.projectcategories_id=projectcategories.id
|
|
|
|
ORDER BY
|
|
|
|
judges_catpref.projectcategories_id");
|
|
|
|
if(mysql_num_rows($catprefq)!=$numcats)
|
|
|
|
{
|
|
|
|
//somethings messed up, we're missing data or have too much, so we really cant draw any conclusions from the data we have
|
|
|
|
//so instead, we will simply blank these out to 0
|
|
|
|
for($x=0;$x<$numcats;$x++)
|
|
|
|
$catdata[]=0;
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
while($cr=mysql_fetch_object($catprefq))
|
|
|
|
{
|
|
|
|
//this is stored in teh db as -2 ... +2 so if we add 2 we get a nice 0 ... 5
|
|
|
|
$catdata[]=$cr->rank+2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-03-28 23:50:36 +00:00
|
|
|
$languages="";
|
2006-03-28 23:48:08 +00:00
|
|
|
//and finally, grab their languages
|
|
|
|
$langq=mysql_query("SELECT * FROM judges_languages WHERE judges_id='".$r->id."' ORDER BY languages_lang");
|
|
|
|
while($langr=mysql_fetch_object($langq))
|
|
|
|
$languages.=$langr->languages_lang."/";
|
|
|
|
//stip off the last /
|
|
|
|
$languages=substr($languages,0,-1);
|
|
|
|
|
2005-03-30 16:04:32 +00:00
|
|
|
// print_r($judge_divs);
|
|
|
|
// print_r($judge_subdivs);
|
|
|
|
|
2006-07-11 20:22:42 +00:00
|
|
|
$qarray = array();
|
|
|
|
$qans = questions_load_answers('judgereg', $r->id, $config['FAIRYEAR']);
|
|
|
|
$keys = array_keys($qans);
|
|
|
|
foreach($keys as $qid) {
|
|
|
|
$qarray[] = $qans[$qid];
|
|
|
|
}
|
|
|
|
|
2005-03-30 16:04:32 +00:00
|
|
|
$tmp=array(
|
2005-03-09 20:33:16 +00:00
|
|
|
$r->id,
|
2005-02-23 14:55:01 +00:00
|
|
|
$r->lastname,
|
|
|
|
$r->firstname,
|
|
|
|
$r->email,
|
|
|
|
$r->phonehome,
|
|
|
|
$r->phonework,
|
|
|
|
$r->phoneworkext,
|
|
|
|
$r->phonecell,
|
2006-03-28 23:48:08 +00:00
|
|
|
$languages,
|
2005-02-23 14:55:01 +00:00
|
|
|
$r->organization,
|
2005-03-29 20:44:28 +00:00
|
|
|
$r->address,
|
2005-02-23 14:55:01 +00:00
|
|
|
$r->address2,
|
|
|
|
$r->city,
|
|
|
|
$r->province,
|
|
|
|
$r->postalcode,
|
|
|
|
$r->highest_psd,
|
|
|
|
$r->professional_quals,
|
2005-03-29 21:08:47 +00:00
|
|
|
$expertise_other
|
2005-02-23 14:55:01 +00:00
|
|
|
);
|
2006-07-11 20:22:42 +00:00
|
|
|
$tmp = array_merge($tmp, $qarray);
|
2005-03-30 16:04:32 +00:00
|
|
|
|
2006-02-07 20:19:56 +00:00
|
|
|
$extradata=array_merge($catdata,$divdata);
|
|
|
|
$table['data'][]=array_merge($tmp,$extradata);
|
2005-02-23 14:55:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$rep->addTable($table);
|
|
|
|
$rep->output();
|
|
|
|
|
|
|
|
?>
|