Exemplo n.º 1
0
 $frmMaintenance->setName(S_MAINTENANCE);
 $frmMaintenance->addVar('form', get_request('form', 1));
 $from_rfr = get_request('form_refresh', 0);
 $frmMaintenance->addVar('form_refresh', $from_rfr + 1);
 if (isset($_REQUEST['maintenanceid'])) {
     $frmMaintenance->addVar('maintenanceid', $_REQUEST['maintenanceid']);
 }
 $left_tab = new CTable();
 $left_tab->setCellPadding(3);
 $left_tab->setCellSpacing(3);
 $left_tab->setAttribute('border', 0);
 $left_tab->addRow(create_hat(S_MAINTENANCE, get_maintenance_form(), null, 'hat_maintenance'));
 $left_tab->addRow(create_hat(S_MAINTENANCE_PERIODS, get_maintenance_periods(), null, 'hat_timeperiods'));
 if (isset($_REQUEST['new_timeperiod'])) {
     $new_timeperiod = $_REQUEST['new_timeperiod'];
     $left_tab->addRow(create_hat(is_array($new_timeperiod) && isset($new_timeperiod['id']) ? S_EDIT_MAINTENANCE_PERIOD : S_NEW_MAINTENANCE_PERIOD, get_timeperiod_form(), null, 'hat_new_timeperiod'));
 }
 $right_tab = new CTable();
 $right_tab->setCellPadding(3);
 $right_tab->setCellSpacing(3);
 $right_tab->setAttribute('border', 0);
 $right_tab->addRow(create_hat(S_HOSTS_IN_MAINTENANCE, get_maintenance_hosts_form($frmMaintenance), null, 'hat_host_link'));
 $right_tab->addRow(create_hat(S_GROUPS_IN_MAINTENANCE, get_maintenance_groups_form($frmMaintenance), null, 'hat_group_link'));
 $td_l = new CCol($left_tab);
 $td_l->setAttribute('valign', 'top');
 $td_r = new CCol($right_tab);
 $td_r->setAttribute('valign', 'top');
 $outer_table = new CTable();
 $outer_table->setAttribute('border', 0);
 $outer_table->setCellPadding(1);
 $outer_table->setCellSpacing(1);
        $maintenanceForm->addVar('timeperiods[' . $id . '][timeperiodid]', $timeperiod['timeperiodid']);
    }
    $maintenanceForm->addVar('timeperiods[' . $id . '][timeperiod_type]', $timeperiod['timeperiod_type'])->addVar('timeperiods[' . $id . '][every]', $timeperiod['every'])->addVar('timeperiods[' . $id . '][month]', $timeperiod['month'])->addVar('timeperiods[' . $id . '][dayofweek]', $timeperiod['dayofweek'])->addVar('timeperiods[' . $id . '][day]', $timeperiod['day'])->addVar('timeperiods[' . $id . '][start_time]', $timeperiod['start_time'])->addVar('timeperiods[' . $id . '][start_date]', $timeperiod['start_date'])->addVar('timeperiods[' . $id . '][period]', $timeperiod['period']);
}
$periodsDiv = (new CDiv($maintenancePeriodTable))->addClass(ZBX_STYLE_TABLE_FORMS_SEPARATOR)->setAttribute('style', 'min-width: ' . ZBX_TEXTAREA_BIG_WIDTH . 'px;');
if (!isset($_REQUEST['new_timeperiod'])) {
    $periodsDiv->addItem((new CSubmit('new_timeperiod', _('New')))->addClass(ZBX_STYLE_BTN_LINK));
}
$maintenancePeriodFormList->addRow(_('Periods'), $periodsDiv);
if (isset($_REQUEST['new_timeperiod'])) {
    if (is_array($_REQUEST['new_timeperiod']) && isset($_REQUEST['new_timeperiod']['id'])) {
        $saveLabel = _('Update');
    } else {
        $saveLabel = _('Add');
    }
    $maintenancePeriodFormList->addRow(_('Maintenance period'), (new CDiv([get_timeperiod_form(), new CHorList([(new CSubmit('add_timeperiod', $saveLabel))->addClass(ZBX_STYLE_BTN_LINK), (new CSubmit('cancel_new_timeperiod', _('Cancel')))->addClass(ZBX_STYLE_BTN_LINK)])]))->addClass(ZBX_STYLE_TABLE_FORMS_SEPARATOR)->setAttribute('style', 'min-width: ' . ZBX_TEXTAREA_BIG_WIDTH . 'px;'));
}
/*
 * Hosts & groups tab
 */
$hostsAndGroupsFormList = new CFormList('hostsAndGroupsFormList');
$hostTweenBox = new CTweenBox($maintenanceForm, 'hostids', $this->data['hostids'], 10);
foreach ($this->data['hosts'] as $host) {
    $hostTweenBox->addItem($host['hostid'], $host['name']);
}
$groupsComboBox = new CComboBox('twb_groupid', $this->data['twb_groupid'], 'submit()');
foreach ($this->data['all_groups'] as $group) {
    $groupsComboBox->addItem($group['groupid'], $group['name']);
}
$hostTable = (new CTable())->addRow($hostTweenBox->get(_('In maintenance'), [_('Other hosts | Group') . SPACE, $groupsComboBox]));
$hostsAndGroupsFormList->addRow(_('Hosts in maintenance'), $hostTable);
    $maintenanceForm->addVar('timeperiods[' . $id . '][start_date]', $timeperiod['start_date']);
    $maintenanceForm->addVar('timeperiods[' . $id . '][period]', $timeperiod['period']);
}
$periodsDiv = new CDiv($maintenancePeriodTable, 'objectgroup inlineblock border_dotted');
if (!isset($_REQUEST['new_timeperiod'])) {
    $periodsDiv->addItem(new CSubmit('new_timeperiod', _('New'), null, 'link_menu'));
}
$maintenancePeriodFormList->addRow(_('Periods'), $periodsDiv);
if (isset($_REQUEST['new_timeperiod'])) {
    if (is_array($_REQUEST['new_timeperiod']) && isset($_REQUEST['new_timeperiod']['id'])) {
        $saveLabel = _('Save');
    } else {
        $saveLabel = _('Add');
    }
    $footer = array(new CSubmit('add_timeperiod', $saveLabel, null, 'link_menu'), SPACE . SPACE, new CSubmit('cancel_new_timeperiod', _('Cancel'), null, 'link_menu'));
    $maintenancePeriodFormList->addRow(_('Maintenance period'), new CDiv(array(get_timeperiod_form(), $footer), 'objectgroup inlineblock border_dotted'));
}
/*
 * Hosts & groups tab
 */
$hostsAndGroupsFormList = new CFormList('hostsAndGroupsFormList');
$hostTweenBox = new CTweenBox($maintenanceForm, 'hostids', $this->data['hostids'], 10);
foreach ($this->data['hosts'] as $host) {
    $hostTweenBox->addItem($host['hostid'], $host['name']);
}
$groupsComboBox = new CComboBox('twb_groupid', $this->data['twb_groupid'], 'submit()');
foreach ($this->data['all_groups'] as $group) {
    $groupsComboBox->addItem($group['groupid'], $group['name']);
}
$hostTable = new CTable(null, 'formElementTable');
$hostTable->addRow($hostTweenBox->get(_('In maintenance'), array(_('Other hosts | Group') . SPACE, $groupsComboBox)));
    if (isset($timeperiod['timeperiodid'])) {
        $maintenanceForm->addVar('timeperiods[' . $id . '][timeperiodid]', $timeperiod['timeperiodid']);
    }
    $maintenanceForm->addVar('timeperiods[' . $id . '][timeperiod_type]', $timeperiod['timeperiod_type']);
    $maintenanceForm->addVar('timeperiods[' . $id . '][every]', $timeperiod['every']);
    $maintenanceForm->addVar('timeperiods[' . $id . '][month]', $timeperiod['month']);
    $maintenanceForm->addVar('timeperiods[' . $id . '][dayofweek]', $timeperiod['dayofweek']);
    $maintenanceForm->addVar('timeperiods[' . $id . '][day]', $timeperiod['day']);
    $maintenanceForm->addVar('timeperiods[' . $id . '][start_time]', $timeperiod['start_time']);
    $maintenanceForm->addVar('timeperiods[' . $id . '][start_date]', $timeperiod['start_date']);
    $maintenanceForm->addVar('timeperiods[' . $id . '][period]', $timeperiod['period']);
}
$maintenancePeriodFormList->addRow(_('Periods'), array($maintenancePeriodTable, new CSubmit('new_timeperiod', _('New'), null, 'link_menu'), SPACE, SPACE, new CSubmit('del_timeperiod', _('Delete selected'), null, 'link_menu')));
if (isset($_REQUEST['new_timeperiod'])) {
    $label = is_array($_REQUEST['new_timeperiod']) && isset($_REQUEST['new_timeperiod']['id']) ? _('Edit maintenance period') : _('New maintenance period');
    $maintenancePeriodFormList->addRow(SPACE, array(BR(), create_hat($label, get_timeperiod_form(), null, 'hat_new_timeperiod')));
}
/*
 * Hosts & groups tab
 */
$hostsAndGroupsFormList = new CFormList('hostsAndGroupsFormList');
$hostTweenBox = new CTweenBox($maintenanceForm, 'hostids', $this->data['hostids'], 10);
foreach ($this->data['hosts'] as $host) {
    $hostTweenBox->addItem($host['hostid'], $host['name']);
}
$groupsComboBox = new CComboBox('twb_groupid', $this->data['twb_groupid'], 'submit()');
foreach ($this->data['all_groups'] as $group) {
    $groupsComboBox->addItem($group['groupid'], $group['name']);
}
$hostTable = new CTable(null, 'formElementTable');
$hostTable->addRow($hostTweenBox->get(_('In maintenance'), array(_('Other hosts | Group') . SPACE, $groupsComboBox)));