<?php if (! $this->compact): ?>
<div class="controls">
    <?= $this->tabs ?>
    <?php
    $helpMessage = $this->translate(
        'Press and hold the Ctrl key while clicking on rows to select multiple rows or press and hold the Shift key to'
        . ' select a range of rows',
        'Multi-selection help'
    );
    ?>
    <div class="selection-info" title="<?= $this->escape($helpMessage) ?>">
        <?= sprintf(
        /// TRANSLATORS: Please leave %s as it is because the selection counter is wrapped in a span tag for updating
        /// the counter via JavaScript
            $this->translate('%s row(s) selected', 'Multi-selection count'),
            '<span class="selection-info-count">0</span>'
        ) ?>
    </div>
    <?= $this->paginator ?>
    <div class="sort-controls-container">
        <?= $this->limiter ?>
        <?= $this->sortBox ?>
    </div>
    <?= $this->filterEditor ?>
    <div class="quick-filter-controls">
        <?= $this->severityFilterForm ?>
        <?= $this->ackFilterForm ?>
    </div>
</div>
<?php endif ?>
<div class="content">
<?php /** @var \Icinga\Repository\RepositoryQuery $events */if (! $events->hasResult()): ?>
    <p><?= $this->translate('No events recorded yet.') ?></p>
</div>
<?php return; endif; $displayColumns = array_merge(array('host_name', 'program', 'message', 'facility'), $additionalColumns); ?>
    <table class="common-table table-row-selectable multiselect table-responsive events-table"
           data-base-target="_next"
           data-icinga-multiselect-url="<?= $this->href('eventdb/events/details') ?>"
           data-icinga-multiselect-controllers="<?= $this->href('eventdb/events') ?>"
           data-icinga-multiselect-data="id">
        <?php if (! $this->compact): ?>
        <thead>
            <tr>
                <th></th>
                <th></th>
            <?php foreach ($displayColumns as $displayColumn): ?>
                <?= $this->columnHeader($displayColumn) ?>
            <?php endforeach ?>
            </tr>
        </thead>
        <?php endif; ?>
        <tbody>
        <?php
        foreach ($events as $eventData):
            /** @var \Icinga\Module\Eventdb\Event $event */
            $event = $this->event($eventData);
            $created = $event->created;
            $createdTs = strtotime($created);
            $url = $this->url('eventdb/event', array('id' => $event->id));
            $classes = array('priority-col', $event->getPriority());
            if ($event->ack) {
                $classes[] = 'ack';
            }
            ?>
            <tr href="<?= $url ?>">
                <td class="<?= implode(' ', $classes) ?>">
                    <div class="priority-label"><?= strtoupper($event->getPriority()) ?></div>
                    <div class="event-meta"><a href="<?= $url ?>" class="timeago" title="<?= $created ?>"><?= $this->timeAgo($createdTs) ?></a></div>
                </td>
                <td class="icon-col">
                    <?= $this->icon($event->getTypeIcon(), $event->getType()) ?>
                    <?php if ($event->ack) { echo $this->icon('ok', $this->translate('Acknowledged')); } ?>
                    <?php if ($event->group_autoclear) { echo $this->icon('reschedule', $this->translate('Auto-Clear')); } ?>
                </td>
            <?php foreach ($displayColumns as $displayColumn): ?>
                <?= $this->column($displayColumn, $event) ?>
            <?php endforeach ?>
            </tr>
        <?php endforeach ?>
        </tbody>
    </table>
<?php if ($this->compact && $events->hasMore()): ?>
    <?= $this->qlink(
        $this->translate('Show More'),
        $this->url()->without(array('view', 'limit')),
        null,
        array(
            'data-base-target'  => '_next',
            'class'             => 'action-link'
        )
    ) ?>
<?php endif; ?>
</div>
