summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcos <cos>2012-05-12 15:51:18 +0200
committercos <cos>2012-12-17 21:12:06 +0100
commit35a096df3dde0dacdcb83a8b3972776e7c7d76fb (patch)
tree0df5ca130c6a5f50f1f65a7eea50e9331e65c893
parent897a56e53f7c815c8a67bce632a8107aae0ec21c (diff)
downloadmat-35a096df3dde0dacdcb83a8b3972776e7c7d76fb.zip
Added printing of mealtype in showplan.
-rwxr-xr-xmat10
1 files 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]);
}