2018-06-14 17:51:48 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Icinga\Module\Director\Forms;
|
|
|
|
|
|
|
|
use Icinga\Module\Director\Web\Form\DirectorObjectForm;
|
|
|
|
|
|
|
|
class IcingaScheduledDowntimeForm extends DirectorObjectForm
|
|
|
|
{
|
2018-06-15 01:31:06 +02:00
|
|
|
/**
|
|
|
|
* @throws \Zend_Form_Exception
|
|
|
|
*/
|
2018-06-14 17:51:48 +02:00
|
|
|
public function setup()
|
|
|
|
{
|
|
|
|
$isTemplate = isset($_POST['object_type']) && $_POST['object_type'] === 'template';
|
2018-06-15 01:31:06 +02:00
|
|
|
$this->addElement('select', 'object_type', [
|
2018-06-14 17:51:48 +02:00
|
|
|
'label' => $this->translate('Object type'),
|
|
|
|
'description' => $this->translate('Whether this should be a template'),
|
|
|
|
'class' => 'autosubmit',
|
2018-06-15 01:31:06 +02:00
|
|
|
'multiOptions' => $this->optionalEnum([
|
2018-06-14 17:51:48 +02:00
|
|
|
'object' => $this->translate('Object'),
|
|
|
|
'template' => $this->translate('Template'),
|
2018-06-15 01:31:06 +02:00
|
|
|
])
|
|
|
|
]);
|
2018-06-14 17:51:48 +02:00
|
|
|
|
|
|
|
if ($isTemplate) {
|
2018-06-15 01:31:06 +02:00
|
|
|
$this->addElement('text', 'object_name', [
|
|
|
|
'label' => $this->translate('Template name'),
|
|
|
|
'required' => true,
|
|
|
|
]);
|
2018-06-14 17:51:48 +02:00
|
|
|
} else {
|
2018-06-15 01:31:06 +02:00
|
|
|
$this->addElement('text', 'object_name', [
|
|
|
|
'label' => $this->translate('Downtime name'),
|
|
|
|
'required' => true,
|
|
|
|
]);
|
2018-06-14 17:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$this->addElement('text', 'display_name', array(
|
|
|
|
'label' => $this->translate('Display Name'),
|
|
|
|
'description' => $this->translate('the display name')
|
|
|
|
));
|
|
|
|
|
|
|
|
$this->addImportsElement();
|
|
|
|
|
2018-06-15 01:31:06 +02:00
|
|
|
$this->addDisabledElement();
|
|
|
|
$this->addElement('text', 'author', [
|
|
|
|
'label' => $this->translate('Author'),
|
|
|
|
'required' => ! $this->isTemplate()
|
|
|
|
]);
|
|
|
|
$this->addElement('textarea', 'comment', [
|
|
|
|
'label' => $this->translate('Comment'),
|
|
|
|
'required' => ! $this->isTemplate(),
|
|
|
|
'rows' => 4,
|
|
|
|
]);
|
|
|
|
$this->addBoolean('fixed', [
|
|
|
|
'label' => $this->translate('Fixed'),
|
|
|
|
'required' => ! $this->isTemplate(),
|
|
|
|
]);
|
|
|
|
$this->addElement('text', 'duration', [
|
|
|
|
'label' => $this->translate('Duration'),
|
|
|
|
'required' => ! $this->isTemplate(),
|
|
|
|
]);
|
|
|
|
|
2018-06-14 17:51:48 +02:00
|
|
|
$this->setButtons();
|
|
|
|
}
|
|
|
|
}
|