diff options
-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); |