|
Line 0
Link Here
|
|
|
1 |
[% USE raw %] |
| 2 |
[% USE Asset %] |
| 3 |
[% SET footerjs = 1 %] |
| 4 |
[% INCLUDE 'doc-head-open.inc' %]<title>Barcode image generator › Tools › 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' %] |