ComputerDisk::showForm PHP Method

showForm() public method

Print the version form
public showForm ( $ID, $options = [] ) : true
$ID integer ID of the item
$options array - target for the Form - computers_id ID of the computer for add process
return true if displayed false if item not found or not right to display
    function showForm($ID, $options = array())
    {
        global $CFG_GLPI;
        if (!Session::haveRight("computer", UPDATE)) {
            return false;
        }
        $comp = new Computer();
        if ($ID > 0) {
            $this->check($ID, READ);
            $comp->getFromDB($this->fields['computers_id']);
        } else {
            $this->check(-1, CREATE, $options);
            $comp->getFromDB($options['computers_id']);
        }
        $this->showFormHeader($options);
        if ($this->isNewID($ID)) {
            echo "<input type='hidden' name='computers_id' value='" . $options['computers_id'] . "'>";
        }
        echo "<tr class='tab_bg_1'>";
        echo "<td>" . __('Computer') . "</td>";
        echo "<td>" . $comp->getLink() . "</td>";
        if (Plugin::haveImport()) {
            echo "<td>" . __('Automatic inventory') . "</td>";
            echo "<td>";
            if ($ID && $this->fields['is_dynamic']) {
                Plugin::doHook("autoinventory_information", $this);
            } else {
                _e('No');
            }
            echo "</td>";
        } else {
            echo "<td colspan='2'></td>";
        }
        echo "</tr>\n";
        echo "<tr class='tab_bg_1'>";
        echo "<td>" . __('Name') . "</td>";
        echo "<td>";
        Html::autocompletionTextField($this, "name");
        echo "</td><td>" . __('Partition') . "</td>";
        echo "<td>";
        Html::autocompletionTextField($this, "device");
        echo "</td></tr>";
        echo "<tr class='tab_bg_1'>";
        echo "<td>" . __('Mount point') . "</td>";
        echo "<td>";
        Html::autocompletionTextField($this, "mountpoint");
        echo "</td><td>" . __('File system') . "</td>";
        echo "<td>";
        FileSystem::dropdown(array('value' => $this->fields["filesystems_id"]));
        echo "</td></tr>";
        echo "<tr class='tab_bg_1'>";
        echo "<td>" . __('Global size') . "</td>";
        echo "<td>";
        Html::autocompletionTextField($this, "totalsize");
        echo "&nbsp;" . __('Mio') . "</td>";
        echo "<td>" . __('Free size') . "</td>";
        echo "<td>";
        Html::autocompletionTextField($this, "freesize");
        echo "&nbsp;" . __('Mio') . "</td></tr>";
        $this->showFormButtons($options);
        return true;
    }

Usage Example

コード例 #1
0
ファイル: computerdisk.form.php プロジェクト: gaforeror/glpi
}
$disk = new ComputerDisk();
if (isset($_POST["add"])) {
    $disk->check(-1, 'w', $_POST);
    if ($newID = $disk->add($_POST)) {
        Event::log($_POST['computers_id'], "computers", 4, "inventory", sprintf(__('%s adds a volume'), $_SESSION["glpiname"]));
    }
    Html::back();
} else {
    if (isset($_POST["delete"])) {
        $disk->check($_POST["id"], 'd');
        if ($disk->delete($_POST)) {
            Event::log($disk->fields['computers_id'], "computers", 4, "inventory", sprintf(__('%s deletes a volume'), $_SESSION["glpiname"]));
        }
        $computer = new Computer();
        $computer->getFromDB($disk->fields['computers_id']);
        Html::redirect(Toolbox::getItemTypeFormURL('Computer') . '?id=' . $disk->fields['computers_id'] . ($computer->fields['is_template'] ? "&withtemplate=1" : ""));
    } else {
        if (isset($_POST["update"])) {
            $disk->check($_POST["id"], 'w');
            if ($disk->update($_POST)) {
                Event::log($disk->fields['computers_id'], "computers", 4, "inventory", sprintf(__('%s updates a volume'), $_SESSION["glpiname"]));
            }
            Html::back();
        } else {
            Html::header(Computer::getTypeName(2), $_SERVER['PHP_SELF'], "inventory", "computer");
            $disk->showForm($_GET["id"], array('computers_id' => $_GET["computers_id"]));
            Html::footer();
        }
    }
}