From c76af7c48f1d9ba91317f8d047ca6529f18603d5 Mon Sep 17 00:00:00 2001 From: Edsel Date: Mon, 27 Mar 2017 11:49:29 +0530 Subject: [PATCH] CRM-20022 Added batch title as pseudoconstant, refactored label for batch id ---------------------------------------- * 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 | 7 ++++++- CRM/Report/Form.php | 7 +------ CRM/Report/Form/Contribute/Summary.php | 7 ++++--- xml/schema/Batch/EntityBatch.xml | 5 +++++ 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/CRM/Batch/DAO/EntityBatch.php b/CRM/Batch/DAO/EntityBatch.php index b4e4f84ad5..831dd0a6ed 100644 --- a/CRM/Batch/DAO/EntityBatch.php +++ b/CRM/Batch/DAO/EntityBatch.php @@ -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']); diff --git a/CRM/Report/Form.php b/CRM/Report/Form.php index b189831f59..a8d4a1f7cd 100644 --- a/CRM/Report/Form.php +++ b/CRM/Report/Form.php @@ -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)); } diff --git a/CRM/Report/Form/Contribute/Summary.php b/CRM/Report/Form/Contribute/Summary.php index edb336ae05..5d683e5f06 100644 --- a/CRM/Report/Form/Contribute/Summary.php +++ b/CRM/Report/Form/Contribute/Summary.php @@ -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; } diff --git a/xml/schema/Batch/EntityBatch.xml b/xml/schema/Batch/EntityBatch.xml index 2f4ebec5e3..462c40d1a7 100644 --- a/xml/schema/Batch/EntityBatch.xml +++ b/xml/schema/Batch/EntityBatch.xml @@ -50,6 +50,11 @@ int unsigned true FK to civicrm_batch + + civicrm_batch
+ id + title +
3.3 -- 2.25.1