var itemsOutCirc = [];
var itemsOutMod = [];
var itemsOutCopy = [];
-var currentItemsOut = [];
var readyHolds = false;
// Rest on the Thank You page this many ms.
// Patron barcode via cgi param. Mainly used for debugging and
// only works if password is not required by policy
- this.loginPatron(this.cgi.param('patron'));
+ this.loginPatron(this.cgi.param('patron'), this.cgi.param('password'));
} else {
this.drawLoginPage();
var self = selfCheckMgr;
var row = self.outTemplate.cloneNode(true);
- if(circs.length) {
- for(circ = 0; circ < circs.length; circ++) {
- var row = self.outTemplate.cloneNode(true);
- currentItemsOut.push(circs[circ]);
- self.byName(row,'barcode').innerHTML = circs[circ].copy.barcode();
- self.byName(row, 'title').innerHTML = circs[circ].record.title();
- self.byName(row, 'author').innerHTML = circs[circ].record.author();
- self.byName(row, 'remaining_renewals').innerHTML = circs[circ].circ.renewal_remaining();
-
- if(dojo.date.stamp.fromISOString(circs[circ].circ.due_date()) < (new Date()))
- self.byName(row,'due_date').style.color="red";
-
- self.byName(row,'due_date').innerHTML = dojo.date.locale.format(
- dojo.date.stamp.fromISOString(circs[circ].circ.due_date()),
- {selector: 'date', fullYear: true}
- );
- if(circs[circ].circ.renewal_remaining() < 1) {
- self.byName(row, 'renew_selector').checked = false;
- self.byName(row, 'renew_selector').setAttribute('disabled', true);
- }
- self.byName(row,'format').innerHTML = circs[circ].record.types_of_resource()[0];
- self.itemsOutTbody.appendChild(row);
- }
- }
+ 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();
+ 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();
+
+ if(dojo.date.stamp.fromISOString(circ.circ.due_date()) < (new Date()))
+ self.byName(row,'due_date').style.color="red";
+
+ self.byName(row,'due_date').innerHTML = dojo.date.locale.format(
+ dojo.date.stamp.fromISOString(circ.circ.due_date()),
+ {selector: 'date', fullYear: true}
+ );
+ if(circ.circ.renewal_remaining() < 1) {
+ 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);
+ });
}
SelfCheckManager.prototype.goToTab = function(name) {
* Renew ticked checkbox items
*/
SelfCheckManager.prototype.renewItems = function() {
+ var self = this;
- var checkboxes = document.getElementsByClassName('oils-selfck-renewal-selector');
- var itemsToRenew = [];
- for(var checkbox = 0; checkbox < checkboxes.length; checkbox++) {
- if(checkboxes[checkbox].checked == true) {
- itemsToRenew.push(currentItemsOut[checkbox]);
- }
- checkboxes[checkbox].checked = false;
- }
+ var rows = document.getElementsByClassName('oils-selfck-items-row');
+ var renew_count = 0;
+ var success_count = 0;
- for(var item = 0; item < itemsToRenew.length; item++) {
- this.renew(itemsToRenew[item].copy.barcode())
- }
+ dojo.forEach(rows, function(row) {
+ var checkbox = self.byName(row, 'renew_selector');
+ if (!checkbox.checked) return;
+
+ renew_count++;
+ checkbox.checked = false; // de-select all
+
+ var stat = self.renew(row.getAttribute('copy_barcode'), false, true);
+ if (stat.success) success_count++;
+ });
this.drawCircPage();
+
+ // 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');
+ }
}
}
}
-SelfCheckManager.prototype.handleXactResult = function(action, item, result) {
+SelfCheckManager.prototype.handleXactResult = function(action, item, result, isBatch) {
var displayText = '';
// If true, the display message is important enough to pop up. Whether or not
var overrideEvents = this.orgSettings[SET_AUTO_OVERRIDE_EVENTS];
var blockStatuses = this.orgSettings[SET_BLOCK_CHECKOUT_ON_COPY_STATUS];
result.payload = payload;
+ var success = false;
if(result.textcode == 'NO_SESSION') {
this.displayCheckout(result, 'renew');
}
+ success = true;
this.checkouts.push({circ : result.payload.circ.id()});
sound = 'checkout-success';
this.updateScanBox();
}
}
- this.handleAlert(displayText, popup, sound);
- return {};
+ // avoid per-item notifications in batch mode.
+ if (!isBatch) this.handleAlert(displayText, popup, sound);
+ return {success : success};
}
/**
* Renew an item
*/
-SelfCheckManager.prototype.renew = function(barcode, override) {
+SelfCheckManager.prototype.renew = function(barcode, override, isBatch) {
var method = 'open-ils.circ.renew';
if(override) method += '.override';
]}
);
- var stat = this.handleXactResult('renew', barcode, result);
+ var stat = this.handleXactResult('renew', barcode, result, isBatch);
+
+ if (stat.override)
+ return this.renew(barcode, true, isBatch);
- if(stat.override)
- this.renew(barcode, true);
+ return stat;
}
/**