Bug 30952: Staff interface redesign (header)
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / labels / barcode-print.tt
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 [% WRAPPER 'header.inc' %]
44     [% INCLUDE 'cat-search.inc' %]
45 [% END %]
46
47 [% WRAPPER 'sub-header.inc' %]
48 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
49     <ol>
50         <li>
51             <a href="/cgi-bin/koha/mainpage.pl"><i class="fa fa-home"></i></a>
52         </li>
53         <li>
54             <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
55         </li>
56         <li>
57             <a href="#" aria-current="page">
58                 Barcode image generator
59             </a>
60         </li>
61     </ol>
62 </nav>
63 [% END %]
64
65 <div class="main container-fluid">
66     <div class="row">
67         <div class="col-sm-10 col-sm-push-2">
68             <main>
69                 <h2>Barcode image generator</h2>
70
71                 <form action="/cgi-bin/koha/svc/barcode" method="post" id="barcodegen">
72                     <fieldset class="brief">
73                         <div class="row">
74                             <div class="col-sm-6">
75                                 <ol>
76                                     <li>
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>
91                                         </select>
92                                     </li>
93                                     <li class="qrcode">
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>
98                                     </li>
99                                     <li class="bcode">
100                                         <label for="notext">Hide text <input type="checkbox" id="notext" name="notext" value="1" /></label>
101                                     </li>
102                                     <li class="bcode">
103                                         <label for="height">Barcode height:</label>
104                                         <input type="text" id="height" name="height" value="50" />
105                                     </li>
106                                     <li>
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>
112                                     </li>
113                                 </ol>
114                                 <fieldset class="action">
115                                     <input type="submit" value="Show barcode" />
116                                 </fieldset>
117                             </div>
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>
122                                 </div>
123                             </div>
124                         </div>
125                     </fieldset>
126                 </form>
127             </main>
128         </div> <!-- /.col-sm-10.col-sm-push-2 -->
129
130         <div class="col-sm-2 col-sm-pull-10">
131             <aside>
132                 [% INCLUDE 'tools-menu.inc' %]
133             </aside>
134         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
135      </div> <!-- /.row -->
136
137 [% MACRO jsinclude BLOCK %]
138     [% Asset.js("js/tools-menu.js") | $raw %]
139     [% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %]
140     <script>
141         var base_url = "[% Koha.Preference('staffClientBaseURL') | html %]";
142
143         function showBarcodeText( path, dimensions ){
144             var params = new URLSearchParams( path );
145             var tag = '<img src="' + path + '" alt="' + params.get("barcode") + '" width="' + dimensions.width + '" height="' + dimensions.height + '" />';
146             $("#urltext").show().text( tag );
147             if( Number( dimensions.width  ) > 250 ){
148                 $("#urltext").css("width", dimensions.width )
149             }
150         }
151
152         function showBarcode( barcodeform ){
153             if( $("#barcode").val() == "" ){
154                 $("#barcode_container").hide();
155             } else {
156                 var url = barcodeform.attr("action");
157                 var params = barcodeform.serialize();
158                 $("#barcode_container").show();
159                 $("#barcode_image").attr("src", url + "?" + params );
160             }
161         }
162
163         function showQrcodeOptions( type ){
164             if( type.val() == "QRcode" ){
165                 $(".qrcode").show().find("input,range").prop("disabled", false );
166                 $(".bcode").hide().find("input").prop("disabled", true );
167             } else {
168                 $(".qrcode").hide().find("input,range").prop("disabled", true );
169                 $(".bcode").show().find("input").prop("disabled", false );
170             }
171         }
172         $(document).ready(function(){
173             showQrcodeOptions( $("#type") );
174             showBarcode( $("#barcodegen") );
175             $("#type").on("change", function(){
176                 showQrcodeOptions( $(this) );
177             })
178             $("#barcodegen").on("change submit", function(e){
179                 e.preventDefault();
180                 showBarcode( $(this) );
181             });
182             $("#modulesize").on("input", function(){
183                 $("#modulesize_text").text( $(this).val() );
184             });
185             $("#urltext").on("click", function(){
186                 $(this).select();
187                 var text = $(this).text();
188                 navigator.clipboard.writeText( text ).then(function() {
189                     /* clipboard successfully set */
190                     humanMsg.displayAlert( _("HTML copied to the clipboard") );
191                 }, function() {
192                     /* clipboard write failed */
193                     humanMsg.displayAlert( _("Could not copy HTML automatically to the clipboard") );
194                 });
195             });
196             $("#barcode_image")[0].onload = function (){
197                 showBarcodeText( this.src, { width: this.width, height: this.height } );
198             }
199             $("#barcode_image")[0].onerror = function(){
200                 var barcodetype = $("#type").val();
201                 if( barcodetype !== "QRcode" ){
202                     if( Number.isNaN( Number( $("#barcode").val() ) ) ){
203                         humanMsg.displayAlert( _("Barcodes of type %s must be numeric").format( barcodetype ) );
204                     } else {
205                         humanMsg.displayAlert( _("There was an unknown error generating the barcode image. Please check that your barcode is correct for the barcode type" ) );
206                     }
207                 } else {
208                     humanMsg.displayAlert( _("There was an unknown error generating the barcode image") );
209                 }
210             }
211         });
212     </script>
213 [% END %]
214
215 [% INCLUDE 'intranet-bottom.inc' %]