From 8a347ca586b5df36a52ce0946bc617f900e825e7 Mon Sep 17 00:00:00 2001 From: Richard van Oosterhout Date: Wed, 27 May 2015 15:33:29 +0200 Subject: [PATCH] Fix for Contribution Summary grouping --- CRM/Report/Form/Contribute/Summary.php | 29 +++++++++++++++++--------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/CRM/Report/Form/Contribute/Summary.php b/CRM/Report/Form/Contribute/Summary.php index 5d5cc58c77..69e3872bca 100644 --- a/CRM/Report/Form/Contribute/Summary.php +++ b/CRM/Report/Form/Contribute/Summary.php @@ -118,6 +118,9 @@ class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form { 'dao' => 'CRM_Contribute_DAO_Contribution', //'bao' => 'CRM_Contribute_BAO_Contribution', 'fields' => array( + 'contribution_status_id' => array( + 'title' => ts('Contribution Status'), + ), 'contribution_source' => array('title' => ts('Source')), 'currency' => array( 'required' => TRUE, @@ -127,8 +130,8 @@ class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form { 'title' => ts('Contribution Amount Stats'), 'default' => TRUE, 'statistics' => array( - 'sum' => ts('Contribution Aggregate'), 'count' => ts('Contributions'), + 'sum' => ts('Contribution Aggregate'), 'avg' => ts('Contribution Avg'), ), ), @@ -191,6 +194,13 @@ class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form { 'chart' => TRUE, ), 'contribution_source' => NULL, + 'contribution_status_id' => array( + 'title' => ts('Contribution Status'), + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), + 'default' => array(1), + 'type' => CRM_Utils_Type::T_INT, + ), ), ), 'civicrm_contribution_soft' => array( @@ -200,8 +210,8 @@ class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form { 'title' => ts('Soft Credit Amount Stats'), 'name' => 'amount', 'statistics' => array( - 'sum' => ts('Soft Credit Aggregate'), 'count' => ts('Soft Credits'), + 'sum' => ts('Soft Credit Aggregate'), 'avg' => ts('Soft Credit Avg'), ), ), @@ -385,14 +395,6 @@ class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form { $ignoreFields = array('total_amount', 'sort_name'); $errors = $self->customDataFormRule($fields, $ignoreFields); - if (empty($fields['group_bys']['receive_date'])) { - if (!empty($fields['receive_date_relative']) || - CRM_Utils_Date::isDate($fields['receive_date_from']) || - CRM_Utils_Date::isDate($fields['receive_date_to']) - ) { - $errors['receive_date_relative'] = ts("Do not use filter on Date if group by Receive Date is not used "); - } - } if (empty($fields['fields']['total_amount'])) { foreach (array( 'total_count_value', @@ -724,6 +726,7 @@ ROUND(AVG({$this->_aliases['civicrm_contribution_soft']}.amount), 2) as civicrm_ */ public function alterDisplay(&$rows) { $entryFound = FALSE; + $contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus(); foreach ($rows as $rowNum => $row) { // make count columns point to detail report @@ -796,6 +799,12 @@ ROUND(AVG({$this->_aliases['civicrm_contribution_soft']}.amount), 2) as civicrm_ $entryFound = TRUE; } + // convert contribution status id to status name + if ($value = CRM_Utils_Array::value('civicrm_contribution_contribution_status_id', $row)) { + $rows[$rowNum]['civicrm_contribution_contribution_status_id'] = $contributionStatus[$value]; + $entryFound = TRUE; + } + // If using campaigns, convert campaign_id to campaign title if (array_key_exists('civicrm_contribution_campaign_id', $row)) { if ($value = $row['civicrm_contribution_campaign_id']) { -- 2.25.1