5 [% IF (AllowOfflineCirculation) %]
6 [% SET manifestattr = 'manifest="/cgi-bin/koha/circ/offline-mf.pl"' %]
8 [% IF ( bidi && AllowOfflineCirculation ) %]<html lang="[% lang | html %]" dir="[% bidi | html %]" manifest="/cgi-bin/koha/circ/offline-mf.pl">
9 [% ELSIF ( bidi ) %]<html lang="[% lang | html %]" dir="[% bidi | html %]">
10 [% ELSIF ( AllowOfflineCirculation ) %]<html lang="[% lang | html %]" manifest="/cgi-bin/koha/circ/offline-mf.pl">
11 [% ELSE %]<html lang="[% lang | html %]">[% END %]
13 <title>Koha › Circulation</title>
14 [% INCLUDE 'doc-head-close.inc' %]
17 <body id="circ_offline" class="circ">
18 [% INCLUDE 'header.inc' %]
19 [% INCLUDE 'circ-search.inc' %]
20 <div class="loading-overlay" style="display: none;">
21 <div>Downloading records, please wait...</div>
24 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a id="go-to-home" href="#offline-home">Offline circulation</a></div>
26 <div class="main container-fluid">
28 <div class="col-sm-10 col-sm-push-2">
31 <audio id="alert_sound" src="[% interface | html %]/prog/sound/critical.ogg" preload="auto"></audio>
32 <audio id="success_sound" src="[% interface | html %]/prog/sound/beep.ogg" preload="auto"></audio>
34 <div id="alerts"></div>
36 [% UNLESS (AllowOfflineCirculation) %]
37 <div id="noofflinecircwarning" class="dialog alert">
38 <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>
42 <div id="offline-home" class="offline-home">
43 <h1>Offline circulation</h1>
45 <div class="col-sm-6">
47 <li><a id="go-to-circ" href="#offline-circulation">Check out</a></li>
48 <li><a id="go-to-returns" href="#offline-returns">Check in</a></li>
52 <div class="col-sm-6">
53 <p><strong>Note:</strong> You must be online to use these options.</p>
55 <li><a id="go-to-sync" href="#offline-sync">Synchronize</a></li>
56 <li><a id="go-to-pending" href="/cgi-bin/koha/offline_circ/list.pl">Pending offline circulation actions</a>
62 <div id="offline-sync" style="display: none;" class="offline-sync">
63 <div id="toolbar" class="btn-toolbar">
64 [% IF (AllowOfflineCirculation) %]
65 <a href="#" id="download-records" class="btn btn-default"><i class="fa fa-arrow-down"></i>Download records</a>
67 <a href="#" id="upload-transactions" class="btn btn-default"><i class="fa fa-arrow-up"></i>Upload transactions</a>
69 <h1>Offline circulation</h1>
71 <div class="col-sm-6">
72 <div id="download-message">
73 In order for offline circulation to work on this computer,
74 your library's records must be up-to-date on this computer:
76 <li>Patron records were last synced on: <span id="patron-timestamp">(checking)</span></li>
77 <li>Item records were last synced on: <span id="item-timestamp">(checking)</span></li>
78 <li>Circulation records were last synced on: <span id="issue-timestamp">(checking)</span></li>
83 <div class="col-sm-6">
84 <div id="upload-message">
86 <div>View <a href="/cgi-bin/koha/offline_circ/list.pl">pending offline circulation actions</a></div>
91 <div id="offline-returns" style="display: none;" class="offline-returns">
93 <form id="checkin-form" method="post" action="/cgi-bin/koha/circ/returns.pl" autocomplete="off" >
94 <div class="col-sm-6">
96 <legend>Check in</legend>
97 <label for="checkin-barcode">Enter item barcode: </label>
98 <input name="barcode" id="checkin-barcode" size="14" class="focus" type="text" />
99 <input type="submit" class="submit" value="Submit" />
105 <div id="session-returned" style="display: none;">
106 <h2>Checked-in items</h2>
107 <table id="already-checked-in">
109 <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>
117 <div style="display: none;" class="offline-circulation-instructions">
118 Scan a patron barcode to start.
121 <div id="offline-circulation" style="display: none;" class="offline-circulation">
122 <form method="post" action="/cgi-bin/koha/circ/offline.pl" id="mainform" name="mainform" autocomplete="off">
123 <fieldset id="circ_circulation_issue">
124 <span id="clearscreen"><a href="/cgi-bin/koha/circ/offline.pl" title="Clear screen">x</a></span>
125 <label for="checkout-barcode">Checking out to <span class="patron-title"></span></label>
126 <div class="hint">Enter item barcode:</div>
127 <input type="text" name="barcode" id="checkout-barcode" class="barcode focus" size="14" />
128 <input type="submit" value="Check Out" />
130 <div class="date-select">
131 <div class="hint">Specify due date [% INCLUDE 'date-format.inc' %]: </div>
132 <input type="text" size="13" id="duedatespec" name="duedatespec" value="[% duedatespec | html %]" />
133 <label for="stickyduedate"> Remember for session:</label>
134 <input type="checkbox" id="stickyduedate" onclick="this.form.barcode.focus();" name="stickyduedate" checked="checked" />
135 <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;" />
140 <div id="patronlists" class="toptabs">
142 <li><a href="#checkouts"><span class="checkout-count">0</span> Checkouts</a></li>
143 <li><a href="#fines"><span class="fine-amount">0</span> in fines</a></li>
146 <!-- SUMMARY : TODAY & PREVIOUS ISSUES -->
148 <div id="session-issues">
151 <th scope="col">Due date</th>
152 <th scope="col">Title</th>
153 <th scope="col">Barcode</th>
154 <th scope="col">Item type</th>
155 <th scope="col">Checked out on</th>
156 <th scope="col">Checked out from</th>
157 <th scope="col">Call no</th>
158 <th scope="col">Charge</th>
166 <h5>Previous checkouts</h5>
167 <table id="oldissuest">
169 <th scope="col">Due date</th>
170 <th scope="col">Title</th>
171 <th scope="col">Barcode</th>
172 <th scope="col">Item type</th>
173 <th scope="col">Checked out on</th>
174 <th scope="col">Checked out from</th>
175 <th scope="col">Call no</th>
176 <th scope="col">Charge</th>
185 <span class="patron-title"></span> has <span class="fine-amount">0</span> in fines. If you would like you can record payments.
186 <fieldset><legend>Pay fines</legend>
187 <label for="pay-fine-amount">Fine amount: </label><input type="text" name="pay-fine-amount" id="pay-fine-amount"/>
188 <button id="pay-fine" class="submit">Pay fine</button>
190 <table id="session-payments" style="display: none;">
191 <thead><tr><th>Amount</th><th>Timestamp</th></tr></thead>
202 </div> <!-- /.col-sm-10.col-sm-push-2 -->
204 <div class="offline-circulation" style="display: none;">
205 <div class="col-sm-2 col-sm-pull-10">
207 <div class="patroninfo"><h5 class="patron-title"> </h5>
209 <li id="patron-address-1"></li>
210 <li id="patron-address-2"></li>
211 <li id="patron-address-parts"><!-- city, state, zipcode, country --></li>
212 <li id="patron-phone"></li>
213 <li id="patron-email"></li>
214 <li id="patron-category"></li>
215 <li id="patron-library"></li>
219 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
220 </div> <!-- /.row -->
223 [% MACRO jsinclude BLOCK %]
224 [% INCLUDE 'calendar.inc' %]
225 [% Asset.js("lib/jquery/plugins/jquery.indexeddb.js") | $raw %]
226 [% Asset.js("js/offlinecirc.js") | $raw %]
227 [% Asset.js("lib/jquery/plugins/jquery-ui-timepicker-addon.min.js") | $raw %]
228 [% INCLUDE 'timepicker.inc' %]
230 var ALERT_SUCCESSFUL_CHECKIN = _("Checked in item.");
231 var ALERT_MATERIALS = _("Note about the accompanying materials: %s");
232 var ALERT_RESTRICTED = _("Patron is RESTRICTED");
233 var ALERT_NO_MATCHING_ITEM = _("No item with barcode in offline database (transaction recorded anyway): %s");
234 var ALERT_NOT_CHECKED_OUT = _("Item not listed as checked out in offline database (transaction recorded anyway)");
235 var ALERT_ITEM_WITHDRAWN = _("Item has been withdrawn (transaction recorded anyway)");
236 var ALERT_ITEM_RESTRICTED = _("Item is restricted (transaction recorded anyway)");
237 var ALERT_ITEM_LOST = _("Item has been lost (transaction recorded anyway)");
238 var ALERT_NO_MATCHING_PATRON = _("No patron cardnumber in offline database (proceeding anyway): %s");
239 var ALERT_PATRON_GONE_NO_ADDRESS = _("Patron's address is in doubt (proceeding anyway)");
240 var ALERT_PATRON_CARD_LOST = _("Patron's card is lost");
241 var ALERT_PATRON_EXPIRED = _("Patron's card is expired (%s)");
242 var ALERT_PATRON_BLOCKED_TEMPORARY = _("Patron has had overdue items and is restricted until: %s");
243 var ALERT_PATRON_RESTRICTED = _("Patron is restricted");
244 var ALERT_PATRON_FINE = _("Patron has outstanding fines: %s");
245 var ALERT_PATRON_FINE_OVER_LIMIT = _("Patron fines are over limit: %s");
246 var UPLOAD_PENDING_MESSAGE = _("You have transactions in the offline circulation database on this computer that have not been uploaded.");
247 var NO_UPLOAD_PENDING_MESSAGE = _("You do not have any pending transactions in the offline circulation database on this computer.");
251 var dateformat = '[% IF ( dateformat_us ) %]mm/dd/yy[% ELSIF ( dateformat_metric ) %]dd/mm/yy[% ELSE %]yy-mm-dd[% END %]';
253 function checkin(barcode, item, error) {
254 var alerts = checkAlerts(barcode, item);
255 if (typeof item === 'undefined') {
258 item.title = item.title || _("(Unknown)");
259 item.author = item.author || _("(Unknown)");
260 item.homebranch = item.homebranch || "";
261 item.holdingbranch = item.holdingbranch || "";
262 item.callnumber = item.callnumber || "";
263 item.itemtype = item.itemtype || "";
264 item.barcode = item.barcode || barcode;
265 var trans = { "timestamp" : new Date().toMySQLString(),
269 $('#alerts').empty();
270 $('.offline-home').hide();
271 $('.offline-sync').hide();
272 $('.offline-circulation').hide();
273 $('.offline-circulation-instructions').hide();
274 $('.offline-returns').show();
275 kohadb.recordTransaction(trans, function () {
276 $('#session-returned').show();
277 $('#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>');
278 if (alerts.length > 0) {
279 $('#alerts').append('<div class="dialog alert"><h3>' + _("Check in message") + '</h3></div>');
280 for (var msg in alerts) {
281 $('#alerts .dialog').append('<p>' + alerts[msg] + '</p');
284 $('#alerts').append('<div class="dialog"><h3>' + ALERT_SUCCESSFUL_CHECKIN + '</h3></div>');
287 setTimeout(function() { $('#checkin-barcode').trigger('focus'), 1 });
290 function checkAlerts(barcode, item) {
292 if (typeof item === 'undefined') {
293 alerts.push(ALERT_NO_MATCHING_ITEM.format(barcode));
295 if (typeof item.materials !== 'undefined' && item.materials != null) {
296 alerts.push(ALERT_MATERIALS.format(item.materials));
302 function showSyncInfo() {
303 kohadb.loadSetting("item-timestamp", showTimestamp);
304 kohadb.loadSetting("patron-timestamp", showTimestamp);
305 kohadb.loadSetting("issue-timestamp", showTimestamp);
306 kohadb.loadSetting("dirty", function (key, val) {
308 $('#upload-message').text(UPLOAD_PENDING_MESSAGE);
310 $('#upload-message').text(NO_UPLOAD_PENDING_MESSAGE);
315 function synchronize() {
316 kohadb.saveSetting("userid", "[% logged_in_user.userid | html %]");
317 kohadb.saveSetting("branchcode", "[% LoginBranchcode | html %]");
319 [% UNLESS (AllowOfflineCirculation) %]
323 $('#download-records').click(reloadRecords);
324 $('#upload-transactions').click(function () {
325 $('.loading-overlay div').text(_("Uploading transactions, please wait..."));
326 $('.loading-overlay').show();
329 url: "/cgi-bin/koha/offline_circ/service.pl",
330 }).done(function (data) {
332 $('.loading-overlay').hide();
333 alert(_("Please log in to Koha and try again. (Error: '%s')").format(data));
335 var uploadIter = $.indexedDB("koha").objectStore("transactions").each(uploadTransaction);
336 uploadIter.done(function() {
337 $.indexedDB("koha").transaction(["transactions"]).then(function(){
339 }, function(transaction){
340 transaction.objectStore("transactions").clear();
342 $('.loading-overlay').hide();
343 kohadb.saveSetting("dirty", false);
344 $('#upload-message').text(NO_UPLOAD_PENDING_MESSAGE);
352 function showTimestamp(key, value) {
353 if (typeof value !== 'undefined') {
354 var ts = new Date(value);
355 $('#' + key).text($.datepicker.formatDate(dateformat, ts) + ' ' + ts.toTimeString());
357 $('#' + key).text(_("(never)"));
361 function reloadRecords(ev) {
362 $(".loading-overlay div").text(_("Loading records, please wait..."));
363 $(".loading-overlay").show();
365 $.indexedDB("koha").transaction(["patrons", "items", "issues"]).then(function(){
368 }, function(transaction){
369 transaction.objectStore("patrons").clear();
370 transaction.objectStore("items").clear();
371 transaction.objectStore("issues").clear();
373 if (typeof ev !== 'undefined') {
374 ev.stopPropagation();
378 function uploadTransaction(transaction) {
381 url: "/cgi-bin/koha/offline_circ/service.pl",
382 data: { "userid" : kohadb.settings.userid,
383 "branchcode" : kohadb.settings.branchcode,
384 "timestamp" : transaction.value.timestamp,
385 "action" : transaction.value.action,
386 "barcode" : transaction.value.barcode,
387 "cardnumber" : transaction.value.cardnumber,
388 "amount" : transaction.value.amount,
392 return undefined, true;
395 function finishedLoading() {
396 kohadb.saveSetting('item-timestamp', start.toISOString())
397 kohadb.saveSetting('patron-timestamp', start.toISOString())
398 kohadb.saveSetting('issue-timestamp', start.toISOString())
399 showTimestamp('item-timestamp', start.toISOString());
400 showTimestamp('patron-timestamp', start.toISOString());
401 showTimestamp('issue-timestamp', start.toISOString());
402 $(".loading-overlay").hide();
405 function loadRecords(page) {
406 [% IF (AllowOfflineCirculation) %]
407 $(".loading-overlay div").text(_("Loading page %s, please wait...").format(page));
408 $(".loading-overlay").show();
411 url: "/cgi-bin/koha/offline_circ/download.pl",
412 data: { "data": "all",
416 }).done(function (data) {
417 $.indexedDB("koha").transaction(["patrons", "items", "issues"]).then(function(){
421 setTimeout(function () { loadRecords(page + 1); }, 200);
424 }, function(transaction){
426 var patrons = transaction.objectStore("patrons");
427 $.each(data.patrons, function () {
432 var items = transaction.objectStore("items");
433 $.each(data.items, function () {
438 var issues = transaction.objectStore("issues");
439 $.each(data.issues, function () {
448 function validate1(date) {
449 var today = new Date();
450 if ( date < today ) {
457 function loadPatron(barcode) {
458 $('#oldissues').hide();
459 $('#session-issues').hide();
460 $('#issuest tbody').empty();
461 $('#session-payments').hide();
462 $('.checkout-count').text(0);
463 $.indexedDB("koha").transaction(["patrons", "issues"]).then(function() {
465 }, function(transaction){
466 var patrons = transaction.objectStore("patrons");
467 patrons.get(barcode).done(function (patron, error) {
468 showPatron(barcode, patron, error);
470 var issuesidx = transaction.objectStore("issues").index("cardnumber");
471 $('#oldissuest tbody').empty();
472 issuesidx.each(function (item) {
473 $('#oldissues').show();
474 $('#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>");
475 $('.checkout-count').text(parseInt($('.checkout-count').text()) + 1);
480 function checkout(barcode, item, error) {
481 var alerts = checkAlerts(barcode, item);
482 if (typeof item === 'undefined') {
485 item.title = item.title || "";
486 item.author = item.author || "";
487 item.homebranch = item.homebranch || "";
488 item.holdingbranch = item.holdingbranch || "";
489 item.callnumber = item.callnumber || "";
490 item.itemtype = item.itemtype || "";
491 if ($('#duedatespec').val().length === 0) {
492 alert(_("You must set a due date in order to use offline circulation!"));
493 setTimeout(function() { $('#duedatespec').trigger('focus'), 1 });
496 var date_due = new Date($('#duedatespec').datepicker('getDate'));
497 var trans = { "timestamp" : new Date().toMySQLString(),
499 "cardnumber" : curpatron.cardnumber,
500 "date_due" : date_due.toMySQLString(),
503 $('#alerts').empty();
504 kohadb.recordTransaction(trans, function () {
505 $('#session-issues').show();
506 $('#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>');
507 $('.checkout-count').text(parseInt($('.checkout-count').text()) + 1);
508 if (alerts.length > 0) {
509 $('#alerts').append('<div class="dialog alert"><h3>' + _("Check out message") + '</h3></div>');
510 for (var msg in alerts) {
511 $('#alerts .dialog').append('<p>' + alerts[msg] + '</p');
514 $('#checkout-barcode').val('');
518 function recordFine(amount) {
519 var timestamp = new Date()
520 var trans = { "timestamp" : timestamp.toMySQLString(),
521 "cardnumber" : curpatron.cardnumber,
523 "action" : "payment",
525 kohadb.recordTransaction(trans, function () {
526 $('#session-payments').show();
527 $('#session-payments tbody').prepend('<tr><td>' + amount + '</td><td>' + $.datepicker.formatDate(dateformat, timestamp) + timestamp.toTimeString() + '</td></tr>');
528 $('.fine-amount').text(parseInt($('.fine-amount').text()) - amount);
532 function checkPatronAlerts(cardnumber, patron) {
534 if (typeof patron === 'undefined') {
535 alerts.push(ALERT_NO_MATCHING_PATRON.format(cardnumber));
537 if (patron.gonenoaddress !== '0') {
538 alerts.push(ALERT_PATRON_GONE_NO_ADDRESS);
540 if (patron.lost !== '0') {
541 alerts.push(ALERT_PATRON_CARD_LOST);
543 if (patron.debarred !== null) {
544 if (patron.debarred != '9999-12-31') {
545 alerts.push(ALERT_PATRON_BLOCKED_TEMPORARY.format($.datepicker.formatDate(dateformat, new Date(patron.debarred))));
547 alerts.push(ALERT_PATRON_RESTRICTED);
550 if (new Date(patron.dateexpiry) < new Date()) {
551 alerts.push(ALERT_PATRON_EXPIRED.format($.datepicker.formatDate(dateformat, new Date(patron.dateexpiry))));
553 if (parseInt(patron.fine) > [% maxoutstanding | html %]) {
554 alerts.push(ALERT_PATRON_FINE_OVER_LIMIT.format(patron.fine));
555 } else if (parseInt(patron.fine) > 0) {
556 alerts.push(ALERT_PATRON_FINE.format(patron.fine));
564 function showPatron(barcode, patron, error) {
565 var alerts = checkPatronAlerts(barcode, patron);
566 if (typeof patron === 'undefined') {
569 patron.surname = patron.surname || "";
570 patron.firstname = patron.firstname || "";
571 patron.othernames = patron.othernames || "";
572 patron.address = patron.address || "";
573 patron.address2 = patron.address2 || "";
574 patron.city = patron.city || "";
575 patron.state = patron.state || "";
576 patron.country = patron.country || "";
577 patron.zipcode = patron.zipcode || "";
578 patron.phone = patron.phone || "";
579 patron.mobile = patron.mobile || "";
580 patron.phonepro = patron.phonepro || "";
581 patron.email = patron.email || "";
582 patron.emailpro = patron.emailpro || "";
583 patron.categorycode = patron.categorycode || "";
584 patron.branchcode = patron.branchcode || "";
585 patron.cardnumber = barcode;
586 patron.fine = patron.fine || "0";
588 patron.name = patron.firstname + (patron.othernames.length > 0 ? " (" + patron.othernames + ") " : " ") + patron.surname + " (" + barcode + ")";
589 if (patron.name.length > 0) {
590 $('.patron-title').text(patron.name);
592 $('.patron-title').text(_("Unrecognized patron (%s)").format(barcode));
594 if (patron.address.length > 0 || patron.address2.length > 0) {
595 $('#patron-address-1').text(patron.address);
596 $('#patron-address-2').text(patron.address2);
598 $('#patron-address-1').html('<span class="empty" id="noaddressstored">' + _("No address stored.") + '</span></li>');
599 $('#patron-address-2').text('');
601 if (patron.city.length > 0) {
602 $('#patron-address-parts').text(patron.city + (patron.state.length > 0 ? ", " + patron.state : "") + " " + patron.zipcode + (patron.country.length > 0 ? ", " + patron.country : ""));
604 $('#patron-address-parts').html('<span class="empty" id="nocitystored">' + _("No city stored.") + '</span></li>');
606 if (patron.phone.length > 0 || patron.mobile.length > 0 || patron.phonepro.length > 0) {
607 $('#patron-phone').text((patron.phone.length > 0 ? patron.phone : (patron.mobile.length > 0 ? patron.mobile : (patron.phonepro.length > 0 ? patron.phonepro : ''))));
609 $('#patron-phone').html('<span class="empty" id="nophonestored">' + _("No phone stored.") + '</span></li>');
611 if (patron.email.length > 0 || patron.emailpro.length > 0) {
612 $('#patron-email').text((patron.email.length > 0 ? patron.email : (patron.emailpro.length > 0 ? patron.emailpro : "")));
614 $('#patron-email').html('<span class="empty" id="noemailstored">' + _("No email stored.") + '</span></li>');
616 if (patron.categorycode.length > 0) {
617 $('#patron-category').text(_("Category: %s").format(patron.categorycode));
619 $('#patron-category').html('<span class="empty" id="unknowncategory">' + _("Category code unknown.") + '</span></li>');
621 if (patron.branchcode.length > 0) {
622 $('#patron-library').text(_("Home library: %s").format(patron.branchcode));
624 $('#patron-library').html('<span class="empty" id="unknowncategory">' + _("Home library unknown.") + '</span></li>');
626 $('.fine-amount').text(patron.fine);
627 $('#alerts').empty();
628 if (alerts.length > 0) {
629 $('#alerts').append('<div class="dialog alert"><h3>' + _("Check out message") + '</h3></div>');
630 for (var msg in alerts) {
631 $('#alerts .dialog').append('<p>' + alerts[msg] + '</p>');
636 setTimeout(function() { $('#checkout-barcode').trigger('focus'), 1 });
639 // This next bit of code is to deal with the updated session issue
640 window.addEventListener('load', function(e) {
641 window.applicationCache.addEventListener('updateready', function(e) {
642 if (window.applicationCache.status == window.applicationCache.UPDATEREADY) {
643 // Browser downloaded a new app cache.
644 // Swap it in and reload the page to get the new hotness.
645 window.applicationCache.swapCache();
646 if (confirm(_("A new version of this site is available. Load it?"))) {
647 window.location.reload();
650 // Manifest didn't changed. Nothing new to server.
656 $(document).ready(function () {
658 $('#header_search #circ_search .tip').text(_("Enter patron card number:"));
660 $('ul[aria-labelledby="logged-in-menu"]').html('<li><a class="toplinks">' + _("You cannot change your branch or logout while using offline circulation") + '</a></li>');
663 $('#checkin-form, #checkin_search form').submit(function (event) {
664 event.preventDefault();
665 var barcode = $('input[name="barcode"]', this).val();
666 $('input[name="barcode"]', this).val('');
667 $.indexedDB("koha").transaction(["items"]).then(function() {
669 }, function(transaction){
670 var items = transaction.objectStore("items");
671 items.get(barcode).done(function (item, error) {
672 checkin(barcode, item, error);
677 $('#go-to-home').click(function () {
678 $('#alerts').empty();
679 $('.offline-sync').hide();
680 $('.offline-circulation').hide();
681 $('.offline-returns').hide();
682 $('.offline-circulation-instructions').hide();
683 $('.offline-home').show();
686 $('#go-to-returns').click(function () {
687 $('#alerts').empty();
688 $('.offline-home').hide();
689 $('.offline-sync').hide();
690 $('.offline-circulation').hide();
691 $('.offline-circulation-instructions').hide();
692 $('.offline-returns').show();
693 setTimeout(function() { $('#checkin-form input[name="barcode"]').trigger('focus'), 1 });
696 $('#go-to-circ').click(function () {
697 $('#alerts').empty();
698 $('.offline-home').hide();
699 $('.offline-sync').hide();
700 $('.offline-returns').hide();
701 $('.offline-circulation').hide();
702 $('.offline-circulation-instructions').show();
703 $('#header_search').tabs("option", "active", 0);
704 setTimeout(function() { $('#circ_search input[name="findborrower"]').trigger('focus'), 1 });
707 $('#go-to-sync').click(function () {
708 $('#alerts').empty();
712 url: "/cgi-bin/koha/offline_circ/list.pl",
713 success: function () {
714 $('.offline-home').hide();
715 $('.offline-returns').hide();
716 $('.offline-circulation').hide();
717 $('.offline-circulation-instructions').hide();
718 $('.offline-sync').show();
722 alert(_("You are offline and therefore cannot sync your database"));
727 $('#go-to-pending').click(function (ev) {
728 $('#alerts').empty();
732 url: "/cgi-bin/koha/offline_circ/list.pl",
733 success: function () {
734 window.location = '/cgi-bin/koha/offline_circ/list.pl';
737 alert(_("You are offline and therefore cannot process pending operations"));
742 $('#patronsearch').submit(function (event) {
743 event.preventDefault();
744 loadPatron($('#findborrower').val());
745 $('.offline-home').hide();
746 $('.offline-returns').hide();
747 $('.offline-sync').hide();
748 $('.offline-circulation-instructions').hide();
749 $('.offline-circulation').show();
750 $('#findborrower').val('');
751 setTimeout(function() { $('#checkout-barcode').trigger('focus'), 1 });
754 $('#pay-fine').click(function (event) {
755 event.preventDefault();
756 recordFine($('#pay-fine-amount').val());
759 $('#patronlists').tabs();
761 $("#newduedate").datetimepicker({
762 minDate: 1, // require that renewal date is after today
766 $("#duedatespec").datetimepicker({
767 onClose: function(dateText, inst) {
768 if (validate_date(dateText, inst) ) {
769 setTimeout(function() { $('#checkout-barcode').trigger('focus'), 1 });
774 }).on("change", function(e, value) {
775 if ( ! is_valid_date( $(this).val() ) ) {$(this).val("");}
777 $('#mainform').submit(function (event) {
778 event.preventDefault();
779 var barcode = $('#checkout-barcode').val();
780 $.indexedDB("koha").transaction(["items"]).then(function() {
782 }, function(transaction){
783 var items = transaction.objectStore("items");
784 items.get(barcode).done(function (item, error) {
785 checkout(barcode, item, error);
793 [% INCLUDE 'intranet-bottom.inc' %]