var selfckWarningTimer;
var selfCheckManager;
-var barcodesSeen = {};
-var scannedBarcode = 0;
+var seenBarcodes = {};
var selfCheckMgr;
var itemsOutCirc = [];
// Ignore duplicate barcode scans that happen within this many ms.
// Dupe scans that happen farther apart result in a patron warning.
-var dblScanWarnTimeout = 5000;
+var dblScanWarnTimeout = 2000;
const SET_BARCODE_REGEX = 'opac.barcode_regex';
const SET_PATRON_TIMEOUT = 'circ.selfcheck.patron_login_timeout';
this.updateScanBox({
msg : 'Please enter an item barcode', // TODO i18n
handler : function(barcode) {
- barcodesSeen[scannedBarcode] = barcode;
- var selfckScanbox = document.getElementById('selfckScanBox');
- if(barcodesSeen[scannedBarcode - 1] == barcode ){
- if(new Date().getTime() - timeScanned < dblScanWarnTimeout){
- console.log("Date: " + new Date().getTime());
- console.log("Time scanned: " + timeScanned);
- console.log(new Date().getTime() - timeScanned);
- var message = dojo.string.substitute(localeStrings.DOUBLE_SCAN, [barcode]);
- dojo.byId('oils-selfck-status-div').innerHTML = message;
- };
- selfckScanbox.value = '';
- selfckScanbox.focus();
- } else {
- scannedBarcode++;
- timeScanned = new Date().getTime();
- switchTo('step3');
- self.checkout(barcode);
- }
+
+ var curTime = new Date().getTime();
+ var prevScanTime = seenBarcodes[barcode];
+
+ if (prevScanTime) {
+ console.log('barcode previously scanned at ' +
+ prevScanTime + ' ; current time ' + curTime );
+
+ // This barcode has already been seen
+ var selfckScanbox = document.getElementById('selfckScanBox');
+
+ if (curTime - prevScanTime > dblScanWarnTimeout) {
+ // this barcode was scanned more than dblScanWarnTimeout
+ // milliseconds ago -- alert the patron.
+ dojo.byId('oils-selfck-status-div').innerHTML =
+ dojo.string.substitute(
+ localeStrings.DOUBLE_SCAN, [barcode]);
+ }
+
+ selfckScanbox.value = '';
+ selfckScanbox.focus();
+ } else {
+ seenBarcodes[barcode] = curTime;
+ switchTo('step3');
+ self.checkout(barcode);
+ }
}
});
SelfCheckManager.prototype.drawItemsOutPage = function() {
switchTo('step3','step3d');
dojo.byId('oils-selfck-status-div').innerHTML = ''; // reset notices
+ dojo.byId('scko-renewal-alerts').innerHTML = '';
// Reset items checked out in case it changed
this.circSummary = undefined;
dojo.forEach(circs, function(circ) {
var row = self.outTemplate.cloneNode(true);
- row.setAttribute('copy_barcode', circ.copy.barcode());
- self.byName(row,'barcode').innerHTML = circ.copy.barcode();
+ var barcode = circ.copy.barcode();
+ row.setAttribute('copy_barcode', barcode);
+
+ self.byName(row, 'barcode').innerHTML = barcode;
self.byName(row, 'title').innerHTML = circ.record.title();
self.byName(row, 'author').innerHTML = circ.record.author();
self.byName(row, 'remaining_renewals').innerHTML = circ.circ.renewal_remaining();
dojo.date.stamp.fromISOString(circ.circ.due_date()),
{selector: 'date', fullYear: true}
);
- if(circ.circ.renewal_remaining() < 1) {
+
+ // Disallow renewals of items with no renewals remaining or
+ // items that were already scanned in the current session.
+ if (circ.circ.renewal_remaining() < 1 || seenBarcodes[barcode]) {
self.byName(row, 'renew_selector').checked = false;
self.byName(row, 'renew_selector').setAttribute('disabled', true);
}
+
self.byName(row,'format').innerHTML = circ.record.types_of_resource()[0];
self.itemsOutTbody.appendChild(row);
});
renew_count++;
checkbox.checked = false; // de-select all
- var stat = self.renew(row.getAttribute('copy_barcode'), false, true);
- if (stat.success) success_count++;
+ var barcode = row.getAttribute('copy_barcode');
+ var stat = self.renew(barcode, false, true);
+
+ if (stat.success) {
+ // prevent any more renewal attempts (batch or scan) on this
+ // item by adding it to the list of already seen barcodes.
+ seenBarcodes[barcode] = new Date().getTime();
+ success_count++;
+ }
});
- this.drawCircPage();
+ //this.drawCircPage();
+ this.drawItemsOutPage();
// Display a generic success/failure batch renewal notification
- if (success_count == renew_count) {
- this.handleAlert(
- dojo.string.substitute(
- localeStrings.BATCH_RENEW_SUCCESS, [success_count]),
- false, 'checkout-success'
- );
-
- } else {
- this.handleAlert(
- dojo.string.substitute(
- localeStrings.BATCH_RENEW_FAILURE,
- [renew_count - success_count]
- ), true, 'checkout-failure');
+ // Renewal messages appear on the items-out page, not the checkouts
+ // page, so the message is manually inserted into the DOM instead
+ // of using the existing handleAlert message handling.
+ var msg = dojo.string.substitute(
+ localeStrings.BATCH_RENEW_SUCCESS, [success_count]);
+ var sound = 'checkout-success';
+
+ if (success_count < renew_count) {
+ msg = dojo.string.substitute(
+ localeStrings.BATCH_RENEW_FAILURE, [renew_count - success_count]);
+ sound = 'checkout-failure';
}
+
+ dojo.byId('scko-renewal-alerts').innerHTML = msg;
+ this.handleAlert('', false, sound);
}
} else if(action == 'renew') {
displayText = dojo.string.substitute(localeStrings.RENEW_SUCCESS, [item]);
- this.displayCheckout(result, 'renew');
+
+ // Avoid displaying batch renewal circs in the session circs
+ // page. The are displayed in session receipts and emails,
+ // though, so they get added to this.checkouts (below).
+ if (!isBatch) this.displayCheckout(result, 'renew');
}
success = true;
- this.checkouts.push({circ : result.payload.circ.id()});
sound = 'checkout-success';
+ this.checkouts.push({circ : result.payload.circ.id()});
this.updateScanBox();
} else if(result.textcode == 'OPEN_CIRCULATION_EXISTS' && action == 'checkout') {
*/
SelfCheckManager.prototype.logoutPatron = function(print, email) {
- var scannedBarcode = 0;
if(print && this.checkouts.length) {
progressDialog.show(true); // prevent patron from clicking logout link twice
this.printSessionReceipt(selfCheckManager.processLogout);