From 0211a554c698e4cb6bd3f6f260d4ab957c028179 Mon Sep 17 00:00:00 2001 From: Debian Live user Date: Sat, 4 May 2013 20:38:08 +0000 Subject: [PATCH] Added campaign information to membership report details form. Added a couple of comments to the contribute Detail functions. --- CRM/Report/Form/Contribute/Detail.php | 3 +++ CRM/Report/Form/Member/Detail.php | 33 ++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/CRM/Report/Form/Contribute/Detail.php b/CRM/Report/Form/Contribute/Detail.php index 4da2923837..c3df67725b 100644 --- a/CRM/Report/Form/Contribute/Detail.php +++ b/CRM/Report/Form/Contribute/Detail.php @@ -48,6 +48,8 @@ class CRM_Report_Form_Contribute_Detail extends CRM_Report_Form { 'Contribution'); function __construct() { + + // Check if CiviCampaign is a) enabled and b) has active campaigns $config = CRM_Core_Config::singleton(); $campaignEnabled = in_array("CiviCampaign", $config->enableComponents); if ($campaignEnabled) { @@ -330,6 +332,7 @@ class CRM_Report_Form_Contribute_Detail extends CRM_Report_Form { ); } + // If we have active campaigns add those elements to both the fields and filters if ($campaignEnabled && !empty($this->activeCampaigns)) { $this->_columns['civicrm_contribution']['fields']['campaign_id'] = array( 'title' => ts('Campaign'), diff --git a/CRM/Report/Form/Member/Detail.php b/CRM/Report/Form/Member/Detail.php index c07a4929c5..a5a41748f4 100644 --- a/CRM/Report/Form/Member/Detail.php +++ b/CRM/Report/Form/Member/Detail.php @@ -49,7 +49,17 @@ class CRM_Report_Form_Member_Detail extends CRM_Report_Form { protected $_customGroupExtends = array('Membership', 'Contribution'); protected $_customGroupGroupBy = FALSE; - function __construct() { + function __construct() { + + // Check if CiviCampaign is a) enabled and b) has active campaigns + $config = CRM_Core_Config::singleton(); + $campaignEnabled = in_array("CiviCampaign", $config->enableComponents); + if ($campaignEnabled) { + $getCampaigns = CRM_Campaign_BAO_Campaign::getPermissionedCampaigns(NULL, NULL, TRUE, FALSE, TRUE); + $this->activeCampaigns = $getCampaigns['campaigns']; + asort($this->activeCampaigns); + } + $this->_columns = array( 'civicrm_contact' => array( @@ -257,6 +267,19 @@ class CRM_Report_Form_Member_Detail extends CRM_Report_Form { $this->_groupFilter = TRUE; $this->_tagFilter = TRUE; + // If we have active campaigns add those elements to both the fields and filters + if ($campaignEnabled && !empty($this->activeCampaigns)) { + $this->_columns['civicrm_contribution']['fields']['campaign_id'] = array( + 'title' => ts('Campaign'), + 'default' => 'false', + ); + $this->_columns['civicrm_contribution']['filters']['campaign_id'] = array('title' => ts('Campaign'), + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => $this->activeCampaigns, + ); + $this->_columns['civicrm_contribution']['order_bys']['campaign_id'] = array('title' => ts('Campaign')); + } + $this->_currencyColumn = 'civicrm_contribution_currency'; parent::__construct(); } @@ -496,6 +519,14 @@ class CRM_Report_Form_Member_Detail extends CRM_Report_Form { $entryFound = TRUE; } + // Convert campaign_id to campaign title + if (array_key_exists('civicrm_contribution_campaign_id', $row)) { + if ($value = $row['civicrm_contribution_campaign_id']) { + $rows[$rowNum]['civicrm_contribution_campaign_id'] = $this->activeCampaigns[$value]; + $entryFound = TRUE; + } + } + if (!$entryFound) { break; } -- 2.25.1