From 8d2ca6b8063993a8ef0f1f7525189c8d1eb7e887 Mon Sep 17 00:00:00 2001 From: Edsel Date: Thu, 9 Feb 2017 18:42:15 +0530 Subject: [PATCH] CRM-16189 IIDA-58 Added Batch Title to columns, grouping and filter ---------------------------------------- * CRM-16189: Improve support for Accrual Method bookkeeping https://issues.civicrm.org/jira/browse/CRM-16189 CRM-16189-44 Changes to filters, group bys CRM-16189 IIDA-58 Prevented loading all batches for report ---------------------------------------- * CRM-16189: Improve support for Accrual Method bookkeeping https://issues.civicrm.org/jira/browse/CRM-16189 --- CRM/Report/Form/Contribute/Summary.php | 30 ++++++++++++++++++++------ 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/CRM/Report/Form/Contribute/Summary.php b/CRM/Report/Form/Contribute/Summary.php index 684032ad1f..9b59afb436 100644 --- a/CRM/Report/Form/Contribute/Summary.php +++ b/CRM/Report/Form/Contribute/Summary.php @@ -229,6 +229,12 @@ class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form { 'civicrm_batch' => array( 'dao' => 'CRM_Batch_DAO_EntityBatch', 'grouping' => 'contri-fields', + 'fields' => array( + 'batch_id' => array( + 'name' => 'batch_id', + 'title' => ts('Batch Title'), + ), + ), 'filters' => array( 'batch_id' => array( 'title' => ts('Batch Title'), @@ -237,6 +243,9 @@ class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form { 'type' => CRM_Utils_Type::T_INT, ), ), + 'group_bys' => array( + 'batch_id' => array('title' => ts('Batch ID')), + ), ), 'civicrm_contribution_soft' => array( 'dao' => 'CRM_Contribute_DAO_ContributionSoft', @@ -495,14 +504,15 @@ class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form { {$this->_aliases['civicrm_phone']}.is_primary = 1)"; $this->addAddressFromClause(); - if (!empty($this->_params['batch_id_value'])) { + //for contribution batches + if ($this->isTableSelected('civicrm_batch')) { $this->_from .= " - LEFT JOIN civicrm_entity_financial_trxn eft - ON eft.entity_id = {$this->_aliases['civicrm_contribution']}.id AND - eft.entity_table = 'civicrm_contribution' - LEFT JOIN civicrm_entity_batch {$this->_aliases['civicrm_batch']} - ON {$this->_aliases['civicrm_batch']}.entity_id = eft.financial_trxn_id AND - {$this->_aliases['civicrm_batch']}.entity_table = 'civicrm_financial_trxn'\n"; + LEFT JOIN civicrm_entity_financial_trxn eft + ON eft.entity_id = {$this->_aliases['civicrm_contribution']}.id AND + eft.entity_table = 'civicrm_contribution' + LEFT JOIN civicrm_entity_batch {$this->_aliases['civicrm_batch']} + ON ({$this->_aliases['civicrm_batch']}.entity_id = eft.financial_trxn_id + AND {$this->_aliases['civicrm_batch']}.entity_table = 'civicrm_financial_trxn')"; } } @@ -936,6 +946,12 @@ ROUND(AVG({$this->_aliases['civicrm_contribution_soft']}.amount), 2) as civicrm_ $entryFound = TRUE; } + // 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'); + $entryFound = TRUE; + } + $entryFound = $this->alterDisplayAddressFields($row, $rows, $rowNum, 'contribute/detail', 'List all contribution(s) for this ') ? TRUE : $entryFound; $entryFound = $this->alterDisplayContactFields($row, $rows, $rowNum, 'contribute/detail', 'List all contribution(s) for this ') ? TRUE : $entryFound; -- 2.25.1