diff options
author | cos <cos> | 2015-02-05 21:01:33 +0100 |
---|---|---|
committer | cos <cos> | 2015-02-05 21:01:33 +0100 |
commit | 80e18fc5ac7e7dcac500f292f886ef9195dc9341 (patch) | |
tree | 070c7827225ef62836d4514643640dd9d2eecf42 | |
parent | 606682c3415b6546d688f9aa5a4fed6546b46f12 (diff) | |
download | mat-80e18fc5ac7e7dcac500f292f886ef9195dc9341.zip |
Add unsetting planned entries.
-rwxr-xr-x | mat | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -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); |