From 4c9d23e5132fd32bc4243d7af80f84a8f1182ae8 Mon Sep 17 00:00:00 2001
From: dave <dave>
Date: Thu, 13 Dec 2007 19:56:44 +0000
Subject: [PATCH] - Add sponsor information to the report generator awards
 report. - Add a system report that dumps all sponsor info to a csv.

---
 admin/reports_awards.inc.php | 61 +++++++++++++++++++++++++++++++++++-
 db/db.code.version.txt       |  2 +-
 db/db.update.81.sql          | 22 +++++++++++++
 3 files changed, 83 insertions(+), 2 deletions(-)
 create mode 100644 db/db.update.81.sql

diff --git a/admin/reports_awards.inc.php b/admin/reports_awards.inc.php
index 0006ee7b..e11f143e 100644
--- a/admin/reports_awards.inc.php
+++ b/admin/reports_awards.inc.php
@@ -59,6 +59,61 @@ $report_awards_fields = array(
 		'width' => 1.0,
 		'table' => 'award_types.type' ),
 
+	'sponsor_organization' => array(
+		'name' => 'Sponsor -- Organization',
+		'header' => 'Sponsor Organization',
+		'width' => 2.0,
+		'table' => 'award_sponsors.organization' ),
+
+	'sponsor_phone' => array(
+		'name' => 'Sponsor -- Phone',
+		'header' => 'Sp. Phone',
+		'width' => 1,
+		'table' => 'award_sponsors.phone' ),
+
+	'sponsor_fax' => array(
+		'name' => 'Sponsor -- Fax',
+		'header' => 'Sp. Fax',
+		'width' => 1,
+		'table' => 'award_sponsors.fax' ),
+
+	'sponsor_address' =>  array(
+		'name' => 'Sponsor -- Street Address',
+		'header' => 'Sponsor Address',
+		'width' => 2.0,
+		'table' => 'award_sponsors.address'),
+
+	'sponsor_city' =>  array(
+		'name' => 'Sponsor -- City',
+		'header' => 'Sp. City',
+		'width' => 1.5,
+		'table' => 'award_sponsors.city' ),
+
+	'sponsor_province' =>  array(
+		'name' => 'Sponsor -- Province',
+		'header' => 'Sp. Province',
+		'width' => 0.75,
+		'table' => 'award_sponsors.province_code' ),
+
+	'sponsor_postal' =>  array(
+		'name' => 'Sponsor -- Postal Code',
+		'header' => 'Sp. Postal',
+		'width' => 0.75,
+		'table' => 'award_sponsors.postalcode' ),
+
+	'sponsor_notes' =>  array(
+		'name' => 'Sponsor -- Notes',
+		'header' => 'Sponsor Notes',
+		'width' => 3,
+		'table' => 'award_sponsors.notes' ),
+
+	'sponsor_confirmed' =>  array(
+		'name' => 'Sponsor -- Confirmed',
+		'header' => 'Sp. Confirmed',
+		'width' => .5,
+		'table' => 'award_sponsors.confirmed',
+		'value_map' => array ('no' => 'No', 'yes' => 'Yes')),
+
 	'judgeteamname' => array(
 		'name' => 'Judging Team -- Name',
 		'header' => 'Judging Team',
@@ -100,7 +155,11 @@ $report_awards_fields = array(
 	}
 
 	$q = "	FROM 
-			award_awards, 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='$year'),
+			judges_teams_awards_link, judges_teams,
 			award_types
 			$judges_join
 		WHERE
diff --git a/db/db.code.version.txt b/db/db.code.version.txt
index d15a2cc4..d88e3136 100644
--- a/db/db.code.version.txt
+++ b/db/db.code.version.txt
@@ -1 +1 @@
-80
+81
diff --git a/db/db.update.81.sql b/db/db.update.81.sql
new file mode 100644
index 00000000..6771d0c4
--- /dev/null
+++ b/db/db.update.81.sql
@@ -0,0 +1,22 @@
+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');
+
+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, '', ''),
+	('', LAST_INSERT_ID(), 'option', 2, 'allow_multiline', 'no', 0, 0, 0, 0, 0, '', ''),
+	('', LAST_INSERT_ID(), 'option', 3, 'label_box', 'no', 0, 0, 0, 0, 0, '', ''),
+	('', LAST_INSERT_ID(), 'option', 4, 'label_fairname', 'no', 0, 0, 0, 0, 0, '', ''),
+	('', LAST_INSERT_ID(), 'option', 5, 'label_logo', 'no', 0, 0, 0, 0, 0, '', ''),
+	('', LAST_INSERT_ID(), 'option', 6, 'stock', 'fullpage', 0, 0, 0, 0, 0, '', ''),
+	('', LAST_INSERT_ID(), 'col', 0, 'name', '', 0, 0, 0, 0, 0, '', ' '),
+	('', LAST_INSERT_ID(), 'col', 1, 'sponsor_organization', '', 0, 0, 0, 0, 0, '', ' '),
+	('', LAST_INSERT_ID(), 'col', 2, 'sponsor_phone', '', 0, 0, 0, 0, 0, '', ' '),
+	('', LAST_INSERT_ID(), 'col', 3, 'sponsor_fax', '', 0, 0, 0, 0, 0, '', ' '),
+	('', LAST_INSERT_ID(), 'col', 4, 'sponsor_address', '', 0, 0, 0, 0, 0, '', ' '),
+	('', LAST_INSERT_ID(), 'col', 5, 'sponsor_city', '', 0, 0, 0, 0, 0, '', ' '),
+	('', LAST_INSERT_ID(), 'col', 6, 'sponsor_province', '', 0, 0, 0, 0, 0, '', ' '),
+	('', 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(), 'sort', 0, 'name', '', 0, 0, 0, 0, 0, '', ' ');