From a75bd018831562767eb92181015f4f63fdbe7f8b 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=utf8 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. Signed-off-by: hakam Signed-off-by: Katrin Fischer Signed-off-by: Jonathan Druart --- .../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 a8d89e8bd4..15b8a3f422 100755 --- a/labels/label-create-pdf.pl +++ b/labels/label-create-pdf.pl @@ -45,6 +45,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; @@ -117,7 +120,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 6a4ac13a1c..cb928504e4 100755 --- a/labels/label-print.pl +++ b/labels/label-print.pl @@ -51,8 +51,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; @@ -124,6 +129,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, @@ -156,7 +162,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.39.5