From 35a096df3dde0dacdcb83a8b3972776e7c7d76fb Mon Sep 17 00:00:00 2001 From: cos Date: Sat, 12 May 2012 15:51:18 +0200 Subject: Added printing of mealtype in showplan. --- mat | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/mat b/mat index 256b232..dcf9ca1 100755 --- a/mat +++ b/mat @@ -7,6 +7,8 @@ use DBI; use DateTime; use DateTime::Format::ISO8601; +#use Data::Dumper; + my $db = DBI->connect("dbi:SQLite:recipe.db", "", "", {RaiseError => 1, AutoCommit => 1}); @@ -221,7 +223,6 @@ sub get_plan_state { sub cmd_showplan { my ( $date ) = @_; - my $mealtype = "lunch"; my $dt; if($date) { @@ -233,11 +234,12 @@ sub cmd_showplan { } for (my $i = 0; $i < 7; $i++) { - my $sql = "SELECT recipe_id FROM plan WHERE date='".$dt->ymd(). - "' and mealtype='$mealtype';"; + my $sql = "SELECT recipe_id, mealtype FROM plan WHERE date='".$dt->ymd(). + "';"; my @ids = $db->selectrow_array($sql); + if ($ids[0]) { - printf "%9s %3s [%s] %s, %s\n", $dt->ymd(), $ids[0], + printf "%9s %-10s %3s [%s] %s, %s\n", $dt->ymd(), $ids[1], $ids[0], substr(get_plan_state($dt->ymd()), 0, 1), get_recipe_name($ids[0]), get_recipe_uri($ids[0]); } -- cgit v1.2.3