*/
public function __construct() {
$this->_autoIncludeIndexedFieldsAsOrderBys = 1;
- // 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, FALSE, FALSE, TRUE);
- $this->activeCampaigns = $getCampaigns['campaigns'];
- asort($this->activeCampaigns);
- }
-
$this->_columns = array_merge($this->getColumns('Contact', array(
'order_bys_defaults' => array('sort_name' => 'ASC '),
'fields_defaults' => array('sort_name'),
$this->_columns['civicrm_contact']['fields']['sort_name']['title'] = ts('Donor Name');
$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,
- 'type' => CRM_Utils_Type::T_INT,
- );
- $this->_columns['civicrm_contribution']['order_bys']['campaign_id'] = array('title' => ts('Campaign'));
- }
+ // If we have campaigns enabled, add those elements to both the fields, filters and sorting
+ $this->addCampaignFields('civicrm_contribution', FALSE, TRUE);
$this->_currencyColumn = 'civicrm_contribution_currency';
parent::__construct();
// 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];
+ $rows[$rowNum]['civicrm_contribution_campaign_id'] = $this->campaigns[$value];
$entryFound = TRUE;
}
}