Skip to content

Commit

Permalink
Merge pull request #12978 from mattwire/datepicker_manageevent_search
Browse files Browse the repository at this point in the history
Convert event search to datepicker and cleanup template
  • Loading branch information
eileenmcnaughton authored Oct 29, 2018
2 parents 4ae6181 + 7a02177 commit b4cbce3
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 31 deletions.
14 changes: 6 additions & 8 deletions CRM/Event/Form/SearchEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ public function setDefaultValues() {
/**
* Build the form object.
*
*
* @return void
* @throws \CRM_Core_Exception
*/
public function buildQuickForm() {
$this->add('text', 'title', ts('Event Name'),
Expand All @@ -72,10 +71,10 @@ public function buildQuickForm() {

$eventsByDates = array();
$searchOption = array(ts('Show Current and Upcoming Events'), ts('Search All or by Date Range'));
$this->addRadio('eventsByDates', ts('Events by Dates'), $searchOption, array('onclick' => "return showHideByValue('eventsByDates','1','id_fromToDates','block','radio',true);"), "<br />");
$this->addRadio('eventsByDates', ts('Events by Dates'), $searchOption, array('onclick' => "return showHideByValue('eventsByDates','1','id_fromToDates','block','radio',true);"), '&nbsp;');

$this->addDate('start_date', ts('From'), FALSE, array('formatType' => 'searchDate'));
$this->addDate('end_date', ts('To'), FALSE, array('formatType' => 'searchDate'));
$this->add('datepicker', 'start_date', ts('From'), [], FALSE, ['time' => FALSE]);
$this->add('datepicker', 'end_date', ts('To'), [], FALSE, ['time' => FALSE]);

CRM_Campaign_BAO_Campaign::addCampaignInComponentSearch($this);

Expand All @@ -98,9 +97,8 @@ public function postProcess() {
if (isset($params[$field]) &&
!CRM_Utils_System::isNull($params[$field])
) {
if (substr($field, -4) == 'date') {
$time = ($field == 'end_date') ? '235959' : NULL;
$parent->set($field, CRM_Utils_Date::processDate($params[$field], $time));
if ($field === 'end_date') {
$parent->set($field, $params[$field] . ' 23:59:59');
}
else {
$parent->set($field, $params[$field]);
Expand Down
5 changes: 2 additions & 3 deletions templates/CRM/Campaign/Form/addCampaignToComponent.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
{* add campaign in component search *}
<tr class="{$campaignTrClass}">
{assign var=elementName value=$campaignInfo.elementName}

<td class="{$campaignTdClass}">{$form.$elementName.label}<br />
<div class="crm-select-container">{$form.$elementName.html}</div>
<td class="{$campaignTdClass}">
{$form.$elementName.label} {$form.$elementName.html}
</td>
</tr>

Expand Down
38 changes: 22 additions & 16 deletions templates/CRM/Event/Form/SearchEvent.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*}
<div class="crm-block crm-form-block crm-event-searchevent-form-block">
<h3>{ts}Find Events{/ts}</h3>
<div class="crm-accordion-wrapper crm-block crm-form-block crm-event-searchevent-form-block collapsed">
<div class="crm-accordion-header">
{ts}Find Events{/ts}
</div>
<div class="crm-accordion-body">
<table class="form-layout">
<tr class="crm-event-searchevent-form-block-title">
<td>
Expand All @@ -33,41 +36,44 @@
<div class="description font-italic">
{ts}Complete OR partial Event name.{/ts}
</div>
<div style="height: auto; vertical-align: bottom">{$form.eventsByDates.html}</div>
</td>
<td rowspan="2"><label>{ts}Event Type{/ts}</label>
<td><label>{ts}Event Type{/ts}</label>
{$form.event_type_id.html}
</td>
<td class="right" rowspan="2">&nbsp;{include file="CRM/common/formButtons.tpl"}</td>
</tr>

<tr>
<td colspan="2"><div style="height: auto; vertical-align: bottom">{$form.eventsByDates.html}</div></td>
</tr>
<tr>
<td colspan="2">
<table class="form-layout-compressed" id="id_fromToDates">
<tr class="crm-event-searchevent-form-block-start_date">
<td class="label">{$form.start_date.label}</td>
<td>{include file="CRM/common/jcalendar.tpl" elementName=start_date}</td>
</tr>
<tr class="crm-event-searchevent-form-block-end_date" >
<td class="label">{$form.end_date.label}</td>
<td>{include file="CRM/common/jcalendar.tpl" elementName=end_date}</td>
<tr class="">
<td class="crm-event-searchevent-form-block-start_date">
<label>{$form.start_date.label}</label>
{$form.start_date.html}
</td>
<td class="crm-event-searchevent-form-block-end_date">
<label>{$form.end_date.label}</label>
{$form.end_date.html}
</td>
</tr>
</table>
</td></tr>

{* campaign in event search *}
{include file="CRM/Campaign/Form/addCampaignToComponent.tpl" campaignContext="componentSearch"
campaignTrClass='crm-event-searchevent-form-block-campaign_id' campaignTdClass=''}

<td class="right">{include file="CRM/common/formButtons.tpl"}</td>
</table>
</div>
</div>
</div>

{include file="CRM/common/showHide.tpl"}

{literal}
<script type="text/javascript">
if ( document.getElementsByName('eventsByDates')[1].checked ) {
cj('#id_fromToDates').show();
CRM.$('#id_fromToDates').show();
}
</script>
{/literal}
10 changes: 6 additions & 4 deletions templates/CRM/Event/Page/ManageEvent.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,25 @@
{capture assign=icalFeed}{crmURL p='civicrm/event/ical' q="reset=1&list=1" fe=1}{/capture}
{capture assign=rssFeed}{crmURL p='civicrm/event/ical' q="reset=1&list=1&rss=1" fe=1}{/capture}
{capture assign=htmlFeed}{crmURL p='civicrm/event/ical' q="reset=1&list=1&html=1" fe=1}{/capture}

<div class="crm-block crm-content-block">
<div class="float-right">
<a href="{$htmlFeed}" target="_blank" title="{ts}HTML listing of current and future public events.{/ts}" class="crm-event-feed-link"><i class="crm-i fa-lg fa-calendar"></i></a>
<a href="{$rssFeed}" target="_blank" title="{ts}Get RSS 2.0 feed for current and future public events.{/ts}" class="crm-event-feed-link"><i class="crm-i fa-lg fa-rss"></i></a>
<a href="{$icalFile}" title="{ts}Download iCalendar file for current and future public events.{/ts}" class="crm-event-feed-link"><i class="crm-i fa-lg fa-download"></i></a>
<a href="{$icalFeed}" target="_blank" title="{ts}Get iCalendar feed for current and future public events.{/ts}" class="crm-event-feed-link"><i class="crm-i fa-lg fa-calendar-o"></i></a>
{help id='icalendar'}
</div>
{include file="CRM/Event/Form/SearchEvent.tpl"}

<div class="action-link">
<a accesskey="N" href="{$newEventURL}" id="newManageEvent" class="button crm-popup">
<span><i class="crm-i fa-calendar-plus-o"></i> {ts}Add Event{/ts}</span>
</a>
<div class="clear"></div>
</div>

{include file="CRM/Event/Form/SearchEvent.tpl"}

{if $rows}
<div id="event_status_id" class="crm-block crm-manage-events">
{strip}
Expand Down Expand Up @@ -153,9 +157,6 @@
</table>
{include file="CRM/common/pager.tpl" location="bottom"}
{/strip}
{if $isSearch eq 0}
<div class="status messages no-popup">{ts}Don't see your event listed? Try "Search All or by Date Range" above.{/ts}</div>
{/if}
</div>
{else}
{if $isSearch eq 1}
Expand All @@ -179,3 +180,4 @@
</div>
{/if}
{/if}
</div>

0 comments on commit b4cbce3

Please sign in to comment.