Example #1
0
if (!isset($_REQUEST["id"])) {
    $_REQUEST["id"] = "";
}
if (!isset($_REQUEST["softwares_id"])) {
    $_REQUEST["softwares_id"] = "";
}
if (!isset($_REQUEST["withtemplate"])) {
    $_REQUEST["withtemplate"] = "";
}
$license = new SoftwareLicense();
if (isset($_POST["add"])) {
    $license->check(-1, CREATE, $_POST);
    if ($newID = $license->add($_POST)) {
        Event::log($_POST['softwares_id'], "software", 4, "inventory", sprintf(__('%1$s adds the license %2$s'), $_SESSION["glpiname"], $newID));
        if ($_SESSION['glpibackcreated']) {
            Html::redirect($license->getFormURL() . "?id=" . $newID);
        }
    }
    Html::back();
} else {
    if (isset($_POST["restore"])) {
        $license->check($_POST['id'], DELETE);
        if ($license->restore($_POST)) {
            Event::log($_POST["id"], "software", 4, "inventory", sprintf(__('%s restores an item'), $_SESSION["glpiname"]));
        }
        $license->redirectToList();
    } else {
        if (isset($_POST["delete"])) {
            $license->check($_POST['id'], DELETE);
            $license->delete($_POST, 0);
            Event::log($license->fields['softwares_id'], "software", 4, "inventory", sprintf(__('%1$s deletes the license %2$s'), $_SESSION["glpiname"], $_POST["id"]));