From 4fa2f64e5e9cf654984ee119af6a8c2527bbd562 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Sun, 2 Dec 2018 08:40:27 +1100 Subject: [PATCH] dev/core#561 Convert Activtiy Custom Search from jcalendar to datepicker and fix indenting in tpl file --- .../Form/Search/Custom/ActivitySearch.php | 22 +-- .../Form/Search/Custom/ActivitySearch.tpl | 175 +++++++++--------- 2 files changed, 90 insertions(+), 107 deletions(-) diff --git a/CRM/Contact/Form/Search/Custom/ActivitySearch.php b/CRM/Contact/Form/Search/Custom/ActivitySearch.php index b2dc8e1694..da9f880910 100644 --- a/CRM/Contact/Form/Search/Custom/ActivitySearch.php +++ b/CRM/Contact/Form/Search/Custom/ActivitySearch.php @@ -123,8 +123,8 @@ class CRM_Contact_Form_Search_Custom_ActivitySearch extends CRM_Contact_Form_Sea ); // Activity Date range - $form->addDate('start_date', ts('Activity Date From'), FALSE, array('formatType' => 'custom')); - $form->addDate('end_date', ts('...through'), FALSE, array('formatType' => 'custom')); + $form->add('datepicker', 'start_date', ts('Activity Date From'), [], FALSE, array('time' => FALSE)); + $form->add('datepicker', 'end_date', ts('...through'), [], FALSE, array('time' => FALSE)); // Contact Name field $form->add('text', 'sort_name', ts('Contact Name')); @@ -328,22 +328,12 @@ ORDER BY contact_a.sort_name'; $clauses[] = "activity.activity_type_id = {$this->_formValues['activity_type_id']}"; } - $startDate = $this->_formValues['start_date']; - if (!empty($startDate)) { - $startDate .= '00:00:00'; - $startDateFormatted = CRM_Utils_Date::processDate($startDate); - if ($startDateFormatted) { - $clauses[] = "activity.activity_date_time >= $startDateFormatted"; - } + if (!empty($this->_formValues['start_date'])) { + $clauses[] = "activity.activity_date_time >= '{$this->_formValues['start_date']} 00:00:00'"; } - $endDate = $this->_formValues['end_date']; - if (!empty($endDate)) { - $endDate .= '23:59:59'; - $endDateFormatted = CRM_Utils_Date::processDate($endDate); - if ($endDateFormatted) { - $clauses[] = "activity.activity_date_time <= $endDateFormatted"; - } + if (!empty($this->_formValues['end_date'])) { + $clauses[] = "activity.activity_date_time <= '{$this->_formValues['end_date']} 23:59:59'"; } if ($includeContactIDs) { diff --git a/templates/CRM/Contact/Form/Search/Custom/ActivitySearch.tpl b/templates/CRM/Contact/Form/Search/Custom/ActivitySearch.tpl index edbafd5428..5d308707c1 100644 --- a/templates/CRM/Contact/Form/Search/Custom/ActivitySearch.tpl +++ b/templates/CRM/Contact/Form/Search/Custom/ActivitySearch.tpl @@ -25,116 +25,109 @@ *} {* Template for "Sample" custom search component. *}
-
-
- {ts}Edit Search Criteria{/ts} -
-
-
-
{include file="CRM/common/formButtons.tpl" location="top"}
+
+
+ {ts}Edit Search Criteria{/ts} +
+
+
+
{include file="CRM/common/formButtons.tpl" location="top"}
- {* Loop through all defined search criteria fields (defined in the buildForm() function). *} - {foreach from=$elements item=element} - - - - - {/foreach} + {* Loop through all defined search criteria fields (defined in the buildForm() function). *} + {foreach from=$elements item=element} + + + + + {/foreach}
{$form.$element.label} - {if $element eq 'start_date' OR $element eq 'end_date'} - {include file="CRM/common/jcalendar.tpl" elementName=$element} - {else} - {$form.$element.html} - {/if} -
{$form.$element.label}{$form.$element.html}
-
{include file="CRM/common/formButtons.tpl" location="bottom"}
-
-
-
+
{include file="CRM/common/formButtons.tpl" location="bottom"}
+
+
+
{if $rowsEmpty || $rows} -
+
{if $rowsEmpty} -
- {include file="CRM/Contact/Form/Search/Custom/EmptyResults.tpl"} -
-{/if} +
+ {include file="CRM/Contact/Form/Search/Custom/EmptyResults.tpl"} +
+ {/if} -{if $rows} -
- {* Search request has returned 1 or more matching rows. Display results and collapse the search criteria fieldset. *} + {if $rows} +
+ {* Search request has returned 1 or more matching rows. Display results and collapse the search criteria fieldset. *} - {* This section handles form elements for action task select and submit *} -
- {include file="CRM/Contact/Form/Search/ResultTasks.tpl"} -
- {* This section displays the rows along and includes the paging controls *} -
+ {* This section handles form elements for action task select and submit *} +
+ {include file="CRM/Contact/Form/Search/ResultTasks.tpl"} +
+ {* This section displays the rows along and includes the paging controls *} +
- {include file="CRM/common/pager.tpl" location="top"} + {include file="CRM/common/pager.tpl" location="top"} - {include file="CRM/common/pagerAToZ.tpl"} + {include file="CRM/common/pagerAToZ.tpl"} - {strip} - - - - {foreach from=$columnHeaders item=header} - {if ($header.sort eq 'activity_id') or ($header.sort eq 'activity_type_id') or ($header.sort eq 'case_id') } - {elseif ($header.sort eq 'sort_name') or ($header.sort eq 'activity_status') or ($header.sort eq 'activity_type') or ($header.sort eq 'activity_subject') or ($header.sort eq 'source_contact') or ($header.SORT eq 'activity_date') or ($header.name eq null) } + {strip} +
{$form.toggleSelect.html}
+ + + {foreach from=$columnHeaders item=header} + {if ($header.sort eq 'activity_id') or ($header.sort eq 'activity_type_id') or ($header.sort eq 'case_id') } + {elseif ($header.sort eq 'sort_name') or ($header.sort eq 'activity_status') or ($header.sort eq 'activity_type') or ($header.sort eq 'activity_subject') or ($header.sort eq 'source_contact') or ($header.SORT eq 'activity_date') or ($header.name eq null) } - {/if} - - {/foreach} - - + {/if} + {/foreach} + + - {counter start=0 skip=1 print=false} - {foreach from=$rows item=row} - - {assign var=cbName value=$row.checkbox} - - {foreach from=$columnHeaders item=header} + {counter start=0 skip=1 print=false} + {foreach from=$rows item=row} + + {assign var=cbName value=$row.checkbox} + + {foreach from=$columnHeaders item=header} {if ($header.sort eq 'sort_name') or ($header.sort eq 'activity_status') or ($header.sort eq 'activity_type') or ($header.sort eq 'activity_subject') or ($header.sort eq 'source_contact') or ($header.SORT eq 'activity_date') or ($header.name eq null) } - {assign var=fName value=$header.sort} - {if $fName eq 'sort_name'} - - {elseif $fName eq 'activity_subject'} - - {elseif ($fName eq 'activity_id') or ($fName eq 'activity_type_id') or ($fName eq 'case_id')} - {else} - - {/if} + {assign var=fName value=$header.sort} + {if $fName eq 'sort_name'} + + {elseif $fName eq 'activity_subject'} + + {elseif ($fName eq 'activity_id') or ($fName eq 'activity_type_id') or ($fName eq 'case_id')} + {else} + + {/if} {/if} - {/foreach} - - - {/foreach} -
{$form.toggleSelect.html} - {if $header.sort} - {assign var='key' value=$header.sort} - {$sort->_response.$key.link} - {else} - {$header.name} - {/if} + {if $header.sort} + {assign var='key' value=$header.sort} + {$sort->_response.$key.link} + {else} + {$header.name} + {/if}  
 
{$form.$cbName.html}
{$form.$cbName.html}{$row.sort_name} - {if $row.case_id } - - {else} - - {/if} - {if isset($row.activity_subject) AND $row.activity_subject NEQ 'NULL'}{$row.activity_subject}{else}{ts}(no subject){/ts}{/if} - {$row.$fName}{$row.sort_name} + {if $row.case_id } + + {else} + + {/if} + {if isset($row.activity_subject) AND $row.activity_subject NEQ 'NULL'}{$row.activity_subject}{else}{ts}(no subject){/ts}{/if} + {$row.$fName}{$row.action}
- {/strip} + {/foreach} + {$row.action} + + {/foreach} + + {/strip} -{include file="CRM/common/pager.tpl" location="bottom"} + {include file="CRM/common/pager.tpl" location="bottom"} -
- {* END Actions/Results section *} +
+ {* END Actions/Results section *} +
+ {/if}
{/if} -
-{/if} -- 2.25.1