From: Chris Doten Date: Sat, 4 May 2013 23:51:23 +0000 (+0000) Subject: Some additional comments in Contribute/Summary. Added Campaign functionality to Membe... X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=a7dbbc5df5de7ca4edb0721dde8360947b1c19f2;p=civicrm-core.git Some additional comments in Contribute/Summary. Added Campaign functionality to Member/Summary --- diff --git a/CRM/Report/Form/Contribute/Summary.php b/CRM/Report/Form/Contribute/Summary.php index 4c0fbaf771..e242505533 100644 --- a/CRM/Report/Form/Contribute/Summary.php +++ b/CRM/Report/Form/Contribute/Summary.php @@ -48,13 +48,16 @@ class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form { public $_drilldownReport = array('contribute/detail' => 'Link to Detail Report'); function __construct() { - $config = CRM_Core_Config::singleton(); + + // 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( @@ -215,6 +218,7 @@ class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form { ), ) + $this->addAddressFields(); + // If we have a campaign, build out the relevant elements $this->_tagFilter = TRUE; if ($campaignEnabled && !empty($this->activeCampaigns)) { $this->_columns['civicrm_contribution']['fields']['campaign_id'] = array( @@ -589,7 +593,7 @@ class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form { $entryFound = TRUE; } - // convert campaign_id to campaign title + // If using campaigns, 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]; @@ -598,7 +602,6 @@ class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form { } $entryFound = $this->alterDisplayAddressFields($row, $rows, $rowNum, 'contribute/detail', 'List all contribution(s) for this ') ? TRUE : $entryFound; - // skip looking further in rows, if first row itself doesn't // have the column we need if (!$entryFound) { diff --git a/CRM/Report/Form/Member/Summary.php b/CRM/Report/Form/Member/Summary.php index b24d6dd918..7125514075 100644 --- a/CRM/Report/Form/Member/Summary.php +++ b/CRM/Report/Form/Member/Summary.php @@ -49,9 +49,19 @@ class CRM_Report_Form_Member_Summary extends CRM_Report_Form { protected $_customGroupGroupBy = FALSE; public $_drilldownReport = array('member/detail' => 'Link to Detail Report'); - function __construct() { + function __construct() { + // UI for selecting columns to appear in the report list - // array conatining the columns, group_bys and filters build and provided to Form + // Array containing the columns, group_bys and filters build and provided to Form + + // 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_membership' => @@ -164,6 +174,22 @@ class CRM_Report_Form_Member_Summary extends CRM_Report_Form { ), ); $this->_tagFilter = TRUE; + + // If we have a campaign, build out the relevant elements + if ($campaignEnabled && !empty($this->activeCampaigns)) { + $this->_columns['civicrm_membership']['fields']['campaign_id'] = array( + 'title' => 'Campaign', + 'default' => 'false', + ); + $this->_columns['civicrm_membership']['filters']['campaign_id'] = array('title' => ts('Campaign'), + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => $this->activeCampaigns, + ); + $this->_columns['civicrm_membership']['grouping']['campaign_id'] = 'contri-fields'; + $this->_columns['civicrm_membership']['group_bys']['campaign_id'] = array('title' => ts('Campaign')); + } + + $this->_groupFilter = TRUE; $this->_currencyColumn = 'civicrm_contribution_currency'; parent::__construct(); @@ -613,6 +639,15 @@ GROUP BY {$this->_aliases['civicrm_contribution']}.currency $rows[$rowNum]['civicrm_membership_membership_type_id'] = 'SubTotal'; $entryFound = TRUE; } + + + // If using campaigns, convert campaign_id to campaign title + if (array_key_exists('civicrm_membership_campaign_id', $row)) { + if ($value = $row['civicrm_membership_campaign_id']) { + $rows[$rowNum]['civicrm_membership_campaign_id'] = $this->activeCampaigns[$value]; + } + $entryFound = TRUE; + } // skip looking further in rows, if first row itself doesn't // have the column we need