- 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.
This commit is contained in:
dave 2007-12-24 21:18:08 +00:00
parent 1b0835a47f
commit a912b7df99

View File

@ -202,13 +202,21 @@ $report_awards_fields = array(
'width' => 0.5, 'width' => 0.5,
'table' => 'judges_teams.num'), '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( 'judgeteammembers' => array(
'components' => array('judgingteam'), 'components' => array('judgingteam', 'judgingteammembers'),
'name' => 'Judging Team -- Members (REQUIRES MySQL 5.0)', 'name' => 'Judging Team -- Members (REQUIRES MySQL 5.0)',
'header' => 'Team Members', 'header' => 'Team Members',
'width' => 3.0, 'width' => 3.0,
'table' => "GROUP_CONCAT(judges.firstname)", 'table' => "GROUP_CONCAT(judges.firstname, ' ', judges.lastname ORDER BY judges.lastname SEPARATOR ', ')",
'group_by' => array('judges_teams.num') ), 'group_by' => array('award_awards.id', 'judges_teams.num') ),
); );
@ -220,34 +228,41 @@ $report_awards_fields = array(
$fields = $report_awards_fields; $fields = $report_awards_fields;
$year = $report['year']; $year = $report['year'];
$judges_join = ''; $judges_join = '';
$judges_where = ''; $judges_where = '';
if(in_array('judgingteam', $components)) { if(in_array('judgingteam', $components)) {
$judges_join = ', judges_teams_awards_link, judges_teams, $judges_join = 'LEFT JOIN judges_teams_awards_link ON judges_teams_awards_link.award_awards_id=award_awards.id
judges_teams_link, judges'; LEFT JOIN judges_teams ON judges_teams.id=judges_teams_awards_link.judges_teams_id';
$judges_where = 'AND judges_teams_awards_link.award_awards_id=award_awards.id $judges_where = "AND judges_teams_awards_link.year='$year'
AND judges_teams.id=judges_teams_awards_link.judges_teams_id AND judges_teams.year='$year'";
AND judges_teams_link.id=judges_teams.id
AND judges.id=judges_teams_link.judges_id';
} }
$q = " FROM $judges_members_join = '';
award_awards LEFT JOIN award_sponsors ON ( $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 award_sponsors.id=award_awards.award_sponsors_id
AND award_sponsors.year=award_awards.year) 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 ( LEFT JOIN award_contacts AS PRIMARYCONTACT ON (
PRIMARYCONTACT.award_sponsors_id=award_sponsors.id PRIMARYCONTACT.award_sponsors_id=award_sponsors.id
AND PRIMARYCONTACT.year=award_awards.year AND PRIMARYCONTACT.year=award_awards.year
AND PRIMARYCONTACT.`primary`='yes'), AND PRIMARYCONTACT.`primary`='yes')
award_types
$judges_join $judges_join
$judges_members_join
WHERE WHERE
award_awards.year='$year' award_awards.year='$year'
AND award_types.id=award_types_id
AND award_types.year='$year' AND award_types.year='$year'
$judges_where $judges_where
$judges_members_where
"; ";
return $q; return $q;