diff options
author | cos <cos> | 2015-01-25 23:04:48 +0100 |
---|---|---|
committer | cos <cos> | 2015-01-25 23:04:48 +0100 |
commit | 84e3857e881a8f3e665df837e6c8d3c06fe61b7b (patch) | |
tree | 50cf8cf1a03c861bbdef9f49440ecf9cb70b1a51 | |
parent | 6a2878a7ddbb4fc6522d694af62e1743da0c872f (diff) | |
download | mat-84e3857e881a8f3e665df837e6c8d3c06fe61b7b.zip |
Initial implementation of cmd_reprintlabel.
-rwxr-xr-x | mat | 24 |
1 files changed, 21 insertions, 3 deletions
@@ -267,7 +267,7 @@ sub cmd_postpone { } sub print_label { - my ( $id, $dish_name, $amount ) = @_; + my ( $id, $dish_name, $amount, $preparation_date ) = @_; my $fontname = "/usr/share/fonts/truetype/freefont/FreeSans.ttf"; my $fontsize = 15; @@ -293,7 +293,7 @@ sub print_label { $row1 =~ s/(.{15,23}) .*/$1/; $row2 = substr($latin1_dish, (length $row1) + 1); } - my $row3 = `date +%Y%m%d|tr -d '\n'`.' ('.$amount.'g)'; + my $row3 = $preparation_date.' ('.$amount.'g)'; my $idbarcode = GD::Barcode::QRcode->new(sprintf("%s%d", $Config{'label_id_prefix'}, $id), { Version=>3 }); my $idbarcode_image=$idbarcode->plot(); @@ -385,7 +385,22 @@ sub cmd_storeportion { $db->do($sql); my $inventory_id = $db->last_insert_id(undef, undef, undef, undef); - print_label($inventory_id, get_recipe_name($recipe_id), $amount); + print_label($inventory_id, get_recipe_name($recipe_id), $amount, + `date +%Y%m%d|tr -d '\n'`); +} + + +sub cmd_reprintlabel { + my ( $id ) = @_; + + my $sql = "SELECT recipe_id, preparation_date, amount, storage FROM inventory WHERE ". + "id=$id"; + + my $row = $db->selectrow_hashref($sql); + print_label($id, get_recipe_name($row->{'recipe_id'}), $row->{'amount'}, + $row->{'preparation_date'}); + + return 0; } sub get_plan_state { @@ -465,6 +480,7 @@ sub cmd_help() { print "showplan [date]\n"; print "postpone <date> <gap>\n"; print "storeportion <recipe_id> [amount] [storage]\n"; + print "reprintlabel <inventory_id>\n"; print "retrieveportion <portion_id> (unimplemented)\n"; print "relocate <portion_id> <new_storage>\n"; print "inventory [storage]\n"; @@ -832,6 +848,8 @@ if ($ARGV[0]) { print "Command failed!\n" unless (cmd_inventory($ARGV[1]) >= 0); } elsif ( $ARGV[0] eq "storeportion") { print "Command failed!\n" unless (cmd_storeportion($ARGV[1], $ARGV[2], $ARGV[3]) >= 0); + } elsif ( $ARGV[0] eq "reprintlabel") { + print "Command failed!\n" unless (cmd_reprintlabel($ARGV[1]) >= 0); } elsif ( $ARGV[0] eq "relocate") { print "Command failed!\n" unless (cmd_relocate($ARGV[1], $ARGV[2]) >= 0); } elsif ( $ARGV[0] eq "queueadd") { |