<?php
use Icinga\Data\Filter\Filter;
?>
<?php if (! $this->compact): ?>
<div class="controls">
    <?= $this->tabs ?>
    <?= $this->filterEditor ?>
</div>
<?php endif ?>
<div class="content tactical grid">
<?php if (! count(array_filter((array) $statusSummary))): ?>
    <p><?= $this->translate('No results found matching the filter.') ?></p>
</div>
<?php return; endif ?>
    <div class="boxview" data-base-target="_next">
        <div class="donut-container">
            <h2 aria-label="<?= $this->translate('Host Summary') ?>"><?= $this->translate('Host Summary') ?></h2>
            <div class="donut">
                <?= $hostStatusSummaryChart ?>
            </div>
            <ul class="donut-legend">
            <?php if ($statusSummary->hosts_up): ?>
                <li>
                    <a href="<?= $this->filteredUrl('monitoring/list/hosts', array('host_state' => 0, 'sort' => 'host_last_check', 'dir' => 'asc')) ?>">
                        <span class="state state-ok badge"><?= $statusSummary->hosts_up ?></span><?= $this->translate('Up') ?>
                    </a>
                </li>
            <?php endif ?>
            <?php if ($statusSummary->hosts_down_handled): ?>
                <li>
                    <a href="<?= $this->filteredUrl('monitoring/list/hosts', array('host_state' => 1, 'host_handled' => 1, 'sort' => 'host_last_check', 'dir' => 'asc')) ?>">
                        <span class="state state-critical handled badge"><?= $statusSummary->hosts_down_handled ?></span><?= $this->translate('Down') ?> (<?= $this->translate('Handled') ?>)
                    </a>
                </li>
            <?php endif ?>
            <?php if ($statusSummary->hosts_down_unhandled): ?>
                <li>
                    <a href="<?= $this->filteredUrl('monitoring/list/hosts', array('host_state' => 1, 'host_handled' => 0, 'sort' => 'host_last_check', 'dir' => 'asc')) ?>">
                        <span class="state state-critical badge"><?= $statusSummary->hosts_down_unhandled ?></span><?= $this->translate('Down') ?>
                    </a>
                </li>
            <?php endif ?>
            <?php if ($statusSummary->hosts_unreachable_handled): ?>
                <li>
                    <a href="<?= $this->filteredUrl('monitoring/list/hosts', array('host_state' => 2, 'host_handled' => 1, 'sort' => 'host_last_check', 'dir' => 'asc')) ?>">
                        <span class="state state-unreachable handled badge"><?= $statusSummary->hosts_unreachable_handled ?></span><?= $this->translate('Unreachable') ?> (<?= $this->translate('Handled') ?>)
                    </a>
                </li>
            <?php endif ?>
            <?php if ($statusSummary->hosts_unreachable_unhandled): ?>
                <li>
                    <a href="<?= $this->filteredUrl('monitoring/list/hosts', array('host_state' => 2, 'host_handled' => 0, 'sort' => 'host_last_check', 'dir' => 'asc')) ?>">
                        <span class="state state-unreachable badge"><?= $statusSummary->hosts_unreachable_unhandled ?></span><?= $this->translate('Unreachable') ?>
                    </a>
                </li>
            <?php endif ?>
            <?php if ($statusSummary->hosts_pending): ?>
                <li>
                    <a href="<?= $this->filteredUrl('monitoring/list/hosts', array('host_state' => 99, 'sort' => 'host_last_check', 'dir' => 'asc'))->addFilter(Filter::not(Filter::where('host_active_checks_enabled', 0), Filter::where('host_passive_checks_enabled', 0))) ?>">
                        <span class="state state-pending badge"><?= $statusSummary->hosts_pending ?></span><?= $this->translate('Pending') ?>
                    </a>
                </li>
            <?php endif ?>
            <?php if ($statusSummary->hosts_pending_not_checked): ?>
                <li>
                    <a href="<?= $this->filteredUrl('monitoring/list/hosts', array('host_state' => 99, 'host_active_checks_enabled' => 0, 'host_passive_checks_enabled' => 0, 'sort' => 'host_last_check', 'dir' => 'asc')) ?>">
                        <span class="state slice-state-not-checked badge"><?= $statusSummary->hosts_pending_not_checked ?></span><?= $this->translate('Not Checked') ?>
                    </a>
                </li>
            <?php endif ?>
            </ul>
        </div>
        <div class="donut-container">
            <h2 aria-label="<?= $this->translate('Service Summary') ?>"><?= $this->translate('Service Summary') ?></h2>
            <div class="donut">
                <?= $serviceStatusSummaryChart ?>
            </div>
            <ul class="donut-legend">
            <?php if ($statusSummary->services_ok):?>
                <li>
                    <a href="<?= $this->filteredUrl('monitoring/list/services', array('service_state' => 0, 'sort' => 'service_last_check', 'dir' => 'asc')) ?>">
                        <span class="state state-ok badge"><?= $statusSummary->services_ok ?></span><?= $this->translate('Ok') ?>
                    </a>
                </li>
            <?php endif;
            if ($statusSummary->services_warning_handled):?>
                <li>
                    <a href="<?= $this->filteredUrl('monitoring/list/services', array('service_state' => 1, 'service_handled' => 1, 'sort' => 'service_last_check', 'dir' => 'asc')) ?>">
                        <span class="state state-warning handled badge"><?= $statusSummary->services_warning_handled ?></span><?= $this->translate('Warning') ?> (<?= $this->translate('Handled') ?>)
                    </a>
                </li>
            <?php endif;
            if ($statusSummary->services_warning_unhandled):?>
                <li>
                    <a href="<?= $this->filteredUrl('monitoring/list/services', array('service_state' => 1, 'service_handled' => 0, 'sort' => 'service_last_check', 'dir' => 'asc')) ?>">
                        <span class="state state-warning badge"><?= $statusSummary->services_warning_unhandled ?></span><?= $this->translate('Warning') ?>
                    </a>
                </li>
            <?php endif;
            if ($statusSummary->services_critical_handled):?>
                <li>
                    <a href="<?= $this->filteredUrl('monitoring/list/services', array('service_state' => 2, 'service_handled' => 1, 'sort' => 'service_last_check', 'dir' => 'asc')) ?>">
                        <span class="state state-critical handled badge"><?= $statusSummary->services_critical_handled ?></span><?= $this->translate('Critical') ?> (<?= $this->translate('Handled') ?>)
                    </a>
                </li>
            <?php endif;
            if ($statusSummary->services_critical_unhandled):?>
                <li>
                    <a href="<?= $this->filteredUrl('monitoring/list/services', array('service_state' => 2, 'service_handled' => 0, 'sort' => 'service_last_check', 'dir' => 'asc')) ?>">
                        <span class="state state-critical badge"><?= $statusSummary->services_critical_unhandled ?></span><?= $this->translate('Critical') ?>
                    </a>
                </li>
            <?php endif;
            if ($statusSummary->services_unknown_handled):?>
                <li>
                    <a href="<?= $this->filteredUrl('monitoring/list/services', array('service_state' => 3, 'service_handled' => 1, 'sort' => 'service_last_check', 'dir' => 'asc')) ?>">
                        <span class="state state-unknown handled badge"><?= $statusSummary->services_unknown_handled ?></span><?= $this->translate('Unknown') ?> (<?= $this->translate('Handled') ?>)
                    </a>
                </li>
            <?php endif;
            if ($statusSummary->services_unknown_unhandled):?>
                <li>
                    <a href="<?= $this->filteredUrl('monitoring/list/services', array('service_state' => 3, 'service_handled' => 0, 'sort' => 'service_last_check', 'dir' => 'asc')) ?>">
                        <span class="state state-unknown badge"><?= $statusSummary->services_unknown_unhandled ?></span><?= $this->translate('Unknown') ?>
                    </a>
                </li>
            <?php endif;
            if ($statusSummary->services_pending):?>
                <li>
                    <a href="<?= $this->filteredUrl('monitoring/list/services', array('service_state' => 99, 'sort' => 'service_last_check', 'dir' => 'asc'))->addFilter(Filter::not(Filter::where('service_active_checks_enabled', 0), Filter::where('service_passive_checks_enabled', 0))) ?>">
                        <span class="state state-pending badge"><?= $statusSummary->services_pending ?></span><?= $this->translate('Pending') ?>
                    </a>
                </li>
            <?php endif;
            if ($statusSummary->services_pending_not_checked):?>
                <li>
                    <a href="<?= $this->filteredUrl('monitoring/list/services', array('service_state' => 99, 'service_active_checks_enabled' => 0, 'service_passive_checks_enabled' => 0, 'sort' => 'service_last_check', 'dir' => 'asc')) ?>">
                        <span class="state slice-state-not-checked badge"><?= $statusSummary->services_pending_not_checked ?></span><?= $this->translate('Not Checked') ?>
                    </a>
                </li>
            <?php endif?>
            </ul>
        </div>
    </div>
</div>
