4 [% IF (AllowOfflineCirculation) %]
5 [% SET manifestattr = 'manifest="/cgi-bin/koha/circ/offline-mf.pl"' %]
7 [% IF ( bidi && AllowOfflineCirculation ) %]<html lang="[% lang %]" dir="[% bidi %]" manifest="/cgi-bin/koha/circ/offline-mf.pl">
8 [% ELSIF ( bidi ) %]<html lang="[% lang %]" dir="[% bidi %]">
9 [% ELSIF ( AllowOfflineCirculation ) %]<html lang="[% lang %]" manifest="/cgi-bin/koha/circ/offline-mf.pl">
10 [% ELSE %]<html lang="[% lang %]">[% END %]
12 <title>Koha › Circulation</title>
13 [% INCLUDE 'doc-head-close.inc' %]
16 <body id="circ_offline" class="circ">
17 [% INCLUDE 'header.inc' %]
18 [% INCLUDE 'circ-search.inc' %]
19 <div class="loading-overlay" style="display: none;">
20 <div>Downloading records, please wait...</div>
23 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a id="go-to-home" href="#offline-home">Offline circulation</a></div>
25 <div id="doc3" class="yui-t2">
29 <audio id="alert_sound" src="[% interface %]/prog/sound/critical.ogg" preload="auto"></audio>
30 <audio id="success_sound" src="[% interface %]/prog/sound/beep.ogg" preload="auto"></audio>
32 <div id="alerts" class="yui-b">
34 [% UNLESS (AllowOfflineCirculation) %]
35 <div id="noofflinecircwarning" class="dialog alert">
36 <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>
40 <div id="offline-home" class="yui-b offline-home">
42 <h1>Offline circulation</h1>
43 <div class="yui-u first">
45 <li><a id="go-to-circ" href="#offline-circulation">Check out</a></li>
46 <li><a id="go-to-returns" href="#offline-returns">Check in</a></li>
51 <p><strong>Note:</strong> You must be online to use these options.</p>
53 <li><a id="go-to-sync" href="#offline-sync">Synchronize</a></li>
54 <li><a id="go-to-pending" href="/cgi-bin/koha/offline_circ/list.pl">Pending offline circulation actions</a>
60 <div id="offline-sync" style="display: none;" class="yui-b offline-sync">
61 <div id="toolbar" class="btn-toolbar">
62 [% IF (AllowOfflineCirculation) %]
63 <a href="#" id="download-records" class="btn btn-default btn-sm"><i class="fa fa-arrow-down"></i>Download records</a>
65 <a href="#" id="upload-transactions" class="btn btn-default btn-sm"><i class="fa fa-arrow-up"></i>Upload transactions</a>
68 <h1>Offline circulation</h1>
69 <div class="yui-u first">
70 <div id="download-message">
71 In order for offline circulation to work on this computer,
72 your library's records must be up-to-date on this computer:
74 <li>Patron records were last synced on: <span id="patron-timestamp">(checking)</span></li>
75 <li>Item records were last synced on: <span id="item-timestamp">(checking)</span></li>
76 <li>Circulation records were last synced on: <span id="issue-timestamp">(checking)</span></li>
82 <div id="upload-message">
84 <div>View <a href="/cgi-bin/koha/offline_circ/list.pl">pending offline circulation actions</a></div>
89 <div id="offline-returns" style="display: none;" class="yui-b offline-returns">
91 <form id="checkin-form" method="post" action="/cgi-bin/koha/circ/returns.pl" autocomplete="off" >
92 <div class="yui-u first">
94 <legend>Check In</legend>
95 <label for="checkin-barcode">Enter item barcode: </label>
96 <input name="barcode" id="checkin-barcode" size="14" class="focus"/>
97 <input type="submit" class="submit" value="Submit" />
103 <div id="session-returned" style="display: none;">
104 <h2>Checked-in items</h2>
105 <table id="already-checked-in">
107 <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>
115 <div style="display: none;" class="yui-b offline-circulation-instructions">
117 Scan a patron barcode to start.
121 <div id="offline-circulation" style="display: none;" class="yui-b 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 %]" />
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;" />
142 <div class="yui-g"><div id="patronlists" class="toptabs">
144 <li><a href="#checkouts"><span class="checkout-count">0</span> Checkouts</a></li>
145 <li><a href="#fines"><span class="fine-amount">0</span> in fines</a></li>
148 <!-- SUMMARY : TODAY & PREVIOUS ISSUES -->
150 <div id="session-issues">
153 <th scope="col">Due date</th>
154 <th scope="col">Title</th>
155 <th scope="col">Barcode</th>
156 <th scope="col">Item type</th>
157 <th scope="col">Checked out on</th>
158 <th scope="col">Checked out from</th>
159 <th scope="col">Call no</th>
160 <th scope="col">Charge</th>
168 <h5>Previous checkouts</h5>
169 <table id="oldissuest">
171 <th scope="col">Due date</th>
172 <th scope="col">Title</th>
173 <th scope="col">Barcode</th>
174 <th scope="col">Item type</th>
175 <th scope="col">Checked out on</th>
176 <th scope="col">Checked out from</th>
177 <th scope="col">Call no</th>
178 <th scope="col">Charge</th>
187 <span class="patron-title"></span> has <span class="fine-amount">0</span> in fines. If you would like you can record payments.
188 <fieldset><legend>Pay fines</legend>
189 <label for="pay-fine-amount">Fine amount: </label><input type="text" name="pay-fine-amount" id="pay-fine-amount"/>
190 <button id="pay-fine" class="submit">Pay fine</button>
192 <table id="session-payments" style="display: none;">
193 <thead><tr><th>Amount</th><th>Timestamp</th></tr></thead>
203 <div class="yui-b offline-circulation" style="display: none;">
204 <div class="patroninfo"><h5 class="patron-title"> </h5>
206 <li id="patron-address-1"></li>
207 <li id="patron-address-2"></li>
208 <li id="patron-address-parts"><!-- city, state, zipcode, country --></li>
209 <li id="patron-phone"></li>
210 <li id="patron-email"></li>
211 <li id="patron-category"></li>
212 <li id="patron-library"></li>
218 [% MACRO jsinclude BLOCK %]
219 [% INCLUDE 'calendar.inc' %]
220 [% Asset.js("lib/jquery/plugins/jquery.indexeddb.js") %]
221 [% Asset.js("js/offlinecirc.js") %]
222 [% Asset.js("lib/jquery/plugins/jquery-ui-timepicker-addon.min.js") %]
223 [% INCLUDE 'timepicker.inc' %]
224 <script type="text/javascript">
225 var ALERT_SUCCESSFUL_CHECKIN = _("Checked in item.");
226 var ALERT_MATERIALS = _("Note about the accompanying materials: %s");
227 var ALERT_RESTRICTED = _("Patron is RESTRICTED");
228 var ALERT_NO_MATCHING_ITEM = _("No item with barcode in offline database (transaction recorded anyway): %s");
229 var ALERT_NOT_CHECKED_OUT = _("Item not listed as checked out in offline database (transaction recorded anyway)");
230 var ALERT_ITEM_WITHDRAWN = _("Item has been withdrawn (transaction recorded anyway)");
231 var ALERT_ITEM_RESTRICTED = _("Item is restricted (transaction recorded anyway)");
232 var ALERT_ITEM_LOST = _("Item has been lost (transaction recorded anyway)");
233 var ALERT_NO_MATCHING_PATRON = _("No patron cardnumber in offline database (proceeding anyway): %s");
234 var ALERT_PATRON_GONE_NO_ADDRESS = _("Patron's address is in doubt (proceeding anyway)");
235 var ALERT_PATRON_CARD_LOST = _("Patron's card is lost");
236 var ALERT_PATRON_EXPIRED = _("Patron's card is expired (%s)");
237 var ALERT_PATRON_BLOCKED_TEMPORARY = _("Patron has had overdue items and is restricted until: %s");
238 var ALERT_PATRON_RESTRICTED = _("Patron is restricted");
239 var ALERT_PATRON_FINE = _("Patron has outstanding fines: %s");
240 var ALERT_PATRON_FINE_OVER_LIMIT = _("Patron fines are over limit: %s");
241 var UPLOAD_PENDING_MESSAGE = _("You have transactions in the offline circulation database on this computer that have not been uploaded.");
242 var NO_UPLOAD_PENDING_MESSAGE = _("You do not have any pending transactions in the offline circulation database on this computer.");
246 var dateformat = '[% IF ( dateformat_us ) %]mm/dd/yy[% ELSIF ( dateformat_metric ) %]dd/mm/yy[% ELSE %]yy-mm-dd[% END %]';
248 function checkin(barcode, item, error) {
249 var alerts = checkAlerts(barcode, item);
250 if (typeof item === 'undefined') {
253 item.title = item.title || _("(Unknown)");
254 item.author = item.author || _("(Unknown)");
255 item.homebranch = item.homebranch || "";
256 item.holdingbranch = item.holdingbranch || "";
257 item.callnumber = item.callnumber || "";
258 item.itemtype = item.itemtype || "";
259 item.barcode = item.barcode || barcode;
260 var trans = { "timestamp" : new Date().toMySQLString(),
264 $('#alerts').empty();
265 $('.offline-home').hide();
266 $('.offline-sync').hide();
267 $('.offline-circulation').hide();
268 $('.offline-circulation-instructions').hide();
269 $('.offline-returns').show();
270 kohadb.recordTransaction(trans, function () {
271 $('#session-returned').show();
272 $('#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>');
273 if (alerts.length > 0) {
274 $('#alerts').append('<div class="dialog alert"><h3>' + _("Check in message") + '</h3></div>');
275 for (var msg in alerts) {
276 $('#alerts .dialog').append('<p>' + alerts[msg] + '</p');
279 $('#alerts').append('<div class="dialog"><h3>' + ALERT_SUCCESSFUL_CHECKIN + '</h3></div>');
282 setTimeout(function() { $('#checkin-barcode').trigger('focus'), 1 });
285 function checkAlerts(barcode, item) {
287 if (typeof item === 'undefined') {
288 alerts.push(ALERT_NO_MATCHING_ITEM.format(barcode));
290 if (typeof item.materials !== 'undefined' && item.materials != null) {
291 alerts.push(ALERT_MATERIALS.format(item.materials));
297 function showSyncInfo() {
298 kohadb.loadSetting("item-timestamp", showTimestamp);
299 kohadb.loadSetting("patron-timestamp", showTimestamp);
300 kohadb.loadSetting("issue-timestamp", showTimestamp);
301 kohadb.loadSetting("dirty", function (key, val) {
303 $('#upload-message').text(UPLOAD_PENDING_MESSAGE);
305 $('#upload-message').text(NO_UPLOAD_PENDING_MESSAGE);
310 function synchronize() {
311 kohadb.saveSetting("userid", "[% loggedinusername %]");
312 kohadb.saveSetting("branchcode", "[% LoginBranchcode %]");
314 [% UNLESS (AllowOfflineCirculation) %]
318 $('#download-records').click(reloadRecords);
319 $('#upload-transactions').click(function () {
320 $('.loading-overlay div').text(_("Uploading transactions, please wait..."));
321 $('.loading-overlay').show();
324 url: "/cgi-bin/koha/offline_circ/service.pl",
325 }).done(function (data) {
327 $('.loading-overlay').hide();
328 alert(_("Please log in to Koha and try again. (Error: '%s')").format(data));
330 var uploadIter = $.indexedDB("koha").objectStore("transactions").each(uploadTransaction);
331 uploadIter.done(function() {
332 $.indexedDB("koha").transaction(["transactions"]).then(function(){
334 }, function(transaction){
335 transaction.objectStore("transactions").clear();
337 $('.loading-overlay').hide();
338 kohadb.saveSetting("dirty", false);
339 $('#upload-message').text(NO_UPLOAD_PENDING_MESSAGE);
347 function showTimestamp(key, value) {
348 if (typeof value !== 'undefined') {
349 var ts = new Date(value);
350 $('#' + key).text($.datepicker.formatDate(dateformat, ts) + ' ' + ts.toTimeString());
352 $('#' + key).text(_("(never)"));
356 function reloadRecords(ev) {
357 $(".loading-overlay div").text(_("Loading records, please wait..."));
358 $(".loading-overlay").show();
360 $.indexedDB("koha").transaction(["patrons", "items", "issues"]).then(function(){
363 }, function(transaction){
364 transaction.objectStore("patrons").clear();
365 transaction.objectStore("items").clear();
366 transaction.objectStore("issues").clear();
368 if (typeof ev !== 'undefined') {
369 ev.stopPropagation();
373 function uploadTransaction(transaction) {
376 url: "/cgi-bin/koha/offline_circ/service.pl",
377 data: { "userid" : kohadb.settings.userid,
378 "branchcode" : kohadb.settings.branchcode,
379 "timestamp" : transaction.value.timestamp,
380 "action" : transaction.value.action,
381 "barcode" : transaction.value.barcode,
382 "cardnumber" : transaction.value.cardnumber,
383 "amount" : transaction.value.amount,
387 return undefined, true;
390 function finishedLoading() {
391 kohadb.saveSetting('item-timestamp', start.toISOString())
392 kohadb.saveSetting('patron-timestamp', start.toISOString())
393 kohadb.saveSetting('issue-timestamp', start.toISOString())
394 showTimestamp('item-timestamp', start.toISOString());
395 showTimestamp('patron-timestamp', start.toISOString());
396 showTimestamp('issue-timestamp', start.toISOString());
397 $(".loading-overlay").hide();
400 function loadRecords(page) {
401 [% IF (AllowOfflineCirculation) %]
402 $(".loading-overlay div").text(_("Loading page %s, please wait...").format(page));
403 $(".loading-overlay").show();
406 url: "/cgi-bin/koha/offline_circ/download.pl",
407 data: { "data": "all",
411 }).done(function (data) {
412 $.indexedDB("koha").transaction(["patrons", "items", "issues"]).then(function(){
416 setTimeout(function () { loadRecords(page + 1); }, 200);
419 }, function(transaction){
421 var patrons = transaction.objectStore("patrons");
422 $.each(data.patrons, function () {
427 var items = transaction.objectStore("items");
428 $.each(data.items, function () {
433 var issues = transaction.objectStore("issues");
434 $.each(data.issues, function () {
443 function validate1(date) {
444 var today = new Date();
445 if ( date < today ) {
452 function loadPatron(barcode) {
453 $('#oldissues').hide();
454 $('#session-issues').hide();
455 $('#issuest tbody').empty();
456 $('#session-payments').hide();
457 $('.checkout-count').text(0);
458 $.indexedDB("koha").transaction(["patrons", "issues"]).then(function() {
460 }, function(transaction){
461 var patrons = transaction.objectStore("patrons");
462 patrons.get(barcode).done(function (patron, error) {
463 showPatron(barcode, patron, error);
465 var issuesidx = transaction.objectStore("issues").index("cardnumber");
466 $('#oldissuest tbody').empty();
467 issuesidx.each(function (item) {
468 $('#oldissues').show();
469 $('#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>");
470 $('.checkout-count').text(parseInt($('.checkout-count').text()) + 1);
475 function checkout(barcode, item, error) {
476 var alerts = checkAlerts(barcode, item);
477 if (typeof item === 'undefined') {
480 item.title = item.title || "";
481 item.author = item.author || "";
482 item.homebranch = item.homebranch || "";
483 item.holdingbranch = item.holdingbranch || "";
484 item.callnumber = item.callnumber || "";
485 item.itemtype = item.itemtype || "";
486 if ($('#duedatespec').val().length === 0) {
487 alert(_("You must set a due date in order to use offline circulation!"));
488 setTimeout(function() { $('#duedatespec').trigger('focus'), 1 });
491 var date_due = new Date($('#duedatespec').datepicker('getDate'));
492 var trans = { "timestamp" : new Date().toMySQLString(),
494 "cardnumber" : curpatron.cardnumber,
495 "date_due" : date_due.toMySQLString(),
498 $('#alerts').empty();
499 kohadb.recordTransaction(trans, function () {
500 $('#session-issues').show();
501 $('#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>');
502 $('.checkout-count').text(parseInt($('.checkout-count').text()) + 1);
503 if (alerts.length > 0) {
504 $('#alerts').append('<div class="dialog alert"><h3>' + _("Check out message") + '</h3></div>');
505 for (var msg in alerts) {
506 $('#alerts .dialog').append('<p>' + alerts[msg] + '</p');
509 $('#checkout-barcode').val('');
513 function recordFine(amount) {
514 var timestamp = new Date()
515 var trans = { "timestamp" : timestamp.toMySQLString(),
516 "cardnumber" : curpatron.cardnumber,
518 "action" : "payment",
520 kohadb.recordTransaction(trans, function () {
521 $('#session-payments').show();
522 $('#session-payments tbody').prepend('<tr><td>' + amount + '</td><td>' + $.datepicker.formatDate(dateformat, timestamp) + timestamp.toTimeString() + '</td></tr>');
523 $('.fine-amount').text(parseInt($('.fine-amount').text()) - amount);
527 function checkPatronAlerts(cardnumber, patron) {
529 if (typeof patron === 'undefined') {
530 alerts.push(ALERT_NO_MATCHING_PATRON.format(cardnumber));
532 if (patron.gonenoaddress !== '0') {
533 alerts.push(ALERT_PATRON_GONE_NO_ADDRESS);
535 if (patron.lost !== '0') {
536 alerts.push(ALERT_PATRON_CARD_LOST);
538 if (patron.debarred !== null) {
539 if (patron.debarred != '9999-12-31') {
540 alerts.push(ALERT_PATRON_BLOCKED_TEMPORARY.format($.datepicker.formatDate(dateformat, new Date(patron.debarred))));
542 alerts.push(ALERT_PATRON_RESTRICTED);
545 if (new Date(patron.dateexpiry) < new Date()) {
546 alerts.push(ALERT_PATRON_EXPIRED.format($.datepicker.formatDate(dateformat, new Date(patron.dateexpiry))));
548 if (parseInt(patron.fine) > [% maxoutstanding %]) {
549 alerts.push(ALERT_PATRON_FINE_OVER_LIMIT.format(patron.fine));
550 } else if (parseInt(patron.fine) > 0) {
551 alerts.push(ALERT_PATRON_FINE.format(patron.fine));
559 function showPatron(barcode, patron, error) {
560 var alerts = checkPatronAlerts(barcode, patron);
561 if (typeof patron === 'undefined') {
564 patron.surname = patron.surname || "";
565 patron.firstname = patron.firstname || "";
566 patron.othernames = patron.othernames || "";
567 patron.address = patron.address || "";
568 patron.address2 = patron.address2 || "";
569 patron.city = patron.city || "";
570 patron.state = patron.state || "";
571 patron.country = patron.country || "";
572 patron.zipcode = patron.zipcode || "";
573 patron.phone = patron.phone || "";
574 patron.mobile = patron.mobile || "";
575 patron.phonepro = patron.phonepro || "";
576 patron.email = patron.email || "";
577 patron.emailpro = patron.emailpro || "";
578 patron.categorycode = patron.categorycode || "";
579 patron.branchcode = patron.branchcode || "";
580 patron.cardnumber = barcode;
581 patron.fine = patron.fine || "0";
583 patron.name = patron.firstname + (patron.othernames.length > 0 ? " (" + patron.othernames + ") " : " ") + patron.surname + " (" + barcode + ")";
584 if (patron.name.length > 0) {
585 $('.patron-title').text(patron.name);
587 $('.patron-title').text(_("Unrecognized patron (%s)").format(barcode));
589 if (patron.address.length > 0 || patron.address2.length > 0) {
590 $('#patron-address-1').text(patron.address);
591 $('#patron-address-2').text(patron.address2);
593 $('#patron-address-1').html('<span class="empty" id="noaddressstored">' + _("No address stored.") + '</span></li>');
594 $('#patron-address-2').text('');
596 if (patron.city.length > 0) {
597 $('#patron-address-parts').text(patron.city + (patron.state.length > 0 ? ", " + patron.state : "") + " " + patron.zipcode + (patron.country.length > 0 ? ", " + patron.country : ""));
599 $('#patron-address-parts').html('<span class="empty" id="nocitystored">' + _("No city stored.") + '</span></li>');
601 if (patron.phone.length > 0 || patron.mobile.length > 0 || patron.phonepro.length > 0) {
602 $('#patron-phone').text((patron.phone.length > 0 ? patron.phone : (patron.mobile.length > 0 ? patron.mobile : (patron.phonepro.length > 0 ? patron.phonepro : ''))));
604 $('#patron-phone').html('<span class="empty" id="nophonestored">' + _("No phone stored.") + '</span></li>');
606 if (patron.email.length > 0 || patron.emailpro.length > 0) {
607 $('#patron-email').text((patron.email.length > 0 ? patron.email : (patron.emailpro.length > 0 ? patron.emailpro : "")));
609 $('#patron-email').html('<span class="empty" id="noemailstored">' + _("No email stored.") + '</span></li>');
611 if (patron.categorycode.length > 0) {
612 $('#patron-category').text(_("Category: %s").format(patron.categorycode));
614 $('#patron-category').html('<span class="empty" id="unknowncategory">' + _("Category code unknown.") + '</span></li>');
616 if (patron.branchcode.length > 0) {
617 $('#patron-library').text(_("Home library: %s").format(patron.branchcode));
619 $('#patron-library').html('<span class="empty" id="unknowncategory">' + _("Home library unknown.") + '</span></li>');
621 $('.fine-amount').text(patron.fine);
622 $('#alerts').empty();
623 if (alerts.length > 0) {
624 $('#alerts').append('<div class="dialog alert"><h3>' + _("Check out message") + '</h3></div>');
625 for (var msg in alerts) {
626 $('#alerts .dialog').append('<p>' + alerts[msg] + '</p>');
630 $('#yui-main').show();
631 setTimeout(function() { $('#checkout-barcode').trigger('focus'), 1 });
634 // This next bit of code is to deal with the updated session issue
635 window.addEventListener('load', function(e) {
636 window.applicationCache.addEventListener('updateready', function(e) {
637 if (window.applicationCache.status == window.applicationCache.UPDATEREADY) {
638 // Browser downloaded a new app cache.
639 // Swap it in and reload the page to get the new hotness.
640 window.applicationCache.swapCache();
641 if (confirm(_("A new version of this site is available. Load it?"))) {
642 window.location.reload();
645 // Manifest didn't changed. Nothing new to server.
651 $(document).ready(function () {
653 $('#header_search #circ_search .tip').text(_("Enter patron card number:"));
655 $('ul[aria-labelledby="logged-in-menu"]').html('<li><a class="toplinks">' + _("You cannot change your branch or logout while using offline circulation") + '</a></li>');
658 $('#checkin-form, #checkin_search form').submit(function (event) {
659 event.preventDefault();
660 var barcode = $('input[name="barcode"]', this).val();
661 $('input[name="barcode"]', this).val('');
662 $.indexedDB("koha").transaction(["items"]).then(function() {
664 }, function(transaction){
665 var items = transaction.objectStore("items");
666 items.get(barcode).done(function (item, error) {
667 checkin(barcode, item, error);
672 $('#go-to-home').click(function () {
673 $('#alerts').empty();
674 $('.offline-sync').hide();
675 $('.offline-circulation').hide();
676 $('.offline-returns').hide();
677 $('.offline-circulation-instructions').hide();
678 $('.offline-home').show();
681 $('#go-to-returns').click(function () {
682 $('#alerts').empty();
683 $('.offline-home').hide();
684 $('.offline-sync').hide();
685 $('.offline-circulation').hide();
686 $('.offline-circulation-instructions').hide();
687 $('.offline-returns').show();
688 setTimeout(function() { $('#checkin-form input[name="barcode"]').trigger('focus'), 1 });
691 $('#go-to-circ').click(function () {
692 $('#alerts').empty();
693 $('.offline-home').hide();
694 $('.offline-sync').hide();
695 $('.offline-returns').hide();
696 $('.offline-circulation').hide();
697 $('.offline-circulation-instructions').show();
698 $('#header_search').tabs("option", "active", 0);
699 setTimeout(function() { $('#circ_search input[name="findborrower"]').trigger('focus'), 1 });
702 $('#go-to-sync').click(function () {
703 $('#alerts').empty();
707 url: "/cgi-bin/koha/offline_circ/list.pl",
708 success: function () {
709 $('.offline-home').hide();
710 $('.offline-returns').hide();
711 $('.offline-circulation').hide();
712 $('.offline-circulation-instructions').hide();
713 $('.offline-sync').show();
717 alert(_("You are offline and therefore cannot sync your database"));
722 $('#go-to-pending').click(function (ev) {
723 $('#alerts').empty();
727 url: "/cgi-bin/koha/offline_circ/list.pl",
728 success: function () {
729 window.location = '/cgi-bin/koha/offline_circ/list.pl';
732 alert(_("You are offline and therefore cannot process pending operations"));
737 $('#patronsearch').submit(function (event) {
738 event.preventDefault();
739 loadPatron($('#findborrower').val());
740 $('.offline-home').hide();
741 $('.offline-returns').hide();
742 $('.offline-sync').hide();
743 $('.offline-circulation-instructions').hide();
744 $('.offline-circulation').show();
745 $('#findborrower').val('');
746 setTimeout(function() { $('#checkout-barcode').trigger('focus'), 1 });
749 $('#pay-fine').click(function (event) {
750 event.preventDefault();
751 recordFine($('#pay-fine-amount').val());
754 $('#patronlists').tabs();
756 $("#newduedate").datetimepicker({
757 minDate: 1, // require that renewal date is after today
761 $("#duedatespec").datetimepicker({
762 onClose: function(dateText, inst) {
763 if (validate_date(dateText, inst) ) {
764 setTimeout(function() { $('#checkout-barcode').trigger('focus'), 1 });
769 }).on("change", function(e, value) {
770 if ( ! is_valid_date( $(this).val() ) ) {$(this).val("");}
772 $('#mainform').submit(function (event) {
773 event.preventDefault();
774 var barcode = $('#checkout-barcode').val();
775 $.indexedDB("koha").transaction(["items"]).then(function() {
777 }, function(transaction){
778 var items = transaction.objectStore("items");
779 items.get(barcode).done(function (item, error) {
780 checkout(barcode, item, error);
788 [% INCLUDE 'intranet-bottom.inc' %]