From 0932d274a58ac2e555de10b253df5bcf54dc87ab Mon Sep 17 00:00:00 2001 From: Ivan Dziuba Date: Mon, 14 Jun 2021 14:41:14 -0400 Subject: [PATCH] Bug 26340: When printing labels from a barcode range, keep zero padding MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TEST PLAN: 1. Go Tools > Label creator 2. Click +New -> Barcode range 3. Print barcode range with zero(s) in the start (Ex. from 00011881 to 00012000 ) 4. Select a template to be applied:: Code à barre 48467 Select a layout to be applied: Code à barres 5. Export 6. Open PDF The prefix is not displayed. We should see 00011881 on the labels, but we see 11881, 11882, ... without zeros in the start of labels. This patch fix it. --- .../en/modules/labels/label-edit-range.tt | 52 ++++++++++++++++--- .../prog/en/modules/labels/label-print.tt | 9 ++-- labels/label-create-pdf.pl | 15 +++++- labels/label-print.pl | 15 ++++-- 4 files changed, 77 insertions(+), 14 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-range.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-range.tt index 6f3a463086..a1bb56fe4f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-range.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-range.tt @@ -67,27 +67,60 @@ [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-print.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-print.tt index fcf706b87f..48ebbec8b7 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-print.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-print.tt @@ -21,7 +21,7 @@
[% IF ( batche.label_ids ) %] [% IF ( batche.label_count == 1 ) %][% batche.label_count | html %] single label[% ELSE %][% batche.label_count | html %] single labels[% END %] -

Download as PDF

+ Download as PDF

Download as CSV

@@ -45,7 +45,7 @@ [% ELSIF (batche.from && batche.to) %] Barcodes from [% batche.from | html %] to [% batche.to | html %]

- Download as PDF + Download as PDF

[% END %]
@@ -76,8 +76,9 @@ [% FOREACH item_number IN item_numbers %] [% END %] - - + + +
  1. diff --git a/labels/label-create-pdf.pl b/labels/label-create-pdf.pl index d35c5d36ea..3f71534cea 100755 --- a/labels/label-create-pdf.pl +++ b/labels/label-create-pdf.pl @@ -47,6 +47,9 @@ my $start_label = $cgi->param('start_label') || 1; @item_numbers = $cgi->multi_param('item_number') if $cgi->param('item_number'); my $from = $cgi->param('from') || undef; my $to = $cgi->param('to') || undef; +my $range = $cgi->param('range') || undef; + +warn ("range_pdf = " . Data::Dumper::Dumper($range)); my $items = undef; @@ -119,7 +122,17 @@ elsif (@item_numbers) { } elsif ($from and $to) { for (my $i = $from; $i <= $to; $i++) { - push @{$items}, {'item_number' => $i}; + my $compare_range = $range - length($i); + if ($compare_range == 0){ + push @{$items}, {'item_number' => $i}; + } else { + my $a = ''; + for (my $j = 1; $j <= $compare_range; $j++){ + $a .= '0'; + } + $a .= $i; + push @{$items}, {'item_number' => $a}; + } } } else { diff --git a/labels/label-print.pl b/labels/label-print.pl index 22d15ec327..f238462203 100755 --- a/labels/label-print.pl +++ b/labels/label-print.pl @@ -52,8 +52,13 @@ my @item_numbers; my $output_format = $cgi->param('output_format') || 'pdf'; my $referer = $cgi->param('referer') || undef; -my $from = $cgi->param('from') || undef; -my $to = $cgi->param('to') || undef; +my $txt_from = $cgi->param('from') || undef; +my $txt_to = $cgi->param('to') || undef; +my $from = int($txt_from) || undef; +my $to = int($txt_to) || undef; +my $range = length($txt_from) || undef; + +warn ("range = " . Data::Dumper::Dumper($range)); my $layouts = undef; my $templates = undef; @@ -125,6 +130,7 @@ if ($op eq 'export') { push (@batches, {create_script => 'label-create-pdf.pl', from => $from, to => $to, + range => $range, template_id => $template_id, layout_id => $layout_id, start_label => $start_label, @@ -157,7 +163,10 @@ elsif ($op eq 'none') { item_count => $item_count, referer => $referer, from => $from, - to => $to + to => $to, + range => $range, + txt_from => $txt_from, + txt_to => $txt_to ); } output_html_with_http_headers $cgi, $cookie, $template->output; -- 2.17.1