Added campaign information to membership report details form. Added a couple of comme...
authorDebian Live user <amnesia@amnesia.(none)>
Sat, 4 May 2013 20:38:08 +0000 (20:38 +0000)
committerDebian Live user <amnesia@amnesia.(none)>
Sat, 4 May 2013 20:38:08 +0000 (20:38 +0000)
CRM/Report/Form/Contribute/Detail.php
CRM/Report/Form/Member/Detail.php

index 4da29238373df377f6a17704563f2c96b8993359..c3df67725b5816e4b7c5b5038112ca0cfce8650b 100644 (file)
@@ -48,6 +48,8 @@ class CRM_Report_Form_Contribute_Detail extends CRM_Report_Form {
     'Contribution');
 
   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) {
@@ -330,6 +332,7 @@ class CRM_Report_Form_Contribute_Detail extends CRM_Report_Form {
       );
     }
 
+       // 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'),
index c07a4929c5b490984dfdd8e396a56726481838a3..a5a41748f4996b3131f2db03fef3ed662a54c242 100644 (file)
@@ -49,7 +49,17 @@ class CRM_Report_Form_Member_Detail extends CRM_Report_Form {
   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(
@@ -257,6 +267,19 @@ class CRM_Report_Form_Member_Detail extends CRM_Report_Form {
     $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();
   }
@@ -496,6 +519,14 @@ class CRM_Report_Form_Member_Detail extends CRM_Report_Form {
         $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;
       }