|
Lines 1-788
Link Here
|
| 1 |
[% USE raw %] |
|
|
| 2 |
[% USE Asset %] |
| 3 |
[% USE Branches %] |
| 4 |
[% SET footerjs = 1 %] |
| 5 |
<!DOCTYPE html> |
| 6 |
[% IF (AllowOfflineCirculation) %] |
| 7 |
[% SET manifestattr = 'manifest="/cgi-bin/koha/circ/offline-mf.pl"' %] |
| 8 |
[% END %] |
| 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 %] |
| 13 |
<head> |
| 14 |
<title>Circulation › Koha</title> |
| 15 |
[% INCLUDE 'doc-head-close.inc' %] |
| 16 |
</head> |
| 17 |
|
| 18 |
<body id="circ_offline" class="circ"> |
| 19 |
[% WRAPPER 'header.inc' %] |
| 20 |
[% INCLUDE 'circ-search.inc' %] |
| 21 |
[% END %] |
| 22 |
<div class="loading-overlay" style="display: none;"> |
| 23 |
<div>Downloading records, please wait...</div> |
| 24 |
</div> |
| 25 |
|
| 26 |
[% WRAPPER 'sub-header.inc' %] |
| 27 |
[% WRAPPER breadcrumbs %] |
| 28 |
[% WRAPPER breadcrumb_item %] |
| 29 |
<a id="go-to-home" href="#offline-home" aria-current="page">Offline circulation</a> |
| 30 |
[% END %] |
| 31 |
[% END #/ WRAPPER breadcrumbs %] |
| 32 |
[% END #/ WRAPPER sub-header.inc %] |
| 33 |
|
| 34 |
<div class="main container-fluid"> |
| 35 |
<div class="row"> |
| 36 |
<div class="col-sm-10 col-sm-push-2"> |
| 37 |
<main> |
| 38 |
<h1>Offline circulation</h1> |
| 39 |
|
| 40 |
<audio id="alert_sound" src="[% interface | html %]/prog/sound/critical.ogg" preload="auto"></audio> |
| 41 |
<audio id="success_sound" src="[% interface | html %]/prog/sound/beep.ogg" preload="auto"></audio> |
| 42 |
|
| 43 |
<div id="alerts"></div> |
| 44 |
|
| 45 |
[% UNLESS (AllowOfflineCirculation) %] |
| 46 |
<div id="noofflinecircwarning" class="dialog alert"> |
| 47 |
<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> |
| 48 |
</div> |
| 49 |
[% END %] |
| 50 |
|
| 51 |
<div id="offline-home" class="offline-home"> |
| 52 |
<div class="row"> |
| 53 |
<div class="col-sm-6"> |
| 54 |
<ul> |
| 55 |
<li><a id="go-to-circ" href="#offline-circulation">Check out</a></li> |
| 56 |
<li><a id="go-to-returns" href="#offline-returns">Check in</a></li> |
| 57 |
</ul> |
| 58 |
</div> |
| 59 |
|
| 60 |
<div class="col-sm-6"> |
| 61 |
<p><strong>Note:</strong> You must be online to use these options.</p> |
| 62 |
<ul> |
| 63 |
<li><a id="go-to-sync" href="#offline-sync">Synchronize</a></li> |
| 64 |
<li><a id="go-to-pending" href="/cgi-bin/koha/offline_circ/list.pl">Pending offline circulation actions</a> |
| 65 |
</ul> |
| 66 |
</div> |
| 67 |
</div> |
| 68 |
</div> |
| 69 |
|
| 70 |
<div id="offline-sync" style="display: none;" class="offline-sync"> |
| 71 |
<div id="toolbar" class="btn-toolbar"> |
| 72 |
[% IF (AllowOfflineCirculation) %] |
| 73 |
<a href="#" id="download-records" class="btn btn-default"><i class="fa fa-arrow-down"></i> Download records</a> |
| 74 |
[% END %] |
| 75 |
<a href="#" id="upload-transactions" class="btn btn-default"><i class="fa fa-arrow-up"></i> Upload transactions</a> |
| 76 |
</div> |
| 77 |
<h1>Offline circulation</h1> |
| 78 |
<div class="row"> |
| 79 |
<div class="col-sm-6"> |
| 80 |
<div id="download-message"> |
| 81 |
In order for offline circulation to work on this computer, |
| 82 |
your library's records must be up-to-date on this computer: |
| 83 |
<ul> |
| 84 |
<li>Patron records were last synced on: <span id="patron-timestamp">(checking)</span></li> |
| 85 |
<li>Item records were last synced on: <span id="item-timestamp">(checking)</span></li> |
| 86 |
<li>Circulation records were last synced on: <span id="issue-timestamp">(checking)</span></li> |
| 87 |
</ul> |
| 88 |
</div> |
| 89 |
</div> |
| 90 |
|
| 91 |
<div class="col-sm-6"> |
| 92 |
<div id="upload-message"> |
| 93 |
</div> |
| 94 |
<div>View <a href="/cgi-bin/koha/offline_circ/list.pl">pending offline circulation actions</a></div> |
| 95 |
</div> |
| 96 |
</div> |
| 97 |
</div> |
| 98 |
|
| 99 |
<div id="offline-returns" style="display: none;" class="offline-returns"> |
| 100 |
<div class="row"> |
| 101 |
<form id="checkin-form" method="post" action="/cgi-bin/koha/circ/returns.pl" autocomplete="off" > |
| 102 |
<div class="col-sm-6"> |
| 103 |
<fieldset> |
| 104 |
<legend>Check in</legend> |
| 105 |
<label for="checkin-barcode">Enter item barcode: </label> |
| 106 |
<input name="barcode" id="checkin-barcode" size="14" class="focus" type="text" /> |
| 107 |
<input type="submit" class="btn btn-primary" value="Submit" /> |
| 108 |
</fieldset> |
| 109 |
</div> |
| 110 |
</form> |
| 111 |
</div> |
| 112 |
|
| 113 |
<div id="session-returned" style="display: none;"> |
| 114 |
<h2>Checked-in items</h2> |
| 115 |
<table id="already-checked-in"> |
| 116 |
<thead> |
| 117 |
<tr><th>Title</th><th>Author</th><th>Barcode</th><th>Home library</th><th>Holding library</th><th>Shelving location</th><th>Call number</th><th>Type</th></tr> |
| 118 |
</thead> |
| 119 |
<tbody> |
| 120 |
</tbody> |
| 121 |
</table> |
| 122 |
</div> |
| 123 |
</div> |
| 124 |
|
| 125 |
<div style="display: none;" class="offline-circulation-instructions"> |
| 126 |
Scan a patron barcode to start. |
| 127 |
</div> |
| 128 |
|
| 129 |
<div id="offline-circulation" style="display: none;" class="offline-circulation"> |
| 130 |
<form method="post" action="/cgi-bin/koha/circ/offline.pl" id="mainform" name="mainform" autocomplete="off"> |
| 131 |
<fieldset id="circ_circulation_issue"> |
| 132 |
<span id="clearscreen"><a href="/cgi-bin/koha/circ/offline.pl" title="Clear screen">x</a></span> |
| 133 |
<label for="checkout-barcode">Checking out to <span class="patron-title"></span></label> |
| 134 |
<div class="hint">Enter item barcode:</div> |
| 135 |
<input type="text" name="barcode" id="checkout-barcode" class="barcode focus" size="14" /> |
| 136 |
<input type="submit" class="btn btn-primary" value="Check out" /> |
| 137 |
|
| 138 |
<div class="date-select"> |
| 139 |
<div class="hint">Specify due date [% INCLUDE 'date-format.inc' %]: </div> |
| 140 |
<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" /> |
| 141 |
<label for="stickyduedate"> Remember for session:</label> |
| 142 |
<input type="checkbox" id="stickyduedate" onclick="this.form.barcode.focus();" name="stickyduedate" checked="checked" /> |
| 143 |
<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;" /> |
| 144 |
</div> |
| 145 |
</fieldset> |
| 146 |
</form> |
| 147 |
|
| 148 |
<div id="patronlists" class="toptabs"> |
| 149 |
<ul class="nav nav-tabs" role="tablist"> |
| 150 |
<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> |
| 151 |
<li role="presentation"><a href="#fines" aria-controls="fines" role="tab" data-toggle="tab"><span class="fine-amount">0</span> in fines</a></li> |
| 152 |
</ul> |
| 153 |
<div class="tab-content"> |
| 154 |
<!-- SUMMARY : TODAY & PREVIOUS ISSUES --> |
| 155 |
<div role="tabpanel" class="tab-pane active" id="checkouts"> |
| 156 |
<div id="session-issues"> |
| 157 |
<table id="issuest"> |
| 158 |
<thead><tr> |
| 159 |
<th scope="col">Due date</th> |
| 160 |
<th scope="col">Title</th> |
| 161 |
<th scope="col">Barcode</th> |
| 162 |
<th scope="col">Item type</th> |
| 163 |
<th scope="col">Checked out on</th> |
| 164 |
<th scope="col">Checked out from</th> |
| 165 |
<th scope="col">Call number</th> |
| 166 |
<th scope="col">Charge</th> |
| 167 |
</tr></thead> |
| 168 |
<tbody> |
| 169 |
</tbody> |
| 170 |
</table> |
| 171 |
</div> |
| 172 |
|
| 173 |
<div id="oldissues"> |
| 174 |
<h5>Previous checkouts</h5> |
| 175 |
<table id="oldissuest"> |
| 176 |
<thead><tr> |
| 177 |
<th scope="col">Due date</th> |
| 178 |
<th scope="col">Title</th> |
| 179 |
<th scope="col">Barcode</th> |
| 180 |
<th scope="col">Item type</th> |
| 181 |
<th scope="col">Checked out on</th> |
| 182 |
<th scope="col">Checked out from</th> |
| 183 |
<th scope="col">Call number</th> |
| 184 |
<th scope="col">Charge</th> |
| 185 |
</tr></thead> |
| 186 |
<tbody> |
| 187 |
</tbody> |
| 188 |
</table> |
| 189 |
</div> |
| 190 |
</div> |
| 191 |
|
| 192 |
<div role="tabpanel" class="tab-pane" id="fines"> |
| 193 |
<span class="patron-title"></span> has <span class="fine-amount">0</span> in fines. If you would like you can record payments. |
| 194 |
<fieldset><legend>Pay fines</legend> |
| 195 |
<label for="pay-fine-amount">Fine amount: </label><input type="text" name="pay-fine-amount" id="pay-fine-amount"/> |
| 196 |
<button id="pay-fine" class="submit">Pay fine</button> |
| 197 |
|
| 198 |
<table id="session-payments" style="display: none;"> |
| 199 |
<thead><tr><th>Amount</th><th>Date</th></tr></thead> |
| 200 |
<tbody></tbody> |
| 201 |
</table> |
| 202 |
</fieldset> |
| 203 |
</div> <!-- /# -->fines |
| 204 |
</div> <!-- /.tab-content --> |
| 205 |
</div> <!-- /#patronlists --> |
| 206 |
</div> |
| 207 |
</div> |
| 208 |
</main> |
| 209 |
|
| 210 |
</main> |
| 211 |
</div> <!-- /.col-sm-10.col-sm-push-2 --> |
| 212 |
|
| 213 |
<div class="offline-circulation" style="display: none;"> |
| 214 |
<div class="col-sm-2 col-sm-pull-10"> |
| 215 |
<aside> |
| 216 |
<div class="patroninfo"><h5 class="patron-title"> </h5> |
| 217 |
<ul> |
| 218 |
<li id="patron-address-1"></li> |
| 219 |
<li id="patron-address-2"></li> |
| 220 |
<li id="patron-address-parts"><!-- city, state, zipcode, country --></li> |
| 221 |
<li id="patron-phone"></li> |
| 222 |
<li id="patron-email"></li> |
| 223 |
<li id="patron-category"></li> |
| 224 |
<li id="patron-library"></li> |
| 225 |
</ul> |
| 226 |
</div> |
| 227 |
</aside> |
| 228 |
</div> <!-- /.col-sm-2.col-sm-pull-10 --> |
| 229 |
</div> <!-- /.row --> |
| 230 |
</div> |
| 231 |
|
| 232 |
[% MACRO jsinclude BLOCK %] |
| 233 |
[% INCLUDE 'calendar.inc' %] |
| 234 |
[% Asset.js("lib/jquery/plugins/jquery.indexeddb.js") | $raw %] |
| 235 |
[% Asset.js("js/offlinecirc.js") | $raw %] |
| 236 |
<script> |
| 237 |
var ALERT_SUCCESSFUL_CHECKIN = _("Checked in item."); |
| 238 |
var ALERT_MATERIALS = _("Note about the accompanying materials: %s"); |
| 239 |
var ALERT_RESTRICTED = _("Patron is RESTRICTED"); |
| 240 |
var ALERT_NO_MATCHING_ITEM = _("No item with barcode in offline database (transaction recorded anyway): %s"); |
| 241 |
var ALERT_NOT_CHECKED_OUT = _("Item not listed as checked out in offline database (transaction recorded anyway)"); |
| 242 |
var ALERT_ITEM_WITHDRAWN = _("Item has been withdrawn (transaction recorded anyway)"); |
| 243 |
var ALERT_ITEM_RESTRICTED = _("Item is restricted (transaction recorded anyway)"); |
| 244 |
var ALERT_ITEM_LOST = _("Item has been lost (transaction recorded anyway)"); |
| 245 |
var ALERT_NO_MATCHING_PATRON = _("No patron card number in offline database (proceeding anyway): %s"); |
| 246 |
var ALERT_PATRON_GONE_NO_ADDRESS = _("Patron's address is in doubt (proceeding anyway)"); |
| 247 |
var ALERT_PATRON_CARD_LOST = _("Patron's card is lost"); |
| 248 |
var ALERT_PATRON_EXPIRED = _("Patron's card is expired (%s)"); |
| 249 |
var ALERT_PATRON_BLOCKED_TEMPORARY = _("Patron has had overdue items and is restricted until: %s"); |
| 250 |
var ALERT_PATRON_RESTRICTED = _("Patron is restricted"); |
| 251 |
var ALERT_PATRON_FINE = _("Patron has outstanding fines: %s"); |
| 252 |
var ALERT_PATRON_FINE_OVER_LIMIT = _("Patron fines are over limit: %s"); |
| 253 |
var UPLOAD_PENDING_MESSAGE = _("You have transactions in the offline circulation database on this computer that have not been uploaded."); |
| 254 |
var NO_UPLOAD_PENDING_MESSAGE = _("You do not have any pending transactions in the offline circulation database on this computer."); |
| 255 |
|
| 256 |
var start; |
| 257 |
|
| 258 |
var dateformat = '[% IF ( dateformat_us ) %]mm/dd/yy[% ELSIF ( dateformat_metric ) %]dd/mm/yy[% ELSE %]yy-mm-dd[% END %]'; |
| 259 |
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 %]; |
| 260 |
var flatpickr_timeformat_string = [% IF Koha.Preference('TimeFormat') == '12hr' %]"G:i K"[% ELSE %]"H:i"[% END %]; |
| 261 |
var flatpickr_timestamp_string = "Y-m-d H:i"; |
| 262 |
var flatpickr_datetime_string = flatpickr_dateformat_string + " " + flatpickr_timeformat_string; |
| 263 |
|
| 264 |
function checkin(barcode, item, error) { |
| 265 |
var alerts = checkAlerts(barcode, item); |
| 266 |
if (typeof item === 'undefined') { |
| 267 |
item = { }; |
| 268 |
} |
| 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(), |
| 277 |
"barcode" : barcode, |
| 278 |
"action" : "return" |
| 279 |
}; |
| 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'); |
| 293 |
} |
| 294 |
} else { |
| 295 |
$('#alerts').append('<div class="dialog"><h3>' + ALERT_SUCCESSFUL_CHECKIN + '</h3></div>'); |
| 296 |
} |
| 297 |
}); |
| 298 |
setTimeout(function() { $('#checkin-barcode').trigger('focus'), 1 }); |
| 299 |
} |
| 300 |
|
| 301 |
function checkAlerts(barcode, item) { |
| 302 |
var alerts = []; |
| 303 |
if (typeof item === 'undefined') { |
| 304 |
alerts.push(ALERT_NO_MATCHING_ITEM.format(barcode)); |
| 305 |
} else { |
| 306 |
if (typeof item.materials !== 'undefined' && item.materials != null) { |
| 307 |
alerts.push(ALERT_MATERIALS.format(item.materials)); |
| 308 |
} |
| 309 |
} |
| 310 |
return alerts; |
| 311 |
} |
| 312 |
|
| 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) { |
| 318 |
if (val) { |
| 319 |
$('#upload-message').text(UPLOAD_PENDING_MESSAGE); |
| 320 |
} else { |
| 321 |
$('#upload-message').text(NO_UPLOAD_PENDING_MESSAGE); |
| 322 |
} |
| 323 |
}); |
| 324 |
} |
| 325 |
|
| 326 |
function synchronize() { |
| 327 |
kohadb.saveSetting("userid", "[% logged_in_user.userid | html %]"); |
| 328 |
kohadb.saveSetting("branchcode", "[% Branches.GetLoggedInBranchcode | html %]"); |
| 329 |
showSyncInfo(); |
| 330 |
[% UNLESS (AllowOfflineCirculation) %] |
| 331 |
reloadRecords(); |
| 332 |
[% END %] |
| 333 |
showSyncInfo(); |
| 334 |
$('#download-records').click(reloadRecords); |
| 335 |
$('#upload-transactions').click(function () { |
| 336 |
$('.loading-overlay div').text(_("Uploading transactions, please wait...")); |
| 337 |
$('.loading-overlay').show(); |
| 338 |
$.ajax({ |
| 339 |
type: "GET", |
| 340 |
url: "/cgi-bin/koha/offline_circ/service.pl", |
| 341 |
}).done(function (data) { |
| 342 |
if (data) { |
| 343 |
$('.loading-overlay').hide(); |
| 344 |
alert(_("Please log in to Koha and try again. (Error: '%s')").format(data)); |
| 345 |
} else { |
| 346 |
var uploadIter = $.indexedDB("koha").objectStore("transactions").each(uploadTransaction); |
| 347 |
uploadIter.done(function() { |
| 348 |
$.indexedDB("koha").transaction(["transactions"]).then(function(){ |
| 349 |
}, function(err, e){ |
| 350 |
}, function(transaction){ |
| 351 |
transaction.objectStore("transactions").clear(); |
| 352 |
}); |
| 353 |
$('.loading-overlay').hide(); |
| 354 |
kohadb.saveSetting("dirty", false); |
| 355 |
$('#upload-message').text(NO_UPLOAD_PENDING_MESSAGE); |
| 356 |
}); |
| 357 |
} |
| 358 |
}); |
| 359 |
}); |
| 360 |
|
| 361 |
} |
| 362 |
|
| 363 |
function fPformatTimeStamp( timestamp ){ |
| 364 |
var datetimeObj = flatpickr.parseDate( timestamp, flatpickr_timestamp_string ); |
| 365 |
return flatpickr.formatDate( datetimeObj, flatpickr_datetime_string ); |
| 366 |
} |
| 367 |
|
| 368 |
function showTimestamp(key, value) { |
| 369 |
if (typeof value !== 'undefined') { |
| 370 |
var ts = new Date(value); |
| 371 |
$('#' + key).text( fPformatTimeStamp( ts ) + ' ' + ts.toTimeString()); |
| 372 |
} else { |
| 373 |
$('#' + key).text(_("(never)")); |
| 374 |
} |
| 375 |
} |
| 376 |
|
| 377 |
function reloadRecords(ev) { |
| 378 |
$(".loading-overlay div").text(_("Loading records, please wait...")); |
| 379 |
$(".loading-overlay").show(); |
| 380 |
start = new Date(); |
| 381 |
$.indexedDB("koha").transaction(["patrons", "items", "issues"]).then(function(){ |
| 382 |
loadRecords(0); |
| 383 |
}, function(err, e){ |
| 384 |
}, function(transaction){ |
| 385 |
transaction.objectStore("patrons").clear(); |
| 386 |
transaction.objectStore("items").clear(); |
| 387 |
transaction.objectStore("issues").clear(); |
| 388 |
}); |
| 389 |
if (typeof ev !== 'undefined') { |
| 390 |
ev.stopPropagation(); |
| 391 |
} |
| 392 |
} |
| 393 |
|
| 394 |
function uploadTransaction(transaction) { |
| 395 |
$.ajax({ |
| 396 |
type: "POST", |
| 397 |
url: "/cgi-bin/koha/offline_circ/service.pl", |
| 398 |
data: { "userid" : kohadb.settings.userid, |
| 399 |
"branchcode" : kohadb.settings.branchcode, |
| 400 |
"timestamp" : transaction.value.timestamp, |
| 401 |
"action" : transaction.value.action, |
| 402 |
"barcode" : transaction.value.barcode, |
| 403 |
"cardnumber" : transaction.value.cardnumber, |
| 404 |
"amount" : transaction.value.amount, |
| 405 |
"pending" : true, |
| 406 |
}, |
| 407 |
}); |
| 408 |
return undefined, true; |
| 409 |
} |
| 410 |
|
| 411 |
function finishedLoading() { |
| 412 |
kohadb.saveSetting('item-timestamp', start.toISOString()) |
| 413 |
kohadb.saveSetting('patron-timestamp', start.toISOString()) |
| 414 |
kohadb.saveSetting('issue-timestamp', start.toISOString()) |
| 415 |
showTimestamp('item-timestamp', start.toISOString()); |
| 416 |
showTimestamp('patron-timestamp', start.toISOString()); |
| 417 |
showTimestamp('issue-timestamp', start.toISOString()); |
| 418 |
$(".loading-overlay").hide(); |
| 419 |
} |
| 420 |
|
| 421 |
function loadRecords(page) { |
| 422 |
[% IF (AllowOfflineCirculation) %] |
| 423 |
$(".loading-overlay div").text(_("Loading page %s, please wait...").format(page)); |
| 424 |
$(".loading-overlay").show(); |
| 425 |
$.ajax({ |
| 426 |
type: "GET", |
| 427 |
url: "/cgi-bin/koha/offline_circ/download.pl", |
| 428 |
data: { "data": "all", |
| 429 |
"page": page |
| 430 |
}, |
| 431 |
dataType: "json", |
| 432 |
}).done(function (data) { |
| 433 |
$.indexedDB("koha").transaction(["patrons", "items", "issues"]).then(function(){ |
| 434 |
if (data.finished) { |
| 435 |
finishedLoading(); |
| 436 |
} else { |
| 437 |
setTimeout(function () { loadRecords(page + 1); }, 200); |
| 438 |
} |
| 439 |
}, function(err, e){ |
| 440 |
}, function(transaction){ |
| 441 |
if (data.patrons) { |
| 442 |
var patrons = transaction.objectStore("patrons"); |
| 443 |
$.each(data.patrons, function () { |
| 444 |
patrons.put(this); |
| 445 |
}); |
| 446 |
} |
| 447 |
if (data.items) { |
| 448 |
var items = transaction.objectStore("items"); |
| 449 |
$.each(data.items, function () { |
| 450 |
items.put(this); |
| 451 |
}); |
| 452 |
} |
| 453 |
if (data.issues) { |
| 454 |
var issues = transaction.objectStore("issues"); |
| 455 |
$.each(data.issues, function () { |
| 456 |
issues.put(this); |
| 457 |
}); |
| 458 |
} |
| 459 |
}); |
| 460 |
}); |
| 461 |
[% END %] |
| 462 |
} |
| 463 |
|
| 464 |
function loadPatron(barcode) { |
| 465 |
$('#oldissues').hide(); |
| 466 |
$('#session-issues').hide(); |
| 467 |
$('#issuest tbody').empty(); |
| 468 |
$('#session-payments').hide(); |
| 469 |
$('.checkout-count').text(0); |
| 470 |
$.indexedDB("koha").transaction(["patrons", "issues"]).then(function() { |
| 471 |
}, function(err, e){ |
| 472 |
}, function(transaction){ |
| 473 |
var patrons = transaction.objectStore("patrons"); |
| 474 |
patrons.get(barcode).done(function (patron, error) { |
| 475 |
showPatron(barcode, patron, error); |
| 476 |
}); |
| 477 |
var issuesidx = transaction.objectStore("issues").index("cardnumber"); |
| 478 |
$('#oldissuest tbody').empty(); |
| 479 |
issuesidx.each(function (item) { |
| 480 |
$('#oldissues').show(); |
| 481 |
$('#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>"); |
| 482 |
$('.checkout-count').text(parseInt($('.checkout-count').text()) + 1); |
| 483 |
}, barcode); |
| 484 |
}); |
| 485 |
} |
| 486 |
|
| 487 |
function checkout(barcode, item, error) { |
| 488 |
var alerts = checkAlerts(barcode, item); |
| 489 |
if (typeof item === 'undefined') { |
| 490 |
item = { }; |
| 491 |
} |
| 492 |
item.title = item.title || ""; |
| 493 |
item.author = item.author || ""; |
| 494 |
item.homebranch = item.homebranch || ""; |
| 495 |
item.holdingbranch = item.holdingbranch || ""; |
| 496 |
item.callnumber = item.callnumber || ""; |
| 497 |
item.itemtype = item.itemtype || ""; |
| 498 |
if ($('#duedatespec').val().length === 0) { |
| 499 |
alert(_("You must set a due date in order to use offline circulation!")); |
| 500 |
setTimeout(function() { $('#duedatespec').trigger('focus'), 1 }); |
| 501 |
return; |
| 502 |
} |
| 503 |
var date_due = flatpickr.parseDate( $('#duedatespec').val(), flatpickr_datetime_string ); |
| 504 |
var trans = { "timestamp" : new Date().toMySQLString(), |
| 505 |
"barcode" : barcode, |
| 506 |
"cardnumber" : curpatron.cardnumber, |
| 507 |
"date_due" : date_due.toMySQLString(), |
| 508 |
"action" : "issue" |
| 509 |
}; |
| 510 |
$('#alerts').empty(); |
| 511 |
kohadb.recordTransaction(trans, function () { |
| 512 |
$('#session-issues').show(); |
| 513 |
$('#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>'); |
| 514 |
$('.checkout-count').text(parseInt($('.checkout-count').text()) + 1); |
| 515 |
if (alerts.length > 0) { |
| 516 |
$('#alerts').append('<div class="dialog alert"><h3>' + _("Check out message") + '</h3></div>'); |
| 517 |
for (var msg in alerts) { |
| 518 |
$('#alerts .dialog').append('<p>' + alerts[msg] + '</p'); |
| 519 |
} |
| 520 |
} |
| 521 |
$('#checkout-barcode').val(''); |
| 522 |
}); |
| 523 |
} |
| 524 |
|
| 525 |
function recordFine(amount) { |
| 526 |
var timestamp = new Date() |
| 527 |
var trans = { "timestamp" : timestamp.toMySQLString(), |
| 528 |
"cardnumber" : curpatron.cardnumber, |
| 529 |
"amount" : amount, |
| 530 |
"action" : "payment", |
| 531 |
}; |
| 532 |
kohadb.recordTransaction(trans, function () { |
| 533 |
$('#session-payments').show(); |
| 534 |
$('#session-payments tbody').prepend('<tr><td>' + amount + '</td><td>' + fPformatTimeStamp( timestamp ) + '</td></tr>'); |
| 535 |
$('.fine-amount').text(parseInt($('.fine-amount').text()) - amount); |
| 536 |
}); |
| 537 |
} |
| 538 |
|
| 539 |
function checkPatronAlerts(cardnumber, patron) { |
| 540 |
var alerts = []; |
| 541 |
if (typeof patron === 'undefined') { |
| 542 |
alerts.push(ALERT_NO_MATCHING_PATRON.format(cardnumber)); |
| 543 |
} else { |
| 544 |
if (patron.gonenoaddress !== '0') { |
| 545 |
alerts.push(ALERT_PATRON_GONE_NO_ADDRESS); |
| 546 |
} |
| 547 |
if (patron.lost !== '0') { |
| 548 |
alerts.push(ALERT_PATRON_CARD_LOST); |
| 549 |
} |
| 550 |
if (patron.debarred !== null) { |
| 551 |
if (patron.debarred != '9999-12-31') { |
| 552 |
alerts.push( ALERT_PATRON_BLOCKED_TEMPORARY.format( flatpickr.formatDate( new Date(patron.debarred), flatpickr_datetime_string ) ) ); |
| 553 |
} else { |
| 554 |
alerts.push(ALERT_PATRON_RESTRICTED); |
| 555 |
} |
| 556 |
} |
| 557 |
if (new Date(patron.dateexpiry) < new Date()) { |
| 558 |
alerts.push( ALERT_PATRON_EXPIRED.format( flatpickr.formatDate( new Date(patron.dateexpiry), flatpickr_datetime_string ) ) ); |
| 559 |
} |
| 560 |
if (parseInt(patron.fine) > [% maxoutstanding | html %]) { |
| 561 |
alerts.push(ALERT_PATRON_FINE_OVER_LIMIT.format(patron.fine)); |
| 562 |
} else if (parseInt(patron.fine) > 0) { |
| 563 |
alerts.push(ALERT_PATRON_FINE.format(patron.fine)); |
| 564 |
} |
| 565 |
} |
| 566 |
return alerts; |
| 567 |
} |
| 568 |
|
| 569 |
var curpatron; |
| 570 |
|
| 571 |
function showPatron(barcode, patron, error) { |
| 572 |
var alerts = checkPatronAlerts(barcode, patron); |
| 573 |
if (typeof patron === 'undefined') { |
| 574 |
patron = { }; |
| 575 |
} |
| 576 |
patron.surname = patron.surname || ""; |
| 577 |
patron.firstname = patron.firstname || ""; |
| 578 |
patron.othernames = patron.othernames || ""; |
| 579 |
patron.address = patron.address || ""; |
| 580 |
patron.address2 = patron.address2 || ""; |
| 581 |
patron.city = patron.city || ""; |
| 582 |
patron.state = patron.state || ""; |
| 583 |
patron.country = patron.country || ""; |
| 584 |
patron.zipcode = patron.zipcode || ""; |
| 585 |
patron.phone = patron.phone || ""; |
| 586 |
patron.mobile = patron.mobile || ""; |
| 587 |
patron.phonepro = patron.phonepro || ""; |
| 588 |
patron.email = patron.email || ""; |
| 589 |
patron.emailpro = patron.emailpro || ""; |
| 590 |
patron.categorycode = patron.categorycode || ""; |
| 591 |
patron.branchcode = patron.branchcode || ""; |
| 592 |
patron.cardnumber = barcode; |
| 593 |
patron.fine = patron.fine || "0"; |
| 594 |
|
| 595 |
patron.name = patron.firstname + (patron.othernames.length > 0 ? " (" + patron.othernames + ") " : " ") + patron.surname + " (" + barcode + ")"; |
| 596 |
if (patron.name.length > 0) { |
| 597 |
$('.patron-title').text(patron.name); |
| 598 |
} else { |
| 599 |
$('.patron-title').text(_("Unrecognized patron (%s)").format(barcode)); |
| 600 |
} |
| 601 |
if (patron.address.length > 0 || patron.address2.length > 0) { |
| 602 |
$('#patron-address-1').text(patron.address); |
| 603 |
$('#patron-address-2').text(patron.address2); |
| 604 |
} else { |
| 605 |
$('#patron-address-1').html('<span class="empty" id="noaddressstored">' + _("No address stored.") + '</span></li>'); |
| 606 |
$('#patron-address-2').text(''); |
| 607 |
} |
| 608 |
if (patron.city.length > 0) { |
| 609 |
$('#patron-address-parts').text(patron.city + (patron.state.length > 0 ? ", " + patron.state : "") + " " + patron.zipcode + (patron.country.length > 0 ? ", " + patron.country : "")); |
| 610 |
} else { |
| 611 |
$('#patron-address-parts').html('<span class="empty" id="nocitystored">' + _("No city stored.") + '</span></li>'); |
| 612 |
} |
| 613 |
if (patron.phone.length > 0 || patron.mobile.length > 0 || patron.phonepro.length > 0) { |
| 614 |
$('#patron-phone').text((patron.phone.length > 0 ? patron.phone : (patron.mobile.length > 0 ? patron.mobile : (patron.phonepro.length > 0 ? patron.phonepro : '')))); |
| 615 |
} else { |
| 616 |
$('#patron-phone').html('<span class="empty" id="nophonestored">' + _("No phone stored.") + '</span></li>'); |
| 617 |
} |
| 618 |
if (patron.email.length > 0 || patron.emailpro.length > 0) { |
| 619 |
$('#patron-email').text((patron.email.length > 0 ? patron.email : (patron.emailpro.length > 0 ? patron.emailpro : ""))); |
| 620 |
} else { |
| 621 |
$('#patron-email').html('<span class="empty" id="noemailstored">' + _("No email stored.") + '</span></li>'); |
| 622 |
} |
| 623 |
if (patron.categorycode.length > 0) { |
| 624 |
$('#patron-category').text(_("Category: %s").format(patron.categorycode)); |
| 625 |
} else { |
| 626 |
$('#patron-category').html('<span class="empty" id="unknowncategory">' + _("Category code unknown.") + '</span></li>'); |
| 627 |
} |
| 628 |
if (patron.branchcode.length > 0) { |
| 629 |
$('#patron-library').text(_("Home library: %s").format(patron.branchcode)); |
| 630 |
} else { |
| 631 |
$('#patron-library').html('<span class="empty" id="unknowncategory">' + _("Home library unknown.") + '</span></li>'); |
| 632 |
} |
| 633 |
$('.fine-amount').text(patron.fine); |
| 634 |
$('#alerts').empty(); |
| 635 |
if (alerts.length > 0) { |
| 636 |
$('#alerts').append('<div class="dialog alert"><h3>' + _("Check out message") + '</h3></div>'); |
| 637 |
for (var msg in alerts) { |
| 638 |
$('#alerts .dialog').append('<p>' + alerts[msg] + '</p>'); |
| 639 |
} |
| 640 |
} |
| 641 |
curpatron = patron; |
| 642 |
$('main').show(); |
| 643 |
setTimeout(function() { $('#checkout-barcode').trigger('focus'), 1 }); |
| 644 |
} |
| 645 |
|
| 646 |
// This next bit of code is to deal with the updated session issue |
| 647 |
if( typeof window.applicationCache !== "undefined" ){ |
| 648 |
window.addEventListener('load', function(e) { |
| 649 |
window.applicationCache.addEventListener('updateready', function(e) { |
| 650 |
if (window.applicationCache.status == window.applicationCache.UPDATEREADY) { |
| 651 |
// Browser downloaded a new app cache. |
| 652 |
// Swap it in and reload the page to get the new hotness. |
| 653 |
window.applicationCache.swapCache(); |
| 654 |
if (confirm(_("A new version of this site is available. Load it?"))) { |
| 655 |
window.location.reload(); |
| 656 |
} |
| 657 |
} else { |
| 658 |
// Manifest didn't changed. Nothing new to server. |
| 659 |
} |
| 660 |
}, false); |
| 661 |
}, false); |
| 662 |
} |
| 663 |
|
| 664 |
|
| 665 |
$(document).ready(function () { |
| 666 |
if( typeof window.applicationCache === "undefined" ){ |
| 667 |
$("#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>'); |
| 668 |
} else { |
| 669 |
kohadb.initialize(); |
| 670 |
} |
| 671 |
$('#header_search #circ_search .tip').text(_("Enter patron card number:")); |
| 672 |
|
| 673 |
$('ul[aria-labelledby="logged-in-menu"]').html('<li><a class="toplinks">' + _("You cannot change your branch or logout while using offline circulation") + '</a></li>'); |
| 674 |
|
| 675 |
// Returns code |
| 676 |
$('#checkin-form, #checkin_search form').submit(function (event) { |
| 677 |
event.preventDefault(); |
| 678 |
var barcode = $('input[name="barcode"]', this).val(); |
| 679 |
$('input[name="barcode"]', this).val(''); |
| 680 |
$.indexedDB("koha").transaction(["items"]).then(function() { |
| 681 |
}, function(err, e){ |
| 682 |
}, function(transaction){ |
| 683 |
var items = transaction.objectStore("items"); |
| 684 |
items.get(barcode).done(function (item, error) { |
| 685 |
checkin(barcode, item, error); |
| 686 |
}); |
| 687 |
}); |
| 688 |
}); |
| 689 |
|
| 690 |
$('#go-to-home').click(function () { |
| 691 |
$('#alerts').empty(); |
| 692 |
$('.offline-sync').hide(); |
| 693 |
$('.offline-circulation').hide(); |
| 694 |
$('.offline-returns').hide(); |
| 695 |
$('.offline-circulation-instructions').hide(); |
| 696 |
$('.offline-home').show(); |
| 697 |
}); |
| 698 |
|
| 699 |
$('#go-to-returns').click(function () { |
| 700 |
$('#alerts').empty(); |
| 701 |
$('.offline-home').hide(); |
| 702 |
$('.offline-sync').hide(); |
| 703 |
$('.offline-circulation').hide(); |
| 704 |
$('.offline-circulation-instructions').hide(); |
| 705 |
$('.offline-returns').show(); |
| 706 |
setTimeout(function() { $('#checkin-form input[name="barcode"]').trigger('focus'), 1 }); |
| 707 |
}); |
| 708 |
|
| 709 |
$('#go-to-circ').click(function () { |
| 710 |
$('#alerts').empty(); |
| 711 |
$('.offline-home').hide(); |
| 712 |
$('.offline-sync').hide(); |
| 713 |
$('.offline-returns').hide(); |
| 714 |
$('.offline-circulation').hide(); |
| 715 |
$('.offline-circulation-instructions').show(); |
| 716 |
$('#header_search').selectTabByID("#circ_search"); |
| 717 |
setTimeout(function() { $('#circ_search input[name="findborrower"]').trigger('focus'), 1 }); |
| 718 |
}); |
| 719 |
|
| 720 |
$('#go-to-sync').click(function () { |
| 721 |
$('#alerts').empty(); |
| 722 |
showSyncInfo(); |
| 723 |
$.ajax({ |
| 724 |
type: "GET", |
| 725 |
url: "/cgi-bin/koha/offline_circ/list.pl", |
| 726 |
success: function () { |
| 727 |
$('.offline-home').hide(); |
| 728 |
$('.offline-returns').hide(); |
| 729 |
$('.offline-circulation').hide(); |
| 730 |
$('.offline-circulation-instructions').hide(); |
| 731 |
$('.offline-sync').show(); |
| 732 |
synchronize(); |
| 733 |
}, |
| 734 |
error: function () { |
| 735 |
alert(_("You are offline and therefore cannot sync your database")); |
| 736 |
} |
| 737 |
}); |
| 738 |
}); |
| 739 |
|
| 740 |
$('#go-to-pending').click(function (ev) { |
| 741 |
$('#alerts').empty(); |
| 742 |
ev.preventDefault(); |
| 743 |
$.ajax({ |
| 744 |
type: "GET", |
| 745 |
url: "/cgi-bin/koha/offline_circ/list.pl", |
| 746 |
success: function () { |
| 747 |
window.location = '/cgi-bin/koha/offline_circ/list.pl'; |
| 748 |
}, |
| 749 |
error: function () { |
| 750 |
alert(_("You are offline and therefore cannot process pending operations")); |
| 751 |
} |
| 752 |
}); |
| 753 |
}); |
| 754 |
|
| 755 |
$('#patronsearch').submit(function (event) { |
| 756 |
event.preventDefault(); |
| 757 |
loadPatron($('#findborrower').val()); |
| 758 |
$('.offline-home').hide(); |
| 759 |
$('.offline-returns').hide(); |
| 760 |
$('.offline-sync').hide(); |
| 761 |
$('.offline-circulation-instructions').hide(); |
| 762 |
$('.offline-circulation').show(); |
| 763 |
$('#findborrower').val(''); |
| 764 |
setTimeout(function() { $('#checkout-barcode').trigger('focus'), 1 }); |
| 765 |
}); |
| 766 |
|
| 767 |
$('#pay-fine').click(function (event) { |
| 768 |
event.preventDefault(); |
| 769 |
recordFine($('#pay-fine-amount').val()); |
| 770 |
}); |
| 771 |
|
| 772 |
$('#mainform').submit(function (event) { |
| 773 |
event.preventDefault(); |
| 774 |
var barcode = $('#checkout-barcode').val(); |
| 775 |
$.indexedDB("koha").transaction(["items"]).then(function() { |
| 776 |
}, function(err, e){ |
| 777 |
}, function(transaction){ |
| 778 |
var items = transaction.objectStore("items"); |
| 779 |
items.get(barcode).done(function (item, error) { |
| 780 |
checkout(barcode, item, error); |
| 781 |
}); |
| 782 |
}); |
| 783 |
}); |
| 784 |
}); |
| 785 |
</script> |
| 786 |
[% END %] |
| 787 |
|
| 788 |
[% INCLUDE 'intranet-bottom.inc' %] |