<?php
use Icinga\Module\Monitoring\Object\Host;
use Icinga\Module\Monitoring\Object\Service;

if (! $this->compact): ?>
<div class="controls separated dont-print">
    <?= $tabs ?>
    <?= $this->render('list/components/selectioninfo.phtml') ?>
    <div class="grid">
        <?= $this->sortBox ?>
        <?= $this->limiter ?>
        <?= $this->paginator ?>
    </div>
    <?= $this->filterEditor ?>
</div>
<?php endif ?>
<div class="content">
  <table data-base-target="_next"
         class="table-row-selectable state-table multiselect"
         data-icinga-multiselect-url="<?= $this->href('monitoring/downtimes/show'); ?>"
         data-icinga-multiselect-controllers="<?= $this->href("monitoring/downtimes") ?>"
         data-icinga-multiselect-data="downtime_id">
    <tbody>
    <?php foreach ($downtimes->peekAhead($this->compact) as $downtime):
      if (isset($downtime->service_description)) {
          $this->isService = true;
          $this->stateName = Service::getStateText($downtime->service_state);
      } else {
          $this->isService = false;
          $this->stateName = Host::getStateText($downtime->host_state);
      }
      $this->downtime = $downtime;
    ?>
    <tr href="<?= $this->href('monitoring/downtime/show', array('downtime_id' => $downtime->id)) ?>">
      <?= $this->render('partials/downtime/downtime-header.phtml'); ?>
    </tr>
    <?php endforeach ?>
    </tbody>
  </table>
<?php if (! $downtimes->hasResult()): ?>
  <?= $this->translate('No downtimes found matching the filter, maybe the downtime already expired.'); ?>
<?php elseif ($downtimes->hasMore()): ?>
  <?= $this->qlink(
    $this->translate('Show More'),
    $this->url()->without(array('view', 'limit')),
    null,
    array(
      'data-base-target'    => '_next',
      'class'               => 'pull-right action-link'
    )
  ); ?>
<?php endif ?>
</div>
