Bug 33384: Use template wrapper for breadcrumbs: Labels
[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; Cataloging &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     [% WRAPPER breadcrumbs %]
49         [% WRAPPER breadcrumb_item %]
50             <a href="/cgi-bin/koha/cataloguing/cataloging-home.pl">Cataloging</a>
51         [% END %]
52         [% WRAPPER breadcrumb_item bc_active= 1 %]
53             <span>Barcode image generator</span>
54         [% END %]
55     [% END #/ WRAPPER breadcrumbs %]
56 [% END #/ WRAPPER sub-header.inc %]
57
58 <div class="main container-fluid">
59     <div class="row">
60         <div class="col-sm-10 col-sm-push-2">
61             <main>
62                 <h2>Barcode image generator</h2>
63
64                 <form action="/cgi-bin/koha/svc/barcode" method="post" id="barcodegen">
65                     <fieldset class="brief">
66                         <div class="row">
67                             <div class="col-sm-6">
68                                 <ol>
69                                     <li>
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>
84                                         </select>
85                                     </li>
86                                     <li class="qrcode">
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>
91                                     </li>
92                                     <li class="bcode">
93                                         <label for="notext">Hide text <input type="checkbox" id="notext" name="notext" value="1" /></label>
94                                     </li>
95                                     <li class="bcode">
96                                         <label for="height">Barcode height:</label>
97                                         <input type="text" id="height" name="height" value="50" />
98                                     </li>
99                                     <li>
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>
105                                     </li>
106                                 </ol>
107                                 <fieldset class="action">
108                                     <input type="submit" class="btn btn-primary" value="Show barcode" />
109                                 </fieldset>
110                             </div>
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>
115                                 </div>
116                             </div>
117                         </div>
118                     </fieldset>
119                 </form>
120             </main>
121         </div> <!-- /.col-sm-10.col-sm-push-2 -->
122
123         <div class="col-sm-2 col-sm-pull-10">
124             <aside>
125                 [% INCLUDE 'cat-menu.inc' %]
126             </aside>
127         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
128      </div> <!-- /.row -->
129
130 [% MACRO jsinclude BLOCK %]
131     [% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %]
132     <script>
133         var base_url = "[% Koha.Preference('staffClientBaseURL') | html %]";
134
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 )
141             }
142         }
143
144         function showBarcode( barcodeform ){
145             if( $("#barcode").val() == "" ){
146                 $("#barcode_container").hide();
147             } else {
148                 var url = barcodeform.attr("action");
149                 var params = barcodeform.serialize();
150                 $("#barcode_container").show();
151                 $("#barcode_image").attr("src", url + "?" + params );
152             }
153         }
154
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 );
159             } else {
160                 $(".qrcode").hide().find("input,range").prop("disabled", true );
161                 $(".bcode").show().find("input").prop("disabled", false );
162             }
163         }
164         $(document).ready(function(){
165             showQrcodeOptions( $("#type") );
166             showBarcode( $("#barcodegen") );
167             $("#type").on("change", function(){
168                 showQrcodeOptions( $(this) );
169             })
170             $("#barcodegen").on("change submit", function(e){
171                 e.preventDefault();
172                 showBarcode( $(this) );
173             });
174             $("#modulesize").on("input", function(){
175                 $("#modulesize_text").text( $(this).val() );
176             });
177             $("#urltext").on("click", function(){
178                 $(this).select();
179                 var text = $(this).text();
180                 navigator.clipboard.writeText( text ).then(function() {
181                     /* clipboard successfully set */
182                     humanMsg.displayAlert( _("HTML copied to the clipboard") );
183                 }, function() {
184                     /* clipboard write failed */
185                     humanMsg.displayAlert( _("Could not copy HTML automatically to the clipboard") );
186                 });
187             });
188             $("#barcode_image")[0].onload = function (){
189                 showBarcodeText( this.src, { width: this.width, height: this.height } );
190             }
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 ) );
196                     } else {
197                         humanMsg.displayAlert( _("There was an unknown error generating the barcode image. Please check that your barcode is correct for the barcode type" ) );
198                     }
199                 } else {
200                     humanMsg.displayAlert( _("There was an unknown error generating the barcode image") );
201                 }
202             }
203         });
204     </script>
205 [% END %]
206
207 [% INCLUDE 'intranet-bottom.inc' %]