<?php
/** @var boolean $showService */
$showService = false;

if (isset($this->service) && $this->tabs->getActiveName() !== 'host') {
    $showService = true;
}

/** @var boolean $inlineCommands */
$inlineCommands = true;
if ($this->tabs->getActiveName() === 'history') {
    $inlineCommands = false;
}

if (!$this->compact) {
    echo $this->tabs->render($this);

}
?>
<div>
<?php if ($inlineCommands === true): ?>
  <div class="pull-right">
    <?=
        $this->monitoringCommands(
            ($showService === true) ? $this->service : $this->host,
            'small'
        );
        ?>
  </div>
<?php endif; ?>

  <table>
    <tr>
      <td>
        {{HOST_ICON}}
        <?php if ($this->host->host_icon_image): ?>
        <div>
          <img src="<?= $this->host->host_icon_image; ?>" alt="Host image"/>
        </div>
        <?php endif; ?>
        <strong>
          <?= $this->escape($this->host->host_name); ?>
          <?php if ($this->host->host_address && $this->host->host_address !== $this->host->host_name): ?>
            (<?= $this->escape($this->host->host_address); ?>)
          <?php endif; ?>
        </strong>

        <?php if (isset($this->host->host_alias) && $this->host->host_alias !== $this->host->host_name): ?>
          <br/>
          <sup>(<?= $this->host->host_alias; ?>)</sup>
        <?php endif; ?>
      </td>
      <td
        <?= $showService ? '' : ' rowspan="2"'; ?>
        <?= $this->util()->getHostStateName($this->host->host_state); ?>
        since <?= $this->timeSince($this->host->host_last_state_change); ?>
        <?php if ($this->host->host_acknowledged === '1'): ?>
          (Has been acknowledged)
        <?php endif; ?>
      </td>
    </tr>

    <?php if ($this->host->host_action_url || $this->host->host_notes_url): ?>
    <tr>
      <td rowspan="2">
        <?php if ($this->host->host_action_url): ?>
          {{EXTERNAL_LINK_ICON}}
          <a href='<?= $this->host->host_notes_url ?>'>Host actions </a>
        <?php endif; ?>
        <?php if ($this->host->host_notes_url): ?>
          {{EXTERNAL_LINK_ICON}}
          <a href='<?= $this->host->host_notes_url ?>'>Host notes </a>
        <?php endif; ?>
      </td>
    </tr>
    <?php endif; ?>

    <?php if ($showService === true): ?>
    <tr>
      <td>
        {{SERVICE_ICON}}
        <?php if ($this->service->service_icon_image): ?>
        <div>
          <img src="<?= $this->service->service_icon_image; ?>" alt="Host image"/>
        </div>
        <?php endif; ?>
        <strong>
          Service: <?= $this->escape($this->service->service_description); ?>
        </strong>
      </td>
      <td>
        <?= $this->util()->getServiceStateName($this->service->service_state); ?>
        since <?= $this->timeSince($this->service->service_last_state_change); ?>
        <?php if ($this->service->service_acknowledged === '1'): ?>
        (Has been acknowledged)
        <?php endif; ?>
      </td>
    </tr>


    <?php if ($this->service->service_action_url || $this->service->service_notes_url): ?>
    <tr>
      <td rowspan="2">
        <?php if ($this->service->service_action_url): ?>
          {{EXTERNAL_LINK_ICON}}
          <a href='<?= $this->service->service_notes_url ?>'>Service actions </a>
        <?php endif; ?>

        <?php if ($this->service->service_notes_url): ?>
          {{EXTERNAL_LINK_ICON}}
          <a href='<?= $this->service->service_notes_url ?>'>Service notes </a>
        <?php endif; ?>
      </td>
    </tr>
    <?php endif; ?>
  <?php endif; ?>
  </table>
  <div class="clearfix"></div>
</div>