6 [% IF (AllowOfflineCirculation) %]
7 [% SET manifestattr = 'manifest="/cgi-bin/koha/circ/offline-mf.pl"' %]
9 [% IF ( bidi && AllowOfflineCirculation ) %]<html lang="[% lang | html %]" dir="[% bidi | html %]" manifest="/cgi-bin/koha/circ/offline-mf.pl">
10 [% ELSIF ( bidi ) %]<html lang="[% lang | html %]" dir="[% bidi | html %]">
11 [% ELSIF ( AllowOfflineCirculation ) %]<html lang="[% lang | html %]" manifest="/cgi-bin/koha/circ/offline-mf.pl">
12 [% ELSE %]<html lang="[% lang | html %]">[% END %]
14 <title>Koha › Circulation</title>
15 [% INCLUDE 'doc-head-close.inc' %]
18 <body id="circ_offline" class="circ">
19 [% INCLUDE 'header.inc' %]
20 [% INCLUDE 'circ-search.inc' %]
21 <div class="loading-overlay" style="display: none;">
22 <div>Downloading records, please wait...</div>
25 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a id="go-to-home" href="#offline-home">Offline circulation</a></div>
27 <div class="main container-fluid">
29 <div class="col-sm-10 col-sm-push-2">
32 <audio id="alert_sound" src="[% interface | html %]/prog/sound/critical.ogg" preload="auto"></audio>
33 <audio id="success_sound" src="[% interface | html %]/prog/sound/beep.ogg" preload="auto"></audio>
35 <div id="alerts"></div>
37 [% UNLESS (AllowOfflineCirculation) %]
38 <div id="noofflinecircwarning" class="dialog alert">
39 <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>
43 <div id="offline-home" class="offline-home">
44 <h1>Offline circulation</h1>
46 <div class="col-sm-6">
48 <li><a id="go-to-circ" href="#offline-circulation">Check out</a></li>
49 <li><a id="go-to-returns" href="#offline-returns">Check in</a></li>
53 <div class="col-sm-6">
54 <p><strong>Note:</strong> You must be online to use these options.</p>
56 <li><a id="go-to-sync" href="#offline-sync">Synchronize</a></li>
57 <li><a id="go-to-pending" href="/cgi-bin/koha/offline_circ/list.pl">Pending offline circulation actions</a>
63 <div id="offline-sync" style="display: none;" class="offline-sync">
64 <div id="toolbar" class="btn-toolbar">
65 [% IF (AllowOfflineCirculation) %]
66 <a href="#" id="download-records" class="btn btn-default"><i class="fa fa-arrow-down"></i>Download records</a>
68 <a href="#" id="upload-transactions" class="btn btn-default"><i class="fa fa-arrow-up"></i>Upload transactions</a>
70 <h1>Offline circulation</h1>
72 <div class="col-sm-6">
73 <div id="download-message">
74 In order for offline circulation to work on this computer,
75 your library's records must be up-to-date on this computer:
77 <li>Patron records were last synced on: <span id="patron-timestamp">(checking)</span></li>
78 <li>Item records were last synced on: <span id="item-timestamp">(checking)</span></li>
79 <li>Circulation records were last synced on: <span id="issue-timestamp">(checking)</span></li>
84 <div class="col-sm-6">
85 <div id="upload-message">
87 <div>View <a href="/cgi-bin/koha/offline_circ/list.pl">pending offline circulation actions</a></div>
92 <div id="offline-returns" style="display: none;" class="offline-returns">
94 <form id="checkin-form" method="post" action="/cgi-bin/koha/circ/returns.pl" autocomplete="off" >
95 <div class="col-sm-6">
97 <legend>Check in</legend>
98 <label for="checkin-barcode">Enter item barcode: </label>
99 <input name="barcode" id="checkin-barcode" size="14" class="focus" type="text" />
100 <input type="submit" class="submit" value="Submit" />
106 <div id="session-returned" style="display: none;">
107 <h2>Checked-in items</h2>
108 <table id="already-checked-in">
110 <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>
118 <div style="display: none;" class="offline-circulation-instructions">
119 Scan a patron barcode to start.
122 <div id="offline-circulation" style="display: none;" class="offline-circulation">
123 <form method="post" action="/cgi-bin/koha/circ/offline.pl" id="mainform" name="mainform" autocomplete="off">
124 <fieldset id="circ_circulation_issue">
125 <span id="clearscreen"><a href="/cgi-bin/koha/circ/offline.pl" title="Clear screen">x</a></span>
126 <label for="checkout-barcode">Checking out to <span class="patron-title"></span></label>
127 <div class="hint">Enter item barcode:</div>
128 <input type="text" name="barcode" id="checkout-barcode" class="barcode focus" size="14" />
129 <input type="submit" value="Check Out" />
131 <div class="date-select">
132 <div class="hint">Specify due date [% INCLUDE 'date-format.inc' %]: </div>
133 <input type="text" size="13" id="duedatespec" name="duedatespec" value="[% duedatespec | html %]" />
134 <label for="stickyduedate"> Remember for session:</label>
135 <input type="checkbox" id="stickyduedate" onclick="this.form.barcode.focus();" name="stickyduedate" checked="checked" />
136 <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;" />
141 <div id="patronlists" class="toptabs">
143 <li><a href="#checkouts"><span class="checkout-count">0</span> Checkouts</a></li>
144 <li><a href="#fines"><span class="fine-amount">0</span> in fines</a></li>
147 <!-- SUMMARY : TODAY & PREVIOUS ISSUES -->
149 <div id="session-issues">
152 <th scope="col">Due date</th>
153 <th scope="col">Title</th>
154 <th scope="col">Barcode</th>
155 <th scope="col">Item type</th>
156 <th scope="col">Checked out on</th>
157 <th scope="col">Checked out from</th>
158 <th scope="col">Call no</th>
159 <th scope="col">Charge</th>
167 <h5>Previous checkouts</h5>
168 <table id="oldissuest">
170 <th scope="col">Due date</th>
171 <th scope="col">Title</th>
172 <th scope="col">Barcode</th>
173 <th scope="col">Item type</th>
174 <th scope="col">Checked out on</th>
175 <th scope="col">Checked out from</th>
176 <th scope="col">Call no</th>
177 <th scope="col">Charge</th>
186 <span class="patron-title"></span> has <span class="fine-amount">0</span> in fines. If you would like you can record payments.
187 <fieldset><legend>Pay fines</legend>
188 <label for="pay-fine-amount">Fine amount: </label><input type="text" name="pay-fine-amount" id="pay-fine-amount"/>
189 <button id="pay-fine" class="submit">Pay fine</button>
191 <table id="session-payments" style="display: none;">
192 <thead><tr><th>Amount</th><th>Timestamp</th></tr></thead>
203 </div> <!-- /.col-sm-10.col-sm-push-2 -->
205 <div class="offline-circulation" style="display: none;">
206 <div class="col-sm-2 col-sm-pull-10">
208 <div class="patroninfo"><h5 class="patron-title"> </h5>
210 <li id="patron-address-1"></li>
211 <li id="patron-address-2"></li>
212 <li id="patron-address-parts"><!-- city, state, zipcode, country --></li>
213 <li id="patron-phone"></li>
214 <li id="patron-email"></li>
215 <li id="patron-category"></li>
216 <li id="patron-library"></li>
220 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
221 </div> <!-- /.row -->
224 [% MACRO jsinclude BLOCK %]
225 [% INCLUDE 'calendar.inc' %]
226 [% Asset.js("lib/jquery/plugins/jquery.indexeddb.js") | $raw %]
227 [% Asset.js("js/offlinecirc.js") | $raw %]
228 [% Asset.js("lib/jquery/plugins/jquery-ui-timepicker-addon.min.js") | $raw %]
229 [% INCLUDE 'timepicker.inc' %]
231 var ALERT_SUCCESSFUL_CHECKIN = _("Checked in item.");
232 var ALERT_MATERIALS = _("Note about the accompanying materials: %s");
233 var ALERT_RESTRICTED = _("Patron is RESTRICTED");
234 var ALERT_NO_MATCHING_ITEM = _("No item with barcode in offline database (transaction recorded anyway): %s");
235 var ALERT_NOT_CHECKED_OUT = _("Item not listed as checked out in offline database (transaction recorded anyway)");
236 var ALERT_ITEM_WITHDRAWN = _("Item has been withdrawn (transaction recorded anyway)");
237 var ALERT_ITEM_RESTRICTED = _("Item is restricted (transaction recorded anyway)");
238 var ALERT_ITEM_LOST = _("Item has been lost (transaction recorded anyway)");
239 var ALERT_NO_MATCHING_PATRON = _("No patron cardnumber in offline database (proceeding anyway): %s");
240 var ALERT_PATRON_GONE_NO_ADDRESS = _("Patron's address is in doubt (proceeding anyway)");
241 var ALERT_PATRON_CARD_LOST = _("Patron's card is lost");
242 var ALERT_PATRON_EXPIRED = _("Patron's card is expired (%s)");
243 var ALERT_PATRON_BLOCKED_TEMPORARY = _("Patron has had overdue items and is restricted until: %s");
244 var ALERT_PATRON_RESTRICTED = _("Patron is restricted");
245 var ALERT_PATRON_FINE = _("Patron has outstanding fines: %s");
246 var ALERT_PATRON_FINE_OVER_LIMIT = _("Patron fines are over limit: %s");
247 var UPLOAD_PENDING_MESSAGE = _("You have transactions in the offline circulation database on this computer that have not been uploaded.");
248 var NO_UPLOAD_PENDING_MESSAGE = _("You do not have any pending transactions in the offline circulation database on this computer.");
252 var dateformat = '[% IF ( dateformat_us ) %]mm/dd/yy[% ELSIF ( dateformat_metric ) %]dd/mm/yy[% ELSE %]yy-mm-dd[% END %]';
254 function checkin(barcode, item, error) {
255 var alerts = checkAlerts(barcode, item);
256 if (typeof item === 'undefined') {
259 item.title = item.title || _("(Unknown)");
260 item.author = item.author || _("(Unknown)");
261 item.homebranch = item.homebranch || "";
262 item.holdingbranch = item.holdingbranch || "";
263 item.callnumber = item.callnumber || "";
264 item.itemtype = item.itemtype || "";
265 item.barcode = item.barcode || barcode;
266 var trans = { "timestamp" : new Date().toMySQLString(),
270 $('#alerts').empty();
271 $('.offline-home').hide();
272 $('.offline-sync').hide();
273 $('.offline-circulation').hide();
274 $('.offline-circulation-instructions').hide();
275 $('.offline-returns').show();
276 kohadb.recordTransaction(trans, function () {
277 $('#session-returned').show();
278 $('#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>');
279 if (alerts.length > 0) {
280 $('#alerts').append('<div class="dialog alert"><h3>' + _("Check in message") + '</h3></div>');
281 for (var msg in alerts) {
282 $('#alerts .dialog').append('<p>' + alerts[msg] + '</p');
285 $('#alerts').append('<div class="dialog"><h3>' + ALERT_SUCCESSFUL_CHECKIN + '</h3></div>');
288 setTimeout(function() { $('#checkin-barcode').trigger('focus'), 1 });
291 function checkAlerts(barcode, item) {
293 if (typeof item === 'undefined') {
294 alerts.push(ALERT_NO_MATCHING_ITEM.format(barcode));
296 if (typeof item.materials !== 'undefined' && item.materials != null) {
297 alerts.push(ALERT_MATERIALS.format(item.materials));
303 function showSyncInfo() {
304 kohadb.loadSetting("item-timestamp", showTimestamp);
305 kohadb.loadSetting("patron-timestamp", showTimestamp);
306 kohadb.loadSetting("issue-timestamp", showTimestamp);
307 kohadb.loadSetting("dirty", function (key, val) {
309 $('#upload-message').text(UPLOAD_PENDING_MESSAGE);
311 $('#upload-message').text(NO_UPLOAD_PENDING_MESSAGE);
316 function synchronize() {
317 kohadb.saveSetting("userid", "[% logged_in_user.userid | html %]");
318 kohadb.saveSetting("branchcode", "[% Branches.GetLoggedInBranchcode | html %]");
320 [% UNLESS (AllowOfflineCirculation) %]
324 $('#download-records').click(reloadRecords);
325 $('#upload-transactions').click(function () {
326 $('.loading-overlay div').text(_("Uploading transactions, please wait..."));
327 $('.loading-overlay').show();
330 url: "/cgi-bin/koha/offline_circ/service.pl",
331 }).done(function (data) {
333 $('.loading-overlay').hide();
334 alert(_("Please log in to Koha and try again. (Error: '%s')").format(data));
336 var uploadIter = $.indexedDB("koha").objectStore("transactions").each(uploadTransaction);
337 uploadIter.done(function() {
338 $.indexedDB("koha").transaction(["transactions"]).then(function(){
340 }, function(transaction){
341 transaction.objectStore("transactions").clear();
343 $('.loading-overlay').hide();
344 kohadb.saveSetting("dirty", false);
345 $('#upload-message').text(NO_UPLOAD_PENDING_MESSAGE);
353 function showTimestamp(key, value) {
354 if (typeof value !== 'undefined') {
355 var ts = new Date(value);
356 $('#' + key).text($.datepicker.formatDate(dateformat, ts) + ' ' + ts.toTimeString());
358 $('#' + key).text(_("(never)"));
362 function reloadRecords(ev) {
363 $(".loading-overlay div").text(_("Loading records, please wait..."));
364 $(".loading-overlay").show();
366 $.indexedDB("koha").transaction(["patrons", "items", "issues"]).then(function(){
369 }, function(transaction){
370 transaction.objectStore("patrons").clear();
371 transaction.objectStore("items").clear();
372 transaction.objectStore("issues").clear();
374 if (typeof ev !== 'undefined') {
375 ev.stopPropagation();
379 function uploadTransaction(transaction) {
382 url: "/cgi-bin/koha/offline_circ/service.pl",
383 data: { "userid" : kohadb.settings.userid,
384 "branchcode" : kohadb.settings.branchcode,
385 "timestamp" : transaction.value.timestamp,
386 "action" : transaction.value.action,
387 "barcode" : transaction.value.barcode,
388 "cardnumber" : transaction.value.cardnumber,
389 "amount" : transaction.value.amount,
393 return undefined, true;
396 function finishedLoading() {
397 kohadb.saveSetting('item-timestamp', start.toISOString())
398 kohadb.saveSetting('patron-timestamp', start.toISOString())
399 kohadb.saveSetting('issue-timestamp', start.toISOString())
400 showTimestamp('item-timestamp', start.toISOString());
401 showTimestamp('patron-timestamp', start.toISOString());
402 showTimestamp('issue-timestamp', start.toISOString());
403 $(".loading-overlay").hide();
406 function loadRecords(page) {
407 [% IF (AllowOfflineCirculation) %]
408 $(".loading-overlay div").text(_("Loading page %s, please wait...").format(page));
409 $(".loading-overlay").show();
412 url: "/cgi-bin/koha/offline_circ/download.pl",
413 data: { "data": "all",
417 }).done(function (data) {
418 $.indexedDB("koha").transaction(["patrons", "items", "issues"]).then(function(){
422 setTimeout(function () { loadRecords(page + 1); }, 200);
425 }, function(transaction){
427 var patrons = transaction.objectStore("patrons");
428 $.each(data.patrons, function () {
433 var items = transaction.objectStore("items");
434 $.each(data.items, function () {
439 var issues = transaction.objectStore("issues");
440 $.each(data.issues, function () {
449 function validate1(date) {
450 var today = new Date();
451 if ( date < today ) {
458 function loadPatron(barcode) {
459 $('#oldissues').hide();
460 $('#session-issues').hide();
461 $('#issuest tbody').empty();
462 $('#session-payments').hide();
463 $('.checkout-count').text(0);
464 $.indexedDB("koha").transaction(["patrons", "issues"]).then(function() {
466 }, function(transaction){
467 var patrons = transaction.objectStore("patrons");
468 patrons.get(barcode).done(function (patron, error) {
469 showPatron(barcode, patron, error);
471 var issuesidx = transaction.objectStore("issues").index("cardnumber");
472 $('#oldissuest tbody').empty();
473 issuesidx.each(function (item) {
474 $('#oldissues').show();
475 $('#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>");
476 $('.checkout-count').text(parseInt($('.checkout-count').text()) + 1);
481 function checkout(barcode, item, error) {
482 var alerts = checkAlerts(barcode, item);
483 if (typeof item === 'undefined') {
486 item.title = item.title || "";
487 item.author = item.author || "";
488 item.homebranch = item.homebranch || "";
489 item.holdingbranch = item.holdingbranch || "";
490 item.callnumber = item.callnumber || "";
491 item.itemtype = item.itemtype || "";
492 if ($('#duedatespec').val().length === 0) {
493 alert(_("You must set a due date in order to use offline circulation!"));
494 setTimeout(function() { $('#duedatespec').trigger('focus'), 1 });
497 var date_due = new Date($('#duedatespec').datepicker('getDate'));
498 var trans = { "timestamp" : new Date().toMySQLString(),
500 "cardnumber" : curpatron.cardnumber,
501 "date_due" : date_due.toMySQLString(),
504 $('#alerts').empty();
505 kohadb.recordTransaction(trans, function () {
506 $('#session-issues').show();
507 $('#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>');
508 $('.checkout-count').text(parseInt($('.checkout-count').text()) + 1);
509 if (alerts.length > 0) {
510 $('#alerts').append('<div class="dialog alert"><h3>' + _("Check out message") + '</h3></div>');
511 for (var msg in alerts) {
512 $('#alerts .dialog').append('<p>' + alerts[msg] + '</p');
515 $('#checkout-barcode').val('');
519 function recordFine(amount) {
520 var timestamp = new Date()
521 var trans = { "timestamp" : timestamp.toMySQLString(),
522 "cardnumber" : curpatron.cardnumber,
524 "action" : "payment",
526 kohadb.recordTransaction(trans, function () {
527 $('#session-payments').show();
528 $('#session-payments tbody').prepend('<tr><td>' + amount + '</td><td>' + $.datepicker.formatDate(dateformat, timestamp) + timestamp.toTimeString() + '</td></tr>');
529 $('.fine-amount').text(parseInt($('.fine-amount').text()) - amount);
533 function checkPatronAlerts(cardnumber, patron) {
535 if (typeof patron === 'undefined') {
536 alerts.push(ALERT_NO_MATCHING_PATRON.format(cardnumber));
538 if (patron.gonenoaddress !== '0') {
539 alerts.push(ALERT_PATRON_GONE_NO_ADDRESS);
541 if (patron.lost !== '0') {
542 alerts.push(ALERT_PATRON_CARD_LOST);
544 if (patron.debarred !== null) {
545 if (patron.debarred != '9999-12-31') {
546 alerts.push(ALERT_PATRON_BLOCKED_TEMPORARY.format($.datepicker.formatDate(dateformat, new Date(patron.debarred))));
548 alerts.push(ALERT_PATRON_RESTRICTED);
551 if (new Date(patron.dateexpiry) < new Date()) {
552 alerts.push(ALERT_PATRON_EXPIRED.format($.datepicker.formatDate(dateformat, new Date(patron.dateexpiry))));
554 if (parseInt(patron.fine) > [% maxoutstanding | html %]) {
555 alerts.push(ALERT_PATRON_FINE_OVER_LIMIT.format(patron.fine));
556 } else if (parseInt(patron.fine) > 0) {
557 alerts.push(ALERT_PATRON_FINE.format(patron.fine));
565 function showPatron(barcode, patron, error) {
566 var alerts = checkPatronAlerts(barcode, patron);
567 if (typeof patron === 'undefined') {
570 patron.surname = patron.surname || "";
571 patron.firstname = patron.firstname || "";
572 patron.othernames = patron.othernames || "";
573 patron.address = patron.address || "";
574 patron.address2 = patron.address2 || "";
575 patron.city = patron.city || "";
576 patron.state = patron.state || "";
577 patron.country = patron.country || "";
578 patron.zipcode = patron.zipcode || "";
579 patron.phone = patron.phone || "";
580 patron.mobile = patron.mobile || "";
581 patron.phonepro = patron.phonepro || "";
582 patron.email = patron.email || "";
583 patron.emailpro = patron.emailpro || "";
584 patron.categorycode = patron.categorycode || "";
585 patron.branchcode = patron.branchcode || "";
586 patron.cardnumber = barcode;
587 patron.fine = patron.fine || "0";
589 patron.name = patron.firstname + (patron.othernames.length > 0 ? " (" + patron.othernames + ") " : " ") + patron.surname + " (" + barcode + ")";
590 if (patron.name.length > 0) {
591 $('.patron-title').text(patron.name);
593 $('.patron-title').text(_("Unrecognized patron (%s)").format(barcode));
595 if (patron.address.length > 0 || patron.address2.length > 0) {
596 $('#patron-address-1').text(patron.address);
597 $('#patron-address-2').text(patron.address2);
599 $('#patron-address-1').html('<span class="empty" id="noaddressstored">' + _("No address stored.") + '</span></li>');
600 $('#patron-address-2').text('');
602 if (patron.city.length > 0) {
603 $('#patron-address-parts').text(patron.city + (patron.state.length > 0 ? ", " + patron.state : "") + " " + patron.zipcode + (patron.country.length > 0 ? ", " + patron.country : ""));
605 $('#patron-address-parts').html('<span class="empty" id="nocitystored">' + _("No city stored.") + '</span></li>');
607 if (patron.phone.length > 0 || patron.mobile.length > 0 || patron.phonepro.length > 0) {
608 $('#patron-phone').text((patron.phone.length > 0 ? patron.phone : (patron.mobile.length > 0 ? patron.mobile : (patron.phonepro.length > 0 ? patron.phonepro : ''))));
610 $('#patron-phone').html('<span class="empty" id="nophonestored">' + _("No phone stored.") + '</span></li>');
612 if (patron.email.length > 0 || patron.emailpro.length > 0) {
613 $('#patron-email').text((patron.email.length > 0 ? patron.email : (patron.emailpro.length > 0 ? patron.emailpro : "")));
615 $('#patron-email').html('<span class="empty" id="noemailstored">' + _("No email stored.") + '</span></li>');
617 if (patron.categorycode.length > 0) {
618 $('#patron-category').text(_("Category: %s").format(patron.categorycode));
620 $('#patron-category').html('<span class="empty" id="unknowncategory">' + _("Category code unknown.") + '</span></li>');
622 if (patron.branchcode.length > 0) {
623 $('#patron-library').text(_("Home library: %s").format(patron.branchcode));
625 $('#patron-library').html('<span class="empty" id="unknowncategory">' + _("Home library unknown.") + '</span></li>');
627 $('.fine-amount').text(patron.fine);
628 $('#alerts').empty();
629 if (alerts.length > 0) {
630 $('#alerts').append('<div class="dialog alert"><h3>' + _("Check out message") + '</h3></div>');
631 for (var msg in alerts) {
632 $('#alerts .dialog').append('<p>' + alerts[msg] + '</p>');
637 setTimeout(function() { $('#checkout-barcode').trigger('focus'), 1 });
640 // This next bit of code is to deal with the updated session issue
641 window.addEventListener('load', function(e) {
642 window.applicationCache.addEventListener('updateready', function(e) {
643 if (window.applicationCache.status == window.applicationCache.UPDATEREADY) {
644 // Browser downloaded a new app cache.
645 // Swap it in and reload the page to get the new hotness.
646 window.applicationCache.swapCache();
647 if (confirm(_("A new version of this site is available. Load it?"))) {
648 window.location.reload();
651 // Manifest didn't changed. Nothing new to server.
657 $(document).ready(function () {
659 $('#header_search #circ_search .tip').text(_("Enter patron card number:"));
661 $('ul[aria-labelledby="logged-in-menu"]').html('<li><a class="toplinks">' + _("You cannot change your branch or logout while using offline circulation") + '</a></li>');
664 $('#checkin-form, #checkin_search form').submit(function (event) {
665 event.preventDefault();
666 var barcode = $('input[name="barcode"]', this).val();
667 $('input[name="barcode"]', this).val('');
668 $.indexedDB("koha").transaction(["items"]).then(function() {
670 }, function(transaction){
671 var items = transaction.objectStore("items");
672 items.get(barcode).done(function (item, error) {
673 checkin(barcode, item, error);
678 $('#go-to-home').click(function () {
679 $('#alerts').empty();
680 $('.offline-sync').hide();
681 $('.offline-circulation').hide();
682 $('.offline-returns').hide();
683 $('.offline-circulation-instructions').hide();
684 $('.offline-home').show();
687 $('#go-to-returns').click(function () {
688 $('#alerts').empty();
689 $('.offline-home').hide();
690 $('.offline-sync').hide();
691 $('.offline-circulation').hide();
692 $('.offline-circulation-instructions').hide();
693 $('.offline-returns').show();
694 setTimeout(function() { $('#checkin-form input[name="barcode"]').trigger('focus'), 1 });
697 $('#go-to-circ').click(function () {
698 $('#alerts').empty();
699 $('.offline-home').hide();
700 $('.offline-sync').hide();
701 $('.offline-returns').hide();
702 $('.offline-circulation').hide();
703 $('.offline-circulation-instructions').show();
704 $('#header_search').tabs("option", "active", 0);
705 setTimeout(function() { $('#circ_search input[name="findborrower"]').trigger('focus'), 1 });
708 $('#go-to-sync').click(function () {
709 $('#alerts').empty();
713 url: "/cgi-bin/koha/offline_circ/list.pl",
714 success: function () {
715 $('.offline-home').hide();
716 $('.offline-returns').hide();
717 $('.offline-circulation').hide();
718 $('.offline-circulation-instructions').hide();
719 $('.offline-sync').show();
723 alert(_("You are offline and therefore cannot sync your database"));
728 $('#go-to-pending').click(function (ev) {
729 $('#alerts').empty();
733 url: "/cgi-bin/koha/offline_circ/list.pl",
734 success: function () {
735 window.location = '/cgi-bin/koha/offline_circ/list.pl';
738 alert(_("You are offline and therefore cannot process pending operations"));
743 $('#patronsearch').submit(function (event) {
744 event.preventDefault();
745 loadPatron($('#findborrower').val());
746 $('.offline-home').hide();
747 $('.offline-returns').hide();
748 $('.offline-sync').hide();
749 $('.offline-circulation-instructions').hide();
750 $('.offline-circulation').show();
751 $('#findborrower').val('');
752 setTimeout(function() { $('#checkout-barcode').trigger('focus'), 1 });
755 $('#pay-fine').click(function (event) {
756 event.preventDefault();
757 recordFine($('#pay-fine-amount').val());
760 $('#patronlists').tabs();
762 $("#newduedate").datetimepicker({
763 minDate: 1, // require that renewal date is after today
767 $("#duedatespec").datetimepicker({
768 onClose: function(dateText, inst) {
769 if (validate_date(dateText, inst) ) {
770 setTimeout(function() { $('#checkout-barcode').trigger('focus'), 1 });
775 }).on("change", function(e, value) {
776 if ( ! is_valid_date( $(this).val() ) ) {$(this).val("");}
778 $('#mainform').submit(function (event) {
779 event.preventDefault();
780 var barcode = $('#checkout-barcode').val();
781 $.indexedDB("koha").transaction(["items"]).then(function() {
783 }, function(transaction){
784 var items = transaction.objectStore("items");
785 items.get(barcode).done(function (item, error) {
786 checkout(barcode, item, error);
794 [% INCLUDE 'intranet-bottom.inc' %]