From a912b7df991184b55383a3f2fb4dfe470391e5ef Mon Sep 17 00:00:00 2001 From: dave Date: Mon, 24 Dec 2007 21:18:08 +0000 Subject: [PATCH] - Clean up the award query. - Fix a bug in the award query tha twas incorrectly linking judges teams with judges - Add 'Judge Name' to the query so non mysql5 users can create an award report that lists the judge names for each award. --- admin/reports_awards.inc.php | 47 ++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/admin/reports_awards.inc.php b/admin/reports_awards.inc.php index cc586ce..d270ab6 100644 --- a/admin/reports_awards.inc.php +++ b/admin/reports_awards.inc.php @@ -202,13 +202,21 @@ $report_awards_fields = array( 'width' => 0.5, 'table' => 'judges_teams.num'), + 'judgeteammembers_name' => array( + 'components' => array('judgingteam', 'judgingteammembers'), + 'name' => 'Judging Team -- Judge Name', + 'header' => 'Judge Name', + 'width' => 1.5, + 'table' => "CONCAT(judges.firstname, ' ', judges.lastname)"), + 'judgeteammembers' => array( - 'components' => array('judgingteam'), + 'components' => array('judgingteam', 'judgingteammembers'), 'name' => 'Judging Team -- Members (REQUIRES MySQL 5.0)', 'header' => 'Team Members', 'width' => 3.0, - 'table' => "GROUP_CONCAT(judges.firstname)", - 'group_by' => array('judges_teams.num') ), + 'table' => "GROUP_CONCAT(judges.firstname, ' ', judges.lastname ORDER BY judges.lastname SEPARATOR ', ')", + 'group_by' => array('award_awards.id', 'judges_teams.num') ), + ); @@ -220,34 +228,41 @@ $report_awards_fields = array( $fields = $report_awards_fields; $year = $report['year']; - $judges_join = ''; $judges_where = ''; - if(in_array('judgingteam', $components)) { - $judges_join = ', judges_teams_awards_link, judges_teams, - judges_teams_link, judges'; - $judges_where = 'AND judges_teams_awards_link.award_awards_id=award_awards.id - AND judges_teams.id=judges_teams_awards_link.judges_teams_id - AND judges_teams_link.id=judges_teams.id - AND judges.id=judges_teams_link.judges_id'; + $judges_join = 'LEFT JOIN judges_teams_awards_link ON judges_teams_awards_link.award_awards_id=award_awards.id + LEFT JOIN judges_teams ON judges_teams.id=judges_teams_awards_link.judges_teams_id'; + $judges_where = "AND judges_teams_awards_link.year='$year' + AND judges_teams.year='$year'"; } - $q = " FROM - award_awards LEFT JOIN award_sponsors ON ( + $judges_members_join = ''; + $judges_members_where = ''; + if(in_array('judgingteammembers', $components)) { + $judges_members_join = 'LEFT JOIN judges_teams_link ON judges_teams_link.judges_teams_id=judges_teams.id + LEFT JOIN judges ON judges.id=judges_teams_link.judges_id'; + + $judges_members_where = "AND judges_teams_link.year='$year'"; + } + + + $q = " FROM award_awards + LEFT JOIN award_sponsors ON ( award_sponsors.id=award_awards.award_sponsors_id AND award_sponsors.year=award_awards.year) + LEFT JOIN award_types ON award_types.id=award_types_id LEFT JOIN award_contacts AS PRIMARYCONTACT ON ( PRIMARYCONTACT.award_sponsors_id=award_sponsors.id AND PRIMARYCONTACT.year=award_awards.year - AND PRIMARYCONTACT.`primary`='yes'), - award_types + AND PRIMARYCONTACT.`primary`='yes') $judges_join + $judges_members_join WHERE award_awards.year='$year' - AND award_types.id=award_types_id AND award_types.year='$year' $judges_where + $judges_members_where "; return $q;