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>Circulation › Koha</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>
26 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
29 <a href="/cgi-bin/koha/mainpage.pl">Home</a>
32 <a id="go-to-home" href="#offline-home" aria-current="page">Offline circulation</a>
37 <div class="main container-fluid">
39 <div class="col-sm-10 col-sm-push-2">
42 <audio id="alert_sound" src="[% interface | html %]/prog/sound/critical.ogg" preload="auto"></audio>
43 <audio id="success_sound" src="[% interface | html %]/prog/sound/beep.ogg" preload="auto"></audio>
45 <div id="alerts"></div>
47 [% UNLESS (AllowOfflineCirculation) %]
48 <div id="noofflinecircwarning" class="dialog alert">
49 <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>
53 <div id="offline-home" class="offline-home">
54 <h1>Offline circulation</h1>
56 <div class="col-sm-6">
58 <li><a id="go-to-circ" href="#offline-circulation">Check out</a></li>
59 <li><a id="go-to-returns" href="#offline-returns">Check in</a></li>
63 <div class="col-sm-6">
64 <p><strong>Note:</strong> You must be online to use these options.</p>
66 <li><a id="go-to-sync" href="#offline-sync">Synchronize</a></li>
67 <li><a id="go-to-pending" href="/cgi-bin/koha/offline_circ/list.pl">Pending offline circulation actions</a>
73 <div id="offline-sync" style="display: none;" class="offline-sync">
74 <div id="toolbar" class="btn-toolbar">
75 [% IF (AllowOfflineCirculation) %]
76 <a href="#" id="download-records" class="btn btn-default"><i class="fa fa-arrow-down"></i>Download records</a>
78 <a href="#" id="upload-transactions" class="btn btn-default"><i class="fa fa-arrow-up"></i>Upload transactions</a>
80 <h1>Offline circulation</h1>
82 <div class="col-sm-6">
83 <div id="download-message">
84 In order for offline circulation to work on this computer,
85 your library's records must be up-to-date on this computer:
87 <li>Patron records were last synced on: <span id="patron-timestamp">(checking)</span></li>
88 <li>Item records were last synced on: <span id="item-timestamp">(checking)</span></li>
89 <li>Circulation records were last synced on: <span id="issue-timestamp">(checking)</span></li>
94 <div class="col-sm-6">
95 <div id="upload-message">
97 <div>View <a href="/cgi-bin/koha/offline_circ/list.pl">pending offline circulation actions</a></div>
102 <div id="offline-returns" style="display: none;" class="offline-returns">
104 <form id="checkin-form" method="post" action="/cgi-bin/koha/circ/returns.pl" autocomplete="off" >
105 <div class="col-sm-6">
107 <legend>Check in</legend>
108 <label for="checkin-barcode">Enter item barcode: </label>
109 <input name="barcode" id="checkin-barcode" size="14" class="focus" type="text" />
110 <input type="submit" class="submit" value="Submit" />
116 <div id="session-returned" style="display: none;">
117 <h2>Checked-in items</h2>
118 <table id="already-checked-in">
120 <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>
128 <div style="display: none;" class="offline-circulation-instructions">
129 Scan a patron barcode to start.
132 <div id="offline-circulation" style="display: none;" class="offline-circulation">
133 <form method="post" action="/cgi-bin/koha/circ/offline.pl" id="mainform" name="mainform" autocomplete="off">
134 <fieldset id="circ_circulation_issue">
135 <span id="clearscreen"><a href="/cgi-bin/koha/circ/offline.pl" title="Clear screen">x</a></span>
136 <label for="checkout-barcode">Checking out to <span class="patron-title"></span></label>
137 <div class="hint">Enter item barcode:</div>
138 <input type="text" name="barcode" id="checkout-barcode" class="barcode focus" size="14" />
139 <input type="submit" value="Check out" />
141 <div class="date-select">
142 <div class="hint">Specify due date [% INCLUDE 'date-format.inc' %]: </div>
143 <input type="text" size="13" id="duedatespec" name="duedatespec" value="[% duedatespec | html %]" />
144 <label for="stickyduedate"> Remember for session:</label>
145 <input type="checkbox" id="stickyduedate" onclick="this.form.barcode.focus();" name="stickyduedate" checked="checked" />
146 <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;" />
151 <div id="patronlists" class="toptabs">
153 <li><a href="#checkouts"><span class="checkout-count">0</span> Checkouts</a></li>
154 <li><a href="#fines"><span class="fine-amount">0</span> in fines</a></li>
157 <!-- SUMMARY : TODAY & PREVIOUS ISSUES -->
159 <div id="session-issues">
162 <th scope="col">Due date</th>
163 <th scope="col">Title</th>
164 <th scope="col">Barcode</th>
165 <th scope="col">Item type</th>
166 <th scope="col">Checked out on</th>
167 <th scope="col">Checked out from</th>
168 <th scope="col">Call number</th>
169 <th scope="col">Charge</th>
177 <h5>Previous checkouts</h5>
178 <table id="oldissuest">
180 <th scope="col">Due date</th>
181 <th scope="col">Title</th>
182 <th scope="col">Barcode</th>
183 <th scope="col">Item type</th>
184 <th scope="col">Checked out on</th>
185 <th scope="col">Checked out from</th>
186 <th scope="col">Call number</th>
187 <th scope="col">Charge</th>
196 <span class="patron-title"></span> has <span class="fine-amount">0</span> in fines. If you would like you can record payments.
197 <fieldset><legend>Pay fines</legend>
198 <label for="pay-fine-amount">Fine amount: </label><input type="text" name="pay-fine-amount" id="pay-fine-amount"/>
199 <button id="pay-fine" class="submit">Pay fine</button>
201 <table id="session-payments" style="display: none;">
202 <thead><tr><th>Amount</th><th>Timestamp</th></tr></thead>
213 </div> <!-- /.col-sm-10.col-sm-push-2 -->
215 <div class="offline-circulation" style="display: none;">
216 <div class="col-sm-2 col-sm-pull-10">
218 <div class="patroninfo"><h5 class="patron-title"> </h5>
220 <li id="patron-address-1"></li>
221 <li id="patron-address-2"></li>
222 <li id="patron-address-parts"><!-- city, state, zipcode, country --></li>
223 <li id="patron-phone"></li>
224 <li id="patron-email"></li>
225 <li id="patron-category"></li>
226 <li id="patron-library"></li>
230 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
231 </div> <!-- /.row -->
234 [% MACRO jsinclude BLOCK %]
235 [% INCLUDE 'calendar.inc' %]
236 [% Asset.js("lib/jquery/plugins/jquery.indexeddb.js") | $raw %]
237 [% Asset.js("js/offlinecirc.js") | $raw %]
238 [% Asset.js("lib/jquery/plugins/jquery-ui-timepicker-addon.min.js") | $raw %]
239 [% INCLUDE 'timepicker.inc' %]
241 var ALERT_SUCCESSFUL_CHECKIN = _("Checked in item.");
242 var ALERT_MATERIALS = _("Note about the accompanying materials: %s");
243 var ALERT_RESTRICTED = _("Patron is RESTRICTED");
244 var ALERT_NO_MATCHING_ITEM = _("No item with barcode in offline database (transaction recorded anyway): %s");
245 var ALERT_NOT_CHECKED_OUT = _("Item not listed as checked out in offline database (transaction recorded anyway)");
246 var ALERT_ITEM_WITHDRAWN = _("Item has been withdrawn (transaction recorded anyway)");
247 var ALERT_ITEM_RESTRICTED = _("Item is restricted (transaction recorded anyway)");
248 var ALERT_ITEM_LOST = _("Item has been lost (transaction recorded anyway)");
249 var ALERT_NO_MATCHING_PATRON = _("No patron cardnumber in offline database (proceeding anyway): %s");
250 var ALERT_PATRON_GONE_NO_ADDRESS = _("Patron's address is in doubt (proceeding anyway)");
251 var ALERT_PATRON_CARD_LOST = _("Patron's card is lost");
252 var ALERT_PATRON_EXPIRED = _("Patron's card is expired (%s)");
253 var ALERT_PATRON_BLOCKED_TEMPORARY = _("Patron has had overdue items and is restricted until: %s");
254 var ALERT_PATRON_RESTRICTED = _("Patron is restricted");
255 var ALERT_PATRON_FINE = _("Patron has outstanding fines: %s");
256 var ALERT_PATRON_FINE_OVER_LIMIT = _("Patron fines are over limit: %s");
257 var UPLOAD_PENDING_MESSAGE = _("You have transactions in the offline circulation database on this computer that have not been uploaded.");
258 var NO_UPLOAD_PENDING_MESSAGE = _("You do not have any pending transactions in the offline circulation database on this computer.");
262 var dateformat = '[% IF ( dateformat_us ) %]mm/dd/yy[% ELSIF ( dateformat_metric ) %]dd/mm/yy[% ELSE %]yy-mm-dd[% END %]';
264 function checkin(barcode, item, error) {
265 var alerts = checkAlerts(barcode, item);
266 if (typeof item === 'undefined') {
269 item.title = item.title || _("(Unknown)");
270 item.author = item.author || _("(Unknown)");
271 item.homebranch = item.homebranch || "";
272 item.holdingbranch = item.holdingbranch || "";
273 item.callnumber = item.callnumber || "";
274 item.itemtype = item.itemtype || "";
275 item.barcode = item.barcode || barcode;
276 var trans = { "timestamp" : new Date().toMySQLString(),
280 $('#alerts').empty();
281 $('.offline-home').hide();
282 $('.offline-sync').hide();
283 $('.offline-circulation').hide();
284 $('.offline-circulation-instructions').hide();
285 $('.offline-returns').show();
286 kohadb.recordTransaction(trans, function () {
287 $('#session-returned').show();
288 $('#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>');
289 if (alerts.length > 0) {
290 $('#alerts').append('<div class="dialog alert"><h3>' + _("Check in message") + '</h3></div>');
291 for (var msg in alerts) {
292 $('#alerts .dialog').append('<p>' + alerts[msg] + '</p');
295 $('#alerts').append('<div class="dialog"><h3>' + ALERT_SUCCESSFUL_CHECKIN + '</h3></div>');
298 setTimeout(function() { $('#checkin-barcode').trigger('focus'), 1 });
301 function checkAlerts(barcode, item) {
303 if (typeof item === 'undefined') {
304 alerts.push(ALERT_NO_MATCHING_ITEM.format(barcode));
306 if (typeof item.materials !== 'undefined' && item.materials != null) {
307 alerts.push(ALERT_MATERIALS.format(item.materials));
313 function showSyncInfo() {
314 kohadb.loadSetting("item-timestamp", showTimestamp);
315 kohadb.loadSetting("patron-timestamp", showTimestamp);
316 kohadb.loadSetting("issue-timestamp", showTimestamp);
317 kohadb.loadSetting("dirty", function (key, val) {
319 $('#upload-message').text(UPLOAD_PENDING_MESSAGE);
321 $('#upload-message').text(NO_UPLOAD_PENDING_MESSAGE);
326 function synchronize() {
327 kohadb.saveSetting("userid", "[% logged_in_user.userid | html %]");
328 kohadb.saveSetting("branchcode", "[% Branches.GetLoggedInBranchcode | html %]");
330 [% UNLESS (AllowOfflineCirculation) %]
334 $('#download-records').click(reloadRecords);
335 $('#upload-transactions').click(function () {
336 $('.loading-overlay div').text(_("Uploading transactions, please wait..."));
337 $('.loading-overlay').show();
340 url: "/cgi-bin/koha/offline_circ/service.pl",
341 }).done(function (data) {
343 $('.loading-overlay').hide();
344 alert(_("Please log in to Koha and try again. (Error: '%s')").format(data));
346 var uploadIter = $.indexedDB("koha").objectStore("transactions").each(uploadTransaction);
347 uploadIter.done(function() {
348 $.indexedDB("koha").transaction(["transactions"]).then(function(){
350 }, function(transaction){
351 transaction.objectStore("transactions").clear();
353 $('.loading-overlay').hide();
354 kohadb.saveSetting("dirty", false);
355 $('#upload-message').text(NO_UPLOAD_PENDING_MESSAGE);
363 function showTimestamp(key, value) {
364 if (typeof value !== 'undefined') {
365 var ts = new Date(value);
366 $('#' + key).text($.datepicker.formatDate(dateformat, ts) + ' ' + ts.toTimeString());
368 $('#' + key).text(_("(never)"));
372 function reloadRecords(ev) {
373 $(".loading-overlay div").text(_("Loading records, please wait..."));
374 $(".loading-overlay").show();
376 $.indexedDB("koha").transaction(["patrons", "items", "issues"]).then(function(){
379 }, function(transaction){
380 transaction.objectStore("patrons").clear();
381 transaction.objectStore("items").clear();
382 transaction.objectStore("issues").clear();
384 if (typeof ev !== 'undefined') {
385 ev.stopPropagation();
389 function uploadTransaction(transaction) {
392 url: "/cgi-bin/koha/offline_circ/service.pl",
393 data: { "userid" : kohadb.settings.userid,
394 "branchcode" : kohadb.settings.branchcode,
395 "timestamp" : transaction.value.timestamp,
396 "action" : transaction.value.action,
397 "barcode" : transaction.value.barcode,
398 "cardnumber" : transaction.value.cardnumber,
399 "amount" : transaction.value.amount,
403 return undefined, true;
406 function finishedLoading() {
407 kohadb.saveSetting('item-timestamp', start.toISOString())
408 kohadb.saveSetting('patron-timestamp', start.toISOString())
409 kohadb.saveSetting('issue-timestamp', start.toISOString())
410 showTimestamp('item-timestamp', start.toISOString());
411 showTimestamp('patron-timestamp', start.toISOString());
412 showTimestamp('issue-timestamp', start.toISOString());
413 $(".loading-overlay").hide();
416 function loadRecords(page) {
417 [% IF (AllowOfflineCirculation) %]
418 $(".loading-overlay div").text(_("Loading page %s, please wait...").format(page));
419 $(".loading-overlay").show();
422 url: "/cgi-bin/koha/offline_circ/download.pl",
423 data: { "data": "all",
427 }).done(function (data) {
428 $.indexedDB("koha").transaction(["patrons", "items", "issues"]).then(function(){
432 setTimeout(function () { loadRecords(page + 1); }, 200);
435 }, function(transaction){
437 var patrons = transaction.objectStore("patrons");
438 $.each(data.patrons, function () {
443 var items = transaction.objectStore("items");
444 $.each(data.items, function () {
449 var issues = transaction.objectStore("issues");
450 $.each(data.issues, function () {
459 function loadPatron(barcode) {
460 $('#oldissues').hide();
461 $('#session-issues').hide();
462 $('#issuest tbody').empty();
463 $('#session-payments').hide();
464 $('.checkout-count').text(0);
465 $.indexedDB("koha").transaction(["patrons", "issues"]).then(function() {
467 }, function(transaction){
468 var patrons = transaction.objectStore("patrons");
469 patrons.get(barcode).done(function (patron, error) {
470 showPatron(barcode, patron, error);
472 var issuesidx = transaction.objectStore("issues").index("cardnumber");
473 $('#oldissuest tbody').empty();
474 issuesidx.each(function (item) {
475 $('#oldissues').show();
476 $('#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>");
477 $('.checkout-count').text(parseInt($('.checkout-count').text()) + 1);
482 function checkout(barcode, item, error) {
483 var alerts = checkAlerts(barcode, item);
484 if (typeof item === 'undefined') {
487 item.title = item.title || "";
488 item.author = item.author || "";
489 item.homebranch = item.homebranch || "";
490 item.holdingbranch = item.holdingbranch || "";
491 item.callnumber = item.callnumber || "";
492 item.itemtype = item.itemtype || "";
493 if ($('#duedatespec').val().length === 0) {
494 alert(_("You must set a due date in order to use offline circulation!"));
495 setTimeout(function() { $('#duedatespec').trigger('focus'), 1 });
498 var date_due = new Date($('#duedatespec').datepicker('getDate'));
499 var trans = { "timestamp" : new Date().toMySQLString(),
501 "cardnumber" : curpatron.cardnumber,
502 "date_due" : date_due.toMySQLString(),
505 $('#alerts').empty();
506 kohadb.recordTransaction(trans, function () {
507 $('#session-issues').show();
508 $('#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>');
509 $('.checkout-count').text(parseInt($('.checkout-count').text()) + 1);
510 if (alerts.length > 0) {
511 $('#alerts').append('<div class="dialog alert"><h3>' + _("Check out message") + '</h3></div>');
512 for (var msg in alerts) {
513 $('#alerts .dialog').append('<p>' + alerts[msg] + '</p');
516 $('#checkout-barcode').val('');
520 function recordFine(amount) {
521 var timestamp = new Date()
522 var trans = { "timestamp" : timestamp.toMySQLString(),
523 "cardnumber" : curpatron.cardnumber,
525 "action" : "payment",
527 kohadb.recordTransaction(trans, function () {
528 $('#session-payments').show();
529 $('#session-payments tbody').prepend('<tr><td>' + amount + '</td><td>' + $.datepicker.formatDate(dateformat, timestamp) + timestamp.toTimeString() + '</td></tr>');
530 $('.fine-amount').text(parseInt($('.fine-amount').text()) - amount);
534 function checkPatronAlerts(cardnumber, patron) {
536 if (typeof patron === 'undefined') {
537 alerts.push(ALERT_NO_MATCHING_PATRON.format(cardnumber));
539 if (patron.gonenoaddress !== '0') {
540 alerts.push(ALERT_PATRON_GONE_NO_ADDRESS);
542 if (patron.lost !== '0') {
543 alerts.push(ALERT_PATRON_CARD_LOST);
545 if (patron.debarred !== null) {
546 if (patron.debarred != '9999-12-31') {
547 alerts.push(ALERT_PATRON_BLOCKED_TEMPORARY.format($.datepicker.formatDate(dateformat, new Date(patron.debarred))));
549 alerts.push(ALERT_PATRON_RESTRICTED);
552 if (new Date(patron.dateexpiry) < new Date()) {
553 alerts.push(ALERT_PATRON_EXPIRED.format($.datepicker.formatDate(dateformat, new Date(patron.dateexpiry))));
555 if (parseInt(patron.fine) > [% maxoutstanding | html %]) {
556 alerts.push(ALERT_PATRON_FINE_OVER_LIMIT.format(patron.fine));
557 } else if (parseInt(patron.fine) > 0) {
558 alerts.push(ALERT_PATRON_FINE.format(patron.fine));
566 function showPatron(barcode, patron, error) {
567 var alerts = checkPatronAlerts(barcode, patron);
568 if (typeof patron === 'undefined') {
571 patron.surname = patron.surname || "";
572 patron.firstname = patron.firstname || "";
573 patron.othernames = patron.othernames || "";
574 patron.address = patron.address || "";
575 patron.address2 = patron.address2 || "";
576 patron.city = patron.city || "";
577 patron.state = patron.state || "";
578 patron.country = patron.country || "";
579 patron.zipcode = patron.zipcode || "";
580 patron.phone = patron.phone || "";
581 patron.mobile = patron.mobile || "";
582 patron.phonepro = patron.phonepro || "";
583 patron.email = patron.email || "";
584 patron.emailpro = patron.emailpro || "";
585 patron.categorycode = patron.categorycode || "";
586 patron.branchcode = patron.branchcode || "";
587 patron.cardnumber = barcode;
588 patron.fine = patron.fine || "0";
590 patron.name = patron.firstname + (patron.othernames.length > 0 ? " (" + patron.othernames + ") " : " ") + patron.surname + " (" + barcode + ")";
591 if (patron.name.length > 0) {
592 $('.patron-title').text(patron.name);
594 $('.patron-title').text(_("Unrecognized patron (%s)").format(barcode));
596 if (patron.address.length > 0 || patron.address2.length > 0) {
597 $('#patron-address-1').text(patron.address);
598 $('#patron-address-2').text(patron.address2);
600 $('#patron-address-1').html('<span class="empty" id="noaddressstored">' + _("No address stored.") + '</span></li>');
601 $('#patron-address-2').text('');
603 if (patron.city.length > 0) {
604 $('#patron-address-parts').text(patron.city + (patron.state.length > 0 ? ", " + patron.state : "") + " " + patron.zipcode + (patron.country.length > 0 ? ", " + patron.country : ""));
606 $('#patron-address-parts').html('<span class="empty" id="nocitystored">' + _("No city stored.") + '</span></li>');
608 if (patron.phone.length > 0 || patron.mobile.length > 0 || patron.phonepro.length > 0) {
609 $('#patron-phone').text((patron.phone.length > 0 ? patron.phone : (patron.mobile.length > 0 ? patron.mobile : (patron.phonepro.length > 0 ? patron.phonepro : ''))));
611 $('#patron-phone').html('<span class="empty" id="nophonestored">' + _("No phone stored.") + '</span></li>');
613 if (patron.email.length > 0 || patron.emailpro.length > 0) {
614 $('#patron-email').text((patron.email.length > 0 ? patron.email : (patron.emailpro.length > 0 ? patron.emailpro : "")));
616 $('#patron-email').html('<span class="empty" id="noemailstored">' + _("No email stored.") + '</span></li>');
618 if (patron.categorycode.length > 0) {
619 $('#patron-category').text(_("Category: %s").format(patron.categorycode));
621 $('#patron-category').html('<span class="empty" id="unknowncategory">' + _("Category code unknown.") + '</span></li>');
623 if (patron.branchcode.length > 0) {
624 $('#patron-library').text(_("Home library: %s").format(patron.branchcode));
626 $('#patron-library').html('<span class="empty" id="unknowncategory">' + _("Home library unknown.") + '</span></li>');
628 $('.fine-amount').text(patron.fine);
629 $('#alerts').empty();
630 if (alerts.length > 0) {
631 $('#alerts').append('<div class="dialog alert"><h3>' + _("Check out message") + '</h3></div>');
632 for (var msg in alerts) {
633 $('#alerts .dialog').append('<p>' + alerts[msg] + '</p>');
638 setTimeout(function() { $('#checkout-barcode').trigger('focus'), 1 });
641 // This next bit of code is to deal with the updated session issue
642 window.addEventListener('load', function(e) {
643 window.applicationCache.addEventListener('updateready', function(e) {
644 if (window.applicationCache.status == window.applicationCache.UPDATEREADY) {
645 // Browser downloaded a new app cache.
646 // Swap it in and reload the page to get the new hotness.
647 window.applicationCache.swapCache();
648 if (confirm(_("A new version of this site is available. Load it?"))) {
649 window.location.reload();
652 // Manifest didn't changed. Nothing new to server.
658 $(document).ready(function () {
660 $('#header_search #circ_search .tip').text(_("Enter patron card number:"));
662 $('ul[aria-labelledby="logged-in-menu"]').html('<li><a class="toplinks">' + _("You cannot change your branch or logout while using offline circulation") + '</a></li>');
665 $('#checkin-form, #checkin_search form').submit(function (event) {
666 event.preventDefault();
667 var barcode = $('input[name="barcode"]', this).val();
668 $('input[name="barcode"]', this).val('');
669 $.indexedDB("koha").transaction(["items"]).then(function() {
671 }, function(transaction){
672 var items = transaction.objectStore("items");
673 items.get(barcode).done(function (item, error) {
674 checkin(barcode, item, error);
679 $('#go-to-home').click(function () {
680 $('#alerts').empty();
681 $('.offline-sync').hide();
682 $('.offline-circulation').hide();
683 $('.offline-returns').hide();
684 $('.offline-circulation-instructions').hide();
685 $('.offline-home').show();
688 $('#go-to-returns').click(function () {
689 $('#alerts').empty();
690 $('.offline-home').hide();
691 $('.offline-sync').hide();
692 $('.offline-circulation').hide();
693 $('.offline-circulation-instructions').hide();
694 $('.offline-returns').show();
695 setTimeout(function() { $('#checkin-form input[name="barcode"]').trigger('focus'), 1 });
698 $('#go-to-circ').click(function () {
699 $('#alerts').empty();
700 $('.offline-home').hide();
701 $('.offline-sync').hide();
702 $('.offline-returns').hide();
703 $('.offline-circulation').hide();
704 $('.offline-circulation-instructions').show();
705 $('#header_search').tabs("option", "active", 0);
706 setTimeout(function() { $('#circ_search input[name="findborrower"]').trigger('focus'), 1 });
709 $('#go-to-sync').click(function () {
710 $('#alerts').empty();
714 url: "/cgi-bin/koha/offline_circ/list.pl",
715 success: function () {
716 $('.offline-home').hide();
717 $('.offline-returns').hide();
718 $('.offline-circulation').hide();
719 $('.offline-circulation-instructions').hide();
720 $('.offline-sync').show();
724 alert(_("You are offline and therefore cannot sync your database"));
729 $('#go-to-pending').click(function (ev) {
730 $('#alerts').empty();
734 url: "/cgi-bin/koha/offline_circ/list.pl",
735 success: function () {
736 window.location = '/cgi-bin/koha/offline_circ/list.pl';
739 alert(_("You are offline and therefore cannot process pending operations"));
744 $('#patronsearch').submit(function (event) {
745 event.preventDefault();
746 loadPatron($('#findborrower').val());
747 $('.offline-home').hide();
748 $('.offline-returns').hide();
749 $('.offline-sync').hide();
750 $('.offline-circulation-instructions').hide();
751 $('.offline-circulation').show();
752 $('#findborrower').val('');
753 setTimeout(function() { $('#checkout-barcode').trigger('focus'), 1 });
756 $('#pay-fine').click(function (event) {
757 event.preventDefault();
758 recordFine($('#pay-fine-amount').val());
761 $('#patronlists').tabs();
763 $("#newduedate").datetimepicker({
764 minDate: 1, // require that renewal date is after today
768 $("#duedatespec").datetimepicker({
769 onClose: function(dateText, inst) {
770 if (validate_date(dateText, inst) ) {
771 setTimeout(function() { $('#checkout-barcode').trigger('focus'), 1 });
776 }).on("change", function(e, value) {
777 if ( ! is_valid_date( $(this).val() ) ) {$(this).val("");}
779 $('#mainform').submit(function (event) {
780 event.preventDefault();
781 var barcode = $('#checkout-barcode').val();
782 $.indexedDB("koha").transaction(["items"]).then(function() {
784 }, function(transaction){
785 var items = transaction.objectStore("items");
786 items.get(barcode).done(function (item, error) {
787 checkout(barcode, item, error);
795 [% INCLUDE 'intranet-bottom.inc' %]