Exemple #1
0
 public function __construct($name, $value)
 {
     parent::__construct();
     $lbl = new CColorCell('lbl_' . $name, $value, "show_color_picker('" . $name . "')");
     $txt = new CTextBox($name, $value, 7);
     $txt->setAttribute('maxlength', 6);
     $txt->setAttribute('id', $name);
     $txt->addAction('onchange', "set_color_by_name('" . $name . "',this.value)");
     $txt->setAttribute('style', 'margin-top: 0px; margin-bottom: 0px');
     $this->addItem(array($txt, $lbl));
     insert_show_color_picker_javascript();
 }
// append inventories to form list
$inventoryModesComboBox = new CComboBox('inventory_mode', $this->data['inventory_mode'], 'submit()');
$inventoryModesComboBox->addItem(HOST_INVENTORY_DISABLED, _('Disabled'));
$inventoryModesComboBox->addItem(HOST_INVENTORY_MANUAL, _('Manual'));
$inventoryModesComboBox->addItem(HOST_INVENTORY_AUTOMATIC, _('Automatic'));
$hostFormList->addRow(array(_('Inventory mode'), SPACE, new CVisibilityBox('visible[inventory_mode]', isset($this->data['visible']['inventory_mode']), 'inventory_mode', _('Original'))), $inventoryModesComboBox);
$hostInventoryTable = DB::getSchema('host_inventory');
if ($this->data['inventory_mode'] != HOST_INVENTORY_DISABLED) {
    foreach ($this->data['inventories'] as $field => $fieldInfo) {
        if (!isset($this->data['host_inventory'][$field])) {
            $this->data['host_inventory'][$field] = '';
        }
        if ($hostInventoryTable['fields'][$field]['type'] == DB::FIELD_TYPE_TEXT) {
            $fieldInput = new CTextArea('host_inventory[' . $field . ']', $this->data['host_inventory'][$field]);
            $fieldInput->addStyle('width: 64em;');
        } else {
            $fieldLength = $hostInventoryTable['fields'][$field]['length'];
            $fieldInput = new CTextBox('host_inventory[' . $field . ']', $this->data['host_inventory'][$field]);
            $fieldInput->setAttribute('maxlength', $fieldLength);
            $fieldInput->addStyle('width: ' . ($fieldLength > 64 ? 64 : $fieldLength) . 'em;');
        }
        $hostFormList->addRow(array($fieldInfo['title'], SPACE, new CVisibilityBox('visible[' . $field . ']', isset($this->data['visible'][$field]), 'host_inventory[' . $field . ']', _('Original'))), $fieldInput);
    }
}
// append tabs to form
$hostTab = new CTabView();
$hostTab->addTab('hostTab', _('Mass update'), $hostFormList);
$hostForm->addItem($hostTab);
// append buttons to form
$hostForm->addItem(makeFormFooter(new CSubmit('masssave', _('Update')), new CButtonCancel(url_param('groupid'))));
return $hostForm;
// status
$httpFormList->addRow(_('Enabled'), new CCheckBox('status', !$this->data['status']));
/*
 * Authentication tab
 */
$httpAuthenticationFormList = new CFormList('httpAuthenticationFormList');
// Authentication type
$authenticationComboBox = new CComboBox('authentication', $this->data['authentication']);
$authenticationComboBox->addItems(httptest_authentications());
$httpAuthenticationFormList->addRow(_('HTTP authentication'), $authenticationComboBox);
$httpAuthenticationUserTB = new CTextBox('http_user', $this->data['http_user'], ZBX_TEXTBOX_STANDARD_SIZE, false, 64);
$httpAuthenticationPasswordTB = new CTextBox('http_password', $this->data['http_password'], ZBX_TEXTBOX_STANDARD_SIZE, false, 64);
$authenticationInputsHidden = $this->data['authentication'] == HTTPTEST_AUTH_NONE;
if ($authenticationInputsHidden) {
    $httpAuthenticationUserTB->setAttribute('disabled', true);
    $httpAuthenticationPasswordTB->setAttribute('disabled', true);
}
$httpAuthenticationFormList->addRow(_('User'), $httpAuthenticationUserTB, $authenticationInputsHidden);
$httpAuthenticationFormList->addRow(_('Password'), $httpAuthenticationPasswordTB, $authenticationInputsHidden);
// SSL verify peer checkbox
$httpAuthenticationFormList->addRow(_('SSL verify peer'), new CCheckBox('verify_peer', $this->data['verify_peer']));
// SSL verify host checkbox
$httpAuthenticationFormList->addRow(_('SSL verify host'), new CCheckBox('verify_host', $this->data['verify_host']));
// SSL certificate file
$httpAuthenticationFormList->addRow(_('SSL certificate file'), new CTextBox('ssl_cert_file', $this->data['ssl_cert_file'], ZBX_TEXTBOX_STANDARD_SIZE, false, 255));
// SSL key file
$httpAuthenticationFormList->addRow(_('SSL key file'), new CTextBox('ssl_key_file', $this->data['ssl_key_file'], ZBX_TEXTBOX_STANDARD_SIZE, false, 255));
// SSL key password
$httpAuthenticationFormList->addRow(_('SSL key password'), new CTextBox('ssl_key_password', $this->data['ssl_key_password'], ZBX_TEXTBOX_STANDARD_SIZE, false, 64));
/*
 * Step tab
$severityTab->addRow(_('Information'), array($severityNameTB1, SPACE, $severityColorTB1));
$severityNameTB2 = new CTextBox('severity_name_2', $this->data['config']['severity_name_2']);
$severityNameTB2->addStyle('width: 15em;');
$severityNameTB2->setAttribute('maxlength', 32);
$severityColorTB2 = new CColor('severity_color_2', $this->data['config']['severity_color_2']);
$severityTab->addRow(_('Warning'), array($severityNameTB2, SPACE, $severityColorTB2));
$severityNameTB3 = new CTextBox('severity_name_3', $this->data['config']['severity_name_3']);
$severityNameTB3->addStyle('width: 15em;');
$severityNameTB3->setAttribute('maxlength', 32);
$severityColorTB3 = new CColor('severity_color_3', $this->data['config']['severity_color_3']);
$severityTab->addRow(_('Average'), array($severityNameTB3, SPACE, $severityColorTB3));
$severityNameTB4 = new CTextBox('severity_name_4', $this->data['config']['severity_name_4']);
$severityNameTB4->addStyle('width: 15em;');
$severityNameTB4->setAttribute('maxlength', 32);
$severityColorTB4 = new CColor('severity_color_4', $this->data['config']['severity_color_4']);
$severityTab->addRow(_('High'), array($severityNameTB4, SPACE, $severityColorTB4));
$severityNameTB5 = new CTextBox('severity_name_5', $this->data['config']['severity_name_5']);
$severityNameTB5->addStyle('width: 15em;');
$severityNameTB5->setAttribute('maxlength', 32);
$severityColorTB5 = new CColor('severity_color_5', $this->data['config']['severity_color_5']);
$severityTab->addRow(_('Disaster'), array($severityNameTB5, SPACE, $severityColorTB5));
$severityTab->addRow(SPACE);
$severityTab->addInfo(_('Custom severity names affect all locales and require manual translation!'));
$severityView = new CTabView();
$severityView->addTab('severities', _('Trigger severities'), $severityTab);
$severityForm = new CForm();
$severityForm->setName('triggerSeverity');
$severityForm->addVar('form_refresh', $this->data['form_refresh'] + 1);
$severityForm->addItem($severityView);
$severityForm->addItem(makeFormFooter(array(new CSubmit('save', _('Save'))), new CButton('resetDefaults', _('Reset defaults'))));
return $severityForm;
$inventoryAutomaticBtn->setEnabled(!$isDiscovered);
$inventoryTypeRadioButton = array($inventoryDisabledBtn, new CLabel(_('Disabled'), 'host_inventory_radio_' . HOST_INVENTORY_DISABLED), $inventoryManualBtn, new CLabel(_('Manual'), 'host_inventory_radio_' . HOST_INVENTORY_MANUAL), $inventoryAutomaticBtn, new CLabel(_('Automatic'), 'host_inventory_radio_' . HOST_INVENTORY_AUTOMATIC));
$inventoryFormList->addRow(SPACE, new CDiv($inventoryTypeRadioButton, 'jqueryinputset'));
$hostInventoryTable = DB::getSchema('host_inventory');
$hostInventoryFields = getHostInventories();
foreach ($hostInventoryFields as $inventoryNo => $inventoryInfo) {
    if (!isset($host_inventory[$inventoryInfo['db_field']])) {
        $host_inventory[$inventoryInfo['db_field']] = '';
    }
    if ($hostInventoryTable['fields'][$inventoryInfo['db_field']]['type'] == DB::FIELD_TYPE_TEXT) {
        $input = new CTextArea('host_inventory[' . $inventoryInfo['db_field'] . ']', $host_inventory[$inventoryInfo['db_field']]);
        $input->addStyle('width: 64em;');
    } else {
        $fieldLength = $hostInventoryTable['fields'][$inventoryInfo['db_field']]['length'];
        $input = new CTextBox('host_inventory[' . $inventoryInfo['db_field'] . ']', $host_inventory[$inventoryInfo['db_field']]);
        $input->setAttribute('maxlength', $fieldLength);
        $input->addStyle('width: ' . ($fieldLength > 64 ? 64 : $fieldLength) . 'em;');
    }
    if ($inventory_mode == HOST_INVENTORY_DISABLED) {
        $input->setAttribute('disabled', 'disabled');
    }
    // link to populating item at the right side (if any)
    if (isset($hostItemsToInventory[$inventoryNo])) {
        $itemName = itemName($hostItemsToInventory[$inventoryNo]);
        $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');
            $group_tb->addItem($group['groupid'], $group['name']);
        }
    }
} else {
    /*
     * When cloning a template or creating a new one, don't show read-only host groups in left box
     * show empty or posted groups in case of an error.
     */
    foreach ($groupsAllowed as $group) {
        $group_tb->addItem($group['groupid'], $group['name']);
    }
}
$templateList->addRow(_('Groups'), $group_tb->get(_('In groups'), _('Other groups')));
// FORM ITEM : new group text box [  ]
$newgroupTB = new CTextBox('newgroup', $newgroup);
$newgroupTB->setAttribute('maxlength', 64);
$tmp_label = _('New group');
if (CWebUser::$data['type'] != USER_TYPE_SUPER_ADMIN) {
    $tmp_label .= SPACE . _('(Only super admins can create groups)');
    $newgroupTB->setReadonly(true);
}
$templateList->addRow(SPACE, array($tmp_label, BR(), $newgroupTB), null, null, 'new');
// FORM ITEM : linked Hosts tween box [  ] [  ]
$twb_groupid = get_request('twb_groupid', 0);
if ($twb_groupid == 0) {
    $gr = reset($groupsAllowed);
    $twb_groupid = $gr['groupid'];
}
$cmbGroups = new CComboBox('twb_groupid', $twb_groupid, 'submit()');
foreach ($groupsAllowed as $group) {
    $cmbGroups->addItem($group['groupid'], $group['name']);
        } else {
            $sub_menu_div->setAttribute('style', 'display: none;');
        }
        $menu_divs[] = $sub_menu_div;
    }
    $sub_menu_div = new CDiv(SPACE);
    $sub_menu_div->setAttribute('id', 'sub_empty');
    $sub_menu_div->setAttribute('style', 'display: ' . ($menu_selected ? 'none;' : 'block;'));
    $menu_divs[] = $sub_menu_div;
    $search_div = null;
    if ($page['file'] != 'index.php' && $USER_DETAILS['userid'] > 0) {
        $search_form = new CForm('search.php');
        $search_form->setMethod('get');
        $search_form->setAttribute('class', 'thin');
        $searchBox = new CTextBox('search', get_request('search', ''));
        $searchBox->setAttribute('autocomplete', 'off');
        $searchBox->setAttribute('style', 'width: 160px;');
        $search_form->addItem(new CDiv(array(S_SEARCH_BIG . ': ', $searchBox)));
        $search_div = new CDiv($search_form);
        $search_div->setAttribute('id', 'zbx_search');
        $search_div->setAttribute('class', 'zbx_search');
        zbx_add_post_js("var sid = createSuggest('search');");
    }
    $sub_menu_table->addRow(array($menu_divs, $search_div));
    $page_menu->addItem($sub_menu_table);
    //---
    $page_menu->show();
}
//------------------------------------- <HISTORY> ---------------------------------------
if (isset($page['hist_arg']) && $USER_DETAILS['alias'] != ZBX_GUEST_USER && $page['type'] == PAGE_TYPE_HTML && !defined('ZBX_PAGE_NO_MENU')) {
    $table = new CTable();
// update interval
$httpFormList->addRow(_('Update interval (in sec)'), new CNumericBox('delay', $this->data['delay'], 5));
// number of retries
$httpFormList->addRow(_('Retries'), new CNumericBox('retries', $this->data['retries'], 2));
// append http agents to form list - http://www.useragentstring.com
$agentComboBox = new CEditableComboBox('agent', $this->data['agent'], ZBX_TEXTBOX_STANDARD_SIZE);
$agentComboBox->addItemsInGroup(_('Internet Explorer'), array('Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)' => 'Internet Explorer 10.0', 'Mozilla/5.0 (Windows; U; MSIE 9.0; Windows NT 9.0; en-US)' => 'Internet Explorer 9.0', 'Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET CLR 1.0.3705; .NET CLR 1.1.4322)' => 'Internet Explorer 8.0', 'Mozilla/5.0 (Windows; U; MSIE 7.0; Windows NT 6.0; en-US)' => 'Internet Explorer 7.0', 'Mozilla/5.0 (compatible; MSIE 6.0; Windows NT 5.1)' => 'Internet Explorer 6.0'));
$agentComboBox->addItemsInGroup(_('Mozilla Firefox'), array('Mozilla/5.0 (X11; Linux i686; rv:8.0) Gecko/20100101 Firefox/8.0' => 'Mozilla Firefox 8.0', 'Mozilla/5.0 (X11; Linux i686; rv:7.0) Gecko/20100101 Firefox/7.0' => 'Mozilla Firefox 7.0', 'Mozilla/5.0 (X11; Linux i686; rv:6.0) Gecko/20100101 Firefox/6.0' => 'Mozilla Firefox 6.0', 'Mozilla/5.0 (X11; U; Linux i586; de; rv:5.0) Gecko/20100101 Firefox/5.0' => 'Mozilla Firefox 5.0', 'Mozilla/5.0 (X11; U; Linux x86_64; pl-PL; rv:2.0) Gecko/20110307 Firefox/4.0' => 'Mozilla Firefox 4.0', 'Mozilla/6.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:2.0.0.0) Gecko/20061028 Firefox/3.0' => 'Mozilla Firefox 3.0', 'Mozilla/5.0 (X11;U;Linux i686;en-US;rv:1.8.1) Gecko/2006101022 Firefox/2.0' => 'Mozilla Firefox 2.0'));
$agentComboBox->addItemsInGroup(_('Opera'), array('Opera/9.80 (Windows NT 6.1; U; es-ES) Presto/2.9.181 Version/12.00' => 'Opera 12.00', 'Opera/9.80 (X11; Linux x86_64; U; pl) Presto/2.7.62 Version/11.00' => 'Opera 11.00', 'Opera/9.80 (X11; Linux x86_64; U; en) Presto/2.2.15 Version/10.00' => 'Opera 10.00', 'Opera/9.00 (X11; Linux i686; U; pl)' => 'Opera 9.00'));
$agentComboBox->addItemsInGroup(_('Safari'), array('Mozilla/5.0 (X11; U; Linux x86_64; en-us) AppleWebKit/531.2+ (KHTML, like Gecko) Version/5.0 Safari/531.2+' => 'Safari 5.0', 'Mozilla/5.0 (Windows; U; Windows NT 6.0; ru-RU) AppleWebKit/528.16 (KHTML, like Gecko) Version/4.0 Safari/528.16' => 'Safari 4.0', 'Mozilla/5.0 (Windows; U; Windows NT 6.0; sv-SE) AppleWebKit/523.13 (KHTML, like Gecko) Version/3.0 Safari/523.13' => 'Safari 3.0', 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 2_1 like Mac OS X; fr-fr) AppleWebKit/525.18.1 (KHTML, like Gecko) Mobile/5F136' => 'Safari on iPhone'));
$agentComboBox->addItemsInGroup(_('Google Chrome'), array('Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.8 (KHTML, like Gecko) Chrome/17.0.940.0 Safari/535.8' => 'Google Chrome 17', 'Mozilla/5.0 (Windows NT 6.0; WOW64) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.36 Safari/535.7' => 'Google Chrome 16', 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.872.0 Safari/535.2' => 'Google Chrome 15', 'Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.1 (KHTML, like Gecko) Ubuntu/11.04 Chromium/14.0.825.0 Chrome/14.0.825.0 Safari/535.1' => 'Google Chrome 14', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_3) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.32 Safari/535.1' => 'Google Chrome 13', 'Mozilla/5.0 (Windows NT 6.1; en-US) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.750.0 Safari/534.30' => 'Google Chrome 12'));
$agentComboBox->addItemsInGroup(_('Others'), array('Mozilla/5.0 (X11; Linux 3.1.0-rc9+; en_US) KHTML/4.7.2 (like Gecko) Konqueror/4.7' => 'Konqueror 4.7', 'Mozilla/5.0 (compatible; Konqueror/4.6; Linux) KHTML/4.6.0 (like Gecko)' => 'Konqueror 4.6', 'Lynx/2.8.7rel.1 libwww-FM/2.14 SSL-MM/1.4.1 OpenSSL/0.9.8r' => 'Lynx 2.8.7rel.1', 'Lynx/2.8.4rel.1 libwww-FM/2.14' => 'Lynx 2.8.4rel.1', 'Links (2.3pre1; Linux 2.6.35.10 i686; 225x51)' => 'Links 2.3pre1', 'Links (2.2; Linux 2.6.37.6-0.7-desktop i686; 225x51)' => 'Links 2.2', 'Googlebot/2.1 (+http://www.google.com/bot.html)' => 'Googlebot'));
$httpFormList->addRow(_('Agent'), $agentComboBox);
// append HTTP proxy to form list
$httpProxyTextBox = new CTextBox('http_proxy', $this->data['http_proxy'], ZBX_TEXTBOX_STANDARD_SIZE, 'no', 255);
$httpProxyTextBox->setAttribute('placeholder', 'http://[username[:password]@]proxy.example.com[:port]');
$httpFormList->addRow(_('HTTP proxy'), $httpProxyTextBox);
// append status to form list
$httpFormList->addRow(_('Variables'), new CTextArea('variables', $this->data['variables']));
$httpFormList->addRow(_('Enabled'), new CCheckBox('status', !$this->data['status']));
/*
 * Step tab
 */
$httpStepFormList = new CFormList('httpFormList');
$stepsTable = new CTable(null, 'formElementTable');
$stepsTable->setAttributes(array('style' => 'min-width: 500px;', 'id' => 'httpStepTable'));
$stepsTable->setHeader(array(new CCol(SPACE, null, null, '15'), new CCol(SPACE, null, null, '15'), new CCol(_('Name'), null, null, '150'), new CCol(_('Timeout'), null, null, '50'), new CCol(_('URL'), null, null, '200'), new CCol(_('Required'), null, null, '50'), new CCol(_('Status codes'), 'nowrap', null, '90'), new CCol('', null, null, '50')));
$i = 1;
foreach ($this->data['steps'] as $stepid => $step) {
    if (!isset($step['name'])) {
        $step['name'] = '';
    $conditions = array(array('macro' => '', 'value' => '', 'formulaid' => num2letter(0)));
} else {
    $conditions = CConditionHelper::sortConditionsByFormulaId($conditions);
}
// fields
foreach ($conditions as $i => $condition) {
    // formula id
    $formulaId = array(new CSpan($condition['formulaid']), new CVar('conditions[' . $i . '][formulaid]', $condition['formulaid']));
    // macro
    $macro = new CTextBox('conditions[' . $i . '][macro]', $condition['macro'], 30, false, 64);
    $macro->addClass('macro');
    $macro->setAttribute('placeholder', '{#MACRO}');
    $macro->setAttribute('data-formulaid', $condition['formulaid']);
    // value
    $value = new CTextBox('conditions[' . $i . '][value]', $condition['value'], 40, false, 255);
    $value->setAttribute('placeholder', _('regular expression'));
    // delete button
    $deleteButtonCell = array(new CButton('conditions_' . $i . '_remove', _('Remove'), null, 'link_menu element-table-remove'));
    $row = array($formulaId, $macro, new CSpan(_('matches')), $value, $deleteButtonCell);
    $conditionTable->addRow($row, 'form_row');
}
$addButton = new CButton('macro_add', _('Add'), null, 'link_menu element-table-add');
$buttonColumn = new CCol($addButton);
$buttonColumn->setAttribute('colspan', 5);
$buttonRow = new CRow();
$buttonRow->setAttribute('id', 'row_new_macro');
$buttonRow->addItem($buttonColumn);
$conditionTable->addRow($buttonRow);
$conditionFormList->addRow(_('Filters'), new CDiv($conditionTable, 'objectgroup inlineblock border_dotted ui-corner-all'));
// append tabs to form
$itemTab = new CTabView();
 $item_params_tbl = new CTable();
 $item_params_tbl->attr('class', 'formtable');
 $item_params_tbl->addStyle("width: 100%; align: left");
 $item_params_tbl->addRow(array(_('Interval') . ':', $itemDelay, _('History') . ':', $itemHistory, _('Trends') . ':', $itemTrends));
 $item_params_div->addItem($item_params_tbl);
 $item_params_w->addItem($item_params_div);
 $right_tab->addRow($empty_row);
 $right_tab->addRow($item_params_w);
 // Graph parameters
 $graphCreate = new CCheckBox('graph_create', 'no', '', 1);
 $graphName = new CTextBox('graph_name', $graph_name);
 $graphWidth = new CTextBox('graph_width', $graph_width);
 $graphWidth->setAttribute("size", "5");
 $graphWidth->setAttribute("maxlength", "5");
 $graphHeight = new CTextBox('graph_height', $graph_height);
 $graphHeight->setAttribute("size", "5");
 $graphHeight->setAttribute("maxlength", "5");
 // Graph type selector
 $cmbGraphType = new CComboBox('graph_type', $graph_type);
 $cmbGraphType->addItem(GRAPH_TYPE_NORMAL, _('Normal'));
 $cmbGraphType->addItem(GRAPH_TYPE_STACKED, _('Stacked'));
 $cmbGraphType->addItem(GRAPH_TYPE_PIE, _('Pie'));
 $cmbGraphType->addItem(GRAPH_TYPE_EXPLODED, _('Exploded'));
 // Graph function selector
 $cmbGraphFunc = new CComboBox('graph_func', $graph_func);
 foreach (array(CALC_FNC_ALL, CALC_FNC_MIN, CALC_FNC_AVG, CALC_FNC_MAX) as $func) {
     $cmbGraphFunc->addItem($func, graph_item_calc_fnc2str($func));
 }
 // Draw type selector
 $cmbDrawType = new CComboBox('draw_type', $draw_type);
 foreach (graph_item_drawtypes() as $dt) {
Exemple #11
0
     $linktrigger = get_request('linktrigger', 0);
     //links
     $parentid = get_request('parentid', 0);
     $parentname = get_request('parentname', '');
     $childs = get_request('childs', array());
     //-----
 }
 if (isset($service)) {
     $frmService->AddVar('serviceid', $service['serviceid']);
 }
 $frmService->AddRow(S_NAME, new CTextBox('name', $name, 60));
 //link
 //-------------------------------------------- <LINK> --------------------------------------------
 //parent link
 $ctb = new CTextBox('parent_name', $parentname, 60);
 $ctb->setAttribute('disabled', 'disabled');
 $frmService->AddVar('parentname', $parentname);
 $frmService->AddVar('parentid', $parentid);
 $cb = new CButton('select_parent', S_CHANGE);
 $cb->SetType('button');
 $cb->SetAction("javascript: openWinCentered('services_form.php?pservices=1" . url_param('serviceid') . "','ZBX_Services_List',740,420,'scrollbars=1, toolbar=0, menubar=0, resizable=1, dialog=0');");
 $frmService->AddRow('Parent Service', array($ctb, $cb));
 //----------
 //child links
 $table = new CTable();
 $table->setClass('tableinfo');
 $table->setOddRowClass('even_row');
 $table->setEvenRowClass('even_row');
 $table->attributes['cellpadding'] = 3;
 $table->attributes['cellspacing'] = 1;
 $table->headerClass = 'header';
Exemple #12
0
function insert_graph_form()
{
    $frmGraph = new CFormTable(S_GRAPH, null, 'post');
    $frmGraph->SetName('frm_graph');
    $frmGraph->SetHelp("web.graphs.graph.php");
    $frmGraph->SetMethod('post');
    $items = get_request('items', array());
    if (isset($_REQUEST['graphid'])) {
        $frmGraph->addVar('graphid', $_REQUEST['graphid']);
        $result = DBselect('SELECT * FROM graphs WHERE graphid=' . $_REQUEST['graphid']);
        $row = DBfetch($result);
        $frmGraph->SetTitle(S_GRAPH . ' "' . $row['name'] . '"');
    }
    if (isset($_REQUEST['graphid']) && !isset($_REQUEST['form_refresh'])) {
        $name = $row['name'];
        $width = $row['width'];
        $height = $row['height'];
        $ymin_type = $row["ymin_type"];
        $ymax_type = $row["ymax_type"];
        $yaxismin = $row['yaxismin'];
        $yaxismax = $row['yaxismax'];
        $ymin_itemid = $row["ymin_itemid"];
        $ymax_itemid = $row["ymax_itemid"];
        $showworkperiod = $row['show_work_period'];
        $showtriggers = $row['show_triggers'];
        $graphtype = $row['graphtype'];
        $legend = $row['show_legend'];
        $graph3d = $row['show_3d'];
        $percent_left = $row['percent_left'];
        $percent_right = $row['percent_right'];
        $db_items = DBselect('SELECT * FROM graphs_items WHERE graphid=' . $_REQUEST['graphid']);
        while ($item = DBfetch($db_items)) {
            array_push($items, array('itemid' => $item['itemid'], 'drawtype' => $item['drawtype'], 'sortorder' => $item['sortorder'], 'color' => $item['color'], 'yaxisside' => $item['yaxisside'], 'calc_fnc' => $item['calc_fnc'], 'type' => $item['type'], 'periods_cnt' => $item['periods_cnt']));
        }
    } else {
        $name = get_request('name', '');
        $graphtype = get_request('graphtype', GRAPH_TYPE_NORMAL);
        if ($graphtype == GRAPH_TYPE_PIE || $graphtype == GRAPH_TYPE_EXPLODED) {
            $width = get_request('width', 400);
            $height = get_request('height', 300);
        } else {
            $width = get_request('width', 900);
            $height = get_request('height', 200);
        }
        $ymin_type = get_request("ymin_type", GRAPH_YAXIS_TYPE_CALCULATED);
        $ymax_type = get_request("ymax_type", GRAPH_YAXIS_TYPE_CALCULATED);
        $yaxismin = get_request("yaxismin", 0.0);
        $yaxismax = get_request("yaxismax", 100.0);
        $ymin_itemid = get_request("ymin_itemid", 0);
        $ymax_itemid = get_request("ymax_itemid", 0);
        $showworkperiod = get_request('showworkperiod', 0);
        $showtriggers = get_request('showtriggers', 0);
        $legend = get_request('legend', 0);
        $graph3d = get_request('graph3d', 0);
        $visible = get_request('visible');
        $percent_left = 0;
        $percent_right = 0;
        if (isset($visible['percent_left'])) {
            $percent_left = get_request('percent_left', 0);
        }
        if (isset($visible['percent_right'])) {
            $percent_right = get_request('percent_right', 0);
        }
    }
    /* reinit $_REQUEST */
    $_REQUEST['items'] = $items;
    $_REQUEST['name'] = $name;
    $_REQUEST['width'] = $width;
    $_REQUEST['height'] = $height;
    $_REQUEST['ymin_type'] = $ymin_type;
    $_REQUEST['ymax_type'] = $ymax_type;
    $_REQUEST['yaxismin'] = $yaxismin;
    $_REQUEST['yaxismax'] = $yaxismax;
    $_REQUEST['ymin_itemid'] = $ymin_itemid;
    $_REQUEST['ymax_itemid'] = $ymax_itemid;
    $_REQUEST['showworkperiod'] = $showworkperiod;
    $_REQUEST['showtriggers'] = $showtriggers;
    $_REQUEST['graphtype'] = $graphtype;
    $_REQUEST['legend'] = $legend;
    $_REQUEST['graph3d'] = $graph3d;
    $_REQUEST['percent_left'] = $percent_left;
    $_REQUEST['percent_right'] = $percent_right;
    /********************/
    if ($graphtype != GRAPH_TYPE_NORMAL) {
        foreach ($items as $gid => $gitem) {
            if ($gitem['type'] != GRAPH_ITEM_AGGREGATED) {
                continue;
            }
            unset($items[$gid]);
        }
    }
    asort_by_key($items, 'sortorder');
    $group_gid = get_request('group_gid', array());
    $frmGraph->addVar('ymin_itemid', $ymin_itemid);
    $frmGraph->addVar('ymax_itemid', $ymax_itemid);
    $frmGraph->addRow(S_NAME, new CTextBox('name', $name, 32));
    $g_width = new CNumericBox('width', $width, 5);
    $g_width->setAttribute('onblur', 'javascript: submit();');
    $frmGraph->addRow(S_WIDTH, $g_width);
    $g_height = new CNumericBox('height', $height, 5);
    $g_height->setAttribute('onblur', 'javascript: submit();');
    $frmGraph->addRow(S_HEIGHT, $g_height);
    $cmbGType = new CComboBox('graphtype', $graphtype, 'graphs.submit(this)');
    $cmbGType->addItem(GRAPH_TYPE_NORMAL, S_NORMAL);
    $cmbGType->addItem(GRAPH_TYPE_STACKED, S_STACKED);
    $cmbGType->addItem(GRAPH_TYPE_PIE, S_PIE);
    $cmbGType->addItem(GRAPH_TYPE_EXPLODED, S_EXPLODED);
    zbx_add_post_js('graphs.graphtype = ' . $graphtype . ";\n");
    $frmGraph->addRow(S_GRAPH_TYPE, $cmbGType);
    if ($graphtype == GRAPH_TYPE_NORMAL || $graphtype == GRAPH_TYPE_STACKED) {
        $frmGraph->addRow(S_SHOW_WORKING_TIME, new CCheckBox('showworkperiod', $showworkperiod, null, 1));
        $frmGraph->addRow(S_SHOW_TRIGGERS, new CCheckBox('showtriggers', $showtriggers, null, 1));
        if ($graphtype == GRAPH_TYPE_NORMAL) {
            $percent_left = sprintf("%2.2f", $percent_left);
            $percent_right = sprintf("%2.2f", $percent_right);
            $pr_left_input = new CTextBox('percent_left', $percent_left, '5');
            $pr_left_chkbx = new CCheckBox('visible[percent_left]', 1, "javascript: ShowHide('percent_left');", 1);
            if ($percent_left == 0) {
                $pr_left_input->setAttribute('style', 'display: none;');
                $pr_left_chkbx->SetChecked(0);
            }
            $pr_right_input = new CTextBox('percent_right', $percent_right, '5');
            $pr_right_chkbx = new CCheckBox('visible[percent_right]', 1, "javascript: ShowHide('percent_right');", 1);
            if ($percent_right == 0) {
                $pr_right_input->setAttribute('style', 'display: none;');
                $pr_right_chkbx->SetChecked(0);
            }
            $frmGraph->addRow(S_PERCENTILE_LINE . ' (' . S_LEFT . ')', array($pr_left_chkbx, $pr_left_input));
            $frmGraph->addRow(S_PERCENTILE_LINE . ' (' . S_RIGHT . ')', array($pr_right_chkbx, $pr_right_input));
        }
        $yaxis_min = array();
        $cmbYType = new CComboBox('ymin_type', $ymin_type, 'javascript: submit();');
        $cmbYType->addItem(GRAPH_YAXIS_TYPE_CALCULATED, S_CALCULATED);
        $cmbYType->addItem(GRAPH_YAXIS_TYPE_FIXED, S_FIXED);
        $cmbYType->addItem(GRAPH_YAXIS_TYPE_ITEM_VALUE, S_ITEM);
        $yaxis_min[] = $cmbYType;
        if ($ymin_type == GRAPH_YAXIS_TYPE_FIXED) {
            $yaxis_min[] = new CTextBox("yaxismin", $yaxismin, 9);
        } else {
            if ($ymin_type == GRAPH_YAXIS_TYPE_ITEM_VALUE) {
                $frmGraph->addVar('yaxismin', $yaxismin);
                $ymin_name = '';
                if ($ymin_itemid > 0) {
                    $min_host = get_host_by_itemid($ymin_itemid);
                    $min_item = get_item_by_itemid($ymin_itemid);
                    $ymin_name = $min_host['host'] . ':' . item_description($min_item);
                }
                $yaxis_min[] = new CTextBox("ymin_name", $ymin_name, 80, 'yes');
                $yaxis_min[] = new CButton('yaxis_min', S_SELECT, 'javascript: ' . "return PopUp('popup.php?dstfrm=" . $frmGraph->getName() . "&dstfld1=ymin_itemid" . "&dstfld2=ymin_name" . "&srctbl=items" . "&srcfld1=itemid" . "&srcfld2=description',0,0,'zbx_popup_item');");
            } else {
                $frmGraph->addVar('yaxismin', $yaxismin);
            }
        }
        $frmGraph->addRow(S_YAXIS_MIN_VALUE, $yaxis_min);
        $yaxis_max = array();
        $cmbYType = new CComboBox("ymax_type", $ymax_type, "submit()");
        $cmbYType->addItem(GRAPH_YAXIS_TYPE_CALCULATED, S_CALCULATED);
        $cmbYType->addItem(GRAPH_YAXIS_TYPE_FIXED, S_FIXED);
        $cmbYType->addItem(GRAPH_YAXIS_TYPE_ITEM_VALUE, S_ITEM);
        $yaxis_max[] = $cmbYType;
        if ($ymax_type == GRAPH_YAXIS_TYPE_FIXED) {
            $yaxis_max[] = new CTextBox("yaxismax", $yaxismax, 9);
        } else {
            if ($ymax_type == GRAPH_YAXIS_TYPE_ITEM_VALUE) {
                $frmGraph->addVar('yaxismax', $yaxismax);
                $ymax_name = '';
                if ($ymax_itemid > 0) {
                    $max_host = get_host_by_itemid($ymax_itemid);
                    $max_item = get_item_by_itemid($ymax_itemid);
                    $ymax_name = $max_host['host'] . ':' . item_description($max_item);
                }
                $yaxis_max[] = new CTextBox("ymax_name", $ymax_name, 80, 'yes');
                $yaxis_max[] = new CButton('yaxis_max', S_SELECT, 'javascript: ' . "return PopUp('popup.php?dstfrm=" . $frmGraph->getName() . "&dstfld1=ymax_itemid" . "&dstfld2=ymax_name" . "&srctbl=items" . "&srcfld1=itemid" . "&srcfld2=description',0,0,'zbx_popup_item');");
            } else {
                $frmGraph->addVar('yaxismax', $yaxismax);
            }
        }
        $frmGraph->addRow(S_YAXIS_MAX_VALUE, $yaxis_max);
    } else {
        $frmGraph->addRow(S_3D_VIEW, new CCheckBox('graph3d', $graph3d, 'javascript: graphs.submit(this);', 1));
        $frmGraph->addRow(S_LEGEND, new CCheckBox('legend', $legend, 'javascript: graphs.submit(this);', 1));
    }
    $only_hostid = null;
    $monitored_hosts = null;
    if (count($items)) {
        $frmGraph->addVar('items', $items);
        $items_table = new CTableInfo();
        foreach ($items as $gid => $gitem) {
            if ($graphtype == GRAPH_TYPE_STACKED && $gitem['type'] == GRAPH_ITEM_AGGREGATED) {
                continue;
            }
            $host = get_host_by_itemid($gitem['itemid']);
            $item = get_item_by_itemid($gitem['itemid']);
            if ($host['status'] == HOST_STATUS_TEMPLATE) {
                $only_hostid = $host['hostid'];
            } else {
                $monitored_hosts = 1;
            }
            if ($gitem['type'] == GRAPH_ITEM_AGGREGATED) {
                $color = '-';
            } else {
                $color = new CColorCell(null, $gitem['color']);
            }
            $do_up = new CLink(S_UP, '#', 'action');
            $do_up->OnClick("return create_var('" . $frmGraph->GetName() . "','move_up'," . $gid . ", true);");
            $do_down = new CLink(S_DOWN, '#', 'action');
            $do_down->OnClick("return create_var('" . $frmGraph->GetName() . "','move_down'," . $gid . ", true);");
            $description = new CLink($host['host'] . ': ' . item_description($item), '#', 'action');
            $description->OnClick('return PopUp("popup_gitem.php?list_name=items&dstfrm=' . $frmGraph->GetName() . url_param($only_hostid, false, 'only_hostid') . url_param($monitored_hosts, false, 'monitored_hosts') . url_param($graphtype, false, 'graphtype') . url_param($gitem, false) . url_param($gid, false, 'gid') . url_param(get_request('graphid', 0), false, 'graphid') . '",550,400,"graph_item_form");');
            if ($graphtype == GRAPH_TYPE_PIE || $graphtype == GRAPH_TYPE_EXPLODED) {
                $items_table->addRow(array(new CCheckBox('group_gid[' . $gid . ']', isset($group_gid[$gid])), $gitem['sortorder'], $description, graph_item_calc_fnc2str($gitem["calc_fnc"], $gitem["type"]), graph_item_type2str($gitem['type'], $gitem["periods_cnt"]), $color, array($do_up, SPACE . "|" . SPACE, $do_down)));
            } else {
                $items_table->addRow(array(new CCheckBox('group_gid[' . $gid . ']', isset($group_gid[$gid])), $gitem['sortorder'], $description, graph_item_calc_fnc2str($gitem["calc_fnc"], $gitem["type"]), graph_item_type2str($gitem['type'], $gitem["periods_cnt"]), graph_item_drawtype2str($gitem["drawtype"], $gitem["type"]), $color, array($do_up, SPACE . "|" . SPACE, $do_down)));
            }
        }
        $dedlete_button = new CButton('delete_item', S_DELETE_SELECTED);
    } else {
        $items_table = $dedlete_button = null;
    }
    $frmGraph->addRow(S_ITEMS, array($items_table, new CButton('add_item', S_ADD, "return PopUp('popup_gitem.php?dstfrm=" . $frmGraph->GetName() . url_param($only_hostid, false, 'only_hostid') . url_param($monitored_hosts, false, 'monitored_hosts') . url_param($graphtype, false, 'graphtype') . "',550,400,'graph_item_form');"), $dedlete_button));
    unset($items_table, $dedlete_button);
    $frmGraph->addItemToBottomRow(new CButton("save", S_SAVE));
    if (isset($_REQUEST["graphid"])) {
        $frmGraph->addItemToBottomRow(SPACE);
        $frmGraph->addItemToBottomRow(new CButton("clone", S_CLONE));
        $frmGraph->addItemToBottomRow(SPACE);
        $frmGraph->addItemToBottomRow(new CButtonDelete(S_DELETE_GRAPH_Q, url_param("graphid") . url_param('groupid') . url_param("hostid")));
    }
    $frmGraph->addItemToBottomRow(SPACE);
    $frmGraph->addItemToBottomRow(new CButtonCancel(url_param('groupid') . url_param("hostid")));
    $frmGraph->show();
}
function bar_report_form3()
{
    $config = get_request('config', 1);
    $title = get_request('title', _('Report 3'));
    $xlabel = get_request('xlabel', '');
    $ylabel = get_request('ylabel', '');
    $scaletype = get_request('scaletype', TIMEPERIOD_TYPE_WEEKLY);
    $avgperiod = get_request('avgperiod', TIMEPERIOD_TYPE_DAILY);
    $report_timesince = get_request('report_timesince', date('YmdHis', time() - SEC_PER_DAY));
    $report_timetill = get_request('report_timetill', date('YmdHis'));
    $items = get_request('items', array());
    $hostids = get_request('hostids', array());
    $hostids = zbx_toHash($hostids);
    $showlegend = get_request('showlegend', 0);
    $palette = get_request('palette', 0);
    $palettetype = get_request('palettetype', 0);
    $reportForm = new CFormTable(null, null, 'get');
    //,'events.php?report_set=1','POST',null,'sform');
    $reportForm->setAttribute('name', 'zbx_report');
    $reportForm->setAttribute('id', 'zbx_report');
    //	$reportForm->setMethod('post');
    if (isset($_REQUEST['report_show']) && !empty($items)) {
        $reportForm->addVar('report_show', 'show');
    }
    $reportForm->addVar('config', $config);
    $reportForm->addVar('report_timesince', date('YmdHis', $report_timesince));
    $reportForm->addVar('report_timetill', date('YmdHis', $report_timetill));
    //	$reportForm->addVar('items',$items); 				//params are set later!!
    //	$reportForm->addVar('periods',$periods);
    $reportForm->addRow(_('Title'), new CTextBox('title', $title, 40));
    $reportForm->addRow(_('X label'), new CTextBox('xlabel', $xlabel, 40));
    $reportForm->addRow(_('Y label'), new CTextBox('ylabel', $ylabel, 40));
    $reportForm->addRow(_('Legend'), new CCheckBox('showlegend', $showlegend, null, 1));
    $reportForm->addVar('sortorder', 0);
    // GROUPS
    $groupids = get_request('groupids', array());
    $group_tb = new CTweenBox($reportForm, 'groupids', $groupids, 10);
    $options = array('real_hosts' => 1, 'output' => 'extend');
    $db_groups = API::HostGroup()->get($options);
    order_result($db_groups, 'name');
    foreach ($db_groups as $gnum => $group) {
        $groupids[$group['groupid']] = $group['groupid'];
        $group_tb->addItem($group['groupid'], $group['name']);
    }
    $reportForm->addRow(_('Groups'), $group_tb->Get(_('Selected groups'), _('Other groups')));
    // ----------
    // HOSTS
    //	validate_group(PERM_READ_ONLY,array('real_hosts'),'web.last.conf.groupid');
    $groupid = get_request('groupid', 0);
    $cmbGroups = new CComboBox('groupid', $groupid, 'submit()');
    $cmbGroups->addItem(0, _('All'));
    foreach ($db_groups as $gnum => $group) {
        $cmbGroups->addItem($group['groupid'], $group['name']);
    }
    $td_groups = new CCol(array(_('Group'), SPACE, $cmbGroups));
    $td_groups->setAttribute('style', 'text-align: right;');
    $host_tb = new CTweenBox($reportForm, 'hostids', $hostids, 10);
    $options = array('real_hosts' => 1, 'output' => array('hostid', 'name'));
    if ($groupid > 0) {
        $options['groupids'] = $groupid;
    }
    $db_hosts = API::Host()->get($options);
    $db_hosts = zbx_toHash($db_hosts, 'hostid');
    order_result($db_hosts, 'name');
    foreach ($db_hosts as $hnum => $host) {
        $host_tb->addItem($host['hostid'], $host['name']);
    }
    $options = array('real_hosts' => 1, 'output' => array('hostid', 'name'), 'hostids' => $hostids);
    $db_hosts2 = API::Host()->get($options);
    order_result($db_hosts2, 'name');
    foreach ($db_hosts2 as $hnum => $host) {
        if (!isset($db_hosts[$host['hostid']])) {
            $host_tb->addItem($host['hostid'], $host['name']);
        }
    }
    $reportForm->addRow(_('Hosts'), $host_tb->Get(_('Selected hosts'), array(_('Other hosts | Group') . SPACE, $cmbGroups)));
    // ----------
    //*/
    // PERIOD
    $clndr_icon = new CImg('images/general/bar/cal.gif', 'calendar', 16, 12, 'pointer');
    $clndr_icon->addAction('onclick', 'javascript: ' . 'var pos = getPosition(this); ' . 'pos.top+=10; ' . 'pos.left+=16; ' . "CLNDR['avail_report_since'].clndr.clndrshow(pos.top,pos.left);");
    $reporttimetab = new CTable(null, 'calendar');
    $reporttimetab->setAttribute('width', '10%');
    $reporttimetab->setCellPadding(0);
    $reporttimetab->setCellSpacing(0);
    $reporttimetab->addRow(array(_('From'), new CNumericBox('report_since_day', $report_timesince > 0 ? date('d', $report_timesince) : '', 2), '/', new CNumericBox('report_since_month', $report_timesince > 0 ? date('m', $report_timesince) : '', 2), '/', new CNumericBox('report_since_year', $report_timesince > 0 ? date('Y', $report_timesince) : '', 4), SPACE, new CNumericBox('report_since_hour', $report_timesince > 0 ? date('H', $report_timesince) : '', 2), ':', new CNumericBox('report_since_minute', $report_timesince > 0 ? date('i', $report_timesince) : '', 2), $clndr_icon));
    zbx_add_post_js('create_calendar(null,' . '["report_since_day","report_since_month","report_since_year","report_since_hour","report_since_minute"],' . '"avail_report_since",' . '"report_timesince");');
    $clndr_icon->addAction('onclick', 'javascript: ' . 'var pos = getPosition(this); ' . 'pos.top+=10; ' . 'pos.left+=16; ' . "CLNDR['avail_report_till'].clndr.clndrshow(pos.top,pos.left);");
    $reporttimetab->addRow(array(_('Till'), new CNumericBox('report_till_day', $report_timetill > 0 ? date('d', $report_timetill) : '', 2), '/', new CNumericBox('report_till_month', $report_timetill > 0 ? date('m', $report_timetill) : '', 2), '/', new CNumericBox('report_till_year', $report_timetill > 0 ? date('Y', $report_timetill) : '', 4), SPACE, new CNumericBox('report_till_hour', $report_timetill > 0 ? date('H', $report_timetill) : '', 2), ':', new CNumericBox('report_till_minute', $report_timetill > 0 ? date('i', $report_timetill) : '', 2), $clndr_icon));
    zbx_add_post_js('create_calendar(null,' . '["report_till_day","report_till_month","report_till_year","report_till_hour","report_till_minute"],' . '"avail_report_till",' . '"report_timetill");');
    zbx_add_post_js('addListener($("filter_icon"),' . '"click",' . 'CLNDR[\'avail_report_since\'].clndr.clndrhide.bindAsEventListener(CLNDR[\'avail_report_since\'].clndr));' . 'addListener($("filter_icon"),' . '"click",' . 'CLNDR[\'avail_report_till\'].clndr.clndrhide.bindAsEventListener(CLNDR[\'avail_report_till\'].clndr));');
    $reportForm->addRow(_('Period'), $reporttimetab);
    $scale = new CComboBox('scaletype', $scaletype);
    $scale->addItem(TIMEPERIOD_TYPE_HOURLY, _('Hourly'));
    $scale->addItem(TIMEPERIOD_TYPE_DAILY, _('Daily'));
    $scale->addItem(TIMEPERIOD_TYPE_WEEKLY, _('Weekly'));
    $scale->addItem(TIMEPERIOD_TYPE_MONTHLY, _('Monthly'));
    $scale->addItem(TIMEPERIOD_TYPE_YEARLY, _('Yearly'));
    $reportForm->addRow(_('Scale'), $scale);
    $avgcmb = new CComboBox('avgperiod', $avgperiod);
    $avgcmb->addItem(TIMEPERIOD_TYPE_HOURLY, _('Hourly'));
    $avgcmb->addItem(TIMEPERIOD_TYPE_DAILY, _('Daily'));
    $avgcmb->addItem(TIMEPERIOD_TYPE_WEEKLY, _('Weekly'));
    $avgcmb->addItem(TIMEPERIOD_TYPE_MONTHLY, _('Monthly'));
    $avgcmb->addItem(TIMEPERIOD_TYPE_YEARLY, _('Yearly'));
    $reportForm->addRow(_('Average by'), $avgcmb);
    // items
    $itemid = 0;
    $description = '';
    if (count($items) && $items[0]['itemid'] > 0) {
        $itemid = $items[0]['itemid'];
        $description = get_item_by_itemid($itemid);
        $description = itemName($description);
    }
    $itemidVar = new CVar('items[0][itemid]', $itemid, 'items_0_itemid');
    $reportForm->addItem($itemidVar);
    $txtCondVal = new CTextBox('items[0][description]', $description, 50, 'yes');
    $txtCondVal->setAttribute('id', 'items_0_description');
    $btnSelect = new CButton('btn1', _('Select'), "return PopUp('popup.php?dstfrm=" . $reportForm->GetName() . "&dstfld1=items_0_itemid&dstfld2=items_0_description&" . "srctbl=items&srcfld1=itemid&srcfld2=name&monitored_hosts=1');", 'T');
    $reportForm->addRow(_('Item'), array($txtCondVal, $btnSelect));
    $paletteCmb = new CComboBox('palette', $palette);
    $paletteCmb->addItem(0, _s('Palette #%1$s', 1));
    $paletteCmb->addItem(1, _s('Palette #%1$s', 2));
    $paletteCmb->addItem(2, _s('Palette #%1$s', 3));
    $paletteCmb->addItem(3, _s('Palette #%1$s', 4));
    $paletteTypeCmb = new CComboBox('palettetype', $palettetype);
    $paletteTypeCmb->addItem(0, _('Middle'));
    $paletteTypeCmb->addItem(1, _('Darken'));
    $paletteTypeCmb->addItem(2, _('Brighten'));
    $reportForm->addRow(_('Palette'), array($paletteCmb, $paletteTypeCmb));
    $reportForm->addItemToBottomRow(new CSubmit('report_show', _('Show')));
    $reset = new CButton('reset', _('Reset'));
    $reset->setType('reset');
    $reportForm->addItemToBottomRow($reset);
    return $reportForm;
}
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 = "&rArr;";
				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);
}
$headerDiv = new CDiv(_('Colour'), 'inlineblock trigger_displaying_form_col');
$headerDiv->addStyle('margin-left: 2px;');
$triggerDOFormList->addRow(SPACE, array($headerDiv, _('Blinking')));
// Unacknowledged problem events
$triggerDOFormList->addRow(_('Unacknowledged PROBLEM events'), array(new CDiv(new CColor('problem_unack_color', $this->data['problem_unack_color']), 'inlineblock trigger_displaying_form_col'), new CCheckBox('problem_unack_style', $this->data['problem_unack_style'] == 1, null, 1)));
// Acknowledged problem events
$triggerDOFormList->addRow(_('Acknowledged PROBLEM events'), array(new CDiv(new CColor('problem_ack_color', $this->data['problem_ack_color']), 'inlineblock trigger_displaying_form_col'), new CCheckBox('problem_ack_style', $this->data['problem_ack_style'] == 1, null, 1)));
// Unacknowledged recovery events
$triggerDOFormList->addRow(_('Unacknowledged OK events'), array(new CDiv(new CColor('ok_unack_color', $this->data['ok_unack_color']), 'inlineblock trigger_displaying_form_col'), new CCheckBox('ok_unack_style', $this->data['ok_unack_style'] == 1, null, 1)));
// Acknowledged recovery events
$triggerDOFormList->addRow(_('Acknowledged OK events'), array(new CDiv(new CColor('ok_ack_color', $this->data['ok_ack_color']), 'inlineblock trigger_displaying_form_col'), new CCheckBox('ok_ack_style', $this->data['ok_ack_style'] == 1, null, 1)));
// some air between the sections
$triggerDOFormList->addRow(BR());
// Display OK triggers
$okPeriodTextBox = new CTextBox('ok_period', $this->data['ok_period']);
$okPeriodTextBox->addStyle('width: 4em;');
$okPeriodTextBox->setAttribute('maxlength', '6');
$triggerDOFormList->addRow(_('Display OK triggers for'), array($okPeriodTextBox, SPACE, _('seconds')));
// Triggers blink on status change
$okPeriodTextBox = new CTextBox('blink_period', $this->data['blink_period']);
$okPeriodTextBox->addStyle('width: 4em;');
$okPeriodTextBox->setAttribute('maxlength', '6');
$triggerDOFormList->addRow(_('On status change triggers blink for'), array($okPeriodTextBox, SPACE, _('seconds')));
$severityView = new CTabView();
$severityView->addTab('triggerdo', _('Trigger displaying options'), $triggerDOFormList);
$severityForm = new CForm();
$severityForm->setName('triggerDisplayOptions');
$severityForm->addVar('form_refresh', $this->data['form_refresh'] + 1);
$severityForm->addItem($severityView);
$severityForm->addItem(makeFormFooter(new CSubmit('save', _('Save')), new CButton('resetDefaults', _('Reset defaults'))));
return $severityForm;
$groups = $this->getArray('groups');
foreach ($groups as $gnum => $group) {
    $host_groups->addItem($group['groupid'], $group['name']);
}
$scriptTab->addRow(_('Host groups'), $host_groups);
// permissions
$select_acc = new CCombobox('access', $this->get('access'));
$select_acc->addItem(PERM_READ_ONLY, _('Read'));
$select_acc->addItem(PERM_READ_WRITE, _('Write'));
$scriptTab->addRow(_('Required host permissions'), $select_acc);
// confirmation
$enableQuestCB = new CCheckBox('enableConfirmation', $this->get('enableConfirmation'));
$scriptTab->addRow(new CLabel(_('Enable confirmation'), 'enableConfirmation'), array($enableQuestCB, SPACE));
$confirmationTB = new CTextBox('confirmation', $this->get('confirmation'));
$confirmationTB->addStyle('width: 50em;');
$confirmationTB->setAttribute('maxlength', 255);
$testLink = new CButton('testConfirmation', _('Test confirmation'), null, 'link_menu');
$confirmationLabel = new CLabel(_('Confirmation text'), 'confirmation');
$confirmationLabel->setAttribute('id', 'confirmationLabel');
$scriptTab->addRow($confirmationLabel, array($confirmationTB, SPACE, $testLink));
$scriptView = new CTabView();
$scriptView->addTab('scripts', _('Script'), $scriptTab);
$frmScr->addItem($scriptView);
// footer
$main = array(new CSubmit('save', _('Save')));
$others = array();
if (isset($_REQUEST['scriptid'])) {
    $others[] = new CButton('clone', _('Clone'));
    $others[] = new CButtonDelete(_('Delete script?'), url_param('form') . url_param('scriptid'));
}
$others[] = new CButtonCancel();
    $iconPreviewImage->setAttribute('data-image-full', 'imgstore.php?iconid=' . $mapping['iconid']);
    $row = new CRow(array(new CSpan(null, 'ui-icon ui-icon-arrowthick-2-n-s move'), $numSpan, $profileLinksComboBox, $expressionTextBox, $iconsComboBox, $iconPreviewImage, new CButton('remove', _('Remove'), '', 'link_menu removeMapping')), 'sortable');
    $row->setAttribute('id', 'iconmapidRow_' . $i);
    $iconMapTable->addRow($row);
    $i++;
}
// hidden row for js
reset($this->data['iconList']);
$firstIconId = key($this->data['iconList']);
$numSpan = new CSpan('0:');
$numSpan->addClass('rowNum');
$profileLinksComboBox = new CComboBox('iconmap[mappings][#{iconmappingid}][inventory_link]');
$profileLinksComboBox->addItems($this->data['inventoryList']);
$profileLinksComboBox->setAttribute('disabled', 'disabled');
$expressionTextBox = new CTextBox('iconmap[mappings][#{iconmappingid}][expression]');
$expressionTextBox->setAttribute('maxlength', 64);
$expressionTextBox->setAttribute('disabled', 'disabled');
$iconsComboBox = new CComboBox('iconmap[mappings][#{iconmappingid}][iconid]', $firstIconId);
$iconsComboBox->addClass('mappingIcon');
$iconsComboBox->addItems($this->data['iconList']);
$iconsComboBox->setAttribute('disabled', 'disabled');
$iconPreviewImage = new CImg('imgstore.php?iconid=' . $firstIconId . '&width=' . ZBX_ICON_PREVIEW_WIDTH . '&height=' . ZBX_ICON_PREVIEW_HEIGHT, _('Preview'), null, null, 'pointer preview');
$iconPreviewImage->setAttribute('data-image-full', 'imgstore.php?iconid=' . $firstIconId);
// row template
$hiddenRowTemplate = new CRow(array(new CSpan(null, 'ui-icon ui-icon-arrowthick-2-n-s move'), $numSpan, $profileLinksComboBox, $expressionTextBox, $iconsComboBox, $iconPreviewImage, new CButton('remove', _('Remove'), '', 'link_menu removeMapping')), 'hidden');
$hiddenRowTemplate->setAttribute('id', 'rowTpl');
$iconMapTable->addRow($hiddenRowTemplate);
// add row button
$iconMapTable->addRow(new CCol(new CButton('addMapping', _('Add'), '', 'link_menu'), null, 7));
// <default icon row>
$numSpan = new CSpan($i++ . ':');
<?php

/*
** Zabbix
** Copyright (C) 2001-2013 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** 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.
**/
$searchForm = new CForm('get', 'search.php');
$searchBox = new CTextBox('search', get_request('search'));
$searchBox->setAttribute('autocomplete', 'off');
$searchBox->addClass('search');
$searchForm->addItem($searchBox);
$searchBtn = new CSubmit('searchbttn', _('Search'), null, 'input button ui-button ui-widget ui-state-default ui-corner-all');
$searchForm->addItem($searchBtn);
return new CDiv($searchForm, 'zbx_search', 'zbx_search');
Exemple #19
0
 } else {
     $itemName = $dbItem['name_expanded'];
 }
 $ctb = new CTextBox('item', $itemName, 80);
 $ctb->setAttribute('id', 'item');
 $ctb->setAttribute('disabled', 'disabled');
 $script = "javascript: return PopUp('popup.php?dstfrm=" . $frmTRLog->getName() . "&dstfld1=itemid&dstfld2=item&srctbl=items&srcfld1=itemid&srcfld2=name',800,450);";
 $cbtn = new CSubmit('select_item', _('Select'), $script);
 $frmTRLog->addRow(_('Item'), array($ctb, $cbtn));
 $frmTRLog->addVar('itemid', $itemid);
 $exp_select = new CComboBox('expr_type');
 $exp_select->setAttribute('id', 'expr_type');
 $exp_select->addItem(REGEXP_INCLUDE, _('Include'));
 $exp_select->addItem(REGEXP_EXCLUDE, _('Exclude'));
 $ctb = new CTextBox('expression', '', 80);
 $ctb->setAttribute('id', 'logexpr');
 $cb = new CButton('add_exp', _('Add'), 'javascript: add_logexpr();');
 $cbAdd = new CButton('add_key_and', _('AND'), 'javascript: add_keyword_and();');
 $cbOr = new CButton('add_key_or', _('OR'), 'javascript: add_keyword_or();');
 $cbIregexp = new CCheckBox('iregexp', 'no', null, 1);
 $frmTRLog->addRow(_('Expression'), array($ctb, BR(), $cbIregexp, 'iregexp', SPACE, $cbAdd, SPACE, $cbOr, SPACE, $exp_select, SPACE, $cb));
 $keyTable = new CTableInfo(null);
 $keyTable->setAttribute('id', 'key_list');
 $keyTable->setHeader(array(_('Keyword'), _('Type'), _('Action')));
 $table = new CTableInfo(null);
 $table->setAttribute('id', 'exp_list');
 $table->setHeader(array(_('Expression'), _('Type'), _('Position'), _('Action')));
 $maxid = 0;
 $bExprResult = true;
 $expressionData = new CTriggerExpression();
 if (isset($_REQUEST['triggerid']) && !isset($_REQUEST['save_trigger']) && !$expressionData->parse(empty($expressions) ? '' : construct_expression($itemid, $expressions)) && !isset($_REQUEST['form_refresh'])) {
        $parents[] = new CLink($parent['parentHost']['name'], '?form=update&hostid=' . $parent['hostid'] . '&parent_discoveryid=' . $parent['discoveryRule']['itemid'], 'highlight underline weight_normal');
        $parents[] = SPACE . RARR . SPACE;
    }
    array_pop($parents);
    $hostList->addRow(_('Parent discovery rules'), $parents);
}
if ($hostPrototype['hostid']) {
    $frmHost->addVar('hostid', $hostPrototype['hostid']);
}
$hostTB = new CTextBox('host', $hostPrototype['host'], ZBX_TEXTBOX_STANDARD_SIZE, (bool) $hostPrototype['templateid']);
$hostTB->setAttribute('maxlength', 64);
$hostTB->setAttribute('autofocus', 'autofocus');
$hostList->addRow(_('Host name'), $hostTB);
$name = $hostPrototype['name'] != $hostPrototype['host'] ? $hostPrototype['name'] : '';
$visiblenameTB = new CTextBox('name', $name, ZBX_TEXTBOX_STANDARD_SIZE, (bool) $hostPrototype['templateid']);
$visiblenameTB->setAttribute('maxlength', 64);
$hostList->addRow(_('Visible name'), $visiblenameTB);
// display inherited parameters only for hosts prototypes on hosts
if ($parentHost['status'] != HOST_STATUS_TEMPLATE) {
    $interfaces = array();
    $existingInterfaceTypes = array();
    foreach ($parentHost['interfaces'] as $interface) {
        $interface['locked'] = true;
        $existingInterfaceTypes[$interface['type']] = true;
        $interfaces[$interface['interfaceid']] = $interface;
    }
    zbx_add_post_js('hostInterfacesManager.add(' . CJs::encodeJson($interfaces) . ');');
    zbx_add_post_js('hostInterfacesManager.disable()');
    // table for agent interfaces with footer
    $ifTab = new CTable(null, 'formElementTable');
    $ifTab->setAttribute('id', 'agentInterfaces');
Exemple #21
0
/**
 * Create report bar for for "Compare values for multiple periods"
 *
 * @return object $reportForm
 */
function valueComparisonFormForMultiplePeriods()
{
    $config = get_request('config', 1);
    $title = get_request('title', _('Report 3'));
    $xlabel = get_request('xlabel', '');
    $ylabel = get_request('ylabel', '');
    $scaletype = get_request('scaletype', TIMEPERIOD_TYPE_WEEKLY);
    $avgperiod = get_request('avgperiod', TIMEPERIOD_TYPE_DAILY);
    $report_timesince = get_request('report_timesince', date(TIMESTAMP_FORMAT_ZERO_TIME, time() - SEC_PER_DAY));
    $report_timetill = get_request('report_timetill', date(TIMESTAMP_FORMAT_ZERO_TIME));
    $itemId = get_request('itemid', 0);
    $hostids = get_request('hostids', array());
    $hostids = zbx_toHash($hostids);
    $showlegend = get_request('showlegend', 0);
    $palette = get_request('palette', 0);
    $palettetype = get_request('palettetype', 0);
    $reportForm = new CFormTable(null, null, 'get');
    $reportForm->setAttribute('name', 'zbx_report');
    $reportForm->setAttribute('id', 'zbx_report');
    if (isset($_REQUEST['report_show']) && $itemId) {
        $reportForm->addVar('report_show', 'show');
    }
    $reportForm->addVar('config', $config);
    $reportForm->addVar('report_timesince', date(TIMESTAMP_FORMAT, $report_timesince));
    $reportForm->addVar('report_timetill', date(TIMESTAMP_FORMAT, $report_timetill));
    $reportForm->addRow(_('Title'), new CTextBox('title', $title, 40));
    $reportForm->addRow(_('X label'), new CTextBox('xlabel', $xlabel, 40));
    $reportForm->addRow(_('Y label'), new CTextBox('ylabel', $ylabel, 40));
    $reportForm->addRow(_('Legend'), new CCheckBox('showlegend', $showlegend, null, 1));
    $reportForm->addVar('sortorder', 0);
    $groupids = get_request('groupids', array());
    $group_tb = new CTweenBox($reportForm, 'groupids', $groupids, 10);
    $options = array('real_hosts' => true, 'output' => 'extend');
    $db_groups = API::HostGroup()->get($options);
    order_result($db_groups, 'name');
    foreach ($db_groups as $gnum => $group) {
        $groupids[$group['groupid']] = $group['groupid'];
        $group_tb->addItem($group['groupid'], $group['name']);
    }
    $reportForm->addRow(_('Groups'), $group_tb->Get(_('Selected groups'), _('Other groups')));
    $groupid = get_request('groupid', 0);
    $cmbGroups = new CComboBox('groupid', $groupid, 'submit()');
    $cmbGroups->addItem(0, _('All'));
    foreach ($db_groups as $gnum => $group) {
        $cmbGroups->addItem($group['groupid'], $group['name']);
    }
    $td_groups = new CCol(array(_('Group'), SPACE, $cmbGroups));
    $td_groups->setAttribute('style', 'text-align: right;');
    $host_tb = new CTweenBox($reportForm, 'hostids', $hostids, 10);
    $options = array('real_hosts' => true, 'output' => array('hostid', 'name'));
    if ($groupid > 0) {
        $options['groupids'] = $groupid;
    }
    $db_hosts = API::Host()->get($options);
    $db_hosts = zbx_toHash($db_hosts, 'hostid');
    order_result($db_hosts, 'name');
    foreach ($db_hosts as $hnum => $host) {
        $host_tb->addItem($host['hostid'], $host['name']);
    }
    $options = array('real_hosts' => true, 'output' => array('hostid', 'name'), 'hostids' => $hostids);
    $db_hosts2 = API::Host()->get($options);
    order_result($db_hosts2, 'name');
    foreach ($db_hosts2 as $hnum => $host) {
        if (!isset($db_hosts[$host['hostid']])) {
            $host_tb->addItem($host['hostid'], $host['name']);
        }
    }
    $reportForm->addRow(_('Hosts'), $host_tb->Get(_('Selected hosts'), array(_('Other hosts | Group') . SPACE, $cmbGroups)));
    $reporttimetab = new CTable(null, 'calendar');
    $timeSinceRow = createDateSelector('report_timesince', $report_timesince, 'report_timetill');
    array_unshift($timeSinceRow, _('From'));
    $reporttimetab->addRow($timeSinceRow);
    $timeTillRow = createDateSelector('report_timetill', $report_timetill, 'report_timesince');
    array_unshift($timeTillRow, _('Till'));
    $reporttimetab->addRow($timeTillRow);
    $reportForm->addRow(_('Period'), $reporttimetab);
    $scale = new CComboBox('scaletype', $scaletype);
    $scale->addItem(TIMEPERIOD_TYPE_HOURLY, _('Hourly'));
    $scale->addItem(TIMEPERIOD_TYPE_DAILY, _('Daily'));
    $scale->addItem(TIMEPERIOD_TYPE_WEEKLY, _('Weekly'));
    $scale->addItem(TIMEPERIOD_TYPE_MONTHLY, _('Monthly'));
    $scale->addItem(TIMEPERIOD_TYPE_YEARLY, _('Yearly'));
    $reportForm->addRow(_('Scale'), $scale);
    $avgcmb = new CComboBox('avgperiod', $avgperiod);
    $avgcmb->addItem(TIMEPERIOD_TYPE_HOURLY, _('Hourly'));
    $avgcmb->addItem(TIMEPERIOD_TYPE_DAILY, _('Daily'));
    $avgcmb->addItem(TIMEPERIOD_TYPE_WEEKLY, _('Weekly'));
    $avgcmb->addItem(TIMEPERIOD_TYPE_MONTHLY, _('Monthly'));
    $avgcmb->addItem(TIMEPERIOD_TYPE_YEARLY, _('Yearly'));
    $reportForm->addRow(_('Average by'), $avgcmb);
    $itemName = '';
    if ($itemId) {
        $itemName = get_item_by_itemid($itemId);
        $itemName = itemName($itemName);
    }
    $itemidVar = new CVar('itemid', $itemId, 'itemid');
    $reportForm->addItem($itemidVar);
    $txtCondVal = new CTextBox('item_name', $itemName, 50, 'yes');
    $txtCondVal->setAttribute('id', 'item_name');
    $btnSelect = new CButton('btn1', _('Select'), 'return PopUp("popup.php?dstfrm=' . $reportForm->GetName() . '&dstfld1=itemid' . '&dstfld2=item_name' . '&srctbl=items' . '&srcfld1=itemid' . '&srcfld2=name' . '&monitored_hosts=1");', 'T');
    $reportForm->addRow(_('Item'), array($txtCondVal, $btnSelect));
    $paletteCmb = new CComboBox('palette', $palette);
    $paletteCmb->addItem(0, _s('Palette #%1$s', 1));
    $paletteCmb->addItem(1, _s('Palette #%1$s', 2));
    $paletteCmb->addItem(2, _s('Palette #%1$s', 3));
    $paletteCmb->addItem(3, _s('Palette #%1$s', 4));
    $paletteTypeCmb = new CComboBox('palettetype', $palettetype);
    $paletteTypeCmb->addItem(0, _('Middle'));
    $paletteTypeCmb->addItem(1, _('Darken'));
    $paletteTypeCmb->addItem(2, _('Brighten'));
    $reportForm->addRow(_('Palette'), array($paletteCmb, $paletteTypeCmb));
    $reportForm->addItemToBottomRow(new CSubmit('report_show', _('Show')));
    $reset = new CButton('reset', _('Reset'));
    $reset->setType('reset');
    $reportForm->addItemToBottomRow($reset);
    return $reportForm;
}
    $macrosFormList->addRow(_('No macros found.'));
    return $macrosFormList;
}
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('&rArr;');
    $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');
}
    $urlLabel = new CTextBox('urls[' . $i . '][name]', $url['name'], 32);
    $urlLink = new CTextBox('urls[' . $i . '][url]', $url['url'], 32);
    $urlEtype = new CComboBox('urls[' . $i . '][elementtype]', $url['elementtype']);
    $urlEtype->addItems(sysmap_element_types());
    $removeButton = new CSpan(_('Remove'), 'link_menu');
    $removeButton->addAction('onclick', '$("urlEntry_' . $i . '").remove();');
    $urlRow = new CRow(array($urlLabel, $urlLink, $urlEtype, $removeButton));
    $urlRow->setAttribute('id', 'urlEntry_' . $i);
    $urlTable->addRow($urlRow);
    $i++;
}
// append empty template row to url table
$templateUrlLabel = new CTextBox('urls[#{id}][name]', '', 32);
$templateUrlLabel->setAttribute('disabled', 'disabled');
$templateUrlLink = new CTextBox('urls[#{id}][url]', '', 32);
$templateUrlLink->setAttribute('disabled', 'disabled');
$templateUrlEtype = new CComboBox('urls[#{id}][elementtype]');
$templateUrlEtype->setAttribute('disabled', 'disabled');
$templateUrlEtype->addItems(sysmap_element_types());
$templateRemoveButton = new CSpan(_('Remove'), 'link_menu');
$templateRemoveButton->addAction('onclick', '$("entry_#{id}").remove();');
$templateUrlRow = new CRow(array($templateUrlLabel, $templateUrlLink, $templateUrlEtype, $templateRemoveButton));
$templateUrlRow->addStyle('display: none');
$templateUrlRow->setAttribute('id', 'urlEntryTpl');
$urlTable->addRow($templateUrlRow);
// append "add" button to url table
$addButton = new CSpan(_('Add'), 'link_menu');
$addButton->addAction('onclick', 'cloneRow("urlEntryTpl", ' . $i . ')');
$addButtonColumn = new CCol($addButton);
$addButtonColumn->setColSpan(4);
$urlTable->addRow($addButtonColumn);
    $multiplier = array();
    if ($this->data['limited']) {
        $itemForm->addVar('multiplier', $this->data['multiplier']);
        $multiplierCheckBox = new CCheckBox('multiplier', $this->data['multiplier'] == 1 ? 'yes' : 'no');
        $multiplierCheckBox->setAttribute('disabled', 'disabled');
        $multiplier[] = $multiplierCheckBox;
        $multiplier[] = SPACE;
        $formulaTextBox = new CTextBox('formula', $this->data['formula'], ZBX_TEXTBOX_SMALL_SIZE, 1);
        $formulaTextBox->setAttribute('style', 'text-align: right;');
        $multiplier[] = $formulaTextBox;
    } else {
        $multiplierCheckBox = new CCheckBox('multiplier', $this->data['multiplier'] == 1 ? 'yes' : 'no', 'var editbx = document.getElementById(\'formula\'); if (editbx) { editbx.disabled = !this.checked; }', 1);
        $multiplier[] = $multiplierCheckBox;
        $multiplier[] = SPACE;
        $formulaTextBox = new CTextBox('formula', $this->data['formula'], ZBX_TEXTBOX_SMALL_SIZE);
        $formulaTextBox->setAttribute('style', 'text-align: right;');
        $multiplier[] = $formulaTextBox;
    }
    $itemFormList->addRow(_('Use custom multiplier'), $multiplier, false, 'row_multiplier');
}
$itemFormList->addRow(_('Update interval (in sec)'), new CNumericBox('delay', $this->data['delay'], 5), false, 'row_delay');
// append delay flex to form list
$delayFlexTable = new CTable(_('No flexible intervals defined.'), 'formElementTable');
$delayFlexTable->setAttribute('style', 'min-width: 310px;');
$delayFlexTable->setAttribute('id', 'delayFlexTable');
$delayFlexTable->setHeader(array(_('Interval'), _('Period'), _('Action')));
$i = 0;
$this->data['maxReached'] = false;
foreach ($this->data['delay_flex'] as $delayFlex) {
    if (!isset($delayFlex['delay']) && !isset($delayFlex['period'])) {
        continue;
    $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, false, 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, false, 2);
    $timeFromMinuteTextBox->setAttribute('placeholder', _('mm'));
    $timeToHourTextBox = new CTextBox('new_service_time[to_hour]', isset($_REQUEST['new_service_time']['to_hour']) ? $_REQUEST['new_service_time']['to_hour'] : '', 2, false, 2);
    $timeToHourTextBox->setAttribute('placeholder', _('hh'));
    $timeToMinuteTextBox = new CTextBox('new_service_time[to_minute]', isset($_REQUEST['new_service_time']['to_minute']) ? $_REQUEST['new_service_time']['to_minute'] : '', 2, false, 2);
    $timeToMinuteTextBox->setAttribute('placeholder', _('mm'));
    $serviceTimeTable->addRow(array(_('From'), $weekFromComboBox, new CCol(array(_('Time'), SPACE, $timeFromHourTextBox, ' : ', $timeFromMinuteTextBox))));
    $serviceTimeTable->addRow(array(_('Till'), $weekToComboBox, new CCol(array(_('Time'), SPACE, $timeToHourTextBox, ' : ', $timeToMinuteTextBox))));
    $servicesForm->addVar('new_service_time[note]', '');
}
$timeTypeComboBox = new CComboBox('new_service_time[type]', $this->data['new_service_time']['type'], 'javascript: document.forms[0].action += \'?form=1\'; submit();');
$timeTypeComboBox->addItem(SERVICE_TIME_TYPE_UPTIME, _('Uptime'));
$timeTypeComboBox->addItem(SERVICE_TIME_TYPE_DOWNTIME, _('Downtime'));
$timeTypeComboBox->addItem(SERVICE_TIME_TYPE_ONETIME_DOWNTIME, _('One-time downtime'));
$servicesTimeFormList->addRow(_('New service time'), new CDiv(array(new CDiv($timeTypeComboBox, 'time-type-combobox'), $serviceTimeTable, new CButton('add_service_time', _('Add'), null, 'link_menu')), 'objectgroup inlineblock border_dotted ui-corner-all'));
/*
 * Append tabs to form
 */
$servicesTab = new CTabView();
if (!$this->data['form_refresh']) {
    $servicesTab->setSelected(0);
$allowedTesting = true;
$expressionData = new CTriggerExpression();
if ($expressionData->parse($expression)) {
    $macrosData = array();
    $expressions = array_merge($expressionData->expressions, $expressionData->macros, $expressionData->usermacros);
    foreach ($expressions as $exprPart) {
        if (isset($macrosData[$exprPart['expression']])) {
            continue;
        }
        $fname = 'test_data_' . md5($exprPart['expression']);
        $macrosData[$exprPart['expression']] = get_request($fname, '');
        $info = get_item_function_info($exprPart['expression']);
        if (!is_array($info) && isset($definedErrorPhrases[$info])) {
            $allowedTesting = false;
            $control = new CTextBox($fname, $macrosData[$exprPart['expression']], 30);
            $control->setAttribute('disabled', 'disabled');
        } else {
            $octet = $info['value_type'] == 'HHMMSS';
            $validation = $info['validation'];
            if (substr($validation, 0, COMBO_PATTERN_LENGTH) == COMBO_PATTERN) {
                $vals = explode(',', substr($validation, COMBO_PATTERN_LENGTH, zbx_strlen($validation) - COMBO_PATTERN_LENGTH - 4));
                $control = new CComboBox($fname, $macrosData[$exprPart['expression']]);
                foreach ($vals as $v) {
                    $control->addItem($v, $v);
                }
            } else {
                $control = new CTextBox($fname, $macrosData[$exprPart['expression']], 30);
            }
            $fields[$fname] = array($info['type'], O_OPT, null, $validation, 'isset({test_expression})', $exprPart['expression']);
        }
        $data_table->addRow(new CRow(array($exprPart['expression'], is_array($info) || !isset($definedErrorPhrases[$info]) ? $info['value_type'] : new CCol($definedErrorPhrases[$info], 'disaster'), $control)));
    $urlLabel = new CTextBox('urls[' . $i . '][name]', $url['name'], 32);
    $urlLink = new CTextBox('urls[' . $i . '][url]', $url['url'], 32);
    $urlEtype = new CCombobox('urls[' . $i . '][elementtype]', $url['elementtype']);
    $urlEtype->addItems(sysmap_element_types());
    $removeButton = new CSpan(_('Remove'), 'link_menu');
    $removeButton->addAction('onclick', '$("urlEntry_' . $i . '").remove();');
    $urlRow = new CRow(array($urlLabel, $urlLink, $urlEtype, $removeButton));
    $urlRow->setAttribute('id', 'urlEntry_' . $i);
    $urlTable->addRow($urlRow);
    $i++;
}
// append empty template row to url table
$tplUrlLabel = new CTextBox('urls[#{id}][name]', '', 32);
$tplUrlLabel->setAttribute('disabled', 'disabled');
$tplUrlLink = new CTextBox('urls[#{id}][url]', '', 32);
$tplUrlLink->setAttribute('disabled', 'disabled');
$tplUrlEtype = new CCombobox('urls[#{id}][elementtype]');
$tplUrlEtype->setAttribute('disabled', 'disabled');
$tplUrlEtype->addItems(sysmap_element_types());
$tplRemoveButton = new CSpan(_('Remove'), 'link_menu');
$tplRemoveButton->addAction('onclick', '$("entry_#{id}").remove();');
$tplUrlRow = new CRow(array($tplUrlLabel, $tplUrlLink, $tplUrlEtype, $tplRemoveButton));
$tplUrlRow->addStyle('display: none');
$tplUrlRow->setAttribute('id', 'urlEntryTpl');
$urlTable->addRow($tplUrlRow);
// append "add" button to url table
$addButton = new CSpan(_('Add'), 'link_menu');
$addButton->addAction('onclick', 'cloneRow("urlEntryTpl", ' . $i . ')');
$addButtonColumn = new CCol($addButton);
$addButtonColumn->setColSpan(4);
$urlTable->addRow($addButtonColumn);