From 477be9cc9b981b98f90098c41f8906b3e5b932d0 Mon Sep 17 00:00:00 2001 From: Andrew Hunt Date: Thu, 28 Mar 2019 13:02:37 -0400 Subject: [PATCH] dev/core#655 contrib detail report: validation for soft credit params Grouping by soft credit when displaying contributions only used to just be stupid--now it results in a DB error. --- CRM/Report/Form/Contribute/Detail.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/CRM/Report/Form/Contribute/Detail.php b/CRM/Report/Form/Contribute/Detail.php index 1106772d81..accac0c1e1 100644 --- a/CRM/Report/Form/Contribute/Detail.php +++ b/CRM/Report/Form/Contribute/Detail.php @@ -367,6 +367,25 @@ class CRM_Report_Form_Contribute_Detail extends CRM_Report_Form { parent::__construct(); } + /** + * Validate incompatible report settings. + * + * @return bool + * true if no error found + */ + public function validate() { + // If you're displaying Contributions Only, you can't group by soft credit. + $contributionOrSoftVal = $this->getElementValue('contribution_or_soft_value'); + if ($contributionOrSoftVal[0] == 'contributions_only') { + $groupBySoft = $this->getElementValue('group_bys'); + if (CRM_Utils_Array::value('soft_credit_id', $groupBySoft)) { + $this->setElementError('group_bys', ts('You cannot group by soft credit when displaying contributions only. Please uncheck "Soft Credit" in the Grouping tab.')); + } + } + + return parent::validate(); + } + /** * Set the FROM clause for the report. */ -- 2.25.1