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