$cb_ack_status->additem(ZBX_ACK_STS_WITH_LAST_UNACK, S_WITH_LAST_EVENT_UNACKNOWLEDGED); $filterForm->addRow(S_ACKNOWLEDGE_STATUS, $cb_ack_status); } $ev_select = new CComboBox('show_events', $_REQUEST['show_events']); $ev_select->addItem(EVENTS_OPTION_NOEVENT, S_HIDE_ALL); $ev_select->addItem(EVENTS_OPTION_ALL, S_SHOW_ALL . SPACE . '(' . $config['event_expire'] . SPACE . ($config['event_expire'] > 1 ? S_DAYS : S_DAY) . ')'); if ($config['event_ack_enable']) { $ev_select->addItem(EVENTS_OPTION_NOT_ACK, S_SHOW_UNACKNOWLEDGED . SPACE . '(' . $config['event_expire'] . SPACE . ($config['event_expire'] > 1 ? S_DAYS : S_DAY) . ')'); } $filterForm->addRow(S_EVENTS, $ev_select); $severity_select = new CComboBox('show_severity', $show_severity); $cb_items = array(-1 => S_ALL_S, TRIGGER_SEVERITY_NOT_CLASSIFIED => S_NOT_CLASSIFIED, TRIGGER_SEVERITY_INFORMATION => S_INFORMATION, TRIGGER_SEVERITY_WARNING => S_WARNING, TRIGGER_SEVERITY_AVERAGE => S_AVERAGE, TRIGGER_SEVERITY_HIGH => S_HIGH, TRIGGER_SEVERITY_DISASTER => S_DISASTER); $severity_select->addItems($cb_items); $filterForm->addRow(S_MIN_SEVERITY, $severity_select); $action = 'javascrip: this.checked ? $("status_change_days").enable() : $("status_change_days").disable()'; $sts_change_days_cb = new CNumericBox('status_change_days', $_REQUEST['status_change_days'], 4); if (!$_REQUEST['status_change']) { $sts_change_days_cb->setAttribute('disabled', 'disabled'); } $sts_change_days_cb->addStyle('vertical-align: middle;'); $cbd = new CCheckBox('status_change', $_REQUEST['status_change'], $action, 1); $cbd->addStyle('vertical-align: middle;'); $spand = new CSpan(S_DAYS_SMALL); $spand->addStyle('vertical-align: middle;'); $filterForm->addRow(S_AGE_LESS_THAN, array($cbd, $sts_change_days_cb, $spand)); $filterForm->addRow(S_SHOW_DETAILS, new CCheckBox('show_details', $_REQUEST['show_details'], null, 1)); $filterForm->addRow(S_FILTER_BY_NAME, new CTextBox('txt_select', $_REQUEST['txt_select'], 40)); $filterForm->addItemToBottomRow(new CButton('filter_set', S_FILTER)); $filterForm->addItemToBottomRow(new CButton('filter_rst', S_RESET)); $trigg_wdgt->addFlicker($filterForm, CProfile::get('web.tr_status.filter.state', 0)); /*************** FILTER END ******************/
$operationFormList->addRow(_('Action operations'), new CDiv(array($operationsTable, $footer), 'objectgroup inlineblock border_dotted ui-corner-all')); // create new operation table if (!empty($this->data['new_operation'])) { $newOperationsTable = new CTable(null, 'formElementTable'); $newOperationsTable->addItem(new CVar('new_operation[action]', $this->data['new_operation']['action'])); if (isset($this->data['new_operation']['id'])) { $newOperationsTable->addItem(new CVar('new_operation[id]', $this->data['new_operation']['id'])); } if (isset($this->data['new_operation']['operationid'])) { $newOperationsTable->addItem(new CVar('new_operation[operationid]', $this->data['new_operation']['operationid'])); } if ($this->data['eventsource'] == EVENT_SOURCE_TRIGGERS || $this->data['eventsource'] == EVENT_SOURCE_INTERNAL) { $stepFrom = new CNumericBox('new_operation[esc_step_from]', $this->data['new_operation']['esc_step_from'], 5); $stepFrom->attr('size', 6); $stepFrom->addAction('onchange', 'javascript:' . $stepFrom->getAttribute('onchange') . ' if (this.value == 0) this.value = 1;'); $stepTo = new CNumericBox('new_operation[esc_step_to]', $this->data['new_operation']['esc_step_to'], 5); $stepTo->attr('size', 6); $stepTable = new CTable(); $stepTable->addRow(array(_('From'), $stepFrom), 'indent_both'); $stepTable->addRow(array(_('To'), new CCol(array($stepTo, SPACE, _('(0 - infinitely)')))), 'indent_both'); $stepTable->addRow(array(_('Step duration'), new CCol(array(new CNumericBox('new_operation[esc_period]', $this->data['new_operation']['esc_period'], 6), SPACE, _('(minimum 60 seconds, 0 - use action default)')))), 'indent_both'); $newOperationsTable->addRow(array(_('Step'), $stepTable)); } // if multiple operation types are available, display a select if (count($this->data['allowedOperations']) > 1) { $operationTypeComboBox = new CComboBox('new_operation[operationtype]', $this->data['new_operation']['operationtype'], 'submit()'); foreach ($this->data['allowedOperations'] as $operation) { $operationTypeComboBox->addItem($operation, operation_type2str($operation)); } $newOperationsTable->addRow(array(_('Operation type'), $operationTypeComboBox), 'indent_both'); } else {
function stage4() { $table = new CTable(null, 'requirements'); $table->setAlign('center'); $table->addRow(array(new CCol(_('Host'), 'header'), new CTextBox('zbx_server', $this->getConfig('ZBX_SERVER', 'localhost')))); $port = new CNumericBox('zbx_server_port', $this->getConfig('ZBX_SERVER_PORT', '10051'), 20, 'no', false, false); $port->attr('style', ''); $table->addRow(array(new CCol(_('Port'), 'header'), $port)); $table->addRow(array(new CCol(_('Name'), 'header'), new CTextBox('zbx_server_name', $this->getConfig('ZBX_SERVER_NAME', '')))); return array('Please enter host name or host IP address', BR(), 'and port number of Zabbix server,', BR(), 'as well as the name of the installation (optional).', BR(), BR(), $table); }
function getItemFilterForm(&$items) { $filter_groupId = $_REQUEST['filter_groupid']; $filter_hostId = $_REQUEST['filter_hostid']; $filter_application = $_REQUEST['filter_application']; $filter_name = $_REQUEST['filter_name']; $filter_type = $_REQUEST['filter_type']; $filter_key = $_REQUEST['filter_key']; $filter_snmp_community = $_REQUEST['filter_snmp_community']; $filter_snmpv3_securityname = $_REQUEST['filter_snmpv3_securityname']; $filter_snmp_oid = $_REQUEST['filter_snmp_oid']; $filter_port = $_REQUEST['filter_port']; $filter_value_type = $_REQUEST['filter_value_type']; $filter_data_type = $_REQUEST['filter_data_type']; $filter_delay = $_REQUEST['filter_delay']; $filter_history = $_REQUEST['filter_history']; $filter_trends = $_REQUEST['filter_trends']; $filter_status = $_REQUEST['filter_status']; $filter_state = $_REQUEST['filter_state']; $filter_templated_items = $_REQUEST['filter_templated_items']; $filter_with_triggers = $_REQUEST['filter_with_triggers']; $subfilter_hosts = $_REQUEST['subfilter_hosts']; $subfilter_apps = $_REQUEST['subfilter_apps']; $subfilter_types = $_REQUEST['subfilter_types']; $subfilter_value_types = $_REQUEST['subfilter_value_types']; $subfilter_status = $_REQUEST['subfilter_status']; $subfilter_state = $_REQUEST['subfilter_state']; $subfilter_templated_items = $_REQUEST['subfilter_templated_items']; $subfilter_with_triggers = $_REQUEST['subfilter_with_triggers']; $subfilter_history = $_REQUEST['subfilter_history']; $subfilter_trends = $_REQUEST['subfilter_trends']; $subfilter_interval = $_REQUEST['subfilter_interval']; $form = new CForm('get'); $form->setAttribute('name', 'zbx_filter'); $form->setAttribute('id', 'zbx_filter'); $form->addVar('subfilter_hosts', $subfilter_hosts); $form->addVar('subfilter_apps', $subfilter_apps); $form->addVar('subfilter_types', $subfilter_types); $form->addVar('subfilter_value_types', $subfilter_value_types); $form->addVar('subfilter_status', $subfilter_status); $form->addVar('subfilter_state', $subfilter_state); $form->addVar('subfilter_templated_items', $subfilter_templated_items); $form->addVar('subfilter_with_triggers', $subfilter_with_triggers); $form->addVar('subfilter_history', $subfilter_history); $form->addVar('subfilter_trends', $subfilter_trends); $form->addVar('subfilter_interval', $subfilter_interval); // type select $fTypeVisibility = array(); $cmbType = new CComboBox('filter_type', $filter_type); $cmbType->setAttribute('id', 'filter_type'); $cmbType->addItem(-1, _('all')); foreach (array('filter_delay_label', 'filter_delay') as $vItem) { zbx_subarray_push($fTypeVisibility, -1, $vItem); } $itemTypes = item_type2str(); unset($itemTypes[ITEM_TYPE_HTTPTEST]); // httptest items are only for internal zabbix logic $cmbType->addItems($itemTypes); foreach ($itemTypes as $typeNum => $typeLabel) { if ($typeNum != ITEM_TYPE_TRAPPER) { zbx_subarray_push($fTypeVisibility, $typeNum, 'filter_delay_label'); zbx_subarray_push($fTypeVisibility, $typeNum, 'filter_delay'); } switch ($typeNum) { case ITEM_TYPE_SNMPV1: case ITEM_TYPE_SNMPV2C: $snmp_types = array('filter_snmp_community_label', 'filter_snmp_community', 'filter_snmp_oid_label', 'filter_snmp_oid', 'filter_port_label', 'filter_port'); foreach ($snmp_types as $vItem) { zbx_subarray_push($fTypeVisibility, $typeNum, $vItem); } break; case ITEM_TYPE_SNMPV3: foreach (array('filter_snmpv3_securityname_label', 'filter_snmpv3_securityname', 'filter_snmp_oid_label', 'filter_snmp_oid', 'filter_port_label', 'filter_port') as $vItem) { zbx_subarray_push($fTypeVisibility, $typeNum, $vItem); } break; } } zbx_add_post_js("var filterTypeSwitcher = new CViewSwitcher('filter_type', 'change', " . zbx_jsvalue($fTypeVisibility, true) . ');'); // type of information select $fVTypeVisibility = array(); $cmbValType = new CComboBox('filter_value_type', $filter_value_type); $cmbValType->addItem(-1, _('all')); $cmbValType->addItem(ITEM_VALUE_TYPE_UINT64, _('Numeric (unsigned)')); $cmbValType->addItem(ITEM_VALUE_TYPE_FLOAT, _('Numeric (float)')); $cmbValType->addItem(ITEM_VALUE_TYPE_STR, _('Character')); $cmbValType->addItem(ITEM_VALUE_TYPE_LOG, _('Log')); $cmbValType->addItem(ITEM_VALUE_TYPE_TEXT, _('Text')); foreach (array('filter_data_type_label', 'filter_data_type') as $vItem) { zbx_subarray_push($fVTypeVisibility, ITEM_VALUE_TYPE_UINT64, $vItem); } zbx_add_post_js("var filterValueTypeSwitcher = new CViewSwitcher('filter_value_type', 'change', " . zbx_jsvalue($fVTypeVisibility, true) . ');'); // status select $cmbStatus = new CComboBox('filter_status', $filter_status); $cmbStatus->addItem(-1, _('all')); foreach (array(ITEM_STATUS_ACTIVE, ITEM_STATUS_DISABLED) as $status) { $cmbStatus->addItem($status, item_status2str($status)); } // state select $cmbState = new CComboBox('filter_state', $filter_state); $cmbState->addItem(-1, _('all')); foreach (array(ITEM_STATE_NORMAL, ITEM_STATE_NOTSUPPORTED) as $state) { $cmbState->addItem($state, itemState($state)); } // update interval $updateIntervalLabel = new CSpan(array(bold(_('Update interval')), SPACE . _('(in sec)') . NAME_DELIMITER)); $updateIntervalLabel->setAttribute('id', 'filter_delay_label'); $updateIntervalInput = new CNumericBox('filter_delay', $filter_delay, 5, false, true); $updateIntervalInput->setEnabled('no'); // data type $dataTypeLabel = new CSpan(bold(_('Data type') . NAME_DELIMITER)); $dataTypeLabel->setAttribute('id', 'filter_data_type_label'); $dataTypeInput = new CComboBox('filter_data_type', $filter_data_type); $dataTypeInput->addItem(-1, _('all')); $dataTypeInput->addItems(item_data_type2str()); $dataTypeInput->setEnabled('no'); // filter table $table = new CTable('', 'filter'); $table->setCellPadding(0); $table->setCellSpacing(0); // SNMP community $snmpCommunityLabel = new CSpan(array(bold(_('SNMP community')), SPACE . _('like') . NAME_DELIMITER)); $snmpCommunityLabel->setAttribute('id', 'filter_snmp_community_label'); $snmpCommunityField = new CTextBox('filter_snmp_community', $filter_snmp_community, ZBX_TEXTBOX_FILTER_SIZE); $snmpCommunityField->setEnabled('no'); // SNMPv3 security name $snmpSecurityLabel = new CSpan(array(bold(_('Security name')), SPACE . _('like') . NAME_DELIMITER)); $snmpSecurityLabel->setAttribute('id', 'filter_snmpv3_securityname_label'); $snmpSecurityField = new CTextBox('filter_snmpv3_securityname', $filter_snmpv3_securityname, ZBX_TEXTBOX_FILTER_SIZE); $snmpSecurityField->setEnabled('no'); // SNMP OID $snmpOidLabel = new CSpan(array(bold(_('SNMP OID')), SPACE . _('like') . NAME_DELIMITER)); $snmpOidLabel->setAttribute('id', 'filter_snmp_oid_label'); $snmpOidField = new CTextBox('filter_snmp_oid', $filter_snmp_oid, ZBX_TEXTBOX_FILTER_SIZE); $snmpOidField->setEnabled('no'); // port $portLabel = new CSpan(array(bold(_('Port')), SPACE . _('like') . NAME_DELIMITER)); $portLabel->setAttribute('id', 'filter_port_label'); $portField = new CNumericBox('filter_port', $filter_port, 5, false, true); $portField->setEnabled('no'); // row 1 $groupFilter = null; if (!empty($filter_groupId)) { $getHostInfo = API::HostGroup()->get(array('groupids' => $filter_groupId, 'output' => array('name'))); $getHostInfo = reset($getHostInfo); if (!empty($getHostInfo)) { $groupFilter[] = array('id' => $getHostInfo['groupid'], 'name' => $getHostInfo['name']); } } $table->addRow(array(new CCol(bold(_('Host group') . NAME_DELIMITER), 'label col1'), new CCol(array(new CMultiSelect(array('name' => 'filter_groupid', 'selectedLimit' => 1, 'objectName' => 'hostGroup', 'objectOptions' => array('editable' => true), 'data' => $groupFilter, 'popup' => array('parameters' => 'srctbl=host_groups&dstfrm=' . $form->getName() . '&dstfld1=filter_groupid' . '&srcfld1=groupid&writeonly=1', 'width' => 450, 'height' => 450, 'buttonClass' => 'input filter-multiselect-select-button')))), 'col1'), new CCol(bold(_('Type') . NAME_DELIMITER), 'label col2'), new CCol($cmbType, 'col2'), new CCol(bold(_('Type of information') . NAME_DELIMITER), 'label col3'), new CCol($cmbValType, 'col3'), new CCol(bold(_('State') . NAME_DELIMITER), 'label'), new CCol($cmbState, 'col4')), 'item-list-row'); // row 2 $hostFilterData = null; if (!empty($filter_hostId)) { $getHostInfo = API::Host()->get(array('hostids' => $filter_hostId, 'templated_hosts' => true, 'output' => array('name'))); $getHostInfo = reset($getHostInfo); if (!empty($getHostInfo)) { $hostFilterData[] = array('id' => $getHostInfo['hostid'], 'name' => $getHostInfo['name']); } } $table->addRow(array(new CCol(bold(_('Host') . NAME_DELIMITER), 'label'), new CCol(array(new CMultiSelect(array('name' => 'filter_hostid', 'selectedLimit' => 1, 'objectName' => 'hosts', 'objectOptions' => array('editable' => true, 'templated_hosts' => true), 'data' => $hostFilterData, 'popup' => array('parameters' => 'srctbl=host_templates&dstfrm=' . $form->getName() . '&dstfld1=filter_hostid' . '&srcfld1=hostid&writeonly=1', 'width' => 450, 'height' => 450, 'buttonClass' => 'input filter-multiselect-select-button')))), 'col1'), new CCol($updateIntervalLabel, 'label'), new CCol($updateIntervalInput), new CCol($dataTypeLabel, 'label'), new CCol($dataTypeInput), new CCol(bold(_('Status') . NAME_DELIMITER), 'label col4'), new CCol($cmbStatus, 'col4')), 'item-list-row'); // row 3 $table->addRow(array(new CCol(bold(_('Application') . NAME_DELIMITER), 'label'), new CCol(array(new CTextBox('filter_application', $filter_application, ZBX_TEXTBOX_FILTER_SIZE), new CButton('btn_app', _('Select'), 'return PopUp("popup.php?srctbl=applications&srcfld1=name' . '&dstfrm=' . $form->getName() . '&dstfld1=filter_application' . '&with_applications=1' . '" + (jQuery("input[name=\'filter_hostid\']").length > 0 ? "&hostid="+jQuery("input[name=\'filter_hostid\']").val() : "")' . ', 550, 450, "application");', 'filter-select-button')), 'col1'), new CCol(array($snmpCommunityLabel, $snmpSecurityLabel), 'label'), new CCol(array($snmpCommunityField, $snmpSecurityField)), new CCol(array(bold(_('History')), SPACE . _('(in days)') . NAME_DELIMITER), 'label'), new CCol(new CNumericBox('filter_history', $filter_history, 8, false, true)), new CCol(bold(_('Triggers') . NAME_DELIMITER), 'label'), new CCol(new CComboBox('filter_with_triggers', $filter_with_triggers, null, array(-1 => _('all'), 1 => _('With triggers'), 0 => _('Without triggers'))))), 'item-list-row'); // row 4 $table->addRow(array(new CCol(array(bold(_('Name')), SPACE . _('like') . NAME_DELIMITER), 'label'), new CCol(new CTextBox('filter_name', $filter_name, ZBX_TEXTBOX_FILTER_SIZE), 'col1'), new CCol($snmpOidLabel, 'label'), new CCol($snmpOidField), new CCol(array(bold(_('Trends')), SPACE . _('(in days)') . NAME_DELIMITER), 'label'), new CCol(new CNumericBox('filter_trends', $filter_trends, 8, false, true)), new CCol(bold(_('Template') . NAME_DELIMITER), 'label'), new CCol(new CComboBox('filter_templated_items', $filter_templated_items, null, array(-1 => _('all'), 1 => _('Templated items'), 0 => _('Not Templated items'))))), 'item-list-row'); // row 5 $table->addRow(array(new CCol(array(bold(_('Key')), SPACE . _('like') . NAME_DELIMITER), 'label'), new CCol(new CTextBox('filter_key', $filter_key, ZBX_TEXTBOX_FILTER_SIZE), 'col1'), new CCol($portLabel, 'label'), new CCol($portField), new CCol(null, 'label'), new CCol(), new CCol(null, 'label'), new CCol()), 'item-list-row'); $filter = new CSubmit('filter_set', _('Filter'), 'chkbxRange.clearSelectedOnFilterChange();'); $filter->useJQueryStyle('main'); $reset = new CSubmit('filter_rst', _('Reset'), 'chkbxRange.clearSelectedOnFilterChange();'); $reset->useJQueryStyle(); $div_buttons = new CDiv(array($filter, SPACE, $reset)); $div_buttons->setAttribute('style', 'padding: 4px 0px;'); $footer = new CCol($div_buttons, 'controls', 8); $table->addRow($footer); $form->addItem($table); // subfilters $table_subfilter = new CTable(null, 'filter sub-filter'); // array contains subfilters and number of items in each $item_params = array('hosts' => array(), 'applications' => array(), 'types' => array(), 'value_types' => array(), 'status' => array(), 'state' => array(), 'templated_items' => array(), 'with_triggers' => array(), 'history' => array(), 'trends' => array(), 'interval' => array()); // generate array with values for subfilters of selected items foreach ($items as $item) { // hosts if (zbx_empty($filter_hostId)) { $host = reset($item['hosts']); if (!isset($item_params['hosts'][$host['hostid']])) { $item_params['hosts'][$host['hostid']] = array('name' => $host['name'], 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_hosts') { continue; } $show_item &= $value; } if ($show_item) { $host = reset($item['hosts']); $item_params['hosts'][$host['hostid']]['count']++; } } // applications if (!empty($item['applications'])) { foreach ($item['applications'] as $application) { if (!isset($item_params['applications'][$application['name']])) { $item_params['applications'][$application['name']] = array('name' => $application['name'], 'count' => 0); } } } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_apps') { continue; } $show_item &= $value; } $sel_app = false; if ($show_item) { // if any of item applications are selected foreach ($item['applications'] as $app) { if (str_in_array($app['name'], $subfilter_apps)) { $sel_app = true; break; } } foreach ($item['applications'] as $app) { if (str_in_array($app['name'], $subfilter_apps) || !$sel_app) { $item_params['applications'][$app['name']]['count']++; } } } // types if ($filter_type == -1) { if (!isset($item_params['types'][$item['type']])) { $item_params['types'][$item['type']] = array('name' => item_type2str($item['type']), 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_types') { continue; } $show_item &= $value; } if ($show_item) { $item_params['types'][$item['type']]['count']++; } } // value types if ($filter_value_type == -1) { if (!isset($item_params['value_types'][$item['value_type']])) { $item_params['value_types'][$item['value_type']] = array('name' => itemValueTypeString($item['value_type']), 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_value_types') { continue; } $show_item &= $value; } if ($show_item) { $item_params['value_types'][$item['value_type']]['count']++; } } // status if ($filter_status == -1) { if (!isset($item_params['status'][$item['status']])) { $item_params['status'][$item['status']] = array('name' => item_status2str($item['status']), 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_status') { continue; } $show_item &= $value; } if ($show_item) { $item_params['status'][$item['status']]['count']++; } } // state if ($filter_state == -1) { if (!isset($item_params['state'][$item['state']])) { $item_params['state'][$item['state']] = array('name' => itemState($item['state']), 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_state') { continue; } $show_item &= $value; } if ($show_item) { $item_params['state'][$item['state']]['count']++; } } // template if ($filter_templated_items == -1) { if ($item['templateid'] == 0 && !isset($item_params['templated_items'][0])) { $item_params['templated_items'][0] = array('name' => _('Not Templated items'), 'count' => 0); } elseif ($item['templateid'] > 0 && !isset($item_params['templated_items'][1])) { $item_params['templated_items'][1] = array('name' => _('Templated items'), 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_templated_items') { continue; } $show_item &= $value; } if ($show_item) { if ($item['templateid'] == 0) { $item_params['templated_items'][0]['count']++; } else { $item_params['templated_items'][1]['count']++; } } } // with triggers if ($filter_with_triggers == -1) { if (count($item['triggers']) == 0 && !isset($item_params['with_triggers'][0])) { $item_params['with_triggers'][0] = array('name' => _('Without triggers'), 'count' => 0); } elseif (count($item['triggers']) > 0 && !isset($item_params['with_triggers'][1])) { $item_params['with_triggers'][1] = array('name' => _('With triggers'), 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_with_triggers') { continue; } $show_item &= $value; } if ($show_item) { if (count($item['triggers']) == 0) { $item_params['with_triggers'][0]['count']++; } else { $item_params['with_triggers'][1]['count']++; } } } // trends if (zbx_empty($filter_trends)) { if (!isset($item_params['trends'][$item['trends']])) { $item_params['trends'][$item['trends']] = array('name' => $item['trends'], 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_trends') { continue; } $show_item &= $value; } if ($show_item) { $item_params['trends'][$item['trends']]['count']++; } } // history if (zbx_empty($filter_history)) { if (!isset($item_params['history'][$item['history']])) { $item_params['history'][$item['history']] = array('name' => $item['history'], 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_history') { continue; } $show_item &= $value; } if ($show_item) { $item_params['history'][$item['history']]['count']++; } } // interval if (zbx_empty($filter_delay) && $filter_type != ITEM_TYPE_TRAPPER) { if (!isset($item_params['interval'][$item['delay']])) { $item_params['interval'][$item['delay']] = array('name' => $item['delay'], 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_interval') { continue; } $show_item &= $value; } if ($show_item) { $item_params['interval'][$item['delay']]['count']++; } } } // output if (zbx_empty($filter_hostId) && count($item_params['hosts']) > 1) { $hosts_output = prepareSubfilterOutput($item_params['hosts'], $subfilter_hosts, 'subfilter_hosts'); $table_subfilter->addRow(array(_('Hosts'), $hosts_output)); } if (!empty($item_params['applications']) && count($item_params['applications']) > 1) { $application_output = prepareSubfilterOutput($item_params['applications'], $subfilter_apps, 'subfilter_apps'); $table_subfilter->addRow(array(_('Applications'), $application_output)); } if ($filter_type == -1 && count($item_params['types']) > 1) { $type_output = prepareSubfilterOutput($item_params['types'], $subfilter_types, 'subfilter_types'); $table_subfilter->addRow(array(_('Types'), $type_output)); } if ($filter_value_type == -1 && count($item_params['value_types']) > 1) { $value_types_output = prepareSubfilterOutput($item_params['value_types'], $subfilter_value_types, 'subfilter_value_types'); $table_subfilter->addRow(array(_('Type of information'), $value_types_output)); } if ($filter_status == -1 && count($item_params['status']) > 1) { $status_output = prepareSubfilterOutput($item_params['status'], $subfilter_status, 'subfilter_status'); $table_subfilter->addRow(array(_('Status'), $status_output)); } if ($filter_state == -1 && count($item_params['state']) > 1) { $state_output = prepareSubfilterOutput($item_params['state'], $subfilter_state, 'subfilter_state'); $table_subfilter->addRow(array(_('State'), $state_output)); } if ($filter_templated_items == -1 && count($item_params['templated_items']) > 1) { $templated_items_output = prepareSubfilterOutput($item_params['templated_items'], $subfilter_templated_items, 'subfilter_templated_items'); $table_subfilter->addRow(array(_('Template'), $templated_items_output)); } if ($filter_with_triggers == -1 && count($item_params['with_triggers']) > 1) { $with_triggers_output = prepareSubfilterOutput($item_params['with_triggers'], $subfilter_with_triggers, 'subfilter_with_triggers'); $table_subfilter->addRow(array(_('With triggers'), $with_triggers_output)); } if (zbx_empty($filter_history) && count($item_params['history']) > 1) { $history_output = prepareSubfilterOutput($item_params['history'], $subfilter_history, 'subfilter_history'); $table_subfilter->addRow(array(_('History'), $history_output)); } if (zbx_empty($filter_trends) && count($item_params['trends']) > 1) { $trends_output = prepareSubfilterOutput($item_params['trends'], $subfilter_trends, 'subfilter_trends'); $table_subfilter->addRow(array(_('Trends'), $trends_output)); } if (zbx_empty($filter_delay) && $filter_type != ITEM_TYPE_TRAPPER && count($item_params['interval']) > 1) { $interval_output = prepareSubfilterOutput($item_params['interval'], $subfilter_interval, 'subfilter_interval'); $table_subfilter->addRow(array(_('Interval'), $interval_output)); } $form->addItem(new CDiv(_('Subfilter [affects only filtered data!]'), 'thin_header')); $form->addItem($table_subfilter); return $form; }
$slideFormList->addRow(_('Default delay (in seconds)'), new CNumericBox('delay', $this->data['delay'], 5, 'no', false, false)); // append slide table $slideTable = new CTableInfo(_('No slides defined.'), 'formElementTable'); $slideTable->setAttribute('style', 'min-width: 500px;'); $slideTable->setAttribute('id', 'slideTable'); $slideTable->setHeader(array(new CCol(SPACE, null, null, '15'), new CCol(SPACE, null, null, '15'), new CCol(_('Screen'), null, null, '140'), new CCol(_('Delay'), null, null, '70'), new CCol(_('Action'), null, null, '50'))); $i = 1; foreach ($this->data['slides'] as $step => $slides) { $name = ''; if (!empty($slides['screenid'])) { $screen = get_screen_by_screenid($slides['screenid']); if (!empty($screen['name'])) { $name = $screen['name']; } } $delay = new CNumericBox('slides[' . $step . '][delay]', !empty($slides['delay']) ? $slides['delay'] : '', 5, 'no', true, false); $delay->setAttribute('placeholder', _('default')); $removeButton = new CButton('remove_' . $step, _('Remove'), 'javascript: removeSlide(this);', 'link_menu'); $removeButton->setAttribute('remove_slide', $step); $row = new CRow(array(new CSpan(null, 'ui-icon ui-icon-arrowthick-2-n-s move'), new CSpan($i++ . ':', 'rowNum', 'current_slide_' . $step), $name, $delay, $removeButton), 'sortable', 'slides_' . $step); $slideTable->addRow($row); } $addButtonColumn = new CCol(empty($this->data['work_slide']) ? new CButton('add', _('Add'), 'return PopUp("popup.php?srctbl=screens&srcfld1=screenid&dstfrm=' . $slideForm->getName() . '&multiselect=1", 450, 450)', 'link_menu') : null, null, 5); $addButtonColumn->setAttribute('style', 'vertical-align: middle;'); $slideTable->addRow(new CRow($addButtonColumn, null, 'screenListFooter')); $slideFormList->addRow(_('Slides'), new CDiv($slideTable, 'objectgroup inlineblock border_dotted ui-corner-all')); // append tabs to form $slideTab = new CTabView(); $slideTab->addTab('slideTab', _('Slide'), $slideFormList); $slideForm->addItem($slideTab); // append buttons to form
$languageError = 'Translations are unavailable because the PHP gettext module is missing.'; $languageComboBox->attr('disabled', 'disabled'); } elseif (!$allLocalesAvailable) { $languageError = _('You are not able to choose some of the languages, because locales for them are not installed on the web server.'); } $userFormList->addRow(_('Language'), $languageError ? array($languageComboBox, SPACE, new CSpan($languageError, 'red wrap')) : $languageComboBox); // append themes to form list $themes = array_merge(array(THEME_DEFAULT => _('System default')), Z::getThemes()); $themeComboBox = new CComboBox('theme', $this->data['theme'], null, $themes); $userFormList->addRow(_('Theme'), $themeComboBox); // append auto-login & auto-logout to form list $autologoutCheckBox = new CCheckBox('autologout_visible', isset($this->data['autologout']) ? 'yes' : 'no'); if (isset($this->data['autologout'])) { $autologoutTextBox = new CNumericBox('autologout', $this->data['autologout'], 4); } else { $autologoutTextBox = new CNumericBox('autologout', 900, 4); $autologoutTextBox->setAttribute('disabled', 'disabled'); } if ($this->data['alias'] != ZBX_GUEST_USER) { $userFormList->addRow(_('Auto-login'), new CCheckBox('autologin', $this->data['autologin'], null, 1)); $userFormList->addRow(_('Auto-logout (min 90 seconds)'), array($autologoutCheckBox, $autologoutTextBox)); } $userFormList->addRow(_('Refresh (in seconds)'), new CNumericBox('refresh', $this->data['refresh'], 4)); $userFormList->addRow(_('Rows per page'), new CNumericBox('rows_per_page', $this->data['rows_per_page'], 6)); $userFormList->addRow(_('URL (after login)'), new CTextBox('url', $this->data['url'], ZBX_TEXTBOX_STANDARD_SIZE)); /* * Media tab */ if (uint_in_array(CWebUser::$data['type'], array(USER_TYPE_ZABBIX_ADMIN, USER_TYPE_SUPER_ADMIN))) { $userMediaFormList = new CFormList('userMediaFormList'); $userForm->addVar('user_medias', $this->data['user_medias']);
// ack status if ($config['event_ack_enable']) { $filterForm->addRow(_('Acknowledge status'), new CComboBox('ack_status', $filter['ackStatus'], null, array(ZBX_ACK_STS_ANY => _('Any'), ZBX_ACK_STS_WITH_UNACK => _('With unacknowledged events'), ZBX_ACK_STS_WITH_LAST_UNACK => _('With last event unacknowledged')))); } // events if (!$overview) { $eventsComboBox = new CComboBox('show_events', $filter['showEvents'], null, array(EVENTS_OPTION_NOEVENT => _('Hide all'), EVENTS_OPTION_ALL => _n('Show all (%1$s day)', 'Show all (%1$s days)', $config['event_expire']))); if ($config['event_ack_enable']) { $eventsComboBox->addItem(EVENTS_OPTION_NOT_ACK, _n('Show unacknowledged (%1$s day)', 'Show unacknowledged (%1$s days)', $config['event_expire'])); } $filterForm->addRow(_('Events'), $eventsComboBox); } // min severity $filterForm->addRow(_('Minimum trigger severity'), new CComboBox('show_severity', $filter['showSeverity'], null, array(TRIGGER_SEVERITY_NOT_CLASSIFIED => getSeverityCaption(TRIGGER_SEVERITY_NOT_CLASSIFIED), TRIGGER_SEVERITY_INFORMATION => getSeverityCaption(TRIGGER_SEVERITY_INFORMATION), TRIGGER_SEVERITY_WARNING => getSeverityCaption(TRIGGER_SEVERITY_WARNING), TRIGGER_SEVERITY_AVERAGE => getSeverityCaption(TRIGGER_SEVERITY_AVERAGE), TRIGGER_SEVERITY_HIGH => getSeverityCaption(TRIGGER_SEVERITY_HIGH), TRIGGER_SEVERITY_DISASTER => getSeverityCaption(TRIGGER_SEVERITY_DISASTER)))); // age less than $statusChangeDays = new CNumericBox('status_change_days', $filter['statusChangeDays'], 3, false, false, false); if (!$filter['statusChange']) { $statusChangeDays->setAttribute('disabled', 'disabled'); } $statusChangeDays->addStyle('vertical-align: middle;'); $statusChangeCheckBox = new CCheckBox('status_change', $filter['statusChange'], 'javascript: this.checked ? $("status_change_days").enable() : $("status_change_days").disable()', 1); $statusChangeCheckBox->addStyle('vertical-align: middle;'); $daysSpan = new CSpan(_('days')); $daysSpan->addStyle('vertical-align: middle;'); $filterForm->addRow(_('Age less than'), array($statusChangeCheckBox, $statusChangeDays, SPACE, $daysSpan)); // name $filterForm->addRow(_('Filter by name'), new CTextBox('txt_select', $filter['txtSelect'], 40)); // application $filterForm->addRow(_('Filter by application'), array(new CTextBox('application', $filter['application'], 40), new CButton('application_name', _('Select'), 'return PopUp("popup.php?srctbl=applications&srcfld1=name&real_hosts=1&dstfld1=application&with_applications=1' . '&dstfrm=' . $filterForm->getName() . '");', 'filter-button'))); // inventory filter $inventoryFilters = $filter['inventory'];
function get_act_new_oper_form($action = null) { $tblOper = new CTableInfo(); if (isset($_REQUEST['actionid']) && empty($action)) { $action = get_action_by_actionid($_REQUEST['actionid']); } $operations = get_request("operations", array()); if (isset($_REQUEST['actionid']) && !isset($_REQUEST['form_refresh'])) { $eventsource = $action['eventsource']; } else { $eventsource = get_request('eventsource'); } $allowed_operations = get_operations_by_eventsource($eventsource); /* init new_operation variable */ $new_operation = get_request('new_operation', array()); if (!is_array($new_operation)) { $new_operation = array(); $new_operation['default_msg'] = 1; } if (!isset($new_operation['operationtype'])) { $new_operation['operationtype'] = OPERATION_TYPE_MESSAGE; } if (!isset($new_operation['object'])) { $new_operation['object'] = OPERATION_OBJECT_GROUP; } if (!isset($new_operation['objectid'])) { $new_operation['objectid'] = 0; } if (!isset($new_operation['shortdata'])) { $new_operation['shortdata'] = '{TRIGGER.NAME}: {STATUS}'; } if (!isset($new_operation['longdata'])) { $new_operation['longdata'] = '{TRIGGER.NAME}: {STATUS}'; } if (!isset($new_operation['esc_step_from'])) { $new_operation['esc_step_from'] = 1; } if (!isset($new_operation['esc_step_to'])) { $new_operation['esc_step_to'] = 1; } if (!isset($new_operation['esc_period'])) { $new_operation['esc_period'] = 0; } if (!isset($new_operation['evaltype'])) { $new_operation['evaltype'] = 0; } if (!isset($new_operation['opconditions'])) { $new_operation['opconditions'] = array(); } if (!isset($new_operation['default_msg'])) { $new_operation['default_msg'] = 0; } unset($update_mode); $evaltype = $new_operation['evaltype']; if (isset($new_operation['id'])) { $tblOper->addItem(new CVar('new_operation[id]', $new_operation['id'])); $update_mode = true; } $tblNewOperation = new CTable(null, 'nowrap'); if (isset($_REQUEST['escalation'])) { $tblStep = new CTable(null, 'nowrap'); $step_from = new CNumericBox('new_operation[esc_step_from]', $new_operation['esc_step_from'], 4); $step_from->addAction('onchange', 'javascript:' . $step_from->GetOption('onchange') . ' if(this.value == 0) this.value=1;'); $tblStep->addRow(array(S_FROM, $step_from)); $tblStep->addRow(array(S_TO, new CCol(array(new CNumericBox('new_operation[esc_step_to]', $new_operation['esc_step_to'], 4), ' [0-' . S_INFINITY . ']')))); $tblStep->addRow(array(S_PERIOD, new CCol(array(new CNumericBox('new_operation[esc_period]', $new_operation['esc_period'], 5), ' [0-' . S_DEFAULT . ']')))); $tblNewOperation->addRow(array(S_STEP, $tblStep)); } else { $tblOper->addItem(new CVar('new_operation[esc_period]', $new_operation['esc_period'])); $tblOper->addItem(new CVar('new_operation[esc_step_from]', $new_operation['esc_step_from'])); $tblOper->addItem(new CVar('new_operation[esc_step_to]', $new_operation['esc_step_to'])); $tblOper->addItem(new CVar('new_operation[evaltype]', $new_operation['evaltype'])); } $cmbOpType = new CComboBox('new_operation[operationtype]', $new_operation['operationtype'], 'submit()'); foreach ($allowed_operations as $oper) { $cmbOpType->addItem($oper, operation_type2str($oper)); } $tblNewOperation->addRow(array(S_OPERATION_TYPE, $cmbOpType)); switch ($new_operation['operationtype']) { case OPERATION_TYPE_MESSAGE: if ($new_operation['object'] == OPERATION_OBJECT_GROUP) { $object_srctbl = 'usrgrp'; $object_srcfld1 = 'usrgrpid'; $object_name = get_group_by_usrgrpid($new_operation['objectid']); $display_name = 'name'; } else { $object_srctbl = 'users'; $object_srcfld1 = 'userid'; $object_name = get_user_by_userid($new_operation['objectid']); $display_name = 'alias'; } $tblOper->addItem(new CVar('new_operation[objectid]', $new_operation['objectid'])); if ($object_name) { $object_name = $object_name[$display_name]; } $cmbObject = new CComboBox('new_operation[object]', $new_operation['object'], 'submit()'); $cmbObject->addItem(OPERATION_OBJECT_USER, S_SINGLE_USER); $cmbObject->addItem(OPERATION_OBJECT_GROUP, S_USER_GROUP); $tblNewOperation->addRow(array(S_SEND_MESSAGE_TO, array($cmbObject, new CTextBox('object_name', $object_name, 40, 'yes'), new CButton('select_object', S_SELECT, 'return PopUp("popup.php?dstfrm=' . S_ACTION . '&dstfld1=new_operation%5Bobjectid%5D&dstfld2=object_name' . '&srctbl=' . $object_srctbl . '&srcfld1=' . $object_srcfld1 . '&srcfld2=' . $display_name . '",450,450)', 'T')))); $tblNewOperation->addRow(array(S_DEFAULT_MESSAGE, new CCheckBox('new_operation[default_msg]', $new_operation['default_msg'], 'javascript: submit();', 1))); if (!$new_operation['default_msg']) { $tblNewOperation->addRow(array(S_SUBJECT, new CTextBox('new_operation[shortdata]', $new_operation['shortdata'], 77))); $tblNewOperation->addRow(array(S_MESSAGE, new CTextArea('new_operation[longdata]', $new_operation['longdata'], 77, 7))); } else { $tblOper->addItem(new CVar('new_operation[shortdata]', $new_operation['shortdata'])); $tblOper->addItem(new CVar('new_operation[longdata]', $new_operation['longdata'])); } break; case OPERATION_TYPE_COMMAND: $tblOper->addItem(new CVar('new_operation[object]', 0)); $tblOper->addItem(new CVar('new_operation[objectid]', 0)); $tblOper->addItem(new CVar('new_operation[shortdata]', '')); $tblNewOperation->addRow(array(S_REMOTE_COMMAND, new CTextArea('new_operation[longdata]', $new_operation['longdata'], 77, 7))); break; case OPERATION_TYPE_HOST_ADD: $tblOper->addItem(new CVar('new_operation[object]', 0)); $tblOper->addItem(new CVar('new_operation[objectid]', 0)); $tblOper->addItem(new CVar('new_operation[shortdata]', '')); $tblOper->addItem(new CVar('new_operation[longdata]', '')); break; case OPERATION_TYPE_HOST_REMOVE: $tblOper->addItem(new CVar('new_operation[object]', 0)); $tblOper->addItem(new CVar('new_operation[objectid]', 0)); $tblOper->addItem(new CVar('new_operation[shortdata]', '')); $tblOper->addItem(new CVar('new_operation[longdata]', '')); break; case OPERATION_TYPE_GROUP_ADD: $tblOper->addItem(new CVar('new_operation[object]', 0)); $tblOper->addItem(new CVar('new_operation[objectid]', $new_operation['objectid'])); $tblOper->addItem(new CVar('new_operation[shortdata]', '')); $tblOper->addItem(new CVar('new_operation[longdata]', '')); if ($object_name = DBfetch(DBselect('select name FROM groups WHERE groupid=' . $new_operation['objectid']))) { $object_name = $object_name['name']; } $tblNewOperation->addRow(array(S_GROUP, array(new CTextBox('object_name', $object_name, 40, 'yes'), new CButton('select_object', S_SELECT, 'return PopUp("popup.php?dstfrm=' . S_ACTION . '&dstfld1=new_operation%5Bobjectid%5D&dstfld2=object_name' . '&srctbl=host_group&srcfld1=groupid&srcfld2=name' . '",450,450)', 'T')))); break; case OPERATION_TYPE_GROUP_REMOVE: $tblOper->addItem(new CVar('new_operation[object]', 0)); $tblOper->addItem(new CVar('new_operation[objectid]', $new_operation['objectid'])); $tblOper->addItem(new CVar('new_operation[shortdata]', '')); $tblOper->addItem(new CVar('new_operation[longdata]', '')); if ($object_name = DBfetch(DBselect('select name FROM groups WHERE groupid=' . $new_operation['objectid']))) { $object_name = $object_name['name']; } $tblNewOperation->addRow(array(S_GROUP, array(new CTextBox('object_name', $object_name, 40, 'yes'), new CButton('select_object', S_SELECT, 'return PopUp("popup.php?dstfrm=' . S_ACTION . '&dstfld1=new_operation%5Bobjectid%5D&dstfld2=object_name' . '&srctbl=host_group&srcfld1=groupid&srcfld2=name' . '",450,450)', 'T')))); break; case OPERATION_TYPE_TEMPLATE_ADD: $tblOper->addItem(new CVar('new_operation[object]', 0)); $tblOper->addItem(new CVar('new_operation[objectid]', $new_operation['objectid'])); $tblOper->addItem(new CVar('new_operation[shortdata]', '')); $tblOper->addItem(new CVar('new_operation[longdata]', '')); if ($object_name = DBfetch(DBselect('SELECT host FROM hosts ' . ' WHERE status=' . HOST_STATUS_TEMPLATE . ' AND hostid=' . $new_operation['objectid']))) { $object_name = $object_name['host']; } $tblNewOperation->addRow(array(S_TEMPLATE, array(new CTextBox('object_name', $object_name, 40, 'yes'), new CButton('select_object', S_SELECT, 'return PopUp("popup.php?dstfrm=' . S_ACTION . '&dstfld1=new_operation%5Bobjectid%5D&dstfld2=object_name' . '&srctbl=host_templates&srcfld1=hostid&srcfld2=host' . '",450,450)', 'T')))); break; case OPERATION_TYPE_TEMPLATE_REMOVE: $tblOper->addItem(new CVar('new_operation[object]', 0)); $tblOper->addItem(new CVar('new_operation[objectid]', $new_operation['objectid'])); $tblOper->addItem(new CVar('new_operation[shortdata]', '')); $tblOper->addItem(new CVar('new_operation[longdata]', '')); if ($object_name = DBfetch(DBselect('SELECT host FROM hosts ' . ' WHERE status=' . HOST_STATUS_TEMPLATE . ' AND hostid=' . $new_operation['objectid']))) { $object_name = $object_name['host']; } $tblNewOperation->addRow(array(S_TEMPLATE, array(new CTextBox('object_name', $object_name, 40, 'yes'), new CButton('select_object', S_SELECT, 'return PopUp("popup.php?dstfrm=' . S_ACTION . '&dstfld1=new_operation%5Bobjectid%5D&dstfld2=object_name' . '&srctbl=host_templates&srcfld1=hostid&srcfld2=host' . '",450,450)', 'T')))); break; } // new Operation conditions if (isset($_REQUEST['escalation'])) { $tblCond = new CTable(); $opconditions = $new_operation['opconditions']; $allowed_opconditions = get_opconditions_by_eventsource($eventsource); // show opcondition LIST zbx_rksort($opconditions); /* group opconditions by type */ $grouped_opconditions = array(); $cond_el = new CTable(S_NO_CONDITIONS_DEFINED); $i = 0; foreach ($opconditions as $val) { if (!isset($val['conditiontype'])) { $val['conditiontype'] = 0; } if (!isset($val['operator'])) { $val['operator'] = 0; } if (!isset($val['value'])) { $val['value'] = 0; } if (!str_in_array($val["conditiontype"], $allowed_opconditions)) { continue; } $label = chr(ord('A') + $i); $cond_el->addRow(array('(' . $label . ')', array(new CCheckBox("g_opconditionid[]", 'no', null, $i), get_condition_desc($val["conditiontype"], $val["operator"], $val["value"])))); $tblCond->addItem(new CVar("new_operation[opconditions][{$i}][conditiontype]", $val["conditiontype"])); $tblCond->addItem(new CVar("new_operation[opconditions][{$i}][operator]", $val["operator"])); $tblCond->addItem(new CVar("new_operation[opconditions][{$i}][value]", $val["value"])); $grouped_opconditions[$val["conditiontype"]][] = $label; $i++; } unset($opconditions); $cond_buttons = array(); if (!isset($_REQUEST['new_opcondition'])) { $cond_buttons[] = new CButton('new_opcondition', S_NEW); } if ($cond_el->ItemsCount() > 0) { if ($cond_el->ItemsCount() > 1) { /* prepare opcondition calcuation type selector */ switch ($evaltype) { case ACTION_EVAL_TYPE_AND: $group_op = $glog_op = S_AND; break; case ACTION_EVAL_TYPE_OR: $group_op = $glog_op = S_OR; break; default: $group_op = S_OR; $glog_op = S_AND; break; } foreach ($grouped_opconditions as $id => $val) { $grouped_opconditions[$id] = '(' . implode(' ' . $group_op . ' ', $val) . ')'; } $grouped_opconditions = implode(' ' . $glog_op . ' ', $grouped_opconditions); $cmb_calc_type = new CComboBox('new_operation[evaltype]', $evaltype, 'submit()'); $cmb_calc_type->addItem(ACTION_EVAL_TYPE_AND_OR, S_AND_OR_BIG); $cmb_calc_type->addItem(ACTION_EVAL_TYPE_AND, S_AND_BIG); $cmb_calc_type->addItem(ACTION_EVAL_TYPE_OR, S_OR_BIG); $tblNewOperation->addRow(array(S_TYPE_OF_CALCULATION, new CCol(array($cmb_calc_type, new CTextBox('preview', $grouped_opconditions, 60, 'yes'))))); unset($cmb_calc_type, $group_op, $glog_op); /* end of calcuation type selector */ } else { $tblCond->addItem(new CVar('new_operation[evaltype]', ACTION_EVAL_TYPE_AND_OR)); } $cond_buttons[] = new CButton('del_opcondition', S_DELETE_SELECTED); } else { $tblCond->addItem(new CVar('new_operation[evaltype]', ACTION_EVAL_TYPE_AND_OR)); } $tblCond->addRow($cond_el); $tblCond->addRow(new CCol($cond_buttons)); // end of opcondition LIST $tblNewOperation->addRow(array(S_CONDITIONS, $tblCond)); unset($grouped_opconditions, $cond_el, $cond_buttons, $tblCond); } $tblOper->addRow($tblNewOperation); $td = new CCol(array(new CButton('add_operation', isset($update_mode) ? S_SAVE : S_ADD), SPACE, new CButton('cancel_new_operation', S_CANCEL))); $td->addOption('colspan', '3'); $td->addOption('style', 'text-align: right;'); $tblOper->SetFooter($td); return $tblOper; }
/** * Create array with all inputs required for date selection and calendar. * * @param string $name * @param int|array $date unix timestamp/date array(Y,m,d,H,i) * @param string|null $relatedCalendar name of the calendar which must be closed when this calendar opens * * @return array */ function createDateSelector($name, $date, $relatedCalendar = null) { $calendarIcon = new CImg('images/general/bar/cal.gif', 'calendar', 16, 12, 'pointer'); $onClick = 'var pos = getPosition(this); pos.top += 10; pos.left += 16; CLNDR["' . $name . '_calendar"].clndr.clndrshow(pos.top, pos.left);'; if ($relatedCalendar) { $onClick .= ' CLNDR["' . $relatedCalendar . '_calendar"].clndr.clndrhide();'; } $calendarIcon->onClick($onClick); if (is_array($date)) { $y = $date['y']; $m = $date['m']; $d = $date['d']; $h = $date['h']; $i = $date['i']; } else { $y = date('Y', $date); $m = date('m', $date); $d = date('d', $date); $h = date('H', $date); $i = date('i', $date); } $day = new CNumericBox($name . '_day', $d, 2); $day->attr('placeholder', _('dd')); $month = new CNumericBox($name . '_month', $m, 2); $month->attr('placeholder', _('mm')); $year = new CNumericBox($name . '_year', $y, 4); $year->attr('placeholder', _('yyyy')); $hour = new CNumericBox($name . '_hour', $h, 2); $hour->attr('placeholder', _('hh')); $minute = new CNumericBox($name . '_minute', $i, 2); $minute->attr('placeholder', _('mm')); $fields = array($day, '/', $month, '/', $year, SPACE, $hour, ':', $minute, $calendarIcon); zbx_add_post_js('create_calendar(null,' . '["' . $name . '_day","' . $name . '_month","' . $name . '_year","' . $name . '_hour","' . $name . '_minute"],' . '"' . $name . '_calendar",' . '"' . $name . '");'); return $fields; }
$month = ''; $day = ''; $hours = ''; $minutes = ''; } $servicesForm->addVar('new_service_time[to]', $year . $month . $day . $hours . $minutes); $calendarIcon->addAction('onclick', "javascript: var pos = getPosition(this); pos.top -= 203; pos.left += 16; CLNDR['downtime_till'].clndr.clndrshow(pos.top, pos.left); CLNDR['downtime_since'].clndr.clndrhide();"); $downtimeTillDay = new CNumericBox('downtime_till_day', $day, 2); $downtimeTillDay->setAttribute('placeholder', _('dd')); $downtimeTillMonth = new CNumericBox('downtime_till_month', $month, 2); $downtimeTillMonth->setAttribute('placeholder', _('mm')); $downtimeTillYear = new CNumericBox('downtime_till_year', $year, 4); $downtimeTillYear->setAttribute('placeholder', _('yyyy')); $downtimeTillHour = new CNumericBox('downtime_till_hour', $hours, 2); $downtimeTillHour->setAttribute('placeholder', _('hh')); $downtimeTillMinute = new CNumericBox('downtime_till_minute', $minutes, 2); $downtimeTillMinute->setAttribute('placeholder', _('mm')); $timeCalendarTable->addRow(array(_('Till'), new CCol(array($downtimeTillDay, '/', $downtimeTillMonth, '/', $downtimeTillYear, SPACE, $downtimeTillHour, ':', $downtimeTillMinute, $calendarIcon)))); zbx_add_post_js('create_calendar(null, ["downtime_till_day", "downtime_till_month", "downtime_till_year", "downtime_till_hour", "downtime_till_minute"], "downtime_till", "new_service_time_to");'); $serviceTimeTable->addRow($timeCalendarTable); } else { $weekFromComboBox = new CComboBox('new_service_time[from_week]', isset($_REQUEST['new_service_time']['from_week']) ? $_REQUEST['new_service_time']['from_week'] : 0); $weekToComboBox = new CComboBox('new_service_time[to_week]', isset($_REQUEST['new_service_time']['from_week']) ? $_REQUEST['new_service_time']['to_week'] : 0); for ($dow = 0; $dow < 7; $dow++) { $weekFromComboBox->addItem($dow, getDayOfWeekCaption($dow)); $weekToComboBox->addItem($dow, getDayOfWeekCaption($dow)); } $timeFromHourTextBox = new CTextBox('new_service_time[from_hour]', isset($_REQUEST['new_service_time']['from_hour']) ? $_REQUEST['new_service_time']['from_hour'] : '', 2, 'no', 2); $timeFromHourTextBox->setAttribute('placeholder', _('hh')); $timeFromMinuteTextBox = new CTextBox('new_service_time[from_minute]', isset($_REQUEST['new_service_time']['from_minute']) ? $_REQUEST['new_service_time']['from_minute'] : '', 2, 'no', 2); $timeFromMinuteTextBox->setAttribute('placeholder', _('mm'));
$histortTab = new CTable(null, 'formElementTable'); $histortTab->addRow(array(new CLabel(_('Enable internal housekeeping'), 'hk_history_mode'), new CCheckBox('hk_history_mode', $this->data['config']['hk_history_mode'], null, 1))); $houseKeeperHistoryGlobal = new CCheckBox('hk_history_global', $this->data['config']['hk_history_global'], null, 1); $houseKeeperHistoryModeGlobal = new CNumericBox('hk_history', $this->data['config']['hk_history'], 5); if (!$this->data['config']['hk_history_global']) { $houseKeeperHistoryModeGlobal->setAttribute('disabled', 'disabled'); } $histortTab->addRow(array(new CLabel(_('Override item history period'), 'hk_history_global'), $houseKeeperHistoryGlobal)); $histortTab->addRow(array(new CLabel(_('Data storage period (in days)'), 'hk_history'), $houseKeeperHistoryModeGlobal)); $histortTab->addClass('border_dotted objectgroup element-row'); $houseKeeperTab->addRow(_('History'), new CDiv($histortTab)); // trend $trendTab = new CTable(null, 'formElementTable'); $trendTab->addRow(array(new CLabel(_('Enable internal housekeeping'), 'hk_trends_mode'), new CCheckBox('hk_trends_mode', $this->data['config']['hk_trends_mode'], null, 1))); $houseKeeperTrendGlobal = new CCheckBox('hk_trends_global', $this->data['config']['hk_trends_global'], null, 1); $houseKeeperTrendModeGlobal = new CNumericBox('hk_trends', $this->data['config']['hk_trends'], 5); if (!$this->data['config']['hk_trends_global']) { $houseKeeperTrendModeGlobal->setAttribute('disabled', 'disabled'); } $trendTab->addRow(array(new CLabel(_('Override item trend period'), 'hk_trends_global'), $houseKeeperTrendGlobal)); $trendTab->addRow(array(new CLabel(_('Data storage period (in days)'), 'hk_trends'), $houseKeeperTrendModeGlobal)); $trendTab->addClass('border_dotted objectgroup element-row'); $houseKeeperTab->addRow(_('Trends'), new CDiv($trendTab)); $houseKeeperView = new CTabView(); $houseKeeperView->addTab('houseKeeper', _('Housekeeping'), $houseKeeperTab); $houseKeeperForm = new CForm(); $houseKeeperForm->setName('houseKeeperForm'); $houseKeeperForm->addVar('form_refresh', $this->data['form_refresh'] + 1); $houseKeeperForm->addItem($houseKeeperView); $houseKeeperForm->addItem(makeFormFooter(new CSubmit('save', _('Save')), new CButton('resetDefaults', _('Reset defaults')))); return $houseKeeperForm;
function get_item_filter_form(&$items) { $filter_group = $_REQUEST['filter_group']; $filter_host = $_REQUEST['filter_host']; $filter_application = $_REQUEST['filter_application']; $filter_description = $_REQUEST['filter_description']; $filter_type = $_REQUEST['filter_type']; $filter_key = $_REQUEST['filter_key']; $filter_snmp_community = $_REQUEST['filter_snmp_community']; $filter_snmpv3_securityname = $_REQUEST['filter_snmpv3_securityname']; $filter_snmp_oid = $_REQUEST['filter_snmp_oid']; $filter_snmp_port = $_REQUEST['filter_snmp_port']; $filter_value_type = $_REQUEST['filter_value_type']; $filter_data_type = $_REQUEST['filter_data_type']; $filter_delay = $_REQUEST['filter_delay']; $filter_history = $_REQUEST['filter_history']; $filter_trends = $_REQUEST['filter_trends']; $filter_status = $_REQUEST['filter_status']; $filter_templated_items = $_REQUEST['filter_templated_items']; $filter_with_triggers = $_REQUEST['filter_with_triggers']; // subfilter $subfilter_hosts = $_REQUEST['subfilter_hosts']; $subfilter_apps = $_REQUEST['subfilter_apps']; $subfilter_types = $_REQUEST['subfilter_types']; $subfilter_value_types = $_REQUEST['subfilter_value_types']; $subfilter_status = $_REQUEST['subfilter_status']; $subfilter_templated_items = $_REQUEST['subfilter_templated_items']; $subfilter_with_triggers = $_REQUEST['subfilter_with_triggers']; $subfilter_history = $_REQUEST['subfilter_history']; $subfilter_trends = $_REQUEST['subfilter_trends']; $subfilter_interval = $_REQUEST['subfilter_interval']; $form = new CForm(); $form->setAttribute('name', 'zbx_filter'); $form->setAttribute('id', 'zbx_filter'); $form->setMethod('get'); $form->addVar('filter_hostid', get_request('filter_hostid', get_request('hostid'))); $form->addVar('subfilter_hosts', $subfilter_hosts); $form->addVar('subfilter_apps', $subfilter_apps); $form->addVar('subfilter_types', $subfilter_types); $form->addVar('subfilter_value_types', $subfilter_value_types); $form->addVar('subfilter_status', $subfilter_status); $form->addVar('subfilter_templated_items', $subfilter_templated_items); $form->addVar('subfilter_with_triggers', $subfilter_with_triggers); $form->addVar('subfilter_history', $subfilter_history); $form->addVar('subfilter_trends', $subfilter_trends); $form->addVar('subfilter_interval', $subfilter_interval); // FORM FOR FILTER DISPLAY { $table = new CTable('', 'itemfilter'); $table->setCellPadding(0); $table->setCellSpacing(0); // 1st col $col_table1 = new CTable(); $col_table1->setClass('filter'); $col_table1->addRow(array(bold(S_HOST_GROUP . ': '), array(new CTextBox('filter_group', $filter_group, 20), new CButton('btn_group', S_SELECT, 'return PopUp("popup.php?dstfrm=' . $form->getName() . '&dstfld1=filter_group&srctbl=host_group&srcfld1=name",450,450);', 'G')))); $col_table1->addRow(array(bold(S_HOST . ': '), array(new CTextBox('filter_host', $filter_host, 20), new CButton('btn_host', S_SELECT, 'return PopUp("popup.php?dstfrm=' . $form->getName() . '&dstfld1=filter_host&srctbl=hosts_and_templates&srcfld1=host",450,450);', 'H')))); $col_table1->addRow(array(bold(S_APPLICATION . ': '), array(new CTextBox('filter_application', $filter_application, 20), new CButton('btn_app', S_SELECT, 'return PopUp("popup.php?dstfrm=' . $form->getName() . '&dstfld1=filter_application&srctbl=applications&srcfld1=name",400,300,"application");', 'A')))); $col_table1->addRow(array(array(bold(S_DESCRIPTION), SPACE . S_LIKE_SMALL . ': '), new CTextBox("filter_description", $filter_description, 30))); $col_table1->addRow(array(array(bold(S_KEY), SPACE . S_LIKE_SMALL . ': '), new CTextBox("filter_key", $filter_key, 30))); // 2nd col $col_table2 = new CTable(); $col_table2->setClass('filter'); $fTypeVisibility = array(); //first row $cmbType = new CComboBox("filter_type", $filter_type); //"javascript: create_var('zbx_filter', 'filter_set', '1', true); "); $cmbType->setAttribute('id', 'filter_type'); $cmbType->addItem(-1, S_ALL_SMALL); foreach (array('filter_delay_label', 'filter_delay') as $vItem) { zbx_subarray_push($fTypeVisibility, -1, $vItem); } $itemTypes = item_type2str(); // httptest items are only for internal zabbix logic unset($itemTypes[ITEM_TYPE_HTTPTEST]); $cmbType->addItems($itemTypes); foreach ($itemTypes as $typeNum => $typeLabel) { if ($typeNum != ITEM_TYPE_TRAPPER) { zbx_subarray_push($fTypeVisibility, $typeNum, 'filter_delay_label'); zbx_subarray_push($fTypeVisibility, $typeNum, 'filter_delay'); } switch ($typeNum) { case ITEM_TYPE_SNMPV1: case ITEM_TYPE_SNMPV2C: $snmp_types = array('filter_snmp_community_label', 'filter_snmp_community', 'filter_snmp_oid_label', 'filter_snmp_oid', 'filter_snmp_port_label', 'filter_snmp_port'); foreach ($snmp_types as $vItem) { zbx_subarray_push($fTypeVisibility, $typeNum, $vItem); } break; case ITEM_TYPE_SNMPV3: foreach (array('filter_snmpv3_securityname_label', 'filter_snmpv3_securityname', 'filter_snmp_oid_label', 'filter_snmp_oid', 'filter_snmp_port_label', 'filter_snmp_port') as $vItem) { zbx_subarray_push($fTypeVisibility, $typeNum, $vItem); } break; } } zbx_add_post_js("var filterTypeSwitcher = new CViewSwitcher('filter_type', 'change', " . zbx_jsvalue($fTypeVisibility, true) . ");"); $col21 = new CCol(bold(S_TYPE . ': ')); $col21->setAttribute('style', 'width: 170px'); $col_table2->addRow(array($col21, $cmbType)); //second row $label221 = new CSpan(bold(S_UPDATE_INTERVAL_IN_SEC . ': ')); $label221->setAttribute('id', 'filter_delay_label'); $field221 = new CNumericBox('filter_delay', $filter_delay, 5, null, true); $field221->setEnabled('no'); $col_table2->addRow(array(array($label221, SPACE), array($field221, SPACE))); //third row $label231 = new CSpan(array(bold(S_SNMP_COMMUNITY), SPACE . S_LIKE_SMALL . ': ')); $label231->setAttribute('id', 'filter_snmp_community_label'); $field231 = new CTextBox('filter_snmp_community', $filter_snmp_community, 40); $field231->setEnabled('no'); $label232 = new CSpan(array(bold(S_SNMPV3_SECURITY_NAME), SPACE . S_LIKE_SMALL . ': ')); $label232->setAttribute('id', 'filter_snmpv3_securityname_label'); $field232 = new CTextBox('filter_snmpv3_securityname', $filter_snmpv3_securityname, 40); $field232->setEnabled('no'); $col_table2->addRow(array(array($label231, $label232, SPACE), array($field231, $field232, SPACE))); //fourth row $label241 = new CSpan(array(bold(S_SNMP_OID), SPACE . S_LIKE_SMALL . ': ')); $label241->setAttribute('id', 'filter_snmp_oid_label'); $field241 = new CTextBox('filter_snmp_oid', $filter_snmp_oid, 40); $field241->setEnabled('no'); $col_table2->addRow(array(array($label241, SPACE), array($field241, SPACE))); //fifth row $label251 = new CSpan(array(bold(S_SNMP_PORT), SPACE . S_LIKE_SMALL . ': ')); $label251->setAttribute('id', 'filter_snmp_port_label'); $field251 = new CNumericBox('filter_snmp_port', $filter_snmp_port, 5, null, true); $field251->setEnabled('no'); $col_table2->addRow(array(array($label251, SPACE), array($field251, SPACE))); // 3rd col $col_table3 = new CTable(); $col_table3->setClass('filter'); $fVTypeVisibility = array(); $cmbValType = new CComboBox('filter_value_type', $filter_value_type); //, "javascript: create_var('zbx_filter', 'filter_set', '1', true);"); $cmbValType->addItem(-1, S_ALL_SMALL); $cmbValType->addItem(ITEM_VALUE_TYPE_UINT64, S_NUMERIC_UNSIGNED); $cmbValType->addItem(ITEM_VALUE_TYPE_FLOAT, S_NUMERIC_FLOAT); $cmbValType->addItem(ITEM_VALUE_TYPE_STR, S_CHARACTER); $cmbValType->addItem(ITEM_VALUE_TYPE_LOG, S_LOG); $cmbValType->addItem(ITEM_VALUE_TYPE_TEXT, S_TEXT); foreach (array('filter_data_type_label', 'filter_data_type') as $vItem) { zbx_subarray_push($fVTypeVisibility, ITEM_VALUE_TYPE_UINT64, $vItem); } $col_table3->addRow(array(bold(S_TYPE_OF_INFORMATION . ': '), $cmbValType)); zbx_add_post_js("var filterValueTypeSwitcher = new CViewSwitcher('filter_value_type', 'change', " . zbx_jsvalue($fVTypeVisibility, true) . ");"); //second row $label321 = new CSpan(bold(S_DATA_TYPE . ': ')); $label321->setAttribute('id', 'filter_data_type_label'); $field321 = new CComboBox('filter_data_type', $filter_data_type); //, 'submit()'); $field321->addItem(-1, S_ALL_SMALL); $field321->addItem(ITEM_DATA_TYPE_DECIMAL, item_data_type2str(ITEM_DATA_TYPE_DECIMAL)); $field321->addItem(ITEM_DATA_TYPE_OCTAL, item_data_type2str(ITEM_DATA_TYPE_OCTAL)); $field321->addItem(ITEM_DATA_TYPE_HEXADECIMAL, item_data_type2str(ITEM_DATA_TYPE_HEXADECIMAL)); $field321->setEnabled('no'); $col_table3->addRow(array(array($label321, SPACE), array($field321, SPACE))); $col_table3->addRow(array(bold(S_KEEP_HISTORY_IN_DAYS . ': '), new CNumericBox('filter_history', $filter_history, 8, null, true))); $col_table3->addRow(array(bold(S_KEEP_TRENDS_IN_DAYS . ': '), new CNumericBox('filter_trends', $filter_trends, 8, null, true))); // 4th col $col_table4 = new CTable(); $col_table4->setClass('filter'); $cmbStatus = new CComboBox('filter_status', $filter_status); $cmbStatus->addItem(-1, S_ALL_SMALL); foreach (array(ITEM_STATUS_ACTIVE, ITEM_STATUS_DISABLED, ITEM_STATUS_NOTSUPPORTED) as $st) { $cmbStatus->addItem($st, item_status2str($st)); } $cmbBelongs = new CComboBox('filter_templated_items', $filter_templated_items); $cmbBelongs->addItem(-1, S_ALL_SMALL); $cmbBelongs->addItem(1, S_TEMPLATED_ITEMS); $cmbBelongs->addItem(0, S_NOT_TEMPLATED_ITEMS); $cmbWithTriggers = new CComboBox('filter_with_triggers', $filter_with_triggers); $cmbWithTriggers->addItem(-1, S_ALL_SMALL); $cmbWithTriggers->addItem(1, S_WITH_TRIGGERS); $cmbWithTriggers->addItem(0, S_WITHOUT_TRIGGERS); $col_table4->addRow(array(bold(S_STATUS . ': '), $cmbStatus)); $col_table4->addRow(array(bold(S_TRIGGERS . ': '), $cmbWithTriggers)); $col_table4->addRow(array(bold(S_TEMPLATE . ': '), $cmbBelongs)); //adding all cols tables to main table $col1 = new CCol($col_table1, 'top'); $col1->setAttribute('style', 'width: 280px'); $col2 = new CCol($col_table2, 'top'); $col2->setAttribute('style', 'width: 410px'); $col3 = new CCol($col_table3, 'top'); $col3->setAttribute('style', 'width: 160px'); $col4 = new CCol($col_table4, 'top'); $table->addRow(array($col1, $col2, $col3, $col4)); $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);"); $div_buttons = new CDiv(array($filter, SPACE, SPACE, SPACE, $reset)); $div_buttons->setAttribute('style', 'padding: 4px 0;'); $footer = new CCol($div_buttons, 'center'); $footer->setColSpan(4); $table->addRow($footer); $form->addItem($table); // } FORM FOR FILTER DISPLAY // SUBFILTERS { $h = new CDiv(S_SUBFILTER . SPACE . '[' . S_AFFECTS_ONLY_FILTERED_DATA_SMALL . ']'); $h->setClass('thin_header'); $form->addItem($h); $table_subfilter = new Ctable(); $table_subfilter->setClass('filter'); // array contains subfilters and number of items in each $item_params = array('hosts' => array(), 'applications' => array(), 'types' => array(), 'value_types' => array(), 'status' => array(), 'templated_items' => array(), 'with_triggers' => array(), 'history' => array(), 'trends' => array(), 'interval' => array()); // generate array with values for subfilters of selected items foreach ($items as $num => $item) { if (zbx_empty($filter_host)) { // hosts $host = reset($item['hosts']); if (!isset($item_params['hosts'][$host['hostid']])) { $item_params['hosts'][$host['hostid']] = array('name' => $host['host'], 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_hosts') { continue; } $show_item &= $value; } if ($show_item) { $host = reset($item['hosts']); $item_params['hosts'][$host['hostid']]['count']++; } } // applications foreach ($item['applications'] as $appid => $app) { if (!isset($item_params['applications'][$app['name']])) { $item_params['applications'][$app['name']] = array('name' => $app['name'], 'count' => 0); } } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_apps') { continue; } $show_item &= $value; } $sel_app = false; if ($show_item) { // if any of item applications are selected foreach ($item['applications'] as $app) { if (str_in_array($app['name'], $subfilter_apps)) { $sel_app = true; break; } } foreach ($item['applications'] as $app) { if (str_in_array($app['name'], $subfilter_apps) || !$sel_app) { $item_params['applications'][$app['name']]['count']++; } } } // types if ($filter_type == -1) { if (!isset($item_params['types'][$item['type']])) { $item_params['types'][$item['type']] = array('name' => item_type2str($item['type']), 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_types') { continue; } $show_item &= $value; } if ($show_item) { $item_params['types'][$item['type']]['count']++; } } // value types if ($filter_value_type == -1) { if (!isset($item_params['value_types'][$item['value_type']])) { $item_params['value_types'][$item['value_type']] = array('name' => item_value_type2str($item['value_type']), 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_value_types') { continue; } $show_item &= $value; } if ($show_item) { $item_params['value_types'][$item['value_type']]['count']++; } } // status if ($filter_status == -1) { if (!isset($item_params['status'][$item['status']])) { $item_params['status'][$item['status']] = array('name' => item_status2str($item['status']), 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_status') { continue; } $show_item &= $value; } if ($show_item) { $item_params['status'][$item['status']]['count']++; } } // template if ($filter_templated_items == -1) { if ($item['templateid'] == 0 && !isset($item_params['templated_items'][0])) { $item_params['templated_items'][0] = array('name' => S_NOT_TEMPLATED_ITEMS, 'count' => 0); } else { if ($item['templateid'] > 0 && !isset($item_params['templated_items'][1])) { $item_params['templated_items'][1] = array('name' => S_TEMPLATED_ITEMS, 'count' => 0); } } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_templated_items') { continue; } $show_item &= $value; } if ($show_item) { if ($item['templateid'] == 0) { $item_params['templated_items'][0]['count']++; } else { $item_params['templated_items'][1]['count']++; } } } // with triggers if ($filter_with_triggers == -1) { if (count($item['triggers']) == 0 && !isset($item_params['with_triggers'][0])) { $item_params['with_triggers'][0] = array('name' => S_WITHOUT_TRIGGERS, 'count' => 0); } else { if (count($item['triggers']) > 0 && !isset($item_params['with_triggers'][1])) { $item_params['with_triggers'][1] = array('name' => S_WITH_TRIGGERS, 'count' => 0); } } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_with_triggers') { continue; } $show_item &= $value; } if ($show_item) { if (count($item['triggers']) == 0) { $item_params['with_triggers'][0]['count']++; } else { $item_params['with_triggers'][1]['count']++; } } } // trends if (zbx_empty($filter_trends)) { if (!isset($item_params['trends'][$item['trends']])) { $item_params['trends'][$item['trends']] = array('name' => $item['trends'], 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_trends') { continue; } $show_item &= $value; } if ($show_item) { $item_params['trends'][$item['trends']]['count']++; } } // history if (zbx_empty($filter_history)) { if (!isset($item_params['history'][$item['history']])) { $item_params['history'][$item['history']] = array('name' => $item['history'], 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_history') { continue; } $show_item &= $value; } if ($show_item) { $item_params['history'][$item['history']]['count']++; } } // interval if (zbx_empty($filter_delay) && $filter_type != ITEM_TYPE_TRAPPER) { if (!isset($item_params['interval'][$item['delay']])) { $item_params['interval'][$item['delay']] = array('name' => $item['delay'], 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_interval') { continue; } $show_item &= $value; } if ($show_item) { $item_params['interval'][$item['delay']]['count']++; } } } // output if (zbx_empty($filter_host) && count($item_params['hosts']) > 1) { $hosts_output = prepare_subfilter_output($item_params['hosts'], $subfilter_hosts, 'subfilter_hosts'); $table_subfilter->addRow(array(S_HOSTS, $hosts_output)); } if (!empty($item_params['applications']) && count($item_params['applications']) > 1) { $application_output = prepare_subfilter_output($item_params['applications'], $subfilter_apps, 'subfilter_apps'); $table_subfilter->addRow(array(S_APPLICATIONS, $application_output)); } if ($filter_type == -1 && count($item_params['types']) > 1) { $type_output = prepare_subfilter_output($item_params['types'], $subfilter_types, 'subfilter_types'); $table_subfilter->addRow(array(S_TYPES, $type_output)); } if ($filter_value_type == -1 && count($item_params['value_types']) > 1) { $value_types_output = prepare_subfilter_output($item_params['value_types'], $subfilter_value_types, 'subfilter_value_types'); $table_subfilter->addRow(array(S_TYPE_OF_INFORMATION, $value_types_output)); } if ($filter_status == -1 && count($item_params['status']) > 1) { $status_output = prepare_subfilter_output($item_params['status'], $subfilter_status, 'subfilter_status'); $table_subfilter->addRow(array(S_STATUS, $status_output)); } if ($filter_templated_items == -1 && count($item_params['templated_items']) > 1) { $templated_items_output = prepare_subfilter_output($item_params['templated_items'], $subfilter_templated_items, 'subfilter_templated_items'); $table_subfilter->addRow(array(S_TEMPLATE, $templated_items_output)); } if ($filter_with_triggers == -1 && count($item_params['with_triggers']) > 1) { $with_triggers_output = prepare_subfilter_output($item_params['with_triggers'], $subfilter_with_triggers, 'subfilter_with_triggers'); $table_subfilter->addRow(array(S_WITH_TRIGGERS, $with_triggers_output)); } if (zbx_empty($filter_history) && count($item_params['history']) > 1) { $history_output = prepare_subfilter_output($item_params['history'], $subfilter_history, 'subfilter_history'); $table_subfilter->addRow(array(S_HISTORY, $history_output)); } if (zbx_empty($filter_trends) && count($item_params['trends']) > 1) { $trends_output = prepare_subfilter_output($item_params['trends'], $subfilter_trends, 'subfilter_trends'); $table_subfilter->addRow(array(S_TRENDS, $trends_output)); } if (zbx_empty($filter_delay) && $filter_type != ITEM_TYPE_TRAPPER && count($item_params['interval']) > 1) { $interval_output = prepare_subfilter_output($item_params['interval'], $subfilter_interval, 'subfilter_interval'); $table_subfilter->addRow(array(S_INTERVAL, $interval_output)); } //} SUBFILTERS $form->addItem($table_subfilter); return $form; }
$year = ''; $month = ''; $day = ''; $hours = ''; $minutes = ''; } $maintenanceForm->addVar('active_till', $year . $month . $day . $hours . $minutes); $maintenanceTillDay = new CNumericBox('mntc_till_day', $day, 2); $maintenanceTillDay->setAttribute('placeholder', _('dd')); $maintenanceTillMonth = new CNumericBox('mntc_till_month', $month, 2); $maintenanceTillMonth->setAttribute('placeholder', _('mm')); $maintenanceTillYear = new CNumericBox('mntc_till_year', $year, 4); $maintenanceTillYear->setAttribute('placeholder', _('yyyy')); $maintenanceTillHour = new CNumericBox('mntc_till_hour', $hours, 2); $maintenanceTillHour->setAttribute('placeholder', _('hh')); $maintenanceTillMinute = new CNumericBox('mntc_till_minute', $minutes, 2); $maintenanceTillMinute->setAttribute('placeholder', _('mm')); $maintenanceFormList->addRow(_('Active till'), array($maintenanceTillDay, '/', $maintenanceTillMonth, '/', $maintenanceTillYear, SPACE, $maintenanceTillHour, ':', $maintenanceTillMinute, $calendarIcon)); zbx_add_post_js('create_calendar(null, ["mntc_till_day", "mntc_till_month", "mntc_till_year", "mntc_till_hour", "mntc_till_minute"], "mntc_active_till", "active_till");'); $maintenanceFormList->addRow(_('Description'), new CTextArea('description', $this->data['description'])); /* * Maintenance period tab */ $maintenancePeriodFormList = new CFormList('maintenancePeriodFormList'); $maintenancePeriodTable = new CTableInfo(_('No maintenance period defined.')); $maintenancePeriodTable->setHeader(array(new CCheckBox('all_periods', null, 'checkAll("' . $maintenanceForm->getName() . '", "all_periods", "g_timeperiodid");'), _('Period type'), _('Schedule'), _('Period'), _('Action'))); foreach ($this->data['timeperiods'] as $id => $timeperiod) { $maintenancePeriodTable->addRow(array(new CCheckBox('g_timeperiodid[]', 'no', null, $id), timeperiod_type2str($timeperiod['timeperiod_type']), new CCol(shedule2str($timeperiod), 'wraptext'), zbx_date2age(0, $timeperiod['period']), new CSubmit('edit_timeperiodid[' . $id . ']', _('Edit'), null, 'link_menu'))); if (isset($timeperiod['timeperiodid'])) { $maintenanceForm->addVar('timeperiods[' . $id . '][timeperiodid]', $timeperiod['timeperiodid']); }
if (!isset($new_operation['opconditions'])) { $new_operation['opconditions'] = array(); } if (!isset($new_operation['default_msg'])) { $new_operation['default_msg'] = 0; } $evaltype = $new_operation['evaltype']; $update_mode = false; if (isset($new_operation['id'])) { $tblOper->addItem(new CVar('new_operation[id]', $new_operation['id'])); $update_mode = true; } $tblNewOperation = new CTable(); if (isset($_REQUEST['escalation'])) { $tblStep = new CTable(); $step_from = new CNumericBox('new_operation[esc_step_from]', $new_operation['esc_step_from'], 4); $step_from->addAction('onchange', 'javascript:' . $step_from->getAttribute('onchange') . ' if(this.value == 0) this.value=1;'); $tblStep->addRow(array(S_FROM, $step_from)); $tblStep->addRow(array(S_TO, new CCol(array(new CNumericBox('new_operation[esc_step_to]', $new_operation['esc_step_to'], 4), ' [0-' . S_INFINITY . ']')))); $tblStep->addRow(array(S_PERIOD, new CCol(array(new CNumericBox('new_operation[esc_period]', $new_operation['esc_period'], 5), ' [' . S_MIN_SMALL . ' 60, 0-' . S_DEFAULT . ']')))); $tblNewOperation->addRow(array(S_STEP, $tblStep)); } else { $tblOper->addItem(new CVar('new_operation[esc_period]', $new_operation['esc_period'])); $tblOper->addItem(new CVar('new_operation[esc_step_from]', $new_operation['esc_step_from'])); $tblOper->addItem(new CVar('new_operation[esc_step_to]', $new_operation['esc_step_to'])); $tblOper->addItem(new CVar('new_operation[evaltype]', $new_operation['evaltype'])); } $cmbOpType = new CComboBox('new_operation[operationtype]', $new_operation['operationtype'], 'submit()'); foreach ($allowed_operations as $oper) { $cmbOpType->addItem($oper, operation_type2str($oper)); }