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