From dcfcd358fc296fa405effd014ab25c11cb84c9ff Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 13 Dec 2007 21:23:29 +0000 Subject: [PATCH] - Add a primary contact field to the award contacts - Use the primary contact in award reports --- admin/award_contacts.php | 11 +++- admin/reports_awards.inc.php | 105 ++++++++++++++++++++++++++++++----- db/db.update.81.sql | 15 ++++- 3 files changed, 114 insertions(+), 17 deletions(-) diff --git a/admin/award_contacts.php b/admin/award_contacts.php index d507af4..37c3246 100644 --- a/admin/award_contacts.php +++ b/admin/award_contacts.php @@ -71,7 +71,7 @@ else $id=$_POST['id']; - + $p = ($_POST['primary']=='yes')?'yes':'no'; $exec="UPDATE award_contacts SET ". "salutation='".mysql_escape_string(stripslashes($_POST['salutation']))."', ". "firstname='".mysql_escape_string(stripslashes($_POST['firstname']))."', ". @@ -82,7 +82,8 @@ "phonehome='".mysql_escape_string(stripslashes($_POST['phonehome']))."', ". "fax='".mysql_escape_string(stripslashes($_POST['fax']))."', ". "email='".mysql_escape_string(stripslashes($_POST['email']))."', ". - "notes='".mysql_escape_string(stripslashes($_POST['notes']))."' ". + "notes='".mysql_escape_string(stripslashes($_POST['notes']))."', ". + "`primary`='$p' ". "WHERE id='$id'"; mysql_query($exec); @@ -134,6 +135,12 @@ echo "".i18n("Fax")."fax)."\" size=\"16\" maxlength=\"32\" />\n"; echo "".i18n("Email")."email)."\" size=\"60\" maxlength=\"128\" />\n"; echo "".i18n("Notes")."\n"; + echo "".i18n("Primary Contact")."\n"; echo "\n"; echo "\n"; diff --git a/admin/reports_awards.inc.php b/admin/reports_awards.inc.php index e11f143..cc586ce 100644 --- a/admin/reports_awards.inc.php +++ b/admin/reports_awards.inc.php @@ -114,19 +114,96 @@ $report_awards_fields = array( 'table' => 'award_sponsors.confirmed', 'value_map' => array ('no' => 'No', 'yes' => 'Yes')), + 'pcontact_salutation' => array( + 'name' => 'Primary Contact -- Salutation', + 'header' => 'Cnct. Salutation', + 'width' => 1.0, + 'table' => 'PRIMARYCONTACT.salutation' ), + + 'pcontact_last_name' => array( + 'name' => 'Primary Contact -- Last Name', + 'header' => 'Cnct. Last Name', + 'width' => 1.0, + 'table' => 'PRIMARYCONTACT.lastname' ), + + 'pcontact_first_name' => array( + 'name' => 'Primary Contact -- First Name', + 'header' => 'Cnct. First Name', + 'width' => 1.0, + 'table' => 'PRIMARYCONTACT.firstname' ), + + 'pcontact_name' => array( + 'name' => 'Primary Contact -- Full Name (last, first)', + 'header' => 'Contact Name', + 'width' => 1.75, + 'table' => "CONCAT(PRIMARYCONTACT.lastname, ', ', PRIMARYCONTACT.firstname)", + 'table_sort'=> 'PRIMARYCONTACT.lastname' ), + + 'pcontact_namefl' => array( + 'name' => 'Primary Contact -- Full Name (salutation first last)', + 'header' => 'Contact Name', + 'width' => 1.75, + 'table' => "CONCAT(PRIMARYCONTACT.salutation, ' ', PRIMARYCONTACT.firstname, ' ', PRIMARYCONTACT.lastname)", + 'table_sort'=> 'PRIMARYCONTACT.lastname' ), + + 'pcontact_position' => array( + 'name' => 'Primary Contact -- Position', + 'header' => 'Cnct. Position', + 'width' => 1.25, + 'table' => 'PRIMARYCONTACT.position'), + + 'pcontact_email' => array( + 'name' => 'Primary Contact -- Email', + 'header' => 'Cnct. Email', + 'width' => 2.0, + 'table' => 'PRIMARYCONTACT.email'), + + 'pcontact_hphone' => array( + 'name' => 'Primary Contact -- Home Phone', + 'header' => 'Cnct. Home', + 'width' => 1, + 'table' => 'PRIMARYCONTACT.phonehome' ), + + 'pcontact_wphone' => array( + 'name' => 'Primary Contact -- Work Phone', + 'header' => 'Cnct. Work', + 'width' => 1, + 'table' => 'PRIMARYCONTACT.phonework' ), + + 'pcontact_cphone' => array( + 'name' => 'Primary Contact -- Cell Phone', + 'header' => 'Cnct. Cell', + 'width' => 1, + 'table' => 'PRIMARYCONTACT.phonecell' ), + + 'pcontact_fax' => array( + 'name' => 'Primary Contact -- Fax', + 'header' => 'Cnct. Fax', + 'width' => 1, + 'table' => 'PRIMARYCONTACT.fax' ), + + 'pcontact_notes' => array( + 'name' => 'Primary Contact -- Notes', + 'header' => 'Contact Notes', + 'width' => 3, + 'table' => 'PRIMARYCONTACT.notes' ), + 'judgeteamname' => array( + 'components' => array('judgingteam'), 'name' => 'Judging Team -- Name', 'header' => 'Judging Team', 'width' => 3.0, 'table' => 'judges_teams.name'), 'judgeteamnum' => array( + 'components' => array('judgingteam'), 'name' => 'Judging Team -- Number', 'header' => 'Team', 'width' => 0.5, 'table' => 'judges_teams.num'), 'judgeteammembers' => array( + 'components' => array('judgingteam'), 'name' => 'Judging Team -- Members (REQUIRES MySQL 5.0)', 'header' => 'Team Members', 'width' => 3.0, @@ -146,29 +223,31 @@ $report_awards_fields = array( $judges_join = ''; $judges_where = ''; - - if(in_array('judgeteammembers', $report['col']) - || in_array('judgeteammembers', $report['group']) ) { - $judges_join = ', judges_teams_link, judges'; - $judges_where = 'AND judges_teams_link.id=judges_teams.id + + 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'; } $q = " FROM - award_awards - LEFT JOIN award_sponsors ON ( - award_sponsors.id=award_awards.award_sponsors_id - AND award_sponsors.year='$year'), - judges_teams_awards_link, judges_teams, + 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_contacts AS PRIMARYCONTACT ON ( + PRIMARYCONTACT.award_sponsors_id=award_sponsors.id + AND PRIMARYCONTACT.year=award_awards.year + AND PRIMARYCONTACT.`primary`='yes'), award_types $judges_join WHERE award_awards.year='$year' - AND judges_teams_awards_link.award_awards_id=award_awards.id - AND judges_teams.id=judges_teams_awards_link.judges_teams_id AND award_types.id=award_types_id AND award_types.year='$year' - $judges_where + $judges_where "; return $q; diff --git a/db/db.update.81.sql b/db/db.update.81.sql index 6771d0c..3b7f5c4 100644 --- a/db/db.update.81.sql +++ b/db/db.update.81.sql @@ -1,6 +1,7 @@ -INSERT INTO `reports` (`id`, `system_report_id`, `name`, `desc`, `creator`, `type`) VALUES - ('', '37', 'Awards -- Award Sponsor Information', 'Sponsor information for each award. This is a large report so the default format is CSV.', 'The Grant Brothers', 'award'); +ALTER TABLE `award_contacts` ADD `primary` ENUM( 'no', 'yes' ) NOT NULL DEFAULT 'no' AFTER `notes` ; +INSERT INTO `reports` (`id`, `system_report_id`, `name`, `desc`, `creator`, `type`) VALUES + ('', '37', 'Awards -- Award Sponsor Information', 'Sponsor information for each award with the primary contact. This is a large report so the default format is CSV.', 'The Grant Brothers', 'award'); INSERT INTO `reports_items` (`id`, `reports_id`, `type`, `ord`, `field`, `value`, `x`, `y`, `w`, `h`, `lines`, `face`, `align`) VALUES ('', LAST_INSERT_ID(), 'option', 0, 'type', 'csv', 0, 0, 0, 0, 0, '', ''), ('', LAST_INSERT_ID(), 'option', 1, 'group_new_page', 'no', 0, 0, 0, 0, 0, '', ''), @@ -19,4 +20,14 @@ INSERT INTO `reports_items` (`id`, `reports_id`, `type`, `ord`, `field`, `value` ('', LAST_INSERT_ID(), 'col', 7, 'sponsor_postal', '', 0, 0, 0, 0, 0, '', ' '), ('', LAST_INSERT_ID(), 'col', 8, 'sponsor_notes', '', 0, 0, 0, 0, 0, '', ' '), ('', LAST_INSERT_ID(), 'col', 9, 'sponsor_confirmed', '', 0, 0, 0, 0, 0, '', ' '), + ('', LAST_INSERT_ID(), 'col', 10, 'pcontact_salutation', '', 0, 0, 0, 0, 0, '', ' '), + ('', LAST_INSERT_ID(), 'col', 11, 'pcontact_namefl', '', 0, 0, 0, 0, 0, '', ' '), + ('', LAST_INSERT_ID(), 'col', 12, 'pcontact_position', '', 0, 0, 0, 0, 0, '', ' '), + ('', LAST_INSERT_ID(), 'col', 13, 'pcontact_email', '', 0, 0, 0, 0, 0, '', ' '), + ('', LAST_INSERT_ID(), 'col', 14, 'pcontact_hphone', '', 0, 0, 0, 0, 0, '', ' '), + ('', LAST_INSERT_ID(), 'col', 15, 'pcontact_wphone', '', 0, 0, 0, 0, 0, '', ' '), + ('', LAST_INSERT_ID(), 'col', 16, 'pcontact_cphone', '', 0, 0, 0, 0, 0, '', ' '), + ('', LAST_INSERT_ID(), 'col', 17, 'pcontact_fax', '', 0, 0, 0, 0, 0, '', ' '), + ('', LAST_INSERT_ID(), 'col', 18, 'pcontact_notes', '', 0, 0, 0, 0, 0, '', ' '), ('', LAST_INSERT_ID(), 'sort', 0, 'name', '', 0, 0, 0, 0, 0, '', ' '); +