public function bodyToString() { $this->cleanItems(); $total = 0; // fetch accessible host ids $hosts = API::Host()->get(array('nodeids' => get_current_nodeid(true), 'output' => array('hostid'), 'preservekeys' => true)); $hostIds = array_keys($hosts); if (remove_nodes_from_id($this->groupid) > 0) { $cond_from = ',hosts_groups hg'; $cond_where = ' AND hg.hostid=h.hostid AND hg.groupid=' . zbx_dbstr($this->groupid); } else { $cond_from = ''; $cond_where = andDbNode('h.hostid', $this->nodeid); } $db_host_cnt = DBselect('SELECT COUNT(DISTINCT h.hostid) AS cnt' . ' FROM hosts h' . $cond_from . ' WHERE h.available=' . HOST_AVAILABLE_TRUE . ' AND h.status IN (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ')' . ' AND ' . dbConditionInt('h.hostid', $hostIds) . $cond_where); $host_cnt = DBfetch($db_host_cnt); $avail = $host_cnt['cnt']; $total += $host_cnt['cnt']; $db_host_cnt = DBselect('SELECT COUNT(DISTINCT h.hostid) AS cnt' . ' FROM hosts h' . $cond_from . ' WHERE h.available=' . HOST_AVAILABLE_FALSE . ' AND h.status IN (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ')' . ' AND ' . dbConditionInt('h.hostid', $hostIds) . $cond_where); $host_cnt = DBfetch($db_host_cnt); $notav = $host_cnt['cnt']; $total += $host_cnt['cnt']; $db_host_cnt = DBselect('SELECT COUNT(DISTINCT h.hostid) AS cnt' . ' FROM hosts h' . $cond_from . ' WHERE h.available=' . HOST_AVAILABLE_UNKNOWN . ' AND h.status IN (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ')' . ' AND ' . dbConditionInt('h.hostid', $hostIds) . $cond_where); $host_cnt = DBfetch($db_host_cnt); $uncn = $host_cnt['cnt']; $total += $host_cnt['cnt']; $node = get_node_by_nodeid($this->nodeid); $header_str = _('Hosts info') . SPACE; if ($node > 0) { $header_str .= '(' . $node['name'] . ')' . SPACE; } if (remove_nodes_from_id($this->groupid) > 0) { $group = get_hostgroup_by_groupid($this->groupid); $header_str .= _('Group') . SPACE . '"' . $group['name'] . '"'; } else { $header_str .= _('All groups'); } $header = new CCol($header_str, 'header'); if ($this->style == STYLE_HORISONTAL) { $header->setColspan(4); } $this->addRow($header); $avail = new CCol($avail . ' ' . _('Available'), 'avail'); $notav = new CCol($notav . ' ' . _('Not available'), 'notav'); $uncn = new CCol($uncn . ' ' . _('Unknown'), 'uncn'); $total = new CCol($total . ' ' . _('Total'), 'total'); if ($this->style == STYLE_HORISONTAL) { $this->addRow(array($avail, $notav, $uncn, $total)); } else { $this->addRow($avail); $this->addRow($notav); $this->addRow($uncn); $this->addRow($total); } return parent::bodyToString(); }
public function bodyToString() { global $USER_DETAILS; $this->cleanItems(); $total = 0; $accessible_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY, PERM_RES_IDS_ARRAY, get_current_nodeid(true)); $cond_from = ''; if (remove_nodes_from_id($this->groupid) > 0) { $cond_from = ', hosts_groups hg '; $cond_where = 'AND hg.hostid=h.hostid AND hg.groupid=' . $this->groupid; } else { $cond_where = ' AND ' . DBin_node('h.hostid', $this->nodeid); } $db_host_cnt = DBselect('SELECT COUNT(DISTINCT h.hostid) as cnt ' . ' FROM hosts h' . $cond_from . ' WHERE h.available=' . HOST_AVAILABLE_TRUE . ' AND h.status IN (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ') ' . ' AND ' . DBcondition('h.hostid', $accessible_hosts) . $cond_where); $host_cnt = DBfetch($db_host_cnt); $avail = $host_cnt['cnt']; $total += $host_cnt['cnt']; $db_host_cnt = DBselect('SELECT COUNT(DISTINCT h.hostid) as cnt ' . ' FROM hosts h' . $cond_from . ' WHERE h.available=' . HOST_AVAILABLE_FALSE . ' AND h.status IN (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ') ' . ' AND ' . DBcondition('h.hostid', $accessible_hosts) . $cond_where); $host_cnt = DBfetch($db_host_cnt); $notav = $host_cnt['cnt']; $total += $host_cnt['cnt']; $db_host_cnt = DBselect('SELECT COUNT(DISTINCT h.hostid) as cnt ' . ' FROM hosts h' . $cond_from . ' WHERE h.available=' . HOST_AVAILABLE_UNKNOWN . ' AND h.status IN (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ') ' . ' AND ' . DBcondition('h.hostid', $accessible_hosts) . $cond_where); $host_cnt = DBfetch($db_host_cnt); $uncn = $host_cnt['cnt']; $total += $host_cnt['cnt']; $node = get_node_by_nodeid($this->nodeid); $header_str = S_HOSTS_INFO . SPACE; $header_str .= S_FOR_GROUP_SMALL . SPACE . '"'; if ($node > 0) { $header_str .= '(' . $node['name'] . ')' . SPACE; } if (remove_nodes_from_id($this->groupid) > 0) { $group = get_hostgroup_by_groupid($this->groupid); $header_str .= $group['name'] . '"'; } else { $header_str .= S_ALL_S . '"'; } $header = new CCol($header_str, "header"); if ($this->style == STYLE_HORISONTAL) { $header->SetColspan(4); } $this->addRow($header); $avail = new CCol($avail . ' ' . S_AVAILABLE, 'avail'); $notav = new CCol($notav . ' ' . S_NOT_AVAILABLE, 'notav'); $uncn = new CCol($uncn . ' ' . S_UNKNOWN, 'uncn'); $total = new CCol($total . ' ' . S_TOTAL, 'total'); if ($this->style == STYLE_HORISONTAL) { $this->addRow(array($avail, $notav, $uncn, $total)); } else { $this->addRow($avail); $this->addRow($notav); $this->addRow($uncn); $this->addRow($total); } return parent::bodyToString(); }
function create_id_by_nodeid($id, $nodeid = 0) { global $ZBX_LOCALNODEID; $nodeid = $nodeid == 0 ? get_current_nodeid(false) : $nodeid; $id = remove_nodes_from_id($id); $id = bcadd($id, bcadd(bcmul($nodeid, '100000000000000'), bcmul($ZBX_LOCALNODEID, '100000000000'))); return $id; }
$caption = $row['node_name'] . $row['name']; $id = $resourceid; } } $screenFormList->addVar('resourceid', $id); $screenFormList->addRow(_('Parameter'), array(new CTextBox('caption', $caption, ZBX_TEXTBOX_STANDARD_SIZE, 'yes'), new CButton('select', _('Select'), 'javascript: return PopUp("popup.php?srctbl=screens2&srcfld1=screenid&srcfld2=name' . '&dstfrm=' . $screenForm->getName() . '&dstfld1=resourceid&dstfld2=caption' . '&writeonly=1&screenid=' . $_REQUEST['screenid'] . '", 800, 450);', 'formlist'))); } elseif ($resourcetype == SCREEN_RESOURCE_HOSTS_INFO || $resourcetype == SCREEN_RESOURCE_TRIGGERS_INFO) { $caption = ''; $id = 0; if (remove_nodes_from_id($resourceid) > 0) { $groups = API::HostGroup()->get(array('groupids' => $resourceid, 'nodeids' => get_current_nodeid(true), 'output' => array('name'), 'preservekeys' => true)); if ($group = reset($groups)) { $caption = get_node_name_by_elid($resourceid, true, ': ') . $group['name']; $id = $resourceid; } } elseif (remove_nodes_from_id($resourceid) == 0) { if ($nodeName = get_node_name_by_elid($resourceid, true, ': ')) { $caption = $nodeName . _('- all groups -'); $id = $resourceid; } } $screenFormList->addVar('resourceid', $id); $screenFormList->addRow(_('Group'), array(new CTextBox('caption', $caption, ZBX_TEXTBOX_STANDARD_SIZE, 'yes'), new CButton('select', _('Select'), 'javascript: return PopUp("popup.php?srctbl=host_group_scr&srcfld1=groupid&srcfld2=name' . '&dstfrm=' . $screenForm->getName() . '&dstfld1=resourceid&dstfld2=caption' . '&writeonly=1", 480, 450);', 'formlist'))); } elseif ($resourcetype == SCREEN_RESOURCE_CLOCK) { $caption = get_request('caption', ''); if (zbx_empty($caption) && TIME_TYPE_HOST == $style && $resourceid > 0) { $items = API::Item()->get(array('itemids' => $resourceid, 'selectHosts' => array('name'), 'output' => API_OUTPUT_EXTEND)); $item = reset($items); $host = reset($item['hosts']); $caption = $host['name'] . ':' . $item['name']; }
function get_screen_item_form() { global $USER_DETAILS; $form = new CFormTable(S_SCREEN_CELL_CONFIGURATION, 'screenedit.php?screenid=' . $_REQUEST['screenid']); $form->SetHelp('web.screenedit.cell.php'); if (isset($_REQUEST['screenitemid'])) { $sql = 'SELECT * ' . ' FROM screens_items' . ' WHERE screenid=' . $_REQUEST['screenid'] . ' AND screenitemid=' . $_REQUEST['screenitemid']; $iresult = DBSelect($sql); $form->addVar('screenitemid', $_REQUEST['screenitemid']); } else { $form->addVar('x', $_REQUEST['x']); $form->addVar('y', $_REQUEST['y']); } if (isset($_REQUEST['screenitemid']) && !isset($_REQUEST['form_refresh'])) { $irow = DBfetch($iresult); $resourcetype = $irow['resourcetype']; $resourceid = $irow['resourceid']; $width = $irow['width']; $height = $irow['height']; $colspan = $irow['colspan']; $rowspan = $irow['rowspan']; $elements = $irow['elements']; $valign = $irow['valign']; $halign = $irow['halign']; $style = $irow['style']; $url = $irow['url']; $dynamic = $irow['dynamic']; } else { $resourcetype = get_request('resourcetype', 0); $resourceid = get_request('resourceid', 0); $width = get_request('width', 500); $height = get_request('height', 100); $colspan = get_request('colspan', 0); $rowspan = get_request('rowspan', 0); $elements = get_request('elements', 25); $valign = get_request('valign', VALIGN_DEFAULT); $halign = get_request('halign', HALIGN_DEFAULT); $style = get_request('style', 0); $url = get_request('url', ''); $dynamic = get_request('dynamic', SCREEN_SIMPLE_ITEM); } $form->addVar('screenid', $_REQUEST['screenid']); // a-z order!!! $cmbRes = new CCombobox('resourcetype', $resourcetype, 'submit()'); $cmbRes->addItem(SCREEN_RESOURCE_CLOCK, S_CLOCK); $cmbRes->addItem(SCREEN_RESOURCE_DATA_OVERVIEW, S_DATA_OVERVIEW); $cmbRes->addItem(SCREEN_RESOURCE_GRAPH, S_GRAPH); $cmbRes->addItem(SCREEN_RESOURCE_ACTIONS, S_HISTORY_OF_ACTIONS); $cmbRes->addItem(SCREEN_RESOURCE_EVENTS, S_HISTORY_OF_EVENTS); $cmbRes->addItem(SCREEN_RESOURCE_HOSTS_INFO, S_HOSTS_INFO); $cmbRes->addItem(SCREEN_RESOURCE_MAP, S_MAP); $cmbRes->addItem(SCREEN_RESOURCE_PLAIN_TEXT, S_PLAIN_TEXT); $cmbRes->addItem(SCREEN_RESOURCE_SCREEN, S_SCREEN); $cmbRes->addItem(SCREEN_RESOURCE_SERVER_INFO, S_SERVER_INFO); $cmbRes->addItem(SCREEN_RESOURCE_SIMPLE_GRAPH, S_SIMPLE_GRAPH); $cmbRes->addItem(SCREEN_RESOURCE_HOSTGROUP_TRIGGERS, S_STATUS_OF_HOSTGROUP_TRIGGERS); $cmbRes->addItem(SCREEN_RESOURCE_HOST_TRIGGERS, S_STATUS_OF_HOST_TRIGGERS); $cmbRes->addItem(SCREEN_RESOURCE_SYSTEM_STATUS, S_SYSTEM_STATUS); $cmbRes->addItem(SCREEN_RESOURCE_TRIGGERS_INFO, S_TRIGGERS_INFO); $cmbRes->addItem(SCREEN_RESOURCE_TRIGGERS_OVERVIEW, S_TRIGGERS_OVERVIEW); $cmbRes->addItem(SCREEN_RESOURCE_URL, S_URL); $form->addRow(S_RESOURCE, $cmbRes); if ($resourcetype == SCREEN_RESOURCE_GRAPH) { // User-defined graph $options = array('graphids' => $resourceid, 'select_hosts' => array('hostid', 'host'), 'output' => API_OUTPUT_EXTEND); $graphs = CGraph::get($options); $caption = ''; $id = 0; if (!empty($graphs)) { $id = $resourceid; $graph = reset($graphs); order_result($graph['hosts'], 'host'); $graph['host'] = reset($graph['hosts']); $caption = $graph['host']['host'] . ':' . $graph['name']; $nodeName = get_node_name_by_elid($graph['host']['hostid']); if (!zbx_empty($nodeName)) { $caption = '(' . $nodeName . ') ' . $caption; } } $form->addVar('resourceid', $id); $textfield = new CTextbox('caption', $caption, 75, 'yes'); $selectbtn = new CButton('select', S_SELECT, "javascript: return PopUp('popup.php?writeonly=1&dstfrm=" . $form->getName() . "&real_hosts=1&dstfld1=resourceid&dstfld2=caption&srctbl=graphs&srcfld1=graphid&srcfld2=name',800,450);"); $selectbtn->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';"); $form->addRow(S_GRAPH_NAME, array($textfield, SPACE, $selectbtn)); } else { if ($resourcetype == SCREEN_RESOURCE_SIMPLE_GRAPH) { // Simple graph $options = array('itemids' => $resourceid, 'select_hosts' => array('hostid', 'host'), 'output' => API_OUTPUT_EXTEND); $items = CItem::get($options); $caption = ''; $id = 0; if (!empty($items)) { $id = $resourceid; $item = reset($items); $item['host'] = reset($item['hosts']); $caption = item_description($item); $nodeName = get_node_name_by_elid($item['itemid']); if (!zbx_empty($nodeName)) { $caption = '(' . $nodeName . ') ' . $caption; } } $form->addVar('resourceid', $id); $textfield = new Ctextbox('caption', $caption, 75, 'yes'); $selectbtn = new Cbutton('select', S_SELECT, "javascript: return PopUp('popup.php?writeonly=1&real_hosts=1&dstfrm=" . $form->getName() . "&dstfld1=resourceid&dstfld2=caption&srctbl=simple_graph&srcfld1=itemid&srcfld2=description',800,450);"); $selectbtn->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';"); $form->addRow(S_PARAMETER, array($textfield, SPACE, $selectbtn)); } else { if ($resourcetype == SCREEN_RESOURCE_MAP) { // Map $options = array('sysmapids' => $resourceid, 'output' => API_OUTPUT_EXTEND); $maps = CMap::get($options); $caption = ''; $id = 0; if (!empty($maps)) { $id = $resourceid; $map = reset($maps); $caption = $map['name']; $nodeName = get_node_name_by_elid($map['sysmapid']); if (!zbx_empty($nodeName)) { $caption = '(' . $nodeName . ') ' . $caption; } } $form->addVar('resourceid', $id); $textfield = new Ctextbox('caption', $caption, 60, 'yes'); $selectbtn = new Cbutton('select', S_SELECT, "javascript: return PopUp('popup.php?writeonly=1&dstfrm=" . $form->getName() . "&dstfld1=resourceid&dstfld2=caption&srctbl=sysmaps&srcfld1=sysmapid&srcfld2=name',400,450);"); $selectbtn->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';"); $form->addRow(S_PARAMETER, array($textfield, SPACE, $selectbtn)); } else { if ($resourcetype == SCREEN_RESOURCE_PLAIN_TEXT) { // Plain text $options = array('itemids' => $resourceid, 'select_hosts' => array('hostid', 'host'), 'output' => API_OUTPUT_EXTEND); $items = CItem::get($options); $caption = ''; $id = 0; if (!empty($items)) { $id = $resourceid; $item = reset($items); $item['host'] = reset($item['hosts']); $caption = item_description($item); $nodeName = get_node_name_by_elid($item['itemid']); if (!zbx_empty($nodeName)) { $caption = '(' . $nodeName . ') ' . $caption; } } $form->addVar('resourceid', $id); $textfield = new CTextbox('caption', $caption, 75, 'yes'); $selectbtn = new CButton('select', S_SELECT, "javascript: return PopUp('popup.php?writeonly=1&dstfrm=" . $form->getName() . "&dstfld1=resourceid&dstfld2=caption&srctbl=plain_text&srcfld1=itemid&srcfld2=description',800,450);"); $selectbtn->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';"); $form->addRow(S_PARAMETER, array($textfield, SPACE, $selectbtn)); $form->addRow(S_SHOW_LINES, new CNumericBox('elements', $elements, 2)); $form->addRow(S_SHOW_TEXT_AS_HTML, new CCheckBox('style', $style, null, 1)); } else { if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_HOSTGROUP_TRIGGERS, SCREEN_RESOURCE_HOST_TRIGGERS))) { // Status of triggers $caption = ''; $id = 0; if (SCREEN_RESOURCE_HOSTGROUP_TRIGGERS == $resourcetype) { if ($resourceid > 0) { $options = array('groupids' => $resourceid, 'output' => API_OUTPUT_EXTEND, 'editable' => 1); $groups = CHostgroup::get($options); foreach ($groups as $gnum => $group) { $caption = get_node_name_by_elid($group['groupid'], true, ':') . $group['name']; $id = $resourceid; } } $form->addVar('resourceid', $id); $textfield = new CTextbox('caption', $caption, 60, 'yes'); $selectbtn = new CButton('select', S_SELECT, "javascript: return PopUp('popup.php?writeonly=1&dstfrm=" . $form->getName() . "&dstfld1=resourceid&dstfld2=caption&srctbl=host_group&srcfld1=groupid&srcfld2=name',800,450);"); $selectbtn->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';"); $form->addRow(S_GROUP, array($textfield, SPACE, $selectbtn)); } else { if ($resourceid > 0) { $options = array('hostids' => $resourceid, 'output' => API_OUTPUT_EXTEND, 'editable' => 1); $hosts = CHost::get($options); foreach ($hosts as $hnum => $host) { $caption = get_node_name_by_elid($host['hostid'], true, ':') . $host['host']; $id = $resourceid; } } $form->addVar('resourceid', $id); $textfield = new CTextbox('caption', $caption, 60, 'yes'); $selectbtn = new CButton('select', S_SELECT, "javascript: return PopUp('popup.php?writeonly=1&dstfrm=" . $form->getName() . "&dstfld1=resourceid&dstfld2=caption&srctbl=hosts&srcfld1=hostid&srcfld2=host',800,450);"); $selectbtn->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';"); $form->addRow(S_HOST, array($textfield, SPACE, $selectbtn)); } $form->addRow(S_SHOW_LINES, new CNumericBox('elements', $elements, 2)); } else { if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_EVENTS, SCREEN_RESOURCE_ACTIONS))) { // History of actions // History of events $form->addRow(S_SHOW_LINES, new CNumericBox('elements', $elements, 2)); $form->addVar('resourceid', 0); } else { if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_TRIGGERS_OVERVIEW, SCREEN_RESOURCE_DATA_OVERVIEW))) { // Overviews $caption = ''; $id = 0; if ($resourceid > 0) { $options = array('groupids' => $resourceid, 'output' => API_OUTPUT_EXTEND, 'editable' => 1); $groups = CHostgroup::get($options); foreach ($groups as $gnum => $group) { $caption = get_node_name_by_elid($group['groupid'], true, ':') . $group['name']; $id = $resourceid; } } $form->addVar('resourceid', $id); $textfield = new CTextbox('caption', $caption, 75, 'yes'); $selectbtn = new CButton('select', S_SELECT, "javascript: return PopUp('popup.php?writeonly=1&dstfrm=" . $form->getName() . "&dstfld1=resourceid&dstfld2=caption&srctbl=overview&srcfld1=groupid&srcfld2=name',800,450);"); $selectbtn->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';"); $form->addRow(S_GROUP, array($textfield, SPACE, $selectbtn)); } else { if ($resourcetype == SCREEN_RESOURCE_SCREEN) { // Screens $caption = ''; $id = 0; if ($resourceid > 0) { $result = DBselect('SELECT DISTINCT n.name as node_name,s.screenid,s.name ' . ' FROM screens s ' . ' LEFT JOIN nodes n ON n.nodeid=' . DBid2nodeid('s.screenid') . ' WHERE s.screenid=' . $resourceid); while ($row = DBfetch($result)) { $r = CScreen::get(array('screenids' => $row['screenid'], 'output' => API_OUTPUT_SHORTEN)); if (empty($r)) { continue; } if (check_screen_recursion($_REQUEST['screenid'], $row['screenid'])) { continue; } $row['node_name'] = isset($row['node_name']) ? '(' . $row['node_name'] . ') ' : ''; $caption = $row['node_name'] . $row['name']; $id = $resourceid; } } $form->addVar('resourceid', $id); $textfield = new Ctextbox('caption', $caption, 60, 'yes'); $selectbtn = new Cbutton('select', S_SELECT, "javascript: return PopUp('popup.php?writeonly=1&dstfrm=" . $form->getName() . "&dstfld1=resourceid&dstfld2=caption&srctbl=screens2&srcfld1=screenid&srcfld2=name&screenid=" . $_REQUEST['screenid'] . "',800,450);"); $selectbtn->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';"); $form->addRow(S_PARAMETER, array($textfield, SPACE, $selectbtn)); } else { if ($resourcetype == SCREEN_RESOURCE_HOSTS_INFO || $resourcetype == SCREEN_RESOURCE_TRIGGERS_INFO) { // HOSTS info $caption = ''; $id = 0; $available_groups = get_accessible_groups_by_user($USER_DETAILS, PERM_READ_ONLY); if (remove_nodes_from_id($resourceid) > 0) { $result = DBselect('SELECT DISTINCT n.name as node_name,g.groupid,g.name ' . ' FROM hosts_groups hg, groups g ' . ' LEFT JOIN nodes n ON n.nodeid=' . DBid2nodeid('g.groupid') . ' WHERE ' . DBcondition('g.groupid', $available_groups) . ' AND g.groupid=' . $resourceid); while ($row = DBfetch($result)) { $row['node_name'] = isset($row['node_name']) ? '(' . $row['node_name'] . ') ' : ''; $caption = $row['node_name'] . $row['name']; $id = $resourceid; } } else { if (remove_nodes_from_id($resourceid) == 0) { $result = DBselect('SELECT DISTINCT n.name as node_name ' . ' FROM nodes n ' . ' WHERE n.nodeid=' . id2nodeid($resourceid)); while ($row = DBfetch($result)) { $row['node_name'] = isset($row['node_name']) ? '(' . $row['node_name'] . ') ' : ''; $caption = $row['node_name'] . S_MINUS_ALL_GROUPS_MINUS; $id = $resourceid; } } } $form->addVar('resourceid', $id); $textfield = new CTextbox('caption', $caption, 60, 'yes'); $selectbtn = new Cbutton('select', S_SELECT, "javascript: return PopUp('popup.php?writeonly=1&dstfrm=" . $form->getName() . "&dstfld1=resourceid&dstfld2=caption&srctbl=host_group_scr&srcfld1=groupid&srcfld2=name',480,450);"); $selectbtn->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';"); $form->addRow(S_GROUP, array($textfield, SPACE, $selectbtn)); } else { // SCREEN_RESOURCE_CLOCK $form->addVar('resourceid', 0); } } } } } } } } } if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_HOSTS_INFO, SCREEN_RESOURCE_TRIGGERS_INFO))) { $cmbStyle = new CComboBox("style", $style); $cmbStyle->addItem(STYLE_HORISONTAL, S_HORIZONTAL); $cmbStyle->addItem(STYLE_VERTICAL, S_VERTICAL); $form->addRow(S_STYLE, $cmbStyle); } else { if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_TRIGGERS_OVERVIEW, SCREEN_RESOURCE_DATA_OVERVIEW))) { $cmbStyle = new CComboBox('style', $style); $cmbStyle->addItem(STYLE_LEFT, S_LEFT); $cmbStyle->addItem(STYLE_TOP, S_TOP); $form->addRow(S_HOSTS_LOCATION, $cmbStyle); } else { if ($resourcetype == SCREEN_RESOURCE_CLOCK) { $cmbStyle = new CComboBox('style', $style); $cmbStyle->addItem(TIME_TYPE_LOCAL, S_LOCAL_TIME); $cmbStyle->addItem(TIME_TYPE_SERVER, S_SERVER_TIME); $form->addRow(S_TIME_TYPE, $cmbStyle); } else { $form->addVar('style', 0); } } } if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_URL))) { $form->addRow(S_URL, new CTextBox('url', $url, 60)); } else { $form->addVar('url', ''); } if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_GRAPH, SCREEN_RESOURCE_SIMPLE_GRAPH, SCREEN_RESOURCE_CLOCK, SCREEN_RESOURCE_URL))) { $form->addRow(S_WIDTH, new CNumericBox('width', $width, 5)); $form->addRow(S_HEIGHT, new CNumericBox('height', $height, 5)); } else { $form->addVar('width', 500); $form->addVar('height', 100); } if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_GRAPH, SCREEN_RESOURCE_SIMPLE_GRAPH, SCREEN_RESOURCE_MAP, SCREEN_RESOURCE_CLOCK, SCREEN_RESOURCE_URL))) { $cmbHalign = new CComboBox('halign', $halign); $cmbHalign->addItem(HALIGN_CENTER, S_CENTRE); $cmbHalign->addItem(HALIGN_LEFT, S_LEFT); $cmbHalign->addItem(HALIGN_RIGHT, S_RIGHT); $form->addRow(S_HORIZONTAL_ALIGN, $cmbHalign); } else { $form->addVar('halign', 0); } $cmbValign = new CComboBox('valign', $valign); $cmbValign->addItem(VALIGN_MIDDLE, S_MIDDLE); $cmbValign->addItem(VALIGN_TOP, S_TOP); $cmbValign->addItem(VALIGN_BOTTOM, S_BOTTOM); $form->addRow(S_VERTICAL_ALIGN, $cmbValign); $form->addRow(S_COLUMN_SPAN, new CNumericBox('colspan', $colspan, 2)); $form->addRow(S_ROW_SPAN, new CNumericBox('rowspan', $rowspan, 2)); // dynamic AddOn if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_GRAPH, SCREEN_RESOURCE_SIMPLE_GRAPH, SCREEN_RESOURCE_PLAIN_TEXT))) { $form->addRow(S_DYNAMIC_ITEM, new CCheckBox('dynamic', $dynamic, null, 1)); } $form->addItemToBottomRow(new CButton('save', S_SAVE)); if (isset($_REQUEST['screenitemid'])) { $form->addItemToBottomRow(SPACE); $form->addItemToBottomRow(new CButtonDelete(null, url_param('form') . url_param('screenid') . url_param('screenitemid'))); } $form->addItemToBottomRow(SPACE); $form->addItemToBottomRow(new CButtonCancel(url_param('screenid'))); return $form; }
public function bodyToString() { $this->cleanItems(); $ok = $uncn = $uncl = $info = $warn = $avg = $high = $dis = 0; $options = array('monitored' => 1, 'skipDependent' => 1, 'output' => API_OUTPUT_SHORTEN); if ($this->hostid > 0) { $options['hostids'] = $this->hostid; } else { if ($this->groupid > 0) { $options['groupids'] = $this->groupid; } } $triggers = CTrigger::get($options); $triggers = zbx_objectValues($triggers, 'triggerid'); $sql = 'SELECT t.priority,t.value,count(DISTINCT t.triggerid) as cnt ' . ' FROM triggers t ' . ' WHERE ' . DBcondition('t.triggerid', $triggers) . ' GROUP BY t.priority,t.value'; $db_priority = DBselect($sql); while ($row = DBfetch($db_priority)) { switch ($row['value']) { case TRIGGER_VALUE_TRUE: switch ($row['priority']) { case TRIGGER_SEVERITY_NOT_CLASSIFIED: $uncl += $row['cnt']; break; case TRIGGER_SEVERITY_INFORMATION: $info += $row['cnt']; break; case TRIGGER_SEVERITY_WARNING: $warn += $row['cnt']; break; case TRIGGER_SEVERITY_AVERAGE: $avg += $row['cnt']; break; case TRIGGER_SEVERITY_HIGH: $high += $row['cnt']; break; case TRIGGER_SEVERITY_DISASTER: $dis += $row['cnt']; break; } break; case TRIGGER_VALUE_FALSE: $ok += $row['cnt']; break; default: $uncn += $row['cnt']; break; } } if ($this->show_header) { $header_str = S_TRIGGERS_INFO . SPACE; if (!is_null($this->nodeid)) { $node = get_node_by_nodeid($this->nodeid); if ($node > 0) { $header_str .= '(' . $node['name'] . ')' . SPACE; } } if (remove_nodes_from_id($this->groupid) > 0) { $group = get_hostgroup_by_groupid($this->groupid); $header_str .= S_GROUP . SPACE . '"' . $group['name'] . '"'; } else { $header_str .= S_ALL_GROUPS; } $header = new CCol($header_str, 'header'); if ($this->style == STYLE_HORISONTAL) { $header->SetColspan(8); } $this->addRow($header); } $trok = new CCol($ok . SPACE . S_OK, get_severity_style('ok', false)); $uncn = new CCol($uncn . SPACE . S_UNKNOWN, 'unknown'); $uncl = new CCol($uncl . SPACE . S_NOT_CLASSIFIED, get_severity_style(TRIGGER_SEVERITY_NOT_CLASSIFIED, $uncl)); $info = new CCol($info . SPACE . S_INFORMATION, get_severity_style(TRIGGER_SEVERITY_INFORMATION, $info)); $warn = new CCol($warn . SPACE . S_WARNING, get_severity_style(TRIGGER_SEVERITY_WARNING, $warn)); $avg = new CCol($avg . SPACE . S_AVERAGE, get_severity_style(TRIGGER_SEVERITY_AVERAGE, $avg)); $high = new CCol($high . SPACE . S_HIGH, get_severity_style(TRIGGER_SEVERITY_HIGH, $high)); $dis = new CCol($dis . SPACE . S_DISASTER, get_severity_style(TRIGGER_SEVERITY_DISASTER, $dis)); if (STYLE_HORISONTAL == $this->style) { $this->addRow(array($trok, $uncn, $uncl, $info, $warn, $avg, $high, $dis)); } else { $this->addRow($trok); $this->addRow($uncn); $this->addRow($uncl); $this->addRow($info); $this->addRow($warn); $this->addRow($avg); $this->addRow($high); $this->addRow($dis); } return parent::BodyToString(); }
public function bodyToString() { $this->cleanItems(); $ok = $uncl = $info = $warn = $avg = $high = $dis = 0; $options = array('monitored' => true, 'skipDependent' => true, 'output' => API_OUTPUT_SHORTEN); if ($this->hostid > 0) { $options['hostids'] = $this->hostid; } elseif ($this->groupid > 0) { $options['groupids'] = $this->groupid; } $triggers = API::Trigger()->get($options); $triggers = zbx_objectValues($triggers, 'triggerid'); $db_priority = DBselect('SELECT t.priority,t.value,count(DISTINCT t.triggerid) AS cnt' . ' FROM triggers t' . ' WHERE ' . dbConditionInt('t.triggerid', $triggers) . ' GROUP BY t.priority,t.value'); while ($row = DBfetch($db_priority)) { switch ($row['value']) { case TRIGGER_VALUE_TRUE: switch ($row['priority']) { case TRIGGER_SEVERITY_NOT_CLASSIFIED: $uncl += $row['cnt']; break; case TRIGGER_SEVERITY_INFORMATION: $info += $row['cnt']; break; case TRIGGER_SEVERITY_WARNING: $warn += $row['cnt']; break; case TRIGGER_SEVERITY_AVERAGE: $avg += $row['cnt']; break; case TRIGGER_SEVERITY_HIGH: $high += $row['cnt']; break; case TRIGGER_SEVERITY_DISASTER: $dis += $row['cnt']; break; } break; case TRIGGER_VALUE_FALSE: $ok += $row['cnt']; break; } } if ($this->show_header) { $header_str = _('Triggers info') . SPACE; if (!is_null($this->nodeid)) { $node = get_node_by_nodeid($this->nodeid); if ($node > 0) { $header_str .= '(' . $node['name'] . ')' . SPACE; } } if (remove_nodes_from_id($this->groupid) > 0) { $group = get_hostgroup_by_groupid($this->groupid); $header_str .= _('Group') . SPACE . '"' . $group['name'] . '"'; } else { $header_str .= _('All groups'); } $header = new CCol($header_str, 'header'); if ($this->style == STYLE_HORISONTAL) { $header->setColspan(8); } $this->addRow($header); } $trok = getSeverityCell(null, $ok . SPACE . _('Ok'), true); $uncl = getSeverityCell(TRIGGER_SEVERITY_NOT_CLASSIFIED, $uncl . SPACE . getSeverityCaption(TRIGGER_SEVERITY_NOT_CLASSIFIED), !$uncl); $info = getSeverityCell(TRIGGER_SEVERITY_INFORMATION, $info . SPACE . getSeverityCaption(TRIGGER_SEVERITY_INFORMATION), !$info); $warn = getSeverityCell(TRIGGER_SEVERITY_WARNING, $warn . SPACE . getSeverityCaption(TRIGGER_SEVERITY_WARNING), !$warn); $avg = getSeverityCell(TRIGGER_SEVERITY_AVERAGE, $avg . SPACE . getSeverityCaption(TRIGGER_SEVERITY_AVERAGE), !$avg); $high = getSeverityCell(TRIGGER_SEVERITY_HIGH, $high . SPACE . getSeverityCaption(TRIGGER_SEVERITY_HIGH), !$high); $dis = getSeverityCell(TRIGGER_SEVERITY_DISASTER, $dis . SPACE . getSeverityCaption(TRIGGER_SEVERITY_DISASTER), !$dis); if (STYLE_HORISONTAL == $this->style) { $this->addRow(array($trok, $uncl, $info, $warn, $avg, $high, $dis)); } else { $this->addRow($trok); $this->addRow($uncl); $this->addRow($info); $this->addRow($warn); $this->addRow($avg); $this->addRow($high); $this->addRow($dis); } return parent::bodyToString(); }
function get_screen_item_form() { global $USER_DETAILS; $available_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY, PERM_RES_IDS_ARRAY, get_current_nodeid(true)); $form = new CFormTable(S_SCREEN_CELL_CONFIGURATION, 'screenedit.php#form'); $form->SetHelp('web.screenedit.cell.php'); if (isset($_REQUEST['screenitemid'])) { $iresult = DBSelect('SELECT * FROM screens_items' . ' WHERE screenid=' . $_REQUEST['screenid'] . ' AND screenitemid=' . $_REQUEST['screenitemid']); $form->AddVar('screenitemid', $_REQUEST['screenitemid']); } else { $form->AddVar('x', $_REQUEST['x']); $form->AddVar('y', $_REQUEST['y']); } if (isset($_REQUEST['screenitemid']) && !isset($_REQUEST['form_refresh'])) { $irow = DBfetch($iresult); $resourcetype = $irow['resourcetype']; $resourceid = $irow['resourceid']; $width = $irow['width']; $height = $irow['height']; $colspan = $irow['colspan']; $rowspan = $irow['rowspan']; $elements = $irow['elements']; $valign = $irow['valign']; $halign = $irow['halign']; $style = $irow['style']; $url = $irow['url']; $dynamic = $irow['dynamic']; } else { $resourcetype = get_request('resourcetype', 0); $resourceid = get_request('resourceid', 0); $width = get_request('width', 500); $height = get_request('height', 100); $colspan = get_request('colspan', 0); $rowspan = get_request('rowspan', 0); $elements = get_request('elements', 25); $valign = get_request('valign', VALIGN_DEFAULT); $halign = get_request('halign', HALIGN_DEFAULT); $style = get_request('style', 0); $url = get_request('url', ''); $dynamic = get_request('dynamic', SCREEN_SIMPLE_ITEM); } $form->addVar('screenid', $_REQUEST['screenid']); $cmbRes = new CCombobox('resourcetype', $resourcetype, 'submit()'); $cmbRes->addItem(SCREEN_RESOURCE_GRAPH, S_GRAPH); $cmbRes->addItem(SCREEN_RESOURCE_SIMPLE_GRAPH, S_SIMPLE_GRAPH); $cmbRes->addItem(SCREEN_RESOURCE_PLAIN_TEXT, S_PLAIN_TEXT); $cmbRes->addItem(SCREEN_RESOURCE_MAP, S_MAP); $cmbRes->addItem(SCREEN_RESOURCE_SCREEN, S_SCREEN); $cmbRes->addItem(SCREEN_RESOURCE_SERVER_INFO, S_SERVER_INFO); $cmbRes->addItem(SCREEN_RESOURCE_HOSTS_INFO, S_HOSTS_INFO); $cmbRes->addItem(SCREEN_RESOURCE_TRIGGERS_INFO, S_TRIGGERS_INFO); $cmbRes->addItem(SCREEN_RESOURCE_TRIGGERS_OVERVIEW, S_TRIGGERS_OVERVIEW); $cmbRes->addItem(SCREEN_RESOURCE_STATUS_OF_TRIGGERS, S_STATUS_OF_TRIGGERS); $cmbRes->addItem(SCREEN_RESOURCE_DATA_OVERVIEW, S_DATA_OVERVIEW); $cmbRes->addItem(SCREEN_RESOURCE_CLOCK, S_CLOCK); $cmbRes->addItem(SCREEN_RESOURCE_URL, S_URL); $cmbRes->addItem(SCREEN_RESOURCE_ACTIONS, S_HISTORY_OF_ACTIONS); $cmbRes->addItem(SCREEN_RESOURCE_EVENTS, S_HISTORY_OF_EVENTS); $form->addRow(S_RESOURCE, $cmbRes); if ($resourcetype == SCREEN_RESOURCE_GRAPH) { // User-defined graph $resourceid = graph_accessible($resourceid) ? $resourceid : 0; $caption = ''; $id = 0; if ($resourceid > 0) { $result = DBselect('SELECT DISTINCT g.graphid,g.name,n.name as node_name, h.host' . ' FROM graphs g ' . ' LEFT JOIN graphs_items gi ON g.graphid=gi.graphid ' . ' LEFT JOIN items i ON gi.itemid=i.itemid ' . ' LEFT JOIN hosts h ON h.hostid=i.hostid ' . ' LEFT JOIN nodes n ON n.nodeid=' . DBid2nodeid('g.graphid') . ' WHERE g.graphid=' . $resourceid); while ($row = DBfetch($result)) { $row['node_name'] = isset($row['node_name']) ? '(' . $row['node_name'] . ') ' : ''; $caption = $row['node_name'] . $row['host'] . ':' . $row['name']; $id = $resourceid; } } $form->addVar('resourceid', $id); $textfield = new Ctextbox('caption', $caption, 75, 'yes'); $selectbtn = new Cbutton('select', S_SELECT, "javascript: return PopUp('popup.php?dstfrm=" . $form->getName() . "&dstfld1=resourceid&dstfld2=caption&srctbl=graphs&srcfld1=graphid&srcfld2=name',800,450);"); $selectbtn->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';"); $form->AddRow(S_GRAPH_NAME, array($textfield, SPACE, $selectbtn)); } else { if ($resourcetype == SCREEN_RESOURCE_SIMPLE_GRAPH) { // Simple graph $caption = ''; $id = 0; if ($resourceid > 0) { $result = DBselect('SELECT n.name as node_name,h.host,i.description,i.itemid,i.key_ ' . ' FROM hosts h,items i ' . ' LEFT JOIN nodes n on n.nodeid=' . DBid2nodeid('i.itemid') . ' WHERE h.hostid=i.hostid ' . ' AND h.status=' . HOST_STATUS_MONITORED . ' AND i.status=' . ITEM_STATUS_ACTIVE . ' AND ' . DBcondition('i.hostid', $available_hosts) . ' AND i.itemid=' . $resourceid); while ($row = DBfetch($result)) { $description_ = item_description($row); $row["node_name"] = isset($row["node_name"]) ? "(" . $row["node_name"] . ") " : ''; $caption = $row['node_name'] . $row['host'] . ': ' . $description_; $id = $resourceid; } } $form->AddVar('resourceid', $id); $textfield = new Ctextbox('caption', $caption, 75, 'yes'); $selectbtn = new Cbutton('select', S_SELECT, "javascript: return PopUp('popup.php?dstfrm=" . $form->getName() . "&dstfld1=resourceid&dstfld2=caption&srctbl=simple_graph&srcfld1=itemid&srcfld2=description',800,450);"); $selectbtn->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';"); $form->AddRow(S_PARAMETER, array($textfield, SPACE, $selectbtn)); } else { if ($resourcetype == SCREEN_RESOURCE_MAP) { // Map $caption = ''; $id = 0; if ($resourceid > 0) { $result = DBselect('SELECT n.name as node_name, s.sysmapid,s.name ' . ' FROM sysmaps s' . ' LEFT JOIN nodes n ON n.nodeid=' . DBid2nodeid('s.sysmapid') . ' WHERE s.sysmapid=' . $resourceid); while ($row = DBfetch($result)) { if (!sysmap_accessible($row['sysmapid'], PERM_READ_ONLY)) { continue; } $row['node_name'] = isset($row['node_name']) ? '(' . $row['node_name'] . ') ' : ''; $caption = $row['node_name'] . $row['name']; $id = $resourceid; } } $form->AddVar('resourceid', $id); $textfield = new Ctextbox('caption', $caption, 60, 'yes'); $selectbtn = new Cbutton('select', S_SELECT, "javascript: return PopUp('popup.php?dstfrm=" . $form->getName() . "&dstfld1=resourceid&dstfld2=caption&srctbl=sysmaps&srcfld1=sysmapid&srcfld2=name',400,450);"); $selectbtn->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';"); $form->AddRow(S_PARAMETER, array($textfield, SPACE, $selectbtn)); } else { if ($resourcetype == SCREEN_RESOURCE_PLAIN_TEXT) { // Plain text $caption = ''; $id = 0; if ($resourceid > 0) { $result = DBselect('SELECT n.name as node_name,h.host,i.description,i.itemid,i.key_ ' . ' FROM hosts h,items i ' . ' LEFT JOIN nodes n on n.nodeid=' . DBid2nodeid('i.itemid') . ' WHERE h.hostid=i.hostid ' . ' AND h.status=' . HOST_STATUS_MONITORED . ' AND i.status=' . ITEM_STATUS_ACTIVE . ' AND ' . DBcondition('i.hostid', $available_hosts) . ' AND i.itemid=' . $resourceid); while ($row = DBfetch($result)) { $description_ = item_description($row); $row["node_name"] = isset($row["node_name"]) ? '(' . $row["node_name"] . ') ' : ''; $caption = $row['node_name'] . $row['host'] . ': ' . $description_; $id = $resourceid; } } $form->AddVar('resourceid', $id); $textfield = new Ctextbox('caption', $caption, 75, 'yes'); $selectbtn = new Cbutton('select', S_SELECT, "javascript: return PopUp('popup.php?dstfrm=" . $form->getName() . "&dstfld1=resourceid&dstfld2=caption&srctbl=plain_text&srcfld1=itemid&srcfld2=description',800,450);"); $selectbtn->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';"); $form->addRow(S_PARAMETER, array($textfield, SPACE, $selectbtn)); $form->addRow(S_SHOW_LINES, new CNumericBox('elements', $elements, 2)); $form->addRow(S_SHOW_TEXT_AS_HTML, new CCheckBox('style', $style, null, 1)); } else { if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_EVENTS, SCREEN_RESOURCE_STATUS_OF_TRIGGERS, SCREEN_RESOURCE_ACTIONS))) { // History of actions // History of events // Status of triggers $form->addRow(S_SHOW_LINES, new CNumericBox('elements', $elements, 2)); $form->addVar('resourceid', 0); } else { if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_TRIGGERS_OVERVIEW, SCREEN_RESOURCE_DATA_OVERVIEW))) { // Overviews $caption = ''; $id = 0; if ($resourceid > 0) { $available_groups = get_accessible_groups_by_user($USER_DETAILS, PERM_READ_ONLY); $result = DBselect('SELECT DISTINCT n.name as node_name,g.groupid,g.name ' . ' FROM hosts_groups hg,hosts h,groups g ' . ' LEFT JOIN nodes n ON n.nodeid=' . DBid2nodeid('g.groupid') . ' WHERE ' . DBcondition('g.groupid', $available_groups) . ' AND g.groupid=hg.groupid ' . ' AND hg.hostid=h.hostid ' . ' AND h.status=' . HOST_STATUS_MONITORED . ' AND g.groupid=' . $resourceid); while ($row = DBfetch($result)) { $row['node_name'] = isset($row['node_name']) ? '(' . $row['node_name'] . ') ' : ''; $caption = $row['node_name'] . $row['name']; $id = $resourceid; } } $form->AddVar('resourceid', $id); $textfield = new Ctextbox('caption', $caption, 75, 'yes'); $selectbtn = new Cbutton('select', S_SELECT, "javascript: return PopUp('popup.php?dstfrm=" . $form->getName() . "&dstfld1=resourceid&dstfld2=caption&srctbl=overview&srcfld1=groupid&srcfld2=name',800,450);"); $selectbtn->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';"); $form->AddRow(S_GROUP, array($textfield, SPACE, $selectbtn)); } else { if ($resourcetype == SCREEN_RESOURCE_SCREEN) { // Screens $caption = ''; $id = 0; if ($resourceid > 0) { $result = DBselect('SELECT DISTINCT n.name as node_name,s.screenid,s.name ' . ' FROM screens s ' . ' LEFT JOIN nodes n ON n.nodeid=' . DBid2nodeid('s.screenid') . ' WHERE s.screenid=' . $resourceid); while ($row = DBfetch($result)) { if (!screen_accessible($row['screenid'], PERM_READ_ONLY)) { continue; } if (check_screen_recursion($_REQUEST['screenid'], $row['screenid'])) { continue; } $row['node_name'] = isset($row['node_name']) ? '(' . $row['node_name'] . ') ' : ''; $caption = $row['node_name'] . $row['name']; $id = $resourceid; } } $form->addVar('resourceid', $id); $textfield = new Ctextbox('caption', $caption, 60, 'yes'); $selectbtn = new Cbutton('select', S_SELECT, "javascript: return PopUp('popup.php?dstfrm=" . $form->getName() . "&dstfld1=resourceid&dstfld2=caption&srctbl=screens2&srcfld1=screenid&srcfld2=name&screenid=" . $_REQUEST['screenid'] . "',800,450);"); $selectbtn->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';"); $form->AddRow(S_PARAMETER, array($textfield, SPACE, $selectbtn)); } else { if ($resourcetype == SCREEN_RESOURCE_HOSTS_INFO || $resourcetype == SCREEN_RESOURCE_TRIGGERS_INFO) { // HOSTS info $caption = ''; $id = 0; $available_groups = get_accessible_groups_by_user($USER_DETAILS, PERM_READ_ONLY); if (remove_nodes_from_id($resourceid) > 0) { $result = DBselect('SELECT DISTINCT n.name as node_name,g.groupid,g.name ' . ' FROM hosts_groups hg, groups g ' . ' LEFT JOIN nodes n ON n.nodeid=' . DBid2nodeid('g.groupid') . ' WHERE ' . DBcondition('g.groupid', $available_groups) . ' AND g.groupid=' . $resourceid); while ($row = DBfetch($result)) { $row['node_name'] = isset($row['node_name']) ? '(' . $row['node_name'] . ') ' : ''; $caption = $row['node_name'] . $row['name']; $id = $resourceid; } } else { if (remove_nodes_from_id($resourceid) == 0) { $result = DBselect('SELECT DISTINCT n.name as node_name ' . ' FROM nodes n ' . ' WHERE n.nodeid=' . id2nodeid($resourceid)); while ($row = DBfetch($result)) { $row['node_name'] = isset($row['node_name']) ? '(' . $row['node_name'] . ') ' : ''; $caption = $row['node_name'] . S_MINUS_ALL_GROUPS_MINUS; $id = $resourceid; } } } $form->AddVar('resourceid', $id); $textfield = new CTextbox('caption', $caption, 60, 'yes'); $selectbtn = new Cbutton('select', S_SELECT, "javascript: return PopUp('popup.php?dstfrm=" . $form->getName() . "&dstfld1=resourceid&dstfld2=caption&srctbl=host_group_scr&srcfld1=groupid&srcfld2=name',480,450);"); $selectbtn->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';"); $form->AddRow(S_GROUP, array($textfield, SPACE, $selectbtn)); } else { // SCREEN_RESOURCE_CLOCK $form->addVar('resourceid', 0); } } } } } } } } if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_HOSTS_INFO, SCREEN_RESOURCE_TRIGGERS_INFO))) { $cmbStyle = new CComboBox("style", $style); $cmbStyle->AddItem(STYLE_HORISONTAL, S_HORIZONTAL); $cmbStyle->AddItem(STYLE_VERTICAL, S_VERTICAL); $form->AddRow(S_STYLE, $cmbStyle); } else { if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_TRIGGERS_OVERVIEW, SCREEN_RESOURCE_DATA_OVERVIEW))) { $cmbStyle = new CComboBox('style', $style); $cmbStyle->AddItem(STYLE_LEFT, S_LEFT); $cmbStyle->AddItem(STYLE_TOP, S_TOP); $form->AddRow(S_HOSTS_LOCATION, $cmbStyle); } else { if ($resourcetype == SCREEN_RESOURCE_CLOCK) { $cmbStyle = new CComboBox('style', $style); $cmbStyle->AddItem(TIME_TYPE_LOCAL, S_LOCAL_TIME); $cmbStyle->AddItem(TIME_TYPE_SERVER, S_SERVER_TIME); $form->AddRow(S_TIME_TYPE, $cmbStyle); } else { $form->AddVar('style', 0); } } } if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_URL))) { $form->AddRow(S_URL, new CTextBox('url', $url, 60)); } else { $form->AddVar('url', ''); } if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_GRAPH, SCREEN_RESOURCE_SIMPLE_GRAPH, SCREEN_RESOURCE_CLOCK, SCREEN_RESOURCE_URL))) { $form->AddRow(S_WIDTH, new CNumericBox('width', $width, 5)); $form->AddRow(S_HEIGHT, new CNumericBox('height', $height, 5)); } else { $form->AddVar('width', 500); $form->AddVar('height', 100); } if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_GRAPH, SCREEN_RESOURCE_SIMPLE_GRAPH, SCREEN_RESOURCE_MAP, SCREEN_RESOURCE_CLOCK, SCREEN_RESOURCE_URL))) { $cmbHalign = new CComboBox('halign', $halign); $cmbHalign->AddItem(HALIGN_CENTER, S_CENTRE); $cmbHalign->AddItem(HALIGN_LEFT, S_LEFT); $cmbHalign->AddItem(HALIGN_RIGHT, S_RIGHT); $form->AddRow(S_HORIZONTAL_ALIGN, $cmbHalign); } else { $form->AddVar('halign', 0); } $cmbValign = new CComboBox('valign', $valign); $cmbValign->AddItem(VALIGN_MIDDLE, S_MIDDLE); $cmbValign->AddItem(VALIGN_TOP, S_TOP); $cmbValign->AddItem(VALIGN_BOTTOM, S_BOTTOM); $form->AddRow(S_VERTICAL_ALIGN, $cmbValign); $form->AddRow(S_COLUMN_SPAN, new CNumericBox('colspan', $colspan, 2)); $form->AddRow(S_ROW_SPAN, new CNumericBox('rowspan', $rowspan, 2)); // dynamic AddOn if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_GRAPH, SCREEN_RESOURCE_SIMPLE_GRAPH, SCREEN_RESOURCE_PLAIN_TEXT))) { $form->AddRow(S_DYNAMIC_ITEM, new CCheckBox('dynamic', $dynamic, null, 1)); } $form->AddItemToBottomRow(new CButton('save', S_SAVE)); if (isset($_REQUEST['screenitemid'])) { $form->addItemToBottomRow(SPACE); $form->addItemToBottomRow(new CButtonDelete(null, url_param('form') . url_param('screenid') . url_param('screenitemid'))); } $form->addItemToBottomRow(SPACE); $form->addItemToBottomRow(new CButtonCancel(url_param('screenid'))); return $form; }