$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->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));
        $populatingItemCell = array(' ← ', $populatingLink);
$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
$hostForm->addItem(makeFormFooter(new CSubmit('masssave', _('Update')), new CButtonCancel(url_param('groupid'))));
$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) {
    $host_groups->addItem($group['groupid'], $group['name']);
    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;