<?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 grid">
    <div class="boxview">
        <div class="box stats col-1-2">
            <h3><?= $this->unhandledProblems ?> <?= $this->translate('Unhandled Problems:') ?>
                <span class="badge badge-critical"> <?= $this->unhandledProblems ?> </span>
            </h3>
            <table class="avp">
                <tbody>
                <tr>
                    <th> <?= $this->translate('Service Problems:') ?> </th>
                    <td>
                        <span class="badge badge-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>
                        <span class="badge badge-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>
            <br>

            <h3 class="tinystatesummary" data-base-target="_next">
                <?php $this->stats = $hoststats ?>
                <?= $this->render('list/components/hostssummary.phtml') ?>
            </h3>
            <table class="avp">
                <thead>
                <tr>
                    <th><strong><?= $this->translate('Runtime Variables') ?></strong></th>
                    <th><?= $this->translate('Host Checks') ?></th>
                    <th></th>
                    <th></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>
            <br>

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

            <h3><?= $this->translate('Active checks') ?></h3>
            <table class="avp">
                <thead>
                <tr>
                    <th><strong> <?= $this->translate('Check Performance') ?> </strong></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>
            <br>

            <h3><?= $this->translate('Passive checks') ?></h3>
            <table class="avp">
                <thead>
                <tr>
                    <th><strong> <?= $this->translate('Check Performance') ?> </strong></th>
                    <th><?= $this->translate('Passive Checks') ?></th>
                    <th></th>
                    <th></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>
