(dev/core#491) campaign cleanup for pledge detail report and show disabled campaigns...
authoryashodha <yashodha@cividesk.com>
Thu, 27 Dec 2018 05:14:30 +0000 (10:44 +0530)
committeryashodha <yashodha@cividesk.com>
Thu, 27 Dec 2018 05:14:30 +0000 (10:44 +0530)
CRM/Report/Form/Pledge/Detail.php

index e9d199c39bf6ce7874aab95249ac0c41481458c7..a9cba5fc4e6707a52cfc1515b4f57e4afb81a3fe 100644 (file)
@@ -71,14 +71,6 @@ class CRM_Report_Form_Pledge_Detail extends CRM_Report_Form {
     $this->_pledgeStatuses = CRM_Core_OptionGroup::values('pledge_status',
       FALSE, FALSE, FALSE, NULL, 'label'
     );
-    // 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(
@@ -199,21 +191,7 @@ class CRM_Report_Form_Pledge_Detail extends CRM_Report_Form {
     $this->_columns += $this->getAddressColumns(array('group_by' => FALSE)) + $this->getPhoneColumns();
 
     // If we have a campaign, build out the relevant elements
-    $this->_tagFilter = TRUE;
-    if ($campaignEnabled && !empty($this->activeCampaigns)) {
-      $this->_columns['civicrm_pledge']['fields']['campaign_id'] = array(
-        'title' => ts('Campaign'),
-        'default' => 'false',
-      );
-      $this->_columns['civicrm_pledge']['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_pledge']['group_bys']['campaign_id'] = array('title' => ts('Campaign'));
-
-    }
+    $this->addCampaignFields('civicrm_pledge', TRUE);
 
     $this->_groupFilter = TRUE;
     $this->_tagFilter = TRUE;
@@ -599,7 +577,7 @@ class CRM_Report_Form_Pledge_Detail extends CRM_Report_Form {
       // If using campaigns, convert campaign_id to campaign title
       if (array_key_exists('civicrm_pledge_campaign_id', $row)) {
         if ($value = $row['civicrm_pledge_campaign_id']) {
-          $rows[$rowNum]['civicrm_pledge_campaign_id'] = $this->activeCampaigns[$value];
+          $rows[$rowNum]['civicrm_pledge_campaign_id'] = $this->campaigns[$value];
         }
         $entryFound = TRUE;
       }