From aae6d9c03ed90ac5ff7ea8695a7f41fd3af749c0 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 7 Feb 2013 09:21:03 -0500 Subject: [PATCH] selfcheck staff mode : more slips / now with holds Signed-off-by: Bill Erickson --- Open-ILS/web/js/dojo/openils/circ/nls/selfcheck.js | 11 ++- .../web/js/ui/default/circ/selfcheck/selfcheck.js | 91 ++++++++++++++++++---- 2 files changed, 86 insertions(+), 16 deletions(-) diff --git a/Open-ILS/web/js/dojo/openils/circ/nls/selfcheck.js b/Open-ILS/web/js/dojo/openils/circ/nls/selfcheck.js index 5f30ae7165..1bc571c7d0 100644 --- a/Open-ILS/web/js/dojo/openils/circ/nls/selfcheck.js +++ b/Open-ILS/web/js/dojo/openils/circ/nls/selfcheck.js @@ -47,8 +47,13 @@ "CHECKIN_ROUTE_ITEM" : "Item ${0} should be routed to ${1}", "CHECKOUT_PROMPT" : "Please an item barcode to check out", "CHECKIN_PROMPT" : "Please an item barcode to check in", - "TRANSIT_RECEIPT" : "This item needs to be routed to ${0}:
${1}
"+ - "${2}

Barcode: ${3}
Title: ${4}
Author: ${5}"+ - "

Slip Date: ${6}
Printed by ${7} at ${8}" + "HOLD_SHELF" : "Hold Shelf", + "ROUTE_MSG" : "This item needs to be routed to ${0}:
", + "ORG_ADDRESS" : "${0}
${1}
", // name, address + "TRANSIT_SLIP" : "${0}${1}" + // shortname, address + "
Barcode: ${2}
Title: ${3}
Author: ${4}"+ + "
${5}
Slip Date: ${6}
Printed by ${7} at ${8}", + "HOLD_SLIP" : "
Hold for patron ${0}
Barcode: ${1}
" + + "Request Date: ${2}
" } diff --git a/Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js b/Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js index f5d0a905b1..51ffd8d370 100644 --- a/Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js +++ b/Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js @@ -1216,26 +1216,87 @@ SelfCheckManager.prototype.getOrgMailingAddress = function(orgId, callback) { }); } -SelfCheckManager.prototype.printTransitSlip = function(item, result, dest) { +SelfCheckManager.prototype.getUser = function(userId, callback) { + if (!userId || typeof userId == 'object') + callback(userId); + + var self = this; + var pcrud = new openils.PermaCrud(); + pcrud.retrieve('au', userId, { + flesh : 1, + flesh_fields : {au : ['card']}, + async : true, + oncomplete : function(r) { + callback(openils.Util.readResponse(r)); + } + }); +} + + +// hold transit slip +SelfCheckManager.prototype.printHoldTransitSlip = function(item, result, dest) { + var self = this; + var payload = result.payload; + var transit = payload.transit; + var hold = payload.hold; + + // in some cases, payload.patron is null even when there is a hold + this.getUser(hold.usr(), function(patron) { + + var holdMsg = dojo.string.substitute( + localeStrings.HOLD_SLIP, [ + // checkin could be for a different user than this.patron + openils.User.formalName(payload.patron), + patron.card().barcode(), + openils.Util.timeStamp(hold.request_time()) + ] + ); + + // now we have hold recipient info, + // continue with regular slip generation + self.printTransitSlip(item, result, dest, holdMsg); + }); +} + +// if this is a hold transit, holdMsg should contain the hold info +SelfCheckManager.prototype.printTransitSlip = + function(item, result, dest, holdMsg) { + var self = this; + var payload = result.payload; + var transit = payload.transit; + var hold = payload.hold; + holdMsg = holdMsg || ''; + + var routeMsg = dojo.string.substitute( + localeStrings.ROUTE_MSG, [dest.shortname()]); + // retrieve the address, then finish rendering the slip this.getOrgMailingAddress(dest.id(), function(addr) { + + var destAddr = dojo.string.substitute( + localeStrings.ORG_ADDRESS, [ + dest.name(), + dojo.string.substitute(localeStrings.ADDRESS, [ + addr.street1(), + addr.street2() || '', + addr.city(), + addr.state(), + addr.post_code() + ]) + ] + ); + self.printData( dojo.string.substitute( - localeStrings.TRANSIT_RECEIPT, [ - dest.shortname(), - dest.name(), - dojo.string.substitute(localeStrings.ADDRESS, [ - addr.street1(), - addr.street2() || '', - addr.city(), - addr.state(), - addr.post_code() - ]), + localeStrings.TRANSIT_SLIP, [ + routeMsg, + destAddr, item, result.payload.record.title(), result.payload.record.author(), - new Date().toString(), + holdMsg, + dojo.date.locale.format(new Date()), self.staff.usrname(), fieldmapper.aou.findOrgUnit(self.staff.ws_ou()).shortname() ] @@ -1281,7 +1342,11 @@ SelfCheckManager.prototype.handleCheckinResult = function(row, item, result) { this.displayCheckin(row, result, tc + ' => ' + dest.shortname()); - this.printTransitSlip(item, result, dest); + if (result.payload.hold) { + this.printHoldTransitSlip(item, result, dest); + } else { + this.printTransitSlip(item, result, dest); + } } else if (tc == 'ASSET_COPY_NOT_FOUND') { -- 2.11.0