Bug 19458: Self-check module highlighting
[koha.git] / koha-tmpl / opac-tmpl / bootstrap / en / modules / sco / sco-main.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Koha %]
4 [% USE KohaDates %]
5 [% USE AudioAlerts %]
6 [% USE Price %]
7 [% INCLUDE 'doc-head-open.inc' %]
8 <title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha [% END %] &rsaquo; Self checkout </title>
9 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
10 <meta name="generator" content="Koha [% Version | html %]" /> <!-- leave this for stats -->
11 <link rel="shortcut icon" href="[% IF ( Koha.Preference('OpacFavicon') ) %][% Koha.Preference('OpacFavicon') | url %][% ELSE %][% interface | html %]/[% theme | html %]/images/favicon.ico[% END %]" type="image/x-icon" />
12 [% Asset.css("lib/bootstrap/css/bootstrap.min.css") | $raw %]
13 [% Asset.css("lib/jquery/jquery-ui.css") | $raw %]
14 [% Asset.css("css/sco.css") | $raw %]
15 [% IF ( Koha.Preference('OPACUserCSS') ) %]<style>[% Koha.Preference('OPACUserCSS') | $raw %]</style>[% END %]
16 [% IF ( Koha.Preference('SCOUserCSS') ) %]<style>[% Koha.Preference('SCOUserCSS') | $raw %]</style>[% END %]
17 <!--[if lt IE 9]>
18     <script src="[% interface | html %]/[% theme | html %]/lib/respond.min.js"></script>
19 <![endif]-->
20 <script>
21     function _(s) { return s } // dummy function for gettext
22 </script>
23 [% Asset.js("lib/modernizr.min.js") | $raw %]
24 </head>
25 <body id="sco_main" class="sco" onload="dofocus();" onunload="mungeHistory();">
26 [% INCLUDE 'masthead-sco.inc' %]
27
28     <div class="main">
29         <div class="container-fluid">
30             <div class="row-fluid">
31                 [% IF ( display_patron_image ) %]
32                     <div class="span10">
33                 [% ELSE %]
34                     <div class="span12">
35                 [% END %]
36
37                     <div id="masthead"><h1>[% LibraryName | html %] Self checkout system</h1></div>
38
39                     [% IF ( impossible ) %]<!-- We tried to issue, but failed. -->
40                         <div class="alert">
41                             <h3>Item cannot be checked out.</h3>
42                             <p>Sorry, this item cannot be checked out at this station.</p>
43                             [% IF ( title ) %]
44                                 <p>Title: <em>[% title | html %]</em> </p>
45                             [% END %]
46
47                             <p>
48                                 [% IF ( circ_error_UNKNOWN_BARCODE ) %]
49                                     The system does not recognize this barcode.
50                                 [% ELSIF ( circ_error_max_loans_allowed ) %]
51                                     You have checked out too many items and can't check out any more.
52                                 [% ELSIF ( circ_error_ISSUED_TO_ANOTHER ) %]
53                                     This item is checked out to someone else.
54                                 [% ELSIF ( circ_error_NO_MORE_RENEWALS ) %]
55                                     You cannot renew this item again.
56                                 [% ELSIF ( circ_error_NOT_FOR_LOAN ) %]
57                                     This item is not for loan.
58                                 [% ELSIF ( circ_error_DEBT ) %]
59                                     You owe the library [% DEBT | $Price %] and cannot check out.
60                                 [% ELSIF ( circ_error_WTHDRAWN ) %]
61                                     This item has been withdrawn from the collection.
62                                 [% ELSIF ( circ_error_RESTRICTED ) %]
63                                     This item is restricted.
64                                 [% ELSIF ( circ_error_RESERVED ) %]
65                                     This item is on hold for another patron.
66                                 [% ELSIF ( circ_error_ITEMNOTSAMEBRANCH ) %]
67                                     This item belongs to another branch.
68                                 [% ELSIF ( circ_error_EXPIRED ) %]
69                                     Your account has expired.
70                                 [% ELSIF ( circ_error_DEBARRED ) %]
71                                     Your account has been suspended.
72                                 [% ELSIF ( circ_error_CARD_LOST ) %]
73                                     This card has been declared lost.
74                                 [% ELSIF ( circ_error_GNA ) %]
75                                     Your contact information seems to be incomplete.
76                                 [% ELSIF ( circ_error_INVALID_DATE ) %]
77                                     Due date is not valid.
78                                 [% END %]
79                                 Please see a member of the library staff.
80                             </p>
81
82                             [% IF ( returnitem && Koha.Preference('AllowSelfCheckReturns') ) %]
83                                 <form action="/cgi-bin/koha/sco/sco-main.pl" name="errorForm" class="inline" method="post">
84                                     <input type="hidden" name="op" value="returnbook" />
85                                     <input type="hidden" name="patronid" value="[% patronid | html %]" />
86                                     <input type="hidden" name="barcode" value="[% barcode | html %]" />
87                                     <button type="submit" name="returnbook" class="btn"><i class="return"></i> Return this item</button>
88                                 </form>
89                             [% END %]
90
91                             <form action="/cgi-bin/koha/sco/sco-main.pl" name="errorForm" class="inline" method="post">
92                                 <input type="hidden" name="op" value="" />
93                                 <input type="hidden" name="patronid" value="[% patronid | html %]" />
94                                 <input type="hidden" name="barcode" value="[% barcode | html %]" />
95                                 <input type="submit" name= "confirm" value="Return to account summary" class="btn back focus" />
96                             </form>
97                         </div> <!-- / .alert -->
98                     [% END # / IF ( impossible %]
99
100                     [% IF ( confirm ) %]<!-- We need to confirm the issue.. -->
101                         <div class="alert"><h3>Please confirm the checkout:</h3>
102                             [% IF ( confirm_renew_issue ) %]
103                                 <p>This item is already checked out to you.</p>
104                             [% END %]
105
106                             [% IF ( renew && Koha.Preference('AllowSelfCheckReturns') ) %]
107                                 <form action="/cgi-bin/koha/sco/sco-main.pl" name="confirmForm" class="inline" method="post">
108                                     <input type="hidden" name="op" value="returnbook" />
109                                     <input type="hidden" name="patronid" value="[% patronid | html %]" />
110                                     <input type="hidden" name="barcode" value="[% barcode | html %]" />
111                                     <input type="hidden" name="confirmed" value="" />
112                                     <button type="submit" name="returnbook" class="btn"><i class="icon return"></i> Return this item</button>
113                                 </form>
114                             [% END %]
115
116                             [% UNLESS ( renew ) %]
117                                 <form action="/cgi-bin/koha/sco/sco-main.pl" name="confirmForm" class="inline" method="post">
118                                     <input type="hidden" name="op" value="checkout" />
119                                     <input type="hidden" name="patronid" value="[% patronid | html %]" />
120                                     <input type="hidden" name="barcode" value="[% barcode | html %]" />
121                                     <input type="hidden" name="confirmed" value="1" />
122                                     <button type="submit" name="confirm" class="btn"><i class="icon renew"></i> Renew item</button>
123                                   </form>
124                             [% ELSE %]
125                                 <form action="/cgi-bin/koha/sco/sco-main.pl" name="confirmForm" class="inline" method="post">
126                                     <input type="hidden" name="op" value="checkout" />
127                                     <input type="hidden" name="patronid" value="[% patronid | html %]" />
128                                     <input type="hidden" name="barcode" value="[% barcode | html %]" />
129                                     <input type="hidden" name="confirmed" value="1" />
130                                     <button type="submit" class="btn"><i class="icon renew"></i> Renew item</button>
131                                 </form>
132                             [% END %]
133
134                             <form action="/cgi-bin/koha/sco/sco-main.pl" name="confirmForm" class="inline" method="post">
135                                 <input type="hidden" name="op" value="" />
136                                 <input type="hidden" name="patronid" value="[% patronid | html %]" />
137                                 <button type="submit" class="btn"><i class="icon cancel"></i> Cancel</button>
138                             </form>
139                         </div>
140                     [% END # / IF confirm %]
141
142                     [% IF ( nopermission ) %]
143                         <!-- This is what is displayed if user doesn't have permission -->
144                         <div class="alert">
145                             <h3>Access denied</h3>
146                             <p>Sorry, this self-checkout station has lost authentication.  Please contact the administrator to resolve this problem.</p>
147                         </div>
148                     [% END %]
149
150                     [% IF ( different_ip ) %]
151                         <!-- This is what is displayed if user doesn't have permission -->
152                         <div class="alert">
153                             <h3>Session lost</h3>
154                             <p>You are accessing self-checkout from a different IP address! please log in again.</p>
155                         </div>
156                     [% END %]
157
158                     [% IF ( invalid_username_or_password ) %]
159                         <!-- This is what is displayed if user doesn't have permission -->
160                         <div class="alert">
161                             <h3>Record not found</h3>
162                             <p>Your userid was not found in the database.  Please try again.</p>
163                         </div>
164                     [% END %]
165
166
167                     [% UNLESS ( hide_main ) %]
168
169                         [% IF ( patronid ) %]
170                             [% IF ( validuser ) %]
171                                 <div class="alert alert-info">You are logged in as [% borrowername | html %].</div>
172                                 [% INCLUDE 'opac-note.inc' %]
173                                 [% IF patron_has_hold_fee %]
174                                     <div class="alert">A hold fee was charged to your account for collecting this item.</div>
175                                 [% END %]
176                             [% END %]
177
178                             [% IF ( nouser ) %]
179                                 <div class="alert">
180                                     <h4>Sorry</h4>
181                                     <p>The userid <strong>[% patronid | html %]</strong> was not found in the database.  Please try again.</p>
182                                 </div>
183                             [% END %]
184                         [% END # / IF patronid %]
185
186                         [% IF ( validuser ) %]
187                             <div id="newcheckout" class="sco_entry">
188                                 <form id="scan_form" name="scan_form" method="post" action="/cgi-bin/koha/sco/sco-main.pl" onsubmit="return checkout_confirm('[% patronid | html %]');">
189                                     <fieldset>
190                                         <legend>Check out[% IF ( Koha.Preference('AllowSelfCheckReturns') ) %], return[% END %] or renew an item: </legend>
191                                         <div class="input-append">
192                                             <label for="barcode">Scan a new item or enter its barcode:</label>
193                                             <input id="barcode" name="barcode" size="20" type="text" class="focus" autocomplete="off" />
194                                             <button type="submit" class="btn">Submit</button>
195                                         </div>
196                                         <input type="hidden" name="op" value="checkout" />
197                                         <input type="hidden" name="patronid" value="[% patronid | html %]" />
198                                         <input type="hidden" name="newissues" value="[% newissues | html %]" />
199                                     </fieldset>
200                                 </form>
201
202                                 <div>
203                                     <form method="post" action="#" id="logout_form">
204                                         <button type="submit" class="btn"><i class="icon finish"></i> Finish</button>
205                                     </form>
206                                 </div>
207                             </div> <!-- / #newcheckout -->
208                 </div> <!-- / .span12/12 -->
209                 [% IF ( display_patron_image ) %]
210                     <div class="span2">
211                         <img src="/cgi-bin/koha/sco/sco-patron-image.pl?borrowernumber=[% borrowernumber | html %]&csrf_token=[% csrf_token | html %]" alt="" />
212                     </div>
213                 [% END %]
214             </div> <!-- / .row-fluid -->
215         </div> <!-- / .container-fluid -->
216
217         <div class="container-fluid">
218             <div class="row-fluid">
219                     <div class="span12">
220                         <div id="borrowerdetails">
221                             [% IF ( issues_count ) %]
222                                 <table id="loanTable" class="table table-bordered table-striped">
223                                     <caption>Checkouts for [% borrowername | html %] <span class="count">([% issues_count | html %] total)</span></caption>
224                                     <!-- ISSUES TABLE ROWS -->
225                                     <thead>
226                                         <tr>
227                                             <th class="noshow">Checked out on</th>
228                                             <th class="anti-the">Title</th>
229                                             <th>Call no.</th>
230                                             <th class="title-string">Due</th>
231                                             <th class="nosort">Renew</th>
232                                             [% UNLESS ( nofines ) %]
233                                                 <th>Fines</th>
234                                             [% END %]
235                                         </tr>
236                                     </thead>
237                                     <tbody>
238                                         [% FOREACH ISSUE IN ISSUES %]
239                                             <tr>
240                                                 <td>[% ISSUE.issuedate | html %]</td>
241                                                 <td>
242                                                     [% IF ( newissues.match(ISSUE.barcode)) %]
243                                                         <span class="label label-info">NEW</span>
244                                                     [% END %]
245                                                     [% UNLESS ( noitemlinks ) %]
246                                                         <a href="/cgi-bin/koha/opac-detail.pl?bib=[% ISSUE.  biblionumber | uri %]">[% ISSUE.title | html %]</a>
247                                                     [% ELSE %]
248                                                         <strong>[% ISSUE.title | html %]</strong>
249                                                     [% END %]
250                                                     <span class="item-details">[% ISSUE.author | html %]</span>
251                                                     ([% ISSUE.barcode | html %])
252                                                 </td>
253                                                 <td>[% ISSUE.itemcallnumber | html %]</td>
254                                                 [% IF ( ISSUE.overdue ) %]
255                                                     <td class="overdue"><span title="[% ISSUE.date_due | html %]">[% ISSUE.date_due | $KohaDates  as_due_date => 1 %]</span></td>
256                                                 [% ELSE   %]
257                                                     <td><span title="[% ISSUE.date_due | html %]">[% ISSUE.date_due | $KohaDates  as_due_date => 1 %]</span></td>
258                                                 [% END %]
259                                                 <td>
260                                                     <form action="/cgi-bin/koha/sco/sco-main.pl" method="post">
261                                                         <input type="hidden" name="patronid" value="[% patronid | html %]" />
262                                                         <input type="hidden" name="barcode" value="[% ISSUE.barcode | html %]" />
263                                                         [% IF ISSUE.can_be_renewed %]
264                                                             <input type="hidden" name="op" value="checkout" />
265                                                             <input type="hidden" name="confirmed" value="1" />
266                                                             [% UNLESS ( ISSUE.renew ) %]
267                                                                 <input type="submit" value="Renew item"  name="confirm  " class="btn renew" />
268                                                             [% ELSE %]
269                                                                 <input type="submit" value="Renew item" class="btn renew" />
270                                                             [% END %]
271                                                         [% ELSE %]
272                                                             [% IF ISSUE.renew_error == 'auto_renew' OR ISSUE.renew_error == 'auto_too_soon' %]
273                                                                 <span>This item has been scheduled for automatic renewal and cannot be renewed</span>
274                                                             [% ELSIF ISSUE.renew_error == 'onsite_checkout' %]
275                                                                 <span>This is a on-site checkout, it cannot be renewed.</span>
276                                                             [% ELSE %]
277                                                                 <span>No renewals allowed</span>
278                                                             [% END %]
279                                                             [% IF Koha.Preference('AllowSelfCheckReturns') %]
280                                                                 <input type="submit" value="Check in item" name="confirm" class="btn return" />
281                                                                 <input type="hidden" name="op" value="returnbook" />
282                                                                 <input type="hidden" name="confirmed" value=""  />
283                                                             [% END %]
284                                                         [% END %]
285                                                     </form>
286                                                 </td>
287                                                 [% UNLESS ( nofines ) %]
288                                                     <td>
289                                                         [% IF ( ISSUE.charges ) %]Yes[% ELSE %]No[% END %]
290                                                     </td>
291                                                 [% END %]
292                                             </tr>
293                                         [% END # / FOREACH ISSUE %]
294                                     </tbody>
295                                 </table>
296                             [% ELSE %]
297                                 <h3>You currently have nothing checked out.</h3>
298                             [% END # / IF issues_count %]
299                         </div> <!-- / #borrowerdetails -->
300                         [% ELSE # IF validuser %]
301                             <div class="sco_entry" >
302                                 <form id="mainform" action="/cgi-bin/koha/sco/sco-main.pl" name="mainform" method="post">
303                                     <fieldset class="checkout brief">
304                                         [% IF ( Koha.Preference('SelfCheckoutByLogin') ) %]
305                                             <legend>Log in to your account</legend>
306                                             <label for="patronlogin">Login:</label>
307                                             <input type="text" id="patronlogin" class="focus" size="20" name="patronlogin" />
308                                             <label for="patronpw">Password:</label>
309                                             <input type="password" id="patronpw" size="20" name="patronpw" />
310                                             <fieldset class="action">
311                                                 <button type="submit" class="btn">Log in</button>
312                                             </fieldset>
313                                         [% ELSE %]
314                                             <div class="input-append">
315                                                 <label for="patronid">Please enter your card number:</label>
316                                                 <input type="text" id="patronid" class="focus" size="20" name="patronid" autocomplete="off" />
317                                                 <button type="submit" class="btn">Submit</button>
318                                             </div>
319                                         [% END %]
320
321                                         [% FOREACH INPUT IN INPUTS %]
322                                             <input type="hidden" name="[% INPUT.name | html %]" value="[% INPUT.value | html %]">
323                                         [% END %]
324                                         <input type="hidden" name="op" value="login" />
325                                     </fieldset>
326                                 </form>
327                             </div> <!-- / .sco_entry -->
328                         [% END # / IF validuser %]
329                     [% END # / UNLESS ( hide_main %]
330                     [% IF ( Koha.Preference('SCOMainUserBlock' ) ) %]<div id="scomainuserblock">[% Koha.Preference('SCOMainUserBlock' ) | $raw %]</div>[% END %]
331                 </div> <!-- / .span12 -->
332             </div> <!-- / .row-fluid -->
333         </div> <!-- / .container-fluid -->
334     </div> <!-- / .main -->
335     <span id="audio-alert"></span>
336
337 [% INCLUDE 'opac-bottom.inc' %]
338 [% BLOCK jsinclude %]
339     [% INCLUDE 'datatables.inc' %]
340     <script>
341         //<![CDATA[
342         function mungeHistory() {
343             // prevent back button from allowing form resubmission
344             if (history && history.pushState) {
345                 history.replaceState(null, document.title, window.location.href);
346             }
347         }
348         var mainTimeout;
349         function sco_init() {
350             mainTimeout = setTimeout(function() {
351                 location.href = '/cgi-bin/koha/sco/sco-main.pl?op=logout';
352             }, [% SelfCheckTimeout | html %]);
353         }
354         function dofocus() {    // named function req'd for body onload event by some FF and IE7 security models
355             // alert("dofocus called");
356             $(".focus:last").select();
357         }
358         var slip_re = /slip/;
359         function printx_window(print_type) {
360           var handler = print_type.match(slip_re) ? "printslip" : "moremember";
361
362           return false;
363         }
364         function checkout_confirm(patronid) {
365             var   barcode = $("#barcode").val();
366             // alert("checkout_confirm('" + patronid + "') called for barcode '" + barcode + "'");
367             if (! barcode) { dofocus(); return false; }    // no barcode
368             if (barcode == "__KOHA_NEW_CIRC__") {   // magic barcode
369                 window.location.href='/cgi-bin/koha/sco/sco-main.pl?op=logout';
370                 return false;
371             }
372             return true;
373         }
374         [% IF Koha.Preference('AudioAlerts') %]
375             var AUDIO_ALERTS = JSON.parse( '[% AudioAlerts.AudioAlerts | replace( "'", "\\'" ) | replace( '"', '\\"' ) | html %]' );
376             $( document ).ready(function() {
377                 if ( AUDIO_ALERTS ) {
378                     for ( var k in AUDIO_ALERTS ) {
379                         var alert = AUDIO_ALERTS[k];
380                         if ( $( alert.selector ).length ) {
381                             playSound( alert.sound );
382                             break;
383                         }
384                     }
385                 }
386             });
387             function playSound( sound ) {
388                 if (  ( sound.indexOf('http://') == 0 || sound.indexOf('https://') == 0 )  ) {
389                     document.getElementById("audio-alert").innerHTML = '<audio src="' + sound + '" autoplay="autoplay" autobuffer="autobuffer"></audio>';
390                 }
391             }
392         [% END %]
393
394
395         $(document).ready(function() {
396             dofocus();
397             [% IF ( patronid ) %]sco_init();[% END %]
398             $("#loanTable").dataTable($.extend(true, {}, dataTablesDefaults, {
399                 "order": [ 0 ],
400                 "columnDefs": [
401                     { "targets": [ "nosort" ], "sortable": false, "searchable": false },
402                     { "targets": [ "noshow" ], "visible": false, "searchable": false },
403                     { "type": "anti-the", "targets" : [ "anti-the" ] },
404                     { "type": "title-string", "targets" : [ "title-string" ] }
405                 ]
406             }));
407
408             $("#logout_form").submit(function(){
409                 clearTimeout(mainTimeout);
410                 [% IF Koha.Preference('SelfCheckReceiptPrompt') %]
411                     var confirmStart = Date.now();
412                     if(confirm(_("Would you like to print a receipt?"))){
413                         if ( (Date.now() - confirmStart) < [% SelfCheckTimeout | html %] ) {
414                             window.open("/cgi-bin/koha/sco/printslip.pl?borrowernumber=[% borrowernumber | html %]&amp;print=qslip");
415                         } else {
416                             alert(_("Timeout while waiting for print confirmation"));
417                         }
418                     }
419                 [% END %]
420
421                 return true;
422             });
423     });
424     //]]>
425     </script>
426
427     [% IF ( Koha.Preference('SCOUserJS') ) %]<script>[% Koha.Preference('SCOUserJS') | $raw %]</script>[% END %]
428 [% END %]