NetworkEquipment::showForm PHP Method

showForm() public method

Print the networking form
public showForm ( $ID, $options = [] ) : boolean
$ID integer ID of the item
$options array - target filename : where to go when done. - withtemplate boolean : template or basic item
return boolean item found
    function showForm($ID, $options = array())
    {
        $this->initForm($ID, $options);
        $this->showFormHeader($options);
        echo "<tr class='tab_bg_1'>";
        //TRANS: %1$s is a string, %2$s a second one without spaces between them : to change for RTL
        echo "<td>" . sprintf(__('%1$s%2$s'), __('Name'), isset($options['withtemplate']) && $options['withtemplate'] ? "*" : "") . "</td>";
        echo "<td>";
        $objectName = autoName($this->fields["name"], "name", isset($options['withtemplate']) && $options['withtemplate'] == 2, $this->getType(), $this->fields["entities_id"]);
        Html::autocompletionTextField($this, "name", array('value' => $objectName));
        echo "</td>";
        echo "<td>" . __('Status') . "</td>";
        echo "<td>";
        State::dropdown(array('value' => $this->fields["states_id"], 'entity' => $this->fields["entities_id"], 'condition' => "`is_visible_networkequipment`"));
        echo "</td></tr>";
        echo "<tr class='tab_bg_1'>";
        echo "<td>" . __('Location') . "</td>";
        echo "<td>";
        Location::dropdown(array('value' => $this->fields["locations_id"], 'entity' => $this->fields["entities_id"]));
        echo "</td>";
        echo "<td>" . __('Type') . "</td>";
        echo "<td>";
        NetworkEquipmentType::dropdown(array('value' => $this->fields["networkequipmenttypes_id"]));
        echo "</td></tr>";
        echo "<tr class='tab_bg_1'>";
        echo "<td>" . __('Technician in charge of the hardware') . "</td>";
        echo "<td>";
        User::dropdown(array('name' => 'users_id_tech', 'value' => $this->fields["users_id_tech"], 'right' => 'own_ticket', 'entity' => $this->fields["entities_id"]));
        echo "</td>";
        echo "<td>" . __('Manufacturer') . "</td>";
        echo "<td>";
        Manufacturer::dropdown(array('value' => $this->fields["manufacturers_id"]));
        echo "</td></tr>";
        echo "<tr class='tab_bg_1'>";
        echo "<td>" . __('Group in charge of the hardware') . "</td>";
        echo "<td>";
        Group::dropdown(array('name' => 'groups_id_tech', 'value' => $this->fields['groups_id_tech'], 'entity' => $this->fields['entities_id'], 'condition' => '`is_assign`'));
        echo "</td>";
        echo "<td>" . __('Model') . "</td>";
        echo "<td>";
        NetworkEquipmentModel::dropdown(array('value' => $this->fields["networkequipmentmodels_id"]));
        echo "</td></tr>";
        echo "<tr class='tab_bg_1'>";
        echo "<td>" . __('Alternate username number') . "</td>";
        echo "<td>";
        Html::autocompletionTextField($this, "contact_num");
        echo "</td>";
        echo "<td>" . __('Serial number') . "</td>";
        echo "<td>";
        Html::autocompletionTextField($this, "serial");
        echo "</td></tr>";
        echo "<tr class='tab_bg_1'>";
        echo "<td>" . __('Alternate username') . "</td>";
        echo "<td>";
        Html::autocompletionTextField($this, "contact");
        echo "</td>";
        echo "<td>" . sprintf(__('%1$s%2$s'), __('Inventory number'), isset($options['withtemplate']) && $options['withtemplate'] ? "*" : "") . "</td>";
        echo "<td>";
        $objectName = autoName($this->fields["otherserial"], "otherserial", isset($options['withtemplate']) && $options['withtemplate'] == 2, $this->getType(), $this->fields["entities_id"]);
        Html::autocompletionTextField($this, "otherserial", array('value' => $objectName));
        echo "</td></tr>";
        echo "<tr class='tab_bg_1'>";
        echo "<td>" . __('User') . "</td>";
        echo "<td>";
        User::dropdown(array('value' => $this->fields["users_id"], 'entity' => $this->fields["entities_id"], 'right' => 'all'));
        echo "</td>";
        echo "<td>" . __('Network') . "</td>";
        echo "<td>";
        Network::dropdown(array('value' => $this->fields["networks_id"]));
        echo "</td></tr>";
        $rowspan = 5;
        echo "<tr class='tab_bg_1'>";
        echo "<td>" . __('Group') . "</td>";
        echo "<td>";
        Group::dropdown(array('value' => $this->fields["groups_id"], 'entity' => $this->fields["entities_id"], 'condition' => '`is_itemgroup`'));
        echo "</td>";
        echo "<td rowspan='{$rowspan}'>" . __('Comments') . "</td>";
        echo "<td rowspan='{$rowspan}'>\n            <textarea cols='45' rows='" . ($rowspan + 3) . "' name='comment' >" . $this->fields["comment"];
        echo "</textarea></td></tr>";
        echo "<tr class='tab_bg_1'>";
        echo "<td>" . __('Domain') . "</td>";
        echo "<td>";
        Domain::dropdown(array('value' => $this->fields["domains_id"], 'entity' => $this->fields["entities_id"]));
        echo "</td></tr>";
        echo "<tr class='tab_bg_1'>";
        echo "<td colspan=2>" . __('The MAC address and the IP of the equipment are included in an aggregated network port') . "</td>";
        echo "</tr>\n";
        echo "<tr class='tab_bg_1'>";
        echo "<td>" . _n('Firmware', 'Firmwares', 1) . "</td>";
        echo "<td>";
        NetworkEquipmentFirmware::dropdown(array('value' => $this->fields["networkequipmentfirmwares_id"]));
        echo "</td>";
        echo "</tr>";
        echo "<tr class='tab_bg_1'>";
        echo "<td>" . sprintf(__('%1$s (%2$s)'), __('Memory'), __('Mio')) . "</td>";
        echo "<td>";
        Html::autocompletionTextField($this, "ram");
        echo "</td></tr>";
        // Display auto inventory informations
        if (!empty($ID) && $this->fields["is_dynamic"]) {
            echo "<tr class='tab_bg_1'><td colspan='4'>";
            Plugin::doHook("autoinventory_information", $this);
            echo "</td></tr>";
        }
        $this->showFormButtons($options);
        return true;
    }

Usage Example

        $netdevice->check($_POST["id"], 'd');
        $netdevice->delete($_POST);
        Event::log($_POST["id"], "networkequipment", 4, "inventory", sprintf(__('%s deletes an item'), $_SESSION["glpiname"]));
        $netdevice->redirectToList();
    } else {
        if (isset($_POST["restore"])) {
            $netdevice->check($_POST["id"], 'd');
            $netdevice->restore($_POST);
            Event::log($_POST["id"], "networkequipment", 4, "inventory", sprintf(__('%s restores an item'), $_SESSION["glpiname"]));
            $netdevice->redirectToList();
        } else {
            if (isset($_POST["purge"])) {
                $netdevice->check($_POST["id"], 'd');
                $netdevice->delete($_POST, 1);
                Event::log($_POST["id"], "networkequipment", 4, "inventory", sprintf(__('%s purges an item'), $_SESSION["glpiname"]));
                $netdevice->redirectToList();
            } else {
                if (isset($_POST["update"])) {
                    $netdevice->check($_POST["id"], 'w');
                    $netdevice->update($_POST);
                    Event::log($_POST["id"], "networkequipment", 4, "inventory", sprintf(__('%s updates an item'), $_SESSION["glpiname"]));
                    Html::back();
                } else {
                    Html::header(NetworkEquipment::getTypeName(2), $_SERVER['PHP_SELF'], "inventory", "networking");
                    $netdevice->showForm($_GET["id"], array('withtemplate' => $_GET["withtemplate"]));
                    Html::footer();
                }
            }
        }
    }
}