<?php
$rv = $this->runtimeVariables()->create($this->runtimevariables);
$cp = $this->checkPerformance()->create($this->checkperformance);

if (! $this->compact): ?>
<div class="controls">
    <?= $this->tabs ?>
</div>
<?php endif ?>

<div class="content stats">
    <div class="boxview">
        <div class="box stats">
            <h2 tabindex="0"><?= $this->unhandledProblems ?> <?= $this->translate('Unhandled Problems:') ?></h2>
            <table class="name-value-table">
                <thead>
                    <th></th>
                    <th colspan="3"></th>
                </thead>
                <tbody>
                    <tr>
                        <th><?= $this->translate('Service Problems:') ?></th>
                        <td colspan="3">
                            <span class="badge state-critical">
                                <?=
                                $this->qlink(
                                    $this->unhandledServiceProblems,
                                    'monitoring/list/services?service_problem=1&service_handled=0&sort=service_severity',
                                    null,
                                    array('data-base-target' => '_next')
                                )
                                ?>
                            </span>
                        </td>
                    </tr>
                    <tr>
                        <th><?= $this->translate('Host Problems:') ?></th>
                        <td colspan="3">
                            <span class="badge state-critical">
                                <?=
                                $this->qlink(
                                    $this->unhandledhostProblems,
                                    'monitoring/list/hosts?host_problem=1&host_handled=0',
                                    null,
                                    array('data-base-target' => '_next')
                                )
                                ?>
                            </span>
                        </td>
                    </tr>
                </tbody>
            </table>

            <h2 tabindex="0" class="tinystatesummary" data-base-target="_next">
                <?php $this->stats = $hoststats ?>
                <?= $this->render('list/components/hostssummary.phtml') ?>
            </h2>
            <table class="name-value-table">
                <thead>
                    <tr>
                        <th><?= $this->translate('Runtime Variables') ?></th>
                        <th colspan="3"><?= $this->translate('Host Checks') ?></th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <th><?= $this->translate('Total') ?></th>
                        <td><?= $rv->total_scheduled_hosts ?></td>
                    </tr>
                    <tr>
                        <th><?= $this->translate('Scheduled') ?></th>
                        <td><?= $rv->total_scheduled_hosts ?></td>
                    </tr>
                </tbody>
            </table>

            <h2 class="tinystatesummary" data-base-target="_next">
                <?php $this->stats = $servicestats ?>
                <?= $this->render('list/components/servicesummary.phtml') ?>
            </h2>
            <table class="name-value-table">
                <thead>
                <tr>
                    <th><?= $this->translate('Runtime Variables') ?></th>
                    <th><?= $this->translate('Service Checks') ?></th>
                    <th colspan="2"><?= $this->translate('Per Host') ?></th>
                </tr>
                </thead>
                <tbody>
                    <tr>
                        <th><?= $this->translate('Total') ?></th>
                        <td><?= $rv->total_services ?></td>
                        <td><?= sprintf('%.2f', $rv->average_services_per_host) ?></td>
                    </tr>
                    <tr>
                        <th><?= $this->translate('Scheduled') ?></th>
                        <td><?= $rv->total_scheduled_services ?></td>
                        <td><?= sprintf('%.2f', $rv->average_scheduled_services_per_host) ?></td>
                    </tr>
                </tbody>
            </table>

            <h2><?= $this->translate('Active checks') ?></h2>
            <table class="name-value-table">
                <thead>
                    <tr>
                        <th><?= $this->translate('Check Performance') ?></th>
                        <th><?= $this->translate('Checks') ?></th>
                        <th><?= $this->translate('Latency') ?></th>
                        <th><?= $this->translate('Execution time') ?></th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <th><?= $this->translate('Host Checks') ?></th>
                        <td><?= $cp->host_active_count; ?></td>
                        <td><?= sprintf('%.3f', $cp->host_active_latency_avg) ?>s</td>
                        <td><?= sprintf('%.3f', $cp->host_active_execution_avg) ?>s</td>
                    </tr>
                    <tr>
                        <th><?= $this->translate('Service Checks') ?></th>
                        <td><?= $cp->service_active_count; ?></td>
                        <td><?= sprintf('%.3f', $cp->service_active_latency_avg) ?>s</td>
                        <td><?= sprintf('%.3f', $cp->service_active_execution_avg) ?>s</td>
                    </tr>
                </tbody>
            </table>

            <h2><?= $this->translate('Passive checks') ?></h2>
            <table class="name-value-table">
                <thead>
                    <tr>
                        <th><?= $this->translate('Check Performance') ?></th>
                        <th colspan="3"><?= $this->translate('Passive Checks') ?></th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <th><?= $this->translate('Host Checks') ?></th>
                        <td><?= $cp->host_passive_count ?></td>
                    </tr>
                    <tr>
                        <th><?= $this->translate('Service Checks') ?></th>
                        <td><?= $cp->service_passive_count ?></td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
</div>
