icingaweb2/modules/monitoring/application/views/scripts/show/components/downtime.phtml

83 lines
3.1 KiB
PHTML

<tr>
<th><?= $this->translate('Downtimes'); ?></th>
<td>
<?php if ($this->hasPermission('monitoring/command/downtime/schedule')) {
/** @type \Icinga\Module\Monitoring\Object\MonitoredObject $object */
if ($object->getType() === $object::TYPE_HOST) {
echo $this->qlink(
$this->icon('plug') . ' ' . $this->translate('Schedule downtime'),
'monitoring/host/schedule-downtime',
array('host' => $object->getName()),
array(
'data-base-target' => '_self',
'title' => $this->translate(
'Schedule a downtime to suppress all problem notifications within a specific period of time'
)
),
false
);
} else {
echo $this->qlink(
$this->icon('plug') . ' ' . $this->translate('Schedule downtime'),
'monitoring/service/schedule-downtime',
array('host' => $object->getHost()->getName(), 'service' => $object->getName()),
array(
'data-base-target' => '_self',
'title' => $this->translate(
'Schedule a downtime to suppress all problem notifications within a specific period of time'
)
),
false
);
}
} else {
echo '&#45;';
} ?>
</td>
</tr>
<?php
foreach ($object->downtimes as $downtime) {
// Ticket hook sample
$commentText = $this->tickets ? preg_replace_callback(
$this->tickets->getPattern(),
array($this->tickets, 'createLink'),
$this->escape($downtime->comment)
) : $this->escape($downtime->comment);
if ((bool) $downtime->is_in_effect) {
$state = 'in downtime since ' . $this->timeSince($downtime->start);
} else {
if ((bool) $downtime->is_fixed) {
$state = 'scheduled ' . $this->timeUntil($downtime->start);
} else {
$state = 'scheduled flexible ' . $this->timeUntil($downtime->start);
}
}
?>
<tr>
<th><?= $this->escape($downtime->author) ?></th>
<td>
<table>
<tr>
<td style="vertical-align: top;" data-base-target="_self">
<?php if (isset($delDowntimeForm)) { // Form is unset if the current user lacks the respective permission
$delDowntimeForm = clone $delDowntimeForm;
$delDowntimeForm->populate(array('downtime_id' => $downtime->id));
echo $delDowntimeForm;
} ?>
<?= $state ?>
</td>
<td style="padding-left: .5em;">
<?= nl2br($commentText) ?>
</td>
</tr>
</table>
</td>
</tr>
<?php } // endforeach ?>