forked from science-ation/science-ation
- 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)
This commit is contained in:
parent
5da58aeb12
commit
4efb335654
@ -429,7 +429,7 @@ switch($_GET['action']){
|
||||
}
|
||||
echo "</td>\n";
|
||||
echo "<td style=\"text-align: center;\"><input type=\"button\" onclick=\"return opensendmaildialog($campaign_id,'$key')\" value=\"".i18n("Generate PDF for mailing")."\" /></td>\n";
|
||||
echo "<td style=\"text-align: center;\"><input type=\"button\" onclick=\"return opensendlabelsdialog(6)\" value=\"".i18n("Generate mailing labels")."\" /></td>\n";
|
||||
echo "<td style=\"text-align: center;\"><input type=\"button\" onclick=\"return opensendlabelsdialog(47,$campaign_id)\" value=\"".i18n("Generate mailing labels")."\" /></td>\n";
|
||||
echo "</tr></table>\n";
|
||||
echo "</td></tr>\n";
|
||||
echo "</table>\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() {
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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 "<input type=\"hidden\" name=\"reloadaction\" value=\"\">";
|
||||
|
174
admin/reports_fundraising.inc.php
Normal file
174
admin/reports_fundraising.inc.php
Normal file
@ -0,0 +1,174 @@
|
||||
<?
|
||||
/*
|
||||
This file is part of the 'Science Fair In A Box' project
|
||||
SFIAB Website: http://www.sfiab.ca
|
||||
|
||||
Copyright (C) 2005 Sci-Tech Ontario Inc <info@scitechontario.org>
|
||||
Copyright (C) 2005 James Grant <james@lightbox.org>
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
?>
|
@ -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;
|
||||
}
|
||||
}
|
||||
?>
|
||||
<div id="report_dialog_gen" title="Generate Report" style="display: none">
|
||||
<form id="report_dialog_form" >
|
||||
|
19
db/db.update.147.sql
Normal file
19
db/db.update.147.sql
Normal file
@ -0,0 +1,19 @@
|
||||
ALTER TABLE `reports` CHANGE `type` `type` ENUM( 'student', 'judge', 'award', 'committee', 'school', 'volunteer', 'tour', 'fair', 'fundraising' ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'student';
|
||||
|
||||
INSERT INTO `reports` (`id`, `system_report_id`, `name`, `desc`, `creator`, `type`) VALUES
|
||||
('', '47', 'Labels -- Fundraising Campaign Mailing Labels', 'Mailing labels for all the contacts attached to a fundraising campaign', 'The Grant Brothers', 'fundraising');
|
||||
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', 'label', 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, 'fit_columns', 'no', 0, 0, 0, 0, 0, '', ''),
|
||||
('', LAST_INSERT_ID(), 'option', 4, 'label_box', 'yes', 0, 0, 0, 0, 0, '', ''),
|
||||
('', LAST_INSERT_ID(), 'option', 5, 'field_box', 'no', 0, 0, 0, 0, 0, '', ''),
|
||||
('', LAST_INSERT_ID(), 'option', 6, 'label_fairname', 'no', 0, 0, 0, 0, 0, '', ''),
|
||||
('', LAST_INSERT_ID(), 'option', 7, 'label_logo', 'no', 0, 0, 0, 0, 0, '', ''),
|
||||
('', LAST_INSERT_ID(), 'option', 8, 'stock', '5163', 0, 0, 0, 0, 0, '', ''),
|
||||
('', LAST_INSERT_ID(), 'col', 0, 'namefl', '', 5, 5, 95, 12, 1, '', 'left vcenter'),
|
||||
('', LAST_INSERT_ID(), 'col', 1, 'address', '', 5, 30, 95, 24, 2, '', 'left vcenter'),
|
||||
('', LAST_INSERT_ID(), 'col', 2, 'city_prov', '', 5, 60, 95, 12, 1, '', 'left vcenter'),
|
||||
('', LAST_INSERT_ID(), 'col', 3, 'postal', '', 5, 80, 95, 12, 1, '', 'left vcenter');
|
||||
|
Loading…
Reference in New Issue
Block a user