summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcos <cos>2015-02-05 21:01:33 +0100
committercos <cos>2015-02-05 21:01:33 +0100
commit80e18fc5ac7e7dcac500f292f886ef9195dc9341 (patch)
tree070c7827225ef62836d4514643640dd9d2eecf42
parent606682c3415b6546d688f9aa5a4fed6546b46f12 (diff)
downloadmat-80e18fc5ac7e7dcac500f292f886ef9195dc9341.zip
Add unsetting planned entries.
-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);