Commit 465bcd1d authored by mattwire's avatar mattwire
Browse files

Add template title to Event search if standalone

parent 82ce032a
......@@ -511,6 +511,9 @@ class CRM_AdvancedEvents_Selector_Search extends CRM_Core_Selector_Base implemen
'Event',
$row['id']
);
$eventTemplate = civicrm_api3('EventTemplate', 'getsingle', ['event_id' => $row['id'], 'options'=> ['limit' => 1]]);
$row['template_id'] = $eventTemplate['template_id'];
$row['template_title'] = $eventTemplate['title'];
$this->_rows[] = $row;
}
}
......@@ -542,37 +545,48 @@ class CRM_AdvancedEvents_Selector_Search extends CRM_Core_Selector_Base implemen
*/
public function &getColumnHeaders($action = NULL, $output = NULL) {
// Sortable columns need to be numbered weirdly for them to work... (ie 2,1,3 is important)!
if (!isset(self::$_columnHeaders)) {
self::$_columnHeaders = [
2 => [
if ($action == NULL) {
$action = CRM_Core_Action::VIEW;
}
if (!isset(self::$_columnHeaders[$action])) {
self::$_columnHeaders[$action][2] = [
'name' => ts('Event'),
'sort' => 'civicrm_event.title',
'direction' => CRM_Utils_Sort::DONTCARE,
'weight' => 0,
],
1 => [
'name' => ts('Event Date(s)'),
'sort' => 'civicrm_event.event_start_date',
'direction' => CRM_Utils_Sort::DESCENDING,
];
if ($action != 'query') {
self::$_columnHeaders[$action][6] = [
'name' => ts('Template'),
'weight' => 1,
],
4 => [
];
}
self::$_columnHeaders[$action][1] = [
'name' => ts('Event Date(s)'),
'sort' => 'civicrm_event.event_start_date',
'direction' => CRM_Utils_Sort::DESCENDING,
'weight' => 2,
];
if ($action != 'query') {
self::$_columnHeaders[$action][4] = [
'name' => ts('Participants'),
'weight' => 2,
],
3 => [
'name' => ts('Active'),
'sort' => 'civicrm_event.is_active',
'direction' => CRM_Utils_Sort::DONTCARE,
'weight' => 3,
],
5 => [
'desc' => ts('Actions'),
'weight' => 4,
],
];
}
self::$_columnHeaders[$action][3] = [
'name' => ts('Active'),
'sort' => 'civicrm_event.is_active',
'direction' => CRM_Utils_Sort::DONTCARE,
'weight' => 4,
];
if ($action !== 'query') {
self::$_columnHeaders[$action][5] = [
'desc' => ts('Actions'),
'weight' => 5,
];
}
}
return self::$_columnHeaders;
return self::$_columnHeaders[$action];
}
/**
......
......@@ -48,11 +48,8 @@ class CRM_Event_Form_ManageEvent_Repeat extends CRM_Event_Form_ManageEvent {
4 => 0,
]];
// FIXME: Currently only sorting by event date works because the sort_order links are wrong (only on the repeat screen)
$selector = new CRM_AdvancedEvents_Selector_Search($queryParams);
$columnHeaders = $selector->getColumnHeaders();
unset($columnHeaders['4']); // Participants
unset($columnHeaders['5']); // Actions
$columnHeaders = $selector->getColumnHeaders('query');
$sort = new CRM_Utils_Sort($columnHeaders, $sortID);
$selector->query($sort);
......
......@@ -33,6 +33,9 @@
<tr>
<th scope="col" title="Select Rows">{$form.toggleSelect.html}</th>
{foreach from=$columnHeaders item=header}
{if $header.name eq 'Template' && $single}
{continue}
{/if}
<th scope="col">
{if $header.sort}
{assign var='key' value=$header.sort}
......@@ -48,13 +51,18 @@
{counter start=0 skip=1 print=false}
{foreach from=$rows item=row}
<tr id='rowid{$row.id}' class="{cycle values="odd-row,even-row"} crm-event crm-event_{$row.id}">
{if $context eq 'Search' }
{if $context eq 'Search'}
{assign var=cbName value=$row.checkbox}
<td>{$form.$cbName.html}</td>
{/if}
<td class="crm-event_title"><a href="{crmURL p='civicrm/event/info' q="id=`$row.id`&reset=1"}" title="{ts}View event info page{/ts}">{$row.event_title}</a>
{if $contactId}<br /><a href="{crmURL p='civicrm/event/search' q="reset=1&force=1&event=`$row.id`"}" title="{ts}List participants for this event (all statuses){/ts}">({ts}participants{/ts})</a>{/if}
<td class="crm-event_title">
<a href="{crmURL p='civicrm/event/info' q="id=`$row.id`&reset=1"}" title="{ts}View event info page{/ts}">{$row.event_title}</a>
</td>
{if !$single}
<td class="crm-event_template_title">
<a href="{crmURL p='civicrm/event/manage/settings' q="id=`$row.template_id`&reset=1"}" title="{ts}Edit event template{/ts}">{$row.template_title}</a>
</td>
{/if}
<td class="crm-event_start_date">
{if $row.event_end_date && $row.event_end_date|date_format:"%Y%m%d" NEQ $row.event_start_date|date_format:"%Y%m%d"}
{$row.event_start_date|crmDate}<br/>- {$row.event_end_date|crmDate}
......
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