summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xmat21
1 files changed, 15 insertions, 6 deletions
diff --git a/mat b/mat
index 4c37bc6..cb0a41f 100755
--- a/mat
+++ b/mat
@@ -8,7 +8,7 @@ use DateTime;
use DateTime::Format::ISO8601;
use GD;
use GD::Barcode;
-use GD::Barcode::EAN13;
+use GD::Barcode::QRcode;
use Text::Iconv;
use constant LABEL_NAME => `sed --silent 's/^label_name //p' < config|tr -d '\\n'`;
@@ -181,6 +181,7 @@ sub cmd_relocate {
sub cmd_inventory {
my ( $storage ) = @_;
+ my $total = 0;
my $sql = "SELECT recipe_id, count(recipe_id), storage FROM inventory";
$sql .= " WHERE storage='$storage'" if ( $storage );
@@ -188,13 +189,15 @@ sub cmd_inventory {
my $all = $db->selectall_arrayref($sql);
foreach my $row (@$all) {
+ $total += @$row[1];
printf "%3d x %s (%s)", @$row[1], get_recipe_name(@$row[0]), @$row[0];
if ( $storage ) {
print "\n";
} else {
- print @$row[2], "\n";
+ print " ", @$row[2], "\n";
}
}
+ printf "----\n%3d\n", $total;
}
sub cmd_setstate {
@@ -264,7 +267,7 @@ sub cmd_postpone {
sub print_label {
my ( $id, $dish_name, $amount ) = @_;
- my $iconv = Text::Iconv->new("UTF8", "ISO-8859-1");
+ my $iconv = Text::Iconv->new("UTF-8", "ISO8859-1");
my $row0 = `date +%Y%m%d|tr -d '\n'`.' '.LABEL_NAME;
my $row1 = $iconv->convert($dish_name).' ('.$amount.'g)';
@@ -278,9 +281,15 @@ sub print_label {
$label->fill(0, 0, $white);
- my $idbarcode = GD::Barcode::EAN13->new(sprintf("%05d%07d", LABEL_ID_PREFIX, $id));
- my $idbarcode_image=$idbarcode->plot()->copyRotate90();
- $label->copyResized($idbarcode_image, $x_border, $y_border, 0, 0, $idbarcode_image->width() * 3, $idbarcode_image->height() * 6, $idbarcode_image->width(), $idbarcode_image->height());
+ my $idbarcode = GD::Barcode::QRcode->new(sprintf("%s%d", LABEL_ID_PREFIX, $id), { Version=>3 });
+ my $idbarcode_image=$idbarcode->plot();
+ $label->copyResized($idbarcode_image, $x_border, $y_border, 0, 0, $idbarcode_image->width() * 5, $idbarcode_image->height() * 5, $idbarcode_image->width(), $idbarcode_image->height());
+ my $idtext = new GD::Image(500, gdGiantFont->height());
+ $white = $idtext->colorAllocate(255,255,255);
+ $black = $idtext->colorAllocate(0,0,0);
+ $idtext->fill(1, 1, $white);
+ $idtext->string(gdGiantFont, 0, 0, $id, $black);
+ $label->copyResized($idtext, $x_border * 2, $y_border + $idbarcode_image->height() * 5, 0, 0, $idtext->width() * 2, $idtext->height() * 2, $idtext->width(), $idtext->height());
my $text = new GD::Image(500, gdGiantFont->height());
$white = $text->colorAllocate(255,255,255);