} $filterForm->addRow(S_EVENTS, $ev_select); $severity_select = new CComboBox('show_severity', $show_severity); $cb_items = array(-1 => S_ALL_S, TRIGGER_SEVERITY_NOT_CLASSIFIED => S_NOT_CLASSIFIED, TRIGGER_SEVERITY_INFORMATION => S_INFORMATION, TRIGGER_SEVERITY_WARNING => S_WARNING, TRIGGER_SEVERITY_AVERAGE => S_AVERAGE, TRIGGER_SEVERITY_HIGH => S_HIGH, TRIGGER_SEVERITY_DISASTER => S_DISASTER); $severity_select->addItems($cb_items); $filterForm->addRow(S_MIN_SEVERITY, $severity_select); $action = 'javascrip: this.checked ? $("status_change_days").enable() : $("status_change_days").disable()'; $sts_change_days_cb = new CNumericBox('status_change_days', $_REQUEST['status_change_days'], 4); if (!$_REQUEST['status_change']) { $sts_change_days_cb->setAttribute('disabled', 'disabled'); } $sts_change_days_cb->addStyle('vertical-align: middle;'); $cbd = new CCheckBox('status_change', $_REQUEST['status_change'], $action, 1); $cbd->addStyle('vertical-align: middle;'); $spand = new CSpan(S_DAYS_SMALL); $spand->addStyle('vertical-align: middle;'); $filterForm->addRow(S_AGE_LESS_THAN, array($cbd, $sts_change_days_cb, $spand)); $filterForm->addRow(S_SHOW_DETAILS, new CCheckBox('show_details', $_REQUEST['show_details'], null, 1)); $filterForm->addRow(S_FILTER_BY_NAME, new CTextBox('txt_select', $_REQUEST['txt_select'], 40)); $filterForm->addItemToBottomRow(new CButton('filter_set', S_FILTER)); $filterForm->addItemToBottomRow(new CButton('filter_rst', S_RESET)); $trigg_wdgt->addFlicker($filterForm, CProfile::get('web.tr_status.filter.state', 0)); /*************** FILTER END ******************/ if ($_REQUEST['fullscreen']) { $triggerInfo = new CTriggersInfo($_REQUEST['groupid'], $_REQUEST['hostid']); $triggerInfo->HideHeader(); $triggerInfo->show(); } $m_form = new CForm('acknow.php'); $m_form->setName('tr_status'); $m_form->addVar('backurl', $page['file']);
$populatingLink = new CLink($itemName, 'items.php?form=update&itemid=' . $hostItemsToInventory[$inventoryNo]['itemid']); $populatingLink->setAttribute('title', _s('This field is automatically populated by item "%s".', $itemName)); $populatingItemCell = array(' ← ', $populatingLink); $input->addClass('linked_to_item'); // this will be used for disabling fields via jquery if ($inventory_mode == HOST_INVENTORY_AUTOMATIC) { $input->setAttribute('disabled', 'disabled'); } } else { $populatingItemCell = ''; } $input->addStyle('float: left;'); $populatingItem = new CSpan($populatingItemCell, 'populating_item'); if ($inventory_mode != HOST_INVENTORY_AUTOMATIC) { // those links are visible only in automatic mode $populatingItem->addStyle('display: none'); } $inventoryFormList->addRow($inventoryInfo['title'], array($input, $populatingItem)); } // clearing the float $clearFixDiv = new CDiv(); $clearFixDiv->addStyle('clear: both;'); $inventoryFormList->addRow('', $clearFixDiv); $divTabs->addTab('inventoryTab', _('Host inventory'), $inventoryFormList); $frmHost->addItem($divTabs); /* * footer */ $others = array(); // do not display the clone and delete buttons for clone forms and new host forms if (getRequest('hostid') && !in_array(getRequest('form'), array('clone', 'full_clone'))) {
$eventsComboBox->addItem(EVENTS_OPTION_NOT_ACK, _n('Show unacknowledged (%1$s day)', 'Show unacknowledged (%1$s days)', $config['event_expire'])); } $filterForm->addRow(_('Events'), $eventsComboBox); } // min severity $filterForm->addRow(_('Minimum trigger severity'), new CComboBox('show_severity', $filter['showSeverity'], null, array(TRIGGER_SEVERITY_NOT_CLASSIFIED => getSeverityCaption(TRIGGER_SEVERITY_NOT_CLASSIFIED), TRIGGER_SEVERITY_INFORMATION => getSeverityCaption(TRIGGER_SEVERITY_INFORMATION), TRIGGER_SEVERITY_WARNING => getSeverityCaption(TRIGGER_SEVERITY_WARNING), TRIGGER_SEVERITY_AVERAGE => getSeverityCaption(TRIGGER_SEVERITY_AVERAGE), TRIGGER_SEVERITY_HIGH => getSeverityCaption(TRIGGER_SEVERITY_HIGH), TRIGGER_SEVERITY_DISASTER => getSeverityCaption(TRIGGER_SEVERITY_DISASTER)))); // age less than $statusChangeDays = new CNumericBox('status_change_days', $filter['statusChangeDays'], 3, false, false, false); if (!$filter['statusChange']) { $statusChangeDays->setAttribute('disabled', 'disabled'); } $statusChangeDays->addStyle('vertical-align: middle;'); $statusChangeCheckBox = new CCheckBox('status_change', $filter['statusChange'], 'javascript: this.checked ? $("status_change_days").enable() : $("status_change_days").disable()', 1); $statusChangeCheckBox->addStyle('vertical-align: middle;'); $daysSpan = new CSpan(_('days')); $daysSpan->addStyle('vertical-align: middle;'); $filterForm->addRow(_('Age less than'), array($statusChangeCheckBox, $statusChangeDays, SPACE, $daysSpan)); // name $filterForm->addRow(_('Filter by name'), new CTextBox('txt_select', $filter['txtSelect'], 40)); // application $filterForm->addRow(_('Filter by application'), array(new CTextBox('application', $filter['application'], 40), new CButton('application_name', _('Select'), 'return PopUp("popup.php?srctbl=applications&srcfld1=name&real_hosts=1&dstfld1=application&with_applications=1' . '&dstfrm=' . $filterForm->getName() . '");', 'filter-button'))); // inventory filter $inventoryFilters = $filter['inventory']; if (!$inventoryFilters) { $inventoryFilters = array(array('field' => '', 'value' => '')); } $inventoryFields = array(); foreach (getHostInventories() as $inventory) { $inventoryFields[$inventory['db_field']] = $inventory['title']; } $inventoryFilterTable = new CTable();
} if (!$readonly) { include dirname(__FILE__) . '/js/common.macros.js.php'; } $macrosTable = new CTable(SPACE, 'formElementTable'); $macrosTable->setAttribute('id', 'tbl_macros'); $macrosTable->addRow(array(_('Macro'), SPACE, _('Value'), SPACE)); // fields foreach ($macros as $i => $macro) { $text1 = new CTextBox('macros[' . $i . '][macro]', $macro['macro'], 30, $readonly, 64); $text1->addClass('macro'); $text1->setAttribute('placeholder', '{$MACRO}'); $text2 = new CTextBox('macros[' . $i . '][value]', $macro['value'], 40, $readonly, 255); $text2->setAttribute('placeholder', _('value')); $span = new CSpan('⇒'); $span->addStyle('vertical-align:top;'); $deleteButtonCell = null; if (!$readonly) { $deleteButtonCell = array(new CButton('macros_' . $i . '_remove', _('Remove'), null, 'link_menu element-table-remove')); if (isset($macro['globalmacroid'])) { $deleteButtonCell[] = new CVar('macros[' . $i . '][globalmacroid]', $macro['globalmacroid'], 'macros_' . $i . '_id'); } if (isset($macro['hostmacroid'])) { $deleteButtonCell[] = new CVar('macros[' . $i . '][hostmacroid]', $macro['hostmacroid'], 'macros_' . $i . '_id'); } } $row = array($text1, $span, $text2, $deleteButtonCell); $macrosTable->addRow($row, 'form_row'); } // buttons if (!$readonly) {
function get_macros_widget($hostid = null) { if (isset($_REQUEST['form_refresh'])) { $macros = get_request('macros', array()); } else { if ($hostid > 0) { $macros = CUserMacro::get(array('output' => API_OUTPUT_EXTEND, 'hostids' => $hostid)); order_result($macros, 'macro'); } else { if ($hostid === null) { $macros = CUserMacro::get(array('output' => API_OUTPUT_EXTEND, 'globalmacro' => 1)); order_result($macros, 'macro'); } else { $macros = array(); } } } if (empty($macros)) { $macros = array(0 => array('macro' => '', 'value' => '')); } $macros_tbl = new CTable(SPACE, 'formElementTable'); $macros_tbl->setAttribute('id', 'tbl_macros'); $macros_tbl->addRow(array(SPACE, S_MACRO, SPACE, S_VALUE)); insert_js(' function addMacroRow(){ if(typeof(addMacroRow.macro_count) == "undefined"){ addMacroRow.macro_count = ' . count($macros) . '; } var tr = document.createElement("tr"); tr.className = (addMacroRow.macro_count % 2) ? "form_even_row" : "form_odd_row"; var td1 = document.createElement("td"); tr.appendChild(td1); var cb = document.createElement("input"); cb.setAttribute("type", "checkbox"); cb.className = "checkbox"; td1.appendChild(cb); td1.appendChild(document.createTextNode(" ")); var td2 = document.createElement("td"); tr.appendChild(td2); var text1 = document.createElement("input"); text1.setAttribute("type", "text"); text1.setAttribute("name", "macros["+addMacroRow.macro_count+"][macro]"); text1.className = "biginput"; text1.setAttribute("size",30); text1.setAttribute("placeholder","{$MACRO}"); td2.appendChild(text1); td2.appendChild(document.createTextNode(" ")); var td3 = document.createElement("td"); tr.appendChild(td3); var span = document.createElement("span"); span.innerHTML = "⇒"; span.setAttribute("style", "vertical-align:top;"); td3.appendChild(span); var td4 = document.createElement("td"); tr.appendChild(td4); var text2 = document.createElement("input"); text2.setAttribute("type", "text"); text2.setAttribute("placeholder","<' . S_VALUE . '>"); text2.setAttribute("name","macros["+addMacroRow.macro_count+"][value]"); text2.className = "biginput"; text2.setAttribute("size",40); td4.appendChild(text2); var sd = $("row_new_macro").insert({before : tr}); addMacroRow.macro_count++; } '); $macros = array_values($macros); foreach ($macros as $macroid => $macro) { $text1 = new CTextBox('macros[' . $macroid . '][macro]', $macro['macro'], 30); $text1->setAttribute('placeholder', '{$MACRO}'); $text2 = new CTextBox('macros[' . $macroid . '][value]', $macro['value'], 40); $text2->setAttribute('placeholder', '<' . S_VALUE . '>'); $span = new CSpan(RARR); $span->addStyle('vertical-align:top;'); $macros_tbl->addRow(array(new CCheckBox(), $text1, $span, $text2)); } $script = '$$("#tbl_macros input:checked").each(function(obj){ $(obj.parentNode.parentNode).remove(); if (typeof(deleted_macro_cnt) == \'undefined\') deleted_macro_cnt=1; else deleted_macro_cnt++; });'; $delete_btn = new CButton('macros_del', S_DELETE_SELECTED, $script); $delete_btn->setType('button'); $add_button = new CButton('macro_add', S_ADD, 'javascript: addMacroRow()'); $add_button->setType('button'); $buttonRow = new CRow(); $buttonRow->setAttribute('id', 'row_new_macro'); $col = new CCol(array($add_button, SPACE, $delete_btn)); $col->setAttribute('colspan', 4); $buttonRow->addItem($col); $macros_tbl->addRow($buttonRow); $footer = null; if ($hostid === null) { $footer = array(new CButton('save', S_SAVE, "if (deleted_macro_cnt > 0) return confirm('" . S_ARE_YOU_SURE_YOU_WANT_TO_DELETE . " '+deleted_macro_cnt+' " . S_MACROS_ES . "?');")); } return new CFormElement(S_MACROS, $macros_tbl, $footer); }