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

(-)a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss (-4 / +7 lines)
Lines 713-718 fieldset { Link Here
713
        }
713
        }
714
714
715
        li {
715
        li {
716
            margin-top: 1em;
717
718
            &:first-child {
719
                margin-top: 0;
720
            }
721
716
            &[aria-disabled="true"] {
722
            &[aria-disabled="true"] {
717
                color: #999;
723
                color: #999;
718
            }
724
            }
Lines 909-918 fieldset { Link Here
909
                    padding-left: 0;
915
                    padding-left: 0;
910
                }
916
                }
911
            }
917
            }
912
913
            legend {
914
                margin-bottom: 0;
915
            }
916
        }
918
        }
917
919
918
        ol {
920
        ol {
Lines 1038-1043 legend { Link Here
1038
    border-radius: 3px;
1040
    border-radius: 3px;
1039
    font-size: 123.1%;
1041
    font-size: 123.1%;
1040
    font-weight: bold;
1042
    font-weight: bold;
1043
    margin-bottom: 0;
1041
    padding: .2em .5em;
1044
    padding: .2em .5em;
1042
    width: auto;
1045
    width: auto;
1043
}
1046
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/tools-menu.inc (+1 lines)
Lines 73-78 Link Here
73
    [% IF ( CAN_user_tools_label_creator ) %]
73
    [% IF ( CAN_user_tools_label_creator ) %]
74
	<li><a href="/cgi-bin/koha/labels/label-home.pl">Label creator</a></li>
74
	<li><a href="/cgi-bin/koha/labels/label-home.pl">Label creator</a></li>
75
	<li><a href="/cgi-bin/koha/labels/spinelabel-home.pl">Quick spine label creator</a></li>
75
	<li><a href="/cgi-bin/koha/labels/spinelabel-home.pl">Quick spine label creator</a></li>
76
    <li><a href="/cgi-bin/koha/labels/barcode-print.pl">Barcode image generator</a></li>
76
    [% END %]
77
    [% END %]
77
    [% IF ( CAN_user_tools_rotating_collections ) %]
78
    [% IF ( CAN_user_tools_rotating_collections ) %]
78
    <li><a href="/cgi-bin/koha/rotating_collections/rotatingCollections.pl">Rotating collections</a></li>
79
    <li><a href="/cgi-bin/koha/rotating_collections/rotatingCollections.pl">Rotating collections</a></li>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/barcode-print.tt (+212 lines)
Line 0 Link Here
1
[% USE raw %]
2
[% USE Asset %]
3
[% SET footerjs = 1 %]
4
[% INCLUDE 'doc-head-open.inc' %]<title>Barcode image generator &rsaquo; Tools &rsaquo; Koha</title>
5
[% INCLUDE 'doc-head-close.inc' %]
6
[% Asset.css("css/humanmsg.css") | $raw %]
7
[% FILTER collapse %]
8
    <style>
9
        input[type='range'] {
10
            display: inline-block;
11
            width: auto;
12
        }
13
        #barcode_container {
14
            background-color:#FFF;
15
            min-height:200px;
16
            overflow: scroll;
17
            padding:2em;
18
            text-align:center;
19
        }
20
        #barcode_image {
21
            border:1px dashed #B9D8D9;
22
            display: block;
23
            margin: 1em auto;
24
            padding: 1em;
25
        }
26
        #modulesize_text {
27
            background-color: #FFF;
28
            border: 1px solid #EEE;
29
            border-radius: 2px;
30
            padding: .2em .4em;
31
        }
32
        #urltext {
33
            border:1px solid #B9D8D9;
34
            border-radius:2px;
35
            margin:1em 0;
36
            padding:.5em;
37
        }
38
    </style>
39
[% END %]
40
</head>
41
42
<body id="labels_spinelabel-home" class="tools labels">
43
[% INCLUDE 'header.inc' %]
44
[% INCLUDE 'cat-search.inc' %]
45
46
<nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
47
    <ol>
48
        <li>
49
            <a href="/cgi-bin/koha/mainpage.pl">Home</a>
50
        </li>
51
        <li>
52
            <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
53
        </li>
54
        <li>
55
            <a href="#" aria-current="page">
56
                Barcode image generator
57
            </a>
58
        </li>
59
    </ol>
60
</nav>
61
62
<div class="main container-fluid">
63
    <div class="row">
64
        <div class="col-sm-10 col-sm-push-2">
65
            <main>
66
                <h2>Barcode image generator</h2>
67
68
                <form action="/cgi-bin/koha/svc/barcode" method="post" id="barcodegen">
69
                    <fieldset class="brief">
70
                        <div class="row">
71
                            <div class="col-sm-6">
72
                                <ol>
73
                                    <li>
74
                                        <label for="type">Barcode type:</label>
75
                                        <select name="type" id="type">
76
                                            <option value="Code39">Code39</option>
77
                                            <option value="COOP2of5">COOP2of5</option>
78
                                            <option value="EAN13">EAN13</option>
79
                                            <option value="EAN8">EAN8</option>
80
                                            <option value="IATA2of5">IATA2of5</option>
81
                                            <option value="Industrial2of5">Industrial2of5</option>
82
                                            <option value="ITF">ITF</option>
83
                                            <option value="Matrix2of5">Matrix2of5</option>
84
                                            <option value="NW7">NW7</option>
85
                                            <option value="QRcode">QRcode</option>
86
                                            <option value="UPCA">UPCA</option>
87
                                            <option value="UPCE">UPCE</option>
88
                                        </select>
89
                                    </li>
90
                                    <li class="qrcode">
91
                                        <label for="modulesize">QR Code module size:</label>
92
                                        <input name="modulesize" id="modulesize" type="range" min="1" max="10" value="3" />
93
                                        <span id="modulesize_text">3</span>
94
                                        <div class="hint">Module size refers to the pixel dimensions of each black or white square in the generated QR code.</div>
95
                                    </li>
96
                                    <li class="bcode">
97
                                        <label for="notext">Hide text <input type="checkbox" id="notext" name="notext" value="1" /></label>
98
                                    </li>
99
                                    <li class="bcode">
100
                                        <label for="height">Barcode height:</label>
101
                                        <input type="text" id="height" name="height" value="50" />
102
                                    </li>
103
                                    <li>
104
                                        <label class="bcode" for="barcode">Barcode: </label>
105
                                        <label class="qrcode" for="barcode">Text, URL, or barcode, etc: </label>
106
                                        <input type="text" name="barcode" id="barcode" size="50" />
107
                                        <div class="hint qrcode">Actual dimensions of the QR code depend on the amount of characters being encoded.</div>
108
                                        <div class="hint bcode">Barcode text must be numeric (0-9)</div>
109
                                    </li>
110
                                </ol>
111
                                <fieldset class="action">
112
                                    <input type="submit" value="Show barcode" />
113
                                </fieldset>
114
                            </div>
115
                            <div class="col-sm-6">
116
                                <div id="barcode_container">
117
                                    <img id="barcode_image" />
118
                                    <textarea readonly="readonly" rows="5" cols="40" id="urltext"></textarea>
119
                                </div>
120
                            </div>
121
                        </div>
122
                    </fieldset>
123
                </form>
124
            </main>
125
        </div> <!-- /.col-sm-10.col-sm-push-2 -->
126
127
        <div class="col-sm-2 col-sm-pull-10">
128
            <aside>
129
                [% INCLUDE 'tools-menu.inc' %]
130
            </aside>
131
        </div> <!-- /.col-sm-2.col-sm-pull-10 -->
132
     </div> <!-- /.row -->
133
134
[% MACRO jsinclude BLOCK %]
135
    [% Asset.js("js/tools-menu.js") | $raw %]
136
    [% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %]
137
    <script>
138
        var base_url = "[% Koha.Preference('staffClientBaseURL') | html %]";
139
140
        function showBarcodeText( path, dimensions ){
141
            var params = new URLSearchParams( path );
142
            var tag = '<img src="' + path + '" alt="' + params.get("barcode") + '" width="' + dimensions.width + '" height="' + dimensions.height + '" />';
143
            $("#urltext").show().text( tag );
144
            if( Number( dimensions.width  ) > 250 ){
145
                $("#urltext").css("width", dimensions.width )
146
            }
147
        }
148
149
        function showBarcode( barcodeform ){
150
            if( $("#barcode").val() == "" ){
151
                $("#barcode_container").hide();
152
            } else {
153
                var url = barcodeform.attr("action");
154
                var params = barcodeform.serialize();
155
                $("#barcode_container").show();
156
                $("#barcode_image").attr("src", url + "?" + params );
157
            }
158
        }
159
160
        function showQrcodeOptions( type ){
161
            if( type.val() == "QRcode" ){
162
                $(".qrcode").show().find("input,range").prop("disabled", false );
163
                $(".bcode").hide().find("input").prop("disabled", true );
164
            } else {
165
                $(".qrcode").hide().find("input,range").prop("disabled", true );
166
                $(".bcode").show().find("input").prop("disabled", false );
167
            }
168
        }
169
        $(document).ready(function(){
170
            showQrcodeOptions( $("#type") );
171
            showBarcode( $("#barcodegen") );
172
            $("#type").on("change", function(){
173
                showQrcodeOptions( $(this) );
174
            })
175
            $("#barcodegen").on("change submit", function(e){
176
                e.preventDefault();
177
                showBarcode( $(this) );
178
            });
179
            $("#modulesize").on("input", function(){
180
                $("#modulesize_text").text( $(this).val() );
181
            });
182
            $("#urltext").on("click", function(){
183
                $(this).select();
184
                var text = $(this).text();
185
                navigator.clipboard.writeText( text ).then(function() {
186
                    /* clipboard successfully set */
187
                    humanMsg.displayAlert( _("HTML copied to the clipboard") );
188
                }, function() {
189
                    /* clipboard write failed */
190
                    humanMsg.displayAlert( _("Could not copy HTML automatically to the clipboard") );
191
                });
192
            });
193
            $("#barcode_image")[0].onload = function (){
194
                showBarcodeText( this.src, { width: this.width, height: this.height } );
195
            }
196
            $("#barcode_image")[0].onerror = function(){
197
                var barcodetype = $("#type").val();
198
                if( barcodetype !== "QRcode" ){
199
                    if( Number.isNaN( Number( $("#barcode").val() ) ) ){
200
                        humanMsg.displayAlert( _("Barcodes of type %s must be numeric").format( barcodetype ) );
201
                    } else {
202
                        humanMsg.displayAlert( _("There was an unknown error generating the barcode image. Please check that your barcode is correct for the barcode type" ) );
203
                    }
204
                } else {
205
                    humanMsg.displayAlert( _("There was an unknown error generating the barcode image") );
206
                }
207
            }
208
        });
209
    </script>
210
[% END %]
211
212
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt (-1 / +6 lines)
Lines 224-230 Link Here
224
    <dt><a href="/cgi-bin/koha/labels/label-home.pl">Label creator</a></dt>
224
    <dt><a href="/cgi-bin/koha/labels/label-home.pl">Label creator</a></dt>
225
    <dd>Create printable labels and barcodes from catalog data</dd>
225
    <dd>Create printable labels and barcodes from catalog data</dd>
226
    [% END %]
226
    [% END %]
227
    
227
228
    [% IF ( CAN_user_tools_label_creator ) %]
229
    <dt><a href="/cgi-bin/koha/labels/barcode-print.pl">Barcode image generator</a></dt>
230
    <dd>Configure and create barcodes of various types to be output as an image</dd>
231
    [% END %]
232
228
    [% IF ( CAN_user_tools_label_creator ) %]
233
    [% IF ( CAN_user_tools_label_creator ) %]
229
    <dt><a href="/cgi-bin/koha/labels/spinelabel-home.pl">Quick spine label creator</a></dt>
234
    <dt><a href="/cgi-bin/koha/labels/spinelabel-home.pl">Quick spine label creator</a></dt>
230
    <dd>Enter a barcode to generate a printable spine label. For use with dedicated label printers</dd>
235
    <dd>Enter a barcode to generate a printable spine label. For use with dedicated label printers</dd>
(-)a/koha-tmpl/intranet-tmpl/prog/js/tools-menu.js (-1 / +1 lines)
Lines 1-6 Link Here
1
  $(document).ready(function() {
1
  $(document).ready(function() {
2
      var path = location.pathname.substring(1);
2
      var path = location.pathname.substring(1);
3
      if (path.indexOf("labels") >= 0 && path.indexOf("spine") < 0 ) {
3
      if (path.indexOf("labels") >= 0 && path.indexOf("spine") < 0 && path.indexOf("barcode") < 0 ) {
4
        $('#navmenulist a[href$="/cgi-bin/koha/labels/label-home.pl"]').addClass("current");
4
        $('#navmenulist a[href$="/cgi-bin/koha/labels/label-home.pl"]').addClass("current");
5
      } else if (path.indexOf("patroncards") >= 0 ) {
5
      } else if (path.indexOf("patroncards") >= 0 ) {
6
        $('#navmenulist a[href$="/cgi-bin/koha/patroncards/home.pl"]').addClass("current");
6
        $('#navmenulist a[href$="/cgi-bin/koha/patroncards/home.pl"]').addClass("current");
(-)a/labels/barcode-print.pl (-1 / +33 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
use CGI qw ( -utf8 );
20
use C4::Auth qw( get_template_and_user );
21
use C4::Output qw( output_html_with_http_headers );
22
use C4::Context;
23
24
my $query = CGI->new;
25
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
26
    {   template_name   => "labels/barcode-print.tt",
27
        query           => $query,
28
        type            => "intranet",
29
        flagsrequired   => { catalogue => 1 },
30
    }
31
);
32
33
output_html_with_http_headers $query, $cookie, $template->output;

Return to bug 29821