View | Details | Raw Unified | Return to bug 7468
Collapse All | Expand All

(-)a/C4/Labels/Label.pm (-2 / +2 lines)
Lines 332-338 sub new { Link Here
332
        justify                 => $params{'justify'},
332
        justify                 => $params{'justify'},
333
        format_string           => $params{'format_string'},
333
        format_string           => $params{'format_string'},
334
        text_wrap_cols          => $params{'text_wrap_cols'},
334
        text_wrap_cols          => $params{'text_wrap_cols'},
335
        barcode                 => 0,
335
        barcode                 => $params{'barcode'},
336
    };
336
    };
337
    if ($self->{'guidebox'}) {
337
    if ($self->{'guidebox'}) {
338
        $self->{'guidebox'} = _guide_box($self->{'llx'}, $self->{'lly'}, $self->{'width'}, $self->{'height'});
338
        $self->{'guidebox'} = _guide_box($self->{'llx'}, $self->{'lly'}, $self->{'width'}, $self->{'height'});
Lines 500-506 sub draw_guide_box { Link Here
500
sub barcode {
500
sub barcode {
501
    my $self = shift;
501
    my $self = shift;
502
    my %params = @_;
502
    my %params = @_;
503
    $params{'barcode_data'} = _get_label_item($self->{'item_number'}, 1) if !$params{'barcode_data'};
503
    $params{'barcode_data'} = ($self->{'barcode'} || _get_label_item($self->{'item_number'}, 1)) if !$params{'barcode_data'};
504
    $params{'barcode_type'} = $self->{'barcode_type'} if !$params{'barcode_type'};
504
    $params{'barcode_type'} = $self->{'barcode_type'} if !$params{'barcode_type'};
505
    my $x_scale_factor = 1;
505
    my $x_scale_factor = 1;
506
    my $num_of_bars = length($params{'barcode_data'});
506
    my $num_of_bars = length($params{'barcode_data'});
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/labels-toolbar.inc (+1 lines)
Lines 6-11 Link Here
6
            <li><a href="/cgi-bin/koha/labels/label-edit-layout.pl?op=new">Layout</a></li>
6
            <li><a href="/cgi-bin/koha/labels/label-edit-layout.pl?op=new">Layout</a></li>
7
            <li><a href="/cgi-bin/koha/labels/label-edit-template.pl?op=new">Label template</a></li>
7
            <li><a href="/cgi-bin/koha/labels/label-edit-template.pl?op=new">Label template</a></li>
8
            <li><a href="/cgi-bin/koha/labels/label-edit-profile.pl?op=new">Printer profile</a></li>
8
            <li><a href="/cgi-bin/koha/labels/label-edit-profile.pl?op=new">Printer profile</a></li>
9
            <li><a href="/cgi-bin/koha/labels/label-edit-range.pl">Barcode range</a></li>
9
        </ul>
10
        </ul>
10
    </div>
11
    </div>
11
    <div class="btn-group">
12
    <div class="btn-group">
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-range.tt (+96 lines)
Line 0 Link Here
1
    [% INCLUDE 'doc-head-open.inc' %]
2
    <title>Koha &rsaquo; Tools &rsaquo; Label creator</title>
3
    [% INCLUDE 'doc-head-close.inc' %]
4
    [% INCLUDE 'greybox.inc' %]
5
    [% IF ( bidi ) %]
6
    <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/right-to-left.css" />
7
    [% END %]
8
    <script type="text/javascript">
9
        function Xport() {
10
            var str = "";
11
            str += "from=" + parseInt(document.getElementById("from-input").value) + "&";
12
            str += "to=" + parseInt(document.getElementById("to-input").value);
13
            return GB_showCenter('Export labels', "/cgi-bin/koha/labels/label-print.pl?" + str, 400, 800);
14
            return;
15
        }
16
        function print() {
17
            var error = false;
18
            if (parseInt(document.getElementById("from-input").value) == 0) {
19
                document.getElementById("from-error").innerHTML = "  *Cannot be smaller than 1";
20
                error = true;
21
            } else {
22
                document.getElementById("from-error").innerHTML = "";
23
            }
24
            if (parseInt(document.getElementById("from-input").value) > parseInt(document.getElementById("to-input").value)) {
25
                document.getElementById("to-error").innerHTML = "  *Cannot be smaller than starting value";
26
                error = true;
27
            }
28
            else {
29
                document.getElementById("to-error").innerHTML = "";
30
            }
31
32
            if (error)
33
                return;
34
35
            return Xport();
36
        }
37
38
    </script>
39
</head>
40
<body id="labels_label-home" class="tools labels">
41
    [% INCLUDE 'header.inc' %]
42
    [% INCLUDE 'cat-search.inc' %]
43
    <div id="breadcrumbs">
44
        <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
45
        <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo;
46
        Label creator
47
    </div>
48
    <div id="doc3" class="yui-t2">
49
        <div id="bd">
50
            <div id="yui-main">
51
                <div class="yui-b">
52
                    <div class="yui-g">
53
                    [% INCLUDE 'labels-toolbar.inc' %]
54
                        <div class="yui-u first">
55
56
                        </div>
57
                        <h3>Print barcode range</h3>
58
                    </div>
59
                        <form name="add_by_number" action="/cgi-bin/koha/labels/label-edit-batch.pl" method="post">
60
                            <div>
61
                                <fieldset class="rows" style="border-bottom: 0px; border: 0px;">
62
                                    <ol>
63
                                        <li>
64
                                            <input type="hidden" name="op" value="add" />
65
                                        </li>
66
                                        <li>
67
                                            <label for="from-input">From:</label>
68
                                            <input type="number" name="from" id="from-input" value="0" style="text-align: right;"/>
69
                                            <span id="from-error" style="color: red; font-style: italic;"></span>
70
                                            <br/>
71
                                        </li>
72
                                        <li>
73
                                            <label for="to-input">To:</label>
74
                                            <input type="number" name="to" id="to-input" value="0" style="text-align: right;"/>
75
                                            <span id="to-error" style="color: red; font-style: italic;"></span>
76
                                            <br/>
77
                                        </li>
78
                                    </ol>
79
                                </fieldset>
80
                            </div>
81
                        </form>
82
                        <div id="batch-manage" class="btn-toolbar">
83
                            <a class="btn btn-default btn-sm" id="print" href="javascript:print()">
84
                                <!-- This display a plus. Is there a more appropriate symbol to use?
85
                                <i class="fa fa-plus"></i>
86
                                -->
87
                                Print range
88
                            </a>
89
                        </div>
90
                </div>
91
            </div>
92
            <div class="yui-b">
93
              [% INCLUDE 'tools-menu.inc' %]
94
            </div>
95
        </div>
96
        [% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-print.tt (-1 / +8 lines)
Lines 38-44 Link Here
38
                                    <p><a class="document csv" href="/cgi-bin/koha/labels/label-create-csv.pl?batch_id=[% batche.batch_id %]&amp;template_id=[% batche.template_id %]&amp;layout_id=[% batche.layout_id %][% batche.item_numbers %]">Download as CSV</a></p>
38
                                    <p><a class="document csv" href="/cgi-bin/koha/labels/label-create-csv.pl?batch_id=[% batche.batch_id %]&amp;template_id=[% batche.template_id %]&amp;layout_id=[% batche.layout_id %][% batche.item_numbers %]">Download as CSV</a></p>
39
39
40
                                    <p><a class="document xml" href="/cgi-bin/koha/labels/label-create-xml.pl?batch_id=[% batche.batch_id %]&amp;template_id=[% batche.template_id %]&amp;layout_id=[% batche.layout_id %][% batche.item_numbers %]">Download as XML</a></p>
40
                                    <p><a class="document xml" href="/cgi-bin/koha/labels/label-create-xml.pl?batch_id=[% batche.batch_id %]&amp;template_id=[% batche.template_id %]&amp;layout_id=[% batche.layout_id %][% batche.item_numbers %]">Download as XML</a></p>
41
                            [% ELSE %]
41
                            [% ELSIF ( batche.batch_id) %]
42
                            <legend>Label Batch Number [% batche.batch_id %]</legend>
42
                            <legend>Label Batch Number [% batche.batch_id %]</legend>
43
                                    <p><a class="document pdf" href="/cgi-bin/koha/labels/label-create-pdf.pl?batch_id=[% batche.batch_id %]&amp;template_id=[% batche.template_id %]&amp;layout_id=[% batche.layout_id %]&amp;start_label=[% batche.start_label %]">Download as PDF</a>
43
                                    <p><a class="document pdf" href="/cgi-bin/koha/labels/label-create-pdf.pl?batch_id=[% batche.batch_id %]&amp;template_id=[% batche.template_id %]&amp;layout_id=[% batche.layout_id %]&amp;start_label=[% batche.start_label %]">Download as PDF</a>
44
                                </p>
44
                                </p>
Lines 47-52 Link Here
47
                                </p>
47
                                </p>
48
                                <p>
48
                                <p>
49
                                    <a class="document xml" href="/cgi-bin/koha/labels/label-create-xml.pl?batch_id=[% batche.batch_id %]&amp;template_id=[% batche.template_id %]&amp;layout_id=[% batche.layout_id %]">Download as XML</a></p>
49
                                    <a class="document xml" href="/cgi-bin/koha/labels/label-create-xml.pl?batch_id=[% batche.batch_id %]&amp;template_id=[% batche.template_id %]&amp;layout_id=[% batche.layout_id %]">Download as XML</a></p>
50
                            [% ELSIF (batche.from && batche.to) %]
51
                            <legend>Barcodes from [% batche.from %] to [% batche.to %]</legend>
52
                            <p>
53
                                <a class="document pdf" href="/cgi-bin/koha/labels/label-create-pdf.pl?batch_id=0&amp;template_id=[% batche.template_id %]&amp;layout_id=[% batche.layout_id %]&amp;start_label=[% batche.start_label %]&amp;from=[% batche.from %]&amp;to=[% batche.to %]">Download as PDF</a>
54
                            </p>
50
                            [% END %]
55
                            [% END %]
51
                        </fieldset>
56
                        </fieldset>
52
                        [% END %]
57
                        [% END %]
Lines 76-81 Link Here
76
                [% FOREACH item_number IN item_numbers %]
81
                [% FOREACH item_number IN item_numbers %]
77
                    <input type="hidden" name="item_number" value="[% item_number.item_number %]" />
82
                    <input type="hidden" name="item_number" value="[% item_number.item_number %]" />
78
                [% END %]
83
                [% END %]
84
                    <input type="hidden" name="from" value="[% from %]" />
85
                    <input type="hidden" name="to" value="[% to %]" />
79
                <fieldset class="rows">
86
                <fieldset class="rows">
80
                    <ol>
87
                    <ol>
81
                        <li>
88
                        <li>
(-)a/labels/label-create-pdf.pl (-2 / +8 lines)
Lines 47-57 my $layout_id = $cgi->param('layout_id') || undef; Link Here
47
my $start_label = $cgi->param('start_label') || 1;
47
my $start_label = $cgi->param('start_label') || 1;
48
@label_ids   = $cgi->multi_param('label_id') if $cgi->param('label_id');
48
@label_ids   = $cgi->multi_param('label_id') if $cgi->param('label_id');
49
@item_numbers  = $cgi->multi_param('item_number') if $cgi->param('item_number');
49
@item_numbers  = $cgi->multi_param('item_number') if $cgi->param('item_number');
50
my $from = $cgi->param('from') || undef;
51
my $to = $cgi->param('to') || undef;
50
52
51
my $items = undef;
53
my $items = undef;
52
54
53
54
55
my $pdf_file = (@label_ids || @item_numbers ? "label_single_" . scalar(@label_ids || @item_numbers) : "label_batch_$batch_id");
55
my $pdf_file = (@label_ids || @item_numbers ? "label_single_" . scalar(@label_ids || @item_numbers) : "label_batch_$batch_id");
56
print $cgi->header( -type       => 'application/pdf',
56
print $cgi->header( -type       => 'application/pdf',
57
                    -encoding   => 'utf-8',
57
                    -encoding   => 'utf-8',
Lines 119-124 elsif (@item_numbers) { Link Here
119
        push(@{$items}, {item_number => $_});
119
        push(@{$items}, {item_number => $_});
120
    } @item_numbers;
120
    } @item_numbers;
121
}
121
}
122
elsif ($from and $to) {
123
    for (my $i = $from; $i <= $to; $i++) {
124
        push @{$items}, {'item_number' => $i};
125
    }
126
}
122
else {
127
else {
123
    $items = $batch->get_attr('items');
128
    $items = $batch->get_attr('items');
124
}
129
}
Lines 199-204 foreach my $item (@{$items}) { Link Here
199
                                        text_wrap_cols      => $layout->get_text_wrap_cols(label_width => $template->get_attr('label_width'), left_text_margin => $template->get_attr('left_text_margin')),
204
                                        text_wrap_cols      => $layout->get_text_wrap_cols(label_width => $template->get_attr('label_width'), left_text_margin => $template->get_attr('left_text_margin')),
200
                                          );
205
                                          );
201
        $pdf->Add($label->draw_guide_box) if $layout->get_attr('guidebox');
206
        $pdf->Add($label->draw_guide_box) if $layout->get_attr('guidebox');
207
        $label->{'barcode'} = $item->{'item_number'} if ($from and $to);
202
        my $label_text = $label->create_label();
208
        my $label_text = $label->create_label();
203
        _print_text($label_text) if $label_text;
209
        _print_text($label_text) if $label_text;
204
        ($row_count, $col_count, $llx, $lly) = _calc_next_label_pos($row_count, $col_count, $llx, $lly);
210
        ($row_count, $col_count, $llx, $lly) = _calc_next_label_pos($row_count, $col_count, $llx, $lly);
(-)a/labels/label-edit-range.pl (+40 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
#
3
# Copyright 2017 Solutions inLibto
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use strict;
21
use warnings;
22
23
use CGI qw ( -utf8 );
24
25
use C4::Auth qw(get_template_and_user);
26
use C4::Output qw(output_html_with_http_headers);
27
28
my $cgi = new CGI;
29
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
30
    {
31
        template_name   => "labels/label-edit-range.tt",
32
        query           => $cgi,
33
        type            => "intranet",
34
        authnotrequired => 0,
35
        flagsrequired   => { catalogue => 1 },
36
        debug           => 1,
37
    }
38
);
39
40
output_html_with_http_headers $cgi, $cookie, $template->output;
(-)a/labels/label-print.pl (-1 / +18 lines)
Lines 53-58 my @item_numbers; Link Here
53
my $output_format = $cgi->param('output_format') || 'pdf';
53
my $output_format = $cgi->param('output_format') || 'pdf';
54
my $referer = $cgi->param('referer') || undef;
54
my $referer = $cgi->param('referer') || undef;
55
55
56
my $from = $cgi->param('from') || undef;
57
my $to = $cgi->param('to') || undef;
58
56
my $layouts = undef;
59
my $layouts = undef;
57
my $templates = undef;
60
my $templates = undef;
58
my $output_formats = undef;
61
my $output_formats = undef;
Lines 107-112 if ($op eq 'export') { Link Here
107
                        referer     => $referer,
110
                        referer     => $referer,
108
                        );
111
                        );
109
    }
112
    }
113
    elsif ($from and $to) {
114
        push (@batches, {create_script   => 'label-create-pdf.pl',
115
                 from            => $from,
116
                 to              => $to,
117
                 template_id     => $template_id,
118
                 layout_id       => $layout_id,
119
                 start_label     => $start_label,
120
                 });
121
       $template->param(
122
                        batches     => \@batches,
123
                        referer     => $referer,
124
                        );
125
    }
110
}
126
}
111
elsif ($op eq 'none') {
127
elsif ($op eq 'none') {
112
    # setup select menus for selecting layout and template for this run...
128
    # setup select menus for selecting layout and template for this run...
Lines 129-134 elsif ($op eq 'none') { Link Here
129
                    label_count                 => $label_count,
145
                    label_count                 => $label_count,
130
                    item_count                  => $item_count,
146
                    item_count                  => $item_count,
131
                    referer                     => $referer,
147
                    referer                     => $referer,
148
                    from                        => $from,
149
                    to                          => $to
132
                    );
150
                    );
133
}
151
}
134
output_html_with_http_headers $cgi, $cookie, $template->output;
152
output_html_with_http_headers $cgi, $cookie, $template->output;
135
- 

Return to bug 7468