<?php
$viewHelper = $this->getHelper('MonitoringState');
$contactHelper = $this->getHelper('ContactFlags');
?>
<div class="controls">
    <?= $this->tabs ?>
    <div style="margin: 1em">
        <?= $this->sortControl->render($this); ?>
    </div>
    <?= $this->paginationControl($contacts, null, null, array('preserve' => $this->preserve)); ?>
</div>

<div data-base-target="_next" class="content contacts">
    <?php
    if (count($contacts) === 0) {
        echo mt('monitoring', 'No contacts matching the filter');
        return;
    }
    foreach ($contacts as $contact): ?>
        <div class="contact">
            <img style="width: 60px; height: 60px;" src="<?= $this->href('/static/gravatar', array('email' => $contact->contact_email )) ?>" />
            <a href="<?= $this->href(
                'monitoring/show/contact',
                array('contact' => $contact->contact_name)
            ) ?>"><strong><?= $contact->contact_name ?></strong></a> (<?= $contact->contact_alias ?>)
            <div><?= sprintf(
                '%1$s: <a href="mailto:%2$s">%2$s</a>',
                mt('monitoring', 'Email'),
                $this->escape($contact->contact_email)
            ) ?></div>
            <?php if ($contact->contact_pager): ?>
            <div>
                <?= mt('monitoring', 'Pager') ?>:
                <?= $this->escape($contact->contact_pager) ?>
            </div>
            <?php endif; ?>
            <div style="clear: both;"></div>
            <div class="notification-periods">
                <?php if ($contact->contact_notify_service_timeperiod): ?>
                <div>
                    <?= mt('monitoring', 'Service notification period') ?>:
                    <?= $this->escape($contact->contact_notify_service_timeperiod) ?>
                </div>
                <?php endif; ?>
                <?php if ($contact->contact_notify_host_timeperiod): ?>
                <div>
                    <?= mt('monitoring', 'Host notification period') ?>:
                    <?= $this->escape($contact->contact_notify_host_timeperiod) ?>
                </div>
                <?php endif; ?>
            </div>
        </div>
    <?php
    endforeach;
    if (true): /* The following piece of HTML MUST be nested in <?php */ ?>
    <div style="clear: both;"></div>
    <?php endif; ?>
</div>
