Example #1
0
 public function toString($destroy = true)
 {
     if (!isset($this->attributes['checked'])) {
         foreach ($this->object_name as $obj_name) {
             if (empty($obj_name)) {
                 continue;
             }
             zbx_add_post_js('visibility_status_changeds(false, ' . zbx_jsvalue($obj_name) . ', ' . zbx_jsvalue($this->replace_to) . ');');
         }
     }
     return parent::toString($destroy);
 }
 $graphFormList->addRow(_('Show triggers'), new CCheckBox('show_triggers', $this->data['show_triggers'], null, 1));
 if ($this->data['graphtype'] == GRAPH_TYPE_NORMAL) {
     // percent left
     $percentLeftTextBox = new CTextBox('percent_left', $this->data['percent_left'], 6, false, 7);
     $percentLeftCheckbox = new CCheckBox('visible[percent_left]', 1, 'javascript: showHideVisible("percent_left");', 1);
     if (isset($this->data['visible']) && isset($this->data['visible']['percent_left'])) {
         $percentLeftTextBox->attr('style', '');
         $percentLeftCheckbox->setChecked(1);
     } elseif ($this->data['percent_left'] == 0) {
         $percentLeftTextBox->attr('style', 'visibility: hidden;');
         $percentLeftCheckbox->setChecked(0);
     }
     $graphFormList->addRow(_('Percentile line (left)'), array($percentLeftCheckbox, SPACE, $percentLeftTextBox));
     // percent right
     $percentRightTextBox = new CTextBox('percent_right', $this->data['percent_right'], 6, false, 7);
     $percentRightCheckbox = new CCheckBox('visible[percent_right]', 1, 'javascript: showHideVisible("percent_right");', 1);
     if (isset($this->data['visible']) && isset($this->data['visible']['percent_right'])) {
         $percentRightTextBox->attr('style', '');
         $percentRightCheckbox->setChecked(1);
     } elseif ($this->data['percent_right'] == 0) {
         $percentRightTextBox->attr('style', 'visibility: hidden;');
         $percentRightCheckbox->setChecked(0);
     }
     $graphFormList->addRow(_('Percentile line (right)'), array($percentRightCheckbox, SPACE, $percentRightTextBox));
 }
 $yaxisMinData = array();
 $yTypeComboBox = new CComboBox('ymin_type', $this->data['ymin_type']);
 $yTypeComboBox->addItem(GRAPH_YAXIS_TYPE_CALCULATED, _('Calculated'));
 $yTypeComboBox->addItem(GRAPH_YAXIS_TYPE_FIXED, _('Fixed'));
 $yTypeComboBox->addItem(GRAPH_YAXIS_TYPE_ITEM_VALUE, _('Item'));
 $yaxisMinData[] = $yTypeComboBox;
Example #3
0
 $exp_select = new CComboBox('expr_type');
 $exp_select->setAttribute('id', 'expr_type');
 $exp_select->addItem(REGEXP_INCLUDE, S_INCLUDE_S);
 $exp_select->addItem(REGEXP_EXCLUDE, S_EXCLUDE);
 $ctb = new CTextBox('expression', '', 80);
 $ctb->setAttribute('id', 'logexpr');
 $cb = new CButton('add_exp', S_ADD, 'javascript: add_logexpr();');
 $cb->setType('button');
 $cb->setAttribute('id', 'add_exp');
 $cbAdd = new CButton('add_key_and', S_AND_BIG, 'javascript: add_keyword_and();');
 $cbAdd->setType('button');
 $cbAdd->setAttribute('id', 'add_key_and');
 $cbOr = new CButton('add_key_or', S_OR_BIG, 'javascript: add_keyword_or();');
 $cbOr->setType('button');
 $cbOr->setAttribute('id', 'add_key_or');
 $cbIregexp = new CCheckBox('iregexp', 'no', null, 1);
 $cbIregexp->setAttribute('id', 'iregexp');
 $frmTRLog->addRow(S_EXPRESSION, array($ctb, BR(), $cbIregexp, 'iregexp', SPACE, $cbAdd, SPACE, $cbOr, SPACE, $exp_select, SPACE, $cb));
 $keyTable = new CTableInfo(null);
 $keyTable->setAttribute('id', 'key_list');
 $keyTable->setHeader(array(S_KEYWORD, S_TYPE, S_ACTION));
 $table = new CTableInfo(null);
 $table->setAttribute('id', 'exp_list');
 $table->setHeader(array(S_EXPRESSION, S_TYPE, S_POSITION, S_ACTION));
 $maxid = 0;
 $bExprResult = true;
 $exprData = new CTriggerExpression(array('expression' => empty($expressions) ? '' : construct_expression($itemid, $expressions)));
 if (isset($_REQUEST['triggerid']) && !isset($_REQUEST['save_trigger']) && !empty($exprData->errors) && !isset($_REQUEST['form_refresh'])) {
     info($exprData->errors);
     unset($expressions);
     $expressions[0]['value'] = $expr_incase;
Example #4
0
$ev_select->addItem(EVENTS_OPTION_ALL, S_SHOW_ALL . SPACE . '(' . $config['event_expire'] . SPACE . ($config['event_expire'] > 1 ? S_DAYS : S_DAY) . ')');
if ($config['event_ack_enable']) {
    $ev_select->addItem(EVENTS_OPTION_NOT_ACK, S_SHOW_UNACKNOWLEDGED . SPACE . '(' . $config['event_expire'] . SPACE . ($config['event_expire'] > 1 ? S_DAYS : S_DAY) . ')');
}
$filterForm->addRow(S_EVENTS, $ev_select);
$severity_select = new CComboBox('show_severity', $show_severity);
$cb_items = array(-1 => S_ALL_S, TRIGGER_SEVERITY_NOT_CLASSIFIED => S_NOT_CLASSIFIED, TRIGGER_SEVERITY_INFORMATION => S_INFORMATION, TRIGGER_SEVERITY_WARNING => S_WARNING, TRIGGER_SEVERITY_AVERAGE => S_AVERAGE, TRIGGER_SEVERITY_HIGH => S_HIGH, TRIGGER_SEVERITY_DISASTER => S_DISASTER);
$severity_select->addItems($cb_items);
$filterForm->addRow(S_MIN_SEVERITY, $severity_select);
$action = 'javascrip: this.checked ? $("status_change_days").enable() : $("status_change_days").disable()';
$sts_change_days_cb = new CNumericBox('status_change_days', $_REQUEST['status_change_days'], 4);
if (!$_REQUEST['status_change']) {
    $sts_change_days_cb->setAttribute('disabled', 'disabled');
}
$sts_change_days_cb->addStyle('vertical-align: middle;');
$cbd = new CCheckBox('status_change', $_REQUEST['status_change'], $action, 1);
$cbd->addStyle('vertical-align: middle;');
$spand = new CSpan(S_DAYS_SMALL);
$spand->addStyle('vertical-align: middle;');
$filterForm->addRow(S_AGE_LESS_THAN, array($cbd, $sts_change_days_cb, $spand));
$filterForm->addRow(S_SHOW_DETAILS, new CCheckBox('show_details', $_REQUEST['show_details'], null, 1));
$filterForm->addRow(S_FILTER_BY_NAME, new CTextBox('txt_select', $_REQUEST['txt_select'], 40));
$filterForm->addItemToBottomRow(new CButton('filter_set', S_FILTER));
$filterForm->addItemToBottomRow(new CButton('filter_rst', S_RESET));
$trigg_wdgt->addFlicker($filterForm, CProfile::get('web.tr_status.filter.state', 0));
/*************** FILTER END ******************/
if ($_REQUEST['fullscreen']) {
    $triggerInfo = new CTriggersInfo($_REQUEST['groupid'], $_REQUEST['hostid']);
    $triggerInfo->HideHeader();
    $triggerInfo->show();
}
if (!$overview) {
    $eventsComboBox = new CComboBox('show_events', $filter['showEvents'], null, array(EVENTS_OPTION_NOEVENT => _('Hide all'), EVENTS_OPTION_ALL => _n('Show all (%1$s day)', 'Show all (%1$s days)', $config['event_expire'])));
    if ($config['event_ack_enable']) {
        $eventsComboBox->addItem(EVENTS_OPTION_NOT_ACK, _n('Show unacknowledged (%1$s day)', 'Show unacknowledged (%1$s days)', $config['event_expire']));
    }
    $filterForm->addRow(_('Events'), $eventsComboBox);
}
// min severity
$filterForm->addRow(_('Minimum trigger severity'), new CComboBox('show_severity', $filter['showSeverity'], null, array(TRIGGER_SEVERITY_NOT_CLASSIFIED => getSeverityCaption(TRIGGER_SEVERITY_NOT_CLASSIFIED), TRIGGER_SEVERITY_INFORMATION => getSeverityCaption(TRIGGER_SEVERITY_INFORMATION), TRIGGER_SEVERITY_WARNING => getSeverityCaption(TRIGGER_SEVERITY_WARNING), TRIGGER_SEVERITY_AVERAGE => getSeverityCaption(TRIGGER_SEVERITY_AVERAGE), TRIGGER_SEVERITY_HIGH => getSeverityCaption(TRIGGER_SEVERITY_HIGH), TRIGGER_SEVERITY_DISASTER => getSeverityCaption(TRIGGER_SEVERITY_DISASTER))));
// age less than
$statusChangeDays = new CNumericBox('status_change_days', $filter['statusChangeDays'], 3, false, false, false);
if (!$filter['statusChange']) {
    $statusChangeDays->setAttribute('disabled', 'disabled');
}
$statusChangeDays->addStyle('vertical-align: middle;');
$statusChangeCheckBox = new CCheckBox('status_change', $filter['statusChange'], 'javascript: this.checked ? $("status_change_days").enable() : $("status_change_days").disable()', 1);
$statusChangeCheckBox->addStyle('vertical-align: middle;');
$daysSpan = new CSpan(_('days'));
$daysSpan->addStyle('vertical-align: middle;');
$filterForm->addRow(_('Age less than'), array($statusChangeCheckBox, $statusChangeDays, SPACE, $daysSpan));
// name
$filterForm->addRow(_('Filter by name'), new CTextBox('txt_select', $filter['txtSelect'], 40));
// application
$filterForm->addRow(_('Filter by application'), array(new CTextBox('application', $filter['application'], 40), new CButton('application_name', _('Select'), 'return PopUp("popup.php?srctbl=applications&srcfld1=name&real_hosts=1&dstfld1=application&with_applications=1' . '&dstfrm=' . $filterForm->getName() . '");', 'filter-button')));
// inventory filter
$inventoryFilters = $filter['inventory'];
if (!$inventoryFilters) {
    $inventoryFilters = array(array('field' => '', 'value' => ''));
}
$inventoryFields = array();
foreach (getHostInventories() as $inventory) {
    if (!empty($graph['templateid'])) {
        $realHosts = get_realhosts_by_graphid($graph['templateid']);
        $realHosts = DBfetch($realHosts);
        $name[] = new CLink($realHosts['name'], 'graphs.php?hostid=' . $realHosts['hostid'], 'unknown');
        $name[] = NAME_DELIMITER;
        $name[] = new CLink($graph['name'], 'graphs.php?' . 'form=update' . '&graphid=' . $graphid . url_param('parent_discoveryid') . '&hostid=' . $this->data['hostid']);
        $isCheckboxEnabled = false;
    } elseif (!empty($graph['discoveryRule']) && empty($this->data['parent_discoveryid'])) {
        $name[] = new CLink($graph['discoveryRule']['name'], 'host_discovery.php?form=update&itemid=' . $graph['discoveryRule']['itemid'], 'parent-discovery');
        $name[] = NAME_DELIMITER;
        $name[] = new CSpan($graph['name']);
        $isCheckboxEnabled = false;
    } else {
        $name[] = new CLink($graph['name'], 'graphs.php?' . 'form=update' . '&graphid=' . $graphid . url_param('parent_discoveryid') . '&hostid=' . $this->data['hostid']);
    }
    $checkBox = new CCheckBox('group_graphid[' . $graphid . ']', null, null, $graphid);
    $checkBox->setEnabled($isCheckboxEnabled);
    $graphTable->addRow(array($checkBox, $this->data['displayNodes'] ? $graph['nodename'] : null, $hostList, $name, $graph['width'], $graph['height'], $graph['graphtype']));
}
// create go buttons
$goComboBox = new CComboBox('go');
if (!$this->data['parent_discoveryid']) {
    $goComboBox->addItem('copy_to', _('Copy selected to ...'));
}
$goOption = new CComboItem('delete', _('Delete selected'));
$goOption->setAttribute('confirm', $this->data['parent_discoveryid'] ? _('Delete selected graph prototypes?') : _('Delete selected graphs?'));
$goComboBox->addItem($goOption);
$goButton = new CSubmit('goButton', _('Go') . ' (0)');
$goButton->attr('id', 'goButton');
zbx_add_post_js('chkbxRange.pageGoName = "group_graphid";');
if ($this->data['parent_discoveryid']) {
Example #7
0
         }
         foreach ($graph['templates'] as $template) {
             $host_list[] = $template['host'];
         }
         $host_list = implode(', ', $host_list);
     }
     $name = array();
     if ($graph['templateid'] != 0) {
         $real_hosts = get_realhosts_by_graphid($graph['templateid']);
         $real_host = DBfetch($real_hosts);
         $name[] = new CLink($real_host['host'], 'graphs.php?' . 'hostid=' . $real_host['hostid'], 'unknown');
         $name[] = ':' . $graph['name'];
     } else {
         $name[] = new CLink($graph['name'], 'graphs.php?graphid=' . $graphid . '&form=update');
     }
     $chkBox = new CCheckBox('group_graphid[' . $graphid . ']', NULL, NULL, $graphid);
     if ($graph['templateid'] > 0) {
         $chkBox->setEnabled(false);
     }
     $table->addRow(array($chkBox, $host_list, $name, $graph['width'], $graph['height'], $graph['graphtype']));
 }
 //----- GO ------
 $goBox = new CComboBox('go');
 $goBox->addItem('copy_to', S_COPY_SELECTED_TO);
 $goOption = new CComboItem('delete', S_DELETE_SELECTED);
 $goOption->setAttribute('confirm', S_DELETE_SELECTED_GRAPHS);
 $goBox->addItem($goOption);
 // goButton name is necessary!!!
 $goButton = new CButton('goButton', S_GO);
 $goButton->setAttribute('id', 'goButton');
 zbx_add_post_js('chkbxRange.pageGoName = "group_graphid";');
Example #8
0
 // column "change"
 $digits = $item['value_type'] == ITEM_VALUE_TYPE_FLOAT ? 2 : 0;
 if (isset($lastHistory['value']) && isset($prevHistory['value']) && ($item['value_type'] == ITEM_VALUE_TYPE_FLOAT || $item['value_type'] == ITEM_VALUE_TYPE_UINT64) && bcsub($lastHistory['value'], $prevHistory['value'], $digits) != 0) {
     $change = '';
     if ($lastHistory['value'] - $prevHistory['value'] > 0) {
         $change = '+';
     }
     // for 'unixtime' change should be calculated as uptime
     $change .= convert_units(array('value' => bcsub($lastHistory['value'], $prevHistory['value'], $digits), 'units' => $item['units'] == 'unixtime' ? 'uptime' : $item['units']));
     $change = nbsp($change);
 } else {
     $change = UNKNOWN_VALUE;
 }
 // column "action"
 $showLink = ($config['hk_history_global'] && $config['hk_history'] == 0 || $item['history'] == 0) && ($config['hk_trends_global'] && $config['hk_trends'] == 0 || $item['trends'] == 0);
 $checkbox = new CCheckBox('itemids[' . $item['itemid'] . ']', null, null, $item['itemid']);
 $checkbox->removeAttribute('id');
 if ($item['value_type'] == ITEM_VALUE_TYPE_FLOAT || $item['value_type'] == ITEM_VALUE_TYPE_UINT64) {
     $actions = $showLink ? UNKNOWN_VALUE : new CLink(_('Graph'), 'history.php?action=' . HISTORY_GRAPH . '&itemids[]=' . $item['itemid']);
 } else {
     $actions = $showLink ? UNKNOWN_VALUE : new CLink(_('History'), 'history.php?action=' . HISTORY_VALUES . '&itemids[]=' . $item['itemid']);
     $checkbox->setEnabled(false);
 }
 $stateCss = $item['state'] == ITEM_STATE_NOTSUPPORTED ? 'unknown' : '';
 $host = $hosts[$item['hostid']];
 if ($filter['showDetails']) {
     // item key
     $itemKey = $item['type'] == ITEM_TYPE_HTTPTEST || $item['flags'] == ZBX_FLAG_DISCOVERY_CREATED ? new CSpan($item['key_expanded'], 'enabled') : new CLink($item['key_expanded'], 'items.php?form=update&itemid=' . $item['itemid'], 'enabled');
     // info
     if ($item['status'] == ITEM_STATUS_ACTIVE && $item['error'] !== '') {
         $info = new CDiv(null, 'status_icon iconerror');
Example #9
0
    $cbMissed = null;
    $cbDeleted = null;
    if (isset($rules[$key]['updateExisting'])) {
        $cbExist = new CCheckBox('rules[' . $key . '][updateExisting]', $rules[$key]['updateExisting'], null, 1);
        if ($key == 'images') {
            if (CWebUser::$data['type'] != USER_TYPE_SUPER_ADMIN) {
                continue;
            }
            $cbExist->setAttribute('onclick', 'if (this.checked) return confirm(\'' . _('Images for all maps will be updated!') . '\')');
        }
    }
    if (isset($rules[$key]['createMissing'])) {
        $cbMissed = new CCheckBox('rules[' . $key . '][createMissing]', $rules[$key]['createMissing'], null, 1);
    }
    if (isset($rules[$key]['deleteMissing'])) {
        $cbDeleted = new CCheckBox('rules[' . $key . '][deleteMissing]', $rules[$key]['deleteMissing'], null, 1);
        $cbDeleted->setAttribute('class', 'input checkbox pointer deleteMissing');
    }
    $rulesTable->addRow(array($title, new CCol($cbExist, 'center'), new CCol($cbMissed, 'center'), new CCol($cbDeleted, 'center')));
}
// form list
$importFormList = new CFormList('proxyFormList');
$importFormList->addRow(_('Import file'), new CFile('import_file'));
$importFormList->addRow(_('Rules'), new CDiv($rulesTable, 'border_dotted objectgroup inlineblock'));
// tab
$importTab = new CTabView();
$importTab->addTab('importTab', _('Import'), $importFormList);
// form
$importForm = new CForm('post', null, 'multipart/form-data');
$importForm->addItem($importTab);
$importForm->addItem(makeFormFooter(new CSubmit('import', _('Import')), new CButtonCancel()));
Example #10
0
         array_push($host_list, $db_host['host']);
     }
     $host_list = implode(',', $host_list);
 }
 if ($row['templateid'] == 0) {
     $name = new CLink($row['name'], 'graphs.php?graphid=' . $row['graphid'] . '&form=update', 'action');
 } else {
     $real_hosts = get_realhosts_by_graphid($row['templateid']);
     $real_host = DBfetch($real_hosts);
     if ($real_host) {
         $name = array(new CLink($real_host['host'], 'graphs.php?' . 'hostid=' . $real_host['hostid'], 'action'), ':', $row['name']);
     } else {
         array_push($description, new CSpan('error', 'on'), ':', expand_trigger_description($row['triggerid']));
     }
 }
 $chkBox = new CCheckBox('group_graphid[' . $row['graphid'] . ']', NULL, NULL, $row['graphid']);
 if ($row['templateid'] > 0) {
     $chkBox->SetEnabled(false);
 }
 switch ($row['graphtype']) {
     case GRAPH_TYPE_STACKED:
         $graphtype = S_STACKED;
         break;
     case GRAPH_TYPE_PIE:
         $graphtype = S_PIE;
         break;
     case GRAPH_TYPE_EXPLODED:
         $graphtype = S_EXPLODED;
         break;
     default:
         $graphtype = S_NORMAL;
Example #11
0
function import_map_form($rules)
{
    global $USER_DETAILS;
    $form = new CFormTable(S_IMPORT, null, 'post', 'multipart/form-data');
    $form->addRow(S_IMPORT_FILE, new CFile('import_file'));
    $table = new CTable();
    $table->setHeader(array(S_ELEMENT, S_UPDATE . SPACE . S_EXISTING, S_ADD . SPACE . S_MISSING), 'bold');
    $titles = array('maps' => S_MAP);
    if ($USER_DETAILS['type'] == USER_TYPE_SUPER_ADMIN) {
        $titles += array('icons' => S_ICON, 'background' => S_BACKGROUND);
    }
    foreach ($titles as $key => $title) {
        $cbExist = new CCheckBox('rules[' . $key . '][exist]', isset($rules[$key]['exist']));
        if ($key != 'maps') {
            $cbExist->setAttribute('onclick', 'javascript: if(this.checked) return confirm(\'Images for all maps will be updated\')');
        }
        $cbMissed = new CCheckBox('rules[' . $key . '][missed]', isset($rules[$key]['missed']));
        $table->addRow(array($title, $cbExist, $cbMissed));
    }
    $form->addRow(S_RULES, $table);
    $form->addItemToBottomRow(new CButton('import', S_IMPORT));
    return $form;
}
Example #12
0
    $form->addItem($table);
    $widget->addItem($form)->show();
} elseif ($srctbl == 'host_groups') {
    $form = (new CForm())->setName('hostGroupsform')->setId('hostGroups');
    $table = (new CTableInfo())->setHeader([$multiselect ? (new CColHeader((new CCheckBox('all_hostgroups'))->onClick("javascript: checkAll('" . $form->getName() . "', 'all_hostgroups', 'hostGroups');")))->addClass(ZBX_STYLE_CELL_WIDTH) : null, _('Name')]);
    $options = ['output' => ['groupid', 'name'], 'preservekeys' => true];
    if (!is_null($writeonly)) {
        $options['editable'] = true;
    }
    $hostgroups = API::HostGroup()->get($options);
    order_result($hostgroups, 'name');
    $data = [];
    $parentId = $dstfld1 ? zbx_jsvalue($dstfld1) : 'null';
    foreach ($hostgroups as &$hostgroup) {
        if ($multiselect) {
            $checkBox = new CCheckBox('hostGroups[' . $hostgroup['groupid'] . ']', $hostgroup['groupid']);
        }
        // check for existing
        if (isset($excludeids[$hostgroup['groupid']])) {
            if ($multiselect) {
                $checkBox->setChecked(1);
                $checkBox->setEnabled(false);
            }
            $name = $hostgroup['name'];
        } else {
            $js_action = 'javascript: addValue(' . zbx_jsvalue($reference) . ', ' . zbx_jsvalue($hostgroup['groupid']) . ', ' . $parentId . ');';
            $name = (new CLink($hostgroup['name'], 'javascript:void(0);'))->setId('spanid' . $hostgroup['groupid'])->onClick($js_action . ' jQuery(this).removeAttr("onclick");');
            $data[$hostgroup['groupid']] = ['id' => $hostgroup['groupid'], 'name' => $hostgroup['name']];
        }
        $table->addRow([$multiselect ? $checkBox : null, $name]);
    }
        CArrayHelper::sort($application['sourceTemplates'], ['name']);
        foreach ($application['sourceTemplates'] as $template) {
            $name[] = (new CLink($template['name'], 'applications.php?hostid=' . $template['hostid']))->addClass(ZBX_STYLE_LINK_ALT)->addClass(ZBX_STYLE_GREY);
            $name[] = ', ';
        }
        array_pop($name);
        $name[] = NAME_DELIMITER;
        $name[] = $application['name'];
        $info_icons[] = '';
    } elseif ($application['flags'] == ZBX_FLAG_DISCOVERY_CREATED && $application['discoveryRule']) {
        $name = [(new CLink(CHtml::encode($application['discoveryRule']['name']), 'disc_prototypes.php?parent_discoveryid=' . $application['discoveryRule']['itemid']))->addClass(ZBX_STYLE_LINK_ALT)->addClass(ZBX_STYLE_ORANGE)];
        $name[] = NAME_DELIMITER . $application['name'];
        if ($application['applicationDiscovery']['ts_delete'] != 0) {
            $info_icons[] = getApplicationLifetimeIndicator($current_time, $application['applicationDiscovery']['ts_delete']);
        } else {
            $info_icons[] = '';
        }
    } else {
        $name = new CLink($application['name'], 'applications.php?form=update&applicationid=' . $application['applicationid'] . '&hostid=' . $application['hostid']);
        $info_icons[] = '';
    }
    $checkBox = new CCheckBox('applications[' . $application['applicationid'] . ']', $application['applicationid']);
    $checkBox->setEnabled(!$application['discoveryRule']);
    $applicationTable->addRow([$checkBox, $this->data['hostid'] > 0 ? null : $application['host']['name'], (new CCol($name))->addClass(ZBX_STYLE_NOWRAP), [new CLink(_('Items'), 'items.php?' . 'hostid=' . $application['hostid'] . '&filter_set=1' . '&filter_application=' . urlencode($application['name'])), CViewHelper::showNum(count($application['items']))], $data['showInfoColumn'] ? $info_icons : null]);
}
zbx_add_post_js('cookie.prefix = "' . $this->data['hostid'] . '";');
// append table to form
$form->addItem([$applicationTable, $this->data['paging'], new CActionButtonList('action', 'applications', ['application.massenable' => ['name' => _('Enable'), 'confirm' => _('Enable selected applications?')], 'application.massdisable' => ['name' => _('Disable'), 'confirm' => _('Disable selected applications?')], 'application.massdelete' => ['name' => _('Delete'), 'confirm' => _('Delete selected applications?')]], $this->data['hostid'])]);
// append form to widget
$widget->addItem($form);
return $widget;
        $status = new CLink(triggerIndicator($trigger['status']), 'trigger_prototypes.php?' . 'action=' . ($trigger['status'] == TRIGGER_STATUS_DISABLED ? 'triggerprototype.massenable' : 'triggerprototype.massdisable') . '&hostid=' . $this->data['hostid'] . '&g_triggerid=' . $triggerid . '&parent_discoveryid=' . $this->data['parent_discoveryid'], triggerIndicatorStyle($trigger['status']));
    } else {
        $status = new CLink(triggerIndicator($trigger['status'], $trigger['state']), 'triggers.php?' . 'action=' . ($trigger['status'] == TRIGGER_STATUS_DISABLED ? 'trigger.massenable' : 'trigger.massdisable') . '&hostid=' . $this->data['hostid'] . '&g_triggerid=' . $triggerid, triggerIndicatorStyle($trigger['status'], $trigger['state']));
    }
    // hosts
    $hosts = null;
    if (empty($this->data['hostid'])) {
        foreach ($trigger['hosts'] as $hostid => $host) {
            if (!empty($hosts)) {
                $hosts[] = ', ';
            }
            $hosts[] = $host['name'];
        }
    }
    // checkbox
    $checkBox = new CCheckBox('g_triggerid[' . $triggerid . ']', null, null, $triggerid);
    $checkBox->setEnabled(empty($trigger['discoveryRule']));
    $triggersTable->addRow(array($checkBox, getSeverityCell($trigger['priority']), $hosts, $description, new CCol(triggerExpression($trigger, true), 'trigger-expression'), $status, $info));
}
// create go button
$actionObject = $this->data['parent_discoveryid'] ? 'triggerprototype' : 'trigger';
$goComboBox = new CComboBox('action');
$goOption = new CComboItem($actionObject . '.massenable', _('Enable selected'));
$goOption->setAttribute('confirm', $this->data['parent_discoveryid'] ? _('Enable selected trigger prototypes?') : _('Enable selected triggers?'));
$goComboBox->addItem($goOption);
$goOption = new CComboItem($actionObject . '.massdisable', _('Disable selected'));
$goOption->setAttribute('confirm', $this->data['parent_discoveryid'] ? _('Disable selected trigger prototypes?') : _('Disable selected triggers?'));
$goComboBox->addItem($goOption);
$goOption = new CComboItem($actionObject . '.massupdateform', _('Mass update'));
$goComboBox->addItem($goOption);
if (empty($this->data['parent_discoveryid'])) {
Example #15
0
         // if count new_templates > 0
         unset($new_templates);
     }
 }
 $table = new CTableInfo(S_NO_TEMPLATES_DEFINED);
 $table->SetHeader(array(S_NAME));
 $sql_from = '';
 $sql_where = '';
 if ($groupid > 0) {
     $sql_from .= ',hosts_groups hg ';
     $sql_where .= ' AND hg.groupid=' . $groupid . ' AND h.hostid=hg.hostid ';
 }
 $sql = 'SELECT DISTINCT h.* ' . ' FROM hosts h' . $sql_from . ' WHERE ' . DBin_node('h.hostid', $nodeid) . ' AND ' . DBcondition('h.hostid', $available_hosts) . ' AND h.status=' . HOST_STATUS_TEMPLATE . $sql_where . ' ORDER BY h.host,h.hostid';
 $db_hosts = DBselect($sql);
 while ($host = DBfetch($db_hosts)) {
     $chk = new CCheckBox('templates[' . $host['hostid'] . ']', isset($templates[$host['hostid']]), null, $host['host']);
     $chk->setEnabled(!isset($existed_templates[$host['hostid']]));
     $table->addRow(array(array($chk, $host['host'])));
     unset($host);
 }
 $table->SetFooter(new CButton('select', S_SELECT));
 $form = new CForm();
 $form->addVar('existed_templates', $existed_templates);
 if ($monitored_hosts) {
     $form->addVar('monitored_hosts', 1);
 }
 if ($real_hosts) {
     $form->addVar('real_hosts', 1);
 }
 $form->addVar('dstfrm', $dstfrm);
 $form->addVar('dstfld1', $dstfld1);
    if (in_array($item['value_type'], array(ITEM_VALUE_TYPE_LOG, ITEM_VALUE_TYPE_STR, ITEM_VALUE_TYPE_TEXT))) {
        $triggers = array();
        foreach ($item['triggers'] as $trigger) {
            foreach ($trigger['functions'] as $function) {
                if (!str_in_array($function['function'], array('regexp', 'iregexp'))) {
                    continue 2;
                }
            }
            $triggers[] = array('id' => $trigger['triggerid'], 'name' => $trigger['description']);
        }
        $menuIcon = new CIcon(_('Menu'), 'iconmenu_b');
        $menuIcon->setMenuPopup(CMenuPopupHelper::getTriggerLog($item['itemid'], $item['name'], $triggers));
    } else {
        $menuIcon = SPACE;
    }
    $checkBox = new CCheckBox('group_itemid[' . $item['itemid'] . ']', null, null, $item['itemid']);
    $checkBox->setEnabled(empty($item['discoveryRule']));
    $itemTable->addRow(array($checkBox, $menuIcon, empty($this->data['filter_hostid']) ? $item['host'] : null, $description, $triggerInfo, CHtml::encode($item['key_']), $item['type'] == ITEM_TYPE_TRAPPER || $item['type'] == ITEM_TYPE_SNMPTRAP ? '' : $item['delay'], $item['history'], in_array($item['value_type'], array(ITEM_VALUE_TYPE_STR, ITEM_VALUE_TYPE_LOG, ITEM_VALUE_TYPE_TEXT)) ? '' : $item['trends'], item_type2str($item['type']), new CCol(CHtml::encode($item['applications_list']), 'wraptext'), $status, $infoIcons));
}
// create go buttons
$goComboBox = new CComboBox('action');
$goOption = new CComboItem('item.massenable', _('Enable selected'));
$goOption->setAttribute('confirm', _('Enable selected items?'));
$goComboBox->addItem($goOption);
$goOption = new CComboItem('item.massdisable', _('Disable selected'));
$goOption->setAttribute('confirm', _('Disable selected items?'));
$goComboBox->addItem($goOption);
$goOption = new CComboItem('item.massupdateform', _('Mass update'));
$goComboBox->addItem($goOption);
$goOption = new CComboItem('item.masscopyto', _('Copy selected to ...'));
$goComboBox->addItem($goOption);
Example #17
0
check_fields($fields);
$dstfrm = getRequest('dstfrm', 0);
$permission = getRequest('permission', PERM_DENY);
/*
 * Display
 */
show_table_header(permission2str($permission));
// host groups
$hostGroupForm = new CForm();
$hostGroupForm->setAttribute('id', 'groups');
$hostGroupTable = new CTableInfo(_('No host groups found.'));
$hostGroupTable->setHeader(new CCol(array(new CCheckBox('all_groups', null, 'checkAll(this.checked)'), _('Name'))));
$hostGroups = API::HostGroup()->get(array('output' => array('groupid', 'name')));
order_result($hostGroups, 'name');
foreach ($hostGroups as $hostGroup) {
    $hostGroupCheckBox = new CCheckBox();
    $hostGroupCheckBox->setAttribute('data-id', $hostGroup['groupid']);
    $hostGroupCheckBox->setAttribute('data-name', $hostGroup['name']);
    $hostGroupCheckBox->setAttribute('data-permission', $permission);
    $hostGroupTable->addRow(new CCol(array($hostGroupCheckBox, $hostGroup['name'])));
}
$hostGroupTable->setFooter(new CCol(new CButton('select', _('Select'), 'addGroups("' . $dstfrm . '")'), 'right'));
$hostGroupForm->addItem($hostGroupTable);
$hostGroupForm->show();
?>
<script type="text/javascript">
	function addGroups(formName) {
		var parentDocument = window.opener.document;

		if (!parentDocument) {
			return close_window();
}
$dashconfFormList->addRow(_('Host groups'), $hostGroupsComboBox);
if ($this->data['grpswitch']) {
    $dashconfFormList->addRow(_('Show selected groups'), new CMultiSelect(array('name' => 'groupids[]', 'objectName' => 'hostGroup', 'data' => $this->data['groups'], 'disabled' => !$this->data['isFilterEnable'], 'popup' => array('parameters' => 'srctbl=host_groups&dstfrm=' . $dashconfForm->getName() . '&dstfld1=groupids_' . '&srcfld1=groupid&multiselect=1', 'width' => 450, 'height' => 450))));
    $dashconfFormList->addRow(_('Hide selected groups'), new CMultiSelect(array('name' => 'hidegroupids[]', 'objectName' => 'hostGroup', 'data' => $this->data['hideGroups'], 'disabled' => !$this->data['isFilterEnable'], 'popup' => array('parameters' => 'srctbl=host_groups&dstfrm=' . $dashconfForm->getName() . '&dstfld1=hidegroupids_' . '&srcfld1=groupid&multiselect=1', 'width' => 450, 'height' => 450))));
}
// append host in maintenance checkbox to form list
$maintenanceCheckBox = new CCheckBox('maintenance', $this->data['maintenance'], null, '1');
if (!$this->data['isFilterEnable']) {
    $maintenanceCheckBox->setAttribute('disabled', 'disabled');
}
$dashconfFormList->addRow(_('Hosts'), array($maintenanceCheckBox, _('Show hosts in maintenance')));
// append trigger severities to form list
$severities = array();
foreach ($this->data['severities'] as $severity) {
    $serverityCheckBox = new CCheckBox('trgSeverity[' . $severity . ']', isset($this->data['severity'][$severity]), '', 1);
    $serverityCheckBox->setEnabled($this->data['isFilterEnable']);
    $severities[] = array($serverityCheckBox, getSeverityCaption($severity));
    $severities[] = BR();
}
array_pop($severities);
$dashconfFormList->addRow(_('Triggers with severity'), $severities);
// append problem display to form list
$extAckComboBox = new CComboBox('extAck', $this->data['extAck']);
$extAckComboBox->addItems(array(EXTACK_OPTION_ALL => _('All'), EXTACK_OPTION_BOTH => _('Separated'), EXTACK_OPTION_UNACK => _('Unacknowledged only')));
$extAckComboBox->setEnabled($this->data['isFilterEnable'] && $this->data['config']['event_ack_enable']);
if (!$this->data['config']['event_ack_enable']) {
    $extAckComboBox->setAttribute('title', _('Event acknowledging disabled'));
}
$dashconfFormList->addRow(_('Problem display'), $extAckComboBox);
// create tab
Example #19
0
 $table = new CTableInfo(_('No host groups found.'));
 $table->setHeader(array($multiselect ? new CCheckBox('allHostGroups', null, "javascript: checkAll('" . $form->getName() . "', 'allHostGroups', 'hostGroups');") : null, _('Name')));
 $options = array('nodeids' => $nodeId, 'output' => array('groupid', 'name'), 'preservekeys' => true);
 if (!is_null($writeonly)) {
     $options['editable'] = true;
 }
 $hostgroups = API::HostGroup()->get($options);
 order_result($hostgroups, 'name');
 $data = array();
 $parentId = $dstfld1 ? zbx_jsvalue($dstfld1) : 'null';
 foreach ($hostgroups as &$hostgroup) {
     $name = new CSpan($hostgroup['name'], 'link');
     $name->attr('id', 'spanid' . $hostgroup['groupid']);
     $jsAction = 'javascript: addValue(' . zbx_jsvalue($reference) . ', ' . zbx_jsvalue($hostgroup['groupid']) . ', ' . $parentId . ');';
     if ($multiselect) {
         $checkBox = new CCheckBox('hostGroups[' . zbx_jsValue('groupid') . ']', null, null, $hostgroup['groupid']);
     }
     // check for existing
     if (isset($excludeids[$hostgroup['groupid']])) {
         if ($multiselect) {
             $checkBox->setChecked(1);
             $checkBox->setEnabled('disabled');
         }
         $name->removeAttr('class');
     } else {
         $name->setAttribute('onclick', $jsAction . ' jQuery(this).removeAttr("onclick");');
         $data[$hostgroup['groupid']] = array('id' => $hostgroup['groupid'], 'name' => $hostgroup['name'], 'prefix' => get_node_name_by_elid($hostgroup['groupid'], null, NAME_DELIMITER));
     }
     $table->addRow(array($multiselect ? $checkBox : null, $name));
 }
 unset($hostgroup);
Example #20
0
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
**/
$rulesTable = new CTable(null, 'formElementTable');
$rulesTable->setHeader(array(SPACE, _('Update existing'), _('Add missing')), 'bold');
$titles = array('groups' => _('Groups'), 'hosts' => _('Hosts'), 'templates' => _('Templates'), 'templateScreens' => _('Template screens'), 'templateLinkage' => _('Template linkage'), 'items' => _('Items'), 'discoveryRules' => _('Discovery rules'), 'triggers' => _('Triggers'), 'graphs' => _('Graphs'), 'screens' => _('Screens'), 'maps' => _('Maps'), 'images' => _('Images'));
$rules = $this->get('rules');
foreach ($titles as $key => $title) {
    $cbExist = $cbMissed = SPACE;
    if (isset($rules[$key]['updateExisting'])) {
        $cbExist = new CCheckBox('rules[' . $key . '][updateExisting]', $rules[$key]['updateExisting'], null, 1);
        if ($key == 'images') {
            if (CWebUser::$data['type'] != USER_TYPE_SUPER_ADMIN) {
                continue;
            }
            $cbExist->setAttribute('onclick', 'if (this.checked) return confirm(\'' . _('Images for all maps will be updated!') . '\')');
        }
    }
    if (isset($rules[$key]['createMissing'])) {
        $cbMissed = new CCheckBox('rules[' . $key . '][createMissing]', $rules[$key]['createMissing'], null, 1);
    }
    $rulesTable->addRow(array($title, new CCol($cbExist, 'center'), new CCol($cbMissed, 'center')));
}
// form list
$importFormList = new CFormList('proxyFormList');
$importFormList->addRow(_('Import file'), new CFile('import_file'));
Example #21
0
$filterForm->AddOption('id', 'zbx_filter');
$filterForm->SetMethod('get');
$filterForm->AddVar('nav_time', $_REQUEST['nav_time']);
if (EVENT_SOURCE_TRIGGERS == $source) {
    $script = new CScript("javascript: if(CLNDR['events_since'].clndr.setSDateFromOuterObj()){" . "\$('filter_timesince').value = parseInt(CLNDR['events_since'].clndr.sdt.getTime()/1000);}" . "if(CLNDR['events_till'].clndr.setSDateFromOuterObj()){" . "\$('filter_timetill').value = parseInt(CLNDR['events_till'].clndr.sdt.getTime()/1000);}");
    $filterForm->AddAction('onsubmit', $script);
    $filterForm->AddVar('triggerid', $_REQUEST['triggerid']);
    if (isset($_REQUEST['triggerid']) && $_REQUEST['triggerid'] > 0) {
        $trigger = expand_trigger_description($_REQUEST['triggerid']);
    } else {
        $trigger = "";
    }
    $row = new CRow(array(new CCol(S_TRIGGER, 'form_row_l'), new CCol(array(new CTextBox("trigger", $trigger, 96, 'yes'), new CButton("btn1", S_SELECT, "return PopUp('popup.php?" . "dstfrm=" . $filterForm->GetName() . "&dstfld1=triggerid&dstfld2=trigger" . "&srctbl=triggers&srcfld1=triggerid&srcfld2=description&real_hosts=1');", 'T')), 'form_row_r')));
    $filterForm->AddRow($row);
    $filterForm->AddVar('show_unknown', $show_unknown);
    $unkcbx = new CCheckBox('show_unk', $show_unknown, null, '1');
    $unkcbx->SetAction('javascript: create_var("' . $filterForm->GetName() . '", "show_unknown", (this.checked?1:0), 0); ');
    $filterForm->AddRow(S_SHOW_UNKNOWN, $unkcbx);
    $reset = new CButton("filter_rst", S_RESET);
    $reset->SetType('button');
    $reset->SetAction('javascript: var uri = new Curl(location.href); uri.setArgument("filter_rst",1); location.href = uri.getUrl();');
    $filterForm->AddItemToBottomRow(new CButton("filter_set", S_FILTER));
    $filterForm->AddItemToBottomRow($reset);
    $p_elements[] = create_filter(S_FILTER, $navigation, $filterForm, 'tr_filter', get_profile('web.events.filter.state', 0));
} else {
    $p_elements[] = get_thin_table_header(SPACE, $navigation);
}
//-------
$p_elements[] = $table;
$p_elements[] = get_thin_table_header(SPACE, $navigation);
$events_hat = create_hat($text, $p_elements, $fs_icon, 'hat_events', get_profile('web.events.hats.hat_events.state', 1));
 }
 // append data type to form list
 if ($this->data['limited']) {
     $itemForm->addVar('data_type', $this->data['data_type']);
     $dataType = new CTextBox('data_type_name', item_data_type2str($this->data['data_type']), ZBX_TEXTBOX_SMALL_SIZE, 'yes');
 } else {
     $dataType = new CComboBox('data_type', $this->data['data_type']);
     $dataType->addItems(item_data_type2str());
 }
 $itemFormList->addRow(_('Data type'), $dataType, false, 'row_data_type');
 $itemFormList->addRow(_('Units'), new CTextBox('units', $this->data['units'], ZBX_TEXTBOX_STANDARD_SIZE, $this->data['limited']), false, 'row_units');
 // append multiplier to form list
 $multiplier = array();
 if ($this->data['limited']) {
     $itemForm->addVar('multiplier', $this->data['multiplier']);
     $multiplierCheckBox = new CCheckBox('multiplier', $this->data['multiplier'] == 1 ? 'yes' : 'no');
     $multiplierCheckBox->setAttribute('disabled', 'disabled');
     $multiplier[] = $multiplierCheckBox;
     $multiplier[] = SPACE;
     $formulaTextBox = new CTextBox('formula', $this->data['formula'], ZBX_TEXTBOX_SMALL_SIZE, 1);
     $formulaTextBox->setAttribute('style', 'text-align: right;');
     $multiplier[] = $formulaTextBox;
 } else {
     $multiplierCheckBox = new CCheckBox('multiplier', $this->data['multiplier'] == 1 ? 'yes' : 'no', 'var editbx = document.getElementById(\'formula\'); if (editbx) { editbx.disabled = !this.checked; }', 1);
     $multiplier[] = $multiplierCheckBox;
     $multiplier[] = SPACE;
     $formulaTextBox = new CTextBox('formula', $this->data['formula'], ZBX_TEXTBOX_SMALL_SIZE);
     $formulaTextBox->setAttribute('style', 'text-align: right;');
     $multiplier[] = $formulaTextBox;
 }
 $itemFormList->addRow(_('Use custom multiplier'), $multiplier, false, 'row_multiplier');
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
**/
include dirname(__FILE__) . '/js/configuration.services.child.list.js.php';
$servicesChildWidget = new CWidget();
$servicesChildWidget->addPageHeader(_('IT service dependencies'));
// create form
$servicesChildForm = new CForm();
$servicesChildForm->setName('servicesForm');
if (!empty($this->data['service'])) {
    $servicesChildForm->addVar('serviceid', $this->data['service']['serviceid']);
}
// create table
$servicesChildTable = new CTableInfo(_('No IT services found.'));
$servicesChildTable->setHeader(array(new CCheckBox('all_services', null, "javascript: checkAll('" . $servicesChildForm->getName() . "', 'all_services', 'services');"), _('Service'), _('Status calculation'), _('Trigger')));
$prefix = null;
foreach ($this->data['db_cservices'] as $service) {
    $description = new CLink($service['name'], '#', 'service-name');
    $description->setAttributes(array('id' => 'service-name-' . $service['serviceid'], 'data-name' => $service['name'], 'data-serviceid' => $service['serviceid'], 'data-trigger' => $service['trigger']));
    $cb = new CCheckBox('services[' . $service['serviceid'] . ']', null, null, $service['serviceid']);
    $cb->addClass('service-select');
    $servicesChildTable->addRow(array($cb, array($prefix, $description), serviceAlgorythm($service['algorithm']), $service['trigger']));
}
$servicesChildTable->setFooter(new CCol(new CButton('select', _('Select')), 'right'));
// append table to form
$servicesChildForm->addItem($servicesChildTable);
// append form to widget
$servicesChildWidget->addItem($servicesChildForm);
return $servicesChildWidget;
Example #24
0
    $filterForm = new CFormTable(null, null, 'get');
    //,'events.php?filter_set=1','POST',null,'sform');
    $filterForm->setAttribute('name', 'zbx_filter');
    $filterForm->setAttribute('id', 'zbx_filter');
    $filterForm->addVar('triggerid', get_request('triggerid'));
    $filterForm->addVar('stime', get_request('stime'));
    $filterForm->addVar('period', get_request('period'));
    if (isset($_REQUEST['triggerid']) && $_REQUEST['triggerid'] > 0) {
        $trigger = expand_trigger_description($_REQUEST['triggerid']);
    } else {
        $trigger = '';
    }
    $row = new CRow(array(new CCol(S_TRIGGER, 'form_row_l'), new CCol(array(new CTextBox('trigger', $trigger, 96, 'yes'), new CButton("btn1", S_SELECT, "return PopUp('popup.php?" . "dstfrm=" . $filterForm->getName() . "&dstfld1=triggerid&dstfld2=trigger" . "&srctbl=triggers&srcfld1=triggerid&srcfld2=description&real_hosts=1');", 'T')), 'form_row_r')));
    $filterForm->addRow($row);
    $filterForm->addVar('hide_unknown', $_REQUEST['hide_unknown']);
    $unkcbx = new CCheckBox('hide_unk', $_REQUEST['hide_unknown'], null, '1');
    $unkcbx->setAction('javascript: create_var("' . $filterForm->GetName() . '", "hide_unknown", (this.checked?1:0), 0); ');
    $filterForm->addRow(S_HIDE_UNKNOWN, $unkcbx);
    $reset = new CButton('filter_rst', S_RESET);
    $reset->setType('button');
    $reset->setAction('javascript: var uri = new Curl(location.href); uri.setArgument("filter_rst",1); location.href = uri.getUrl();');
    $filterForm->addItemToBottomRow(new CButton('filter_set', S_FILTER));
    $filterForm->addItemToBottomRow($reset);
}
$events_wdgt->addFlicker($filterForm, CProfile::get('web.events.filter.state', 0));
$scroll_div = new CDiv();
$scroll_div->setAttribute('id', 'scrollbar_cntr');
$events_wdgt->addFlicker($scroll_div, CProfile::get('web.events.filter.state', 0));
// }}} FILTER
$table = new CTableInfo(S_NO_EVENTS_FOUND);
// CHECK IF EVENTS EXISTS {{{
Example #25
0
function insert_graph_form()
{
    $frmGraph = new CFormTable(S_GRAPH, null, 'post');
    $frmGraph->SetName('frm_graph');
    $frmGraph->SetHelp("web.graphs.graph.php");
    $frmGraph->SetMethod('post');
    $items = get_request('items', array());
    if (isset($_REQUEST['graphid'])) {
        $frmGraph->addVar('graphid', $_REQUEST['graphid']);
        $result = DBselect('SELECT * FROM graphs WHERE graphid=' . $_REQUEST['graphid']);
        $row = DBfetch($result);
        $frmGraph->SetTitle(S_GRAPH . ' "' . $row['name'] . '"');
    }
    if (isset($_REQUEST['graphid']) && !isset($_REQUEST['form_refresh'])) {
        $name = $row['name'];
        $width = $row['width'];
        $height = $row['height'];
        $ymin_type = $row["ymin_type"];
        $ymax_type = $row["ymax_type"];
        $yaxismin = $row['yaxismin'];
        $yaxismax = $row['yaxismax'];
        $ymin_itemid = $row["ymin_itemid"];
        $ymax_itemid = $row["ymax_itemid"];
        $showworkperiod = $row['show_work_period'];
        $showtriggers = $row['show_triggers'];
        $graphtype = $row['graphtype'];
        $legend = $row['show_legend'];
        $graph3d = $row['show_3d'];
        $percent_left = $row['percent_left'];
        $percent_right = $row['percent_right'];
        $db_items = DBselect('SELECT * FROM graphs_items WHERE graphid=' . $_REQUEST['graphid']);
        while ($item = DBfetch($db_items)) {
            array_push($items, array('itemid' => $item['itemid'], 'drawtype' => $item['drawtype'], 'sortorder' => $item['sortorder'], 'color' => $item['color'], 'yaxisside' => $item['yaxisside'], 'calc_fnc' => $item['calc_fnc'], 'type' => $item['type'], 'periods_cnt' => $item['periods_cnt']));
        }
    } else {
        $name = get_request('name', '');
        $graphtype = get_request('graphtype', GRAPH_TYPE_NORMAL);
        if ($graphtype == GRAPH_TYPE_PIE || $graphtype == GRAPH_TYPE_EXPLODED) {
            $width = get_request('width', 400);
            $height = get_request('height', 300);
        } else {
            $width = get_request('width', 900);
            $height = get_request('height', 200);
        }
        $ymin_type = get_request("ymin_type", GRAPH_YAXIS_TYPE_CALCULATED);
        $ymax_type = get_request("ymax_type", GRAPH_YAXIS_TYPE_CALCULATED);
        $yaxismin = get_request("yaxismin", 0.0);
        $yaxismax = get_request("yaxismax", 100.0);
        $ymin_itemid = get_request("ymin_itemid", 0);
        $ymax_itemid = get_request("ymax_itemid", 0);
        $showworkperiod = get_request('showworkperiod', 0);
        $showtriggers = get_request('showtriggers', 0);
        $legend = get_request('legend', 0);
        $graph3d = get_request('graph3d', 0);
        $visible = get_request('visible');
        $percent_left = 0;
        $percent_right = 0;
        if (isset($visible['percent_left'])) {
            $percent_left = get_request('percent_left', 0);
        }
        if (isset($visible['percent_right'])) {
            $percent_right = get_request('percent_right', 0);
        }
    }
    /* reinit $_REQUEST */
    $_REQUEST['items'] = $items;
    $_REQUEST['name'] = $name;
    $_REQUEST['width'] = $width;
    $_REQUEST['height'] = $height;
    $_REQUEST['ymin_type'] = $ymin_type;
    $_REQUEST['ymax_type'] = $ymax_type;
    $_REQUEST['yaxismin'] = $yaxismin;
    $_REQUEST['yaxismax'] = $yaxismax;
    $_REQUEST['ymin_itemid'] = $ymin_itemid;
    $_REQUEST['ymax_itemid'] = $ymax_itemid;
    $_REQUEST['showworkperiod'] = $showworkperiod;
    $_REQUEST['showtriggers'] = $showtriggers;
    $_REQUEST['graphtype'] = $graphtype;
    $_REQUEST['legend'] = $legend;
    $_REQUEST['graph3d'] = $graph3d;
    $_REQUEST['percent_left'] = $percent_left;
    $_REQUEST['percent_right'] = $percent_right;
    /********************/
    if ($graphtype != GRAPH_TYPE_NORMAL) {
        foreach ($items as $gid => $gitem) {
            if ($gitem['type'] != GRAPH_ITEM_AGGREGATED) {
                continue;
            }
            unset($items[$gid]);
        }
    }
    asort_by_key($items, 'sortorder');
    $group_gid = get_request('group_gid', array());
    $frmGraph->addVar('ymin_itemid', $ymin_itemid);
    $frmGraph->addVar('ymax_itemid', $ymax_itemid);
    $frmGraph->addRow(S_NAME, new CTextBox('name', $name, 32));
    $g_width = new CNumericBox('width', $width, 5);
    $g_width->addoption('onblur', 'javascript: submit();');
    $frmGraph->addRow(S_WIDTH, $g_width);
    $g_height = new CNumericBox('height', $height, 5);
    $g_height->addoption('onblur', 'javascript: submit();');
    $frmGraph->addRow(S_HEIGHT, $g_height);
    $cmbGType = new CComboBox('graphtype', $graphtype, 'graphs.submit(this)');
    $cmbGType->addItem(GRAPH_TYPE_NORMAL, S_NORMAL);
    $cmbGType->addItem(GRAPH_TYPE_STACKED, S_STACKED);
    $cmbGType->addItem(GRAPH_TYPE_PIE, S_PIE);
    $cmbGType->addItem(GRAPH_TYPE_EXPLODED, S_EXPLODED);
    zbx_add_post_js('graphs.graphtype = ' . $graphtype . ";\n");
    $frmGraph->addRow(S_GRAPH_TYPE, $cmbGType);
    if ($graphtype == GRAPH_TYPE_NORMAL || $graphtype == GRAPH_TYPE_STACKED) {
        $frmGraph->addRow(S_SHOW_WORKING_TIME, new CCheckBox('showworkperiod', $showworkperiod, null, 1));
        $frmGraph->addRow(S_SHOW_TRIGGERS, new CCheckBox('showtriggers', $showtriggers, null, 1));
        if ($graphtype == GRAPH_TYPE_NORMAL) {
            $percent_left = sprintf("%2.2f", $percent_left);
            $percent_right = sprintf("%2.2f", $percent_right);
            $pr_left_input = new CTextBox('percent_left', $percent_left, '5');
            $pr_left_chkbx = new CCheckBox('visible[percent_left]', 1, "javascript: ShowHide('percent_left');", 1);
            if ($percent_left == 0) {
                $pr_left_input->addOption('style', 'display: none;');
                $pr_left_chkbx->SetChecked(0);
            }
            $pr_right_input = new CTextBox('percent_right', $percent_right, '5');
            $pr_right_chkbx = new CCheckBox('visible[percent_right]', 1, "javascript: ShowHide('percent_right');", 1);
            if ($percent_right == 0) {
                $pr_right_input->addOption('style', 'display: none;');
                $pr_right_chkbx->SetChecked(0);
            }
            $frmGraph->addRow(S_PERCENTILE_LINE . ' (' . S_LEFT . ')', array($pr_left_chkbx, $pr_left_input));
            $frmGraph->addRow(S_PERCENTILE_LINE . ' (' . S_RIGHT . ')', array($pr_right_chkbx, $pr_right_input));
        }
        $yaxis_min = array();
        $cmbYType = new CComboBox('ymin_type', $ymin_type, 'javascript: submit();');
        $cmbYType->addItem(GRAPH_YAXIS_TYPE_CALCULATED, S_CALCULATED);
        $cmbYType->addItem(GRAPH_YAXIS_TYPE_FIXED, S_FIXED);
        $cmbYType->addItem(GRAPH_YAXIS_TYPE_ITEM_VALUE, S_ITEM);
        $yaxis_min[] = $cmbYType;
        if ($ymin_type == GRAPH_YAXIS_TYPE_FIXED) {
            $yaxis_min[] = new CTextBox("yaxismin", $yaxismin, 9);
        } else {
            if ($ymin_type == GRAPH_YAXIS_TYPE_ITEM_VALUE) {
                $frmGraph->addVar('yaxismin', $yaxismin);
                $ymin_name = '';
                if ($ymin_itemid > 0) {
                    $min_host = get_host_by_itemid($ymin_itemid);
                    $min_item = get_item_by_itemid($ymin_itemid);
                    $ymin_name = $min_host['host'] . ':' . item_description($min_item);
                }
                $yaxis_min[] = new CTextBox("ymin_name", $ymin_name, 80, 'yes');
                $yaxis_min[] = new CButton('yaxis_min', S_SELECT, 'javascript: ' . "return PopUp('popup.php?dstfrm=" . $frmGraph->getName() . "&dstfld1=ymin_itemid" . "&dstfld2=ymin_name" . "&srctbl=items" . "&srcfld1=itemid" . "&srcfld2=description',0,0,'zbx_popup_item');");
            } else {
                $frmGraph->addVar('yaxismin', $yaxismin);
            }
        }
        $frmGraph->addRow(S_YAXIS_MIN_VALUE, $yaxis_min);
        $yaxis_max = array();
        $cmbYType = new CComboBox("ymax_type", $ymax_type, "submit()");
        $cmbYType->addItem(GRAPH_YAXIS_TYPE_CALCULATED, S_CALCULATED);
        $cmbYType->addItem(GRAPH_YAXIS_TYPE_FIXED, S_FIXED);
        $cmbYType->addItem(GRAPH_YAXIS_TYPE_ITEM_VALUE, S_ITEM);
        $yaxis_max[] = $cmbYType;
        if ($ymax_type == GRAPH_YAXIS_TYPE_FIXED) {
            $yaxis_max[] = new CTextBox("yaxismax", $yaxismax, 9);
        } else {
            if ($ymax_type == GRAPH_YAXIS_TYPE_ITEM_VALUE) {
                $frmGraph->addVar('yaxismax', $yaxismax);
                $ymax_name = '';
                if ($ymax_itemid > 0) {
                    $max_host = get_host_by_itemid($ymax_itemid);
                    $max_item = get_item_by_itemid($ymax_itemid);
                    $ymax_name = $max_host['host'] . ':' . item_description($max_item);
                }
                $yaxis_max[] = new CTextBox("ymax_name", $ymax_name, 80, 'yes');
                $yaxis_max[] = new CButton('yaxis_max', S_SELECT, 'javascript: ' . "return PopUp('popup.php?dstfrm=" . $frmGraph->getName() . "&dstfld1=ymax_itemid" . "&dstfld2=ymax_name" . "&srctbl=items" . "&srcfld1=itemid" . "&srcfld2=description',0,0,'zbx_popup_item');");
            } else {
                $frmGraph->addVar('yaxismax', $yaxismax);
            }
        }
        $frmGraph->addRow(S_YAXIS_MAX_VALUE, $yaxis_max);
    } else {
        $frmGraph->addRow(S_3D_VIEW, new CCheckBox('graph3d', $graph3d, 'javascript: graphs.submit(this);', 1));
        $frmGraph->addRow(S_LEGEND, new CCheckBox('legend', $legend, 'javascript: graphs.submit(this);', 1));
    }
    $only_hostid = null;
    $monitored_hosts = null;
    if (count($items)) {
        $frmGraph->addVar('items', $items);
        $items_table = new CTableInfo();
        foreach ($items as $gid => $gitem) {
            if ($graphtype == GRAPH_TYPE_STACKED && $gitem['type'] == GRAPH_ITEM_AGGREGATED) {
                continue;
            }
            $host = get_host_by_itemid($gitem['itemid']);
            $item = get_item_by_itemid($gitem['itemid']);
            if ($host['status'] == HOST_STATUS_TEMPLATE) {
                $only_hostid = $host['hostid'];
            } else {
                $monitored_hosts = 1;
            }
            if ($gitem['type'] == GRAPH_ITEM_AGGREGATED) {
                $color = '-';
            } else {
                $color = new CColorCell(null, $gitem['color']);
            }
            $do_up = new CLink(S_UP, '#', 'action');
            $do_up->OnClick("return create_var('" . $frmGraph->GetName() . "','move_up'," . $gid . ", true);");
            $do_down = new CLink(S_DOWN, '#', 'action');
            $do_down->OnClick("return create_var('" . $frmGraph->GetName() . "','move_down'," . $gid . ", true);");
            $description = new CLink($host['host'] . ': ' . item_description($item), '#', 'action');
            $description->OnClick('return PopUp("popup_gitem.php?list_name=items&dstfrm=' . $frmGraph->GetName() . url_param($only_hostid, false, 'only_hostid') . url_param($monitored_hosts, false, 'monitored_hosts') . url_param($graphtype, false, 'graphtype') . url_param($gitem, false) . url_param($gid, false, 'gid') . url_param(get_request('graphid', 0), false, 'graphid') . '",550,400,"graph_item_form");');
            if ($graphtype == GRAPH_TYPE_PIE || $graphtype == GRAPH_TYPE_EXPLODED) {
                $items_table->addRow(array(new CCheckBox('group_gid[' . $gid . ']', isset($group_gid[$gid])), $gitem['sortorder'], $description, graph_item_calc_fnc2str($gitem["calc_fnc"], $gitem["type"]), graph_item_type2str($gitem['type'], $gitem["periods_cnt"]), $color, array($do_up, SPACE . "|" . SPACE, $do_down)));
            } else {
                $items_table->addRow(array(new CCheckBox('group_gid[' . $gid . ']', isset($group_gid[$gid])), $gitem['sortorder'], $description, graph_item_calc_fnc2str($gitem["calc_fnc"], $gitem["type"]), graph_item_type2str($gitem['type'], $gitem["periods_cnt"]), graph_item_drawtype2str($gitem["drawtype"], $gitem["type"]), $color, array($do_up, SPACE . "|" . SPACE, $do_down)));
            }
        }
        $dedlete_button = new CButton('delete_item', S_DELETE_SELECTED);
    } else {
        $items_table = $dedlete_button = null;
    }
    $frmGraph->addRow(S_ITEMS, array($items_table, new CButton('add_item', S_ADD, "return PopUp('popup_gitem.php?dstfrm=" . $frmGraph->GetName() . url_param($only_hostid, false, 'only_hostid') . url_param($monitored_hosts, false, 'monitored_hosts') . url_param($graphtype, false, 'graphtype') . "',550,400,'graph_item_form');"), $dedlete_button));
    unset($items_table, $dedlete_button);
    $frmGraph->addItemToBottomRow(new CButton("save", S_SAVE));
    if (isset($_REQUEST["graphid"])) {
        $frmGraph->addItemToBottomRow(SPACE);
        $frmGraph->addItemToBottomRow(new CButton("clone", S_CLONE));
        $frmGraph->addItemToBottomRow(SPACE);
        $frmGraph->addItemToBottomRow(new CButtonDelete(S_DELETE_GRAPH_Q, url_param("graphid") . url_param('groupid') . url_param("hostid")));
    }
    $frmGraph->addItemToBottomRow(SPACE);
    $frmGraph->addItemToBottomRow(new CButtonCancel(url_param('groupid') . url_param("hostid")));
    $frmGraph->Show();
}
Example #26
0
    if (!$filterEnable) {
        $lstGroups->setAttribute('disabled', 'disabled');
    }
    $addButton = new CButton('add', S_ADD, "return PopUp('popup_right.php?dstfrm=" . $dashForm->getName() . "&permission=" . PERM_READ_WRITE . "',450,450);");
    if (!$filterEnable) {
        $addButton->setAttribute('disabled', 'disabled');
    }
    $delButton = new CButton('delete', S_DELETE_SELECTED);
    if (!$filterEnable) {
        $delButton->setAttribute('disabled', 'disabled');
    }
    $dashForm->addRow(S_GROUPS, array($lstGroups, BR(), $addButton, $delButton));
}
//HOSTS
// SPACE added to extend CB width in Chrome
$cbMain = new CCheckBox('maintenance', $maintenance, null, '1');
if (!$filterEnable) {
    $cbMain->setAttribute('disabled', 'disabled');
}
$dashForm->addRow(S_HOSTS, array($cbMain, S_SHOW_HOSTS_IN_MAINTENANCE));
// Trigger
$severity = zbx_toHash($severity);
$trgSeverities = array();
$severities = array(TRIGGER_SEVERITY_NOT_CLASSIFIED, TRIGGER_SEVERITY_INFORMATION, TRIGGER_SEVERITY_WARNING, TRIGGER_SEVERITY_AVERAGE, TRIGGER_SEVERITY_HIGH, TRIGGER_SEVERITY_DISASTER);
foreach ($severities as $snum => $sever) {
    $cb = new CCheckBox('trgSeverity[' . $sever . ']', isset($severity[$sever]), '', 1);
    $cb->setEnabled($filterEnable);
    $trgSeverities[] = array($cb, getSeverityCaption($sever));
    $trgSeverities[] = BR();
}
array_pop($trgSeverities);
    $itemFormList->addRow(_('Data type'), $dataType, false, 'row_data_type');
    $itemFormList->addRow(_('Units'), new CTextBox('units', $this->data['units'], ZBX_TEXTBOX_STANDARD_SIZE, $this->data['limited']), false, 'row_units');
    // append multiplier to form list
    $multiplier = array();
    if ($this->data['limited']) {
        $itemForm->addVar('multiplier', $this->data['multiplier']);
        $multiplierCheckBox = new CCheckBox('multiplier', $this->data['multiplier'] == 1 ? 'yes' : 'no');
        $multiplierCheckBox->setAttribute('disabled', 'disabled');
        $multiplierCheckBox->setAttribute('style', 'vertical-align: middle;');
        $multiplier[] = $multiplierCheckBox;
        $multiplier[] = SPACE;
        $formulaTextBox = new CTextBox('formula', $this->data['formula'], ZBX_TEXTBOX_SMALL_SIZE, 1);
        $formulaTextBox->setAttribute('style', 'text-align: right;');
        $multiplier[] = $formulaTextBox;
    } else {
        $multiplierCheckBox = new CCheckBox('multiplier', $this->data['multiplier'] == 1 ? 'yes' : 'no', 'var editbx = document.getElementById(\'formula\'); if (editbx) { editbx.disabled = !this.checked; }', 1);
        $multiplierCheckBox->setAttribute('style', 'vertical-align: middle;');
        $multiplier[] = $multiplierCheckBox;
        $multiplier[] = SPACE;
        $formulaTextBox = new CTextBox('formula', $this->data['formula'], ZBX_TEXTBOX_SMALL_SIZE);
        $formulaTextBox->setAttribute('style', 'text-align: right;');
        $multiplier[] = $formulaTextBox;
    }
    $itemFormList->addRow(_('Use custom multiplier'), $multiplier, false, 'row_multiplier');
}
$itemFormList->addRow(_('Update interval (in sec)'), new CNumericBox('delay', $this->data['delay'], 5), false, 'row_delay');
// append delay flex to form list
$delayFlexTable = new CTable(_('No flexible intervals defined.'), 'formElementTable');
$delayFlexTable->setAttribute('style', 'min-width: 310px;');
$delayFlexTable->setAttribute('id', 'delayFlexTable');
$delayFlexTable->setHeader(array(_('Interval'), _('Period'), _('Action')));