@@ -, +, @@ --- 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 --- a/C4/Labels/Label.pm +++ a/C4/Labels/Label.pm @@ -332,7 +332,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'}); @@ -500,7 +500,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'}); --- a/koha-tmpl/intranet-tmpl/prog/en/includes/labels-toolbar.inc +++ a/koha-tmpl/intranet-tmpl/prog/en/includes/labels-toolbar.inc @@ -6,6 +6,7 @@
  • Layout
  • Label template
  • Printer profile
  • +
  • Barcode range
  • --- a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-range.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-range.tt @@ -0,0 +1,96 @@ + [% INCLUDE 'doc-head-open.inc' %] + Koha › Tools › Label creator + [% INCLUDE 'doc-head-close.inc' %] + [% INCLUDE 'greybox.inc' %] + [% IF ( bidi ) %] + + [% END %] + + + + [% INCLUDE 'header.inc' %] + [% INCLUDE 'cat-search.inc' %] + +
    +
    +
    +
    +
    + [% INCLUDE 'labels-toolbar.inc' %] +
    + +
    +

    Print barcode range

    +
    +
    +
    +
    +
      +
    1. + +
    2. +
    3. + + + +
      +
    4. +
    5. + + + +
      +
    6. +
    +
    +
    +
    + +
    +
    +
    + [% INCLUDE 'tools-menu.inc' %] +
    +
    + [% INCLUDE 'intranet-bottom.inc' %] --- a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-print.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-print.tt @@ -38,7 +38,7 @@

    Download as CSV

    Download as XML

    - [% ELSE %] + [% ELSIF ( batche.batch_id) %] Label Batch Number [% batche.batch_id %]

    Download as PDF

    @@ -47,6 +47,11 @@

    Download as XML

    + [% ELSIF (batche.from && batche.to) %] + Barcodes from [% batche.from %] to [% batche.to %] +

    + Download as PDF +

    [% END %] [% END %] @@ -76,6 +81,8 @@ [% FOREACH item_number IN item_numbers %] [% END %] + +
    1. --- a/labels/label-create-pdf.pl +++ a/labels/label-create-pdf.pl @@ -47,11 +47,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', @@ -119,6 +119,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'); } @@ -199,6 +204,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); --- a/labels/label-edit-range.pl +++ a/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 . + +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; --- a/labels/label-print.pl +++ a/labels/label-print.pl @@ -53,6 +53,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; @@ -107,6 +110,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... @@ -129,6 +145,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; --