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. */ ?> newPage(); $rep->setFontSize(11); } else if($type=="csv") { $rep=new lcsv(i18n("Judge List")); } $table=array(); $table['header']=array( i18n("ID"), i18n("Last Name"), i18n("First Name"), i18n("Email"), i18n("Phone Home"), i18n("Phone Work"), i18n("Phone Work Ext"), i18n("Phone Cell"), i18n("Organization"), i18n("Address 1"), i18n("Address 2"), i18n("City"), i18n("Province"), i18n("Postal Code"), i18n("Category Pref"), i18n("Division Pref"), i18n("Highest PostSecDeg"), i18n("Professional Quals"), i18n("Years School"), i18n("Years Regional"), i18n("Years National"), i18n("Willing Chair"), i18n("Attending Lunch"), 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 projectdivisions ORDER BY id AND year='".$config['FAIRYEAR']."'"); $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 $table['header']=array_merge($table['header'],$divheadings); //fill these in if we ever make this PDFable $table['widths']=array(); $table['dataalign']=array(); $q=mysql_query("SELECT judges.*, projectcategories.category AS catpref_name, projectdivisions.division AS divpref_name 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 ORDER BY lastname, firstname"); 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"); 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; } //make sure divdata is empty if($divdata) unset($divdata); //now redeclare the empty array $divdata=array(); foreach($divs as $div) { $divdata[]=$judge_divs[$div]; if(count($judge_subdivs[$div])) $divdata[]=implode(",",$judge_subdivs[$div]); else $divdata[]=""; } // print_r($judge_divs); // print_r($judge_subdivs); $tmp=array( $r->id, $r->lastname, $r->firstname, $r->email, $r->phonehome, $r->phonework, $r->phoneworkext, $r->phonecell, $r->organization, $r->address, $r->address2, $r->city, $r->province, $r->postalcode, $r->catpref_name, $r->divpref_name, $r->highest_psd, $r->professional_quals, $r->years_school, $r->years_regional, $r->years_national, $r->willing_chair, $r->attending_lunch, $expertise_other ); $table['data'][]=array_merge($tmp,$divdata); } $rep->addTable($table); $rep->output(); ?>