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 [% WRAPPER 'header.inc' %]
20 [% INCLUDE 'circ-search.inc' %]
22 <div class="loading-overlay" style="display: none;">
23 <div>Downloading records, please wait...</div>
27 [% WRAPPER 'sub-header.inc' %]
28 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
31 <a href="/cgi-bin/koha/mainpage.pl">Home</a>
34 <a id="go-to-home" href="#offline-home" aria-current="page">Offline circulation</a>
40 <div class="main container-fluid">
42 <div class="col-sm-10 col-sm-push-2">
44 <h1>Offline circulation</h1>
46 <audio id="alert_sound" src="[% interface | html %]/prog/sound/critical.ogg" preload="auto"></audio>
47 <audio id="success_sound" src="[% interface | html %]/prog/sound/beep.ogg" preload="auto"></audio>
49 <div id="alerts"></div>
51 [% UNLESS (AllowOfflineCirculation) %]
52 <div id="noofflinecircwarning" class="dialog alert">
53 <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>
57 <div id="offline-home" class="offline-home">
59 <div class="col-sm-6">
61 <li><a id="go-to-circ" href="#offline-circulation">Check out</a></li>
62 <li><a id="go-to-returns" href="#offline-returns">Check in</a></li>
66 <div class="col-sm-6">
67 <p><strong>Note:</strong> You must be online to use these options.</p>
69 <li><a id="go-to-sync" href="#offline-sync">Synchronize</a></li>
70 <li><a id="go-to-pending" href="/cgi-bin/koha/offline_circ/list.pl">Pending offline circulation actions</a>
76 <div id="offline-sync" style="display: none;" class="offline-sync">
77 <div id="toolbar" class="btn-toolbar">
78 [% IF (AllowOfflineCirculation) %]
79 <a href="#" id="download-records" class="btn btn-default"><i class="fa fa-arrow-down"></i> Download records</a>
81 <a href="#" id="upload-transactions" class="btn btn-default"><i class="fa fa-arrow-up"></i> Upload transactions</a>
83 <h1>Offline circulation</h1>
85 <div class="col-sm-6">
86 <div id="download-message">
87 In order for offline circulation to work on this computer,
88 your library's records must be up-to-date on this computer:
90 <li>Patron records were last synced on: <span id="patron-timestamp">(checking)</span></li>
91 <li>Item records were last synced on: <span id="item-timestamp">(checking)</span></li>
92 <li>Circulation records were last synced on: <span id="issue-timestamp">(checking)</span></li>
97 <div class="col-sm-6">
98 <div id="upload-message">
100 <div>View <a href="/cgi-bin/koha/offline_circ/list.pl">pending offline circulation actions</a></div>
105 <div id="offline-returns" style="display: none;" class="offline-returns">
107 <form id="checkin-form" method="post" action="/cgi-bin/koha/circ/returns.pl" autocomplete="off" >
108 <div class="col-sm-6">
110 <legend>Check in</legend>
111 <label for="checkin-barcode">Enter item barcode: </label>
112 <input name="barcode" id="checkin-barcode" size="14" class="focus" type="text" />
113 <input type="submit" class="btn btn-primary" value="Submit" />
119 <div id="session-returned" style="display: none;">
120 <h2>Checked-in items</h2>
121 <table id="already-checked-in">
123 <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>
131 <div style="display: none;" class="offline-circulation-instructions">
132 Scan a patron barcode to start.
135 <div id="offline-circulation" style="display: none;" class="offline-circulation">
136 <form method="post" action="/cgi-bin/koha/circ/offline.pl" id="mainform" name="mainform" autocomplete="off">
137 <fieldset id="circ_circulation_issue">
138 <span id="clearscreen"><a href="/cgi-bin/koha/circ/offline.pl" title="Clear screen">x</a></span>
139 <label for="checkout-barcode">Checking out to <span class="patron-title"></span></label>
140 <div class="hint">Enter item barcode:</div>
141 <input type="text" name="barcode" id="checkout-barcode" class="barcode focus" size="14" />
142 <input type="submit" class="btn btn-primary" value="Check out" />
144 <div class="date-select">
145 <div class="hint">Specify due date [% INCLUDE 'date-format.inc' %]: </div>
146 <input type="text" size="13" id="duedatespec" name="duedatespec" value="[% duedatespec | html %]" class="flatpickr" data-flatpickr-enable-time="true" data-flatpickr-on-close-focus="#checkout-barcode" />
147 <label for="stickyduedate"> Remember for session:</label>
148 <input type="checkbox" id="stickyduedate" onclick="this.form.barcode.focus();" name="stickyduedate" checked="checked" />
149 <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;" />
154 <div id="patronlists" class="toptabs">
155 <ul class="nav nav-tabs" role="tablist">
156 <li role="presentation" class="active"><a href="#checkouts" aria-controls="checkouts" role="tab" data-toggle="tab"><span class="checkout-count">0</span> Checkouts</a></li>
157 <li role="presentation"><a href="#fines" aria-controls="fines" role="tab" data-toggle="tab"><span class="fine-amount">0</span> in fines</a></li>
159 <div class="tab-content">
160 <!-- SUMMARY : TODAY & PREVIOUS ISSUES -->
161 <div role="tabpanel" class="tab-pane active" id="checkouts">
162 <div id="session-issues">
165 <th scope="col">Due date</th>
166 <th scope="col">Title</th>
167 <th scope="col">Barcode</th>
168 <th scope="col">Item type</th>
169 <th scope="col">Checked out on</th>
170 <th scope="col">Checked out from</th>
171 <th scope="col">Call number</th>
172 <th scope="col">Charge</th>
180 <h5>Previous checkouts</h5>
181 <table id="oldissuest">
183 <th scope="col">Due date</th>
184 <th scope="col">Title</th>
185 <th scope="col">Barcode</th>
186 <th scope="col">Item type</th>
187 <th scope="col">Checked out on</th>
188 <th scope="col">Checked out from</th>
189 <th scope="col">Call number</th>
190 <th scope="col">Charge</th>
198 <div role="tabpanel" class="tab-pane" id="fines">
199 <span class="patron-title"></span> has <span class="fine-amount">0</span> in fines. If you would like you can record payments.
200 <fieldset><legend>Pay fines</legend>
201 <label for="pay-fine-amount">Fine amount: </label><input type="text" name="pay-fine-amount" id="pay-fine-amount"/>
202 <button id="pay-fine" class="submit">Pay fine</button>
204 <table id="session-payments" style="display: none;">
205 <thead><tr><th>Amount</th><th>Date</th></tr></thead>
209 </div> <!-- /# -->fines
210 </div> <!-- /.tab-content -->
211 </div> <!-- /#patronlists -->
217 </div> <!-- /.col-sm-10.col-sm-push-2 -->
219 <div class="offline-circulation" style="display: none;">
220 <div class="col-sm-2 col-sm-pull-10">
222 <div class="patroninfo"><h5 class="patron-title"> </h5>
224 <li id="patron-address-1"></li>
225 <li id="patron-address-2"></li>
226 <li id="patron-address-parts"><!-- city, state, zipcode, country --></li>
227 <li id="patron-phone"></li>
228 <li id="patron-email"></li>
229 <li id="patron-category"></li>
230 <li id="patron-library"></li>
234 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
235 </div> <!-- /.row -->
238 [% MACRO jsinclude BLOCK %]
239 [% INCLUDE 'calendar.inc' %]
240 [% Asset.js("lib/jquery/plugins/jquery.indexeddb.js") | $raw %]
241 [% Asset.js("js/offlinecirc.js") | $raw %]
243 var ALERT_SUCCESSFUL_CHECKIN = _("Checked in item.");
244 var ALERT_MATERIALS = _("Note about the accompanying materials: %s");
245 var ALERT_RESTRICTED = _("Patron is RESTRICTED");
246 var ALERT_NO_MATCHING_ITEM = _("No item with barcode in offline database (transaction recorded anyway): %s");
247 var ALERT_NOT_CHECKED_OUT = _("Item not listed as checked out in offline database (transaction recorded anyway)");
248 var ALERT_ITEM_WITHDRAWN = _("Item has been withdrawn (transaction recorded anyway)");
249 var ALERT_ITEM_RESTRICTED = _("Item is restricted (transaction recorded anyway)");
250 var ALERT_ITEM_LOST = _("Item has been lost (transaction recorded anyway)");
251 var ALERT_NO_MATCHING_PATRON = _("No patron card number in offline database (proceeding anyway): %s");
252 var ALERT_PATRON_GONE_NO_ADDRESS = _("Patron's address is in doubt (proceeding anyway)");
253 var ALERT_PATRON_CARD_LOST = _("Patron's card is lost");
254 var ALERT_PATRON_EXPIRED = _("Patron's card is expired (%s)");
255 var ALERT_PATRON_BLOCKED_TEMPORARY = _("Patron has had overdue items and is restricted until: %s");
256 var ALERT_PATRON_RESTRICTED = _("Patron is restricted");
257 var ALERT_PATRON_FINE = _("Patron has outstanding fines: %s");
258 var ALERT_PATRON_FINE_OVER_LIMIT = _("Patron fines are over limit: %s");
259 var UPLOAD_PENDING_MESSAGE = _("You have transactions in the offline circulation database on this computer that have not been uploaded.");
260 var NO_UPLOAD_PENDING_MESSAGE = _("You do not have any pending transactions in the offline circulation database on this computer.");
264 var dateformat = '[% IF ( dateformat_us ) %]mm/dd/yy[% ELSIF ( dateformat_metric ) %]dd/mm/yy[% ELSE %]yy-mm-dd[% END %]';
265 var flatpickr_dateformat_string = [% IF ( dateformat == "us" ) %]"m/d/Y"[% ELSIF ( dateformat == "metric" ) %]"d/m/Y"[% ELSIF ( dateformat == "dmydot" ) %]"d.m.Y"[% ELSE %]"Y-m-d"[% END %];
266 var flatpickr_timeformat_string = [% IF Koha.Preference('TimeFormat') == '12hr' %]"G:i K"[% ELSE %]"H:i"[% END %];
267 var flatpickr_timestamp_string = "Y-m-d H:i";
268 var flatpickr_datetime_string = flatpickr_dateformat_string + " " + flatpickr_timeformat_string;
270 function checkin(barcode, item, error) {
271 var alerts = checkAlerts(barcode, item);
272 if (typeof item === 'undefined') {
275 item.title = item.title || _("(Unknown)");
276 item.author = item.author || _("(Unknown)");
277 item.homebranch = item.homebranch || "";
278 item.holdingbranch = item.holdingbranch || "";
279 item.callnumber = item.callnumber || "";
280 item.itemtype = item.itemtype || "";
281 item.barcode = item.barcode || barcode;
282 var trans = { "timestamp" : new Date().toMySQLString(),
286 $('#alerts').empty();
287 $('.offline-home').hide();
288 $('.offline-sync').hide();
289 $('.offline-circulation').hide();
290 $('.offline-circulation-instructions').hide();
291 $('.offline-returns').show();
292 kohadb.recordTransaction(trans, function () {
293 $('#session-returned').show();
294 $('#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>');
295 if (alerts.length > 0) {
296 $('#alerts').append('<div class="dialog alert"><h3>' + _("Check in message") + '</h3></div>');
297 for (var msg in alerts) {
298 $('#alerts .dialog').append('<p>' + alerts[msg] + '</p');
301 $('#alerts').append('<div class="dialog"><h3>' + ALERT_SUCCESSFUL_CHECKIN + '</h3></div>');
304 setTimeout(function() { $('#checkin-barcode').trigger('focus'), 1 });
307 function checkAlerts(barcode, item) {
309 if (typeof item === 'undefined') {
310 alerts.push(ALERT_NO_MATCHING_ITEM.format(barcode));
312 if (typeof item.materials !== 'undefined' && item.materials != null) {
313 alerts.push(ALERT_MATERIALS.format(item.materials));
319 function showSyncInfo() {
320 kohadb.loadSetting("item-timestamp", showTimestamp);
321 kohadb.loadSetting("patron-timestamp", showTimestamp);
322 kohadb.loadSetting("issue-timestamp", showTimestamp);
323 kohadb.loadSetting("dirty", function (key, val) {
325 $('#upload-message').text(UPLOAD_PENDING_MESSAGE);
327 $('#upload-message').text(NO_UPLOAD_PENDING_MESSAGE);
332 function synchronize() {
333 kohadb.saveSetting("userid", "[% logged_in_user.userid | html %]");
334 kohadb.saveSetting("branchcode", "[% Branches.GetLoggedInBranchcode | html %]");
336 [% UNLESS (AllowOfflineCirculation) %]
340 $('#download-records').click(reloadRecords);
341 $('#upload-transactions').click(function () {
342 $('.loading-overlay div').text(_("Uploading transactions, please wait..."));
343 $('.loading-overlay').show();
346 url: "/cgi-bin/koha/offline_circ/service.pl",
347 }).done(function (data) {
349 $('.loading-overlay').hide();
350 alert(_("Please log in to Koha and try again. (Error: '%s')").format(data));
352 var uploadIter = $.indexedDB("koha").objectStore("transactions").each(uploadTransaction);
353 uploadIter.done(function() {
354 $.indexedDB("koha").transaction(["transactions"]).then(function(){
356 }, function(transaction){
357 transaction.objectStore("transactions").clear();
359 $('.loading-overlay').hide();
360 kohadb.saveSetting("dirty", false);
361 $('#upload-message').text(NO_UPLOAD_PENDING_MESSAGE);
369 function fPformatTimeStamp( timestamp ){
370 var datetimeObj = flatpickr.parseDate( timestamp, flatpickr_timestamp_string );
371 return flatpickr.formatDate( datetimeObj, flatpickr_datetime_string );
374 function showTimestamp(key, value) {
375 if (typeof value !== 'undefined') {
376 var ts = new Date(value);
377 $('#' + key).text( fPformatTimeStamp( ts ) + ' ' + ts.toTimeString());
379 $('#' + key).text(_("(never)"));
383 function reloadRecords(ev) {
384 $(".loading-overlay div").text(_("Loading records, please wait..."));
385 $(".loading-overlay").show();
387 $.indexedDB("koha").transaction(["patrons", "items", "issues"]).then(function(){
390 }, function(transaction){
391 transaction.objectStore("patrons").clear();
392 transaction.objectStore("items").clear();
393 transaction.objectStore("issues").clear();
395 if (typeof ev !== 'undefined') {
396 ev.stopPropagation();
400 function uploadTransaction(transaction) {
403 url: "/cgi-bin/koha/offline_circ/service.pl",
404 data: { "userid" : kohadb.settings.userid,
405 "branchcode" : kohadb.settings.branchcode,
406 "timestamp" : transaction.value.timestamp,
407 "action" : transaction.value.action,
408 "barcode" : transaction.value.barcode,
409 "cardnumber" : transaction.value.cardnumber,
410 "amount" : transaction.value.amount,
414 return undefined, true;
417 function finishedLoading() {
418 kohadb.saveSetting('item-timestamp', start.toISOString())
419 kohadb.saveSetting('patron-timestamp', start.toISOString())
420 kohadb.saveSetting('issue-timestamp', start.toISOString())
421 showTimestamp('item-timestamp', start.toISOString());
422 showTimestamp('patron-timestamp', start.toISOString());
423 showTimestamp('issue-timestamp', start.toISOString());
424 $(".loading-overlay").hide();
427 function loadRecords(page) {
428 [% IF (AllowOfflineCirculation) %]
429 $(".loading-overlay div").text(_("Loading page %s, please wait...").format(page));
430 $(".loading-overlay").show();
433 url: "/cgi-bin/koha/offline_circ/download.pl",
434 data: { "data": "all",
438 }).done(function (data) {
439 $.indexedDB("koha").transaction(["patrons", "items", "issues"]).then(function(){
443 setTimeout(function () { loadRecords(page + 1); }, 200);
446 }, function(transaction){
448 var patrons = transaction.objectStore("patrons");
449 $.each(data.patrons, function () {
454 var items = transaction.objectStore("items");
455 $.each(data.items, function () {
460 var issues = transaction.objectStore("issues");
461 $.each(data.issues, function () {
470 function loadPatron(barcode) {
471 $('#oldissues').hide();
472 $('#session-issues').hide();
473 $('#issuest tbody').empty();
474 $('#session-payments').hide();
475 $('.checkout-count').text(0);
476 $.indexedDB("koha").transaction(["patrons", "issues"]).then(function() {
478 }, function(transaction){
479 var patrons = transaction.objectStore("patrons");
480 patrons.get(barcode).done(function (patron, error) {
481 showPatron(barcode, patron, error);
483 var issuesidx = transaction.objectStore("issues").index("cardnumber");
484 $('#oldissuest tbody').empty();
485 issuesidx.each(function (item) {
486 $('#oldissues').show();
487 $('#oldissuest tbody').append("<tr><td>" + fPformatTimeStamp( item.value.date_due ) + "</td><td>" + item.value.title + "</td><td>" + item.value.barcode + "</td><td>" + item.value.itype + "</td><td>" + fPformatTimeStamp( item.value.issuedate ) + "</td><td>" + item.value.issuebranch + "</td><td>" + item.value.callnumber + "</td><td>" + "" + "</td></tr>");
488 $('.checkout-count').text(parseInt($('.checkout-count').text()) + 1);
493 function checkout(barcode, item, error) {
494 var alerts = checkAlerts(barcode, item);
495 if (typeof item === 'undefined') {
498 item.title = item.title || "";
499 item.author = item.author || "";
500 item.homebranch = item.homebranch || "";
501 item.holdingbranch = item.holdingbranch || "";
502 item.callnumber = item.callnumber || "";
503 item.itemtype = item.itemtype || "";
504 if ($('#duedatespec').val().length === 0) {
505 alert(_("You must set a due date in order to use offline circulation!"));
506 setTimeout(function() { $('#duedatespec').trigger('focus'), 1 });
509 var date_due = flatpickr.parseDate( $('#duedatespec').val(), flatpickr_datetime_string );
510 var trans = { "timestamp" : new Date().toMySQLString(),
512 "cardnumber" : curpatron.cardnumber,
513 "date_due" : date_due.toMySQLString(),
516 $('#alerts').empty();
517 kohadb.recordTransaction(trans, function () {
518 $('#session-issues').show();
519 $('#issuest tbody').prepend('<tr><td>' + flatpickr.formatDate( date_due, flatpickr_datetime_string ) + '</td><td>' + item.title + '</td><td>' + barcode + '</td><td>' + item.itemtype + '</td><td>' + flatpickr.formatDate( new Date(), flatpickr_datetime_string ) + '</td><td>' + kohadb.settings.branchcode + '</td><td>' + item.callnumber + '</td><td></td></tr>');
520 $('.checkout-count').text(parseInt($('.checkout-count').text()) + 1);
521 if (alerts.length > 0) {
522 $('#alerts').append('<div class="dialog alert"><h3>' + _("Check out message") + '</h3></div>');
523 for (var msg in alerts) {
524 $('#alerts .dialog').append('<p>' + alerts[msg] + '</p');
527 $('#checkout-barcode').val('');
531 function recordFine(amount) {
532 var timestamp = new Date()
533 var trans = { "timestamp" : timestamp.toMySQLString(),
534 "cardnumber" : curpatron.cardnumber,
536 "action" : "payment",
538 kohadb.recordTransaction(trans, function () {
539 $('#session-payments').show();
540 $('#session-payments tbody').prepend('<tr><td>' + amount + '</td><td>' + fPformatTimeStamp( timestamp ) + '</td></tr>');
541 $('.fine-amount').text(parseInt($('.fine-amount').text()) - amount);
545 function checkPatronAlerts(cardnumber, patron) {
547 if (typeof patron === 'undefined') {
548 alerts.push(ALERT_NO_MATCHING_PATRON.format(cardnumber));
550 if (patron.gonenoaddress !== '0') {
551 alerts.push(ALERT_PATRON_GONE_NO_ADDRESS);
553 if (patron.lost !== '0') {
554 alerts.push(ALERT_PATRON_CARD_LOST);
556 if (patron.debarred !== null) {
557 if (patron.debarred != '9999-12-31') {
558 alerts.push( ALERT_PATRON_BLOCKED_TEMPORARY.format( flatpickr.formatDate( new Date(patron.debarred), flatpickr_datetime_string ) ) );
560 alerts.push(ALERT_PATRON_RESTRICTED);
563 if (new Date(patron.dateexpiry) < new Date()) {
564 alerts.push( ALERT_PATRON_EXPIRED.format( flatpickr.formatDate( new Date(patron.dateexpiry), flatpickr_datetime_string ) ) );
566 if (parseInt(patron.fine) > [% maxoutstanding | html %]) {
567 alerts.push(ALERT_PATRON_FINE_OVER_LIMIT.format(patron.fine));
568 } else if (parseInt(patron.fine) > 0) {
569 alerts.push(ALERT_PATRON_FINE.format(patron.fine));
577 function showPatron(barcode, patron, error) {
578 var alerts = checkPatronAlerts(barcode, patron);
579 if (typeof patron === 'undefined') {
582 patron.surname = patron.surname || "";
583 patron.firstname = patron.firstname || "";
584 patron.othernames = patron.othernames || "";
585 patron.address = patron.address || "";
586 patron.address2 = patron.address2 || "";
587 patron.city = patron.city || "";
588 patron.state = patron.state || "";
589 patron.country = patron.country || "";
590 patron.zipcode = patron.zipcode || "";
591 patron.phone = patron.phone || "";
592 patron.mobile = patron.mobile || "";
593 patron.phonepro = patron.phonepro || "";
594 patron.email = patron.email || "";
595 patron.emailpro = patron.emailpro || "";
596 patron.categorycode = patron.categorycode || "";
597 patron.branchcode = patron.branchcode || "";
598 patron.cardnumber = barcode;
599 patron.fine = patron.fine || "0";
601 patron.name = patron.firstname + (patron.othernames.length > 0 ? " (" + patron.othernames + ") " : " ") + patron.surname + " (" + barcode + ")";
602 if (patron.name.length > 0) {
603 $('.patron-title').text(patron.name);
605 $('.patron-title').text(_("Unrecognized patron (%s)").format(barcode));
607 if (patron.address.length > 0 || patron.address2.length > 0) {
608 $('#patron-address-1').text(patron.address);
609 $('#patron-address-2').text(patron.address2);
611 $('#patron-address-1').html('<span class="empty" id="noaddressstored">' + _("No address stored.") + '</span></li>');
612 $('#patron-address-2').text('');
614 if (patron.city.length > 0) {
615 $('#patron-address-parts').text(patron.city + (patron.state.length > 0 ? ", " + patron.state : "") + " " + patron.zipcode + (patron.country.length > 0 ? ", " + patron.country : ""));
617 $('#patron-address-parts').html('<span class="empty" id="nocitystored">' + _("No city stored.") + '</span></li>');
619 if (patron.phone.length > 0 || patron.mobile.length > 0 || patron.phonepro.length > 0) {
620 $('#patron-phone').text((patron.phone.length > 0 ? patron.phone : (patron.mobile.length > 0 ? patron.mobile : (patron.phonepro.length > 0 ? patron.phonepro : ''))));
622 $('#patron-phone').html('<span class="empty" id="nophonestored">' + _("No phone stored.") + '</span></li>');
624 if (patron.email.length > 0 || patron.emailpro.length > 0) {
625 $('#patron-email').text((patron.email.length > 0 ? patron.email : (patron.emailpro.length > 0 ? patron.emailpro : "")));
627 $('#patron-email').html('<span class="empty" id="noemailstored">' + _("No email stored.") + '</span></li>');
629 if (patron.categorycode.length > 0) {
630 $('#patron-category').text(_("Category: %s").format(patron.categorycode));
632 $('#patron-category').html('<span class="empty" id="unknowncategory">' + _("Category code unknown.") + '</span></li>');
634 if (patron.branchcode.length > 0) {
635 $('#patron-library').text(_("Home library: %s").format(patron.branchcode));
637 $('#patron-library').html('<span class="empty" id="unknowncategory">' + _("Home library unknown.") + '</span></li>');
639 $('.fine-amount').text(patron.fine);
640 $('#alerts').empty();
641 if (alerts.length > 0) {
642 $('#alerts').append('<div class="dialog alert"><h3>' + _("Check out message") + '</h3></div>');
643 for (var msg in alerts) {
644 $('#alerts .dialog').append('<p>' + alerts[msg] + '</p>');
649 setTimeout(function() { $('#checkout-barcode').trigger('focus'), 1 });
652 // This next bit of code is to deal with the updated session issue
653 if( typeof window.applicationCache !== "undefined" ){
654 window.addEventListener('load', function(e) {
655 window.applicationCache.addEventListener('updateready', function(e) {
656 if (window.applicationCache.status == window.applicationCache.UPDATEREADY) {
657 // Browser downloaded a new app cache.
658 // Swap it in and reload the page to get the new hotness.
659 window.applicationCache.swapCache();
660 if (confirm(_("A new version of this site is available. Load it?"))) {
661 window.location.reload();
664 // Manifest didn't changed. Nothing new to server.
671 $(document).ready(function () {
672 if( typeof window.applicationCache === "undefined" ){
673 $("#offline-home div").html('<div class="dialog alert"><h3>' + _("Offline circulation disabled") + '</h3><p>' + _("Your browser is not compatible with the built-in offline circulation tool.") + '</div>');
677 $('#header_search #circ_search .tip').text(_("Enter patron card number:"));
679 $('ul[aria-labelledby="logged-in-menu"]').html('<li><a class="toplinks">' + _("You cannot change your branch or logout while using offline circulation") + '</a></li>');
682 $('#checkin-form, #checkin_search form').submit(function (event) {
683 event.preventDefault();
684 var barcode = $('input[name="barcode"]', this).val();
685 $('input[name="barcode"]', this).val('');
686 $.indexedDB("koha").transaction(["items"]).then(function() {
688 }, function(transaction){
689 var items = transaction.objectStore("items");
690 items.get(barcode).done(function (item, error) {
691 checkin(barcode, item, error);
696 $('#go-to-home').click(function () {
697 $('#alerts').empty();
698 $('.offline-sync').hide();
699 $('.offline-circulation').hide();
700 $('.offline-returns').hide();
701 $('.offline-circulation-instructions').hide();
702 $('.offline-home').show();
705 $('#go-to-returns').click(function () {
706 $('#alerts').empty();
707 $('.offline-home').hide();
708 $('.offline-sync').hide();
709 $('.offline-circulation').hide();
710 $('.offline-circulation-instructions').hide();
711 $('.offline-returns').show();
712 setTimeout(function() { $('#checkin-form input[name="barcode"]').trigger('focus'), 1 });
715 $('#go-to-circ').click(function () {
716 $('#alerts').empty();
717 $('.offline-home').hide();
718 $('.offline-sync').hide();
719 $('.offline-returns').hide();
720 $('.offline-circulation').hide();
721 $('.offline-circulation-instructions').show();
722 $('#header_search').tabs("option", "active", 0);
723 setTimeout(function() { $('#circ_search input[name="findborrower"]').trigger('focus'), 1 });
726 $('#go-to-sync').click(function () {
727 $('#alerts').empty();
731 url: "/cgi-bin/koha/offline_circ/list.pl",
732 success: function () {
733 $('.offline-home').hide();
734 $('.offline-returns').hide();
735 $('.offline-circulation').hide();
736 $('.offline-circulation-instructions').hide();
737 $('.offline-sync').show();
741 alert(_("You are offline and therefore cannot sync your database"));
746 $('#go-to-pending').click(function (ev) {
747 $('#alerts').empty();
751 url: "/cgi-bin/koha/offline_circ/list.pl",
752 success: function () {
753 window.location = '/cgi-bin/koha/offline_circ/list.pl';
756 alert(_("You are offline and therefore cannot process pending operations"));
761 $('#patronsearch').submit(function (event) {
762 event.preventDefault();
763 loadPatron($('#findborrower').val());
764 $('.offline-home').hide();
765 $('.offline-returns').hide();
766 $('.offline-sync').hide();
767 $('.offline-circulation-instructions').hide();
768 $('.offline-circulation').show();
769 $('#findborrower').val('');
770 setTimeout(function() { $('#checkout-barcode').trigger('focus'), 1 });
773 $('#pay-fine').click(function (event) {
774 event.preventDefault();
775 recordFine($('#pay-fine-amount').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' %]