From eb2f9e769f361e32f5534267d04dc4f9dd799128 Mon Sep 17 00:00:00 2001 From: james Date: Fri, 22 Jan 2010 17:43:43 +0000 Subject: [PATCH] Fix the custom judge report -its the only way to get div/cat/lang prefs, and the answers to judge questions --- admin/reports_judges.php | 110 +++++++++++---------------------------- 1 file changed, 30 insertions(+), 80 deletions(-) diff --git a/admin/reports_judges.php b/admin/reports_judges.php index 3b865ea..b71139a 100644 --- a/admin/reports_judges.php +++ b/admin/reports_judges.php @@ -48,7 +48,9 @@ else if($type=="csv") } $table=array(); -$table['header']=array( i18n("ID"), +$table['header']=array( + i18n("ID"), + i18n("Unique ID"), i18n("Last Name"), i18n("First Name"), i18n("Email"), @@ -103,97 +105,44 @@ $table['widths']=array(); $table['dataalign']=array(); $q=mysql_query("SELECT - judges.* + users.*, + users_judge.* FROM - judges, - judges_years + users + JOIN users_judge ON users.id=users_judge.users_id WHERE - judges.complete='yes' AND - judges.deleted='no' AND - judges_years.year='".$config['FAIRYEAR']."' AND - judges.id=judges_years.judges_id + users.deleted='no' AND + users.year='".$config['FAIRYEAR']."' + AND users.types LIKE '%judge%' + ORDER BY lastname, firstname"); -while($r=mysql_fetch_object($q)) -{ +echo mysql_error(); +while($r=mysql_fetch_object($q)) { + $u=user_load($r->id); + $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"); - 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)) - { - 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[]=""; - } - - - $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; - } - } - $languages=""; - //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); -// print_r($judge_divs); -// print_r($judge_subdivs); + foreach($u['cat_prefs'] AS $c) { + $catdata[]=$c+2; + } + + foreach($u['div_prefs'] AS $d) { + $divdata[]=$d; + //FIXME: 2010-01-22 - James - get the sub divisions for now we use a placeholder + $divdata[]=""; + } + + foreach($u['languages'] AS $k=>$v) { + $languages.="$v/"; + } + $languages=substr($languages,0,-1); $qarray = array(); $qans = questions_load_answers('judgereg', $r->id, $config['FAIRYEAR']); @@ -204,6 +153,7 @@ while($r=mysql_fetch_object($q)) $tmp=array( $r->id, + $r->uid, $r->lastname, $r->firstname, $r->email,