CRM-20022 Added batch title as pseudoconstant, refactored label for batch id
authorEdsel <edsel.lopez@jmaconsulting.biz>
Mon, 27 Mar 2017 06:19:29 +0000 (11:49 +0530)
committerEdsel <edsel.lopez@jmaconsulting.biz>
Mon, 27 Mar 2017 06:19:29 +0000 (11:49 +0530)
----------------------------------------
* CRM-20022: Add Batch Title to Columns, Grouping tabs on Contribution Summary report
  https://issues.civicrm.org/jira/browse/CRM-20022

CRM/Batch/DAO/EntityBatch.php
CRM/Report/Form.php
CRM/Report/Form/Contribute/Summary.php
xml/schema/Batch/EntityBatch.xml

index b4e4f84ad571d02d93a631a9422ed3692c21d6c9..831dd0a6edc971db8c9982d5992c95d219ad1ab4 100644 (file)
@@ -30,7 +30,7 @@
  *
  * Generated from xml/schema/CRM/Batch/EntityBatch.xml
  * DO NOT EDIT.  Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:bdeffe170df7314f5643fcd266b2ba16)
+ * (GenCodeChecksum:db880689cbebab222e9decece8487c1d)
  */
 require_once 'CRM/Core/DAO.php';
 require_once 'CRM/Utils/Type.php';
@@ -145,6 +145,11 @@ class CRM_Batch_DAO_EntityBatch extends CRM_Core_DAO {
           'entity' => 'EntityBatch',
           'bao' => 'CRM_Batch_BAO_EntityBatch',
           'FKClassName' => 'CRM_Batch_DAO_Batch',
+          'pseudoconstant' => array(
+            'table' => 'civicrm_batch',
+            'keyColumn' => 'id',
+            'labelColumn' => 'title',
+          )
         ) ,
       );
       CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
index b189831f590bb07584e30f57862d782e72190da2..a8d4a1f7cd8542c4c699db53d978bfce04665f33 100644 (file)
@@ -4882,12 +4882,7 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a
     $types = explode(',', $options);
     $labels = array();
     foreach ($types as $value) {
-      if ($labelValue = CRM_Core_PseudoConstant::getLabel($baoName, $fieldName, $value)) {
-        $labels[$value] = $labelValue;
-      }
-      else {
-        $labels[$value] = CRM_Core_DAO::getFieldValue($baoName, $value, $fieldName);
-      }
+      $labels[$value] = CRM_Core_PseudoConstant::getLabel($baoName, $fieldName, $value);
     }
     return implode(', ', array_filter($labels));
   }
index edb336ae056e60d21b1778565c656a0d1a41d6a2..5d683e5f06e299a60ab16b4989513073b31563a2 100644 (file)
@@ -251,7 +251,8 @@ 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 ",")',
+            'dbAlias' => 'GROUP_CONCAT(DISTINCT batch_civireport.batch_id
+                                    ORDER BY batch_civireport.batch_id SEPARATOR ",")',
           ),
         ),
         'filters' => array(
@@ -981,8 +982,8 @@ 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'] = $this->getLabels($row['civicrm_batch_batch_id'], 'CRM_Batch_BAO_Batch', 'title');
+      if (!empty($row['civicrm_batch_batch_id']) && !in_array('Subtotal', $rows[$rowNum])) {
+        $rows[$rowNum]['civicrm_batch_batch_id'] = $this->getLabels($row['civicrm_batch_batch_id'], 'CRM_Batch_BAO_EntityBatch', 'batch_id');
         $entryFound = TRUE;
       }
 
index 2f4ebec5e350d9d56dad019b04e043fcc3932bab..462c40d1a71ed92702f1ff7cffb711469601a61a 100644 (file)
     <type>int unsigned</type>
     <required>true</required>
     <comment>FK to civicrm_batch</comment>
+    <pseudoconstant>
+      <table>civicrm_batch</table>
+      <keyColumn>id</keyColumn>
+      <labelColumn>title</labelColumn>
+    </pseudoconstant>
     <add>3.3</add>
   </field>
   <foreignKey>