From b4f6780b408a854eb6f97e4eaa986f0659b4ac40 Mon Sep 17 00:00:00 2001 From: Jon goldberg Date: Thu, 21 Apr 2016 17:09:53 -0400 Subject: [PATCH] CRM-18460 - Contribution Aggregate custom search - use relative date fields --- .../Form/Search/Custom/ContributionAggregate.php | 14 ++++++-------- .../Form/Search/Custom/ContributionAggregate.tpl | 12 +++++------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/CRM/Contact/Form/Search/Custom/ContributionAggregate.php b/CRM/Contact/Form/Search/Custom/ContributionAggregate.php index c5015b0a3a..c1036761db 100644 --- a/CRM/Contact/Form/Search/Custom/ContributionAggregate.php +++ b/CRM/Contact/Form/Search/Custom/ContributionAggregate.php @@ -83,9 +83,7 @@ class CRM_Contact_Form_Search_Custom_ContributionAggregate extends CRM_Contact_F ts('...and $') ); $form->addRule('max_amount', ts('Please enter a valid amount (numbers and decimal point only).'), 'money'); - - $form->addDate('start_date', ts('Contribution Date From'), FALSE, array('formatType' => 'custom')); - $form->addDate('end_date', ts('...through'), FALSE, array('formatType' => 'custom')); + CRM_Core_Form_Date::buildDateRange($form, 'contribution_date', 1, '_low', '_high', ts('From:'), FALSE, FALSE); $form->addSelect('financial_type_id', array('entity' => 'contribution', 'multiple' => 'multiple', 'context' => 'search') @@ -95,7 +93,7 @@ class CRM_Contact_Form_Search_Custom_ContributionAggregate extends CRM_Contact_F * If you are using the sample template, this array tells the template fields to render * for the search form. */ - $form->assign('elements', array('min_amount', 'max_amount', 'start_date', 'end_date')); + $form->assign('elements', array('min_amount', 'max_amount')); } /** @@ -202,15 +200,15 @@ civicrm_contact AS contact_a {$this->_aclFrom} $clauses[] = "contrib.contact_id = contact_a.id"; $clauses[] = "contrib.is_test = 0"; - $startTime = !empty($this->_formValues['start_date_time']) ? $this->_formValues['start_date_time'] : '00:00:00'; - $endTime = !empty($this->_formValues['end_date_time']) ? $this->_formValues['end_date_time'] : '23:59:59'; + $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); - $startDate = CRM_Utils_Date::processDate($this->_formValues['start_date'], $startTime); if ($startDate) { $clauses[] = "contrib.receive_date >= $startDate"; } - $endDate = CRM_Utils_Date::processDate($this->_formValues['end_date'], $endTime); if ($endDate) { $clauses[] = "contrib.receive_date <= $endDate"; } diff --git a/templates/CRM/Contact/Form/Search/Custom/ContributionAggregate.tpl b/templates/CRM/Contact/Form/Search/Custom/ContributionAggregate.tpl index db6d66d947..343f862c7f 100644 --- a/templates/CRM/Contact/Form/Search/Custom/ContributionAggregate.tpl +++ b/templates/CRM/Contact/Form/Search/Custom/ContributionAggregate.tpl @@ -35,15 +35,13 @@ {foreach from=$elements item=element} {$form.$element.label} - {if $element eq 'start_date'} - {include file="CRM/common/jcalendar.tpl" elementName=start_date} - {elseif $element eq 'end_date'} - {include file="CRM/common/jcalendar.tpl" elementName=end_date} - {else} - {$form.$element.html} - {/if} + {$form.$element.html} {/foreach} + + + {include file="CRM/Core/DateRange.tpl" fieldName="contribution_date" from='_low' to='_high'} + {ts}Financial Type{/ts} {$form.financial_type_id.html|crmAddClass:twenty} -- 2.25.1