summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xmat8
1 files changed, 4 insertions, 4 deletions
diff --git a/mat b/mat
index ca80721..2c7c0f5 100755
--- a/mat
+++ b/mat
@@ -146,10 +146,10 @@ sub cmd_setmeal {
return unless $mealtype =~ "^(frukost)|(elvakaffe)|(lunch)|(fruktstund)|(middag)\$";
return unless $date =~ "^[0-9]{4}-[0-9]{2}-[0-9]{2}\$";
- return -1 unless $recipe_id =~ "^[0-9]+\$";
- if (get_recipe_name($recipe_id) ne 'NULL') {
- my $sql = "DELETE FROM plan WHERE date='$date' and mealtype='$mealtype';";
- $db->do($sql);
+ return -1 unless $recipe_id =~ m/^[0-9]+$|^-$/;
+ my $sql = "DELETE FROM plan WHERE date='$date' and mealtype='$mealtype';";
+ $db->do($sql);
+ if ($recipe_id ne '-' && get_recipe_name($recipe_id) ne 'NULL') {
$sql = "INSERT INTO plan (date, mealtype, recipe_id) VALUES ('$date',
'$mealtype', $recipe_id);";
$db->do($sql);