Bug 10240: (follow-up) correctly record fines and fix label
[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 (proceeding 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 until: ");
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                 "amount" : transaction.value.amount,
176                 "pending" : true,
177               },
178     });
179     return undefined, true;
180 }
181
182 function finishedLoading() {
183     kohadb.saveSetting('item-timestamp', start.toISOString())
184     kohadb.saveSetting('patron-timestamp', start.toISOString())
185     kohadb.saveSetting('issue-timestamp', start.toISOString())
186     showTimestamp('item-timestamp', start.toISOString());
187     showTimestamp('patron-timestamp', start.toISOString());
188     showTimestamp('issue-timestamp', start.toISOString());
189     $(".loading-overlay").hide();
190 }
191
192 function loadRecords(page) {
193 [% IF (AllowOfflineCirculation) %]
194     $(".loading-overlay div").text(_("Loading page " + page + ", please wait..."));
195     $(".loading-overlay").show();
196     $.ajax({
197         type: "GET",
198         url: "/cgi-bin/koha/offline_circ/download.pl",
199         data: { "data": "all",
200                 "page": page
201               },
202         dataType: "json",
203     }).done(function (data) {
204         $.indexedDB("koha").transaction(["patrons", "items", "issues"]).then(function(){
205             if (data.finished) {
206                 finishedLoading();
207             } else {
208                 setTimeout(function () { loadRecords(page + 1); }, 200);
209             }
210         }, function(err, e){
211         }, function(transaction){
212             if (data.patrons) {
213                 var patrons = transaction.objectStore("patrons");
214                 $.each(data.patrons, function () {
215                     patrons.put(this);
216                 });
217             }
218             if (data.items) {
219                 var items = transaction.objectStore("items");
220                 $.each(data.items, function () {
221                     items.put(this);
222                 });
223             }
224             if (data.issues) {
225                 var issues = transaction.objectStore("issues");
226                 $.each(data.issues, function () {
227                     issues.put(this);
228                 });
229             }
230         });
231     });
232 [% END %]
233 }
234
235 function validate1(date) {
236     var today = new Date();
237     if ( date < today ) {
238         return true;
239      } else {
240         return false;
241      }
242 };
243
244 function loadPatron(barcode) {
245     $('#oldissues').hide();
246     $('#session-issues').hide();
247     $('#issuest tbody').empty();
248     $('#session-payments').hide();
249     $('.checkout-count').text(0);
250     $.indexedDB("koha").transaction(["patrons", "issues"]).then(function() {
251     }, function(err, e){
252     }, function(transaction){
253         var patrons = transaction.objectStore("patrons");
254         patrons.get(barcode).done(function (patron, error) {
255             showPatron(barcode, patron, error);
256         });
257         var issuesidx = transaction.objectStore("issues").index("cardnumber");
258         $('#oldissuest tbody').empty();
259         issuesidx.each(function (item) {
260             $('#oldissues').show();
261             $('#oldissuest tbody').append("<tr><td>" + item.value.date_due + "</td><td>" + item.value.title + "</td><td>" + item.value.barcode + "</td><td>" + item.value.itype + "</td><td>" + item.value.issuedate + "</td><td>" + item.value.issuebranch + "</td><td>" + item.value.callnumber + "</td><td>" + "" + "</td></tr>");
262             $('.checkout-count').text(parseInt($('.checkout-count').text()) + 1);
263         }, barcode);
264     });
265 }
266
267 function checkout(barcode, item, error) {
268     var alerts = checkAlerts(barcode, item);
269     if (typeof item === 'undefined') {
270         item = { };
271     }
272     item.title = item.title || "";
273     item.author = item.author || "";
274     item.homebranch = item.homebranch || "";
275     item.holdingbranch = item.holdingbranch || "";
276     item.callnumber = item.callnumber || "";
277     item.itemtype = item.itemtype || "";
278     if ($('#duedatespec').val().length === 0) {
279         alert(_("You must set a due date in order to use offline circulation!"));
280         setTimeout(function() { $('#duedatespec').trigger('focus'), 1 });
281         return;
282     }
283     var date_due = new Date($('#duedatespec').datepicker('getDate'));
284     var trans = { "timestamp" : new Date().toMySQLString(),
285                   "barcode" : barcode,
286                   "cardnumber" : curpatron.cardnumber,
287                   "date_due" : date_due.toMySQLString(),
288                   "action" : "issue"
289                 };
290     $('#alerts').empty();
291     kohadb.recordTransaction(trans, function () {
292         $('#session-issues').show();
293         $('#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>');
294         $('.checkout-count').text(parseInt($('.checkout-count').text()) + 1);
295         if (alerts.length > 0) {
296             $('#alerts').append('<div class="dialog alert"><h3>' + _("Check out message") + '</h3></div>');
297             for (var msg in alerts) {
298                 $('#alerts .dialog').append('<p>' + alerts[msg] + '</p');
299             }
300         }
301         $('#checkout-barcode').val('');
302     });
303 }
304
305 function recordFine(amount) {
306     var timestamp = new Date()
307     var trans = { "timestamp" : timestamp.toMySQLString(),
308                   "cardnumber" : curpatron.cardnumber,
309                   "amount" : amount,
310                   "action" : "payment",
311                 };
312     kohadb.recordTransaction(trans, function () {
313         $('#session-payments').show();
314         $('#session-payments tbody').prepend('<tr><td>' + amount + '</td><td>' + $.datepicker.formatDate(dateformat, timestamp) + timestamp.toTimeString() + '</td></tr>');
315         $('.fine-amount').text(parseInt($('.fine-amount').text()) - amount);
316     });
317 }
318
319 function checkPatronAlerts(cardnumber, patron) {
320     var alerts = [];
321     if (typeof patron === 'undefined') {
322         alerts.push(ALERT_NO_MATCHING_PATRON + cardnumber);
323     } else {
324         if (patron.gonenoaddress !== '0') {
325             alerts.push(ALERT_PATRON_GONE_NO_ADDRESS);
326         }
327         if (patron.lost !== '0') {
328             alerts.push(ALERT_PATRON_CARD_LOST);
329         }
330         if (patron.debarred !== null) {
331             if (patron.debarred != '9999-12-31') {
332                 alerts.push(ALERT_PATRON_BLOCKED_TEMPORARY + $.datepicker.formatDate(dateformat, new Date(patron.debarred)));
333             } else {
334                 alerts.push(ALERT_PATRON_RESTRICTED);
335             }
336         }
337         if (new Date(patron.dateexpiry) < new Date()) {
338             alerts.push(ALERT_PATRON_EXPIRED + ' (' + $.datepicker.formatDate(dateformat, new Date(patron.dateexpiry)) + ')');
339         }
340         if (parseInt(patron.fine) > [% maxoutstanding %]) {
341             alerts.push(ALERT_PATRON_FINE_OVER_LIMIT + patron.fine);
342         } else if (parseInt(patron.fine) > 0) {
343             alerts.push(ALERT_PATRON_FINE + patron.fine);
344         }
345     }
346     return alerts;
347 }
348
349 var curpatron;
350
351 function showPatron(barcode, patron, error) {
352     var alerts = checkPatronAlerts(barcode, patron);
353     if (typeof patron === 'undefined') {
354         patron = { };
355     }
356     patron.surname = patron.surname || "";
357     patron.firstname = patron.firstname || "";
358     patron.othernames = patron.othernames || "";
359     patron.address = patron.address || "";
360     patron.address2 = patron.address2 || "";
361     patron.city = patron.city || "";
362     patron.state = patron.state || "";
363     patron.country = patron.country || "";
364     patron.zipcode = patron.zipcode || "";
365     patron.phone = patron.phone || "";
366     patron.mobile = patron.mobile || "";
367     patron.phonepro = patron.phonepro || "";
368     patron.email = patron.email || "";
369     patron.emailpro = patron.emailpro || "";
370     patron.categorycode = patron.categorycode || "";
371     patron.branchcode = patron.branchcode || "";
372     patron.cardnumber = barcode;
373     patron.fine = patron.fine || "0";
374
375     patron.name = patron.firstname + (patron.othernames.length > 0 ? " (" + patron.othernames + ") " : " ") + patron.surname + " (" + barcode + ")";
376     if (patron.name.length > 0) {
377         $('.patron-title').text(patron.name);
378     } else {
379         $('.patron-title').text(_("Unrecognized patron") + " (" + barcode + ")");
380     }
381     if (patron.address.length > 0 || patron.address2.length > 0) {
382         $('#patron-address-1').text(patron.address);
383         $('#patron-address-2').text(patron.address2);
384     } else {
385         $('#patron-address-1').html('<span class="empty" id="noaddressstored">' + _("No address stored.") + '</span></li>');
386         $('#patron-address-2').text('');
387     }
388     if (patron.city.length > 0) {
389         $('#patron-address-parts').text(patron.city + (patron.state.length > 0 ? ", " + patron.state : "") + " " + patron.zipcode + (patron.country.length > 0 ? ", " + patron.country : ""));
390     } else {
391         $('#patron-address-parts').html('<span class="empty" id="nocitystored">' + _("No city stored.") + '</span></li>');
392     }
393     if (patron.phone.length > 0 || patron.mobile.length > 0 || patron.phonepro.length > 0) {
394         $('#patron-phone').text((patron.phone.length > 0 ? patron.phone : (patron.mobile.length > 0 ? patron.mobile : (patron.phonepro.length > 0 ? patron.phonepro : ''))));
395     } else {
396         $('#patron-phone').html('<span class="empty" id="nophonestored">' + _("No phone stored.") + '</span></li>');
397     }
398     if (patron.email.length > 0 || patron.emailpro.length > 0) {
399         $('#patron-email').text((patron.email.length > 0 ? patron.email : (patron.emailpro.length > 0 ? patron.emailpro : "")));
400     } else {
401         $('#patron-email').html('<span class="empty" id="noemailstored">' + _("No email stored.") + '</span></li>');
402     }
403     if (patron.categorycode.length > 0) {
404         $('#patron-category').text(_("Category: ") + patron.categorycode);
405     } else {
406         $('#patron-category').html('<span class="empty" id="unknowncategory">' + _("Category code unknown.") + '</span></li>');
407     }
408     if (patron.branchcode.length > 0) {
409         $('#patron-library').text(_("Home library: ") + patron.branchcode);
410     } else {
411         $('#patron-library').html('<span class="empty" id="unknowncategory">' + _("Home library unknown.") + '</span></li>');
412     }
413     $('.fine-amount').text(patron.fine);
414     $('#alerts').empty();
415     if (alerts.length > 0) {
416         $('#alerts').append('<div class="dialog alert"><h3>' + _("Check out message") + '</h3></div>');
417         for (var msg in alerts) {
418             $('#alerts .dialog').append('<p>' + alerts[msg] + '</p>');
419         }
420     }
421     curpatron = patron;
422     $('#yui-main').show();
423     setTimeout(function() { $('#checkout-barcode').trigger('focus'), 1 });
424 }
425
426 // This next bit of code is to deal with the updated session issue
427 window.addEventListener('load', function(e) {
428     window.applicationCache.addEventListener('updateready', function(e) {
429         if (window.applicationCache.status == window.applicationCache.UPDATEREADY) {
430             // Browser downloaded a new app cache.
431             // Swap it in and reload the page to get the new hotness.
432             window.applicationCache.swapCache();
433             if (confirm(_("A new version of this site is available. Load it?"))) {
434                 window.location.reload();
435             }
436         } else {
437         // Manifest didn't changed. Nothing new to server.
438         }
439     }, false);
440 }, false);
441
442
443 $(document).ready(function () {
444     kohadb.initialize();
445     $('#header_search #circ_search .tip').text(_("Enter patron card number:"));
446
447     $('ul[aria-labelledby="drop3"]').html('<li><a class="toplinks">You cannot change your branch or logout while using offline circulation</a></li>');
448
449     // Returns code
450     $('#checkin-form, #checkin_search form').submit(function (event) {
451         event.preventDefault();
452         var barcode = $('input[name="barcode"]', this).val();
453         $('input[name="barcode"]', this).val('');
454         $.indexedDB("koha").transaction(["items"]).then(function() {
455         }, function(err, e){
456         }, function(transaction){
457             var items = transaction.objectStore("items");
458             items.get(barcode).done(function (item, error) {
459                 checkin(barcode, item, error);
460             });
461         });
462     });
463
464     $('#go-to-home').click(function () {
465         $('#alerts').empty();
466         $('.offline-sync').hide();
467         $('.offline-circulation').hide();
468         $('.offline-returns').hide();
469         $('.offline-circulation-instructions').hide();
470         $('.offline-home').show();
471     });
472
473     $('#go-to-returns').click(function () {
474         $('#alerts').empty();
475         $('.offline-home').hide();
476         $('.offline-sync').hide();
477         $('.offline-circulation').hide();
478         $('.offline-circulation-instructions').hide();
479         $('.offline-returns').show();
480         setTimeout(function() { $('#checkin-form input[name="barcode"]').trigger('focus'), 1 });
481     });
482
483     $('#go-to-circ').click(function () {
484         $('#alerts').empty();
485         $('.offline-home').hide();
486         $('.offline-sync').hide();
487         $('.offline-returns').hide();
488         $('.offline-circulation').hide();
489         $('.offline-circulation-instructions').show();
490         $('#header_search').tabs("option", "active", 0);
491         setTimeout(function() { $('#circ_search input[name="findborrower"]').trigger('focus'), 1 });
492     });
493
494     $('#go-to-sync').click(function () {
495         $('#alerts').empty();
496         showSyncInfo();
497         $.ajax({
498             type: "GET",
499             url: "/cgi-bin/koha/offline_circ/list.pl",
500             success: function () {
501                 $('.offline-home').hide();
502                 $('.offline-returns').hide();
503                 $('.offline-circulation').hide();
504                 $('.offline-circulation-instructions').hide();
505                 $('.offline-sync').show();
506                 synchronize();
507             },
508             error: function () {
509                 alert(_("You are offline and therefore cannot sync your database"));
510             }
511         });
512     });
513
514     $('#go-to-pending').click(function (ev) {
515         $('#alerts').empty();
516         ev.preventDefault();
517         $.ajax({
518             type: "GET",
519             url: "/cgi-bin/koha/offline_circ/list.pl",
520             success: function () {
521                 window.location = '/cgi-bin/koha/offline_circ/list.pl';
522             },
523             error: function () {
524                 alert(_("You are offline and therefore cannot process pending operations"));
525             }
526         });
527     });
528
529     $('#patronsearch').submit(function (event) {
530         event.preventDefault();
531         loadPatron($('#findborrower').val());
532         $('.offline-home').hide();
533         $('.offline-returns').hide();
534         $('.offline-sync').hide();
535         $('.offline-circulation-instructions').hide();
536         $('.offline-circulation').show();
537         $('#findborrower').val('');
538         setTimeout(function() { $('#checkout-barcode').trigger('focus'), 1 });
539     });
540
541     $('#pay-fine').click(function (event) {
542         event.preventDefault();
543         recordFine($('#pay-fine-amount').val());
544     });
545
546     $('#patronlists').tabs();
547
548     $("#newduedate").datetimepicker({
549         minDate: 1, // require that renewal date is after today
550         hour: 23,
551         minute: 59
552     });
553     $("#duedatespec").datetimepicker({
554         onClose: function(dateText, inst) { setTimeout(function() { $('#checkout-barcode').trigger('focus'), 1 }); },
555         hour: 23,
556         minute: 59
557     });
558     $('#mainform').submit(function (event) {
559         event.preventDefault();
560         var barcode = $('#checkout-barcode').val();
561         $.indexedDB("koha").transaction(["items"]).then(function() {
562         }, function(err, e){
563         }, function(transaction){
564             var items = transaction.objectStore("items");
565             items.get(barcode).done(function (item, error) {
566                 checkout(barcode, item, error);
567             });
568         });
569     });
570 });
571 //]]>
572 </script>
573 </head>
574 <body id="circ_offline" class="circ">
575 [% INCLUDE 'header.inc' %]
576 [% INCLUDE 'circ-search.inc' %]
577 <div class="loading-overlay" style="display: none;">
578     <div>Downloading records, please wait...</div>
579 </div>
580
581 <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>
582
583 <div id="doc3" class="yui-t2">
584
585     <div id="bd">
586         <div id="yui-main">
587             <audio id="alert_sound" src="[% interface %]/prog/sound/critical.ogg" autobuffer="autobuffer"></audio>
588             <audio id="success_sound" src="[% interface %]/prog/sound/beep.ogg" autobuffer="autobuffer"></audio>
589
590             <div id="alerts" class="yui-b">
591             </div>
592             [% UNLESS (AllowOfflineCirculation) %]
593                 <div id="noofflinecircwarning" class="dialog alert">
594                     <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>
595                 </div>
596             [% END %]
597
598             <div id="offline-home" class="yui-b offline-home">
599                 <div class="yui-g">
600                     <h1>Offline circulation</h1>
601                     <div class="yui-u first">
602                         <ul>
603                             <li><a id="go-to-circ" href="#offline-circulation">Check out</a></li>
604                             <li><a id="go-to-returns" href="#offline-returns">Check in</a></li>
605                         </ul>
606                     </div>
607
608                     <div class="yui-u">
609                         <p><strong>Note:</strong> You must be online to use these options.</p>
610                         <ul>
611                             <li><a id="go-to-sync" href="#offline-sync">Synchronize</a></li>
612                             <li><a id="go-to-pending" href="/cgi-bin/koha/offline_circ/list.pl">Pending offline circulation actions</a>
613                         </ul>
614                     </div>
615                 </div>
616             </div>
617
618             <div id="offline-sync" style="display: none;" class="yui-b offline-sync">
619                 <div id="toolbar" class="btn-toolbar">
620                     [% IF (AllowOfflineCirculation) %]
621                         <a href="#" id="download-records" class="btn btn-small"><i class="icon-arrow-down"></i>Download records</a>
622                     [% END %]
623                     <a href="#" id="upload-transactions" class="btn btn-small"><i class="icon-arrow-up"></i>Upload transactions</a>
624                 </div>
625                 <div class="yui-g">
626                     <h1>Offline circulation</h1>
627                     <div class="yui-u first">
628                         <div id="download-message">
629                             In order for offline circulation to work on this computer,
630                             your library's records must be up-to-date on this computer:
631                             <ul>
632                                 <li>Patron records were last synced on: <span id="patron-timestamp">(checking)</span></li>
633                                 <li>Item records were last synced on: <span id="item-timestamp">(checking)</span></li>
634                                 <li>Circulation records were last synced on: <span id="issue-timestamp">(checking)</span></li>
635                             </ul>
636                         </div>
637                     </div>
638
639                     <div class="yui-u">
640                         <div id="upload-message">
641                         </div>
642                         <div>View <a href="/cgi-bin/koha/offline_circ/list.pl">pending offline circulation actions</a></div>
643                     </div>
644                 </div>
645             </div>
646
647             <div id="offline-returns" style="display: none;" class="yui-b offline-returns">
648                 <div class="yui-g">
649                     <form id="checkin-form" method="post" action="/cgi-bin/koha/circ/returns.pl" autocomplete="off" >
650                         <div class="yui-u first">
651                             <fieldset>
652                                 <legend>Check In</legend>
653                                 <label for="checkin-barcode">Enter item barcode: </label>
654                                 <input name="barcode" id="checkin-barcode" size="14" class="focus"/>
655                                 <input type="submit" class="submit" value="Submit" />
656                             </fieldset>
657                         </div>
658                     </form>
659                 </div>
660
661                 <div id="session-returned" style="display: none;">
662                     <h2>Checked-in items</h2>
663                     <table id="already-checked-in">
664                         <thead>
665                             <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>
666                         </thead>
667                         <tbody>
668                         </tbody>
669                     </table>
670                 </div>
671             </div>
672
673             <div style="display: none;" class="yui-b offline-circulation-instructions">
674                 <div class="yui-g">
675                     Scan a patron barcode to start.
676                 </div>
677             </div>
678
679             <div id="offline-circulation" style="display: none;" class="yui-b offline-circulation">
680                 <div class="yui-g">
681                     <form method="post" action="/cgi-bin/koha/circ/offline.pl" id="mainform" name="mainform" autocomplete="off">
682                         <fieldset id="circ_circulation_issue">
683                             <span id="clearscreen"><a href="/cgi-bin/koha/circ/offline.pl" title="Clear screen">x</a></span>
684                             <label for="checkout-barcode">Checking out to <span class="patron-title"></span></label>
685                             <div class="hint">Enter item barcode:</div>
686                             <input type="text" name="barcode" id="checkout-barcode" class="barcode focus" size="14" />
687                             <input type="submit" value="Check Out" />
688
689                             <div class="date-select">
690                                 <div class="hint">Specify due date [% INCLUDE 'date-format.inc' %]: </div>
691                                 <input type="text" size="13" id="duedatespec" name="duedatespec" value="[% duedatespec %]" readonly="readonly" />
692                                 <label for="stickyduedate"> Remember for session:</label>
693                                 <input type="checkbox" id="stickyduedate" onclick="this.form.barcode.focus();" name="stickyduedate" checked="checked" />
694                                 <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;" />
695                             </div>
696                         </fieldset>
697                     </form>
698                 </div>
699
700                 <div class="yui-g"><div id="patronlists" class="toptabs">
701                     <ul>
702                         <li><a href="#checkouts"><span class="checkout-count">0</span> Checkouts</a></li>
703                         <li><a href="#fines"><span class="fine-amount">0</span> in fines</a></li>
704                     </ul>
705
706                     <!-- SUMMARY : TODAY & PREVIOUS ISSUES -->
707                     <div id="checkouts">
708                         <div id="session-issues">
709                             <table id="issuest">
710                                 <thead><tr>
711                                     <th scope="col">Due date</th>
712                                     <th scope="col">Title</th>
713                                     <th scope="col">Barcode</th>
714                                     <th scope="col">Item type</th>
715                                     <th scope="col">Checked out on</th>
716                                     <th scope="col">Checked out from</th>
717                                     <th scope="col">Call no</th>
718                                     <th scope="col">Charge</th>
719                                 </tr></thead>
720                                 <tbody>
721                                 </tbody>
722                             </table>
723                         </div>
724
725                         <div id="oldissues">
726                             <h5>Previous checkouts</h5>
727                             <table id="oldissuest">
728                                 <thead><tr>
729                                     <th scope="col">Due date</th>
730                                     <th scope="col">Title</th>
731                                     <th scope="col">Barcode</th>
732                                     <th scope="col">Item type</th>
733                                     <th scope="col">Checked out on</th>
734                                     <th scope="col">Checked out from</th>
735                                     <th scope="col">Call no</th>
736                                     <th scope="col">Charge</th>
737                                 </tr></thead>
738                                 <tbody>
739                                 </tbody>
740                             </table>
741                         </div>
742                     </div>
743
744                     <div id="fines">
745                         <span class="patron-title"></span> has <span class="fine-amount">0</span> in fines. If you would like you can record payments.
746                         <fieldset><legend>Pay fines</legend>
747                             <label for="pay-fine-amount">Fine amount: </label><input type="text" name="pay-fine-amount" id="pay-fine-amount"/>
748                             <button id="pay-fine" class="submit">Pay fine</button>
749
750                             <table id="session-payments" style="display: none;">
751                                 <thead><tr><th>Amount</th><th>Timestamp</th></tr></thead>
752                                 <tbody></tbody>
753                             </table>
754                         </fieldset>
755                     </div>
756                 </div>
757             </div>
758         </div>
759     </div>
760
761     <div class="yui-b offline-circulation" style="display: none;">
762         <div class="patroninfo"><h5 class="patron-title"></h5>
763             <ul>
764                 <li id="patron-address-1"></li>
765                 <li id="patron-address-2"></li>
766                 <li id="patron-address-parts"><!-- city, state, zipcode, country --></li>
767                 <li id="patron-phone"></li>
768                 <li id="patron-email"></li>
769                 <li id="patron-category"></li>
770                 <li id="patron-library"></li>
771             </ul>
772         </div>
773
774 [% INCLUDE 'intranet-bottom.inc' %]