From 4ee1992d5a0db3e2f9d96483910e542218b172ab Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Fri, 15 Sep 2017 14:00:45 -0600 Subject: [PATCH] Close #3 --- action.php | 19 ++++++++++++++++++- lang/en_us.php | 4 +++- lang/messages.php | 8 ++++++++ pages/edititem.php | 4 ++-- 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/action.php b/action.php index 79378fd..61440b9 100644 --- a/action.php +++ b/action.php @@ -42,7 +42,24 @@ switch ($VARS['action']) { returnToSender("invalid_itemid"); } } - if (is_empty($VARS['name']) || is_empty($VARS['cat']) || is_empty($VARS['loc'])) { + if (is_empty($VARS['name'])) { + returnToSender('missing_name'); + } + if (!is_empty($VARS['catstr']) && is_empty($VARS['cat'])) { + if ($database->count("categories", ["catname" => $VARS['catstr']]) == 1) { + $VARS['cat'] = $database->get("categories", 'catid', ["catname" => $VARS['catstr']]); + } else { + returnToSender('use_the_drop_luke'); + } + } + if (!is_empty($VARS['locstr']) && is_empty($VARS['loc'])) { + if ($database->count("locations", ["locname" => $VARS['locstr']]) == 1) { + $VARS['loc'] = $database->get("locations", 'locid', ["locname" => $VARS['locstr']]); + } else { + returnToSender('use_the_drop_luke'); + } + } + if (is_empty($VARS['cat']) || is_empty($VARS['loc'])) { returnToSender('invalid_parameters'); } if (is_empty($VARS['qty'])) { diff --git a/lang/en_us.php b/lang/en_us.php index 5730f3c..d4edea5 100644 --- a/lang/en_us.php +++ b/lang/en_us.php @@ -84,5 +84,7 @@ define("STRINGS", [ "understocked items" => "Understocked Items", "view understocked" => "View Understocked", "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.", + "use the dropdowns" => "Whoops, you need to use the category and location autocomplete boxes." ]); \ No newline at end of file diff --git a/lang/messages.php b/lang/messages.php index 52ed211..840b41e 100644 --- a/lang/messages.php +++ b/lang/messages.php @@ -72,5 +72,13 @@ define("MESSAGES", [ "field_nan" => [ "string" => "field not a number", "type" => "danger" + ], + "missing_name" => [ + "string" => "missing name", + "type" => "danger" + ], + "use_the_drop_luke" => [ + "string" => "use the dropdowns", + "type" => "danger" ] ]); diff --git a/pages/edititem.php b/pages/edititem.php index e092ce3..ad012a2 100644 --- a/pages/edititem.php +++ b/pages/edititem.php @@ -86,14 +86,14 @@ if (!is_empty($VARS['id'])) {
- " value="" /> + " value="" />
- " value="" /> + " value="" />