Bugzilla – Attachment 97551 Details for
Bug 7468
Add label to batch by barcode range
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 7468: Print barcodes by range
Bug-7468-Print-barcodes-by-range.patch (text/plain), 15.43 KB, created by
David Nind
on 2020-01-17 18:57:04 UTC
(
hide
)
Description:
Bug 7468: Print barcodes by range
Filename:
MIME Type:
Creator:
David Nind
Created:
2020-01-17 18:57:04 UTC
Size:
15.43 KB
patch
obsolete
>From 57e0ba8f73dd2af9b818deacd11675406abd4ebe Mon Sep 17 00:00:00 2001 >From: David Bourgault <david.bourgault@inlibro.com> >Date: Mon, 18 Sep 2017 10:55:05 -0400 >Subject: [PATCH] Bug 7468: Print barcodes by range > >Adds an option to the label creator to print a range of barcodes. >Only allows printing to PDF. > >C4/Label.pm had to get minor changes to override database-based barcode >generation. Same with labels/label-create-pdf.pl. By default, the >barcode is fetched from the database using the itemnumber, but when >printing ranges, you might not have a corresponding database entry. > >Signed-off-by: David Nind <david@davidnind.com> >--- > C4/Labels/Label.pm | 4 +- > .../prog/en/includes/labels-toolbar.inc | 1 + > .../prog/en/modules/labels/label-edit-range.tt | 96 ++++++++++++++++++++++ > .../prog/en/modules/labels/label-print.tt | 9 +- > labels/label-create-pdf.pl | 10 ++- > labels/label-edit-range.pl | 40 +++++++++ > labels/label-print.pl | 18 ++++ > 7 files changed, 173 insertions(+), 5 deletions(-) > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-range.tt > create mode 100755 labels/label-edit-range.pl > >diff --git a/C4/Labels/Label.pm b/C4/Labels/Label.pm >index 9ce6c0e580..fc0657ebb5 100644 >--- a/C4/Labels/Label.pm >+++ b/C4/Labels/Label.pm >@@ -274,7 +274,7 @@ sub new { > justify => $params{'justify'}, > format_string => $params{'format_string'}, > text_wrap_cols => $params{'text_wrap_cols'}, >- barcode => 0, >+ barcode => $params{'barcode'}, > }; > if ($self->{'guidebox'}) { > $self->{'guidebox'} = _guide_box($self->{'llx'}, $self->{'lly'}, $self->{'width'}, $self->{'height'}); >@@ -454,7 +454,7 @@ sub draw_guide_box { > sub barcode { > my $self = shift; > my %params = @_; >- $params{'barcode_data'} = _get_label_item($self->{'item_number'}, 1) if !$params{'barcode_data'}; >+ $params{'barcode_data'} = ($self->{'barcode'} || _get_label_item($self->{'item_number'}, 1)) if !$params{'barcode_data'}; > $params{'barcode_type'} = $self->{'barcode_type'} if !$params{'barcode_type'}; > my $x_scale_factor = 1; > my $num_of_bars = length($params{'barcode_data'}); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/labels-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/labels-toolbar.inc >index 269aaca813..801ab9cb2e 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/labels-toolbar.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/labels-toolbar.inc >@@ -7,6 +7,7 @@ > <li><a href="/cgi-bin/koha/labels/label-edit-layout.pl?op=new">Layout</a></li> > <li><a href="/cgi-bin/koha/labels/label-edit-template.pl?op=new">Label template</a></li> > <li><a href="/cgi-bin/koha/labels/label-edit-profile.pl?op=new">Printer profile</a></li> >+ <li><a href="/cgi-bin/koha/labels/label-edit-range.pl">Barcode range</a></li> > </ul> > </div> > <div class="btn-group"> >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 >new file mode 100644 >index 0000000000..79a21610f1 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-range.tt >@@ -0,0 +1,96 @@ >+ [% INCLUDE 'doc-head-open.inc' %] >+ <title>Koha › Tools › Label creator</title> >+ [% INCLUDE 'doc-head-close.inc' %] >+ [% INCLUDE 'greybox.inc' %] >+ [% IF ( bidi ) %] >+ <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/right-to-left.css" /> >+ [% END %] >+ <script type="text/javascript"> >+ function Xport() { >+ var str = ""; >+ str += "from=" + parseInt(document.getElementById("from-input").value) + "&"; >+ str += "to=" + parseInt(document.getElementById("to-input").value); >+ return GB_showCenter('Export labels', "/cgi-bin/koha/labels/label-print.pl?" + str, 400, 800); >+ return; >+ } >+ function print() { >+ var error = false; >+ if (parseInt(document.getElementById("from-input").value) == 0) { >+ document.getElementById("from-error").innerHTML = " *Cannot be smaller than 1"; >+ error = true; >+ } else { >+ document.getElementById("from-error").innerHTML = ""; >+ } >+ if (parseInt(document.getElementById("from-input").value) > parseInt(document.getElementById("to-input").value)) { >+ document.getElementById("to-error").innerHTML = " *Cannot be smaller than starting value"; >+ error = true; >+ } >+ else { >+ document.getElementById("to-error").innerHTML = ""; >+ } >+ >+ if (error) >+ return; >+ >+ return Xport(); >+ } >+ >+ </script> >+</head> >+<body id="labels_label-home" class="tools labels"> >+ [% INCLUDE 'header.inc' %] >+ [% INCLUDE 'cat-search.inc' %] >+ <div id="breadcrumbs"> >+ <a href="/cgi-bin/koha/mainpage.pl">Home</a> › >+ <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> › >+ Label creator >+ </div> >+ <div id="doc3" class="yui-t2"> >+ <div id="bd"> >+ <div id="yui-main"> >+ <div class="yui-b"> >+ <div class="yui-g"> >+ [% INCLUDE 'labels-toolbar.inc' %] >+ <div class="yui-u first"> >+ >+ </div> >+ <h3>Print barcode range</h3> >+ </div> >+ <form name="add_by_number" action="/cgi-bin/koha/labels/label-edit-batch.pl" method="post"> >+ <div> >+ <fieldset class="rows" style="border-bottom: 0px; border: 0px;"> >+ <ol> >+ <li> >+ <input type="hidden" name="op" value="add" /> >+ </li> >+ <li> >+ <label for="from-input">From:</label> >+ <input type="number" name="from" id="from-input" value="0" style="text-align: right;"/> >+ <span id="from-error" style="color: red; font-style: italic;"></span> >+ <br/> >+ </li> >+ <li> >+ <label for="to-input">To:</label> >+ <input type="number" name="to" id="to-input" value="0" style="text-align: right;"/> >+ <span id="to-error" style="color: red; font-style: italic;"></span> >+ <br/> >+ </li> >+ </ol> >+ </fieldset> >+ </div> >+ </form> >+ <div id="batch-manage" class="btn-toolbar"> >+ <a class="btn btn-default btn-sm" id="print" href="javascript:print()"> >+ <!-- This display a plus. Is there a more appropriate symbol to use? >+ <i class="fa fa-plus"></i> >+ --> >+ Print range >+ </a> >+ </div> >+ </div> >+ </div> >+ <div class="yui-b"> >+ [% INCLUDE 'tools-menu.inc' %] >+ </div> >+ </div> >+ [% INCLUDE 'intranet-bottom.inc' %] >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 663a0d7fb9..f1b17ee13f 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 >@@ -27,7 +27,7 @@ > <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.item_numbers | html %]">Download as CSV</a></p> > > <p><a class="document xml" href="/cgi-bin/koha/labels/label-create-xml.pl?batch_id=[% batche.batch_id | html %]&template_id=[% batche.template_id | html %]&layout_id=[% batche.layout_id | html %][% batche.item_numbers | html %]">Download as XML</a></p> >- [% ELSE %] >+ [% ELSIF ( batche.batch_id) %] > <legend>Label Batch Number [% batche.batch_id | html %]</legend> > <p><a class="document pdf" href="/cgi-bin/koha/labels/label-create-pdf.pl?batch_id=[% batche.batch_id | html %]&template_id=[% batche.template_id | html %]&layout_id=[% batche.layout_id | html %]&start_label=[% batche.start_label | html %]">Download as PDF</a> > </p> >@@ -36,6 +36,11 @@ > </p> > <p> > <a class="document xml" href="/cgi-bin/koha/labels/label-create-xml.pl?batch_id=[% batche.batch_id | html %]&template_id=[% batche.template_id | html %]&layout_id=[% batche.layout_id | html %]">Download as XML</a></p> >+ [% ELSIF (batche.from && batche.to) %] >+ <legend>Barcodes from [% batche.from %] to [% batche.to %]</legend> >+ <p> >+ <a class="document pdf" href="/cgi-bin/koha/labels/label-create-pdf.pl?batch_id=0&template_id=[% batche.template_id %]&layout_id=[% batche.layout_id %]&start_label=[% batche.start_label %]&from=[% batche.from %]&to=[% batche.to %]">Download as PDF</a> >+ </p> > [% END %] > </fieldset> > [% END %] >@@ -65,6 +70,8 @@ > [% 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 %]" /> >+ <input type="hidden" name="to" value="[% to %]" /> > <fieldset class="rows"> > <ol> > <li> >diff --git a/labels/label-create-pdf.pl b/labels/label-create-pdf.pl >index edff024bc1..2077dc3c53 100755 >--- a/labels/label-create-pdf.pl >+++ b/labels/label-create-pdf.pl >@@ -46,11 +46,11 @@ my $layout_id = $cgi->param('layout_id') || undef; > my $start_label = $cgi->param('start_label') || 1; > @label_ids = $cgi->multi_param('label_id') if $cgi->param('label_id'); > @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 $items = undef; > >- >- > my $pdf_file = (@label_ids || @item_numbers ? "label_single_" . scalar(@label_ids || @item_numbers) : "label_batch_$batch_id"); > print $cgi->header( -type => 'application/pdf', > -encoding => 'utf-8', >@@ -118,6 +118,11 @@ elsif (@item_numbers) { > push(@{$items}, {item_number => $_}); > } @item_numbers; > } >+elsif ($from and $to) { >+ for (my $i = $from; $i <= $to; $i++) { >+ push @{$items}, {'item_number' => $i}; >+ } >+} > else { > $items = $batch->get_attr('items'); > } >@@ -198,6 +203,7 @@ foreach my $item (@{$items}) { > text_wrap_cols => $layout->get_text_wrap_cols(label_width => $template->get_attr('label_width'), left_text_margin => $template->get_attr('left_text_margin')), > ); > $pdf->Add($label->draw_guide_box) if $layout->get_attr('guidebox'); >+ $label->{'barcode'} = $item->{'item_number'} if ($from and $to); > my $label_text = $label->create_label(); > _print_text($label_text) if $label_text; > ($row_count, $col_count, $llx, $lly) = _calc_next_label_pos($row_count, $col_count, $llx, $lly); >diff --git a/labels/label-edit-range.pl b/labels/label-edit-range.pl >new file mode 100755 >index 0000000000..8f73934395 >--- /dev/null >+++ b/labels/label-edit-range.pl >@@ -0,0 +1,40 @@ >+#!/usr/bin/perl >+# >+# Copyright 2017 Solutions inLibto >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use strict; >+use warnings; >+ >+use CGI qw ( -utf8 ); >+ >+use C4::Auth qw(get_template_and_user); >+use C4::Output qw(output_html_with_http_headers); >+ >+my $cgi = new CGI; >+my ( $template, $loggedinuser, $cookie ) = get_template_and_user( >+ { >+ template_name => "labels/label-edit-range.tt", >+ query => $cgi, >+ type => "intranet", >+ authnotrequired => 0, >+ flagsrequired => { catalogue => 1 }, >+ debug => 1, >+ } >+); >+ >+output_html_with_http_headers $cgi, $cookie, $template->output; >diff --git a/labels/label-print.pl b/labels/label-print.pl >index e8a42fa206..3835ec4672 100755 >--- a/labels/label-print.pl >+++ b/labels/label-print.pl >@@ -52,6 +52,9 @@ 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 $layouts = undef; > my $templates = undef; > my $output_formats = undef; >@@ -106,6 +109,19 @@ if ($op eq 'export') { > referer => $referer, > ); > } >+ elsif ($from and $to) { >+ push (@batches, {create_script => 'label-create-pdf.pl', >+ from => $from, >+ to => $to, >+ template_id => $template_id, >+ layout_id => $layout_id, >+ start_label => $start_label, >+ }); >+ $template->param( >+ batches => \@batches, >+ referer => $referer, >+ ); >+ } > } > elsif ($op eq 'none') { > # setup select menus for selecting layout and template for this run... >@@ -128,6 +144,8 @@ elsif ($op eq 'none') { > label_count => $label_count, > item_count => $item_count, > referer => $referer, >+ from => $from, >+ to => $to > ); > } > output_html_with_http_headers $cgi, $cookie, $template->output; >-- >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 7468
:
67184
|
67598
|
67636
|
70980
|
77592
|
81071
|
81072
|
81073
|
81074
|
81075
|
91568
|
91569
|
91570
|
97454
|
97455
|
97456
|
97457
|
97458
|
97459
|
97460
|
97461
|
97551
|
97552
|
97553
|
97554
|
97555
|
97556
|
97557
|
97558
|
97638
|
97639
|
97640
|
97641
|
97642
|
97643
|
97644
|
97645
|
97646