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

(-)a/C4/Labels/Label.pm (-2 / +2 lines)
Lines 274-280 sub new { Link Here
274
        justify                 => $params{'justify'},
274
        justify                 => $params{'justify'},
275
        format_string           => $params{'format_string'},
275
        format_string           => $params{'format_string'},
276
        text_wrap_cols          => $params{'text_wrap_cols'},
276
        text_wrap_cols          => $params{'text_wrap_cols'},
277
        barcode                 => 0,
277
        barcode                 => $params{'barcode'},
278
    };
278
    };
279
    if ($self->{'guidebox'}) {
279
    if ($self->{'guidebox'}) {
280
        $self->{'guidebox'} = _guide_box($self->{'llx'}, $self->{'lly'}, $self->{'width'}, $self->{'height'});
280
        $self->{'guidebox'} = _guide_box($self->{'llx'}, $self->{'lly'}, $self->{'width'}, $self->{'height'});
Lines 454-460 sub draw_guide_box { Link Here
454
sub barcode {
454
sub barcode {
455
    my $self = shift;
455
    my $self = shift;
456
    my %params = @_;
456
    my %params = @_;
457
    $params{'barcode_data'} = _get_label_item($self->{'item_number'}, 1) if !$params{'barcode_data'};
457
    $params{'barcode_data'} = ($self->{'barcode'} || _get_label_item($self->{'item_number'}, 1)) if !$params{'barcode_data'};
458
    $params{'barcode_type'} = $self->{'barcode_type'} if !$params{'barcode_type'};
458
    $params{'barcode_type'} = $self->{'barcode_type'} if !$params{'barcode_type'};
459
    my $x_scale_factor = 1;
459
    my $x_scale_factor = 1;
460
    my $num_of_bars = length($params{'barcode_data'});
460
    my $num_of_bars = length($params{'barcode_data'});
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/labels-toolbar.inc (+1 lines)
Lines 7-12 Link Here
7
            <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-layout.pl?op=new">Layout</a></li>
8
            <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-template.pl?op=new">Label template</a></li>
9
            <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-profile.pl?op=new">Printer profile</a></li>
10
            <li><a href="/cgi-bin/koha/labels/label-edit-range.pl">Barcode range</a></li>
10
        </ul>
11
        </ul>
11
    </div>
12
    </div>
12
    <div class="btn-group">
13
    <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 27-33 Link Here
27
                                    <p><a class="document csv" href="/cgi-bin/koha/labels/label-create-csv.pl?batch_id=[% batche.batch_id | html %]&amp;template_id=[% batche.template_id | html %]&amp;layout_id=[% batche.layout_id | html %][% batche.item_numbers | html %]">Download as CSV</a></p>
27
                                    <p><a class="document csv" href="/cgi-bin/koha/labels/label-create-csv.pl?batch_id=[% batche.batch_id | html %]&amp;template_id=[% batche.template_id | html %]&amp;layout_id=[% batche.layout_id | html %][% batche.item_numbers | html %]">Download as CSV</a></p>
28
28
29
                                    <p><a class="document xml" href="/cgi-bin/koha/labels/label-create-xml.pl?batch_id=[% batche.batch_id | html %]&amp;template_id=[% batche.template_id | html %]&amp;layout_id=[% batche.layout_id | html %][% batche.item_numbers | html %]">Download as XML</a></p>
29
                                    <p><a class="document xml" href="/cgi-bin/koha/labels/label-create-xml.pl?batch_id=[% batche.batch_id | html %]&amp;template_id=[% batche.template_id | html %]&amp;layout_id=[% batche.layout_id | html %][% batche.item_numbers | html %]">Download as XML</a></p>
30
                            [% ELSE %]
30
                            [% ELSIF ( batche.batch_id) %]
31
                            <legend>Label Batch Number [% batche.batch_id | html %]</legend>
31
                            <legend>Label Batch Number [% batche.batch_id | html %]</legend>
32
                                    <p><a class="document pdf" href="/cgi-bin/koha/labels/label-create-pdf.pl?batch_id=[% batche.batch_id | html %]&amp;template_id=[% batche.template_id | html %]&amp;layout_id=[% batche.layout_id | html %]&amp;start_label=[% batche.start_label | html %]">Download as PDF</a>
32
                                    <p><a class="document pdf" href="/cgi-bin/koha/labels/label-create-pdf.pl?batch_id=[% batche.batch_id | html %]&amp;template_id=[% batche.template_id | html %]&amp;layout_id=[% batche.layout_id | html %]&amp;start_label=[% batche.start_label | html %]">Download as PDF</a>
33
                                </p>
33
                                </p>
Lines 36-41 Link Here
36
                                </p>
36
                                </p>
37
                                <p>
37
                                <p>
38
                                    <a class="document xml" href="/cgi-bin/koha/labels/label-create-xml.pl?batch_id=[% batche.batch_id | html %]&amp;template_id=[% batche.template_id | html %]&amp;layout_id=[% batche.layout_id | html %]">Download as XML</a></p>
38
                                    <a class="document xml" href="/cgi-bin/koha/labels/label-create-xml.pl?batch_id=[% batche.batch_id | html %]&amp;template_id=[% batche.template_id | html %]&amp;layout_id=[% batche.layout_id | html %]">Download as XML</a></p>
39
                            [% ELSIF (batche.from && batche.to) %]
40
                            <legend>Barcodes from [% batche.from %] to [% batche.to %]</legend>
41
                            <p>
42
                                <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>
43
                            </p>
39
                            [% END %]
44
                            [% END %]
40
                        </fieldset>
45
                        </fieldset>
41
                        [% END %]
46
                        [% END %]
Lines 65-70 Link Here
65
                [% FOREACH item_number IN item_numbers %]
70
                [% FOREACH item_number IN item_numbers %]
66
                    <input type="hidden" name="item_number" value="[% item_number.item_number | html %]" />
71
                    <input type="hidden" name="item_number" value="[% item_number.item_number | html %]" />
67
                [% END %]
72
                [% END %]
73
                    <input type="hidden" name="from" value="[% from %]" />
74
                    <input type="hidden" name="to" value="[% to %]" />
68
                <fieldset class="rows">
75
                <fieldset class="rows">
69
                    <ol>
76
                    <ol>
70
                        <li>
77
                        <li>
(-)a/labels/label-create-pdf.pl (-2 / +8 lines)
Lines 46-56 my $layout_id = $cgi->param('layout_id') || undef; Link Here
46
my $start_label = $cgi->param('start_label') || 1;
46
my $start_label = $cgi->param('start_label') || 1;
47
@label_ids   = $cgi->multi_param('label_id') if $cgi->param('label_id');
47
@label_ids   = $cgi->multi_param('label_id') if $cgi->param('label_id');
48
@item_numbers  = $cgi->multi_param('item_number') if $cgi->param('item_number');
48
@item_numbers  = $cgi->multi_param('item_number') if $cgi->param('item_number');
49
my $from = $cgi->param('from') || undef;
50
my $to = $cgi->param('to') || undef;
49
51
50
my $items = undef;
52
my $items = undef;
51
53
52
53
54
my $pdf_file = (@label_ids || @item_numbers ? "label_single_" . scalar(@label_ids || @item_numbers) : "label_batch_$batch_id");
54
my $pdf_file = (@label_ids || @item_numbers ? "label_single_" . scalar(@label_ids || @item_numbers) : "label_batch_$batch_id");
55
print $cgi->header( -type       => 'application/pdf',
55
print $cgi->header( -type       => 'application/pdf',
56
                    -encoding   => 'utf-8',
56
                    -encoding   => 'utf-8',
Lines 118-123 elsif (@item_numbers) { Link Here
118
        push(@{$items}, {item_number => $_});
118
        push(@{$items}, {item_number => $_});
119
    } @item_numbers;
119
    } @item_numbers;
120
}
120
}
121
elsif ($from and $to) {
122
    for (my $i = $from; $i <= $to; $i++) {
123
        push @{$items}, {'item_number' => $i};
124
    }
125
}
121
else {
126
else {
122
    $items = $batch->get_attr('items');
127
    $items = $batch->get_attr('items');
123
}
128
}
Lines 198-203 foreach my $item (@{$items}) { Link Here
198
                                        text_wrap_cols      => $layout->get_text_wrap_cols(label_width => $template->get_attr('label_width'), left_text_margin => $template->get_attr('left_text_margin')),
203
                                        text_wrap_cols      => $layout->get_text_wrap_cols(label_width => $template->get_attr('label_width'), left_text_margin => $template->get_attr('left_text_margin')),
199
                                          );
204
                                          );
200
        $pdf->Add($label->draw_guide_box) if $layout->get_attr('guidebox');
205
        $pdf->Add($label->draw_guide_box) if $layout->get_attr('guidebox');
206
        $label->{'barcode'} = $item->{'item_number'} if ($from and $to);
201
        my $label_text = $label->create_label();
207
        my $label_text = $label->create_label();
202
        _print_text($label_text) if $label_text;
208
        _print_text($label_text) if $label_text;
203
        ($row_count, $col_count, $llx, $lly) = _calc_next_label_pos($row_count, $col_count, $llx, $lly);
209
        ($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 52-57 my @item_numbers; Link Here
52
my $output_format = $cgi->param('output_format') || 'pdf';
52
my $output_format = $cgi->param('output_format') || 'pdf';
53
my $referer = $cgi->param('referer') || undef;
53
my $referer = $cgi->param('referer') || undef;
54
54
55
my $from = $cgi->param('from') || undef;
56
my $to = $cgi->param('to') || undef;
57
55
my $layouts = undef;
58
my $layouts = undef;
56
my $templates = undef;
59
my $templates = undef;
57
my $output_formats = undef;
60
my $output_formats = undef;
Lines 106-111 if ($op eq 'export') { Link Here
106
                        referer     => $referer,
109
                        referer     => $referer,
107
                        );
110
                        );
108
    }
111
    }
112
    elsif ($from and $to) {
113
        push (@batches, {create_script   => 'label-create-pdf.pl',
114
                 from            => $from,
115
                 to              => $to,
116
                 template_id     => $template_id,
117
                 layout_id       => $layout_id,
118
                 start_label     => $start_label,
119
                 });
120
       $template->param(
121
                        batches     => \@batches,
122
                        referer     => $referer,
123
                        );
124
    }
109
}
125
}
110
elsif ($op eq 'none') {
126
elsif ($op eq 'none') {
111
    # setup select menus for selecting layout and template for this run...
127
    # setup select menus for selecting layout and template for this run...
Lines 128-133 elsif ($op eq 'none') { Link Here
128
                    label_count                 => $label_count,
144
                    label_count                 => $label_count,
129
                    item_count                  => $item_count,
145
                    item_count                  => $item_count,
130
                    referer                     => $referer,
146
                    referer                     => $referer,
147
                    from                        => $from,
148
                    to                          => $to
131
                    );
149
                    );
132
}
150
}
133
output_html_with_http_headers $cgi, $cookie, $template->output;
151
output_html_with_http_headers $cgi, $cookie, $template->output;
134
- 

Return to bug 7468