return $this->_selectedTables;
}
+ /**
+ * Add campaign fields.
+ *
+ * @param bool $groupBy
+ * Add GroupBy? Not appropriate for detail report.
+ * @param bool $orderBy
+ * Add OrderBy? Not appropriate for detail report.
+ * @param bool $filters
+ *
+ */
+ public function addCampaignFields($entityTable = 'civicrm_contribution', $groupBy = FALSE, $orderBy = FALSE, $filters = TRUE) {
+ // 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);
+ // If we have a campaign, build out the relevant elements
+ if (!empty($getCampaigns['campaigns'])) {
+ $campaigns = $getCampaigns['campaigns'];
+ asort($campaigns);
+ $this->_columns[$entityTable]['fields']['campaign_id'] = array('title' => ts('Campaign'), 'default' => 'false');
+ if ($filters) {
+ $this->_columns[$entityTable]['filters']['campaign_id'] = array(
+ 'title' => ts('Campaign'),
+ 'operatorType' => CRM_Report_Form::OP_MULTISELECT,
+ 'options' => $campaigns,
+ 'type' => CRM_Utils_Type::T_INT,
+ );
+ }
+ if ($groupBy) {
+ $this->_columns[$entityTable]['group_bys']['campaign_id'] = array('title' => ts('Campaign'));
+ }
+ }
+ }
+ }
+
/**
* Add address fields.
*
$date['minYear']++;
}
- // 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(
'dao' => 'CRM_Contact_DAO_Contact',
);
// If we have a campaign, build out the relevant elements
- if ($campaignEnabled && !empty($this->activeCampaigns)) {
- $this->_columns['civicrm_contribution']['fields']['campaign_id'] = array(
- 'title' => ts('Campaign'),
- 'default' => 'false',
- 'type' => CRM_Utils_Type::T_INT,
- );
- $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->addCampaignFields('civicrm_contribution');
$this->_groupFilter = TRUE;
$this->_tagFilter = TRUE;