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