From f36b9484a65c75ea1704892823652cc812bc8417 Mon Sep 17 00:00:00 2001 From: "deb.monish" Date: Fri, 2 Dec 2016 18:05:56 +0530 Subject: [PATCH] additional fix --- .../Search/Custom/ContributionAggregate.php | 32 ++++++++++--------- .../Search/Custom/ContributionAggregate.tpl | 2 +- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/CRM/Contact/Form/Search/Custom/ContributionAggregate.php b/CRM/Contact/Form/Search/Custom/ContributionAggregate.php index c1036761db..b545c07387 100644 --- a/CRM/Contact/Form/Search/Custom/ContributionAggregate.php +++ b/CRM/Contact/Form/Search/Custom/ContributionAggregate.php @@ -195,22 +195,24 @@ civicrm_contact AS contact_a {$this->_aclFrom} * @return string */ public function where($includeContactIDs = FALSE) { - $clauses = array(); - - $clauses[] = "contrib.contact_id = contact_a.id"; - $clauses[] = "contrib.is_test = 0"; - - $relative = $this->_formValues['contribution_date_relative']; - $startDate = $this->_formValues['contribution_date_low']; - $endDate = $this->_formValues['contribution_date_high']; - list($startDate, $endDate) = CRM_Utils_Date::getFromTo($relative, $startDate, $endDate); - - if ($startDate) { - $clauses[] = "contrib.receive_date >= $startDate"; - } + $clauses = array( + "contrib.contact_id = contact_a.id", + "contrib.is_test = 0", + ); - if ($endDate) { - $clauses[] = "contrib.receive_date <= $endDate"; + $dateParams = array( + 'contribution_date_relative' => $this->_formValues['contribution_date_relative'], + 'contribution_date_low' => $this->_formValues['contribution_date_low'], + 'contribution_date_high' => $this->_formValues['contribution_date_high'], + ); + foreach (CRM_Contact_BAO_Query::convertFormValues($dateParams) as $values) { + list($name, $op, $value) = $values; + if (strstr($name, '_low')) { + $clauses[] = "contrib.receive_date >= " . CRM_Utils_Date::processDate($value); + } + else { + $clauses[] = "contrib.receive_date <= " . CRM_Utils_Date::processDate($value); + } } if ($includeContactIDs) { diff --git a/templates/CRM/Contact/Form/Search/Custom/ContributionAggregate.tpl b/templates/CRM/Contact/Form/Search/Custom/ContributionAggregate.tpl index 343f862c7f..c985e2e381 100644 --- a/templates/CRM/Contact/Form/Search/Custom/ContributionAggregate.tpl +++ b/templates/CRM/Contact/Form/Search/Custom/ContributionAggregate.tpl @@ -39,7 +39,7 @@ {/foreach} - + {ts}Contribution Dates{/ts} {include file="CRM/Core/DateRange.tpl" fieldName="contribution_date" from='_low' to='_high'} -- 2.25.1