diff options
-rwxr-xr-x | mat | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -11,13 +11,15 @@ use GD; use GD::Barcode; use GD::Barcode::QRcode; use Text::Iconv; +use utf8; +binmode(STDOUT, 'utf8:'); tie my %Config, "Config::Simple", '/etc/mat.conf'; #use Data::Dumper; my $db = DBI->connect($Config{'database'}, "", "", {RaiseError => 1, - AutoCommit => 1}); + AutoCommit => 1, sqlite_unicode => 1}); my @recipes; my @ingredients; @@ -772,6 +774,7 @@ sub cmd_shoppinglist { # $shop{shop_position} = $shop{unit} = $$contents{$content}{unit}; $shop{ingredient} = @$ingredientcol[0]; + $shop{recipe}[0] = $recipe; push @shop_ingredients, \%shop; } } @@ -781,6 +784,7 @@ sub cmd_shoppinglist { { if (exists($squeezed_ingredients[-1]) and $squeezed_ingredients[-1]{ingredient} eq $squeeze->{ingredient} and $squeezed_ingredients[-1]{unit} eq $squeeze->{unit}) { $squeezed_ingredients[-1]{quantity} += $squeeze->{quantity}; + push @{$squeezed_ingredients[-1]{recipe}}, $squeeze->{recipe}[0] unless grep(/$squeeze->{recipe}[0]/, @{$squeezed_ingredients[-1]{recipe}}); } else { push @squeezed_ingredients, $squeeze; } @@ -788,7 +792,11 @@ sub cmd_shoppinglist { # for my $shop ( @sorted_ingredients ) for my $shop ( @squeezed_ingredients ) { - printf "%4s %-8s %s\n", $shop->{quantity}, $shop->{unit}, $shop->{ingredient}; + printf "%4s %-8s %-40s", $shop->{quantity}, $shop->{unit}, $shop->{ingredient}; + for ( @{$shop->{recipe}} ) { + print get_recipe_name($_), ", "; + } + print "\n"; } return 1; } |