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