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