<?php if (!$this->compact): ?>
<div class="controls">
  <?= $this->tabs ?>
  <div class="dontprint" style="margin: 1em;">
    <?= $this->translate('Sort by') ?> <?=  $this->sortControl->render($this) ?>
  </div>
  <?= $this->widget('limiter') ?>
  <?=  $this->paginationControl($notifications, null, null, array('preserve' => $this->preserve)) ?>
 </div>
<?php endif ?>

<?php if (! $this->inline): ?>
<div class="content">
<?php endif; ?>

<?php

if (empty($this->notifications)) {
    echo 'No notifications yet</div>';
    return;
}
?>

<table data-base-target="_next" class="action">
<tbody>
<?php

if (count($notifications) === 0) {
    echo mt('monitoring', 'No notifications matching the filter');
}
foreach ($notifications as $notification):

  if (isset($notification->service)) {
      $isService = true;
      $href = $this->href('monitoring/show/service', array(
          'host'    => $notification->host,
          'service' => $notification->service
      ));
      $stateName = strtolower($this->util()->getServiceStateName($notification->notification_state));
  } else {
      $isService = false;
      $href = $this->href('monitoring/show/host', array(
          'host'    => $notification->host
      ));
      $stateName = strtolower($this->util()->getHostStateName($notification->notification_state));
  }
?>
  <tr class="state <?= $stateName ?>">
    <td class="state">
        <?= $this->dateTimeRenderer($notification->notification_start_time)->render(
                $this->translate('on %s', 'datetime'),
                $this->translate('at %s', 'time'),
                $this->translate('%s ago', 'timespan')
            );
        ?>
    </td>
    <td style="font-size: 0.8em">
      <?php if ($isService): ?>
        <a href="<?= $href ?>"><?= $notification->service ?></a> on <?= $notification->host ?>
      <?php else: ?>
        <a href="<?= $href ?>"><?= $notification->host ?></a>
      <?php endif; ?>
      <br />
      <?= $this->escape(substr(strip_tags($notification->notification_output), 0, 10000)); ?>
      <br />
      <?php if (!$this->contact): ?>
      <small>
          Sent to <a href="<?= $this->href(
              'monitoring/show/contact',
              array('contact' => $notification->notification_contact)
          ) ?>"><?= $this->escape($notification->notification_contact) ?></a>
      </small>
      <?php endif ?>
    </td>
  </tr>
<?php endforeach ?>
</tbody>
</table>

<?php if (!$this->inline): ?>
</div>
<?php endif; ?>
