summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcos <cos>2019-05-04 09:30:26 +0200
committercos <cos>2019-05-04 09:30:26 +0200
commitfa1a9d38a8fc6f620c9021738e687b47c12ade17 (patch)
tree5bb6ee0dac2b29776ddd5ef468575f537554a364
parenta0a24affd16c41099ce1576bd4fa38894f3ec2c5 (diff)
downloadmat-fa1a9d38a8fc6f620c9021738e687b47c12ade17.zip
Two changes:HEADmaster
Update energy content in reprintlabel if missing Show QR code of recipe url in showrecipe
-rwxr-xr-xmat50
1 files changed, 36 insertions, 14 deletions
diff --git a/mat b/mat
index e347aa5..6f52797 100755
--- a/mat
+++ b/mat
@@ -11,7 +11,7 @@ use GD;
use GD::Barcode;
use GD::Barcode::QRcode;
use Text::Iconv;
-#use Text::QRCode;
+use Text::QRCode;
use utf8;
binmode(STDOUT, 'utf8:');
@@ -661,10 +661,19 @@ sub cmd_reprintlabel {
my $row = $db->selectrow_hashref($sql);
- $sql = "SELECT proteins, carbs, fats FROM cookings WHERE recipe_id=? AND date=?;";
+ $sql = "SELECT specific_energy, proteins, carbs, fats FROM cookings WHERE recipe_id=? AND date=?;";
my $sql_date_format = $row->{preparation_date};
$sql_date_format =~ s/(....)(..)(..)/$1-$2-$3/;
my $cookings = $db->selectrow_hashref($sql, undef, $row->{recipe_id}, $sql_date_format);
+ if ( ! $row->{'energy'} ) {
+ my $updated_energy = int($cookings->{'specific_energy'}*$row->{'amount'}/100);
+ if ($cookings->{'specific_energy'}) {
+ $sql = "UPDATE inventory SET energy=".$updated_energy." WHERE id=$id;";
+ my $sth = $db->prepare($sql);
+ my $dummy = $sth->execute();
+ $row->{'energy'} = $updated_energy;
+ }
+ }
print_label($id, get_recipe_name($row->{'recipe_id'}), $row->{'amount'},
$row->{'preparation_date'}, $row->{'energy'}, $cookings->{'proteins'},
$cookings->{'carbs'}, $cookings->{'fats'});
@@ -971,24 +980,37 @@ sub cmd_showrecipe {
my $ingredient_multipler = 1;
my $debug_substitution = "no";
-# my $qrcode = Text::QRCode->new();
-# my $urlqr = $qrcode->plot(@$recipe_row[1]);
-# for ( @$urlqr ) {
-# for ( @$_ ) {
-# if ( $_ eq "*" ) {
-# print "██";
-# } else {
-# print " ";
-# }
-# }
-# print "\n";
-# }
+ if(@$recipe_row[1]) {
+ my $qrcode = Text::QRCode->new();
+ my $urlqr = $qrcode->plot(@$recipe_row[1]);
+
+ for ( @$urlqr ) {
+ print "██";
+ }
+ print "████\n";
+ for ( @$urlqr ) {
+ print "██";
+ for ( @$_ ) {
+ if ( $_ eq "*" ) {
+# print "##";
+ print " ";
+ } else {
+ print "██";
+ }
+ }
+ print "██\n";
+ }
+ for ( @$urlqr ) {
+ print "██";
+ }
+ print "████\n";
print @$recipe_row[0];
if(defined(@$recipe_row[1])) {
printf ", %s\n", @$recipe_row[1];
} else {
print "\n";
}
+ }
if(defined(@$recipe_row[2])) {
$servings = @$recipe_row[2];
if(defined($desired_servings)) {