(dev/core#491) campaign cleanup for 'pledged but not paid' report and show disabled...
authoryashodha <yashodha@cividesk.com>
Thu, 27 Dec 2018 09:12:16 +0000 (14:42 +0530)
committeryashodha <yashodha@cividesk.com>
Thu, 27 Dec 2018 09:12:16 +0000 (14:42 +0530)
CRM/Report/Form/Pledge/Pbnp.php

index 788a10886e9b651c84ec3ca4e7fbba65eab57fb6..e2199e88218a1462959e108fd283180b59a5bd98 100644 (file)
@@ -49,12 +49,6 @@ class CRM_Report_Form_Pledge_Pbnp extends CRM_Report_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_contact' => array(
@@ -184,18 +178,7 @@ class CRM_Report_Form_Pledge_Pbnp extends CRM_Report_Form {
     );
 
     // If we have a campaign, build out the relevant elements
-    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->addCampaignFields('civicrm_pledge');
 
     $this->_groupFilter = TRUE;
     $this->_tagFilter = TRUE;
@@ -359,7 +342,7 @@ class CRM_Report_Form_Pledge_Pbnp 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;
       }