// Get list of models $models = Model::getSimple($db); // Get types if (feature('consumable_types')) { $types = Tag::get_by_type('consumable_type'); } include 'views/consumables/addedit.php'; } /** * Delete a consumable */ if ($action == 'delete') { // Get ID $id = fRequest::get('id', 'integer'); try { $c = new Consumable($id); if (fRequest::isPost()) { $c->delete(); fMessaging::create('success', fURL::get(), 'The consumable ' . $c->getName() . ' was successfully deleted.'); fURL::redirect(fURL::get()); } } catch (fNotFoundException $e) { fMessaging::create('error', fURL::get(), 'The consumable requested, ID ' . $id . ', could not be found.'); fURL::redirect($manage_url); } catch (fExpectedException $e) { fMessaging::create('error', fURL::get(), $e->getMessage()); } catch (fSQLException $e) { fMessaging::create('error', fURL::get(), 'Database error: ' . $e->getMessage()); } include 'views/consumables/delete.php'; }
$_GET["cID"] = ""; } $con = new Consumable(); $constype = new ConsumableItem(); if (isset($_POST["add_several"])) { $constype->check($_POST["tID"], 'w'); for ($i = 0; $i < $_POST["to_add"]; $i++) { unset($con->fields["id"]); $con->add($_POST); } Event::log($_POST["tID"], "consumables", 4, "inventory", $_SESSION["glpiname"] . " " . $LANG['log'][89] . ": " . $_POST["to_add"]); glpi_header($_SERVER['HTTP_REFERER']); } else { if (isset($_GET["delete"])) { $constype->check($_GET["tID"], 'w'); if ($con->delete($_GET)) { Event::log($_GET["tID"], "consumables", 4, "inventory", $_SESSION["glpiname"] . " " . $LANG['log'][91]); } glpi_header($_SERVER['HTTP_REFERER']); } else { if (isset($_POST["give"])) { $constype->check($_POST["tID"], 'w'); if ($_POST["users_id"] > 0) { if (isset($_POST["out"])) { foreach ($_POST["out"] as $key => $val) { $con->out($key, $_POST["users_id"]); } } Event::log($_POST["tID"], "consumables", 5, "inventory", $_SESSION["glpiname"] . " " . $LANG['log'][97] . " " . $_POST["users_id"]); } glpi_header($_SERVER['HTTP_REFERER']);