CRM-13715 - Add custom field column to Contribution Details report crashes
authorDonald A. Lobo <lobo@civicrm.org>
Wed, 6 Nov 2013 21:23:37 +0000 (13:23 -0800)
committerDonald A. Lobo <lobo@civicrm.org>
Wed, 6 Nov 2013 21:23:37 +0000 (13:23 -0800)
http://issues.civicrm.org/jira/browse/CRM-13715

CRM/Report/Form.php
CRM/Report/Form/Contribute/Detail.php
CRM/Report/Form/Contribute/Summary.php

index 6b353d5cdb9d659bf08c06c55e99531907620ef1..e48b71ffbac99dc18133d56c54a4d91c48871932 100644 (file)
@@ -514,7 +514,7 @@ class CRM_Report_Form extends CRM_Core_Form {
             }
 
             // a few auto fills for filters
-            if ($fieldGrp == 'filters') { 
+            if ($fieldGrp == 'filters') {
               // fill operator types
               if (!array_key_exists('operatorType', $this->_columns[$tableName][$fieldGrp][$fieldName])) {
                 switch (CRM_Utils_Array::value('type', $this->_columns[$tableName][$fieldGrp][$fieldName])) {
@@ -526,18 +526,18 @@ class CRM_Report_Form extends CRM_Core_Form {
                     $this->_columns[$tableName][$fieldGrp][$fieldName]['operatorType'] = CRM_Report_Form::OP_INT;
                     break;
                   case CRM_Utils_Type::T_DATE:
-                    $this->_columns[$tableName][$fieldGrp][$fieldName]['operatorType'] = CRM_Report_Form::OP_DATE;  
+                    $this->_columns[$tableName][$fieldGrp][$fieldName]['operatorType'] = CRM_Report_Form::OP_DATE;
                     break;
                   case CRM_Utils_Type::T_BOOLEAN:
                     $this->_columns[$tableName][$fieldGrp][$fieldName]['operatorType'] = CRM_Report_Form::OP_SELECT;
                     if (!array_key_exists('options', $this->_columns[$tableName][$fieldGrp][$fieldName])) {
-                      $this->_columns[$tableName][$fieldGrp][$fieldName]['options'] = 
+                      $this->_columns[$tableName][$fieldGrp][$fieldName]['options'] =
                         array('' => ts('Any'), '0' => ts('No'), '1' => ts('Yes'));
                     }
                     break;
                   default:
-                    if ($daoOrBaoName && 
-                      (array_key_exists('pseudoconstant', $this->_columns[$tableName][$fieldGrp][$fieldName]) 
+                    if ($daoOrBaoName &&
+                      (array_key_exists('pseudoconstant', $this->_columns[$tableName][$fieldGrp][$fieldName])
                         || array_key_exists('enumValues', $this->_columns[$tableName][$fieldGrp][$fieldName]))
                     ) {
                       // with multiple options operator-type is generally multi-select
index b3c68d9e009a6c5e62028f28e8828ecd6af72b13..9afbc1db00047059fd877a6598fe7d797db34a14 100644 (file)
@@ -43,8 +43,7 @@ class CRM_Report_Form_Contribute_Detail extends CRM_Report_Form {
   protected $_summary = NULL;
   protected $_allBatches = NULL;
 
-  protected $_customGroupExtends = array(
-    'Contribution');
+  protected $_customGroupExtends = array( 'Contribution');
 
   function __construct() {
 
@@ -604,7 +603,10 @@ GROUP BY {$this->_aliases['civicrm_contribution']}.currency";
 
     // copy _from for later use of stats calculation for soft credits, and reset $this->_from to main query
     $this->_softFrom = $this->_from;
-    $this->from(); // simple reset of ->_from
+
+    // simple reset of ->_from
+    $this->from();
+    $this->customDataFrom();
 
     // 3. Decide where to populate temp3 table from
     if (CRM_Utils_Array::value('contribution_or_soft_value', $this->_params) == 'contributions_only') {
index a968fcbb3a7ff9846e70f27d430685acea7a7251..7d01d875d9f47a75879b122c9690a208ef2beaca 100644 (file)
@@ -175,7 +175,7 @@ class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form {
             'operatorType' => CRM_Report_Form::OP_MULTISELECT,
             'options'  => CRM_Contribute_PseudoConstant::contributionPage(),
             'type' => CRM_Utils_Type::T_INT,
-          ),          
+          ),
           'total_amount' =>
           array('title' => ts('Contribution Amount'),
           ),
@@ -429,7 +429,7 @@ class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form {
 
   function from() {
     $softCreditJoin = "LEFT";
-    if (CRM_Utils_Array::value('soft_amount', $this->_params['fields']) && 
+    if (CRM_Utils_Array::value('soft_amount', $this->_params['fields']) &&
       !CRM_Utils_Array::value('total_amount', $this->_params['fields'])) {
       // if its only soft credit stats, use inner join
       $softCreditJoin = "INNER";
@@ -514,21 +514,21 @@ class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form {
     $softCredit = CRM_Utils_Array::value('soft_amount', $this->_params['fields']);
     $onlySoftCredit = $softCredit && !CRM_Utils_Array::value('total_amount', $this->_params['fields']);
 
-    $select = "SELECT 
+    $select = "SELECT
 COUNT({$this->_aliases['civicrm_contribution']}.total_amount )        as civicrm_contribution_total_amount_count,
 SUM({$this->_aliases['civicrm_contribution']}.total_amount )          as civicrm_contribution_total_amount_sum,
 ROUND(AVG({$this->_aliases['civicrm_contribution']}.total_amount), 2) as civicrm_contribution_total_amount_avg,
 {$this->_aliases['civicrm_contribution']}.currency                    as currency";
 
     if ($softCredit) {
-      $select .= ", 
+      $select .= ",
 COUNT({$this->_aliases['civicrm_contribution_soft']}.amount )        as civicrm_contribution_soft_soft_amount_count,
 SUM({$this->_aliases['civicrm_contribution_soft']}.amount )          as civicrm_contribution_soft_soft_amount_sum,
 ROUND(AVG({$this->_aliases['civicrm_contribution_soft']}.amount), 2) as civicrm_contribution_soft_soft_amount_avg";
     }
     $group = "\nGROUP BY {$this->_aliases['civicrm_contribution']}.currency";
     $sql = "{$select} {$this->_from} {$this->_where} {$group} {$this->_having}";
-    
+
     $dao = CRM_Core_DAO::executeQuery($sql);
     $totalAmount = $average = $softTotalAmount = $softAverage = array();
     $count = $softCount = 0;
@@ -536,14 +536,14 @@ ROUND(AVG({$this->_aliases['civicrm_contribution_soft']}.amount), 2) as civicrm_
       $totalAmount[] = CRM_Utils_Money::format($dao->civicrm_contribution_total_amount_sum, $dao->currency)." (".$dao->civicrm_contribution_total_amount_count.")";
       $average[] = CRM_Utils_Money::format($dao->civicrm_contribution_total_amount_avg, $dao->currency);
       $count += $dao->civicrm_contribution_total_amount_count;
-      
+
       if ($softCredit) {
         $softTotalAmount[] = CRM_Utils_Money::format($dao->civicrm_contribution_soft_soft_amount_sum, $dao->currency)." (".$dao->civicrm_contribution_soft_soft_amount_count.")";
         $softAverage[] = CRM_Utils_Money::format($dao->civicrm_contribution_soft_soft_amount_avg, $dao->currency);
         $softCount += $dao->civicrm_contribution_soft_soft_amount_count;
       }
     }
-    
+
     if (!$onlySoftCredit) {
       $statistics['counts']['amount'] = array(
         'title' => ts('Total Amount'),