Added Campaign organizing functionality in the Pledge 'Summary' page which is on...
authorChris Doten <cdoten@ndi.org>
Sun, 5 May 2013 01:09:29 +0000 (01:09 +0000)
committerChris Doten <cdoten@ndi.org>
Sun, 5 May 2013 01:09:29 +0000 (01:09 +0000)
CRM/Report/Form/Contribute/Summary.php
CRM/Report/Form/Pledge/Detail.php

index e242505533324a6497bb4d5a7a52f97d3cc8512f..e4570112309e924a14dc8c3dbb9b04bcd91beb33 100644 (file)
@@ -600,6 +600,7 @@ class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form {
         }
         $entryFound = TRUE;
       }
+
       $entryFound = $this->alterDisplayAddressFields($row, $rows, $rowNum, 'contribute/detail', 'List all contribution(s) for this ') ? TRUE : $entryFound;
 
       // skip looking further in rows, if first row itself doesn't
index 0ecbaa3a911098a8dddbe10783ad02e80aaeae2a..c8a9374b8e08442f2db87652cc8b00a801030e61 100644 (file)
  +--------------------------------------------------------------------+
 */
 
+ /*
+  *   !!!!!!!!!!!!!!!!!!!!
+  *     NB: this is named detail but behaves like a summary report.
+  *    It is also accessed through the Pledge Summary link in the UI
+  *    This should presumably be changed.
+  *    ~ Doten
+  *   !!!!!!!!!!!!!!!!!!!!
+  *
+  */
+
 /**
  *
  * @package CRM
@@ -43,6 +54,16 @@ class CRM_Report_Form_Pledge_Detail extends CRM_Report_Form {
     'Individual'
   );
   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(
@@ -146,6 +167,7 @@ class CRM_Report_Form_Pledge_Detail extends CRM_Report_Form {
             'operatorType' => CRM_Report_Form::OP_MULTISELECT,
             'options' => CRM_Core_OptionGroup::values('contribution_status'),
           ),
+          
         ),
       ),
       'civicrm_pledge_payment' =>
@@ -164,6 +186,7 @@ class CRM_Report_Form_Pledge_Detail extends CRM_Report_Form {
               'default' => TRUE,
               'type' => CRM_Utils_Type::T_MONEY,
             ),
+            
         ),
       ),
       'civicrm_group' =>
@@ -183,6 +206,21 @@ class CRM_Report_Form_Pledge_Detail extends CRM_Report_Form {
         ),
       ),
     ) + $this->addAddressFields(FALSE, FALSE);
+    
+    // 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' => 'Campaign',
+          'default' => 'false',
+               );
+               $this->_columns['civicrm_pledge']['filters']['campaign_id'] = array('title' => ts('Campaign'),
+          'operatorType' => CRM_Report_Form::OP_MULTISELECT,
+          'options' => $this->activeCampaigns,
+               );
+               $this->_columns['civicrm_pledge']['group_bys']['campaign_id'] = array('title' => ts('Campaign'));
+
+    }
 
     $this->_tagFilter = TRUE;
     $this->_currencyColumn = 'civicrm_pledge_currency';
@@ -555,6 +593,14 @@ class CRM_Report_Form_Pledge_Detail extends CRM_Report_Form {
         $entryFound = TRUE;
       }
 
+      // 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];
+        }
+        $entryFound = TRUE;
+      }
+
       $entryFound = $this->alterDisplayAddressFields($row, $rows, $rowNum, 'pledge/detail', 'List all pledge(s) for this ') ? TRUE : $entryFound;
 
       // skip looking further in rows, if first row itself doesn't