Bug 10240: (follow-up) don't delete transactions if auth fails
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / circ / offline.tt
1 <!DOCTYPE html>
2 [% IF (AllowOfflineCirculation) %]
3 [% SET manifestattr = 'manifest="/cgi-bin/koha/circ/offline-mf.pl"' %]
4 [% END %]
5 [% IF ( bidi && AllowOfflineCirculation ) %]<html lang="[% lang %]" dir="[% bidi %]" manifest="/cgi-bin/koha/circ/offline-mf.pl">
6 [% ELSIF ( bidi ) %]<html lang="[% lang %]" dir="[% bidi %]">
7 [% ELSIF ( AllowOfflineCirculation ) %]<html lang="[% lang %]" manifest="/cgi-bin/koha/circ/offline-mf.pl">
8 [% ELSE %]<html lang="[% lang %]">[% END %]
9 <head>
10 <title>Koha &rsaquo; Circulation</title>
11 [% INCLUDE 'doc-head-close.inc' %]
12 <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.indexeddb.js"></script>
13 <script type="text/javascript" src="[% interface %]/prog/en/js/offlinecirc.js"></script>
14 <script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery-ui-timepicker-addon.js"></script>
15 <script type="text/javascript">
16 //<![CDATA[
17 var ALERT_SUCCESSFUL_CHECKIN = _("Checked in item.");
18 var ALERT_MATERIALS = _("Note about the accompanying materials: ");
19 var ALERT_RESTRICTED = _("Patron is RESTRICTED");
20 var ALERT_NO_MATCHING_ITEM = _("No item with barcode in offline database (transaction recorded anyway): ");
21 var ALERT_NOT_CHECKED_OUT = _("Item not listed as checked out in offline database (transaction recorded anyway)");
22 var ALERT_ITEM_WITHDRAWN = _("Item has been withdrawn (transaction recorded anyway)");
23 var ALERT_ITEM_RESTRICTED = _("Item is restricted (transaction recorded anyway)");
24 var ALERT_ITEM_LOST = _("Item has been lost (transaction recorded anyway)");
25 var ALERT_NO_MATCHING_PATRON = _("No patron cardnumber in offline database (proceeding anyway): ");
26 var ALERT_PATRON_GONE_NO_ADDRESS = _("Patron's address is in doubt (transaction recorded anyway)");
27 var ALERT_PATRON_CARD_LOST = _("Patron's card is lost");
28 var ALERT_PATRON_EXPIRED = _("Patron's card is expired");
29 var ALERT_PATRON_BLOCKED_TEMPORARY = _("Patron has had overdue items and is restricted for: ");
30 var ALERT_PATRON_RESTRICTED = _("Patron is restricted");
31 var ALERT_PATRON_FINE = _("Patron has outstanding fines: ");
32 var ALERT_PATRON_FINE_OVER_LIMIT = _("Patron fines are over limit: ");
33 var UPLOAD_PENDING_MESSAGE = _("You have transactions in the offline circulation database on this computer that have not been uploaded.");
34 var NO_UPLOAD_PENDING_MESSAGE = _("You do not have any pending transactions in the offline circulation database on this computer.");
35
36 var start;
37
38 var dateformat = '[% IF ( dateformat_us ) %]mm/dd/yy[% ELSIF ( dateformat_metric ) %]dd/mm/yy[% ELSE %]yy-mm-dd[% END %]';
39
40 function checkin(barcode, item, error) {
41     var alerts = checkAlerts(barcode, item);
42     if (typeof item === 'undefined') {
43         item = { };
44     }
45     item.title = item.title || _("(Unknown)");
46     item.author = item.author || _("(Unknown)");
47     item.homebranch = item.homebranch || "";
48     item.holdingbranch = item.holdingbranch || "";
49     item.callnumber = item.callnumber || "";
50     item.itemtype = item.itemtype || "";
51     item.barcode = item.barcode || barcode;
52     var trans = { "timestamp" : new Date().toMySQLString(),
53                   "barcode" : barcode,
54                   "action" : "return"
55                 };
56     $('#alerts').empty();
57     $('.offline-home').hide();
58     $('.offline-sync').hide();
59     $('.offline-circulation').hide();
60     $('.offline-circulation-instructions').hide();
61     $('.offline-returns').show();
62     kohadb.recordTransaction(trans, function () {
63         $('#session-returned').show();
64         $('#already-checked-in tbody').prepend('<tr><td>' + item.title + '</td><td>' + item.author + '</td><td>' + barcode + '</td><td>' + item.homebranch + '</td><td>' + item.holdingbranch + '</td><td></td><td>' + item.callnumber + '</td><td>' + item.itemtype + '</td></tr>');
65         if (alerts.length > 0) {
66             $('#alerts').append('<div class="dialog alert"><h3>' + _("Check in message") + '</h3></div>');
67             for (var msg in alerts) {
68                 $('#alerts .dialog').append('<p>' + alerts[msg] + '</p');
69             }
70         } else {
71             $('#alerts').append('<div class="dialog"><h3>' + ALERT_SUCCESSFUL_CHECKIN + '</h3></div>');
72         }
73     });
74     setTimeout(function() { $('#checkin-barcode').trigger('focus'), 1 });
75 }
76
77 function checkAlerts(barcode, item) {
78     var alerts = [];
79     if (typeof item === 'undefined') {
80         alerts.push(ALERT_NO_MATCHING_ITEM + barcode);
81     } else {
82         if (typeof item.materials !== 'undefined' && item.materials != null) {
83             alerts.push(ALERT_MATERIALS + item.materials);
84         }
85     }
86     return alerts;
87 }
88
89 function showSyncInfo() {
90     kohadb.loadSetting("item-timestamp", showTimestamp);
91     kohadb.loadSetting("patron-timestamp", showTimestamp);
92     kohadb.loadSetting("issue-timestamp", showTimestamp);
93     kohadb.loadSetting("dirty", function (key, val) {
94         if (val) {
95             $('#upload-message').text(UPLOAD_PENDING_MESSAGE);
96         } else {
97             $('#upload-message').text(NO_UPLOAD_PENDING_MESSAGE);
98         }
99     });
100 }
101
102 function synchronize() {
103     kohadb.saveSetting("userid", "[% loggedinusername %]");
104     kohadb.saveSetting("branchcode", "[% LoginBranchcode %]");
105     showSyncInfo();
106     [% UNLESS (AllowOfflineCirculation) %]
107         reloadRecords();
108     [% END %]
109     showSyncInfo();
110     $('#download-records').click(reloadRecords);
111     $('#upload-transactions').click(function () {
112         $('.loading-overlay div').text(_("Uploading transactions, please wait..."));
113         $('.loading-overlay').show();
114         $.ajax({
115             type: "GET",
116             url: "/cgi-bin/koha/offline_circ/service.pl",
117         }).done(function (data) {
118             if (data) {
119                 $('.loading-overlay').hide();
120                 alert(_("Please log in to Koha and try again. (Error: '" + data + "')"));
121             } else {
122                 var uploadIter = $.indexedDB("koha").objectStore("transactions").each(uploadTransaction);
123                 uploadIter.done(function() {
124                     $.indexedDB("koha").transaction(["transactions"]).then(function(){
125                     }, function(err, e){
126                     }, function(transaction){
127                         transaction.objectStore("transactions").clear();
128                     });
129                     $('.loading-overlay').hide();
130                     kohadb.saveSetting("dirty", false);
131                     $('#upload-message').text(NO_UPLOAD_PENDING_MESSAGE);
132                 });
133             }
134         });
135     });
136
137 }
138
139 function showTimestamp(key, value) {
140     if (typeof value !== 'undefined') {
141         var ts = new Date(value);
142         $('#' + key).text($.datepicker.formatDate(dateformat, ts) + ' ' + ts.toTimeString());
143     } else {
144         $('#' + key).text(_("(never)"));
145     }
146 }
147
148 function reloadRecords(ev) {
149     $(".loading-overlay div").text(_("Loading records, please wait..."));
150     $(".loading-overlay").show();
151     start = new Date();
152     $.indexedDB("koha").transaction(["patrons", "items", "issues"]).then(function(){
153         loadRecords(0);
154     }, function(err, e){
155     }, function(transaction){
156         transaction.objectStore("patrons").clear();
157         transaction.objectStore("items").clear();
158         transaction.objectStore("issues").clear();
159     });
160     if (typeof ev !== 'undefined') {
161         ev.stopPropagation();
162     }
163 }
164
165 function uploadTransaction(transaction) {
166     $.ajax({
167         type: "POST",
168         url: "/cgi-bin/koha/offline_circ/service.pl",
169         data: { "userid" : kohadb.settings.userid,
170                 "branchcode" : kohadb.settings.branchcode,
171                 "timestamp" : transaction.value.timestamp,
172                 "action" : transaction.value.action,
173                 "barcode" : transaction.value.barcode,
174                 "cardnumber" : transaction.value.cardnumber,
175                 "pending" : true,
176               },
177     });
178     return undefined, true;
179 }
180
181 function finishedLoading() {
182     kohadb.saveSetting('item-timestamp', start.toISOString())
183     kohadb.saveSetting('patron-timestamp', start.toISOString())
184     kohadb.saveSetting('issue-timestamp', start.toISOString())
185     showTimestamp('item-timestamp', start.toISOString());
186     showTimestamp('patron-timestamp', start.toISOString());
187     showTimestamp('issue-timestamp', start.toISOString());
188     $(".loading-overlay").hide();
189 }
190
191 function loadRecords(page) {
192 [% IF (AllowOfflineCirculation) %]
193     $(".loading-overlay div").text(_("Loading page " + page + ", please wait..."));
194     $(".loading-overlay").show();
195     $.ajax({
196         type: "GET",
197         url: "/cgi-bin/koha/offline_circ/download.pl",
198         data: { "data": "all",
199                 "page": page
200               },
201         dataType: "json",
202     }).done(function (data) {
203         $.indexedDB("koha").transaction(["patrons", "items", "issues"]).then(function(){
204             if (data.finished) {
205                 finishedLoading();
206             } else {
207                 setTimeout(function () { loadRecords(page + 1); }, 200);
208             }
209         }, function(err, e){
210         }, function(transaction){
211             if (data.patrons) {
212                 var patrons = transaction.objectStore("patrons");
213                 $.each(data.patrons, function () {
214                     patrons.put(this);
215                 });
216             }
217             if (data.items) {
218                 var items = transaction.objectStore("items");
219                 $.each(data.items, function () {
220                     items.put(this);
221                 });
222             }
223             if (data.issues) {
224                 var issues = transaction.objectStore("issues");
225                 $.each(data.issues, function () {
226                     issues.put(this);
227                 });
228             }
229         });
230     });
231 [% END %]
232 }
233
234 function validate1(date) {
235     var today = new Date();
236     if ( date < today ) {
237         return true;
238      } else {
239         return false;
240      }
241 };
242
243 function loadPatron(barcode) {
244     $('#oldissues').hide();
245     $('#session-issues').hide();
246     $('#issuest tbody').empty();
247     $('#session-payments').hide();
248     $('.checkout-count').text(0);
249     $.indexedDB("koha").transaction(["patrons", "issues"]).then(function() {
250     }, function(err, e){
251     }, function(transaction){
252         var patrons = transaction.objectStore("patrons");
253         patrons.get(barcode).done(function (patron, error) {
254             showPatron(barcode, patron, error);
255         });
256         var issuesidx = transaction.objectStore("issues").index("cardnumber");
257         $('#oldissuest tbody').empty();
258         issuesidx.each(function (item) {
259             $('#oldissues').show();
260             $('#oldissuest tbody').append("<tr><td>" + item.value.date_due + "</td><td>" + item.value.barcode + "</td><td>" + item.value.title + "</td><td>" + item.value.itype + "</td><td>" + item.value.issuedate + "</td><td>" + item.value.issuebranch + "</td><td>" + item.value.callnumber + "</td><td>" + "" + "</td></tr>");
261             $('.checkout-count').text(parseInt($('.checkout-count').text()) + 1);
262         }, barcode);
263     });
264 }
265
266 function checkout(barcode, item, error) {
267     var alerts = checkAlerts(barcode, item);
268     if (typeof item === 'undefined') {
269         item = { };
270     }
271     item.title = item.title || "";
272     item.author = item.author || "";
273     item.homebranch = item.homebranch || "";
274     item.holdingbranch = item.holdingbranch || "";
275     item.callnumber = item.callnumber || "";
276     item.itemtype = item.itemtype || "";
277     if ($('#duedatespec').val().length === 0) {
278         alert(_("You must set a due date in order to use offline circulation!"));
279         setTimeout(function() { $('#duedatespec').trigger('focus'), 1 });
280         return;
281     }
282     var date_due = new Date($('#duedatespec').datepicker('getDate'));
283     var trans = { "timestamp" : new Date().toMySQLString(),
284                   "barcode" : barcode,
285                   "cardnumber" : curpatron.cardnumber,
286                   "date_due" : date_due.toMySQLString(),
287                   "action" : "issue"
288                 };
289     $('#alerts').empty();
290     kohadb.recordTransaction(trans, function () {
291         $('#session-issues').show();
292         $('#issuest tbody').prepend('<tr><td>' + $.datepicker.formatDate(dateformat, date_due) + date_due.toTimeString() + '</td><td>' + item.title + '</td><td>' + barcode + '</td><td>' + item.itemtype + '</td><td>' + $.datepicker.formatDate(dateformat, new Date()) + '</td><td>' + kohadb.settings.branchcode + '</td><td>' + item.callnumber + '</td><td></td></tr>');
293         $('.checkout-count').text(parseInt($('.checkout-count').text()) + 1);
294         if (alerts.length > 0) {
295             $('#alerts').append('<div class="dialog alert"><h3>' + _("Check out message") + '</h3></div>');
296             for (var msg in alerts) {
297                 $('#alerts .dialog').append('<p>' + alerts[msg] + '</p');
298             }
299         }
300         $('#checkout-barcode').val('');
301     });
302 }
303
304 function recordFine(amount) {
305     var timestamp = new Date()
306     var trans = { "timestamp" : timestamp.toMySQLString(),
307                   "cardnumber" : curpatron.cardnumber,
308                   "amount" : amount,
309                   "action" : "payment",
310                 };
311     kohadb.recordTransaction(trans, function () {
312         $('#session-payments').show();
313         $('#session-payments tbody').prepend('<tr><td>' + amount + '</td><td>' + $.datepicker.formatDate(dateformat, timestamp) + timestamp.toTimeString() + '</td></tr>');
314         $('.fine-amount').text(parseInt($('.fine-amount').text) - amount);
315     });
316 }
317
318 function checkPatronAlerts(cardnumber, patron) {
319     var alerts = [];
320     if (typeof patron === 'undefined') {
321         alerts.push(ALERT_NO_MATCHING_PATRON + cardnumber);
322     } else {
323         if (patron.gonenoaddress !== '0') {
324             alerts.push(ALERT_PATRON_GONE_NO_ADDRESS);
325         }
326         if (patron.lost !== '0') {
327             alerts.push(ALERT_PATRON_CARD_LOST);
328         }
329         if (patron.debarred !== null) {
330             if (patron.debarred != '9999-12-31') {
331                 alerts.push(ALERT_PATRON_BLOCKED_TEMPORARY + $.datepicker.formatDate(dateformat, patron.debarred));
332             } else {
333                 alerts.push(ALERT_PATRON_RESTRICTED);
334             }
335         }
336         if (parseInt(patron.fine) > [% maxoutstanding %]) {
337             alerts.push(ALERT_PATRON_FINE_OVER_LIMIT + patron.fine);
338         } else if (parseInt(patron.fine) > 0) {
339             alerts.push(ALERT_PATRON_FINE + patron.fine);
340         }
341     }
342     return alerts;
343 }
344
345 var curpatron;
346
347 function showPatron(barcode, patron, error) {
348     var alerts = checkPatronAlerts(barcode, patron);
349     if (typeof patron === 'undefined') {
350         patron = { };
351     }
352     patron.surname = patron.surname || "";
353     patron.firstname = patron.firstname || "";
354     patron.othernames = patron.othernames || "";
355     patron.address = patron.address || "";
356     patron.address2 = patron.address2 || "";
357     patron.city = patron.city || "";
358     patron.state = patron.state || "";
359     patron.country = patron.country || "";
360     patron.zipcode = patron.zipcode || "";
361     patron.phone = patron.phone || "";
362     patron.mobile = patron.mobile || "";
363     patron.phonepro = patron.phonepro || "";
364     patron.email = patron.email || "";
365     patron.emailpro = patron.emailpro || "";
366     patron.categorycode = patron.categorycode || "";
367     patron.branchcode = patron.branchcode || "";
368     patron.cardnumber = barcode;
369     patron.fine = patron.fine || "0";
370
371     patron.name = patron.firstname + (patron.othernames.length > 0 ? " (" + patron.othernames + ") " : " ") + patron.surname + " (" + barcode + ")";
372     if (patron.name.length > 0) {
373         $('.patron-title').text(patron.name);
374     } else {
375         $('.patron-title').text(_("Unrecognized patron") + " (" + barcode + ")");
376     }
377     if (patron.address.length > 0 || patron.address2.length > 0) {
378         $('#patron-address-1').text(patron.address);
379         $('#patron-address-2').text(patron.address2);
380     } else {
381         $('#patron-address-1').html('<span class="empty" id="noaddressstored">' + _("No address stored.") + '</span></li>');
382         $('#patron-address-2').text('');
383     }
384     if (patron.city.length > 0) {
385         $('#patron-address-parts').text(patron.city + (patron.state.length > 0 ? ", " + patron.state : "") + " " + patron.zipcode + (patron.country.length > 0 ? ", " + patron.country : ""));
386     } else {
387         $('#patron-address-parts').html('<span class="empty" id="nocitystored">' + _("No city stored.") + '</span></li>');
388     }
389     if (patron.phone.length > 0 || patron.mobile.length > 0 || patron.phonepro.length > 0) {
390         $('#patron-phone').text((patron.phone.length > 0 ? patron.phone : (patron.mobile.length > 0 ? patron.mobile : (patron.phonepro.length > 0 ? patron.phonepro : ''))));
391     } else {
392         $('#patron-phone').html('<span class="empty" id="nophonestored">' + _("No phone stored.") + '</span></li>');
393     }
394     if (patron.email.length > 0 || patron.emailpro.length > 0) {
395         $('#patron-email').text((patron.email.length > 0 ? patron.email : (patron.emailpro.length > 0 ? patron.emailpro : "")));
396     } else {
397         $('#patron-email').html('<span class="empty" id="noemailstored">' + _("No email stored.") + '</span></li>');
398     }
399     if (patron.categorycode.length > 0) {
400         $('#patron-category').text(_("Category: ") + patron.categorycode);
401     } else {
402         $('#patron-category').html('<span class="empty" id="unknowncategory">' + _("Category code unknown.") + '</span></li>');
403     }
404     if (patron.branchcode.length > 0) {
405         $('#patron-library').text(_("Home library: ") + patron.branchcode);
406     } else {
407         $('#patron-library').html('<span class="empty" id="unknowncategory">' + _("Home library unknown.") + '</span></li>');
408     }
409     $('.fine-amount').text(patron.fine);
410     $('#alerts').empty();
411     if (alerts.length > 0) {
412         $('#alerts').append('<div class="dialog alert"><h3>' + _("Check out message") + '</h3></div>');
413         for (var msg in alerts) {
414             $('#alerts .dialog').append('<p>' + alerts[msg] + '</p>');
415         }
416     }
417     curpatron = patron;
418     $('#yui-main').show();
419     setTimeout(function() { $('#checkout-barcode').trigger('focus'), 1 });
420 }
421
422 // This next bit of code is to deal with the updated session issue
423 window.addEventListener('load', function(e) {
424     window.applicationCache.addEventListener('updateready', function(e) {
425         if (window.applicationCache.status == window.applicationCache.UPDATEREADY) {
426             // Browser downloaded a new app cache.
427             // Swap it in and reload the page to get the new hotness.
428             window.applicationCache.swapCache();
429             if (confirm(_("A new version of this site is available. Load it?"))) {
430                 window.location.reload();
431             }
432         } else {
433         // Manifest didn't changed. Nothing new to server.
434         }
435     }, false);
436 }, false);
437
438
439 $(document).ready(function () {
440     kohadb.initialize();
441
442     // Returns code
443     $('#checkin-form, #checkin_search form').submit(function (event) {
444         event.preventDefault();
445         var barcode = $('input[name="barcode"]', this).val();
446         $('input[name="barcode"]', this).val('');
447         $.indexedDB("koha").transaction(["items"]).then(function() {
448         }, function(err, e){
449         }, function(transaction){
450             var items = transaction.objectStore("items");
451             items.get(barcode).done(function (item, error) {
452                 checkin(barcode, item, error);
453             });
454         });
455     });
456
457     $('#go-to-home').click(function () {
458         $('#alerts').empty();
459         $('.offline-sync').hide();
460         $('.offline-circulation').hide();
461         $('.offline-returns').hide();
462         $('.offline-circulation-instructions').hide();
463         $('.offline-home').show();
464     });
465
466     $('#go-to-returns').click(function () {
467         $('#alerts').empty();
468         $('.offline-home').hide();
469         $('.offline-sync').hide();
470         $('.offline-circulation').hide();
471         $('.offline-circulation-instructions').hide();
472         $('.offline-returns').show();
473         setTimeout(function() { $('#checkin-form input[name="barcode"]').trigger('focus'), 1 });
474     });
475
476     $('#go-to-circ').click(function () {
477         $('#alerts').empty();
478         $('.offline-home').hide();
479         $('.offline-sync').hide();
480         $('.offline-returns').hide();
481         $('.offline-circulation').hide();
482         $('.offline-circulation-instructions').show();
483         $('#header_search').tabs("option", "active", 0);
484         setTimeout(function() { $('#circ_search input[name="findborrower"]').trigger('focus'), 1 });
485     });
486
487     $('#go-to-sync').click(function () {
488         $('#alerts').empty();
489         showSyncInfo();
490         $.ajax({
491             type: "GET",
492             url: "/cgi-bin/koha/offline_circ/list.pl",
493             success: function () {
494                 $('.offline-home').hide();
495                 $('.offline-returns').hide();
496                 $('.offline-circulation').hide();
497                 $('.offline-circulation-instructions').hide();
498                 $('.offline-sync').show();
499                 synchronize();
500             },
501             error: function () {
502                 alert(_("You are offline and therefore cannot sync your database"));
503             }
504         });
505     });
506
507     $('#go-to-pending').click(function (ev) {
508         $('#alerts').empty();
509         ev.preventDefault();
510         $.ajax({
511             type: "GET",
512             url: "/cgi-bin/koha/offline_circ/list.pl",
513             success: function () {
514                 window.location = '/cgi-bin/koha/offline_circ/list.pl';
515             },
516             error: function () {
517                 alert(_("You are offline and therefore cannot process pending operations"));
518             }
519         });
520     });
521
522     $('#patronsearch').submit(function (event) {
523         event.preventDefault();
524         loadPatron($('#findborrower').val());
525         $('.offline-home').hide();
526         $('.offline-returns').hide();
527         $('.offline-sync').hide();
528         $('.offline-circulation-instructions').hide();
529         $('.offline-circulation').show();
530         $('#findborrower').val('');
531         setTimeout(function() { $('#checkout-barcode').trigger('focus'), 1 });
532     });
533
534     $('#pay-fine').click(function (event) {
535         event.preventDefault();
536         recordFine($('#pay-fine-amount').val());
537     });
538
539     $('#patronlists').tabs();
540
541     $("#newduedate").datetimepicker({
542         minDate: 1, // require that renewal date is after today
543         hour: 23,
544         minute: 59
545     });
546     $("#duedatespec").datetimepicker({
547         onClose: function(dateText, inst) { setTimeout(function() { $('#checkout-barcode').trigger('focus'), 1 }); },
548         hour: 23,
549         minute: 59
550     });
551     $('#mainform').submit(function (event) {
552         event.preventDefault();
553         var barcode = $('#checkout-barcode').val();
554         $.indexedDB("koha").transaction(["items"]).then(function() {
555         }, function(err, e){
556         }, function(transaction){
557             var items = transaction.objectStore("items");
558             items.get(barcode).done(function (item, error) {
559                 checkout(barcode, item, error);
560             });
561         });
562     });
563 });
564 //]]>
565 </script>
566 </head>
567 <body id="circ_offline" class="circ">
568 [% INCLUDE 'header.inc' %]
569 [% INCLUDE 'circ-search.inc' %]
570 <div class="loading-overlay" style="display: none;">
571     <div>Downloading records, please wait...</div>
572 </div>
573
574 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a id="go-to-home" href="#offline-home">Offline circulation</a></div>
575
576 <div id="doc3" class="yui-t2">
577
578     <div id="bd">
579         <div id="yui-main">
580             <audio id="alert_sound" src="[% interface %]/prog/sound/critical.ogg" autobuffer="autobuffer"></audio>
581             <audio id="success_sound" src="[% interface %]/prog/sound/beep.ogg" autobuffer="autobuffer"></audio>
582
583             <div id="alerts" class="yui-b">
584             </div>
585             [% UNLESS (AllowOfflineCirculation) %]
586                 <div id="noofflinecircwarning" class="dialog alert">
587                     <p><strong>Warning:</strong> Offline Circulation has been disabled. You may continue and record transactions, but patron and item information will not be available.</p>
588                 </div>
589             [% END %]
590
591             <div id="offline-home" class="yui-b offline-home">
592                 <div class="yui-g">
593                     <h1>Offline circulation</h1>
594                     <div class="yui-u first">
595                         <ul>
596                             <li><a id="go-to-circ" href="#offline-circulation">Check out</a></li>
597                             <li><a id="go-to-returns" href="#offline-returns">Check in</a></li>
598                         </ul>
599                     </div>
600
601                     <div class="yui-u">
602                         <p><strong>Note:</strong> You must be online to use these options.</p>
603                         <ul>
604                             <li><a id="go-to-sync" href="#offline-sync">Synchronize</a></li>
605                             <li><a id="go-to-pending" href="/cgi-bin/koha/offline_circ/list.pl">Pending offline circulation actions</a>
606                         </ul>
607                     </div>
608                 </div>
609             </div>
610
611             <div id="offline-sync" style="display: none;" class="yui-b offline-sync">
612                 <div id="toolbar" class="btn-toolbar">
613                     [% IF (AllowOfflineCirculation) %]
614                         <a href="#" id="download-records" class="btn btn-small"><i class="icon-arrow-down"></i>Download records</a>
615                     [% END %]
616                     <a href="#" id="upload-transactions" class="btn btn-small"><i class="icon-arrow-up"></i>Upload transactions</a>
617                 </div>
618                 <div class="yui-g">
619                     <h1>Offline circulation</h1>
620                     <div class="yui-u first">
621                         <div id="download-message">
622                             In order for offline circulation to work on this computer,
623                             your library's records must be up-to-date on this computer:
624                             <ul>
625                                 <li>Patron records were last synced on: <span id="patron-timestamp">(checking)</span></li>
626                                 <li>Item records were last synced on: <span id="item-timestamp">(checking)</span></li>
627                                 <li>Circulation records were last synced on: <span id="issue-timestamp">(checking)</span></li>
628                             </ul>
629                         </div>
630                     </div>
631
632                     <div class="yui-u">
633                         <div id="upload-message">
634                         </div>
635                         <div>View <a href="/cgi-bin/koha/offline_circ/list.pl">pending offline circulation actions</a></div>
636                     </div>
637                 </div>
638             </div>
639
640             <div id="offline-returns" style="display: none;" class="yui-b offline-returns">
641                 <div class="yui-g">
642                     <form id="checkin-form" method="post" action="/cgi-bin/koha/circ/returns.pl" autocomplete="off" >
643                         <div class="yui-u first">
644                             <fieldset>
645                                 <legend>Check In</legend>
646                                 <label for="checkin-barcode">Enter item barcode: </label>
647                                 <input name="barcode" id="checkin-barcode" size="14" class="focus"/>
648                                 <input type="submit" class="submit" value="Submit" />
649                             </fieldset>
650                         </div>
651                     </form>
652                 </div>
653
654                 <div id="session-returned" style="display: none;">
655                     <h2>Checked-in items</h2>
656                     <table id="already-checked-in">
657                         <thead>
658                             <tr><th>Title</th><th>Author</th><th>Barcode</th><th>Home library</th><th>Holding library</th><th>Shelving location</th><th>Call number</th><th>Type</th></tr>
659                         </thead>
660                         <tbody>
661                         </tbody>
662                     </table>
663                 </div>
664             </div>
665
666             <div style="display: none;" class="yui-b offline-circulation-instructions">
667                 <div class="yui-g">
668                     Scan a patron barcode to start.
669                 </div>
670             </div>
671
672             <div id="offline-circulation" style="display: none;" class="yui-b offline-circulation">
673                 <div class="yui-g">
674                     <form method="post" action="/cgi-bin/koha/circ/offline.pl" id="mainform" name="mainform" autocomplete="off">
675                         <fieldset id="circ_circulation_issue">
676                             <span id="clearscreen"><a href="/cgi-bin/koha/circ/offline.pl" title="Clear screen">x</a></span>
677                             <label for="checkout-barcode">Checking out to <span class="patron-title"></span></label>
678                             <div class="hint">Enter item barcode:</div>
679                             <input type="text" name="barcode" id="checkout-barcode" class="barcode focus" size="14" />
680                             <input type="submit" value="Check Out" />
681
682                             <div class="date-select">
683                                 <div class="hint">Specify due date [% INCLUDE 'date-format.inc' %]: </div>
684                                 <input type="text" size="13" id="duedatespec" name="duedatespec" value="[% duedatespec %]" readonly="readonly" />
685                                 <label for="stickyduedate"> Remember for session:</label>
686                                 <input type="checkbox" id="stickyduedate" onclick="this.form.barcode.focus();" name="stickyduedate" checked="checked" />
687                                 <input type="button" class="action" id="cleardate" value="Clear" name="cleardate" onclick="this.checked = false; this.form.duedatespec.value = ''; this.form.stickyduedate.checked = false; this.form.barcode.focus(); return false;" />
688                             </div>
689                         </fieldset>
690                     </form>
691                 </div>
692
693                 <div class="yui-g"><div id="patronlists" class="toptabs">
694                     <ul>
695                         <li><a href="#checkouts"><span class="checkout-count">0</span> Checkouts</a></li>
696                         <li><a href="#fines"><span class="fine-amount">0</span> in fines</a></li>
697                     </ul>
698
699                     <!-- SUMMARY : TODAY & PREVIOUS ISSUES -->
700                     <div id="checkouts">
701                         <div id="session-issues">
702                             <table id="issuest">
703                                 <thead><tr>
704                                     <th scope="col">Due date</th>
705                                     <th scope="col">Title</th>
706                                     <th scope="col">Barcode</th>
707                                     <th scope="col">Item type</th>
708                                     <th scope="col">Checked out on</th>
709                                     <th scope="col">Checked out from</th>
710                                     <th scope="col">Call no</th>
711                                     <th scope="col">Charge</th>
712                                 </tr></thead>
713                                 <tbody>
714                                 </tbody>
715                             </table>
716                         </div>
717
718                         <div id="oldissues">
719                             <h5>Previous checkouts</h5>
720                             <table id="oldissuest">
721                                 <thead><tr>
722                                     <th scope="col">Due date</th>
723                                     <th scope="col">Title</th>
724                                     <th scope="col">Barcode</th>
725                                     <th scope="col">Item type</th>
726                                     <th scope="col">Checked out on</th>
727                                     <th scope="col">Checked out from</th>
728                                     <th scope="col">Call no</th>
729                                     <th scope="col">Charge</th>
730                                 </tr></thead>
731                                 <tbody>
732                                 </tbody>
733                             </table>
734                         </div>
735                     </div>
736
737                     <div id="fines">
738                         <span class="patron-title"></span> has <span class="fine-amount">0</span> in fines. If you would like you can record payments.
739                         <fieldset><legend>Pay fines</legend>
740                             <label for="pay-fine-amount">Fine amount: </label><input type="text" name="pay-fine-amount" id="pay-fine-amount"/>
741                             <button id="pay-fine" class="submit">Pay fine</button>
742
743                             <table id="session-payments" style="display: none;">
744                                 <thead><tr><th>Amount</th><th>Timestamp</th></tr></thead>
745                                 <tbody></tbody>
746                             </table>
747                         </fieldset>
748                     </div>
749                 </div>
750             </div>
751         </div>
752     </div>
753
754     <div class="yui-b offline-circulation" style="display: none;">
755         <div class="patroninfo"><h5 class="patron-title"></h5>
756             <ul>
757                 <li id="patron-address-1"></li>
758                 <li id="patron-address-2"></li>
759                 <li id="patron-address-parts"><!-- city, state, zipcode, country --></li>
760                 <li id="patron-phone"></li>
761                 <li id="patron-email"></li>
762                 <li id="patron-category"></li>
763                 <li id="patron-library"></li>
764             </ul>
765         </div>
766
767 [% INCLUDE 'intranet-bottom.inc' %]