2 [% IF (AllowOfflineCirculation) %]
3 [% SET manifestattr = 'manifest="/cgi-bin/koha/circ/offline-mf.pl"' %]
5 [% IF ( bidi ) %]<html lang="[% lang %]" dir="[% bidi %]" [% manifestattr %]>[% ELSE %]<html lang="[% lang %]" [% manifestattr %]>[% END %]
7 <title>Koha › Circulation</title>
8 [% INCLUDE 'doc-head-close.inc' %]
9 <script type="text/javascript" src="/intranet-tmpl/lib/jquery/plugins/jquery.indexeddb.js"></script>
10 <script type="text/javascript" src="/intranet-tmpl/prog/en/js/offlinecirc.js"></script>
11 <script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery-ui-timepicker-addon.js"></script>
12 <script type="text/javascript">
14 var ALERT_MATERIALS = _("Note about the accompanying materials: ");
15 var ALERT_RESTRICTED = _("Patron is RESTRICTED");
16 var ALERT_NO_MATCHING_ITEM = _("No item with barcode in offline database (transaction recorded anyway): ");
17 var ALERT_NOT_CHECKED_OUT = _("Item not listed as checked out in offline database (transaction recorded anyway)");
18 var ALERT_ITEM_WITHDRAWN = _("Item has been withdrawn (transaction recorded anyway)");
19 var ALERT_ITEM_RESTRICTED = _("Item is restricted (transaction recorded anyway)");
20 var ALERT_ITEM_LOST = _("Item is has been lost (transaction recorded anyway)");
21 var ALERT_NO_MATCHING_PATRON = _("No patron cardnumber in offline database (proceeding anyway): ");
22 var ALERT_PATRON_GONE_NO_ADDRESS = _("Patron's address is in doubt (transaction recorded anyway)");
23 var ALERT_PATRON_CARD_LOST = _("Patron's card is lost");
24 var ALERT_PATRON_EXPIRED = _("Patron's card is expired");
25 var ALERT_PATRON_BLOCKED_TEMPORARY = _("Patron has had overdue items and is restricted for: ");
26 var ALERT_PATRON_RESTRICTED = _("Patron is restricted");
27 var ALERT_PATRON_FINE = _("Patron has outstanding fines: ");
28 var ALERT_PATRON_FINE_OVER_LIMIT = _("Patron fines are over limit: ");
32 var dateformat = '[% IF ( dateformat_us ) %]mm/dd/yy[% ELSIF ( dateformat_metric ) %]dd/mm/yy[% ELSE %]yy-mm-dd[% END %]';
34 function checkin(barcode, item, error) {
35 var alerts = checkAlerts(barcode, item);
36 if (typeof item === 'undefined') {
39 item.title = item.title || _("(Unknown)");
40 item.author = item.author || _("(Unknown)");
41 item.homebranch = item.homebranch || "";
42 item.holdingbranch = item.holdingbranch || "";
43 item.callnumber = item.callnumber || "";
44 item.itemtype = item.itemtype || "";
45 item.barcode = item.barcode || barcode;
46 var trans = { "timestamp" : new Date().toMySQLString(),
51 $('#offline-home').hide();
52 $('#offline-returns').show();
53 kohadb.recordTransaction(trans, function () {
54 $('#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>');
55 if (alerts.length > 0) {
56 $('#alerts').append('<div class="dialog alert"><h3>' + _("Check in message") + '</h3></div>');
57 for (var msg in alerts) {
58 $('#alerts .dialog').append('<p>' + alerts[msg] + '</p');
64 function checkAlerts(barcode, item) {
66 if (typeof item === 'undefined') {
67 alerts.push(ALERT_NO_MATCHING_ITEM + barcode);
69 if (typeof item.materials !== 'undefined' && item.materials != null) {
70 alerts.push(ALERT_MATERIALS + item.materials);
76 function synchronize() {
77 kohadb.saveSetting("userid", "[% loggedinusername %]");
78 kohadb.saveSetting("branchcode", "[% LoginBranchcode %]");
79 kohadb.loadSetting("item-timestamp", showTimestamp);
80 kohadb.loadSetting("patron-timestamp", showTimestamp);
81 kohadb.loadSetting("issue-timestamp", showTimestamp);
82 [% UNLESS (AllowOfflineCirculation) %]
85 $('#download-records').click(reloadRecords);
86 $('#upload-transactions').click(function () {
87 $('.loading-overlay div').text(_("Uploading transactions, please wait..."));
88 $('.loading-overlay').show();
89 var uploadIter = $.indexedDB("koha").objectStore("transactions").each(uploadTransaction);
90 uploadIter.done(function() {
91 $('.loading-overlay').hide();
97 function showTimestamp(key, value) {
98 if (typeof value !== 'undefined') {
99 var ts = new Date(value);
100 $('#' + key).text($.datepicker.formatDate(dateformat, ts) + ' ' + ts.toTimeString());
102 $('#' + key).text(_("(never)"));
106 function reloadRecords(ev) {
107 $(".loading-overlay div").text(_("Loading records, please wait..."));
108 $(".loading-overlay").show();
110 $.indexedDB("koha").transaction(["patrons", "items", "issues"]).then(function(){
113 }, function(transaction){
114 transaction.objectStore("patrons").clear();
115 transaction.objectStore("items").clear();
116 transaction.objectStore("issues").clear();
118 if (typeof ev !== 'undefined') {
119 ev.stopPropagation();
123 function uploadTransaction(transaction) {
126 url: "/cgi-bin/koha/offline_circ/service.pl",
127 data: { "userid" : kohadb.settings.userid,
128 "branchcode" : kohadb.settings.branchcode,
129 "timestamp" : transaction.value.timestamp,
130 "action" : transaction.value.action,
131 "barcode" : transaction.value.barcode,
132 "cardnumber" : transaction.value.cardnumber,
135 }).done(function () {
136 transaction.delete();
140 function finishedLoading() {
141 kohadb.saveSetting('item-timestamp', start.toISOString())
142 kohadb.saveSetting('patron-timestamp', start.toISOString())
143 kohadb.saveSetting('issue-timestamp', start.toISOString())
144 showTimestamp('item-timestamp', start.toISOString());
145 showTimestamp('patron-timestamp', start.toISOString());
146 showTimestamp('issue-timestamp', start.toISOString());
147 $(".loading-overlay").hide();
150 function loadRecords(page) {
151 [% IF (AllowOfflineCirculation) %]
152 $(".loading-overlay div").text(_("Loading page " + page + ", please wait..."));
153 $(".loading-overlay").show();
156 url: "/cgi-bin/koha/offline_circ/download.pl",
157 data: { "data": "all",
161 }).done(function (data) {
162 $.indexedDB("koha").transaction(["patrons", "items", "issues"]).then(function(){
163 if ($.isEmptyObject(data.patrons) && $.isEmptyObject(data.items)) {
166 setTimeout(function () { loadRecords(page + 1); }, 200);
169 }, function(transaction){
171 var patrons = transaction.objectStore("patrons");
172 $.each(data.patrons, function () {
177 var items = transaction.objectStore("items");
178 $.each(data.items, function () {
183 var issues = transaction.objectStore("issues");
184 $.each(data.issues, function () {
193 function validate1(date) {
194 var today = new Date();
195 if ( date < today ) {
202 function loadPatron(barcode) {
203 $('#oldissues').hide();
204 $('#session-issues').hide();
205 $('#session-payments').hide();
206 $.indexedDB("koha").transaction(["patrons", "issues"]).then(function() {
208 }, function(transaction){
209 var patrons = transaction.objectStore("patrons");
210 patrons.get(barcode).done(function (patron, error) {
211 showPatron(barcode, patron, error);
213 var issuesidx = transaction.objectStore("issues").index("cardnumber");
214 $('#oldissuest tbody').empty();
215 issuesidx.each(function (item) {
216 $('#oldissues').show();
217 $('#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>");
222 function checkout(barcode, item, error) {
223 var alerts = checkAlerts(barcode, item);
224 if (typeof item === 'undefined') {
227 item.title = item.title || "";
228 item.author = item.author || "";
229 item.homebranch = item.homebranch || "";
230 item.holdingbranch = item.holdingbranch || "";
231 item.callnumber = item.callnumber || "";
232 item.itemtype = item.itemtype || "";
233 if ($('#duedatespec').val().length === 0) {
234 alert(_("You must set a due date in order to use offline circulation!"));
235 $('#duedatespec').focus();
238 var date_due = new Date($('#duedatespec').datepicker('getDate'));
239 var trans = { "timestamp" : new Date().toMySQLString(),
241 "cardnumber" : curpatron.cardnumber,
242 "date_due" : date_due.toMySQLString(),
245 $('#alerts').empty();
246 kohadb.recordTransaction(trans, function () {
247 $('#session-issues').show();
248 $('#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>');
249 if (alerts.length > 0) {
250 $('#alerts').append('<div class="dialog alert"><h3>' + _("Check out message") + '</h3></div>');
251 for (var msg in alerts) {
252 $('#alerts .dialog').append('<p>' + alerts[msg] + '</p');
258 function recordFine(amount) {
259 var timestamp = new Date()
260 var trans = { "timestamp" : timestamp.toMySQLString(),
261 "cardnumber" : curpatron.cardnumber,
263 "action" : "payment",
265 kohadb.recordTransaction(trans, function () {
266 $('#session-payments').show();
267 $('#session-payments tbody').prepend('<tr><td>' + amount + '</td><td>' + $.datepicker.formatDate(dateformat, timestamp) + timestamp.toTimeString() + '</td></tr>');
271 function checkPatronAlerts(cardnumber, patron) {
273 if (typeof patron === 'undefined') {
274 alerts.push(ALERT_NO_MATCHING_PATRON + cardnumber);
276 if (patron.gonenoaddress !== '0') {
277 alerts.push(ALERT_PATRON_GONE_NO_ADDRESS);
279 if (patron.lost !== '0') {
280 alerts.push(ALERT_PATRON_CARD_LOST);
282 if (patron.debarred !== null) {
283 if (patron.debarred != '9999-12-31') {
284 alerts.push(ALERT_PATRON_BLOCKED_TEMPORARY + $.datepicker.formatDate(dateformat, patron.debarred));
286 alerts.push(ALERT_PATRON_RESTRICTED);
289 if (parseInt(patron.fine) > [% maxoutstanding %]) {
290 alerts.push(ALERT_PATRON_FINE_OVER_LIMIT + patron.fine);
291 } else if (parseInt(patron.fine) > 0) {
292 alerts.push(ALERT_PATRON_FINE + patron.fine);
300 function showPatron(barcode, patron, error) {
301 var alerts = checkPatronAlerts(barcode, patron);
302 if (typeof patron === 'undefined') {
305 patron.surname = patron.surname || "";
306 patron.firstname = patron.firstname || "";
307 patron.othernames = patron.othernames || "";
308 patron.address = patron.address || "";
309 patron.address2 = patron.address2 || "";
310 patron.city = patron.city || "";
311 patron.state = patron.state || "";
312 patron.country = patron.country || "";
313 patron.zipcode = patron.zipcode || "";
314 patron.phone = patron.phone || "";
315 patron.mobile = patron.mobile || "";
316 patron.phonepro = patron.phonepro || "";
317 patron.email = patron.email || "";
318 patron.emailpro = patron.emailpro || "";
319 patron.categorycode = patron.categorycode || "";
320 patron.branchcode = patron.branchcode || "";
321 patron.cardnumber = barcode;
322 patron.fine = patron.fine || "0";
324 patron.name = patron.firstname + (patron.othernames.length > 0 ? " (" + patron.othernames + ") " : " ") + patron.surname + " (" + barcode + ")";
325 if (patron.name.length > 0) {
326 $('.patron-title').text(patron.name);
328 $('.patron-title').text(_("Unrecognized patron") + " (" + barcode + ")");
330 if (patron.address.length > 0 || patron.address2.length > 0) {
331 $('#patron-address-1').text(patron.address);
332 $('#patron-address-2').text(patron.address2);
334 $('#patron-address-1').html('<span class="empty" id="noaddressstored">' + _("No address stored.") + '</span></li>');
335 $('#patron-address-2').text('');
337 if (patron.city.length > 0) {
338 $('#patron-address-parts').text(patron.city + (patron.state.length > 0 ? ", " + patron.state : "") + " " + patron.zipcode + (patron.country.length > 0 ? ", " + patron.country : ""));
340 $('#patron-address-parts').html('<span class="empty" id="nocitystored">' + _("No city stored.") + '</span></li>');
342 if (patron.phone.length > 0 || patron.mobile.length > 0 || patron.phonepro.length > 0) {
343 $('#patron-phone').text((patron.phone.length > 0 ? patron.phone : (patron.mobile.length > 0 ? patron.mobile : (patron.phonepro.length > 0 ? patron.phonepro : ''))));
345 $('#patron-phone').html('<span class="empty" id="nophonestored">' + _("No phone stored.") + '</span></li>');
347 if (patron.email.length > 0 || patron.emailpro.length > 0) {
348 $('#patron-email').text((patron.email.length > 0 ? patron.email : (patron.emailpro.length > 0 ? patron.emailpro : "")));
350 $('#patron-email').html('<span class="empty" id="noemailstored">' + _("No email stored.") + '</span></li>');
352 if (patron.categorycode.length > 0) {
353 $('#patron-category').text(_("Category: ") + patron.categorycode);
355 $('#patron-category').html('<span class="empty" id="unknowncategory">' + _("Category code unknown.") + '</span></li>');
357 if (patron.branchcode.length > 0) {
358 $('#patron-library').text(_("Home library: ") + patron.branchcode);
360 $('#patron-library').html('<span class="empty" id="unknowncategory">' + _("Home library unknown.") + '</span></li>');
362 $('.fine-amount').text(patron.fine);
363 $('#alerts').empty();
364 if (alerts.length > 0) {
365 $('#alerts').append('<div class="dialog alert"><h3>' + _("Check out message") + '</h3></div>');
366 for (var msg in alerts) {
367 $('#alerts .dialog').append('<p>' + alerts[msg] + '</p');
371 $('#yui-main').show();
372 $('#barcode').focus();
375 // This next bit of code is to deal with the updated session issue
376 window.addEventListener('load', function(e) {
377 window.applicationCache.addEventListener('updateready', function(e) {
378 if (window.applicationCache.status == window.applicationCache.UPDATEREADY) {
379 // Browser downloaded a new app cache.
380 // Swap it in and reload the page to get the new hotness.
381 window.applicationCache.swapCache();
382 if (confirm(_("A new version of this site is available. Load it?"))) {
383 window.location.reload();
386 // Manifest didn't changed. Nothing new to server.
392 $(document).ready(function () {
396 $('#checkin-form, #checkin_search form').submit(function (event) {
397 event.preventDefault();
398 var barcode = $('input[name="barcode"]', this).val();
399 $('input[name="barcode"]', this).val('');
400 $.indexedDB("koha").transaction(["items"]).then(function() {
402 }, function(transaction){
403 var items = transaction.objectStore("items");
404 items.get(barcode).done(function (item, error) {
405 checkin(barcode, item, error);
410 $('#go-to-home').click(function () {
411 $('.offline-sync').hide();
412 $('.offline-circulation').hide();
413 $('.offline-returns').hide();
414 $('.offline-home').show();
417 $('#go-to-returns').click(function () {
418 $('.offline-home').hide();
419 $('.offline-sync').hide();
420 $('.offline-circulation').hide();
421 $('.offline-returns').show();
422 $('#checkin-form input[name="barcode"]').focus();
425 $('#go-to-circ').click(function () {
426 $('.offline-home').hide();
427 $('.offline-sync').hide();
428 $('.offline-returns').hide();
429 $('.offline-circulation').hide();
430 $('#header_search').tabs("option", "active", 0);
431 $('#circ_search input[name="findborrower"]').focus();
434 $('#go-to-sync').click(function () {
437 url: "/cgi-bin/koha/offline_circ/list.pl",
438 success: function () {
439 $('.offline-home').hide();
440 $('.offline-returns').hide();
441 $('.offline-circulation').hide();
442 $('.offline-sync').show();
446 alert(_("You are offline and therefore cannot sync your database"));
451 $('#patronsearch').submit(function (event) {
452 event.preventDefault();
453 loadPatron($('#findborrower').val());
454 $('.offline-home').hide();
455 $('.offline-returns').hide();
456 $('.offline-sync').hide();
457 $('.offline-circulation').show();
458 $('#findborrower').val('');
459 $('#barcode').focus();
462 $('#pay-fine').click(function (event) {
463 event.preventDefault();
464 recordFine($('#pay-fine-amount').val());
467 $('#patronlists').tabs();
469 $("#newduedate").datetimepicker({
470 minDate: 1, // require that renewal date is after today
474 $("#duedatespec").datetimepicker({
475 onClose: function(dateText, inst) { $("#barcode").focus(); },
479 $('#mainform').submit(function (event) {
480 event.preventDefault();
481 var barcode = $('#barcode').val();
482 $.indexedDB("koha").transaction(["items"]).then(function() {
484 }, function(transaction){
485 var items = transaction.objectStore("items");
486 items.get(barcode).done(function (item, error) {
487 checkout(barcode, item, error);
495 <body id="circ_offline" class="circ">
496 [% INCLUDE 'header.inc' %]
497 [% INCLUDE 'circ-search.inc' %]
498 <div class="loading-overlay" style="display: none;">
499 <div>Downloading records, please wait...</div>
502 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a id="go-to-home" href="#offline-home">Offline circulation</a></div>
504 <div id="doc3" class="yui-t2">
508 <audio id="alert_sound" src="/intranet-tmpl/prog/sound/critical.ogg" autobuffer="autobuffer"></audio>
509 <audio id="success_sound" src="/intranet-tmpl/prog/sound/beep.ogg" autobuffer="autobuffer"></audio>
511 <div id="alerts" class="yui-b">
513 [% UNLESS (AllowOfflineCirculation) %]
514 <div id="noofflinecircwarning" class="dialog alert">
515 <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>
519 <div id="offline-home" class="yui-b offline-home">
521 <h1>Offline circulation</h1>
522 <div class="yui-u first">
524 <li><a id="go-to-circ" href="#offline-circulation">Check out</a></li>
525 <li><a id="go-to-returns" href="#offline-returns">Check in</a></li>
526 <li><a id="go-to-sync" href="#offline-sync">Synchronize (must be online)</a></li>
531 <p><strong>Note:</strong> You must be online to use these options.</p>
533 <li><a href="/cgi-bin/koha/offline_circ/list.pl">Pending offline circulation actions</a>
539 <div id="offline-sync" style="display: none;" class="yui-b offline-sync">
540 <div id="toolbar" class="btn-toolbar">
541 [% IF (AllowOfflineCirculation) %]
542 <a href="#" id="download-records" class="btn btn-small"><i class="icon-arrow-down"></i>Download records</a>
544 <a href="#" id="upload-transactions" class="btn btn-small"><i class="icon-arrow-up"></i>Upload transactions</a>
547 <h1>Offline circulation</h1>
548 <div class="yui-u first">
549 <div id="download-message">
550 You have records in the offline circulation database on this
551 computer, but they may not be current:
553 <li>Patron records were last synced on: <span id="patron-timestamp">(checking)</span></li>
554 <li>Item records were last synced on: <span id="item-timestamp">(checking)</span></li>
555 <li>Circulation records were last synced on: <span id="issue-timestamp">(checking)</span></li>
561 <div id="upload-message">You have transactions in the offline
562 circulation database on this computer that have not been
569 <div id="offline-returns" style="display: none;" class="yui-b offline-returns">
571 <form id="checkin-form" method="post" action="/cgi-bin/koha/circ/returns.pl" autocomplete="off" >
572 <div class="yui-u first">
574 <legend>Check In</legend>
575 <label for="barcode">Enter item barcode: </label>
576 <input name="barcode" id="barcode" size="14" class="focus"/>
577 <input type="submit" class="submit" value="Submit" />
583 <div id="session-returned" style="display: none;">
584 <h2>Checked-in items</h2>
585 <table id="already-checked-in">
587 <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>
595 <div id="offline-circulation" style="display: none;" class="yui-b offline-circulation">
597 <form method="post" action="/cgi-bin/koha/circ/offline-circulation.pl" id="mainform" name="mainform" autocomplete="off">
598 <fieldset id="circ_circulation_issue">
599 <span id="clearscreen"><a href="/cgi-bin/koha/circ/offline-circulation.pl" title="Clear screen">x</a></span>
600 <label for="barcode">Checking out to <span class="patron-title"></span></label>
601 <div class="hint">Enter item barcode:</div>
602 <input type="text" name="barcode" id="barcode" class="barcode focus" size="14" />
603 <input type="submit" value="Check Out" />
605 <div class="date-select">
606 <div class="hint">Specify due date [% INCLUDE 'date-format.inc' %]: </div>
607 <input type="text" size="13" id="duedatespec" name="duedatespec" value="[% duedatespec %]" readonly="readonly" />
608 <label for="stickyduedate"> Remember for session:</label>
609 <input type="checkbox" id="stickyduedate" onclick="this.form.barcode.focus();" name="stickyduedate" checked="checked" />
610 <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;" />
616 <div class="yui-g"><div id="patronlists" class="toptabs">
618 <li><a href="#checkouts"><span class="checkout-count">0</span> Checkouts</a></li>
619 <li><a href="#fines"><span class="fine-amount">0</span> in fines</a></li>
622 <!-- SUMMARY : TODAY & PREVIOUS ISSUES -->
624 <div id="session-issues">
627 <th scope="col">Due date</th>
628 <th scope="col">Title</th>
629 <th scope="col">Barcode</th>
630 <th scope="col">Item type</th>
631 <th scope="col">Checked out on</th>
632 <th scope="col">Checked out from</th>
633 <th scope="col">Call no</th>
634 <th scope="col">Charge</th>
642 <h5>Previous checkouts</h5>
643 <table id="oldissuest">
645 <th scope="col">Due date</th>
646 <th scope="col">Title</th>
647 <th scope="col">Barcode</th>
648 <th scope="col">Item type</th>
649 <th scope="col">Checked out on</th>
650 <th scope="col">Checked out from</th>
651 <th scope="col">Call no</th>
652 <th scope="col">Charge</th>
661 <span class="patron-title"></span> has <span class="fine-amount">0</span> in fines. If you would like you can record payments.
662 <fieldset><legend>Pay fines</legend>
663 <label for="pay-fine-amount">Fine amount: </label><input type="text" name="pay-fine-amount" id="pay-fine-amount"/>
664 <button id="pay-fine" class="submit">Pay fine</button>
666 <table id="session-payments" style="display: none;">
667 <thead><tr><th>Amount</th><th>Timestamp</th></tr></thead>
677 <div class="yui-b offline-circulation" style="display: none;">
678 <div class="patroninfo"><h5 class="patron-title"></h5>
680 <li id="patron-address-1"></li>
681 <li id="patron-address-2"></li>
682 <li id="patron-address-parts"><!-- city, state, zipcode, country --></li>
683 <li id="patron-phone"></li>
684 <li id="patron-email"></li>
685 <li id="patron-category"></li>
686 <li id="patron-library"></li>
690 [% INCLUDE 'intranet-bottom.inc' %]