4 [% INCLUDE 'doc-head-open.inc' %]<title>Barcode image generator › Cataloging › Koha</title>
5 [% INCLUDE 'doc-head-close.inc' %]
6 [% Asset.css("css/humanmsg.css") | $raw %]
10 display: inline-block;
14 background-color:#FFF;
21 border:1px dashed #B9D8D9;
27 background-color: #FFF;
28 border: 1px solid #EEE;
33 border:1px solid #B9D8D9;
42 <body id="labels_spinelabel-home" class="tools labels">
43 [% WRAPPER 'header.inc' %]
44 [% INCLUDE 'cat-search.inc' %]
47 [% WRAPPER 'sub-header.inc' %]
48 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
51 <a href="/cgi-bin/koha/mainpage.pl">Home</a>
54 <a href="/cgi-bin/koha/cataloguing/cataloging-home.pl">Cataloging</a>
57 <a href="#" aria-current="page">
58 Barcode image generator
65 <div class="main container-fluid">
67 <div class="col-sm-10 col-sm-push-2">
69 <h2>Barcode image generator</h2>
71 <form action="/cgi-bin/koha/svc/barcode" method="post" id="barcodegen">
72 <fieldset class="brief">
74 <div class="col-sm-6">
77 <label for="type">Barcode type:</label>
78 <select name="type" id="type">
79 <option value="Code39">Code39</option>
80 <option value="COOP2of5">COOP2of5</option>
81 <option value="EAN13">EAN13</option>
82 <option value="EAN8">EAN8</option>
83 <option value="IATA2of5">IATA2of5</option>
84 <option value="Industrial2of5">Industrial2of5</option>
85 <option value="ITF">ITF</option>
86 <option value="Matrix2of5">Matrix2of5</option>
87 <option value="NW7">NW7</option>
88 <option value="QRcode">QRcode</option>
89 <option value="UPCA">UPCA</option>
90 <option value="UPCE">UPCE</option>
94 <label for="modulesize">QR Code module size:</label>
95 <input name="modulesize" id="modulesize" type="range" min="1" max="10" value="3" />
96 <span id="modulesize_text">3</span>
97 <div class="hint">Module size refers to the pixel dimensions of each black or white square in the generated QR code.</div>
100 <label for="notext">Hide text <input type="checkbox" id="notext" name="notext" value="1" /></label>
103 <label for="height">Barcode height:</label>
104 <input type="text" id="height" name="height" value="50" />
107 <label class="bcode" for="barcode">Barcode: </label>
108 <label class="qrcode" for="barcode">Text, URL, or barcode, etc: </label>
109 <input type="text" name="barcode" id="barcode" size="50" />
110 <div class="hint qrcode">Actual dimensions of the QR code depend on the amount of characters being encoded.</div>
111 <div class="hint bcode">Barcode text must be numeric (0-9)</div>
114 <fieldset class="action">
115 <input type="submit" value="Show barcode" />
118 <div class="col-sm-6">
119 <div id="barcode_container">
120 <img id="barcode_image" />
121 <textarea readonly="readonly" rows="5" cols="40" id="urltext"></textarea>
128 </div> <!-- /.col-sm-10.col-sm-push-2 -->
130 <div class="col-sm-2 col-sm-pull-10">
132 [% INCLUDE 'cat-menu.inc' %]
134 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
135 </div> <!-- /.row -->
137 [% MACRO jsinclude BLOCK %]
138 [% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %]
140 var base_url = "[% Koha.Preference('staffClientBaseURL') | html %]";
142 function showBarcodeText( path, dimensions ){
143 var params = new URLSearchParams( path );
144 var tag = '<img src="' + path + '" alt="' + params.get("barcode") + '" width="' + dimensions.width + '" height="' + dimensions.height + '" />';
145 $("#urltext").show().text( tag );
146 if( Number( dimensions.width ) > 250 ){
147 $("#urltext").css("width", dimensions.width )
151 function showBarcode( barcodeform ){
152 if( $("#barcode").val() == "" ){
153 $("#barcode_container").hide();
155 var url = barcodeform.attr("action");
156 var params = barcodeform.serialize();
157 $("#barcode_container").show();
158 $("#barcode_image").attr("src", url + "?" + params );
162 function showQrcodeOptions( type ){
163 if( type.val() == "QRcode" ){
164 $(".qrcode").show().find("input,range").prop("disabled", false );
165 $(".bcode").hide().find("input").prop("disabled", true );
167 $(".qrcode").hide().find("input,range").prop("disabled", true );
168 $(".bcode").show().find("input").prop("disabled", false );
171 $(document).ready(function(){
172 showQrcodeOptions( $("#type") );
173 showBarcode( $("#barcodegen") );
174 $("#type").on("change", function(){
175 showQrcodeOptions( $(this) );
177 $("#barcodegen").on("change submit", function(e){
179 showBarcode( $(this) );
181 $("#modulesize").on("input", function(){
182 $("#modulesize_text").text( $(this).val() );
184 $("#urltext").on("click", function(){
186 var text = $(this).text();
187 navigator.clipboard.writeText( text ).then(function() {
188 /* clipboard successfully set */
189 humanMsg.displayAlert( _("HTML copied to the clipboard") );
191 /* clipboard write failed */
192 humanMsg.displayAlert( _("Could not copy HTML automatically to the clipboard") );
195 $("#barcode_image")[0].onload = function (){
196 showBarcodeText( this.src, { width: this.width, height: this.height } );
198 $("#barcode_image")[0].onerror = function(){
199 var barcodetype = $("#type").val();
200 if( barcodetype !== "QRcode" ){
201 if( Number.isNaN( Number( $("#barcode").val() ) ) ){
202 humanMsg.displayAlert( _("Barcodes of type %s must be numeric").format( barcodetype ) );
204 humanMsg.displayAlert( _("There was an unknown error generating the barcode image. Please check that your barcode is correct for the barcode type" ) );
207 humanMsg.displayAlert( _("There was an unknown error generating the barcode image") );
214 [% INCLUDE 'intranet-bottom.inc' %]