Prevent adding item if there are no categories or locations (Close #4)

master
Skylar Ittner 7 years ago
parent 4ee1992d5a
commit e6745e693b

@ -86,5 +86,6 @@ define("STRINGS", [
"only showing understocked" => "Only showing understocked items.",
"show all items" => "Show all items",
"missing name" => "You need to enter a name.",
"use the dropdowns" => "Whoops, you need to use the category and location autocomplete boxes."
"use the dropdowns" => "Whoops, you need to use the category and location autocomplete boxes.",
"make categories and locations" => "Please create at least one category and location before adding an item."
]);

@ -80,5 +80,9 @@ define("MESSAGES", [
"use_the_drop_luke" => [
"string" => "use the dropdowns",
"type" => "danger"
],
"noloccat" => [
"string" => "make categories and locations",
"type" => "info"
]
]);

@ -5,6 +5,11 @@ require_once __DIR__ . "/../lib/userinfo.php";
redirectifnotloggedin();
if ($database->count("locations") == 0 || $database->count("categories") == 0) {
header('Location: app.php?page=items&msg=noloccat');
die();
}
$itemdata = [
'name' => '',
'catid' => '',
@ -55,6 +60,7 @@ if (!is_empty($VARS['id'])) {
} else {
// item id is invalid, redirect to a page that won't cause an error when pressing Save
header('Location: app.php?page=edititem');
die();
}
}
?>

Loading…
Cancel
Save