public function parseValue($name, $value)
 {
     if (is_array($value)) {
         foreach ($value as $key => $item) {
             if (is_null($item)) {
                 continue;
             }
             $this->parseValue($name . '[' . $key . ']', $item);
         }
         return null;
     }
     if (strpos($value, "\n") === false) {
         $hiddenVar = new CInput('hidden', $name, $value, null, $this->element_id);
         $hiddenVar->removeAttribute('class');
     } else {
         $hiddenVar = new CTextArea($name, $value);
         $hiddenVar->setAttribute('class', 'hidden');
     }
     $this->var_container[] = $hiddenVar;
 }
** 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.
**/
require_once dirname(__FILE__) . '/js/monitoring.triggerComment.js.php';
$commentWidget = new CWidget('triggerComment');
$commentWidget->addPageHeader(_('TRIGGER DESCRIPTION'));
// create form
$commentForm = new CForm();
$commentForm->setName('commentForm');
$commentForm->addVar('triggerid', $this->data['triggerid']);
// create form list
$commentFormList = new CFormList('commentFormList');
$commentTextArea = new CTextArea('comments', CMacrosResolverHelper::resolveTriggerDescription($this->data['trigger']), array('rows' => 25, 'width' => ZBX_TEXTAREA_BIG_WIDTH, 'readonly' => $this->data['isCommentExist']));
$commentTextArea->attr('autofocus', 'autofocus');
$commentFormList->addRow(_('Description'), $commentTextArea);
// append tabs to form
$commentTab = new CTabView();
$commentTab->addTab('commentTab', _s('Description for "%s".', $this->data['trigger']['description']), $commentFormList);
$commentForm->addItem($commentTab);
// append buttons to form
$updateButton = new CSubmit('update', _('Update'));
$updateButton->setEnabled(!$this->data['isCommentExist']);
if ($this->data['isCommentExist']) {
    $editButton = new CButton('edit', _('Edit'));
    $editButton->setEnabled($this->data['isTriggerEditable']);
} else {
    $editButton = null;
}
        $hostInventoryFieldComboBox = new CComboBox('inventory_link');
        $hostInventoryFieldComboBox->addItem(0, '-' . _('None') . '-', $this->data['inventory_link'] == '0' ? 'yes' : null);
        // a list of available host inventory fields
        foreach ($this->data['possibleHostInventories'] as $fieldNo => $fieldInfo) {
            if (isset($this->data['alreadyPopulated'][$fieldNo])) {
                $enabled = isset($this->data['item']['inventory_link']) ? $this->data['item']['inventory_link'] == $fieldNo : $this->data['inventory_link'] == $fieldNo && !$itemCloned;
            } else {
                $enabled = true;
            }
            $hostInventoryFieldComboBox->addItem($fieldNo, $fieldInfo['title'], $this->data['inventory_link'] == $fieldNo && $enabled ? 'yes' : null, $enabled ? 'yes' : 'no');
        }
        $itemFormList->addRow(_('Populates host inventory field'), $hostInventoryFieldComboBox, false, 'row_inventory_link');
    }
}
// append description to form list
$description = new CTextArea('description', $this->data['description']);
$description->addStyle('margin-top: 5px;');
$itemFormList->addRow(_('Description'), $description);
// status
$enabledCheckBox = new CCheckBox('status', !$this->data['status'], null, ITEM_STATUS_ACTIVE);
$itemFormList->addRow(_('Enabled'), $enabledCheckBox);
// append tabs to form
$itemTab = new CTabView();
$itemTab->addTab('itemTab', $this->data['caption'], $itemFormList);
$itemForm->addItem($itemTab);
// append buttons to form
$buttons = array();
if (!empty($this->data['itemid'])) {
    array_push($buttons, new CSubmit('clone', _('Clone')));
    if (!$this->data['is_template'] && !empty($this->data['itemid']) && empty($this->data['parent_discoveryid']) && !$this->data['is_discovery_rule']) {
        array_push($buttons, new CButtonQMessage('del_history', _('Clear history and trends'), _('History clearing can take a long time. Continue?')));
$inventoryDisabledBtn = new CRadioButton('inventory_mode', HOST_INVENTORY_DISABLED, null, 'host_inventory_radio_' . HOST_INVENTORY_DISABLED, $inventoryMode == HOST_INVENTORY_DISABLED);
$inventoryDisabledBtn->setEnabled(!$isDiscovered);
$inventoryManualBtn = new CRadioButton('inventory_mode', HOST_INVENTORY_MANUAL, null, 'host_inventory_radio_' . HOST_INVENTORY_MANUAL, $inventoryMode == HOST_INVENTORY_MANUAL);
$inventoryManualBtn->setEnabled(!$isDiscovered);
$inventoryAutomaticBtn = new CRadioButton('inventory_mode', HOST_INVENTORY_AUTOMATIC, null, 'host_inventory_radio_' . HOST_INVENTORY_AUTOMATIC, $inventoryMode == HOST_INVENTORY_AUTOMATIC);
$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));
** 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.
**/
require_once dirname(__FILE__) . '/js/monitoring.triggerComment.js.php';
$commentWidget = new CWidget('triggerComment');
$commentWidget->addPageHeader(_('TRIGGER COMMENTS'));
// create form
$commentForm = new CForm();
$commentForm->setName('commentForm');
$commentForm->addVar('triggerid', $this->data['triggerid']);
// create form list
$commentFormList = new CFormList('commentFormList');
$commentTextArea = new CTextArea('comments', CMacrosResolverHelper::resolveTriggerDescription($this->data['trigger']), array('rows' => 25, 'width' => ZBX_TEXTAREA_BIG_WIDTH, 'readonly' => $this->data['isCommentExist']));
$commentTextArea->attr('autofocus', 'autofocus');
$commentFormList->addRow(_('Comments'), $commentTextArea);
// append tabs to form
$commentTab = new CTabView();
$commentTab->addTab('commentTab', _s('Comments for "%s".', $this->data['trigger']['description']), $commentFormList);
$commentForm->addItem($commentTab);
// append buttons to form
$saveButton = new CSubmit('save', _('Save'));
$saveButton->setEnabled(!$this->data['isCommentExist']);
if ($this->data['isCommentExist']) {
    $editButton = new CButton('edit', _('Edit'));
    $editButton->setEnabled($this->data['isTriggerEditable']);
} else {
    $editButton = null;
}
// execute on
$typeRB = new CRadioButtonList('execute_on', $this->get('execute_on'));
$typeRB->makeVertical();
$typeRB->addValue(_('Zabbix agent'), ZBX_SCRIPT_EXECUTE_ON_AGENT);
$typeRB->addValue(_('Zabbix server'), ZBX_SCRIPT_EXECUTE_ON_SERVER);
$scriptTab->addRow(_('Execute on'), new CDiv($typeRB, 'objectgroup inlineblock border_dotted ui-corner-all'), $data['type'] == ZBX_SCRIPT_TYPE_IPMI);
// command
$commandTA = new CTextArea('command', $this->get('command'));
$commandTA->addStyle('width: 50em; padding: 0;');
$scriptTab->addRow(_('Commands'), $commandTA, $this->get('type') == ZBX_SCRIPT_TYPE_IPMI);
// command ipmi
$commandIpmiTB = new CTextBox('commandipmi', $this->get('commandipmi'));
$commandIpmiTB->addStyle('width: 50em;');
$scriptTab->addRow(_('Command'), $commandIpmiTB, $this->get('type') == ZBX_SCRIPT_TYPE_CUSTOM_SCRIPT);
// description
$descriptionTA = new CTextArea('description', $this->get('description'));
$descriptionTA->addStyle('width: 50em; padding: 0;');
$scriptTab->addRow(_('Description'), $descriptionTA);
// user groups
$usr_groups = new CCombobox('usrgrpid', $this->get('usrgrpid'));
$usr_groups->addItem(0, _('All'));
$usergroups = $this->getArray('usergroups');
foreach ($usergroups as $ugnum => $usr_group) {
    $usr_groups->addItem($usr_group['usrgrpid'], $usr_group['name']);
}
$scriptTab->addRow(_('User groups'), $usr_groups);
// host groups
$host_groups = new CCombobox('groupid', $this->get('groupid'));
$host_groups->addItem(0, _('All'));
$groups = $this->getArray('groups');
foreach ($groups as $gnum => $group) {
$hostFormList->addRow(array(_('IPMI username'), SPACE, new CVisibilityBox('visible[ipmi_username]', isset($this->data['visible']['ipmi_username']), 'ipmi_username', _('Original'))), new CTextBox('ipmi_username', $this->data['ipmi_username'], ZBX_TEXTBOX_SMALL_SIZE));
$hostFormList->addRow(array(_('IPMI password'), SPACE, new CVisibilityBox('visible[ipmi_password]', isset($this->data['visible']['ipmi_password']), 'ipmi_password', _('Original'))), new CTextBox('ipmi_password', $this->data['ipmi_password'], ZBX_TEXTBOX_SMALL_SIZE));
// 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
Esempio n. 8
0
    }
}
$messageTable = new CFormTable($title . ' "' . getUserFullname(CWebUser::$data) . '"');
$messageTable->addVar('backurl', $_REQUEST['backurl']);
if (in_array($_REQUEST['backurl'], array('tr_events.php', 'events.php'))) {
    $messageTable->addVar('eventid', $_REQUEST['eventid']);
    $messageTable->addVar('triggerid', $_REQUEST['triggerid']);
} elseif (in_array($_REQUEST['backurl'], array('screenedit.php', 'screens.php'))) {
    $messageTable->addVar('screenid', $_REQUEST['screenid']);
}
if (isset($_REQUEST['eventid'])) {
    $messageTable->addVar('eventid', $_REQUEST['eventid']);
} elseif (isset($_REQUEST['triggers'])) {
    foreach ($_REQUEST['triggers'] as $triggerId) {
        $messageTable->addVar('triggers[' . $triggerId . ']', $triggerId);
    }
} elseif (isset($_REQUEST['events'])) {
    foreach ($_REQUEST['events'] as $eventId) {
        $messageTable->addVar('events[' . $eventId . ']', $eventId);
    }
}
$message = new CTextArea('message', '', array('rows' => ZBX_TEXTAREA_STANDARD_ROWS, 'width' => ZBX_TEXTAREA_BIG_WIDTH, 'maxlength' => 255));
$message->attr('autofocus', 'autofocus');
$messageTable->addRow(_('Message'), $message);
$messageTable->addItemToBottomRow(new CSubmit('saveandreturn', $saveAndReturnLabel));
if (!$bulk) {
    $messageTable->addItemToBottomRow(new CSubmit('save', $saveLabel));
}
$messageTable->addItemToBottomRow(new CButtonCancel(url_params(array('backurl', 'eventid', 'triggerid', 'screenid'))));
$messageTable->show(false);
require_once dirname(__FILE__) . '/include/page_footer.php';
$labelTypeTriggerComboBox = new CComboBox('label_type_trigger', $this->data['sysmap']['label_type_trigger'], null, $this->data['labelTypesLimited']);
$customLabelTriggerTextArea = new CTextArea('label_string_trigger', $this->data['sysmap']['label_string_trigger']);
if ($this->data['sysmap']['label_type_trigger'] != MAP_LABEL_TYPE_CUSTOM) {
    $customLabelTriggerTextArea->addClass('hidden');
}
$sysmapList->addRow(_('Trigger label type'), array($labelTypeTriggerComboBox, BR(), $customLabelTriggerTextArea));
// append map to form list
$labelTypeMapComboBox = new CComboBox('label_type_map', $this->data['sysmap']['label_type_map'], null, $this->data['labelTypesLimited']);
$customLabelMapTextArea = new CTextArea('label_string_map', $this->data['sysmap']['label_string_map']);
if ($this->data['sysmap']['label_type_map'] != MAP_LABEL_TYPE_CUSTOM) {
    $customLabelMapTextArea->addClass('hidden');
}
$sysmapList->addRow(_('Map label type'), array($labelTypeMapComboBox, BR(), $customLabelMapTextArea));
// append image to form list
$labelTypeImageComboBox = new CComboBox('label_type_image', $this->data['sysmap']['label_type_image'], null, $this->data['labelTypesImage']);
$customLabelImageTextArea = new CTextArea('label_string_image', $this->data['sysmap']['label_string_image']);
if ($this->data['sysmap']['label_type_image'] != MAP_LABEL_TYPE_CUSTOM) {
    $customLabelImageTextArea->addClass('hidden');
}
$sysmapList->addRow(_('Image label type'), array($labelTypeImageComboBox, BR(), $customLabelImageTextArea));
// append icon label to form list
unset($this->data['labelTypes'][MAP_LABEL_TYPE_CUSTOM]);
$sysmapList->addRow(_('Icon label type'), new CComboBox('label_type', $this->data['sysmap']['label_type'], null, $this->data['labelTypes']));
// append icon label location to form list
$locationComboBox = new CComboBox('label_location', $this->data['sysmap']['label_location']);
$locationComboBox->addItems(array(0 => _('Bottom'), 1 => _('Left'), 2 => _('Right'), 3 => _('Top')));
$sysmapList->addRow(_('Icon label location'), $locationComboBox);
// append show unack to form list
$showUnackComboBox = new CComboBox('show_unack', $this->data['sysmap']['show_unack']);
$showUnackComboBox->addItems(array(EXTACK_OPTION_ALL => _('All'), EXTACK_OPTION_BOTH => _('Separated'), EXTACK_OPTION_UNACK => _('Unacknowledged only')));
$showUnackComboBox->setEnabled($this->data['config']['event_ack_enable']);
    if (isset($_REQUEST['new_applications'])) {
        foreach ($_REQUEST['new_applications'] as $newApplication) {
            if (is_array($newApplication) && isset($newApplication['new'])) {
                $appToAdd[] = array('id' => $newApplication['new'], 'name' => $newApplication['new'] . ' (new)', 'isNew' => true);
            } else {
                $appToAddId[] = $newApplication;
            }
        }
        if (isset($appToAddId)) {
            $getApps = API::Application()->get(array('applicationids' => $appToAddId, 'output' => array('applicationid', 'name')));
            foreach ($getApps as $getApp) {
                $appToAdd[] = array('id' => $getApp['applicationid'], 'name' => $getApp['name']);
            }
        }
    }
    $newApp = new CMultiSelect(array('name' => 'new_applications[]', 'objectName' => 'applications', 'objectOptions' => array('hostid' => $this->data['hostid']), 'data' => $appToAdd, 'addNew' => true));
    $itemFormList->addRow(array(_('Add new or existing applications'), SPACE, new CVisibilityBox('visible[new_applications]', isset($this->data['visible']['new_applications']), 'new_applications_', _('Original'))), $newApp);
}
// append description to form list
$descriptionTextArea = new CTextArea('description', $this->data['description']);
$descriptionTextArea->addStyle('margin-top: 5px;');
$itemFormList->addRow(array(_('Description'), SPACE, new CVisibilityBox('visible[description]', isset($this->data['visible']['description']), 'description', _('Original'))), $descriptionTextArea);
// append tabs to form
$itemTab = new CTabView();
$itemTab->addTab('itemTab', _('Mass update'), $itemFormList);
$itemForm->addItem($itemTab);
// append buttons to form
$itemForm->addItem(makeFormFooter(new CSubmit('update', _('Update')), new CButtonCancel(url_param('groupid') . url_param('hostid') . url_param('config'))));
$itemWidget->addItem($itemForm);
require_once dirname(__FILE__) . '/js/configuration.item.edit.js.php';
return $itemWidget;
Esempio n. 11
0
function insert_item_form()
{
    global $USER_DETAILS;
    $frmItem = new CFormTable(S_ITEM, 'items.php', 'post');
    $frmItem->setAttribute('style', 'visibility: hidden;');
    $frmItem->setHelp('web.items.item.php');
    $hostid = get_request('form_hostid', 0);
    $description = get_request('description', '');
    $key = get_request('key', '');
    $host = get_request('host', null);
    $delay = get_request('delay', 30);
    $history = get_request('history', 90);
    $status = get_request('status', 0);
    $type = get_request('type', 0);
    $snmp_community = get_request('snmp_community', 'public');
    $snmp_oid = get_request('snmp_oid', 'interfaces.ifTable.ifEntry.ifInOctets.1');
    $snmp_port = get_request('snmp_port', 161);
    $value_type = get_request('value_type', ITEM_VALUE_TYPE_UINT64);
    $data_type = get_request('data_type', ITEM_DATA_TYPE_DECIMAL);
    $trapper_hosts = get_request('trapper_hosts', '');
    $units = get_request('units', '');
    $valuemapid = get_request('valuemapid', 0);
    $params = get_request('params', '');
    $multiplier = get_request('multiplier', 0);
    $delta = get_request('delta', 0);
    $trends = get_request('trends', 365);
    $new_application = get_request('new_application', '');
    $applications = get_request('applications', array());
    $delay_flex = get_request('delay_flex', array());
    $snmpv3_securityname = get_request('snmpv3_securityname', '');
    $snmpv3_securitylevel = get_request('snmpv3_securitylevel', 0);
    $snmpv3_authpassphrase = get_request('snmpv3_authpassphrase', '');
    $snmpv3_privpassphrase = get_request('snmpv3_privpassphrase', '');
    $ipmi_sensor = get_request('ipmi_sensor', '');
    $authtype = get_request('authtype', 0);
    $username = get_request('username', '');
    $password = get_request('password', '');
    $publickey = get_request('publickey', '');
    $privatekey = get_request('privatekey', '');
    $formula = get_request('formula', '1');
    $logtimefmt = get_request('logtimefmt', '');
    $add_groupid = get_request('add_groupid', get_request('groupid', 0));
    $limited = null;
    $types = item_type2str();
    // http items only for internal processes
    unset($types[ITEM_TYPE_HTTPTEST]);
    if (isset($_REQUEST['itemid'])) {
        $frmItem->addVar('itemid', $_REQUEST['itemid']);
        $options = array('itemids' => $_REQUEST['itemid'], 'output' => API_OUTPUT_EXTEND);
        $item_data = CItem::get($options);
        $item_data = reset($item_data);
        $hostid = $hostid > 0 ? $hostid : $item_data['hostid'];
        $limited = $item_data['templateid'] == 0 && $item_data['type'] != ITEM_TYPE_HTTPTEST ? null : 'yes';
        $item_data['snmp_port'] = $item_data['snmp_port'] == '0' ? 161 : $item_data['snmp_port'];
    }
    if (is_null($host)) {
        if ($hostid > 0) {
            $options = array('hostids' => $hostid, 'output' => API_OUTPUT_EXTEND, 'templated_hosts' => 1);
            $host_info = CHost::get($options);
            $host_info = reset($host_info);
            $host = $host_info['host'];
        } else {
            $host = S_NOT_SELECTED_SMALL;
        }
    }
    if (isset($_REQUEST['itemid']) && !isset($_REQUEST['form_refresh']) || isset($limited)) {
        $description = $item_data['description'];
        $key = $item_data['key_'];
        //			$host			= $item_data['host'];
        $type = $item_data['type'];
        $snmp_community = $item_data['snmp_community'];
        $snmp_oid = $item_data['snmp_oid'];
        $snmp_port = $item_data['snmp_port'];
        $value_type = $item_data['value_type'];
        $data_type = $item_data['data_type'];
        $trapper_hosts = $item_data['trapper_hosts'];
        $units = $item_data['units'];
        $valuemapid = $item_data['valuemapid'];
        $multiplier = $item_data['multiplier'];
        $hostid = $item_data['hostid'];
        $params = $item_data['params'];
        $snmpv3_securityname = $item_data['snmpv3_securityname'];
        $snmpv3_securitylevel = $item_data['snmpv3_securitylevel'];
        $snmpv3_authpassphrase = $item_data['snmpv3_authpassphrase'];
        $snmpv3_privpassphrase = $item_data['snmpv3_privpassphrase'];
        $ipmi_sensor = $item_data['ipmi_sensor'];
        $authtype = $item_data['authtype'];
        $username = $item_data['username'];
        $password = $item_data['password'];
        $publickey = $item_data['publickey'];
        $privatekey = $item_data['privatekey'];
        $formula = $item_data['formula'];
        $logtimefmt = $item_data['logtimefmt'];
        $new_application = get_request('new_application', '');
        if (!isset($limited) || !isset($_REQUEST['form_refresh'])) {
            $delay = $item_data['delay'];
            $history = $item_data['history'];
            $status = $item_data['status'];
            $delta = $item_data['delta'];
            $trends = $item_data['trends'];
            $db_delay_flex = $item_data['delay_flex'];
            if (isset($db_delay_flex)) {
                $arr_of_dellays = explode(';', $db_delay_flex);
                foreach ($arr_of_dellays as $one_db_delay) {
                    $arr_of_delay = explode('/', $one_db_delay);
                    if (!isset($arr_of_delay[0]) || !isset($arr_of_delay[1])) {
                        continue;
                    }
                    array_push($delay_flex, array('delay' => $arr_of_delay[0], 'period' => $arr_of_delay[1]));
                }
            }
            $applications = array_unique(zbx_array_merge($applications, get_applications_by_itemid($_REQUEST['itemid'])));
        }
    }
    $securityLevelVisibility = array();
    $valueTypeVisibility = array();
    $authTypeVisibility = array();
    $typeVisibility = array();
    $delay_flex_el = array();
    //if($type != ITEM_TYPE_TRAPPER){
    $i = 0;
    foreach ($delay_flex as $val) {
        if (!isset($val['delay']) && !isset($val['period'])) {
            continue;
        }
        array_push($delay_flex_el, array(new CCheckBox('rem_delay_flex[' . $i . ']', 'no', null, $i), $val['delay'], SPACE . S_SEC_AT . SPACE, $val['period']), BR());
        $frmItem->addVar('delay_flex[' . $i . '][delay]', $val['delay']);
        $frmItem->addVar('delay_flex[' . $i . '][period]', $val['period']);
        foreach ($types as $it => $caption) {
            if ($it == ITEM_TYPE_TRAPPER || $it == ITEM_TYPE_ZABBIX_ACTIVE) {
                continue;
            }
            zbx_subarray_push($typeVisibility, $it, 'delay_flex[' . $i . '][delay]');
            zbx_subarray_push($typeVisibility, $it, 'delay_flex[' . $i . '][period]');
            zbx_subarray_push($typeVisibility, $it, 'rem_delay_flex[' . $i . ']');
        }
        $i++;
        if ($i >= 7) {
            break;
        }
        /* limit count of intervals
         * 7 intervals by 30 symbols = 210 characters
         * db storage field is 256
         */
    }
    //}
    array_push($delay_flex_el, count($delay_flex_el) == 0 ? S_NO_FLEXIBLE_INTERVALS : new CButton('del_delay_flex', S_DELETE_SELECTED));
    if (count($applications) == 0) {
        array_push($applications, 0);
    }
    if (isset($_REQUEST['itemid'])) {
        $caption = array();
        $itemid = $_REQUEST['itemid'];
        do {
            $sql = 'SELECT i.itemid, i.templateid, h.host' . ' FROM items i, hosts h' . ' WHERE i.itemid=' . $itemid . ' AND h.hostid=i.hostid';
            $itemFromDb = DBfetch(DBselect($sql));
            if ($itemFromDb) {
                if ($_REQUEST['itemid'] == $itemid) {
                    $caption[] = SPACE;
                    $caption[] = $itemFromDb['host'];
                } else {
                    $caption[] = ' : ';
                    $caption[] = new CLink($itemFromDb['host'], 'items.php?form=update&itemid=' . $itemFromDb['itemid'], 'highlight underline');
                }
                $itemid = $itemFromDb['templateid'];
            } else {
                break;
            }
        } while ($itemid != 0);
        $caption[] = S_ITEM . ' "';
        $caption = array_reverse($caption);
        $caption[] = ': ';
        $caption[] = $item_data['description'];
        $caption[] = '"';
        $frmItem->setTitle($caption);
    } else {
        $frmItem->setTitle(S_ITEM . " {$host} : {$description}");
    }
    $frmItem->addVar('form_hostid', $hostid);
    $frmItem->addRow(S_HOST, array(new CTextBox('host', $host, 32, true), new CButton('btn_host', S_SELECT, "return PopUp('popup.php?dstfrm=" . $frmItem->getName() . "&dstfld1=host&dstfld2=form_hostid&srctbl=hosts_and_templates&srcfld1=host&srcfld2=hostid',450,450);", 'H')));
    $frmItem->addRow(S_DESCRIPTION, new CTextBox('description', $description, 40, $limited));
    if (isset($limited)) {
        $frmItem->addRow(S_TYPE, new CTextBox('typename', item_type2str($type), 40, 'yes'));
        $frmItem->addVar('type', $type);
    } else {
        $cmbType = new CComboBox('type', $type);
        $cmbType->addItems($types);
        $frmItem->addRow(S_TYPE, $cmbType);
    }
    $row = new CRow(array(new CCol(S_SNMP_OID, 'form_row_l'), new CCol(new CTextBox('snmp_oid', $snmp_oid, 40, $limited), 'form_row_r')));
    $row->setAttribute('id', 'row_snmp_oid');
    $frmItem->addRow($row);
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SNMPV1, 'snmp_oid');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SNMPV2C, 'snmp_oid');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SNMPV3, 'snmp_oid');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SNMPV1, 'row_snmp_oid');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SNMPV2C, 'row_snmp_oid');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SNMPV3, 'row_snmp_oid');
    $row = new CRow(array(new CCol(S_SNMP_COMMUNITY, 'form_row_l'), new CCol(new CTextBox('snmp_community', $snmp_community, 16), 'form_row_r')));
    $row->setAttribute('id', 'row_snmp_community');
    $frmItem->addRow($row);
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SNMPV1, 'snmp_community');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SNMPV2C, 'snmp_community');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SNMPV1, 'row_snmp_community');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SNMPV2C, 'row_snmp_community');
    $row = new CRow(array(new CCol(S_SNMPV3_SECURITY_NAME, 'form_row_l'), new CCol(new CTextBox('snmpv3_securityname', $snmpv3_securityname, 64), 'form_row_r')));
    $row->setAttribute('id', 'row_snmpv3_securityname');
    $frmItem->addRow($row);
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SNMPV3, 'snmpv3_securityname');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SNMPV3, 'row_snmpv3_securityname');
    $cmbSecLevel = new CComboBox('snmpv3_securitylevel', $snmpv3_securitylevel);
    $cmbSecLevel->addItem(ITEM_SNMPV3_SECURITYLEVEL_NOAUTHNOPRIV, 'noAuthNoPriv');
    $cmbSecLevel->addItem(ITEM_SNMPV3_SECURITYLEVEL_AUTHNOPRIV, 'authNoPriv');
    $cmbSecLevel->addItem(ITEM_SNMPV3_SECURITYLEVEL_AUTHPRIV, 'authPriv');
    $row = new CRow(array(new CCol(S_SNMPV3_SECURITY_LEVEL, 'form_row_l'), new CCol($cmbSecLevel, 'form_row_r')));
    $row->setAttribute('id', 'row_snmpv3_securitylevel');
    $frmItem->addRow($row);
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SNMPV3, 'snmpv3_securitylevel');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SNMPV3, 'row_snmpv3_securitylevel');
    $row = new CRow(array(new CCol(S_SNMPV3_AUTH_PASSPHRASE, 'form_row_l'), new CCol(new CTextBox('snmpv3_authpassphrase', $snmpv3_authpassphrase, 64), 'form_row_r')));
    $row->setAttribute('id', 'row_snmpv3_authpassphrase');
    $frmItem->addRow($row);
    zbx_subarray_push($securityLevelVisibility, ITEM_SNMPV3_SECURITYLEVEL_AUTHNOPRIV, 'snmpv3_authpassphrase');
    zbx_subarray_push($securityLevelVisibility, ITEM_SNMPV3_SECURITYLEVEL_AUTHNOPRIV, 'row_snmpv3_authpassphrase');
    $row = new CRow(array(new CCol(S_SNMPV3_PRIV_PASSPHRASE, 'form_row_l'), new CCol(new CTextBox('snmpv3_privpassphrase', $snmpv3_privpassphrase, 64), 'form_row_r')));
    $row->setAttribute('id', 'row_snmpv3_privpassphrase');
    $frmItem->addRow($row);
    zbx_subarray_push($securityLevelVisibility, ITEM_SNMPV3_SECURITYLEVEL_AUTHPRIV, 'snmpv3_privpassphrase');
    zbx_subarray_push($securityLevelVisibility, ITEM_SNMPV3_SECURITYLEVEL_AUTHPRIV, 'row_snmpv3_privpassphrase');
    zbx_subarray_push($securityLevelVisibility, ITEM_SNMPV3_SECURITYLEVEL_AUTHPRIV, 'snmpv3_authpassphrase');
    zbx_subarray_push($securityLevelVisibility, ITEM_SNMPV3_SECURITYLEVEL_AUTHPRIV, 'row_snmpv3_authpassphrase');
    $row = new CRow(array(new CCol(S_SNMP_PORT, 'form_row_l'), new CCol(new CNumericBox('snmp_port', $snmp_port, 5), 'form_row_r')));
    $row->setAttribute('id', 'row_snmp_port');
    $frmItem->addRow($row);
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SNMPV1, 'snmp_port');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SNMPV2C, 'snmp_port');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SNMPV3, 'snmp_port');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SNMPV1, 'row_snmp_port');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SNMPV2C, 'row_snmp_port');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SNMPV3, 'row_snmp_port');
    $row = new CRow(array(new CCol(S_IPMI_SENSOR, 'form_row_l'), new CCol(new CTextBox('ipmi_sensor', $ipmi_sensor, 64, $limited), 'form_row_r')));
    $row->setAttribute('id', 'row_ipmi_sensor');
    $frmItem->addRow($row);
    zbx_subarray_push($typeVisibility, ITEM_TYPE_IPMI, 'ipmi_sensor');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_IPMI, 'row_ipmi_sensor');
    if (isset($limited)) {
        $btnSelect = null;
    } else {
        $btnSelect = new CButton('btn1', S_SELECT, "return PopUp('popup.php?dstfrm=" . $frmItem->getName() . "&dstfld1=key&srctbl=help_items&srcfld1=key_&itemtype=" . $type . "');", 'T');
    }
    $frmItem->addRow(S_KEY, array(new CTextBox('key', $key, 40, $limited), $btnSelect));
    foreach ($types as $it => $ilabel) {
        switch ($it) {
            case ITEM_TYPE_DB_MONITOR:
                zbx_subarray_push($typeVisibility, $it, array('id' => 'key', 'defaultValue' => 'db.odbc.select[<unique short description>]'));
                zbx_subarray_push($typeVisibility, $it, array('id' => 'params_dbmonitor', 'defaultValue' => "DSN=<database source name>\nuser=<user name>\npassword=<password>\nsql=<query>"));
                break;
            case ITEM_TYPE_SSH:
                zbx_subarray_push($typeVisibility, $it, array('id' => 'key', 'defaultValue' => 'ssh.run[<unique short description>,<ip>,<port>,<encoding>]'));
                break;
            case ITEM_TYPE_TELNET:
                zbx_subarray_push($typeVisibility, $it, array('id' => 'key', 'defaultValue' => 'telnet.run[<unique short description>,<ip>,<port>,<encoding>]'));
                break;
            default:
                zbx_subarray_push($typeVisibility, $it, array('id' => 'key', 'defaultValue' => ''));
        }
    }
    /*
    ITEM_TYPE_DB_MONITOR $key = 'db.odbc.select[<unique short description>]'; $params = "DSN=<database source name>\nuser=<user name>\npassword=<password>\nsql=<query>";
    ITEM_TYPE_SSH $key = 'ssh.run[<unique short description>,<ip>,<port>,<encoding>]'; $params = '';
    ITEM_TYPE_TELNET $key = 'telnet.run[<unique short description>,<ip>,<port>,<encoding>]'; $params = '';
    ITEM_TYPE_CALCULATED $key = ''; $params = '';
    //*/
    $cmbAuthType = new CComboBox('authtype', $authtype);
    $cmbAuthType->addItem(ITEM_AUTHTYPE_PASSWORD, S_PASSWORD);
    $cmbAuthType->addItem(ITEM_AUTHTYPE_PUBLICKEY, S_PUBLIC_KEY);
    $row = new CRow(array(new CCol(S_AUTHENTICATION_METHOD, 'form_row_l'), new CCol($cmbAuthType, 'form_row_r')));
    $row->setAttribute('id', 'row_authtype');
    $frmItem->addRow($row);
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SSH, 'authtype');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SSH, 'row_authtype');
    $row = new CRow(array(new CCol(S_USER_NAME, 'form_row_l'), new CCol(new CTextBox('username', $username, 16), 'form_row_r')));
    $row->setAttribute('id', 'row_username');
    $frmItem->addRow($row);
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SSH, 'username');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SSH, 'row_username');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_TELNET, 'username');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_TELNET, 'row_username');
    $row = new CRow(array(new CCol(S_PUBLIC_KEY_FILE, 'form_row_l'), new CCol(new CTextBox('publickey', $publickey, 16), 'form_row_r')));
    $row->setAttribute('id', 'row_publickey');
    $frmItem->addRow($row);
    zbx_subarray_push($authTypeVisibility, ITEM_AUTHTYPE_PUBLICKEY, 'publickey');
    zbx_subarray_push($authTypeVisibility, ITEM_AUTHTYPE_PUBLICKEY, 'row_publickey');
    $row = new CRow(array(new CCol(S_PRIVATE_KEY_FILE, 'form_row_l'), new CCol(new CTextBox('privatekey', $privatekey, 16), 'form_row_r')));
    $row->setAttribute('id', 'row_privatekey');
    $frmItem->addRow($row);
    zbx_subarray_push($authTypeVisibility, ITEM_AUTHTYPE_PUBLICKEY, 'privatekey');
    zbx_subarray_push($authTypeVisibility, ITEM_AUTHTYPE_PUBLICKEY, 'row_privatekey');
    $row = new CRow(array(new CCol(S_PASSWORD, 'form_row_l'), new CCol(new CTextBox('password', $password, 16), 'form_row_r')));
    $row->setAttribute('id', 'row_password');
    $frmItem->addRow($row);
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SSH, 'password');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SSH, 'row_password');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_TELNET, 'password');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_TELNET, 'row_password');
    $spanEC = new CSpan(S_EXECUTED_SCRIPT);
    $spanEC->setAttribute('id', 'label_executed_script');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SSH, 'label_executed_script');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_TELNET, 'label_executed_script');
    $spanP = new CSpan(S_PARAMS);
    $spanP->setAttribute('id', 'label_params');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_DB_MONITOR, 'label_params');
    $spanF = new CSpan(S_FORMULA);
    $spanF->setAttribute('id', 'label_formula');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_CALCULATED, 'label_formula');
    $params_script = new CTextArea('params', $params, 60, 4);
    $params_script->setAttribute('id', 'params_script');
    $params_dbmonitor = new CTextArea('params', $params, 60, 4);
    $params_dbmonitor->setAttribute('id', 'params_dbmonitor');
    $params_calculted = new CTextArea('params', $params, 60, 4);
    $params_calculted->setAttribute('id', 'params_calculted');
    $row = new CRow(array(new CCol(array($spanEC, $spanP, $spanF), 'form_row_l'), new CCol(array($params_script, $params_dbmonitor, $params_calculted), 'form_row_r')));
    $row->setAttribute('id', 'row_params');
    $frmItem->addRow($row);
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SSH, 'params_script');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SSH, 'row_params');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_TELNET, 'params_script');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_TELNET, 'row_params');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_DB_MONITOR, 'params_dbmonitor');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_DB_MONITOR, 'row_params');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_CALCULATED, 'params_calculted');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_CALCULATED, 'row_params');
    /*
    ITEM_TYPE_DB_MONITOR $key = 'db.odbc.select[<unique short description>]'; $params = "DSN=<database source name>\nuser=<user name>\npassword=<password>\nsql=<query>";
    ITEM_TYPE_SSH $key = 'ssh.run[<unique short description>,<ip>,<port>,<encoding>]'; $params = '';
    ITEM_TYPE_TELNET $key = 'telnet.run[<unique short description>,<ip>,<port>,<encoding>]'; $params = '';
    ITEM_TYPE_CALCULATED $key = ''; $params = '';
    //*/
    if (isset($limited)) {
        $frmItem->addVar('value_type', $value_type);
        $cmbValType = new CTextBox('value_type_name', item_value_type2str($value_type), 40, 'yes');
    } else {
        $cmbValType = new CComboBox('value_type', $value_type);
        $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);
    }
    $frmItem->addRow(S_TYPE_OF_INFORMATION, $cmbValType);
    if (isset($limited)) {
        $frmItem->addVar('data_type', $data_type);
        $cmbDataType = new CTextBox('data_type_name', item_data_type2str($data_type), 20, 'yes');
    } else {
        $cmbDataType = new CComboBox('data_type', $data_type);
        $cmbDataType->addItem(ITEM_DATA_TYPE_DECIMAL, item_data_type2str(ITEM_DATA_TYPE_DECIMAL));
        $cmbDataType->addItem(ITEM_DATA_TYPE_OCTAL, item_data_type2str(ITEM_DATA_TYPE_OCTAL));
        $cmbDataType->addItem(ITEM_DATA_TYPE_HEXADECIMAL, item_data_type2str(ITEM_DATA_TYPE_HEXADECIMAL));
    }
    $row = new CRow(array(new CCol(S_DATA_TYPE, 'form_row_l'), new CCol($cmbDataType, 'form_row_r')));
    $row->setAttribute('id', 'row_data_type');
    $frmItem->addRow($row);
    zbx_subarray_push($valueTypeVisibility, ITEM_VALUE_TYPE_UINT64, 'data_type');
    zbx_subarray_push($valueTypeVisibility, ITEM_VALUE_TYPE_UINT64, 'row_data_type');
    $row = new CRow(array(new CCol(S_UNITS, 'form_row_l'), new CCol(new CTextBox('units', $units, 40, $limited), 'form_row_r')));
    $row->setAttribute('id', 'row_units');
    $frmItem->addRow($row);
    zbx_subarray_push($valueTypeVisibility, ITEM_VALUE_TYPE_FLOAT, 'units');
    zbx_subarray_push($valueTypeVisibility, ITEM_VALUE_TYPE_FLOAT, 'row_units');
    zbx_subarray_push($valueTypeVisibility, ITEM_VALUE_TYPE_UINT64, 'units');
    zbx_subarray_push($valueTypeVisibility, ITEM_VALUE_TYPE_UINT64, 'row_units');
    $mltpbox = array();
    if (isset($limited)) {
        $frmItem->addVar('multiplier', $multiplier);
        $mcb = new CCheckBox('multiplier', $multiplier == 1 ? 'yes' : 'no');
        $mcb->setAttribute('disabled', 'disabled');
        $mltpbox[] = $mcb;
        if ($multiplier) {
            $mltpbox[] = SPACE;
            $ctb = new CTextBox('formula', $formula, 10, 1);
            $ctb->setAttribute('style', 'text-align: right;');
            $mltpbox[] = $ctb;
        } else {
            $frmItem->addVar('formula', $formula);
        }
    } else {
        $mltpbox[] = new CCheckBox('multiplier', $multiplier == 1 ? 'yes' : 'no', 'var editbx = document.getElementById(\'formula\'); if(editbx) editbx.disabled = !this.checked;', 1);
        $mltpbox[] = SPACE;
        $ctb = new CTextBox('formula', $formula, 10);
        $ctb->setAttribute('style', 'text-align: right;');
        $mltpbox[] = $ctb;
    }
    $row = new CRow(array(new CCol(S_USE_CUSTOM_MULTIPLIER, 'form_row_l'), new CCol($mltpbox, 'form_row_r')));
    $row->setAttribute('id', 'row_multiplier');
    $frmItem->addRow($row);
    zbx_subarray_push($valueTypeVisibility, ITEM_VALUE_TYPE_FLOAT, 'multiplier');
    zbx_subarray_push($valueTypeVisibility, ITEM_VALUE_TYPE_FLOAT, 'row_multiplier');
    zbx_subarray_push($valueTypeVisibility, ITEM_VALUE_TYPE_UINT64, 'multiplier');
    zbx_subarray_push($valueTypeVisibility, ITEM_VALUE_TYPE_UINT64, 'row_multiplier');
    $row = new CRow(array(new CCol(S_UPDATE_INTERVAL_IN_SEC, 'form_row_l'), new CCol(new CNumericBox('delay', $delay, 5), 'form_row_r')));
    $row->setAttribute('id', 'row_delay');
    $frmItem->addRow($row);
    foreach ($types as $it => $ilabel) {
        if ($it == ITEM_TYPE_TRAPPER) {
            continue;
        }
        zbx_subarray_push($typeVisibility, $it, 'delay');
        zbx_subarray_push($typeVisibility, $it, 'row_delay');
    }
    $row = new CRow(array(new CCol(S_FLEXIBLE_INTERVALS, 'form_row_l'), new CCol($delay_flex_el, 'form_row_r')));
    $row->setAttribute('id', 'row_flex_intervals');
    $frmItem->addRow($row);
    $row = new CRow(array(new CCol(S_NEW_FLEXIBLE_INTERVAL, 'form_row_l'), new CCol(array(S_DELAY, SPACE, new CNumericBox('new_delay_flex[delay]', '50', 5), S_PERIOD, SPACE, new CTextBox('new_delay_flex[period]', '1-7,00:00-23:59', 27), BR(), new CButton('add_delay_flex', S_ADD)), 'form_row_r')), 'new');
    $row->setAttribute('id', 'row_new_delay_flex');
    $frmItem->addRow($row);
    foreach ($types as $it => $ilabel) {
        if ($it == ITEM_TYPE_TRAPPER || $it == ITEM_TYPE_ZABBIX_ACTIVE) {
            continue;
        }
        zbx_subarray_push($typeVisibility, $it, 'row_flex_intervals');
        zbx_subarray_push($typeVisibility, $it, 'row_new_delay_flex');
        zbx_subarray_push($typeVisibility, $it, 'new_delay_flex[delay]');
        zbx_subarray_push($typeVisibility, $it, 'new_delay_flex[period]');
        zbx_subarray_push($typeVisibility, $it, 'add_delay_flex');
    }
    $frmItem->addRow(S_KEEP_HISTORY_IN_DAYS, array(new CNumericBox('history', $history, 8), !isset($_REQUEST['itemid']) ? null : new CButtonQMessage('del_history', S_CLEAR_HISTORY, S_HISTORY_CLEARING_CAN_TAKE_A_LONG_TIME_CONTINUE_Q)));
    $row = new CRow(array(new CCol(S_KEEP_TRENDS_IN_DAYS, 'form_row_l'), new CCol(new CNumericBox('trends', $trends, 8), 'form_row_r')));
    $row->setAttribute('id', 'row_trends');
    $frmItem->addRow($row);
    zbx_subarray_push($valueTypeVisibility, ITEM_VALUE_TYPE_FLOAT, 'trends');
    zbx_subarray_push($valueTypeVisibility, ITEM_VALUE_TYPE_FLOAT, 'row_trends');
    zbx_subarray_push($valueTypeVisibility, ITEM_VALUE_TYPE_UINT64, 'trends');
    zbx_subarray_push($valueTypeVisibility, ITEM_VALUE_TYPE_UINT64, 'row_trends');
    $cmbStatus = new CComboBox('status', $status);
    foreach (array(ITEM_STATUS_ACTIVE, ITEM_STATUS_DISABLED, ITEM_STATUS_NOTSUPPORTED) as $st) {
        $cmbStatus->addItem($st, item_status2str($st));
    }
    $frmItem->addRow(S_STATUS, $cmbStatus);
    $row = new CRow(array(new CCol(S_LOG_TIME_FORMAT, 'form_row_l'), new CCol(new CTextBox('logtimefmt', $logtimefmt, 16, $limited), 'form_row_r')));
    $row->setAttribute('id', 'row_logtimefmt');
    $frmItem->addRow($row);
    zbx_subarray_push($valueTypeVisibility, ITEM_VALUE_TYPE_LOG, 'logtimefmt');
    zbx_subarray_push($valueTypeVisibility, ITEM_VALUE_TYPE_LOG, 'row_logtimefmt');
    $cmbDelta = new CComboBox('delta', $delta);
    $cmbDelta->addItem(0, S_AS_IS);
    $cmbDelta->addItem(1, S_DELTA_SPEED_PER_SECOND);
    $cmbDelta->addItem(2, S_DELTA_SIMPLE_CHANGE);
    $row = new CRow(array(new CCol(S_STORE_VALUE, 'form_row_l'), new CCol($cmbDelta, 'form_row_r')));
    $row->setAttribute('id', 'row_delta');
    $frmItem->addRow($row);
    zbx_subarray_push($valueTypeVisibility, ITEM_VALUE_TYPE_FLOAT, 'delta');
    zbx_subarray_push($valueTypeVisibility, ITEM_VALUE_TYPE_FLOAT, 'row_delta');
    zbx_subarray_push($valueTypeVisibility, ITEM_VALUE_TYPE_UINT64, 'delta');
    zbx_subarray_push($valueTypeVisibility, ITEM_VALUE_TYPE_UINT64, 'row_delta');
    if (isset($limited)) {
        $frmItem->addVar('valuemapid', $valuemapid);
        $map_name = S_AS_IS;
        if ($map_data = DBfetch(DBselect('SELECT name FROM valuemaps WHERE valuemapid=' . $valuemapid))) {
            $map_name = $map_data['name'];
        }
        $cmbMap = new CTextBox('valuemap_name', $map_name, 20, 'yes');
    } else {
        $cmbMap = new CComboBox('valuemapid', $valuemapid);
        $cmbMap->addItem(0, S_AS_IS);
        $db_valuemaps = DBselect('SELECT * FROM valuemaps WHERE ' . DBin_node('valuemapid'));
        while ($db_valuemap = DBfetch($db_valuemaps)) {
            $cmbMap->addItem($db_valuemap['valuemapid'], get_node_name_by_elid($db_valuemap['valuemapid'], null, ': ') . $db_valuemap['name']);
        }
    }
    $link = new CLink(S_SHOW_VALUE_MAPPINGS, 'config.php?config=6');
    $link->setAttribute('target', '_blank');
    $row = new CRow(array(new CCol(S_SHOW_VALUE), new CCol(array($cmbMap, SPACE, $link))));
    $row->setAttribute('id', 'row_valuemap');
    $frmItem->addRow($row);
    zbx_subarray_push($valueTypeVisibility, ITEM_VALUE_TYPE_FLOAT, 'valuemapid');
    zbx_subarray_push($valueTypeVisibility, ITEM_VALUE_TYPE_FLOAT, 'row_valuemap');
    zbx_subarray_push($valueTypeVisibility, ITEM_VALUE_TYPE_FLOAT, 'valuemap_name');
    zbx_subarray_push($valueTypeVisibility, ITEM_VALUE_TYPE_UINT64, 'valuemapid');
    zbx_subarray_push($valueTypeVisibility, ITEM_VALUE_TYPE_UINT64, 'row_valuemap');
    zbx_subarray_push($valueTypeVisibility, ITEM_VALUE_TYPE_UINT64, 'valuemap_name');
    $row = new CRow(array(new CCol(S_ALLOWED_HOSTS, 'form_row_l'), new CCol(new CTextBox('trapper_hosts', $trapper_hosts, 40), 'form_row_r')));
    $row->setAttribute('id', 'row_trapper_hosts');
    $frmItem->addRow($row);
    zbx_subarray_push($typeVisibility, ITEM_TYPE_TRAPPER, 'trapper_hosts');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_TRAPPER, 'row_trapper_hosts');
    $new_app = new CTextBox('new_application', $new_application, 40);
    $frmItem->addRow(S_NEW_APPLICATION, $new_app, 'new');
    $cmbApps = new CListBox('applications[]', $applications, 6);
    $cmbApps->addItem(0, '-' . S_NONE . '-');
    $sql = 'SELECT DISTINCT applicationid,name ' . ' FROM applications ' . ' WHERE hostid=' . $hostid . ' ORDER BY name';
    $db_applications = DBselect($sql);
    while ($db_app = DBfetch($db_applications)) {
        $cmbApps->addItem($db_app['applicationid'], $db_app['name']);
    }
    $frmItem->addRow(S_APPLICATIONS, $cmbApps);
    $frmRow = array(new CButton('save', S_SAVE));
    if (isset($_REQUEST['itemid'])) {
        array_push($frmRow, SPACE, new CButton('clone', S_CLONE));
        if (!isset($limited)) {
            array_push($frmRow, SPACE, new CButtonDelete(S_DELETE_SELECTED_ITEM_Q, url_param('form') . url_param('groupid') . url_param('itemid')));
        }
    }
    array_push($frmRow, SPACE, new CButtonCancel(url_param('groupid')));
    $frmItem->addSpanRow($frmRow, 'form_row_last');
    // GROUP OPERATIONS
    $cmbGroups = new CComboBox('add_groupid', $add_groupid);
    $groups = CHostGroup::get(array('editable' => 1, 'output' => API_OUTPUT_EXTEND));
    order_result($groups, 'name');
    foreach ($groups as $group) {
        $cmbGroups->addItem($group['groupid'], get_node_name_by_elid($group['groupid'], null, ': ') . $group['name']);
    }
    $frmItem->addRow(S_GROUP, $cmbGroups);
    $cmbAction = new CComboBox('action');
    $cmbAction->addItem('add to group', S_ADD_TO_GROUP);
    if (isset($_REQUEST['itemid'])) {
        $cmbAction->addItem('update in group', S_UPDATE_IN_GROUP);
        $cmbAction->addItem('delete FROM group', S_DELETE_FROM_GROUP);
    }
    $frmItem->addItemToBottomRow(array($cmbAction, SPACE, new CButton('register', S_DO)));
    $json = new CJSON();
    zbx_add_post_js("var valueTypeSwitcher = new CViewSwitcher('value_type', 'change', " . zbx_jsvalue($valueTypeVisibility, true) . ");");
    zbx_add_post_js("var authTypeSwitcher = new CViewSwitcher('authtype', 'change', " . zbx_jsvalue($authTypeVisibility, true) . ");");
    zbx_add_post_js("var typeSwitcher = new CViewSwitcher('type', 'change', " . zbx_jsvalue($typeVisibility, true) . (isset($_REQUEST['itemid']) ? ', true' : '') . ');');
    zbx_add_post_js("var securityLevelSwitcher = new CViewSwitcher('snmpv3_securitylevel', 'change', " . zbx_jsvalue($securityLevelVisibility, true) . ");");
    zbx_add_post_js("var multpStat = document.getElementById('multiplier'); if(multpStat && multpStat.onclick) multpStat.onclick();");
    zbx_add_post_js("var mnFrmTbl = document.getElementById('web.items.item.php'); if(mnFrmTbl) mnFrmTbl.style.visibility = 'visible';");
    return $frmItem;
}
    $valueMapsComboBox->addItem($valuemap['valuemapid'], get_node_name_by_elid($valuemap['valuemapid'], null, ': ') . $valuemap['name']);
}
$valueMapLink = new CLink(_('show value mappings'), 'adm.valuemapping.php');
$valueMapLink->setAttribute('target', '_blank');
$itemFormList->addRow(array(_('Show value'), SPACE, new CVisibilityBox('valuemapid_visible', get_request('valuemapid_visible'), 'valuemap', _('Original'))), new CDiv(array($valueMapsComboBox, SPACE, $valueMapLink), null, 'valuemap'));
// append trapper hosts to form list
$itemFormList->addRow(array(_('Allowed hosts'), SPACE, new CVisibilityBox('trapper_hosts_visible', get_request('trapper_hosts_visible'), 'trapper_hosts', _('Original'))), new CTextBox('trapper_hosts', $this->data['trapper_hosts'], ZBX_TEXTBOX_STANDARD_SIZE));
// append applications to form list
if (!$this->data['is_multiple_hosts']) {
    $applicationsComboBox = new CListBox('applications[]', $this->data['applications'], 6);
    $applicationsComboBox->addItem(0, '-' . _('None') . '-');
    if (!empty($this->data['db_applications'])) {
        foreach ($this->data['db_applications'] as $application) {
            $applicationsComboBox->addItem($application['applicationid'], $application['name']);
        }
    }
    $itemFormList->addRow(array(_('Applications'), SPACE, new CVisibilityBox('applications_visible', get_request('applications_visible'), 'applications_', _('Original'))), $applicationsComboBox);
}
// append description to form list
$descriptionTextArea = new CTextArea('description', $this->data['description']);
$descriptionTextArea->addStyle('margin-top: 5px;');
$itemFormList->addRow(array(_('Description'), SPACE, new CVisibilityBox('description_visible', get_request('description_visible'), 'description', _('Original'))), $descriptionTextArea);
// append tabs to form
$itemTab = new CTabView();
$itemTab->addTab('itemTab', _('Mass update'), $itemFormList);
$itemForm->addItem($itemTab);
// append buttons to form
$itemForm->addItem(makeFormFooter(new CSubmit('update', _('Update')), new CButtonCancel(url_param('groupid') . url_param('hostid') . url_param('config'))));
$itemWidget->addItem($itemForm);
require_once dirname(__FILE__) . '/js/configuration.item.edit.js.php';
return $itemWidget;