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