forked from Business/BinStack
Prevent adding item if there are no categories or locations (Close #4)
This commit is contained in:
parent
4ee1992d5a
commit
e6745e693b
@ -86,5 +86,6 @@ define("STRINGS", [
|
|||||||
"only showing understocked" => "Only showing understocked items.",
|
"only showing understocked" => "Only showing understocked items.",
|
||||||
"show all items" => "Show all items",
|
"show all items" => "Show all items",
|
||||||
"missing name" => "You need to enter a name.",
|
"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" => [
|
"use_the_drop_luke" => [
|
||||||
"string" => "use the dropdowns",
|
"string" => "use the dropdowns",
|
||||||
"type" => "danger"
|
"type" => "danger"
|
||||||
|
],
|
||||||
|
"noloccat" => [
|
||||||
|
"string" => "make categories and locations",
|
||||||
|
"type" => "info"
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
|
@ -5,6 +5,11 @@ require_once __DIR__ . "/../lib/userinfo.php";
|
|||||||
|
|
||||||
redirectifnotloggedin();
|
redirectifnotloggedin();
|
||||||
|
|
||||||
|
if ($database->count("locations") == 0 || $database->count("categories") == 0) {
|
||||||
|
header('Location: app.php?page=items&msg=noloccat');
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
$itemdata = [
|
$itemdata = [
|
||||||
'name' => '',
|
'name' => '',
|
||||||
'catid' => '',
|
'catid' => '',
|
||||||
@ -55,6 +60,7 @@ if (!is_empty($VARS['id'])) {
|
|||||||
} else {
|
} else {
|
||||||
// item id is invalid, redirect to a page that won't cause an error when pressing Save
|
// item id is invalid, redirect to a page that won't cause an error when pressing Save
|
||||||
header('Location: app.php?page=edititem');
|
header('Location: app.php?page=edititem');
|
||||||
|
die();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user