From a85faefe2df87f4d2d1ec3e02fdb54e7cac7d855 Mon Sep 17 00:00:00 2001 From: james Date: Tue, 7 Feb 2006 20:19:56 +0000 Subject: [PATCH] Fix the judges report --- admin/reports_judges.php | 69 +++++++++++++++++++++++++++++++--------- 1 file changed, 54 insertions(+), 15 deletions(-) diff --git a/admin/reports_judges.php b/admin/reports_judges.php index 6aacbb8..6aded9c 100644 --- a/admin/reports_judges.php +++ b/admin/reports_judges.php @@ -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);