<div class="controls">
    <?php if (! $this->compact): ?>
        <?= $tabs; ?>
    <?php endif ?>
    <?= $this->render('list/components/hostssummary.phtml') ?>
    <?= $this->render('partials/host/objects-header.phtml'); ?>
    <?php
        $hostCount = count($objects);
        $unhandledCount = count($unhandledObjects);
        $problemCount = count($problemObjects);
        $unackCount = count($unacknowledgedObjects);
        $scheduledDowntimeCount = count($objects->getScheduledDowntimes());
    ?>
</div>

<div class="content">
    <?php if ($hostCount === 0): ?>
        <?= $this->translate('No hosts found matching the filter'); ?>
    <?php else: ?>
        <h2><?= $this->translate('Problem Handling') ?></h2>
        <table class="name-value-table">
            <tbody>
            <?php

            if ($unackCount > 0): ?>
                <tr>
                    <th> <?= sprintf($this->translate('%d unhandled problems'), $unackCount) ?> </th>
                    <td>
                        <?= $this->qlink(
                            $this->translate('Acknowledge'),
                            $acknowledgeLink,
                            null,
                            array(
                                'class' => 'action-link',
                                'icon'  => 'check'
                            )
                        ) ?>
                    </td>
                </tr>
            <?php endif; ?>

            <?php if (($acknowledgedCount = count($acknowledgedObjects)) > 0): ?>
                <tr>
                    <th> <?= sprintf(
                            $this->translatePlural(
                                '%s acknowledgement',
                                '%s acknowledgements',
                                $acknowledgedCount
                            ),
                            '<b>' . $acknowledgedCount . '</b>'
                        ); ?> </th>
                    <td>
                        <?= $removeAckForm->setLabelEnabled(true) ?>
                    </td>
                </tr>
            <?php endif ?>

            <tr>
                <th> <?= $this->translate('Comments') ?> </th>
                <td>
                    <?= $this->qlink(
                        $this->translate('Add comments'),
                        $addCommentLink,
                        null,
                        array(
                            'class' => 'action-link',
                            'icon'  => 'comment-empty'
                        )
                    ) ?>
                </td>
            </tr>

            <?php if (($commentCount = count($objects->getComments())) > 0): ?>
            <tr>
                <th></th>
                <td>
                    <?= $this->qlink(
                        sprintf(
                            $this->translatePlural(
                                '%s comment',
                                '%s comments',
                                $commentCount
                            ),
                            $commentCount
                        ),
                        $commentsLink,
                        null,
                        array('data-base-target' => '_next')
                    ); ?>
                </td>
            </tr>
            <?php endif ?>

            <tr>
                <th>
                    <?= $this->translate('Downtimes') ?>
                </th>
                <td>
                    <?= $this->qlink(
                        $this->translate('Schedule downtimes'),
                        $downtimeAllLink,
                        null,
                        array(
                            'icon' => 'plug',
                            'class' => 'action-link'
                        )
                    ) ?>
                </td>
            </tr>

            <?php if ($scheduledDowntimeCount > 0): ?>
                <tr>
                    <th></th>
                    <td>
                        <?= $this->qlink(
                            sprintf(
                                $this->translatePlural(
                                    '%d scheduled downtime',
                                    '%d scheduled downtimes',
                                    $scheduledDowntimeCount
                                ),
                                $scheduledDowntimeCount
                            ),
                            $showDowntimesLink,
                            null,
                            array(
                                'data-base-target' => '_next'
                            )
                        ) ?>
                    </td>
                </tr>
            <?php endif ?>
            </tbody>
        </table>

        <?php if ($this->hasPermission('monitoring/command/send-custom-notification')): ?>
            <h2> <?= $this->translate('Notifications') ?> </h2>
            <table class="name-value-table">
                <tbody>
                <tr>
                    <th> <?= $this->translate('Notifications') ?> </th>
                    <td>
                        <?= $this->qlink(
                            $this->translate('Send notifications'),
                            $sendCustomNotificationLink,
                            null,
                            array(
                                'class' => 'action-link',
                                'icon'  => 'bell'
                            )
                        ) ?>
                    </td>
                </tr>
                </tbody>
            </table>
        <?php endif ?>

        <h2> <?= $this->translate('Check Execution') ?> </h2>

        <table class="name-value-table">
            <tbody>
            <tr>
                <th> <?= $this->translate('Command') ?> </th>
                <td>
                    <?= $this->qlink(
                        $this->translate('Process check result'),
                        $processCheckResultAllLink,
                        null,
                        array(
                            'class' => 'action-link',
                            'icon'  => 'edit'
                        )
                    ) ?>
                </td>
            </tr>

            <?php if (isset($checkNowForm)): // Form is unset if the current user lacks the respective permission ?>
                <tr>
                    <th> <?= $this->translate('Schedule Check') ?> </th>
                    <td> <?= $checkNowForm ?> </td>
                </tr>
            <?php endif ?>

            <tr>
                <th></th>
                <td>
                    <?= $this->qlink(
                        $this->translate('Reschedule'),
                        $rescheduleAllLink,
                        null,
                        array(
                            'class' => 'action-link',
                            'icon'  => 'calendar-empty'
                        )
                    ) ?>
                </td>
            </tr>
            </tbody>
        </table>
        <h2><?= $this->translate('Feature Commands') ?></h2>
        <?= $toggleFeaturesForm ?>
    <?php endif ?>
</div>
