#!perl # Ja, het is lelijk. Even snel in elkaar geklust en daarna niet meer naar # gekeken. Pech :) -- Juerd sub command :Tab(barcode) ($self, $cart, $command, @) { return NEXT if $command ne "barcode"; return "Barcode data", \&data; } sub data($self, $cart, $input, @) { my $price = 0.07; $cart ->add( -$price, "Barcode <$input>", { is_barcode => 1, barcode_data => $input, deduplicate => join("/", $self->id, $input), } ) ->add_contra( "+sales/barcodes", +$price, "\$you bought barcode <$input>" ); return ACCEPT; } sub hook_checkout($class, $cart, $username, $transaction_id, @) { my @barcodes; for my $entry ($cart->entries('is_barcode')) { push @barcodes, ($entry->attribute('barcode_data')) x $entry->quantity; } if (@barcodes) { print "\nCheck the following:\n 1. label tape is 12 mm\n 2. printer is on\n 3. wifi is enabled and connected\n\nPress enter to continue."; readline STDIN; my $printjob = ""; open my $bcgen, "-|", "/home/bar/revlabel/barcode.pl", @barcodes or warn "Could not open script 1"; local $/; my $filenames = readline $bcgen; close $bcgen; open my $fh, "| /home/bar/revlabel/ptouch-770-write 12 $filenames | nc -N 10.42.42.222 9100" or warn "Couldn't open script 2\n"; print $fh $printjob; close $fh; } }