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