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