Bug 30045: (bug 29543 follow-up) Fix SCO print slip
[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                                     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                                     <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 ( renewed == 0) %]
209                         <span class="sco-alert-warning renew"></span>
210                         <div class="alert alert-info">
211                             <p>Item not renewed</p>
212                         </div>
213                     [% ELSIF ( returned == 0 ) %]
214                         <span class="sco-alert-warning return"></span>
215                         <div class="alert alert-info">
216                             <p>Item not checked in: please see circulation staff for assistance</p>
217                         </div>
218                     [% ELSIF ( returned == 1 ) %]
219                         <span class="sco-alert-success return"></span>
220                         <div class="alert alert-info">
221                             <p>Item checked in</p>
222                         </div>
223                     [% END %]
224
225
226                     [% UNLESS ( hide_main ) %]
227
228                         [% IF ( patronid ) %]
229                             [% IF ( validuser ) %]
230                                 <div class="alert alert-info">You are logged in as [% borrowername | html %].</div>
231                                 [% INCLUDE 'opac-note.inc' %]
232                                 [% IF patron_has_hold_fee %]
233                                     <div class="alert alert-warning">A hold fee was charged to your account for collecting this item.</div>
234                                 [% END %]
235                             [% END %]
236
237                             [% IF ( nouser ) %]
238                                 <div class="alert alert-warning">
239                                     <h3>Sorry</h3>
240                                     <p>The userid <strong>[% patronid | html %]</strong> was not found in the database.  Please try again.</p>
241                                 </div>
242                             [% END %]
243                         [% END # / IF patronid %]
244
245                         [% IF ( validuser ) %]
246                             <div id="newcheckout" class="sco_entry">
247                                 <form id="scan_form" name="scan_form" method="post" action="/cgi-bin/koha/sco/sco-main.pl" onsubmit="return checkout_confirm('[% patronid | html %]');">
248                                     <legend><h2>
249                                         [% IF ( Koha.Preference('SCOAllowCheckin') ) %]
250                                             Check out, return, or renew an item:
251                                         [% ELSE %]
252                                             Check out or renew an item:
253                                         [% END %]
254                                         </h2></legend>
255                                     <div class="row">
256                                         <div class="col">
257                                             <label for="barcode">Scan a new item or enter its barcode:</label>
258                                         </div>
259                                         <div class="col-3">
260                                             <input id="barcode" name="barcode" size="20" type="text" class="focus form-control" autocomplete="off" />
261                                         </div>
262                                         <div class="col-auto">
263                                             <button type="submit" class="btn btn-primary">Submit</button>
264                                         </div>
265                                         <div class="col ml-auto">
266                                             <button type="button" id="logout_form" class="btn btn-info"><i class="fa fa-check" aria-hidden="true"></i> Finish</button>
267                                             <input type="hidden" name="op" value="checkout" />
268                                             <input type="hidden" name="patronid" value="[% patronid | html %]" />
269                                             <input type="hidden" name="newissues" value="[% newissues | html %]" />
270                                         </div>
271                                     </div> <!-- /.row -->
272                                 </form> <!-- /#scan_form -->
273                             </div> <!-- / #newcheckout -->
274                 </div> <!-- / .span12/12 -->
275                 [% IF ( display_patron_image ) %]
276                     <div class="col-lg-2">
277                         <img src="/cgi-bin/koha/sco/sco-patron-image.pl?borrowernumber=[% borrowernumber | uri %]&csrf_token=[% csrf_token | uri %]" alt="" />
278                     </div>
279                 [% END %]
280             </div> <!-- / .row -->
281         </div> <!-- / .container-fluid -->
282
283         <div class="container-fluid">
284             <div class="row">
285                 <div class="col order-first order-md-first order-lg-2">
286                     <ul class="nav nav-tabs" role="tablist">
287                         <li class="nav-item" role="presentation">
288                             <a class="nav-link active" href="#checkouts-tab" id="checkouts" aria-controls="home" aria-selected="true" data-toggle="tab">Checkouts ([% issues_count | html %])</a>
289                         </li>
290                         <li class="nav-item" role="presentation">
291                             <a class="nav-link" href="#holds-tab" id="holds" aria-controls="home" aria-selected="false" data-toggle="tab">
292                                 [% IF waiting_holds_count %]
293                                     <i class="fa fa-exclamation" aria-hidden="true"></i>
294                                 [% END %]
295                                 Holds ([% HOLDS.count | html %])
296                             </a>
297                         </li>
298                         <li class="nav-item" role="presentation">
299                             <a class="nav-link" href="#account-tab" id="account" aria-controls="home" aria-selected="false" data-toggle="tab">Charges ([% total | $Price %])</a>
300                         </li>
301                     </ul>
302                     <div class="tab-content">
303                         <div id="checkouts-tab" class="tab-pane show active" aria-labelledby="checkouts">
304                             <div id="borrowerdetails">
305                                 [% IF ( issues_count ) %]
306                                     <table id="loanTable" class="table table-bordered table-striped">
307                                         <caption>Checkouts for [% borrowername | html %] <span class="count">([% issues_count | html %] total)</span></caption>
308                                         <!-- ISSUES TABLE ROWS -->
309                                         <thead>
310                                             <tr>
311                                                 <th class="noshow">Checked out on</th>
312                                                 <th class="anti-the">Title</th>
313                                                 <th>Call number</th>
314                                                 <th>Due</th>
315                                                 <th class="nosort">Renew</th>
316                                                 [% UNLESS ( nofines ) %]
317                                                     <th>Fines</th>
318                                                 [% END %]
319                                             </tr>
320                                         </thead>
321                                         <tbody>
322                                             [% FOREACH ISSUE IN ISSUES %]
323                                                 <tr>
324                                                     <td>[% ISSUE.issuedate | html %]</td>
325                                                     <td>
326                                                         [% UNLESS ( noitemlinks ) %]
327                                                             <a href="/cgi-bin/koha/opac-detail.pl?bib=[% ISSUE.  biblionumber | uri %]">[% ISSUE.title | html %]</a>
328                                                         [% ELSE %]
329                                                             <strong>[% ISSUE.title | html %]</strong>
330                                                         [% END %]
331                                                         [% IF ( newissues.match(ISSUE.barcode)) %]
332                                                             <span class="label label-info">NEW</span>
333                                                         [% END %]
334                                                         <span class="item-details">[% ISSUE.author | html %]</span>
335                                                         ([% ISSUE.barcode | html %])
336                                                     </td>
337                                                     <td>[% ISSUE.itemcallnumber | html %]</td>
338                                                     [% IF ( ISSUE.overdue ) %]
339                                                         <td class="overdue" data-order="[% ISSUE.date_due | html %]">
340                                                             [% ISSUE.date_due | $KohaDates  as_due_date => 1 %]
341                                                         </td>
342                                                     [% ELSE   %]
343                                                         <td data-order="[% ISSUE.date_due | html %]">
344                                                             [% ISSUE.date_due | $KohaDates  as_due_date => 1 %]
345                                                         </td>
346                                                     [% END %]
347                                                     <td>
348                                                         <form action="/cgi-bin/koha/sco/sco-main.pl" method="post">
349                                                             <legend class="sr-only">Issue renews</legend>
350                                                             <input type="hidden" name="patronid" value="[% patronid | html %]" />
351                                                             <input type="hidden" name="barcode" value="[% ISSUE.barcode | html %]" />
352                                                             <input type="hidden" name="newissues" value="[% newissues | html %]" />
353                                                             [% IF ISSUE.can_be_renewed %]
354                                                                 <input type="hidden" name="op" value="renew" />
355                                                                 <input type="hidden" name="confirmed" value="1" />
356                                                                 [% UNLESS ( ISSUE.renew ) %]
357                                                                     <input type="submit" value="Renew item"  name="confirm  " class="btn btn-primary btn-sm renew" />
358                                                                 [% ELSE %]
359                                                                     <input type="submit" value="Renew item" class="btn btn-primary btn-sm renew" />
360                                                                 [% END %]
361                                                             [% ELSE %]
362                                                                 [% IF ISSUE.renew_error == 'auto_renew' OR ISSUE.renew_error == 'auto_too_soon' %]
363                                                                     <span>This item has been scheduled for automatic renewal and cannot be renewed</span>
364                                                                 [% ELSIF ISSUE.renew_error == 'onsite_checkout' %]
365                                                                     <span>This is a on-site checkout, it cannot be renewed.</span>
366                                                                 [% ELSIF ISSUE.renew_error == 'too_unseen' %]
367                                                                     <span>You have renewed this item the maximum number of consecutive times without it being seen by the library.</span>
368                                                                 [% ELSE %]
369                                                                     <span>No renewals allowed</span>
370                                                                 [% END %]
371                                                                 [% IF Koha.Preference('SCOAllowCheckin') %]
372                                                                     <input type="submit" value="Check in item" name="confirm" class="btn btn-info btn-sm return" />
373                                                                     <input type="hidden" name="op" value="returnbook" />
374                                                                     <input type="hidden" name="confirmed" value=""  />
375                                                                 [% END %]
376                                                             [% END %]
377                                                         </form>
378                                                     </td>
379                                                     [% UNLESS ( nofines ) %]
380                                                         <td>
381                                                             [% IF ( ISSUE.charges ) %]Yes[% ELSE %]No[% END %]
382                                                         </td>
383                                                     [% END %]
384                                                 </tr>
385                                             [% END # / FOREACH ISSUE %]
386                                         </tbody>
387                                     </table>
388                                 [% ELSE %]
389                                     <h3>You currently have nothing checked out.</h3>
390                                 [% END # / IF issues_count %]
391                             </div> <!-- / #borrowerdetails -->
392                         </div>
393                         <div id="holds-tab" class="tab-pane" role="tabpanel" aria-labelledby="holds">
394                             [% IF HOLDS.count > 0 %]
395                                 [% PROCESS 'holds-table.inc' HOLDS = HOLDS, SuspendHoldsOpac = SuspendHoldsOpac, showpriority = showpriority, AutoResumeSuspendedHolds = AutoResumeSuspendedHolds, onlyinfo = 'true' %]
396                             [% ELSE %]
397                                 <h3>You currently have no pending holds.</h3>
398                             [% END %]
399                         </div>
400                         <div id="account-tab" class="tab-pane" role="tabpanel" aria-labelledby="account">
401                             [% PROCESS 'account-table.inc' %]
402                         </div>
403                     </div>
404                         [% ELSE # IF validuser %]
405                             <div class="sco_entry" >
406                                 <form id="mainform" action="/cgi-bin/koha/sco/sco-main.pl" name="mainform" method="post">
407                                     <fieldset>
408                                         [% IF ( Koha.Preference('SelfCheckoutByLogin') ) %]
409                                             <legend>Log in to your account</legend>
410                                             <label for="patronlogin">Login:</label>
411                                             <input type="text" id="patronlogin" class="focus noEnterSubmit" size="20" name="patronlogin" autocomplete="off"/>
412                                             <label for="patronpw">Password:</label>
413                                             <input type="password" id="patronpw" size="20" name="patronpw" autocomplete="off"/>
414                                             <fieldset class="action">
415                                                 <button type="submit" class="btn btn-primary">Log in</button>
416                                             </fieldset>
417                                         [% ELSE %]
418                                             <div class="form-row">
419                                                 <div class="col-auto">
420                                                     <label for="patronid">Please enter your card number:</label>
421                                                 </div>
422                                                 <div class="col-3">
423                                                     <input type="text" id="patronid" class="form-control focus" size="20" name="patronid" autocomplete="off" />
424                                                 </div>
425                                                 <div class="col-auto">
426                                                     <button type="submit" class="btn btn-primary">Submit</button>
427                                                 </div>
428                                             </div> <!-- /.form-row -->
429                                         [% END %]
430
431                                         [% FOREACH INPUT IN INPUTS %]
432                                             <input type="hidden" name="[% INPUT.name | html %]" value="[% INPUT.value | html %]">
433                                         [% END %]
434                                         <input type="hidden" name="op" value="login" />
435                                     </fieldset>
436                                 </form>
437                             </div> <!-- / .sco_entry -->
438                         [% END # / IF validuser %]
439                     [% END # / UNLESS ( hide_main %]
440                     [% IF ( Koha.Preference('SCOMainUserBlock' ) ) %]<div id="scomainuserblock">[% Koha.Preference('SCOMainUserBlock' ) | $raw %]</div>[% END %]
441                 </div> <!-- / .span12 -->
442             </div> <!-- / .row -->
443         </div> <!-- / .container-fluid -->
444     </div> <!-- / .main -->
445     <span id="audio-alert"></span>
446
447 [% INCLUDE 'opac-bottom.inc' %]
448 [% BLOCK jsinclude %]
449     [% INCLUDE 'datatables.inc' %]
450     <script>
451         function mungeHistory() {
452             // prevent back button from allowing form resubmission
453             if (history && history.pushState) {
454                 history.replaceState(null, document.title, window.location.href);
455             }
456         }
457         var mainTimeout;
458         function sco_init() {
459             mainTimeout = setTimeout(function() {
460                 location.href = '/cgi-bin/koha/sco/sco-main.pl?op=logout';
461             }, [% SelfCheckTimeout | html %]);
462         }
463         function dofocus() {    // named function req'd for body onload event by some FF and IE7 security models
464             // alert("dofocus called");
465             $(".focus:last").select();
466         }
467         var slip_re = /slip/;
468         function printx_window(print_type) {
469           var handler = print_type.match(slip_re) ? "printslip" : "moremember";
470
471           return false;
472         }
473         function checkout_confirm(patronid) {
474             var   barcode = $("#barcode").val();
475             // alert("checkout_confirm('" + patronid + "') called for barcode '" + barcode + "'");
476             if (! barcode) { dofocus(); return false; }    // no barcode
477             if (barcode == "__KOHA_NEW_CIRC__") {   // magic barcode
478                 window.location.href='/cgi-bin/koha/sco/sco-main.pl?op=logout';
479                 return false;
480             }
481             return true;
482         }
483         [% IF Koha.Preference('AudioAlerts') %]
484             var AUDIO_ALERTS = JSON.parse( "[% To.json(AudioAlerts.AudioAlerts) | $raw %]" );
485             $( document ).ready(function() {
486                 if ( AUDIO_ALERTS ) {
487                     for ( var k in AUDIO_ALERTS ) {
488                         var alert = AUDIO_ALERTS[k];
489                         if ( $( alert.selector ).length ) {
490                             playSound( alert.sound );
491                             break;
492                         }
493                     }
494                 }
495             });
496             function playSound( sound ) {
497                 if (  ( sound.indexOf('http://') == 0 || sound.indexOf('https://') == 0 )  ) {
498                     document.getElementById("audio-alert").innerHTML = '<audio src="' + sound + '" autoplay="autoplay" autobuffer="autobuffer"></audio>';
499                 }
500             }
501         [% END %]
502
503
504         $(document).ready(function() {
505             dofocus();
506             [% IF ( patronid ) %]sco_init();[% END %]
507             $("#loanTable").dataTable($.extend(true, {}, dataTablesDefaults, {
508                 "dom": "t",
509                 "order": [ 0 ],
510                 "columnDefs": [
511                     { "targets": [ "nosort" ], "sortable": false, "searchable": false },
512                     { "targets": [ "noshow" ], "visible": false, "searchable": false },
513                     { "type": "anti-the", "targets" : [ "anti-the" ] }
514                 ]
515             }));
516
517             $("#logout_form").on("click", function(e){
518                 e.preventDefault(e);
519                 clearTimeout(mainTimeout);
520                 [% IF Koha.Preference('SelfCheckReceiptPrompt') %]
521                     var confirmStart = Date.now();
522                     confirmModal("", _("Would you like to print a receipt?"), _("Print receipt and end session"), _("End session"), function(result) {
523                         if ( result && (Date.now() - confirmStart) < [% SelfCheckTimeout | html %] ) {
524                             var win = window.open("/cgi-bin/koha/sco/printslip.pl?print=qslip");
525                             location.href = '/cgi-bin/koha/sco/sco-main.pl?op=logout';
526                         } else {
527                             location.href = '/cgi-bin/koha/sco/sco-main.pl?op=logout';
528                         }
529                     })
530                 [% ELSE %]
531                     location.href = '/cgi-bin/koha/sco/sco-main.pl?op=logout';
532                 [% END %]
533
534                 return true;
535             });
536     });
537
538     </script>
539
540     [% IF ( Koha.Preference('SCOUserJS') ) %]<script>[% Koha.Preference('SCOUserJS') | $raw %]</script>[% END %]
541 [% END %]