CRM-17869 - Revert custom field date search refactoring to support relative dates
authorColeman Watts <coleman@civicrm.org>
Thu, 20 Oct 2016 16:00:37 +0000 (12:00 -0400)
committerColeman Watts <coleman@civicrm.org>
Thu, 20 Oct 2016 16:32:46 +0000 (12:32 -0400)
CRM/Contact/Form/Search/Criteria.php
templates/CRM/Custom/Form/Search.tpl

index a21dc8c0377b8b6dcbc7ce1d75fb8bff7403b045..639814e63abc9dbf15c9ad7fa72d01bd483bd6d2 100644 (file)
@@ -532,7 +532,12 @@ class CRM_Contact_Form_Search_Criteria {
       foreach ($group['fields'] as $field) {
         $fieldId = $field['id'];
         $elementName = 'custom_' . $fieldId;
-        CRM_Core_BAO_CustomField::addQuickFormElement($form, $elementName, $fieldId, FALSE, TRUE);
+        if ($field['data_type'] == 'Date' && $field['is_search_range']) {
+          CRM_Core_Form_Date::buildDateRange($form, $elementName, 1, '_from', '_to', ts('From:'), FALSE);
+        }
+        else {
+          CRM_Core_BAO_CustomField::addQuickFormElement($form, $elementName, $fieldId, FALSE, TRUE);
+        }
       }
     }
   }
index 85d06e53590d1367af626be6018fa5a2f99082cf..88ea7fc80032aaa60f24ef44a880b330970277e0 100644 (file)
                 {assign var="element_name_from" value=$element_name|cat:"_from"}
                 {assign var="element_name_to" value=$element_name|cat:"_to"}
                 <tr>
+                  {if $element.data_type neq 'Date'}
                     <td class="label">{$form.$element_name_from.label}</td><td>
                     {$form.$element_name_from.html|crmAddClass:six}
                     &nbsp;&nbsp;{$form.$element_name_to.label}&nbsp;&nbsp;{$form.$element_name_to.html|crmAddClass:six}
+                  {elseif $element.skip_calendar NEQ true }
+                    <td class="label"><label for='{$element_name}'>{$element.label}</label>
+                    {include file="CRM/Core/DateRange.tpl" fieldName=$element_name from='_from' to='_to'}</td><td>
+                  {/if}
             {else}
                 <td class="label">{$form.$element_name.label}</td><td>
                   {$form.$element_name.html}