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(
'financial_type_id' => array('title' => ts('Financial Type')),
'contribution_status_id' => array('title' => ts('Contribution Status')),
'payment_instrument_id' => array('title' => ts('Payment Type')),
+ 'currency' => array(
+ 'required' => TRUE,
+ 'no_display' => TRUE,
+ ),
'trxn_id' => NULL,
'receive_date' => NULL,
'receipt_date' => NULL,
'options' => CRM_Contribute_PseudoConstant::paymentInstrument(),
'type' => CRM_Utils_Type::T_INT,
),
+ 'currency' =>
+ array('title' => 'Currency',
+ 'operatorType' => CRM_Report_Form::OP_MULTISELECT,
+ 'options' => CRM_Core_OptionGroup::values('currencies_enabled'),
+ 'default' => NULL,
+ 'type' => CRM_Utils_Type::T_STRING,
+ ),
'contribution_status_id' =>
array('title' => ts('Contribution Status'),
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
);
$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();
}
$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;
}