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