From 4efb3356543506fb780761d5eb641eb2ae07339f Mon Sep 17 00:00:00 2001 From: dave Date: Fri, 16 Oct 2009 17:17:45 +0000 Subject: [PATCH] - Add a report for fundraising mail labels - Add the ability to specify a filter when calling for a report generation (e.g., so we can dynamically filter a report for a specific fundraising campaign) --- admin/fundraising_campaigns.php | 7 +- admin/reports.inc.php | 5 +- admin/reports_editor.php | 4 +- admin/reports_fundraising.inc.php | 174 ++++++++++++++++++++++++++++++ admin/reports_gen.php | 6 ++ db/db.update.147.sql | 19 ++++ 6 files changed, 210 insertions(+), 5 deletions(-) create mode 100644 admin/reports_fundraising.inc.php create mode 100644 db/db.update.147.sql diff --git a/admin/fundraising_campaigns.php b/admin/fundraising_campaigns.php index 46cfbe9..e9e7273 100644 --- a/admin/fundraising_campaigns.php +++ b/admin/fundraising_campaigns.php @@ -429,7 +429,7 @@ switch($_GET['action']){ } echo "\n"; echo "\n"; - echo "\n"; + echo "\n"; echo "\n"; echo "\n"; echo "\n"; @@ -711,9 +711,10 @@ function comm_dialog_edit_cancel() { // alert("cancelled!"); } -function opensendlabelsdialog(reports_id) { +function opensendlabelsdialog(reports_id,fcid) { $("#dialog").empty(); - $("#dialog").load("reports_gen.php?action=dialog_gen&id="+reports_id,null,function() { + var args = "action=dialog_gen&sid="+reports_id+"&filter[fundraising_campaigns_id]="+fcid; + $("#dialog").load("reports_gen.php?"+args,null,function() { }); } diff --git a/admin/reports.inc.php b/admin/reports.inc.php index 017e4b4..b96c7a7 100644 --- a/admin/reports.inc.php +++ b/admin/reports.inc.php @@ -29,6 +29,7 @@ require_once("reports_schools.inc.php"); require_once("reports_tours.inc.php"); require_once("reports_fairs.inc.php"); + require_once("reports_fundraising.inc.php"); require_once('../lpdf.php'); require_once('../lcsv.php'); @@ -297,7 +298,7 @@ foreach($report_stock as $n=>$v) { global $report_students_fields, $report_judges_fields, $report_awards_fields; global $report_committees_fields, $report_schools_fields; global $report_volunteers_fields, $report_fairs_fields; - global $report_tours_fields; + global $report_tours_fields, $report_fundraisings_fields; $fieldvar = "report_{$report['type']}s_fields"; @@ -343,6 +344,7 @@ foreach($report_stock as $n=>$v) { global $report_committees_fields, $report_awards_fields; global $report_schools_fields, $report_volunteers_fields; global $report_tours_fields, $report_fairs_fields; + global $report_fundraisings_fields; $report = array(); @@ -506,6 +508,7 @@ foreach($report_stock as $n=>$v) { global $config, $report_students_fields, $report_judges_fields, $report_awards_fields, $report_schools_fields; global $report_stock, $report_committees_fields, $report_volunteers_fields; global $report_tours_fields, $report_fairs_fields; + global $report_fundraisings_fields; global $filter_ops; //print_r($report); diff --git a/admin/reports_editor.php b/admin/reports_editor.php index 33a808b..67b244c 100644 --- a/admin/reports_editor.php +++ b/admin/reports_editor.php @@ -34,6 +34,7 @@ require_once('reports_volunteers.inc.php'); require_once('reports_tours.inc.php'); require_once('reports_fairs.inc.php'); + require_once('reports_fundraising.inc.php'); require_once('reports.inc.php'); $fields = array(); @@ -353,7 +354,8 @@ function createData(x,y,w,h,l,face,align,valign,value) { selector('type', array('student' => 'Student Report', 'judge' => 'Judge Report', 'award' => 'Award Report', 'committee' => 'Committee Member Report', 'school' => 'School Report', 'volunteer' => 'Volunteer Report', - 'tour' => 'Tour Report', 'fair' => 'Feeder Fair Report'), + 'tour' => 'Tour Report', 'fair' => 'Feeder Fair Report', + 'fundraising' => 'Fundraising Report'), $report['type'], "onChange=\"reportReload();\""); echo ""; diff --git a/admin/reports_fundraising.inc.php b/admin/reports_fundraising.inc.php new file mode 100644 index 0000000..bc70df2 --- /dev/null +++ b/admin/reports_fundraising.inc.php @@ -0,0 +1,174 @@ + + 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. +*/ + + +/* Take the language array in users_fundraising, unserialize it, and join it + * with a space */ +function report_fundraisings_languages(&$report, $text) +{ + $l = unserialize($text); + return join(' ', $l); +} + + + +/* Components: */ +/* Yes, fundraisings, the generator takes the report type (also the user.type in many cases) and + * just adds an 's' to find the fields and the functions. */ +$report_fundraisings_fields = array( + 'fundraising_campaigns_id' => array( + 'name' => 'Fundraising Campaign numerical ID', + 'header' => 'ID', + 'width' => 0.25, + 'table' => "fundraising_campaigns.id"), + + 'namefl' => array( + 'name' => 'Contact -- Full Name (first last)', + 'header' => 'Name', + 'width' => 1.75, + 'table' => "CONCAT(users.firstname, ' ', users.lastname)", + 'table_sort'=> 'users.lastname', + 'components' => array('users') ), + + 'email' => array( + 'name' => 'Contact -- Email', + 'header' => 'Email', + 'width' => 2.0, + 'table' => 'users.email', + 'components' => array('users') ), + + 'address' => array( + 'name' => 'Contact Address -- Street', + 'header' => 'Address', + 'width' => 2.0, + 'table' => "CONCAT(users.address, ' ', users.address2)", + 'components' => array('users') ), + + 'city' => array( + 'name' => 'Contact Address -- City', + 'header' => 'City', + 'width' => 1.5, + 'table' => 'users.city', + 'components' => array('users') ), + + 'province' => array( + 'name' => 'Contact Address -- '.$config['provincestate'], + 'header' => $config['provincestate'], + 'width' => 0.75, + 'table' => 'users.province', + 'components' => array('users') ), + + 'postal' => array( + 'name' => 'Contact -- Address '.$config['postalzip'], + 'header' => $config['postalzip'], + 'width' => 0.75, + 'table' => 'users.postalcode' , + 'components' => array('users') ), + + 'city_prov' => array( + 'name' => 'Contact Address -- City, '.$config['provincestate'].' (for mailing)', + 'header' => 'City', + 'width' => 1.5, + 'table' => "CONCAT(users.city, ', ', users.province)", + 'components' => array('users') ), + + 'phone_home' => array( + 'name' => 'Contact -- Phone (Home)', + 'header' => 'Phone(Home)', + 'width' => 1, + 'table' => 'users.phonehome', + 'components' => array('users') ), + + 'phone_work' => array( + 'name' => 'Contact -- Phone (Work)', + 'header' => 'Phone(Work)', + 'width' => 1.25, + 'table' => "users.phonework", + 'components' => array('users') ), + + 'organization' => array( + 'name' => 'Contact -- Organization', + 'header' => 'Organization', + 'width' => 2, + 'table' => 'users.organization', + 'components' => array('users') ), + + 'year' => array( + 'name' => 'Contact -- Year', + 'header' => 'Year', + 'width' => 0.5, + 'table' => 'users.year', + 'components' => array('users') ), + + 'static_text' => array( + 'name' => 'Static Text (useful for labels)', + 'header' => '', + 'width' => 0.1, + 'table' => "CONCAT(' ')"), + +); + + function report_fundraisings_fromwhere($report, $components) + { + global $config, $report_fundraisings_fields; + + $fields = $report_fundraisings_fields; + $year = $report['year']; + + if(in_array('users', $components)) { + $users_from = 'LEFT JOIN fundraising_campaigns_users_link ON fundraising_campaigns.id=fundraising_campaigns_users_link.fundraising_campaigns_id + LEFT JOIN users ON users.uid=fundraising_campaigns_users_link.users_uid'; + } + +/* + $teams_from = ''; + $teams_where = ''; + if(in_array('teams', $components)) { + $teams_from = "LEFT JOIN fundraisings_teams_link ON judges_teams_link.users_id=users.id + LEFT JOIN fundraisings_teams ON judges_teams.id=judges_teams_link.judges_teams_id"; + $teams_where = "AND fundraisings_teams_link.year='$year' + AND fundraisings_teams.year='$year'"; + } + + $projects_from=''; + $projects_where=''; + if(in_array('projects', $components)) { + $projects_from = "LEFT JOIN fundraisings_teams_timeslots_projects_link ON + fundraisings_teams_timeslots_projects_link.judges_teams_id=judges_teams.id + LEFT JOIN projects ON projects.id=fundraisings_teams_timeslots_projects_link.projects_id + LEFT JOIN fundraisings_timeslots ON judges_timeslots.id=judges_teams_timeslots_projects_link.judges_timeslots_id"; + $projects_where = "AND fundraisings_teams_timeslots_projects_link.year='$year' + AND projects.year='$year'"; + } +*/ + + $q = " FROM fundraising_campaigns + $users_from + WHERE + 1 + "; + + return $q; +} + +?> diff --git a/admin/reports_gen.php b/admin/reports_gen.php index 23315d9..3f342af 100644 --- a/admin/reports_gen.php +++ b/admin/reports_gen.php @@ -45,7 +45,13 @@ switch($_GET['action']) { case 'dialog_gen': + /* Add a custom filter */ $report = report_load($id); + if(is_array($_GET['filter'])) { + foreach($_GET['filter'] as $f=>$v) { + $report['options']['filter'][$f] = $v; + } + } ?>