Fix the judges report

This commit is contained in:
james 2006-02-07 20:19:56 +00:00
parent 4aff70ef17
commit a85faefe2d

View File

@ -60,8 +60,6 @@ $table['header']=array( i18n("ID"),
i18n("City"),
i18n("Province"),
i18n("Postal Code"),
i18n("Category Pref"),
i18n("Division Pref"),
i18n("Highest PostSecDeg"),
i18n("Professional Quals"),
i18n("Years School"),
@ -72,6 +70,15 @@ $table['header']=array( i18n("ID"),
i18n("Expertise Other"));
//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)";
}
//grab the list of divisions, because the last fields of the table will be the sub-divisions
$q=mysql_query("SELECT * FROM projectdivisions WHERE year='".$config['FAIRYEAR']."' ORDER BY id");
$divheadings=array();
@ -83,7 +90,7 @@ while($r=mysql_fetch_object($q))
}
//now append the arrays together
$table['header']=array_merge($table['header'],$divheadings);
$table['header']=array_merge($table['header'],array_merge($catheadings,$divheadings));
//fill these in if we ever make this PDFable
@ -91,18 +98,14 @@ $table['widths']=array();
$table['dataalign']=array();
$q=mysql_query("SELECT
judges.*,
projectcategories.category AS catpref_name,
projectdivisions.division AS divpref_name
judges.*
FROM
judges,
judges_years
LEFT JOIN projectcategories ON judges.catpref=projectcategories.id
LEFT JOIN projectdivisions ON judges.divpref=projectdivisions.id
WHERE
judges.complete='yes' AND
judges_years.year='".$config['FAIRYEAR']."' AND
judges.id=judges_years.judges_id
judges.id=judges_years.judges_id
ORDER BY
lastname,
firstname");
@ -111,12 +114,21 @@ while($r=mysql_fetch_object($q))
$expertise_other=str_replace("\n"," ",$r->expertise_other);
$expertise_other=str_replace("\r","",$expertise_other);
$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");
$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");
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();
if(isset($catdata)) unset($catdata); $catdata=array();
while($subdivr=mysql_fetch_object($subdivq))
{
@ -138,6 +150,34 @@ while($r=mysql_fetch_object($q))
$divdata[]="";
}
$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;
}
}
// print_r($judge_divs);
// print_r($judge_subdivs);
@ -156,8 +196,6 @@ while($r=mysql_fetch_object($q))
$r->city,
$r->province,
$r->postalcode,
$r->catpref_name,
$r->divpref_name,
$r->highest_psd,
$r->professional_quals,
$r->years_school,
@ -168,7 +206,8 @@ while($r=mysql_fetch_object($q))
$expertise_other
);
$table['data'][]=array_merge($tmp,$divdata);
$extradata=array_merge($catdata,$divdata);
$table['data'][]=array_merge($tmp,$extradata);
}
$rep->addTable($table);