CProfile::update('web.tr_status.filter.status_change', $_REQUEST['status_change'], PROFILE_TYPE_INT); CProfile::update('web.tr_status.filter.status_change_days', $_REQUEST['status_change_days'], PROFILE_TYPE_INT); } $show_triggers = $_REQUEST['show_triggers']; $show_events = $_REQUEST['show_events']; $show_severity = $_REQUEST['show_severity']; $ack_status = $_REQUEST['ack_status']; // -------------- validate_sort_and_sortorder('lastchange', ZBX_SORT_DOWN); $mute = CProfile::get('web.tr_status.mute', 0); if (isset($audio) && !$mute) { play_sound($audio); } $trigg_wdgt = new CWidget(); $r_form = new CForm(null, 'get'); $r_form->addItem(array(S_GROUP . SPACE, $pageFilter->getGroupsCB(true))); $r_form->addItem(array(SPACE . S_HOST . SPACE, $pageFilter->getHostsCB(true))); $r_form->addVar('fullscreen', $_REQUEST['fullscreen']); $fs_icon = get_icon('fullscreen', array('fullscreen' => $_REQUEST['fullscreen'])); $trigg_wdgt->addPageHeader(S_STATUS_OF_TRIGGERS_BIG . ' [' . date(S_DATE_FORMAT_YMDHMS) . ']', array($fs_icon)); $numrows = new CDiv(); $numrows->setAttribute('name', 'numrows'); $trigg_wdgt->addHeader(S_TRIGGERS_BIG, $r_form); $trigg_wdgt->addHeader($numrows); /************************* FILTER **************************/ /***********************************************************/ $filterForm = new CFormTable(null, null, 'get'); //,'tr_status.php?filter_set=1','POST',null,'sform'); $filterForm->setAttribute('name', 'zbx_filter'); $filterForm->setAttribute('id', 'zbx_filter'); $filterForm->addVar('fullscreen', $_REQUEST['fullscreen']);
*/ if (get_request('groupid') && !API::HostGroup()->isReadable(array($_REQUEST['groupid']))) { access_deny(); } if (get_request('hostid') && !API::Host()->isReadable(array($_REQUEST['hostid']))) { access_deny(); } validate_sort_and_sortorder('name', ZBX_SORT_DOWN); $options = array('groups' => array('real_hosts' => true, 'with_httptests' => true), 'hosts' => array('with_monitored_items' => true, 'with_httptests' => true), 'hostid' => get_request('hostid', null), 'groupid' => get_request('groupid', null)); $pageFilter = new CPageFilter($options); $_REQUEST['groupid'] = $pageFilter->groupid; $_REQUEST['hostid'] = $pageFilter->hostid; $displayNodes = is_array(get_current_nodeid()) && $pageFilter->groupid == 0 && $pageFilter->hostid == 0; $r_form = new CForm('get'); $r_form->addVar('fullscreen', $_REQUEST['fullscreen']); $r_form->addItem(array(_('Group') . SPACE, $pageFilter->getGroupsCB(true))); $r_form->addItem(array(SPACE . _('Host') . SPACE, $pageFilter->getHostsCB(true))); $httpmon_wdgt = new CWidget(); $httpmon_wdgt->addPageHeader(_('STATUS OF WEB MONITORING'), get_icon('fullscreen', array('fullscreen' => $_REQUEST['fullscreen']))); $httpmon_wdgt->addHeader(_('Web scenarios'), $r_form); $httpmon_wdgt->addHeaderRowNumber(); // TABLE $table = new CTableInfo(_('No web scenarios found.')); $table->SetHeader(array($displayNodes ? _('Node') : null, $_REQUEST['hostid'] == 0 ? make_sorting_header(_('Host'), 'hostname') : null, make_sorting_header(_('Name'), 'name'), _('Number of steps'), _('Last check'), _('Status'))); $paging = null; if ($pageFilter->hostsSelected) { $options = array('output' => array('httptestid'), 'templated' => false, 'filter' => array('status' => HTTPTEST_STATUS_ACTIVE), 'limit' => $config['search_limit'] + 1); if ($pageFilter->hostid > 0) { $options['hostids'] = $pageFilter->hostid; } elseif ($pageFilter->groupid > 0) { $options['groupids'] = $pageFilter->groupid;
$_REQUEST['groupid'] = $pageFilter->groupid; $_REQUEST['groupby'] = getRequest('groupby', ''); $groupFieldTitle = ''; $hostinvent_wdgt = (new CWidget())->setTitle(_('Host inventory overview')); // getting inventory fields to make a drop down $inventoryFields = getHostInventories(true); // 'true' means list should be ordered by title $inventoryFieldsComboBox = new CComboBox('groupby', $_REQUEST['groupby'], 'submit()'); $inventoryFieldsComboBox->addItem('', _('not selected')); foreach ($inventoryFields as $inventoryField) { $inventoryFieldsComboBox->addItem($inventoryField['db_field'], $inventoryField['title'], $_REQUEST['groupby'] === $inventoryField['db_field'] ? 'yes' : null); if ($_REQUEST['groupby'] === $inventoryField['db_field']) { $groupFieldTitle = $inventoryField['title']; } } $controls = (new CList())->addItem([_('Group') . SPACE, $pageFilter->getGroupsCB()])->addItem([_('Grouping by') . SPACE, $inventoryFieldsComboBox]); $hostinvent_wdgt->setControls((new CForm('get'))->addItem($controls)); $table = (new CTableInfo())->setHeader([make_sorting_header($groupFieldTitle === '' ? _('Field') : $groupFieldTitle, 'inventory_field', $sortField, $sortOrder), make_sorting_header(_('Host count'), 'host_count', $sortField, $sortOrder)]); // to show a report, we will need a host group and a field to aggregate if ($pageFilter->groupsSelected && $groupFieldTitle !== '') { $options = ['output' => ['hostid', 'name'], 'selectInventory' => [$_REQUEST['groupby']], 'withInventory' => true]; if ($pageFilter->groupid > 0) { $options['groupids'] = $pageFilter->groupid; } $hosts = API::Host()->get($options); // aggregating data by chosen field value $report = []; foreach ($hosts as $host) { if ($host['inventory'][$_REQUEST['groupby']] !== '') { // same names with different letter casing are considered the same $lowerValue = mb_strtolower($host['inventory'][$_REQUEST['groupby']]);
$groupFieldTitle = ''; $hostinvent_wdgt = new CWidget(); $hostinvent_wdgt->addPageHeader(_('HOST INVENTORY OVERVIEW')); // getting inventory fields to make a drop down $inventoryFields = getHostInventories(true); // 'true' means list should be ordered by title $inventoryFieldsComboBox = new CComboBox('groupby', $_REQUEST['groupby'], 'submit()'); $inventoryFieldsComboBox->addItem('', _('not selected')); foreach ($inventoryFields as $inventoryField) { $inventoryFieldsComboBox->addItem($inventoryField['db_field'], $inventoryField['title'], $_REQUEST['groupby'] === $inventoryField['db_field'] ? 'yes' : null); if ($_REQUEST['groupby'] === $inventoryField['db_field']) { $groupFieldTitle = $inventoryField['title']; } } $r_form = new CForm('get'); $r_form->addItem(array(_('Group'), SPACE, $pageFilter->getGroupsCB(), SPACE)); $r_form->addItem(array(_('Grouping by'), SPACE, $inventoryFieldsComboBox)); $hostinvent_wdgt->addHeader(_('Hosts'), $r_form); $hostinvent_wdgt->addItem(BR()); $table = new CTableInfo(_('No hosts found.')); $table->setHeader(array(make_sorting_header($groupFieldTitle === '' ? _('Field') : $groupFieldTitle, 'inventory_field', $sortField, $sortOrder), make_sorting_header(_('Host count'), 'host_count', $sortField, $sortOrder))); // to show a report, we will need a host group and a field to aggregate if ($pageFilter->groupsSelected && $groupFieldTitle !== '') { $options = array('output' => array('hostid', 'name'), 'selectInventory' => array($_REQUEST['groupby']), 'withInventory' => true); if ($pageFilter->groupid > 0) { $options['groupids'] = $pageFilter->groupid; } $hosts = API::Host()->get($options); // aggregating data by chosen field value $report = array(); foreach ($hosts as $host) {
$data['linkedTemplates'] = API::Template()->get(array('templateids' => $templateIds, 'output' => array('templateid', 'name'))); CArrayHelper::sort($data['linkedTemplates'], array('name')); $templateForm = new CView('configuration.template.edit', $data); $templateWidget->addItem($templateForm->render()); } else { $sortField = getRequest('sort', CProfile::get('web.' . $page['file'] . '.sort', 'name')); $sortOrder = getRequest('sortorder', CProfile::get('web.' . $page['file'] . '.sortorder', ZBX_SORT_UP)); CProfile::update('web.' . $page['file'] . '.sort', $sortField, PROFILE_TYPE_STR); CProfile::update('web.' . $page['file'] . '.sortorder', $sortOrder, PROFILE_TYPE_STR); $frmForm = new CForm(); $frmForm->cleanItems(); $frmForm->addItem(new CDiv(array(new CSubmit('form', _('Create template')), new CButton('form', _('Import'), 'redirect("conf.import.php?rules_preset=template")')))); $frmForm->addItem(new CVar('groupid', $_REQUEST['groupid'], 'filter_groupid_id')); $templateWidget->addPageHeader(_('CONFIGURATION OF TEMPLATES'), $frmForm); $frmGroup = new CForm('get'); $frmGroup->addItem(array(_('Group') . SPACE, $pageFilter->getGroupsCB())); $templateWidget->addHeader(_('Templates'), $frmGroup); $templateWidget->addHeaderRowNumber(); $form = new CForm(); $form->setName('templates'); $table = new CTableInfo(_('No templates found.')); $table->setHeader(array(new CCheckBox('all_templates', null, "checkAll('" . $form->getName() . "', 'all_templates', 'templates');"), make_sorting_header(_('Templates'), 'name', $sortField, $sortOrder), _('Applications'), _('Items'), _('Triggers'), _('Graphs'), _('Screens'), _('Discovery'), _('Web'), _('Linked templates'), _('Linked to'))); // get templates $templates = array(); if ($pageFilter->groupsSelected) { $templates = API::Template()->get(array('output' => array('templateid', 'name'), 'groupids' => $pageFilter->groupid > 0 ? $pageFilter->groupid : null, 'editable' => true, 'sortfield' => $sortField, 'limit' => $config['search_limit'] + 1)); } // sorting && paging order_result($templates, $sortField, $sortOrder); $paging = getPagingLine($templates); $templates = API::Template()->get(array('templateids' => zbx_objectValues($templates, 'templateid'), 'editable' => true, 'output' => array('name', 'proxy_hostid'), 'selectHosts' => array('hostid', 'name', 'status'), 'selectTemplates' => array('hostid', 'name', 'status'), 'selectParentTemplates' => array('hostid', 'name', 'status'), 'selectItems' => API_OUTPUT_COUNT, 'selectTriggers' => API_OUTPUT_COUNT, 'selectGraphs' => API_OUTPUT_COUNT, 'selectApplications' => API_OUTPUT_COUNT, 'selectDiscoveries' => API_OUTPUT_COUNT, 'selectScreens' => API_OUTPUT_COUNT, 'selectHttpTests' => API_OUTPUT_COUNT, 'nopermissions' => true));
// if elementid is used to fetch an element, saving it in profile if (!$this->data['use_screen_name']) { CProfile::update('web.screens.elementid', $screen['screenid'], PROFILE_TYPE_ID); } // page header $screenWidget->addPageHeader(_('SCREENS'), array($headerForm, SPACE, get_icon('favourite', array('fav' => 'web.favorite.screenids', 'elname' => 'screenid', 'elid' => $screen['screenid'])), SPACE, get_icon('fullscreen', array('fullscreen' => $this->data['fullscreen'])))); $screenWidget->addItem(BR()); // append screens combobox to page header $headerForm = new CForm('get'); $headerForm->setName('headerForm'); $headerForm->addVar('fullscreen', $this->data['fullscreen']); $elementsComboBox = new CComboBox('elementid', $screen['screenid'], 'submit()'); foreach ($this->data['screens'] as $dbScreen) { $elementsComboBox->addItem($dbScreen['screenid'], htmlspecialchars(get_node_name_by_elid($dbScreen['screenid'], null, NAME_DELIMITER) . $dbScreen['name'])); } $headerForm->addItem(array(_('Screens') . SPACE, $elementsComboBox)); if (check_dynamic_items($screen['screenid'], 0)) { $pageFilter = new CPageFilter(array('groups' => array('monitored_hosts' => true, 'with_items' => true), 'hosts' => array('monitored_hosts' => true, 'with_items' => true, 'DDFirstLabel' => _('Default')), 'hostid' => get_request('hostid', null), 'groupid' => get_request('groupid', null))); $_REQUEST['groupid'] = $pageFilter->groupid; $_REQUEST['hostid'] = $pageFilter->hostid; $headerForm->addItem(array(SPACE, _('Group'), SPACE, $pageFilter->getGroupsCB(true))); $headerForm->addItem(array(SPACE, _('Host'), SPACE, $pageFilter->getHostsCB(true))); } $screenWidget->addHeader($screen['name'], $headerForm); // append screens to widget $screenBuilder = new CScreenBuilder(array('screenid' => $screen['screenid'], 'mode' => SCREEN_MODE_PREVIEW, 'profileIdx' => 'web.screens', 'profileIdx2' => $screen['screenid'], 'groupid' => get_request('groupid'), 'hostid' => get_request('hostid'), 'period' => $this->data['period'], 'stime' => $this->data['stime'])); $screenWidget->addItem($screenBuilder->show()); CScreenBuilder::insertScreenStandardJs(array('timeline' => $screenBuilder->timeline, 'profileIdx' => $screenBuilder->profileIdx)); $screenWidget->addItem(BR()); } return $screenWidget;
$page['hist_arg'] = array('groupid', 'hostid', 'graphid'); $page['scripts'] = array('class.calendar.js', 'scriptaculous.js?load=effects'); $page['type'] = detect_page_type(PAGE_TYPE_HTML); include_once 'include/page_header.php'; // VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION $fields = array('groupid' => array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, null), 'hostid' => array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, null), 'applicationid' => array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, null), 'itemid' => array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, null), 'timeshiftsource' => array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, null), 'timeshiftprojection' => array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, null), 'agregation' => array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, null), 'num_projection' => array(T_ZBX_STR, O_OPT, P_SYS, DB_ID, null), 'formato' => array(T_ZBX_STR, O_OPT, P_SYS, DB_ID, null), 'report_timesince' => array(T_ZBX_STR, O_OPT, null, null, 'isset({filter})'), 'report_timetill' => array(T_ZBX_STR, O_OPT, null, null, 'isset({filter})')); check_fields($fields); // --------------------------- Filtro --------------------------------------------------------------------- $options = array('groups' => array('monitored_hosts' => 1), 'hosts' => array('monitored_hosts' => 1), 'groupid' => get_request('groupid', null), 'hostid' => get_request('hostid', null)); $hostid = $_REQUEST['hostid'] = get_request('hostid', 0); $groupid = $_REQUEST['groupid'] = get_request('groupid', 0); $pageFilter = new CPageFilter($options); $filter_table = new CTable('', 'filter_config'); $filter_table->setAttribute('border', 0); $filter_table->setAttribute('width', '100%'); $cmbGroups = $pageFilter->getGroupsCB(true); $cmbHosts = $pageFilter->getHostsCB(true); $filter_table->addRow(array(array(bold(_('Group')), ': ', $cmbGroups), array(bold(_('Host')), ': ', $cmbHosts), array())); $groupids = checkAccessGroup('groupid'); $hostids = checkAccessHost('hostid'); // --------------------------- Fim Filtro --------------------------------------------------------------------- $options = array(); $options['templated_hosts'] = 1; $hosts = API::Host()->get($options); $filtroSegHosts = " hos.status <> 1 AND " . dbConditionInt('hos.hostid', zbx_objectValues($hosts, 'hostid')); $rep2_wdgt = new CWidget(); $rep2_wdgt->addPageHeader(_zeT('Not Supported Items Report')); $filter_form = new CForm(); $filter_form->setMethod('get'); $filter_form->setAttribute('name', 'zbx_filter'); $filter_form->setAttribute('id', 'zbx_filter');
** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** 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. **/ $widget = (new CWidget())->setTitle(_('Screens'))->addItem((new CList())->addClass(ZBX_STYLE_OBJECT_GROUP)->addItem([(new CSpan())->addItem(new CLink(_('All screens'), 'screenconf.php')), '/', (new CSpan())->addClass(ZBX_STYLE_SELECTED)->addItem(new CLink($data['screen']['name'], 'screens.php?elementid=' . $data['screen']['screenid'] . '&fullscreen=' . $data['fullscreen']))]))->addItem((new CFilter('web.screens.filter.state'))->addNavigator()); $controls = (new CList())->addItem(new CComboBox('config', 'screens.php', 'redirect(this.options[this.selectedIndex].value);', ['screens.php' => _('Screens'), 'slides.php' => _('Slide shows')])); // Append screens combobox to page header. $form = (new CForm())->setName('headerForm')->addVar('fullscreen', $data['fullscreen']); if (check_dynamic_items($data['screen']['screenid'], 0)) { $pageFilter = new CPageFilter(['groups' => ['monitored_hosts' => true, 'with_items' => true], 'hosts' => ['monitored_hosts' => true, 'with_items' => true, 'DDFirstLabel' => _('not selected')], 'hostid' => getRequest('hostid'), 'groupid' => getRequest('groupid')]); $_REQUEST['groupid'] = $pageFilter->groupid; $_REQUEST['hostid'] = $pageFilter->hostid; $controls->addItem([_('Group') . SPACE, $pageFilter->getGroupsCB()])->addItem([_('Host') . SPACE, $pageFilter->getHostsCB()]); } // page header $controls->addItem($data['screen']['editable'] ? (new CButton('edit', _('Edit screen')))->onClick('redirect("screenedit.php?screenid=' . $data['screen']['screenid'] . '")') : null)->addItem(get_icon('favourite', ['fav' => 'web.favorite.screenids', 'elname' => 'screenid', 'elid' => $data['screen']['screenid']]))->addItem(get_icon('fullscreen', ['fullscreen' => $data['fullscreen']])); $form->addItem($controls); $widget->setControls($form); // Append screens to widget. $screenBuilder = new CScreenBuilder(['screenid' => $data['screen']['screenid'], 'mode' => SCREEN_MODE_PREVIEW, 'profileIdx' => 'web.screens', 'profileIdx2' => $data['screen']['screenid'], 'groupid' => getRequest('groupid'), 'hostid' => getRequest('hostid'), 'period' => $data['period'], 'stime' => $data['stime']]); $widget->addItem((new CDiv($screenBuilder->show()))->addClass(ZBX_STYLE_TABLE_FORMS_CONTAINER)); CScreenBuilder::insertScreenStandardJs(['timeline' => $screenBuilder->timeline, 'profileIdx' => $screenBuilder->profileIdx]); return $widget;
$frmTitle->addItem(array(SPACE, _('Node'), SPACE, $nodeComboBox, SPACE)); } /* * Only host id */ if (isset($onlyHostid)) { $only_hosts = API::Host()->get(array('hostids' => $hostid, 'templated_hosts' => true, 'output' => array('hostid', 'host'), 'limit' => 1)); $host = reset($only_hosts); $cmbHosts = new CComboBox('hostid', $hostid); $cmbHosts->addItem($hostid, $host['host']); $cmbHosts->setEnabled('disabled'); $cmbHosts->setAttribute('title', _('You can not switch hosts for current selection.')); $frmTitle->addItem(array(SPACE, _('Host'), SPACE, $cmbHosts)); } else { if (str_in_array($srctbl, array('triggers', 'items', 'applications', 'graphs', 'templates', 'hosts', 'host_templates'))) { $frmTitle->addItem(array(_('Group'), SPACE, $pageFilter->getGroupsCB())); } if (str_in_array($srctbl, array('help_items'))) { $itemtype = get_request('itemtype', 0); $cmbTypes = new CComboBox('itemtype', $itemtype, 'javascript: submit();'); foreach ($allowed_item_types as $type) { $cmbTypes->addItem($type, item_type2str($type)); } $frmTitle->addItem(array(_('Type'), SPACE, $cmbTypes)); } if (str_in_array($srctbl, array('triggers', 'items', 'applications', 'graphs'))) { $frmTitle->addItem(array(SPACE, _('Host'), SPACE, $pageFilter->getHostsCB())); } } if (str_in_array($srctbl, array('applications', 'triggers'))) { if (zbx_empty($noempty)) {
$frmForm->addVar('groupid', $pageFilter->groupid, 'groupid_csv'); $frmForm->addVar('hostid', $pageFilter->hostid, 'hostid_csv'); if ($triggerId) { $frmForm->addVar('triggerid', $triggerId, 'triggerid_csv'); } } $frmForm->addVar('fullscreen', getRequest('fullscreen')); $frmForm->addVar('stime', $stime); $frmForm->addVar('period', $period); $controls = new CList(); // add host and group filters to the form if ($source == EVENT_SOURCE_TRIGGERS) { if (getRequest('triggerid') != 0) { $frmForm->addVar('triggerid', getRequest('triggerid'), 'triggerid_filter'); } $controls->addItem([_('Group'), SPACE, $pageFilter->getGroupsCB()]); $controls->addItem([_('Host'), SPACE, $pageFilter->getHostsCB()]); } if ($allow_discovery) { $controls->addItem([_('Source'), SPACE, new CComboBox('source', $source, 'submit()', [EVENT_SOURCE_TRIGGERS => _('Trigger'), EVENT_SOURCE_DISCOVERY => _('Discovery')])]); } $controls->addItem(new CSubmit('csv_export', _('Export to CSV'))); $controls->addItem(get_icon('fullscreen', ['fullscreen' => getRequest('fullscreen')])); $frmForm->addItem($controls); $eventsWidget->setControls($frmForm); $filterForm = (new CFilter('web.events.filter.state'))->addVar('fullscreen', getRequest('fullscreen')); if ($source == EVENT_SOURCE_TRIGGERS) { $filterForm->addVar('triggerid', $triggerId)->addVar('stime', $stime)->addVar('period', $period); $filterForm->addVar('groupid', $pageFilter->groupid); $filterForm->addVar('hostid', $pageFilter->hostid); if ($triggerId > 0) {
$db_nodes = DBselect('SELECT * FROM nodes WHERE ' . DBcondition('nodeid', $available_nodes)); while ($node_data = DBfetch($db_nodes)) { $cmbNode->addItem($node_data['nodeid'], $node_data['name']); if (bccomp($nodeid, $node_data['nodeid']) == 0) { $ok = true; } } $frmTitle->addItem(array(SPACE, S_NODE, SPACE, $cmbNode, SPACE)); } } if (!isset($ok)) { $nodeid = get_current_nodeid(); } unset($ok); if (str_in_array($srctbl, array('hosts_and_templates', 'hosts', 'templates', 'triggers', 'items', 'applications', 'host_templates', 'graphs', 'simple_graph', 'plain_text'))) { $frmTitle->addItem(array(S_GROUP, SPACE, $pageFilter->getGroupsCB(true))); } if (str_in_array($srctbl, array('help_items'))) { $itemtype = get_request('itemtype', CProfile::get('web.popup.itemtype', 0)); $cmbTypes = new CComboBox('itemtype', $itemtype, 'javascript: submit();'); foreach ($allowed_item_types as $type) { $cmbTypes->addItem($type, item_type2str($type)); } $frmTitle->addItem(array(S_TYPE, SPACE, $cmbTypes)); } if (str_in_array($srctbl, array('triggers', 'items', 'applications', 'graphs', 'simple_graph', 'plain_text'))) { $frmTitle->addItem(array(SPACE, S_HOST, SPACE, $pageFilter->getHostsCB(true))); } if (str_in_array($srctbl, array('triggers', 'hosts', 'host_group', 'hosts_and_templates'))) { $value1 = isset($_REQUEST['dstfld1']) && zbx_strpos($_REQUEST['dstfld1'], 'id') !== false ? 0 : ''; $value2 = isset($_REQUEST['dstfld2']) && zbx_strpos($_REQUEST['dstfld2'], 'id') !== false ? 0 : '';
$frmForm->addVar('groupid', getRequest('groupid'), 'groupid_csv'); $frmForm->addVar('hostid', getRequest('hostid'), 'hostid_csv'); } } $frmForm->addItem(new CSubmit('csv_export', _('Export to CSV'))); $eventsWidget->addPageHeader(_('HISTORY OF EVENTS') . SPACE . '[' . zbx_date2str(DATE_TIME_FORMAT_SECONDS) . ']', array($frmForm, SPACE, get_icon('fullscreen', array('fullscreen' => getRequest('fullscreen'))))); $headerForm = new CForm('get'); $headerForm->addVar('fullscreen', getRequest('fullscreen')); $headerForm->addVar('stime', $stime); $headerForm->addVar('period', $period); // add host and group filters to the form if ($source == EVENT_SOURCE_TRIGGERS) { if (getRequest('triggerid') != 0) { $headerForm->addVar('triggerid', getRequest('triggerid'), 'triggerid_filter'); } $headerForm->addItem(array(_('Group') . SPACE, $pageFilter->getGroupsCB())); $headerForm->addItem(array(SPACE . _('Host') . SPACE, $pageFilter->getHostsCB())); } if ($allow_discovery) { $cmbSource = new CComboBox('source', $source, 'submit()'); $cmbSource->addItem(EVENT_SOURCE_TRIGGERS, _('Trigger')); $cmbSource->addItem(EVENT_SOURCE_DISCOVERY, _('Discovery')); $headerForm->addItem(array(SPACE . _('Source') . SPACE, $cmbSource)); } $eventsWidget->addHeader(_('Events'), $headerForm); $eventsWidget->addHeaderRowNumber(); $filterForm = null; if ($source == EVENT_SOURCE_TRIGGERS) { $filterForm = new CFormTable(null, null, 'get'); $filterForm->setTableClass('formtable old-filter'); $filterForm->setAttribute('name', 'zbx_filter');
$data['hostsAllowed'] = API::Host()->get(['output' => ['hostid', 'name', 'flags'], 'hostids' => $hostIdsLinkedTo, 'templated_hosts' => true, 'editable' => true, 'preservekeys' => true, 'filter' => ['flags' => ZBX_FLAG_DISCOVERY_NORMAL]]); CArrayHelper::sort($data['hostsAllowed'], ['name']); // Select selected hosts including read only. $data['hostsAll'] = API::Host()->get(['output' => ['hostid', 'name', 'flags'], 'hostids' => $hostIdsLinkedTo, 'templated_hosts' => true]); CArrayHelper::sort($data['hostsAll'], ['name']); $data['hostIdsLinkedTo'] = $hostIdsLinkedTo; $data['templateId'] = $templateId; $templateForm = new CView('configuration.template.edit', $data); $templateWidget->addItem($templateForm->render()); } else { $sortField = getRequest('sort', CProfile::get('web.' . $page['file'] . '.sort', 'name')); $sortOrder = getRequest('sortorder', CProfile::get('web.' . $page['file'] . '.sortorder', ZBX_SORT_UP)); CProfile::update('web.' . $page['file'] . '.sort', $sortField, PROFILE_TYPE_STR); CProfile::update('web.' . $page['file'] . '.sortorder', $sortOrder, PROFILE_TYPE_STR); $config = select_config(); $controls = (new CList())->addItem([_('Group'), SPACE, $pageFilter->getGroupsCB()])->addItem(new CSubmit('form', _('Create template')))->addItem((new CButton('form', _('Import')))->onClick('redirect("conf.import.php?rules_preset=template")')); $frmForm = (new CForm('get'))->cleanItems()->addItem($controls); $templateWidget->setControls($frmForm); $form = (new CForm())->setName('templates'); $table = (new CTableInfo())->setHeader([(new CColHeader((new CCheckBox('all_templates'))->onClick("checkAll('" . $form->getName() . "', 'all_templates', 'templates');")))->addClass(ZBX_STYLE_CELL_WIDTH), make_sorting_header(_('Templates'), 'name', $sortField, $sortOrder), _('Applications'), _('Items'), _('Triggers'), _('Graphs'), _('Screens'), _('Discovery'), _('Web'), _('Linked templates'), _('Linked to')]); // get templates $templates = []; if ($pageFilter->groupsSelected) { $templates = API::Template()->get(['output' => ['templateid', $sortField], 'groupids' => $pageFilter->groupid > 0 ? $pageFilter->groupid : null, 'editable' => true, 'sortfield' => $sortField, 'limit' => $config['search_limit'] + 1]); } // sorting && paging order_result($templates, $sortField, $sortOrder); $url = (new CUrl('templates.php'))->setArgument('groupid', getRequest('groupid', 0)); $paging = getPagingLine($templates, $sortOrder, $url); $templates = API::Template()->get(['templateids' => zbx_objectValues($templates, 'templateid'), 'editable' => true, 'output' => ['name', 'proxy_hostid'], 'selectHosts' => ['hostid', 'name', 'status'], 'selectTemplates' => ['templateid', 'name', 'status'], 'selectParentTemplates' => ['templateid', 'name', 'status'], 'selectItems' => API_OUTPUT_COUNT, 'selectTriggers' => API_OUTPUT_COUNT, 'selectGraphs' => API_OUTPUT_COUNT, 'selectApplications' => API_OUTPUT_COUNT, 'selectDiscoveries' => API_OUTPUT_COUNT, 'selectScreens' => API_OUTPUT_COUNT, 'selectHttpTests' => API_OUTPUT_COUNT, 'nopermissions' => true]); order_result($templates, $sortField, $sortOrder);
$_REQUEST['groupid'] = $pageFilter->groupid; $_REQUEST['hostid'] = get_request('hostid', 0); // echo SBR; if ($_REQUEST['go'] == 'massupdate' && isset($_REQUEST['hosts'])) { $hosts_wdgt->addItem(insert_mass_update_host_form()); } else { if (isset($_REQUEST['form'])) { if ($_REQUEST['form'] == S_IMPORT_HOST) { $hosts_wdgt->addItem(import_host_form()); } else { $hosts_wdgt->addItem(insert_host_form()); } } 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');
* Only host id */ $controls = []; if (isset($onlyHostid)) { $only_hosts = API::Host()->get(['hostids' => $hostid, 'templated_hosts' => true, 'output' => ['hostid', 'host', 'name'], 'limit' => 1]); $host = reset($only_hosts); $cmbHosts = new CComboBox('hostid', $hostid); $cmbHosts->addItem($hostid, $host['name']); $cmbHosts->setEnabled(false); $cmbHosts->setAttribute('title', _('You can not switch hosts for current selection.')); $controls[] = [SPACE, _('Host'), SPACE, $cmbHosts]; } else { // show Group dropdown in header for these specified sources $showGroupCmbBox = ['triggers', 'items', 'applications', 'graphs', 'graph_prototypes', 'item_prototypes', 'templates', 'hosts', 'host_templates']; if (str_in_array($srctbl, $showGroupCmbBox) && ($srctbl !== 'item_prototypes' || !$parentDiscoveryId)) { $controls[] = [_('Group'), SPACE, $pageFilter->getGroupsCB()]; } // show Type dropdown in header for help items if ($srctbl === 'help_items') { $itemType = getRequest('itemtype', 0); $cmbTypes = new CComboBox('itemtype', $itemType, 'javascript: submit();'); foreach ($allowedItemTypes as $type) { $cmbTypes->addItem($type, item_type2str($type)); } $controls[] = [_('Type'), SPACE, $cmbTypes]; } // show Host dropdown in header for these specified sources $showHostCmbBox = ['triggers', 'items', 'applications', 'graphs', 'graph_prototypes', 'item_prototypes']; if (str_in_array($srctbl, $showHostCmbBox) && ($srctbl !== 'item_prototypes' || !$parentDiscoveryId)) { $controls[] = [SPACE, _('Host'), SPACE, $pageFilter->getHostsCB()]; }