Bug 22880: (follow-up) Loose ends: Better DB update, global inclusion, etc.
[koha.git] / koha-tmpl / opac-tmpl / bootstrap / en / modules / sci / sci-main.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [%# Includes %]
4 [% USE Koha %]
5 [% USE KohaDates %]
6 [% USE KohaNews %]
7 [%# Helper template functions %]
8 [% BLOCK error_message %]
9     [% IF messages.BadBarcode %]
10         <span>(Barcode not found on the database, please see library staff for assistance)</span>
11     [% ELSIF messages.Wrongbranch %]
12         <span>(The item cannot be returned at this library, please see library staff for assistance)</span>
13     [% ELSIF messages.withdrawn %]
14         <span>(Item is withdrawn and check-in blocked by policy, please see library staff for assistance)</span>
15     [% ELSIF messages.NotIssued %]
16         <span>(The book is not currently on loan, please see library staff for assistance)</span>
17     [% ELSE %]
18         <span>(There was a problem returning this item, please see library staff for assistance)</span>
19     [% END %]
20 [% END %]
21 [% PROCESS 'html_helpers.inc' %]
22 [% SET OpacHeader = KohaNews.get( location => "opacheader", lang => lang, library => branchcode, blocktitle => 0 ) %]
23 [% INCLUDE 'doc-head-open.inc' %]
24
25 <title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha [% END %] &rsaquo; Self check-in</title>
26
27 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
28 <meta name="generator" content="Koha [% Version | html %]" /> <!-- leave this for stats -->
29
30 [% IF ( Koha.Preference('OpacFavicon') ) %]
31 <link rel="shortcut icon" href="[% Koha.Preference('OpacFavicon') | url %]" type="image/x-icon" />
32 [% ELSE %]
33 <link rel="shortcut icon" href="[% interface | html %]/[% theme | html %]/images/favicon.ico" type="image/x-icon" />
34 [% END %]
35 [% Asset.css("lib/bootstrap/css/bootstrap.min.css") | $raw %]
36 [% Asset.css("lib/jquery/jquery-ui-1.12.1.css") | $raw %]
37 [% Asset.css("lib/font-awesome/css/font-awesome.min.css") | $raw %]
38 [% Asset.css("css/sco.css") | $raw %]
39 [% IF ( Koha.Preference('OPACUserCSS') ) %]<style>[% Koha.Preference('OPACUserCSS') | $raw %]</style>[% END %]
40 [% IF ( Koha.Preference('SelfCheckInUserCSS') ) %]<style>[% Koha.Preference('SelfCheckInUserCSS') | $raw %]</style>[% END %]
41 <!--[if lt IE 9]>
42     <script src="[% interface | html %]/[% theme | html %]/lib/respond.min.js"></script>
43 <![endif]-->
44 <script>
45     function _(s) { return s } // dummy function for gettext
46 </script>
47 [% Asset.js("lib/modernizr.min.js") | $raw %]
48 </head>
49 <body id="sci_main" class="sci" onload="dofocus();" onunload="mungeHistory();">
50
51 [% SET OpacLangSelectorMode = Koha.Preference('OpacLangSelectorMode') %]
52 <div id="wrap">
53     <div class="navbar navbar-inverse navbar-static-top">
54         <div class="navbar-inner">
55             <div class="container-fluid">
56                 <a class="brand" href="/cgi-bin/koha/sci/sci-main.pl"><img src="[% interface | html %]/[% theme | html %]/images/koha-green-logo.png" alt=""></a>
57                 <div id="checkouthelp">
58                     <ul class="nav pull-right">
59                         <li><a href="/cgi-bin/koha/sci/sci-main.pl" class="helpModal-trigger" role="button" data-toggle="modal"><i class="fa fa-info-circle"></i> Help</a></li>
60                         <li><a id="sci_logout" href="/cgi-bin/koha/sci/sci-main.pl?logout.x=1" class="logout">Log out</a></li>
61                     </ul>
62                 </div>
63
64                 [% IF Koha.Preference( 'opaclanguagesdisplay' ) %]
65                     <div id="members">
66                         <ul class="nav pull-right">
67                             [% INCLUDE 'masthead-langmenu.inc' %]
68                         </ul>
69                     </div>
70                 [% END %]
71
72             </div> <!-- /.container-fluid -->
73         </div> <!-- /.navbar-inner -->
74     </div> <!-- /.navbar -->
75
76     [% IF ( OpacHeader ) %]
77         <div class="container-fluid">
78             <div class="row-fluid">
79                 <div id="opacheader">
80                     [% PROCESS koha_news_block news => OpacHeader %]
81                 </div>
82             </div>
83         </div>
84     [% END %]
85
86     <div class="main">
87         <div class="container-fluid">
88             <div class="row-fluid">
89                 <div id="masthead">
90                     <h1>[% LibraryName | html %] Self check-in</h1>
91                 [% IF ( nopermission ) %]
92                     [%# This is what is displayed if user doesn't have permission %]
93                     <div class="alert">
94                         <h3>Access denied</h3>
95                         <p>Sorry, this self check-in station has lost authentication. Please contact the administrator to resolve this problem.</p>
96                     </div>
97                 [% ELSIF ( different_ip ) %]
98                     [%# This is what is displayed if user doesn't have permission %]
99                     <div class="alert">
100                         <h3>Session lost</h3>
101                         <p>You are accessing self check-in from a different IP address! Please log in again.</p>
102                     </div>
103                 [% ELSIF ( checkins ) %]
104                     [%# We have results from a check-in attempt %]
105                     <div id="checkins" class="sci_results_list">
106                         [% IF ( success && success.size > 0 || errors && errors.size > 0 ) %]
107                             <h3>Results</h3>
108                                 <table id="sci_bcheckins_table" class="table table-bordered table-striped dataTable no-footer" style="font-size: initial;">
109                                   <thead>
110                                     <th>Barcode</th>
111                                     <th>Status</th>
112                                   </thead>
113                                   <tbody>
114                                 [% FOREACH success_line IN success %]
115                                     <tr><td>[% success_line.barcode | html %]</td><td>Checked in</td></tr>
116                                 [% END %]
117                                 [% FOREACH error IN errors %]
118                                     <tr>
119                                       <td>[% error.barcode | html %]</td>
120                                       <td>Not checked in [% PROCESS error_message messages=error.messages %]</td>
121                                     </tr>
122                                 [% END %]
123                                   </tbody>
124                                 </table>
125                                 <div>
126                                     <form method="post" action="#" id="finish_form">
127                                         <button id="sci_finish_button" type="submit" class="btn"><i class="fa fa-check"></i> Finish</button>
128                                     </form>
129                                 </div>
130                         [% ELSE %]
131                             <div class="alert">
132                                 <p>Your request included no check-ins.</p>
133                             </div>
134                         [% END %]
135                     </div>
136                 [% ELSE %]
137                     [%# Prompt for barcodes %]
138                     <div id="new_checkins" class="sci_entry">
139                         <form id="scan_form" name="scan_form"
140                               method="post" action="/cgi-bin/koha/sci/sci-main.pl">
141                             <fieldset>
142                                 <div>
143                                   <label for="barcode_input">Scan the item or enter its barcode:</label>
144                                   <input id="barcode_input" name="barcode_input" size="20" type="text" class="focus" autocomplete="off" />
145                                   <button id="sci_append_button" type="submit" class="btn btn-default btn-sm">
146                                     <i class="fa fa-plus" aria-hidden="true"></i> <span>Add</span>
147                                   </button>
148                                 </div>
149                                 <div class="sci_input_append">
150                                     <table id="sci_barcodes_table" class="table table-bordered table-striped dataTable no-footer" style="display: none; font-size: initial;">
151                                       <thead>
152                                         <th class="barcodes_column">Barcode</th>
153                                       </thead>
154                                       <tbody>
155                                       </tbody>
156                                     </table>
157                                 </div>
158                                 <input type="hidden" name="op" value="check_in" />
159                                 <div id="button_bar">
160                                 <button id="sci_checkin_button" type="submit" class="btn btn-default btn-sm" style="display: none;">
161                                     <i class="fa fa-check-square-o" aria-hidden="true"></i> <span>Check in</span>
162                                 </button>
163                                 <a href="/cgi-bin/koha/sci/sci-main.pl" class="btn btn-default btn-sm" role="button" style="display: none;" id="sci_refresh_button">
164                                     <i class="fa fa-refresh" aria-hidden="true"></i> <span>Cancel</span>
165                                 </a>
166                                 </div>
167                             </fieldset>
168                         </form>
169                     </div> <!-- / #new_checkins -->
170                 [% END %]
171                 </div> <!-- / #masthead -->
172             </div> <!-- / .row-fluid -->
173         </div> <!-- / .container-fluid -->
174
175         [% IF ( Koha.Preference('SelfCheckInMainUserBlock') ) %]
176             <div id="SelfCheckInMainUserBlock">[% Koha.Preference('SelfCheckInMainUserBlock' ) | $raw %]</div>
177         [% END %]
178     </div> <!-- / .main -->
179
180     <div id="helpModal" class="modal hide" tabindex="-1" role="dialog" aria-labelledby="helpModalLabel" aria-hidden="true">
181
182       <div class="modal-header">
183         <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
184         <h3 id="helpModalLabel">Self check-in help</h3>
185       </div>
186
187       <div class="modal-body">
188         <ul>
189           <li>Scan each item or enter its barcode. A list with the entered barcodes will be displayed.</li>
190           <li>Click the 'Check in' button to confirm.</li>
191           <li>The operation results will be displayed for each entered barcode.</li>
192           <li>The 'Finish' button is presented to start over.</li>
193           <li>At any step, clicking the 'Cancel' button will erase the scanned barcodes and start over.</li>
194         </ul>
195       </div>
196     </div> <!-- /#helpModal -->
197 </body>
198
199 [% INCLUDE 'opac-bottom.inc' %]
200 [% BLOCK jsinclude %]
201     <script>
202
203         function mungeHistory() {
204             // prevent back button from allowing form resubmission
205             if (history && history.pushState) {
206                 history.replaceState(null, document.title, window.location.href);
207             }
208         }
209
210         function dofocus() {
211             $(".focus:last").select();
212         }
213
214         var barcodes = [];
215
216         $(document).ready(function() {
217             // Barcodes scanning table initially hidden
218             $("#sci_barcodes_table").hide();
219             // Control de 'append' button behaviour
220             $("#sci_append_button").on('click',function( e ){
221                 // Make sure the form is not submitted by the button
222                 e.preventDefault();
223                 var barcode = $('#barcode_input').val();
224                 //var result  = validate_barcode( barcode );
225                 $('#sci_barcodes_table tbody').append(
226                         '<tr style="font-size: initial;"><td>' +
227                             barcode +
228                             '<input type="hidden" name="barcode" value="' + barcode + '" />' +
229                         '</td></tr>' );
230                 // Make sure the table is now displayed
231                 $("#sci_barcodes_table").show();
232                 $('#sci_checkin_button').show();
233                 $('#sci_refresh_button').show();
234                 barcodes.push(barcode);
235                 // clean the input, reset the focus
236                 $('#barcode_input').val('');
237                 dofocus();
238             });
239
240             $(".helpModal-trigger").on("click",function(e){
241                 e.preventDefault();
242                 $("#helpModal").modal("show");
243             });
244
245             // set focus at the beginning
246             dofocus();
247         });
248
249         var idleTime = 0;
250         $(document).ready(function () {
251             //Increment the idle time counter every second
252             var idleInterval = setInterval(timerIncrement, 1000);
253
254             //Zero the idle timer on mouse movement.
255             $(this).mousemove(function (e) {
256                 idleTime = 0;
257             });
258             $(this).keypress(function (e) {
259                 idleTime = 0;
260             });
261         });
262
263         function timerIncrement() {
264             if ( $("#sci_finish_button").is(":visible") || $("#sci_refresh_button").is(":visible") ) {
265                 idleTime = idleTime + 1;
266                 idleTimeout = [% refresh_timeout | html %];
267                 if (idleTime >= idleTimeout ) {
268                     location.href = '/cgi-bin/koha/sci/sci-main.pl';
269                 }
270             }
271         }
272     </script>
273
274     [% IF ( Koha.Preference('SelfCheckInUserJS') ) %]<script>[% Koha.Preference('SelfCheckInUserJS') | $raw %]</script>[% END %]
275 [% END %]