// dict of org unit settings for "here"
this.orgSettings = {};
+ // true if we are exposing staff-only features (e.g. checkin)
+ this.staffMode = false;
+
// Construct a mock checkout for debugging purposes
if(this.mockCheckouts = this.cgi.param('mock-circ')) {
* Fetch the org-unit settings, initialize the display, etc.
*/
SelfCheckManager.prototype.init = function() {
+ var self = this;
this.setupStaffLogin();
this.loadOrgSettings();
+ // are we in staff mode?
+ new openils.User().getPermOrgList(['SELFCHECK_FULL_THROTTLE'],
+ function(orglist) {
+ if (orglist.length) {
+ self.staffMode = true;
+ openils.Util.show(
+ dojo.byId('oils-selfck-nav-checkin').parentNode,
+ 'inline'
+ );
+ }
+ }
+ );
+
this.circTbody = dojo.byId('oils-selfck-circ-tbody');
+ this.checkinTbody = dojo.byId('oils-selfck-checkin-tbody');
this.itemsOutTbody = dojo.byId('oils-selfck-circ-out-tbody');
+ this.itemsCheckinTbody = dojo.byId('oils-selfck-checkin-out-tbody');
// workstation is required but none provided
if(this.orgSettings[SET_WORKSTATION_REQUIRED] && !this.workstation) {
return;
}
- var self = this;
// connect onclick handlers to the various navigation links
var linkHandlers = {
'oils-selfck-hold-details-link' : function() { self.drawHoldsPage(); },
);
},
'oils-selfck-nav-home' : function() { self.drawCircPage(); },
+ 'oils-selfck-nav-checkin' : function() { self.drawCheckinPage(); },
'oils-selfck-nav-logout' : function() { self.logoutPatron(); },
'oils-selfck-nav-logout-print' : function() { self.logoutPatron(true); },
'oils-selfck-items-out-details-link' : function() { self.drawItemsOutPage(); },
}
}
+/**
+ * Sets up the checkin page
+ */
+SelfCheckManager.prototype.drawCheckinPage = function() {
+ openils.Util.show('oils-selfck-checkin-tbody', 'table-row-group');
+ this.goToTab('checkin');
+
+ while(this.itemsCheckinTbody.childNodes[0])
+ this.itemsCheckinTbody.removeChild(
+ this.itemsCheckinTbody.childNodes[0]);
+
+ if(!this.checkinTemplate) {
+ this.checkinTemplate =
+ this.checkinTbody.removeChild(
+ dojo.byId('oils-selfck-checkin-row'));
+ }
+
+ var self = this;
+ this.updateScanBox({
+ msg : 'Please enter an item barcode', // TODO i18n
+ handler : function(barcode) { self.checkin(barcode); }
+ });
+};
+
+
+SelfCheckManager.prototype.checkin = function(barcode) {
+ var self = this;
+
+ var checkinHandler = function(evt) {
+ if(!evt.length) evt = [evt];
+
+ for(var i = 0; i < evt.length; i++) {
+ var tc = evt.textcode;
+ console.log('checkin returned ' + tc);
+
+ switch (tc) {
+ case 'SUCCESS':
+ case 'NO_CHANGE':
+ continue;
+ break;
+ default:
+ self.handleAlert(
+ // TODO: i18n
+ 'Unhandled checkin event for "' +
+ barcode + '"\n' + evt.toString(),
+ true, 'checkin-failure'
+ );
+ }
+ }
+
+
+ // TODO checkin would be faster if these were
+ // not updated in real time w/ each checkin
+
+ // fines summary
+ self.updateFinesSummary();
+
+ // holds summary
+ self.updateHoldsSummary();
+
+ // items out summary
+ self.updateCircSummary();
+ };
+
+ this.checkinCopy({
+ barcode : barcode,
+ onload : checkinHandler
+ });
+};
+
SelfCheckManager.prototype.updateFinesSummary = function() {
var self = this;
openils.Util.hide('oils-selfck-payment-page');
openils.Util.hide('oils-selfck-holds-page');
openils.Util.hide('oils-selfck-circ-page');
+ openils.Util.hide('oils-selfck-checkin-page');
openils.Util.hide('oils-selfck-pay-fines-link');
switch(name) {
case 'checkout':
openils.Util.show('oils-selfck-circ-page');
break;
+ case 'checkin':
+ openils.Util.show('oils-selfck-checkin-page');
+ break;
case 'items_out':
openils.Util.show('oils-selfck-circ-page');
break;
);
}
-SelfCheckManager.prototype.checkin = function(barcode, abortTransit) {
-
- var resp = fieldmapper.standardRequest(
- ['open-ils.circ', 'open-ils.circ.transit.abort'],
- {params : [this.authtoken, {barcode : barcode}]}
+/** top-level checkin handler */
+SelfCheckManager.prototype.checkinCopy = function(args) {
+ fieldmapper.standardRequest(
+ ['open-ils.circ', 'open-ils.circ.checkin.override'],
+ { async : true,
+ params : [
+ this.authtoken, {
+ patron_id : this.patron.id(),
+ copy_barcode : args.barcode,
+ // TODO
+ // amnesty
+ // backdate
+ }
+ ],
+ oncomplete : function(r) {
+ var resp = openils.Util.readResponse(r, true);
+ args.onload(resp);
+ }
+ }
);
+};
- // resp == 1 on success
- if(openils.Event.parse(resp))
- return false;
+/** used for checkins required to fullfil a checkout */
+SelfCheckManager.prototype.inlineCheckinCopy = function(barcode, abortTransit) {
+
+ if (abortTransit) {
+ var resp = fieldmapper.standardRequest(
+ ['open-ils.circ', 'open-ils.circ.transit.abort'],
+ {params : [this.authtoken, {barcode : barcode}]}
+ );
+
+ // resp == 1 on success
+ if(openils.Event.parse(resp))
+ return false;
+ }
var resp = fieldmapper.standardRequest(
['open-ils.circ', 'open-ils.circ.checkin.override'],
]}
);
+ // TODO: staffMode : handle/report events better
+
if(!resp.length) resp = [resp];
for(var i = 0; i < resp.length; i++) {
var tc = openils.Event.parse(resp[i]).textcode;
overrideEvents && overrideEvents.length &&
overrideEvents.indexOf('COPY_STATUS_LOST') != -1) {
- if(this.checkin(item)) {
+ if(this.inlineCheckinCopy(item)) {
return { doOver : true };
}
}
if(result[i].textcode == 'COPY_IN_TRANSIT') {
// to override a transit, we have to abort the transit and check it in first
- if(this.checkin(item, true)) {
+ if(this.inlineCheckinCopy(item, true)) {
return { doOver : true };
} else {
override = false;