public function __construct($url = 'index.php', $side = null) { if (is_null($side)) { $side = 'right'; } if ($side == 'right') { $pside = 'left'; } else { $side = 'left'; $pside = 'right'; } parent::__construct(new CDiv(SPACE, 'iconhelp'), 'http://www.zabbix.com/documentation.php'); //'http://www.zabbix.com/manual/v1.1/'.$url); parent::onClick('window.open("http://www.zabbix.com/documentation.php");'); $this->attributes['style'] = 'padding-' . $pside . ': 5px; float:' . $side . ';text-decoration: none;'; $this->attributes['target'] = '_blank'; }
function bar_report_form2() { global $USER_DETAILS; $config = get_request('config', 1); $title = get_request('title', S_REPORT . ' 2'); $xlabel = get_request('xlabel', ''); $ylabel = get_request('ylabel', ''); $sorttype = get_request('sorttype', 0); $captions = get_request('captions', array()); $items = get_request('items', array()); $periods = get_request('periods', array()); $showlegend = get_request('showlegend', 0); $reportForm = new CFormTable(null, null, 'get'); //,'events.php?report_set=1','POST',null,'sform'); $reportForm->setAttribute('name', 'zbx_report'); $reportForm->setAttribute('id', 'zbx_report'); // $reportForm->setMethod('post'); if (isset($_REQUEST['report_show']) && !empty($items)) { $reportForm->addVar('report_show', 'show'); } $reportForm->addVar('config', $config); $reportForm->addVar('items', $items); // periods add later $reportForm->addRow(S_TITLE, new CTextBox('title', $title, 40)); $reportForm->addRow(S_X . SPACE . S_LABEL, new CTextBox('xlabel', $xlabel, 40)); $reportForm->addRow(S_Y . SPACE . S_LABEL, new CTextBox('ylabel', $ylabel, 40)); $reportForm->addRow(S_LEGEND, new CCheckBox('showlegend', $showlegend, null, 1)); if (count($periods) < 2) { $sortCmb = new CComboBox('sorttype', $sorttype); $sortCmb->addItem(0, S_NAME); $sortCmb->addItem(1, S_VALUE); $reportForm->addRow(S_SORT_BY, $sortCmb); } else { $reportForm->addVar('sortorder', 0); } //*/ // PERIODS if (count($periods)) { $periods_table = new CTableInfo(); foreach ($periods as $pid => $period) { $color = new CColorCell(null, $period['color']); $edit_link = 'popup_period.php?period_id=' . $pid . '&config=2' . '&dstfrm=' . $reportForm->getName() . '&caption=' . $period['caption'] . '&report_timesince=' . $period['report_timesince'] . '&report_timetill=' . $period['report_timetill'] . '&color=' . $period['color']; $caption = new CSpan($period['caption'], 'link'); $caption->addAction('onclick', "return PopUp('" . $edit_link . "',840,340,'period_form');"); $periods_table->addRow(array(new CCheckBox('group_pid[' . $pid . ']'), $caption, zbx_date2str(S_REPORTS_BAR_REPORT_DATE_FORMAT, $period['report_timesince']), zbx_date2str(S_REPORTS_BAR_REPORT_DATE_FORMAT, $period['report_timetill']), $color)); } $delete_button = new CButton('delete_period', S_DELETE_SELECTED); } else { $periods_table = $delete_button = null; } $reportForm->addVar('periods', $periods); $reportForm->addRow(S_PERIOD, array($periods_table, new CButton('add_period', S_ADD, "return PopUp('popup_period.php?config=2&dstfrm=" . $reportForm->getName() . "',840,340,'period_form');"), $delete_button)); unset($periods_table, $delete_button); //----------- // ITEMS if (count($items)) { $items_table = new CTableInfo(); foreach ($items as $gid => $gitem) { $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; } $caption = new CSpan($gitem['caption'], 'link'); $caption->onClick('return PopUp("popup_bitem.php?config=2&list_name=items&dstfrm=' . $reportForm->GetName() . url_param($gitem, false) . url_param($gid, false, 'gid') . '",550,400,"graph_item_form");'); $description = $host['host'] . ': ' . item_description($item); $items_table->addRow(array(new CCheckBox('group_gid[' . $gid . ']', isset($group_gid[$gid])), $caption, $description, graph_item_calc_fnc2str($gitem['calc_fnc'], 0))); } $delete_button = new CButton('delete_item', S_DELETE_SELECTED); } else { $items_table = $delete_button = null; } $reportForm->addRow(S_ITEMS, array($items_table, new CButton('add_item', S_ADD, "return PopUp('popup_bitem.php?config=2&dstfrm=" . $reportForm->getName() . "',550,400,'graph_item_form');"), $delete_button)); unset($items_table, $delete_button); //-------------- $reportForm->addItemToBottomRow(new CButton('report_show', S_SHOW)); $reset = new CButton('reset', S_RESET); $reset->setType('reset'); $reportForm->addItemToBottomRow($reset); return $reportForm; }
function prepareSubfilterOutput($data, $subfilter, $subfilterName) { order_result($data, 'name'); $output = array(); foreach ($data as $id => $element) { $element['name'] = nbsp(CHtml::encode($element['name'])); // is activated if (str_in_array($id, $subfilter)) { $span = new CSpan($element['name'] . SPACE . '(' . $element['count'] . ')', 'subfilter_enabled'); $span->onClick(CHtml::encode('javascript: create_var("zbx_filter", "subfilter_set", "1", false);' . 'create_var("zbx_filter", ' . CJs::encodeJson($subfilterName . '[' . $id . ']') . ', null, true);')); $output[] = $span; } else { // subfilter has 0 items if ($element['count'] == 0) { $span = new CSpan($element['name'] . SPACE . '(' . $element['count'] . ')', 'subfilter_inactive'); $output[] = $span; } else { // this level has no active subfilters $nspan = $subfilter ? new CSpan(SPACE . '(+' . $element['count'] . ')', 'subfilter_active') : new CSpan(SPACE . '(' . $element['count'] . ')', 'subfilter_active'); $span = new CSpan($element['name'], 'subfilter_disabled'); $span->onClick(CHtml::encode('javascript: create_var("zbx_filter", "subfilter_set", "1", false);' . 'create_var("zbx_filter", ' . CJs::encodeJson($subfilterName . '[' . $id . ']') . ', ' . CJs::encodeJson($id) . ', ' . 'true' . ');')); $output[] = $span; $output[] = $nspan; } } $output[] = ', '; } array_pop($output); return $output; }
/** * Create bar report form for "Distribution of values for multiple items". * * @param array $items * @param array $periods * * @return object $reportForm */ function valueDistributionFormForMultipleItems($items = array(), $periods = array()) { $config = get_request('config', 1); $title = get_request('title', _('Report 2')); $xlabel = get_request('xlabel', ''); $ylabel = get_request('ylabel', ''); $sorttype = get_request('sorttype', 0); $showlegend = get_request('showlegend', 0); $reportForm = new CFormTable(null, null, 'get'); $reportForm->setAttribute('name', 'zbx_report'); $reportForm->setAttribute('id', 'zbx_report'); if (isset($_REQUEST['report_show']) && is_array($items) && $items && is_array($periods) && $periods) { $reportForm->addVar('report_show', 'show'); } $reportForm->addVar('config', $config); $reportForm->addRow(_('Title'), new CTextBox('title', $title, 40)); $reportForm->addRow(_('X label'), new CTextBox('xlabel', $xlabel, 40)); $reportForm->addRow(_('Y label'), new CTextBox('ylabel', $ylabel, 40)); $reportForm->addRow(_('Legend'), new CCheckBox('showlegend', $showlegend, null, 1)); if (count($periods) < 2) { $sortCmb = new CComboBox('sorttype', $sorttype); $sortCmb->addItem(0, _('Name')); $sortCmb->addItem(1, _('Value')); $reportForm->addRow(_('Sort by'), $sortCmb); } else { $reportForm->addVar('sortorder', 0); } if (is_array($periods) && $periods) { $periods_table = new CTableInfo(); foreach ($periods as $pid => $period) { $color = new CColorCell(null, $period['color']); $edit_link = 'popup_period.php?' . 'period_id=' . $pid . '&config=2' . '&dstfrm=' . $reportForm->getName() . '&caption=' . $period['caption'] . '&report_timesince=' . $period['report_timesince'] . '&report_timetill=' . $period['report_timetill'] . '&color=' . $period['color']; $caption = new CSpan($period['caption'], 'link'); $caption->addAction('onclick', "return PopUp('" . $edit_link . "',840,340,'period_form');"); $periods_table->addRow(array(new CCheckBox('group_pid[' . $pid . ']'), $caption, zbx_date2str(REPORTS_BAR_REPORT_DATE_FORMAT, $period['report_timesince']), zbx_date2str(REPORTS_BAR_REPORT_DATE_FORMAT, $period['report_timetill']), $color)); } $reportForm->addVar('periods', $periods); $delete_button = new CSubmit('delete_period', _('Delete selected')); } else { $periods_table = $delete_button = null; } $reportForm->addRow(_('Period'), array($periods_table, new CButton('add_period', _('Add'), 'return PopUp("popup_period.php?config=2&dstfrm=' . $reportForm->getName() . '", 840, 340, "period_form");'), $delete_button)); unset($periods_table, $delete_button); if (is_array($items) && $items) { $items_table = new CTableInfo(); foreach ($items as $id => &$item) { $caption = new CSpan($item['caption'], 'link'); $caption->onClick('return PopUp("popup_bitem.php?' . 'config=2' . '&list_name=items' . '&dstfrm=' . $reportForm->GetName() . url_param($item, false) . url_param($id, false, 'gid') . '", 550, 400, "graph_item_form");'); $description = $item['host']['name'] . NAME_DELIMITER . itemName($item); $items_table->addRow(array(new CCheckBox('group_gid[' . $id . ']', isset($group_gid[$id])), $caption, $description, graph_item_calc_fnc2str($item['calc_fnc'], 0))); // once used, unset unnecessary fields so they don't pass to URL. "color" goes in "periods" parameter. unset($item['value_type'], $item['host'], $item['name'], $item['color']); } unset($item); $reportForm->addVar('items', $items); $delete_button = new CSubmit('delete_item', _('Delete selected')); } else { $items_table = $delete_button = null; } $reportForm->addRow(_('Items'), array($items_table, new CButton('add_item', _('Add'), "return PopUp('popup_bitem.php?config=2&dstfrm=" . $reportForm->getName() . "', 550, 400, 'graph_item_form');"), $delete_button)); unset($items_table, $delete_button); $reportForm->addItemToBottomRow(new CSubmit('report_show', _('Show'))); $reset = new CButton('reset', _('Reset')); $reset->setType('reset'); $reportForm->addItemToBottomRow($reset); return $reportForm; }
if (!isset($step['url'])) { $step['url'] = ''; } if (!isset($step['posts'])) { $step['posts'] = ''; } if (!isset($step['required'])) { $step['required'] = ''; } $numSpan = new CSpan($i++ . ':'); $numSpan->addClass('rowNum'); $numSpan->setAttribute('id', 'current_step_' . $stepid); $name = new CSpan($step['name'], 'link'); $name->setAttribute('id', 'name_' . $stepid); $name->setAttribute('name_step', $stepid); $name->onClick('return PopUp("popup_httpstep.php?dstfrm=' . $httpForm->getName() . '&list_name=steps&stepid="+jQuery(this).attr("name_step")+"' . url_param($step['name'], false, 'name') . url_param($step['timeout'], false, 'timeout') . url_param($step['url'], false, 'url') . url_param($step['posts'], false, 'posts') . url_param($step['required'], false, 'required') . url_param($step['status_codes'], false, 'status_codes') . '", 600, 410);'); if (zbx_strlen($step['url']) > 70) { $url = new CSpan(substr($step['url'], 0, 35) . SPACE . '...' . SPACE . substr($step['url'], zbx_strlen($step['url']) - 25, 25)); $url->setHint($step['url']); } else { $url = $step['url']; } $removeButton = new CButton('remove_' . $stepid, _('Remove'), 'javascript: removeStep(this);', 'link_menu'); $removeButton->setAttribute('remove_step', $stepid); $row = new CRow(array(new CSpan(null, 'ui-icon ui-icon-arrowthick-2-n-s move'), $numSpan, $name, $step['timeout'] . SPACE . _('sec'), $url, htmlspecialchars($step['required']), $step['status_codes'], $removeButton), 'sortable'); $row->setAttribute('id', 'steps_' . $stepid); $stepsTable->addRow($row); } $tmpColumn = new CCol(new CButton('add_step', _('Add'), 'return PopUp("popup_httpstep.php?dstfrm=' . $httpForm->getName() . '", 600, 410);', 'link_menu'), null, 8); $tmpColumn->setAttribute('style', 'vertical-align: middle;'); $stepsTable->addRow(new CRow($tmpColumn));
function bar_report_form2() { $config = get_request('config', 1); $title = get_request('title', _('Report 2')); $xlabel = get_request('xlabel', ''); $ylabel = get_request('ylabel', ''); $sorttype = get_request('sorttype', 0); $items = get_request('items', array()); $periods = get_request('periods', array()); $showlegend = get_request('showlegend', 0); $reportForm = new CFormTable(null, null, 'get'); //,'events.php?report_set=1','POST',null,'sform'); $reportForm->setAttribute('name', 'zbx_report'); $reportForm->setAttribute('id', 'zbx_report'); // $reportForm->setMethod('post'); if (isset($_REQUEST['report_show']) && !empty($items)) { $reportForm->addVar('report_show', 'show'); } $reportForm->addVar('config', $config); $reportForm->addVar('items', $items); // periods add later $reportForm->addRow(_('Title'), new CTextBox('title', $title, 40)); $reportForm->addRow(_('X label'), new CTextBox('xlabel', $xlabel, 40)); $reportForm->addRow(_('Y label'), new CTextBox('ylabel', $ylabel, 40)); $reportForm->addRow(_('Legend'), new CCheckBox('showlegend', $showlegend, null, 1)); if (count($periods) < 2) { $sortCmb = new CComboBox('sorttype', $sorttype); $sortCmb->addItem(0, _('Name')); $sortCmb->addItem(1, _('Value')); $reportForm->addRow(_('Sort by'), $sortCmb); } else { $reportForm->addVar('sortorder', 0); } //*/ // PERIODS if (count($periods)) { $periods_table = new CTableInfo(); foreach ($periods as $pid => $period) { $color = new CColorCell(null, $period['color']); $edit_link = 'popup_period.php?period_id=' . $pid . '&config=2' . '&dstfrm=' . $reportForm->getName() . '&caption=' . $period['caption'] . '&report_timesince=' . $period['report_timesince'] . '&report_timetill=' . $period['report_timetill'] . '&color=' . $period['color']; $caption = new CSpan($period['caption'], 'link'); $caption->addAction('onclick', "return PopUp('" . $edit_link . "',840,340,'period_form');"); $periods_table->addRow(array(new CCheckBox('group_pid[' . $pid . ']'), $caption, zbx_date2str(REPORTS_BAR_REPORT_DATE_FORMAT, $period['report_timesince']), zbx_date2str(REPORTS_BAR_REPORT_DATE_FORMAT, $period['report_timetill']), $color)); } $delete_button = new CSubmit('delete_period', _('Delete selected')); } else { $periods_table = $delete_button = null; } $reportForm->addVar('periods', $periods); $reportForm->addRow(_('Period'), array($periods_table, new CButton('add_period', _('Add'), "return PopUp('popup_period.php?config=2&dstfrm=" . $reportForm->getName() . "',840,340,'period_form');"), $delete_button)); unset($periods_table, $delete_button); //----------- // ITEMS if (count($items)) { $items_table = new CTableInfo(); foreach ($items as $gid => $gitem) { $host = get_host_by_itemid($gitem['itemid']); $item = get_item_by_itemid($gitem['itemid']); $caption = new CSpan($gitem['caption'], 'link'); $caption->onClick('return PopUp("popup_bitem.php?config=2&list_name=items&dstfrm=' . $reportForm->GetName() . url_param($gitem, false) . url_param($gid, false, 'gid') . '",550,400,"graph_item_form");'); $description = $host['name'] . ': ' . itemName($item); $items_table->addRow(array(new CCheckBox('group_gid[' . $gid . ']', isset($group_gid[$gid])), $caption, $description, graph_item_calc_fnc2str($gitem['calc_fnc'], 0))); } $delete_button = new CSubmit('delete_item', _('Delete selected')); } else { $items_table = $delete_button = null; } $reportForm->addRow(_('Items'), array($items_table, new CButton('add_item', _('Add'), "return PopUp('popup_bitem.php?config=2&dstfrm=" . $reportForm->getName() . "',550,400,'graph_item_form');"), $delete_button)); unset($items_table, $delete_button); //-------------- $reportForm->addItemToBottomRow(new CSubmit('report_show', _('Show'))); $reset = new CButton('reset', _('Reset')); $reset->setType('reset'); $reportForm->addItemToBottomRow($reset); return $reportForm; }
$table->addRow($name); } $table->show(); } else { if ($srctbl == "users") { $table = new CTableInfo(S_NO_USERS_DEFINED); $table->setHeader(array(S_ALIAS, S_NAME, S_SURNAME)); $result = DBselect('SELECT * FROM users WHERE ' . DBin_node('userid') . ' ORDER BY alias'); while ($row = DBfetch($result)) { if (isset($_REQUEST['reference']) && $_REQUEST['reference'] == 'dashboard') { $action = get_window_opener($dstfrm, $dstfld1, $srcfld2) . get_window_opener($dstfrm, $dstfld2, $row[$srcfld2]) . "window.opener.setTimeout('add2favorites();', 1000);"; } else { $action = get_window_opener($dstfrm, $dstfld1, $row[$srcfld1]) . (isset($srcfld2) ? get_window_opener($dstfrm, $dstfld2, $row[$srcfld2]) : '') . (isset($_REQUEST['submit']) ? " window.opener.document.getElementsByName('{$dstfrm}')[0].submit();" : ''); } $alias = new CSpan(get_node_name_by_elid($row['userid']) . $row['alias'], 'link'); $alias->onClick($action . ' close_window(); return false;'); $table->addRow(array($alias, $row['name'], $row['surname'])); } $table->Show(); } else { if ($srctbl == "help_items") { $table = new CTableInfo(S_NO_ITEMS); $table->SetHeader(array(S_KEY, S_DESCRIPTION)); $result = DBselect("select * from help_items where itemtype=" . $itemtype . " ORDER BY key_"); while ($row = DBfetch($result)) { $name = new CLink($row["key_"], "#", "action"); if (isset($_REQUEST['reference']) && $_REQUEST['reference'] == 'dashboard') { $action = get_window_opener($dstfrm, $dstfld1, $srcfld2) . get_window_opener($dstfrm, $dstfld2, $row[$srcfld2]) . "window.opener.setTimeout('add2favorites();', 1000);"; } else { $action = get_window_opener($dstfrm, $dstfld1, html_entity_decode($row[$srcfld1])) . (isset($srcfld2) ? get_window_opener($dstfrm, $dstfld2, $row[$srcfld2]) : ''); }
function prepare_subfilter_output($data, $subfilter, $subfilter_name) { $output = array(); order_result($data, 'name'); foreach ($data as $id => $element) { // subfilter is activated if (str_in_array($id, $subfilter)) { $span = new CSpan($element['name'] . ' (' . $element['count'] . ')', 'subfilter_enabled'); $script = CHtml::encode('javascript: create_var("zbx_filter", ' . CJs::encodeJson($subfilter_name . '[' . $id . ']') . ', null, true);'); $span->onClick($script); $output[] = $span; } else { $script = CHtml::encode('javascript: create_var("zbx_filter", ' . CJs::encodeJson($subfilter_name . '[' . $id . ']') . ', ' . CJs::encodeJson($id) . ', true);'); // subfilter has 0 items if ($element['count'] == 0) { $span = new CSpan($element['name'] . ' (' . $element['count'] . ')', 'subfilter_inactive'); $span->onClick($script); $output[] = $span; } else { // this level has no active subfilters if (empty($subfilter)) { $nspan = new CSpan(' (' . $element['count'] . ')', 'subfilter_active'); } else { $nspan = new CSpan(' (+' . $element['count'] . ')', 'subfilter_active'); } $span = new CSpan($element['name'], 'subfilter_disabled'); $span->onClick($script); $output[] = $span; $output[] = $nspan; } } $output[] = ' , '; } array_pop($output); return $output; }
function insert_graph_form() { $frmGraph = new CFormTable(S_GRAPH, null, 'post'); $frmGraph->setName('frm_graph'); //$frmGraph->setHelp("web.graphs.graph.php"); $items = get_request('items', array()); if (isset($_REQUEST['graphid'])) { $frmGraph->addVar('graphid', $_REQUEST['graphid']); $options = array('graphids' => $_REQUEST['graphid'], 'extendoutput' => 1); $graphs = CGraph::get($options); $row = reset($graphs); $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']; $options = array('graphids' => $_REQUEST['graphid'], 'sortfield' => 'sortorder', 'extendoutput' => 1); $items = CGraphItem::get($options); } 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) { unset($items[$gid]); } } } $items = array_values($items); $icount = count($items); for ($i = 0; $i < $icount - 1;) { // check if we deletd an item $next = $i + 1; while (!isset($items[$next]) && $next < $icount - 1) { $next++; } if (isset($items[$next]) && $items[$i]['sortorder'] == $items[$next]['sortorder']) { for ($j = $next; $j < $icount; $j++) { if ($items[$j - 1]['sortorder'] >= $items[$j]['sortorder']) { $items[$j]['sortorder']++; } } } $i = $next; } asort_by_key($items, 'sortorder'); $items = array_values($items); $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)); $frmGraph->addRow(S_WIDTH, new CNumericBox('width', $width, 5)); $frmGraph->addRow(S_HEIGHT, new CNumericBox('height', $height, 5)); $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); // items beforehead, to get only_hostid for miny maxy items $only_hostid = null; $monitored_hosts = null; if (count($items)) { $frmGraph->addVar('items', $items); $keys = array_keys($items); $first = reset($keys); $last = end($keys); $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']); } if ($gid == $first) { $do_up = null; } else { $do_up = new CSpan(S_UP, 'link'); $do_up->onClick("return create_var('" . $frmGraph->getName() . "','move_up'," . $gid . ", true);"); } if ($gid == $last) { $do_down = null; } else { $do_down = new CSpan(S_DOWN, 'link'); $do_down->onClick("return create_var('" . $frmGraph->getName() . "','move_down'," . $gid . ", true);"); } $description = new CSpan($host['host'] . ': ' . item_description($item), 'link'); $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])), $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])), $description, graph_item_calc_fnc2str($gitem["calc_fnc"], $gitem["type"]), graph_item_type2str($gitem['type'], $gitem["periods_cnt"]), $gitem['yaxisside'] == GRAPH_YAXIS_SIDE_LEFT ? S_LEFT : S_RIGHT, graph_item_drawtype2str($gitem["drawtype"], $gitem["type"]), $color, array($do_up, !is_null($do_up) && !is_null($do_down) ? SPACE . "|" . SPACE : '', $do_down))); } } $dedlete_button = new CButton('delete_item', S_DELETE_SELECTED); } else { $items_table = $dedlete_button = null; } // $frmGraph->addRow(S_SHOW_LEGEND, new CCheckBox('legend',$legend, null, 1)); 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->setAttribute('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->setAttribute('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); } if (count($items)) { $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() . url_param($only_hostid, false, 'only_hostid') . url_param($monitored_hosts, false, 'monitored_hosts') . "&dstfld1=ymin_itemid" . "&dstfld2=ymin_name" . "&srctbl=items" . "&srcfld1=itemid" . "&srcfld2=description',0,0,'zbx_popup_item');"); } else { $yaxis_min[] = SPACE . S_ADD_GRAPH_ITEMS; } } 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); } if (count($items)) { $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() . url_param($only_hostid, false, 'only_hostid') . url_param($monitored_hosts, false, 'monitored_hosts') . "&dstfld1=ymax_itemid" . "&dstfld2=ymax_name" . "&srctbl=items" . "&srcfld1=itemid" . "&srcfld2=description',0,0,'zbx_popup_item');"); } else { $yaxis_max[] = SPACE . S_ADD_GRAPH_ITEMS; } } else { $frmGraph->addVar('yaxismax', $yaxismax); } } $frmGraph->addRow(S_YAXIS_MAX_VALUE, $yaxis_max); } else { $frmGraph->addRow(S_SHOW_LEGEND, new CCheckBox('legend', $legend, null, 1)); $frmGraph->addRow(S_3D_VIEW, new CCheckBox('graph3d', $graph3d, null, 1)); } $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); $preView = new CButton('preview', S_PREVIEW); //$preView->setAttribute('style', 'float: left;'); $frmGraph->addItemToBottomRow($preView); $frmGraph->addItemToBottomRow(SPACE); $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(); }
} } else { $frmForm = new CForm(); $frmForm->setMethod('get'); $frmForm->addItem(array(S_GROUP . SPACE, $pageFilter->getGroupsCB())); $numrows = new CDiv(); $numrows->setAttribute('name', 'numrows'); $hosts_wdgt->addHeader(S_HOSTS_BIG, $frmForm); $hosts_wdgt->addHeader($numrows); // HOSTS FILTER {{{ $filter_table = new CTable('', 'filter_config'); $filter_table->addRow(array(array(array(bold(S_HOST), SPACE . S_LIKE_SMALL . ': '), new CTextBox('filter_host', $_REQUEST['filter_host'], 20)), array(array(bold(S_DNS), SPACE . S_LIKE_SMALL . ': '), new CTextBox('filter_dns', $_REQUEST['filter_dns'], 20)), array(array(bold(S_IP), SPACE . S_LIKE_SMALL . ': '), new CTextBox('filter_ip', $_REQUEST['filter_ip'], 20)), array(bold(S_PORT . ': '), new CTextBox('filter_port', $_REQUEST['filter_port'], 20)))); $reset = new CSpan(S_RESET, 'biglink'); $reset->onClick("javascript: clearAllForm('zbx_filter');"); $filter = new CSpan(S_FILTER, 'biglink'); $filter->onClick("javascript: create_var('zbx_filter', 'filter_set', '1', true);"); $footer_col = new CCol(array($filter, SPACE, SPACE, SPACE, $reset), 'center'); $footer_col->setColSpan(4); $filter_table->addRow($footer_col); $filter_form = new CForm(null, 'get'); $filter_form->setAttribute('name', 'zbx_filter'); $filter_form->setAttribute('id', 'zbx_filter'); $filter_form->addItem($filter_table); // }}} HOSTS FILTER $hosts_wdgt->addFlicker($filter_form, CProfile::get('web.hosts.filter.state', 0)); // table HOSTS $form = new CForm(); $form->setName('hosts'); $table = new CTableInfo(S_NO_HOSTS_DEFINED); $table->setHeader(array(new CCheckBox('all_hosts', null, "checkAll('" . $form->getName() . "','all_hosts','hosts');"), make_sorting_header(S_NAME, 'host'), S_APPLICATIONS, S_ITEMS, S_TRIGGERS, S_GRAPHS, make_sorting_header(S_DNS, 'dns'), make_sorting_header(S_IP, 'ip'), S_PORT, S_TEMPLATES, make_sorting_header(S_STATUS, 'status'), S_AVAILABILITY)); // get Hosts
$table->SetHeader($header); $sql = 'SELECT h.host,t.triggerid,t.description,t.expression,t.priority,t.status,count(d.triggerid_up) as dep_count ' . ' FROM hosts h,items i,functions f, triggers t' . ' LEFT JOIN trigger_depends d ON d.triggerid_down=t.triggerid ' . ' WHERE f.itemid=i.itemid ' . ' AND h.hostid=i.hostid ' . ' AND t.triggerid=f.triggerid' . ' AND ' . DBin_node('t.triggerid', $nodeid) . ' AND ' . DBcondition('t.triggerid', $available_triggers) . ' AND h.status in (' . implode(',', $host_status) . ')'; if ($hostid > 0) { $sql .= ' AND h.hostid=' . $hostid; } $sql .= ' GROUP BY h.host, t.triggerid, t.description, t.expression, t.priority, t.status' . ' ORDER BY h.host,t.description'; $result = DBselect($sql); while ($row = DBfetch($result)) { $exp_desc = expand_trigger_description_by_data($row); $description = new CSpan($exp_desc, 'link'); if ($multiselect) { $js_action = 'add_selected_values("' . S_TRIGGERS . '", "' . $dstfrm . '", "' . $dstfld1 . '", "' . $dstact . '", "' . $row["triggerid"] . '");'; } else { $js_action = 'add_value("' . $dstfld1 . '", "' . $dstfld2 . '", "' . $row["triggerid"] . '", "' . $exp_desc . '");'; } $description->onClick($js_action); if ($row['dep_count'] > 0) { $description = array($description, BR(), BR(), bold(S_DEPENDS_ON), BR()); $deps = get_trigger_dependencies_by_triggerid($row["triggerid"]); foreach ($deps as $val) { $description[] = array(expand_trigger_description($val), BR()); } } switch ($row["status"]) { case TRIGGER_STATUS_DISABLED: $status = new CSpan(S_DISABLED, 'disabled'); break; case TRIGGER_STATUS_UNKNOWN: $status = new CSpan(S_UNKNOWN, 'unknown'); break; case TRIGGER_STATUS_ENABLED:
if (!isset($s['timeout'])) { $s['timeout'] = 15; } if (!isset($s['url'])) { $s['url'] = ''; } if (!isset($s['posts'])) { $s['posts'] = ''; } if (!isset($s['required'])) { $s['required'] = ''; } $up = null; if ($stepid != $first) { $up = new CSpan(S_UP, 'link'); $up->onClick("return create_var('" . $form->getName() . "','move_up'," . $stepid . ", true);"); } $down = null; if ($stepid != $last) { $down = new CLink(S_DOWN, 'link'); $down->onClick("return create_var('" . $form->getName() . "','move_down'," . $stepid . ", true);"); } $name = new CSpan($s['name'], 'link'); $name->onClick('return PopUp("popup_httpstep.php?dstfrm=' . $form->getName() . '&list_name=steps&stepid=' . $stepid . url_param($s['name'], false, 'name') . url_param($s['timeout'], false, 'timeout') . url_param($s['url'], false, 'url') . url_param($s['posts'], false, 'posts') . url_param($s['required'], false, 'required') . url_param($s['status_codes'], false, 'status_codes') . '");'); if (zbx_strlen($s['url']) > 70) { $url = new CTag('span', 'yes', substr($s['url'], 0, 35) . SPACE . '...' . SPACE . substr($s['url'], zbx_strlen($s['url']) - 25, 25)); $url->setHint($s['url']); } else { $url = $s['url']; } $tblSteps->addRow(array(new CCheckBox('sel_step[]', null, null, $stepid), $name, $s['timeout'] . SPACE . S_SEC_SMALL, $url, $s['required'], $s['status_codes'], array($up, isset($up) && isset($down) ? SPACE : null, $down)));