Bugzilla – Attachment 122779 Details for
Bug 26340
When printing labels from a barcode range, keep zero padding
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26340: Code simplification
Bug-26340-Code-simplification.patch (text/plain), 6.27 KB, created by
Jonathan Druart
on 2021-07-12 13:17:27 UTC
(
hide
)
Description:
Bug 26340: Code simplification
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2021-07-12 13:17:27 UTC
Size:
6.27 KB
patch
obsolete
>From 645d1f2d4a975484d05053086710b6a5078f8be4 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 12 Jul 2021 14:53:38 +0200 >Subject: [PATCH] Bug 26340: Code simplification > >And rename $range with $barcode_length >--- > .../prog/en/modules/labels/label-print.tt | 6 +++--- > labels/label-create-pdf.pl | 17 ++++------------- > labels/label-print.pl | 6 +++--- > 3 files changed, 10 insertions(+), 19 deletions(-) > >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 6c155341446..a4c54a779d2 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 @@ > <fieldset> > [% IF ( batche.label_ids ) %] > <legend>[% IF ( batche.label_count == 1 ) %][% batche.label_count | html %] single label[% ELSE %][% batche.label_count | html %] single labels[% END %]</legend> >- <a class="document pdf" href="/cgi-bin/koha/labels/label-create-pdf.pl?batch_id=0&template_id=[% batche.template_id | html %]&layout_id=[% batche.layout_id | html %]&start_label=[% batche.start_label | html %]&from=[% batche.from | html %]&to=[% batche.to | html %]&range=[% batche.range | html %]">Download as PDF</a> >+ <a class="document pdf" href="/cgi-bin/koha/labels/label-create-pdf.pl?batch_id=0&template_id=[% batche.template_id | html %]&layout_id=[% batche.layout_id | html %]&start_label=[% batche.start_label | html %]&from=[% batche.from | html %]&to=[% batche.to | html %]&barcode_length=[% batche.barcode_length| html %]">Download as PDF</a> > > <p><a class="document csv" href="/cgi-bin/koha/labels/label-create-csv.pl?batch_id=[% batche.batch_id | html %]&template_id=[% batche.template_id | html %]&layout_id=[% batche.layout_id | html %][% batche.label_ids | html %]">Download as CSV</a></p> > >@@ -45,7 +45,7 @@ > [% ELSIF (batche.from && batche.to) %] > <legend>Barcodes from [% batche.from | html %] to [% batche.to | html %]</legend> > <p> >- <a class="document pdf" href="/cgi-bin/koha/labels/label-create-pdf.pl?batch_id=0&template_id=[% batche.template_id | html %]&layout_id=[% batche.layout_id | html %]&start_label=[% batche.start_label | html %]&from=[% batche.from | html %]&to=[% batche.to | html %]&range=[% batche.range | html %]">Download as PDF</a> >+ <a class="document pdf" href="/cgi-bin/koha/labels/label-create-pdf.pl?batch_id=0&template_id=[% batche.template_id | html %]&layout_id=[% batche.layout_id | html %]&start_label=[% batche.start_label | html %]&from=[% batche.from | html %]&to=[% batche.to | html %]&barcode_length=[% batche.barcode_length | html %]">Download as PDF</a> > </p> > [% END %] > </fieldset> >@@ -78,7 +78,7 @@ > [% END %] > <input type="hidden" name="from" value="[% txt_from | html %]" /> > <input type="hidden" name="to" value="[% txt_to | html %]" /> >- <input type="hidden" name="range" value="[% range | html %]" /> >+ <input type="hidden" name="barcode_length" value="[% barcode_length | html %]" /> > <fieldset class="rows"> > <ol> > <li> >diff --git a/labels/label-create-pdf.pl b/labels/label-create-pdf.pl >index ecb16a5a5bb..b76a013cdfb 100755 >--- a/labels/label-create-pdf.pl >+++ b/labels/label-create-pdf.pl >@@ -45,7 +45,7 @@ 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; >+my $barcode_length = $cgi->param('barcode_length'); > > my $items = undef; > >@@ -117,18 +117,9 @@ elsif (@item_numbers) { > } @item_numbers; > } > elsif ($from and $to) { >- for (my $i = $from; $i <= $to; $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}; >- } >+ for my $i ( $from .. $to ) { >+ my $padding = '0' x ( $barcode_length - length($i) ); >+ push @$items, { item_number => $padding . $i }; > } > } > else { >diff --git a/labels/label-print.pl b/labels/label-print.pl >index 1347390b8ec..0d1e0bba197 100755 >--- a/labels/label-print.pl >+++ b/labels/label-print.pl >@@ -55,7 +55,7 @@ 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; >+my $barcode_length = length($txt_from) || undef; > > my $layouts = undef; > my $templates = undef; >@@ -127,7 +127,7 @@ if ($op eq 'export') { > push (@batches, {create_script => 'label-create-pdf.pl', > from => $from, > to => $to, >- range => $range, >+ barcode_length => $barcode_length, > template_id => $template_id, > layout_id => $layout_id, > start_label => $start_label, >@@ -161,7 +161,7 @@ elsif ($op eq 'none') { > referer => $referer, > from => $from, > to => $to, >- range => $range, >+ barcode_length => $barcode_length, > txt_from => $txt_from, > txt_to => $txt_to > ); >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 26340
:
109441
|
109442
|
111190
|
111653
|
111654
|
121496
|
121923
|
122305
|
122575
|
122576
|
122777
| 122779