Example #1
0
*/
include '../inc/includes.php';
Session::checkRight("printer", READ);
if (!isset($_GET["id"])) {
    $_GET["id"] = "";
}
if (!isset($_GET["withtemplate"])) {
    $_GET["withtemplate"] = "";
}
$print = new Printer();
if (isset($_POST["add"])) {
    $print->check(-1, CREATE, $_POST);
    if ($newID = $print->add($_POST)) {
        Event::log($newID, "printers", 4, "inventory", sprintf(__('%1$s adds the item %2$s'), $_SESSION["glpiname"], $_POST["name"]));
        if ($_SESSION['glpibackcreated']) {
            Html::redirect($print->getFormURL() . "?id=" . $newID);
        }
    }
    Html::back();
} else {
    if (isset($_POST["delete"])) {
        $print->check($_POST["id"], DELETE);
        $print->delete($_POST);
        Event::log($_POST["id"], "printers", 4, "inventory", sprintf(__('%s deletes an item'), $_SESSION["glpiname"]));
        $print->redirectToList();
    } else {
        if (isset($_POST["restore"])) {
            $print->check($_POST["id"], DELETE);
            $print->restore($_POST);
            Event::log($_POST["id"], "printers", 4, "inventory", sprintf(__('%s restores an item'), $_SESSION["glpiname"]));
            $print->redirectToList();