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 [% WRAPPER breadcrumbs %]
49 [% WRAPPER breadcrumb_item %]
50 <a href="/cgi-bin/koha/cataloguing/cataloging-home.pl">Cataloging</a>
52 [% WRAPPER breadcrumb_item bc_active= 1 %]
53 <span>Barcode image generator</span>
55 [% END #/ WRAPPER breadcrumbs %]
56 [% END #/ WRAPPER sub-header.inc %]
58 <div class="main container-fluid">
60 <div class="col-sm-10 col-sm-push-2">
62 <h2>Barcode image generator</h2>
64 <form action="/cgi-bin/koha/svc/barcode" method="post" id="barcodegen">
65 <fieldset class="brief">
67 <div class="col-sm-6">
70 <label for="type">Barcode type:</label>
71 <select name="type" id="type">
72 <option value="Code39">Code39</option>
73 <option value="COOP2of5">COOP2of5</option>
74 <option value="EAN13">EAN13</option>
75 <option value="EAN8">EAN8</option>
76 <option value="IATA2of5">IATA2of5</option>
77 <option value="Industrial2of5">Industrial2of5</option>
78 <option value="ITF">ITF</option>
79 <option value="Matrix2of5">Matrix2of5</option>
80 <option value="NW7">NW7</option>
81 <option value="QRcode">QRcode</option>
82 <option value="UPCA">UPCA</option>
83 <option value="UPCE">UPCE</option>
87 <label for="modulesize">QR Code module size:</label>
88 <input name="modulesize" id="modulesize" type="range" min="1" max="10" value="3" />
89 <span id="modulesize_text">3</span>
90 <div class="hint">Module size refers to the pixel dimensions of each black or white square in the generated QR code.</div>
93 <label for="notext">Hide text <input type="checkbox" id="notext" name="notext" value="1" /></label>
96 <label for="height">Barcode height:</label>
97 <input type="text" id="height" name="height" value="50" />
100 <label class="bcode" for="barcode">Barcode: </label>
101 <label class="qrcode" for="barcode">Text, URL, or barcode, etc: </label>
102 <input type="text" name="barcode" id="barcode" size="50" />
103 <div class="hint qrcode">Actual dimensions of the QR code depend on the amount of characters being encoded.</div>
104 <div class="hint bcode">Barcode text must be numeric (0-9)</div>
107 <fieldset class="action">
108 <input type="submit" class="btn btn-primary" value="Show barcode" />
111 <div class="col-sm-6">
112 <div id="barcode_container">
113 <img id="barcode_image" />
114 <textarea readonly="readonly" rows="5" cols="40" id="urltext"></textarea>
121 </div> <!-- /.col-sm-10.col-sm-push-2 -->
123 <div class="col-sm-2 col-sm-pull-10">
125 [% INCLUDE 'cat-menu.inc' %]
127 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
128 </div> <!-- /.row -->
130 [% MACRO jsinclude BLOCK %]
131 [% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %]
133 var base_url = "[% Koha.Preference('staffClientBaseURL') | html %]";
135 function showBarcodeText( path, dimensions ){
136 var params = new URLSearchParams( path );
137 var tag = '<img src="' + path + '" alt="' + params.get("barcode") + '" width="' + dimensions.width + '" height="' + dimensions.height + '" />';
138 $("#urltext").show().text( tag );
139 if( Number( dimensions.width ) > 250 ){
140 $("#urltext").css("width", dimensions.width )
144 function showBarcode( barcodeform ){
145 if( $("#barcode").val() == "" ){
146 $("#barcode_container").hide();
148 var url = barcodeform.attr("action");
149 var params = barcodeform.serialize();
150 $("#barcode_container").show();
151 $("#barcode_image").attr("src", url + "?" + params );
155 function showQrcodeOptions( type ){
156 if( type.val() == "QRcode" ){
157 $(".qrcode").show().find("input,range").prop("disabled", false );
158 $(".bcode").hide().find("input").prop("disabled", true );
160 $(".qrcode").hide().find("input,range").prop("disabled", true );
161 $(".bcode").show().find("input").prop("disabled", false );
164 $(document).ready(function(){
165 showQrcodeOptions( $("#type") );
166 showBarcode( $("#barcodegen") );
167 $("#type").on("change", function(){
168 showQrcodeOptions( $(this) );
170 $("#barcodegen").on("change submit", function(e){
172 showBarcode( $(this) );
174 $("#modulesize").on("input", function(){
175 $("#modulesize_text").text( $(this).val() );
177 $("#urltext").on("click", function(){
179 var text = $(this).text();
180 navigator.clipboard.writeText( text ).then(function() {
181 /* clipboard successfully set */
182 humanMsg.displayAlert( _("HTML copied to the clipboard") );
184 /* clipboard write failed */
185 humanMsg.displayAlert( _("Could not copy HTML automatically to the clipboard") );
188 $("#barcode_image")[0].onload = function (){
189 showBarcodeText( this.src, { width: this.width, height: this.height } );
191 $("#barcode_image")[0].onerror = function(){
192 var barcodetype = $("#type").val();
193 if( barcodetype !== "QRcode" ){
194 if( Number.isNaN( Number( $("#barcode").val() ) ) ){
195 humanMsg.displayAlert( _("Barcodes of type %s must be numeric").format( barcodetype ) );
197 humanMsg.displayAlert( _("There was an unknown error generating the barcode image. Please check that your barcode is correct for the barcode type" ) );
200 humanMsg.displayAlert( _("There was an unknown error generating the barcode image") );
207 [% INCLUDE 'intranet-bottom.inc' %]