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