Bugzilla – Attachment 111190 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: Printing labels without zero(s) in the start of labels
Bug-26340-Printing-labels-without-zeros-in-the-sta.patch (text/plain), 8.90 KB, created by
David Nind
on 2020-10-03 08:19:02 UTC
(
hide
)
Description:
Bug 26340: Printing labels without zero(s) in the start of labels
Filename:
MIME Type:
Creator:
David Nind
Created:
2020-10-03 08:19:02 UTC
Size:
8.90 KB
patch
obsolete
>From 97f433fe2ffe3c713b6d57cc90913baa6b645ce9 Mon Sep 17 00:00:00 2001 >From: Ivan Dziuba <ivan.dziuba@inlibro.com> >Date: Tue, 1 Sep 2020 10:27:54 -0400 >Subject: [PATCH] Bug 26340: Printing labels without zero(s) in the start of > labels > >Signed-off-by: David Nind <david@davidnind.com> >--- > .../prog/en/modules/labels/label-edit-range.tt | 25 ++++++++++++---------- > .../prog/en/modules/labels/label-print.tt | 7 +++--- > labels/label-create-pdf.pl | 14 +++++++++++- > labels/label-print.pl | 24 +++++++++++++++------ > 4 files changed, 48 insertions(+), 22 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 4a5bc5a7e4..7b43aa7111 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 >@@ -54,8 +54,8 @@ > <script> > function Xport() { > var str = ""; >- str += "from=" + parseInt(document.getElementById("from-input").value) + "&"; >- str += "to=" + parseInt(document.getElementById("to-input").value); >+ str += "from=" + document.getElementById("from-input").value + "&"; >+ str += "to=" + document.getElementById("to-input").value; > return GB_showCenter('Export labels', "/cgi-bin/koha/labels/label-print.pl?" + str, 400, 800); > } > >@@ -64,20 +64,23 @@ > return parseInt(value) > parseInt($(params).val()); > }, _("Must be greater than from value.")); > >+ $.validator.addMethod("eq", function(value, element, params) { >+ return value.length == $(params).val().length; >+ }, _("Length from and to values must be same.")); >+ >+ > $("form[name=add_by_number]").validate({ > rules: { > from: { >- required: true, >- number: true, >- min: 1 >+ required: true, > }, >- to: { >- required: true, >- number: true, >- gt: "#from-input" >- } >+ to: { >+ required: true, >+ gt: "#from-input", >+ eq: "#from-input", > } >- }); >+ } >+ }); > > $("#print").on("click", function () { > if ( $("form[name=add_by_number]").valid() ) { >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 63b3836503..1a375bdc1d 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 >@@ -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 %]">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 %]&range=[% batche.range | html %]">Download as PDF</a> > </p> > [% END %] > </fieldset> >@@ -76,8 +76,9 @@ > [% FOREACH item_number IN item_numbers %] > <input type="hidden" name="item_number" value="[% item_number.item_number | html %]" /> > [% END %] >- <input type="hidden" name="from" value="[% from | html %]" /> >- <input type="hidden" name="to" value="[% to | html %]" /> >+ <input type="hidden" name="from" value="[% txt_from | html %]" /> >+ <input type="hidden" name="to" value="[% txt_to | html %]" /> >+ <input type="hidden" name="to" value="[% range | html %]" /> > <fieldset class="rows"> > <ol> > <li> >diff --git a/labels/label-create-pdf.pl b/labels/label-create-pdf.pl >index 0fea1dfe88..a77880a24e 100755 >--- a/labels/label-create-pdf.pl >+++ b/labels/label-create-pdf.pl >@@ -48,6 +48,8 @@ my $start_label = $cgi->param('start_label') || 1; > my $from = $cgi->param('from') || undef; > my $to = $cgi->param('to') || undef; > >+my $range = $cgi->param('range') || undef; >+ > my $items = undef; > > my $pdf_file = (@label_ids || @item_numbers ? "label_single_" . scalar(@label_ids || @item_numbers) : "label_batch_$batch_id"); >@@ -119,7 +121,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 93b86790e0..d7a4cb0c75 100755 >--- a/labels/label-print.pl >+++ b/labels/label-print.pl >@@ -52,8 +52,11 @@ 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; > > my $layouts = undef; > my $templates = undef; >@@ -74,6 +77,7 @@ if ($op eq 'export') { > start_label => $start_label, > label_ids => $label_id_param, > label_count => scalar(@label_ids), >+ range => $range > }); > $template->param( > batches => \@batches, >@@ -84,11 +88,12 @@ if ($op eq 'export') { > my $item_number_param = '&item_number='; > $item_number_param .= join ('&item_number=',@item_numbers); > push (@batches, {create_script => ($output_format eq 'pdf' ? 'label-create-pdf.pl' : 'label-create-csv.pl'), >- template_id => $template_id, >- layout_id => $layout_id, >- start_label => $start_label, >- item_numbers => $item_number_param, >- label_count => scalar(@item_numbers), >+ template_id => $template_id, >+ layout_id => $layout_id, >+ start_label => $start_label, >+ item_numbers => $item_number_param, >+ label_count => scalar(@item_numbers), >+ range => $range > }); > $template->param( > batches => \@batches, >@@ -102,6 +107,7 @@ if ($op eq 'export') { > template_id => $template_id, > layout_id => $layout_id, > start_label => $start_label, >+ range => $range > }); > } > $template->param( >@@ -128,6 +134,7 @@ if ($op eq 'export') { > template_id => $template_id, > layout_id => $layout_id, > start_label => $start_label, >+ range => $range > }); > $template->param( > batches => \@batches, >@@ -156,6 +163,9 @@ elsif ($op eq 'none') { > label_count => $label_count, > item_count => $item_count, > referer => $referer, >+ range => $range, >+ txt_from => $txt_from, >+ txt_to => $txt_to, > from => $from, > to => $to > ); >-- >2.11.0
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