function showFormItemtype($p_itemtype) { $can = 0; $typeright = strtolower($p_itemtype); if ($typeright == "networkequipment") { $typeright = "networking"; } if (Session::haveRight($typeright, UPDATE)) { $can = 1; } $tableName = getTableForItemType($p_itemtype); echo "<div width='50%'>"; $locked = PluginFusioninventoryLock::getLockFields($tableName, 0); if (!count($locked)) { $locked = array(); } $colspan = '2'; $item = new $p_itemtype(); $item->getEmpty(); echo "<form method='post' action='" . PluginFusioninventoryLock::getFormURL() . "'>"; echo "<input type='hidden' name='id' value='0'>"; echo "<input type='hidden' name='type' value='{$p_itemtype}'>"; echo "<table class='tab_cadre'>"; echo "<tr>"; echo "<th colspan='2'>" . $item->getTypeName(1) . "</th>"; echo "</tr>"; echo "<tr><th> " . __('Fields') . " </th>"; echo "<th> " . _n('Lock', 'Locks', 2, 'fusioninventory') . " </th>"; echo "</tr>"; $checked = false; $a_exclude = $this->excludeFields(); $serialized = $this->getSerialized_InventoryArray($p_itemtype, 0); $options = search::getOptions($p_itemtype); foreach ($item->fields as $key => $val) { $name = ""; $key_source = $key; if (!in_array($key, $a_exclude)) { if (in_array($key, $locked)) { $checked = true; } else { $checked = false; } // Get name of field $num = Search::getOptionNumber($p_itemtype, $key); if (isset($options[$num]['name'])) { $name = $options[$num]['name']; } else { //Get name by search in linkfields foreach ($options as $opt) { if (isset($opt['linkfield']) && $opt['linkfield'] == $key) { $name = $opt['name']; break; } } } $css_glpi_value = ''; // Get value of field $val = $this->getValueForKey($val, $key); echo "<tr class='tab_bg_1'>"; $table = getTableNameForForeignKeyField($key); if ($name == "" && $table != "") { $linkItemtype = getItemTypeForTable($table); $class = new $linkItemtype(); $name = $class->getTypeName(); } echo "<td>" . $name . "</td>"; echo "<td align='center'>"; Html::showCheckbox(array('name' => "lockfield_fusioninventory[{$key_source}]", 'checked' => $checked)); echo "</td>"; echo "</tr>"; } } if ($can == '1') { echo "<tr class='tab_bg_2'>"; echo "<td align='center' colspan='" . ($colspan + 1) . "'>"; echo "<input class='submit' type='submit' name='unlock_field_fusioninventory'\n value='" . __('Update') . "'>"; echo "</td>"; echo "</tr>"; } echo "</table>"; Html::closeForm(); echo "</div>"; }