Commit 687e42f6 authored by Seamus Lee's avatar Seamus Lee

#561 Convert DateAdded and Tagged Contributions custom searches to...

#561 Convert DateAdded and Tagged Contributions custom searches to using datepicker rather than jcalendar
parent 22273586
......@@ -61,8 +61,8 @@ class CRM_Contact_Form_Search_Custom_DateAdded extends CRM_Contact_Form_Search_C
* @param CRM_Core_Form $form
*/
public function buildForm(&$form) {
$form->addDate('start_date', ts('Start Date'), FALSE, array('formatType' => 'custom'));
$form->addDate('end_date', ts('End Date'), FALSE, array('formatType' => 'custom'));
$form->add('datepicker', 'start_date', ts('Start Date'), [], FALSE, array('time' => FALSE));
$form->add('datepicker', 'end_date', ts('End Date'), [], FALSE, array('time' => FALSE));
$groups = CRM_Core_PseudoConstant::nestedGroup();
......@@ -192,12 +192,11 @@ class CRM_Contact_Form_Search_Custom_DateAdded extends CRM_Contact_Form_Search_C
}
CRM_Core_DAO::executeQuery($sql);
$startDate = CRM_Utils_Date::mysqlToIso(CRM_Utils_Date::processDate($this->_formValues['start_date']));
$startDate = !empty($this->_formValues['start_date']) ? $this->_formValues['start_date'] : date('Y-m-d');
$endDateFix = NULL;
if (!empty($this->_formValues['end_date'])) {
$endDate = CRM_Utils_Date::mysqlToIso(CRM_Utils_Date::processDate($this->_formValues['end_date']));
# tack 11:59pm on to make search inclusive of the end date
$endDateFix = "AND date_added <= '" . substr($endDate, 0, 10) . " 23:59:00'";
$endDateFix = "AND date_added <= '{$this->_formValues['end_date']} 23:59:00'";
}
$dateRange = "INSERT INTO {$this->_datesTable} ( id, date_added )
......@@ -211,7 +210,7 @@ class CRM_Contact_Form_Search_Custom_DateAdded extends CRM_Contact_Form_Search_C
GROUP BY
civicrm_contact.id
HAVING
date_added >= '$startDate'
date_added >= '$startDate 00:00:00'
$endDateFix";
if ($this->_debug > 0) {
......
......@@ -73,8 +73,8 @@ class CRM_Contact_Form_Search_Custom_TagContributions extends CRM_Contact_Form_S
* Define the search form fields here
*/
$form->addDate('start_date', ts('Contribution Date From'), FALSE, array('formatType' => 'custom'));
$form->addDate('end_date', ts('...through'), FALSE, array('formatType' => 'custom'));
$form->add('datepicker', 'start_date', ts('Contribution Date From'), [], FALSE, array('time' => FALSE));
$form->add('datepicker', 'end_date', ts('...through'), [], FALSE, array('time' => FALSE));
$tag = array('' => ts('- any tag -')) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
$form->addElement('select', 'tag', ts('Tagged'), $tag);
......@@ -180,14 +180,12 @@ WHERE $where
$clauses[] = "contact_a.contact_type = 'Individual'";
$clauses[] = "civicrm_contribution.contact_id = contact_a.id";
$startDate = CRM_Utils_Date::processDate($this->_formValues['start_date']);
if ($startDate) {
$clauses[] = "civicrm_contribution.receive_date >= $startDate";
if ($this->_formValues['start_date']) {
$clauses[] = "civicrm_contribution.receive_date >= '{$this->_formValues['start_date']} 00:00:00'";
}
$endDate = CRM_Utils_Date::processDate($this->_formValues['end_date']);
if ($endDate) {
$clauses[] = "civicrm_contribution.receive_date <= $endDate";
if ($this->_formValues['end_date']) {
$clauses[] = "civicrm_contribution.receive_date <= '{$this->_formValues['end_date']} 23:59:59'";
}
$tag = CRM_Utils_Array::value('tag', $this->_formValues);
......
......@@ -38,11 +38,7 @@
{foreach from=$elements item=element}
<tr class="crm-contact-custom-search-form-row-{$element}">
<td class="label">{$form.$element.label}</td>
{if $element|strstr:'_date'}
<td>{include file="CRM/common/jcalendar.tpl" elementName=$element}</td>
{else}
<td>{$form.$element.html}</td>
{/if}
<td>{$form.$element.html}</td>
</tr>
{/foreach}
</table>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment