<?php

use Icinga\Module\Monitoring\Object\Service;

$o = $this->object;

$isService = $o instanceof Service;
$obj = new \stdClass();
$obj->handled =
    ($isService) ? $o->service_handled : $o->host_handled;
$obj->state =
    ($isService) ? $o->service_state : $o->host_state;
$obj->acknowledged =
    ($isService) ? $o->service_acknowledged : $o->host_acknowledged;
$obj->in_downtime =
    ($isService) ? $o->in_downtime : $o->host_in_downtime;
$obj->notifications_enabled =
    ($isService) ? $o->notifications_enabled : $o->service_notifications_enabled;
$obj->active_checks_enabled =
    ($isService) ? $o->active_checks_enabled : $o->host_active_checks_enabled;
$obj->passive_checks_enabled =
    ($isService) ? $o->passive_checks_enabled : $o->host_passive_checks_enabled;

$i = array();
if (! $obj->handled && $obj->state > 0) {
    $i[] = $this->icon('unhandled.png', $this->translate('Unhandled'));
}

if ($obj->acknowledged && ! $obj->in_downtime) {
    $i[] = $this->icon('acknowledgement.png', $this->translate('Acknowledged'));
}

if (!$obj->notifications_enabled) {
    $i[] = $this->icon('notification_disabled.png', $this->translate('Notifications Disabled'));
}

if ($obj->in_downtime) {
    $i[] = $this->icon('in_downtime.png', $this->translate('In Downtime'));
}

if (! $obj->active_checks_enabled) {
    if ($obj->passive_checks_enabled) {
        $i[] = $this->icon('active_checks_disabled.png', $this->translate('Active Checks Disabled'));
    } else {
        $i[] = $this->icon('active_passive_checks_disabled.png', $this->translate('Active And Passive Checks Disabled'));
    }
}

?><?= implode("\n", $i) ?>
