CRM-20022 Extended function to support multiple batch labels
authorEdsel <edsel.lopez@jmaconsulting.biz>
Fri, 17 Mar 2017 06:51:33 +0000 (12:21 +0530)
committerEdsel <edsel.lopez@jmaconsulting.biz>
Mon, 27 Mar 2017 05:39:59 +0000 (11:09 +0530)
----------------------------------------
* CRM-20022: Add Batch Title to Columns, Grouping tabs on Contribution Summary report
  https://issues.civicrm.org/jira/browse/CRM-20022

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

index a8d4a1f7cd8542c4c699db53d978bfce04665f33..b189831f590bb07584e30f57862d782e72190da2 100644 (file)
@@ -4882,7 +4882,12 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a
     $types = explode(',', $options);
     $labels = array();
     foreach ($types as $value) {
-      $labels[$value] = CRM_Core_PseudoConstant::getLabel($baoName, $fieldName, $value);
+      if ($labelValue = CRM_Core_PseudoConstant::getLabel($baoName, $fieldName, $value)) {
+        $labels[$value] = $labelValue;
+      }
+      else {
+        $labels[$value] = CRM_Core_DAO::getFieldValue($baoName, $value, $fieldName);
+      }
     }
     return implode(', ', array_filter($labels));
   }
index 33cdec1e551558cf1480d2d8ccc85a4891fa5bcf..edb336ae056e60d21b1778565c656a0d1a41d6a2 100644 (file)
@@ -251,6 +251,7 @@ class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form {
           'batch_id' => array(
             'name' => 'batch_id',
             'title' => ts('Batch Title'),
+            'dbAlias' => 'GROUP_CONCAT(batch_civireport.batch_id SEPARATOR ",")',
           ),
         ),
         'filters' => array(
@@ -981,7 +982,7 @@ ROUND(AVG({$this->_aliases['civicrm_contribution_soft']}.amount), 2) as civicrm_
 
       // convert batch id to batch title
       if (!empty($row['civicrm_batch_batch_id'])) {
-        $rows[$rowNum]['civicrm_batch_batch_id'] = CRM_Core_DAO::getFieldValue('CRM_Batch_BAO_Batch', $row['civicrm_batch_batch_id'], 'title');
+        $rows[$rowNum]['civicrm_batch_batch_id'] = $this->getLabels($row['civicrm_batch_batch_id'], 'CRM_Batch_BAO_Batch', 'title');
         $entryFound = TRUE;
       }