From 7c00ef8c0d674ffa29971133b4d44ddc65ead456 Mon Sep 17 00:00:00 2001 From: Llewellyn Marshall Date: Mon, 8 Aug 2022 14:39:50 -0400 Subject: [PATCH] LP1983991 Allow display of source address and source location on transit slips Added source address and source location information to transit slip & hold transit slip print template documentation. Signed-off-by: Llewellyn Marshall Signed-off-by: Terran McCanna Signed-off-by: Jane Sandberg --- .../share/print_templates/t_hold_transit_slip.tt2 | 7 +++ .../staff/share/print_templates/t_transit_slip.tt2 | 7 +++ .../js/ui/default/staff/admin/workstation/app.js | 2 + .../web/js/ui/default/staff/circ/services/circ.js | 58 +++++++++++++++++++--- 4 files changed, 68 insertions(+), 6 deletions(-) diff --git a/Open-ILS/src/templates/staff/share/print_templates/t_hold_transit_slip.tt2 b/Open-ILS/src/templates/staff/share/print_templates/t_hold_transit_slip.tt2 index 787c91c0d6..7690302540 100644 --- a/Open-ILS/src/templates/staff/share/print_templates/t_hold_transit_slip.tt2 +++ b/Open-ILS/src/templates/staff/share/print_templates/t_hold_transit_slip.tt2 @@ -9,6 +9,13 @@ Template for printing hold transit slips. Fields include: * dest_address.state * dest_address.post_code * dest_courier_code - from lib.courier_code library setting +* source_location.name - name of source library +* source_location.shortname +* source_address.street1 +* source_address.street2 +* source_address.city +* source_address.state +* source_address.post_code * hold.behind_desk * copy.barcode * copy.status.name - Copy status diff --git a/Open-ILS/src/templates/staff/share/print_templates/t_transit_slip.tt2 b/Open-ILS/src/templates/staff/share/print_templates/t_transit_slip.tt2 index 852d75a6f1..a27585cfd0 100644 --- a/Open-ILS/src/templates/staff/share/print_templates/t_transit_slip.tt2 +++ b/Open-ILS/src/templates/staff/share/print_templates/t_transit_slip.tt2 @@ -9,6 +9,13 @@ Template for printing a transit slip. Fields include: * dest_address.state * dest_address.post_code * dest_courier_code - from lib.courier_code library setting +* source_location.name - name of source library +* source_location.shortname +* source_address.street1 +* source_address.street2 +* source_address.city +* source_address.state +* source_address.post_code * copy.barcode * copy.status.name - Copy status * title diff --git a/Open-ILS/web/js/ui/default/staff/admin/workstation/app.js b/Open-ILS/web/js/ui/default/staff/admin/workstation/app.js index 29d880d4a2..d928ad89d8 100644 --- a/Open-ILS/web/js/ui/default/staff/admin/workstation/app.js +++ b/Open-ILS/web/js/ui/default/staff/admin/workstation/app.js @@ -653,6 +653,8 @@ function($scope , $q , egCore , ngToast) { dest_location : egCore.idl.toHash(egCore.org.get(egCore.auth.user().ws_ou())), dest_courier_code : 'ABC 123', dest_address : seed_addr, + source_address : seed_addr, + source_location : egCore.idl.toHash(egCore.org.get(egCore.auth.user().ws_ou())), hold : one_hold, holds : [ { diff --git a/Open-ILS/web/js/ui/default/staff/circ/services/circ.js b/Open-ILS/web/js/ui/default/staff/circ/services/circ.js index c328cab701..a73cae2962 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/services/circ.js +++ b/Open-ILS/web/js/ui/default/staff/circ/services/circ.js @@ -712,6 +712,19 @@ function($uibModal , $q , egCore , egAlertDialog , egConfirmDialog, egAddCopyAl return egCore.env.aoa.map[addr_id]; }); } + + //retrieve addresses from multiple org units + service.cache_org_addr = function (org_ids, addr_type) { + var addr_ids = []; + org_ids.forEach(function(org_id){ + var org = egCore.org.get(org_id); + var addr_id = org[addr_type](); + if(addr_id)addr_ids.push(addr_id); + }); + return egCore.pcrud.search('aoa', {id: addr_ids},{},{ atomic: true}).then(function(addrs) { + return egCore.env.absorbList(addrs, 'aoa'); + }); + } service.exit_alert = function(msg, scope) { return egAlertDialog.open(msg, scope).result.then( @@ -1767,20 +1780,48 @@ function($uibModal , $q , egCore , egAlertDialog , egConfirmDialog, egAddCopyAl } } - // collect transit, address, and hold info that's not already + // collect transit, addresses, and hold info that's not already // included in responses. service.collect_route_data = function(tmpl, evt, params, options) { if (angular.isArray(evt)) evt = evt[0]; var promises = []; var data = {}; - + var addr_deferred = $q.defer(); + // associates org units with the address they're needed for + var addr_orgs = {}; + promises.push(addr_deferred.promise); + if (evt.org && !tmpl.match(/hold_shelf/)) { - promises.push( - service.get_org_addr(evt.org, 'holds_address') - .then(function(addr) { data.address = addr }) - ); + addr_orgs['address'] = evt.org; } + + if(evt.payload.transit){ + addr_orgs['source_address'] = evt.payload.transit.source().id(); + } + if(Object.keys(addr_orgs).length){ + promises.push( + service.cache_org_addr(Object.values(addr_orgs),'holds_address') + .then(function(){ + // promise to assign all of the addresses we need + var addr_promises = []; + Object.keys(addr_orgs).forEach(function(key){ + addr_promises.push( + service.get_org_addr(addr_orgs[key], 'holds_address') + .then(function(addr) { + // assign address to field in data + data[key] = addr; + }) + ) + }); + $q.all(addr_promises).then(addr_deferred.resolve()); + })); + } + else{ + // no addresses are needed so continue + addr_deferred.resolve(); + } + if (evt.payload.hold) { promises.push( egCore.pcrud.retrieve('au', @@ -1849,8 +1890,13 @@ function($uibModal , $q , egCore , egAlertDialog , egConfirmDialog, egAddCopyAl if (data.address) { print_context.dest_address = egCore.idl.toHash(data.address); } + if (data.source_address) { + print_context.source_address = egCore.idl.toHash(data.source_address); + } print_context.dest_location = egCore.idl.toHash(egCore.org.get(data.transit.dest())); + print_context.source_location = + egCore.idl.toHash(egCore.org.get(data.transit.source())); print_context.copy.status = egCore.idl.toHash(print_context.copy.status); } -- 2.11.0