Bug 34732: For Code39, append or prepend asterisk if missing from barcode

This patch appends or prepends an asterisk on Code39 barcodes if
they are missing from the input. This is so that they form correct
Code39 barcode images.

Test plan:
0. Apply the patch
1. koha-plack --reload kohadev
2. Go to http://localhost:8081/cgi-bin/koha/labels/barcode-print.pl
3. Type 39999000001310 into "Barcode" and click "Show barcode"
4. Note that the barcode text on the right includes asterisks around it
5. Type *39999000001310 into "Barcode" and click "Show barcode"
6. Note the same as above
7. Type 39999000001310* into "Barcode" and click "Show barcode"
8. Note the same as above
9. Type *39999000001310* into "Barcode" and click "Show barcode"
10. Note the same as above

Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 0f888f48fa)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
David Cook 2023-09-08 02:19:20 +00:00 committed by Fridolin Somers
parent eb995d498f
commit 66e179f905

View file

@ -106,6 +106,11 @@ my $height = $input->param('height') || 50;
my $qrcode_modulesize = $input->param('modulesize') || "5"; # 1+ my $qrcode_modulesize = $input->param('modulesize') || "5"; # 1+
my $image; my $image;
if ($type eq 'Code39'){
$barcode = '*' . $barcode unless $barcode =~ /^\*/;
$barcode = $barcode . '*' unless $barcode =~ /\*$/;
}
eval { eval {
if( $type eq "QRcode" ){ if( $type eq "QRcode" ){
$image = GD::Barcode->new('QRcode', $barcode, { Ecc => "M", ModuleSize => $qrcode_modulesize } )->plot->png(); $image = GD::Barcode->new('QRcode', $barcode, { Ecc => "M", ModuleSize => $qrcode_modulesize } )->plot->png();