Example #1
0
 /**
  * Print the network name form
  *
  * @param $ID        integer ID of the item
  * @param $options   array
  *     - target for the Form
  *     - withtemplate template or basic computer
  *
  *@return Nothing (display)
  **/
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI;
     $this->initForm($ID, $options);
     $recursiveItems = $this->recursivelyGetItems();
     if (count($recursiveItems) != 0) {
         $lastItem = $recursiveItems[count($recursiveItems) - 1];
         $options['entities_id'] = $lastItem->getField('entities_id');
     }
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'><td>";
     if (count($recursiveItems) > 0) {
         $this->displayRecursiveItems($recursiveItems, 'Type');
     }
     echo "</td>\n<td colspan='3'>";
     if (!($ID > 0)) {
         echo "<input type='hidden' name='items_id' value='" . $this->fields["items_id"] . "'>\n";
         echo "<input type='hidden' name='itemtype' value='" . $this->fields["itemtype"] . "'>\n";
     }
     $this->displayRecursiveItems($recursiveItems, "Link");
     if (count($recursiveItems) > 0 && $this->canUpdate()) {
         Html::showSimpleForm($this->getFormURL(), 'unaffect', _sx('button', 'Dissociate'), array('id' => $ID));
     }
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Name') . "</td><td>\n";
     Html::autocompletionTextField($this, "name");
     echo "</td>\n";
     echo "<td>" . FQDN::getTypeName(1) . "</td><td>";
     Dropdown::show(getItemTypeForTable(getTableNameForForeignKeyField("fqdns_id")), array('value' => $this->fields["fqdns_id"], 'name' => 'fqdns_id', 'entity' => $this->getEntityID(), 'displaywith' => array('view')));
     echo "</td>\n</tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . IPAddress::getTypeName(Session::getPluralNumber());
     IPAddress::showAddChildButtonForItemForm($this, '_ipaddresses');
     echo "</td>";
     echo "<td>";
     IPAddress::showChildsForItemForm($this, '_ipaddresses');
     echo "</td>\n";
     echo "<td rowspan='3'>" . __('Comments') . "</td>";
     echo "<td rowspan='3'><textarea cols='45' rows='4' name='comment' >" . $this->fields["comment"];
     echo "</textarea></td>\n";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . IPNetwork::getTypeName(Session::getPluralNumber()) . "</td><td>";
     _e('IP network is not included in the database. However, you can see current available networks.');
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td>&nbsp;</td><td>";
     IPNetwork::showIPNetworkProperties($this->getEntityID());
     echo "</td></tr>\n";
     $this->showFormButtons($options);
     return true;
 }