From b287eedbf97e5ed0aa85c52cf194e826a80f4012 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 5 Apr 2017 16:58:53 -0400 Subject: [PATCH] LP#1680110 Webstaff circ.staff_client.receipt.* AOUS support Support fetching and adding server-configured strings to print receipts scope so they can be added to receipts. Currently supported settings: circ.staff_client.receipt.alert_text circ.staff_client.receipt.event_text circ.staff_client.receipt.footer_text circ.staff_client.receipt.header_text circ.staff_client.receipt.notice_text Signed-off-by: Bill Erickson Signed-off-by: Lynn Floyd Signed-off-by: Kathy Lussier --- .../web/js/ui/default/staff/services/print.js | 45 +++++++++++++++---- 1 file changed, 37 insertions(+), 8 deletions(-) diff --git a/Open-ILS/web/js/ui/default/staff/services/print.js b/Open-ILS/web/js/ui/default/staff/services/print.js index 97f8333091..de6e7663d6 100644 --- a/Open-ILS/web/js/ui/default/staff/services/print.js +++ b/Open-ILS/web/js/ui/default/staff/services/print.js @@ -8,7 +8,16 @@ angular.module('egCoreMod') ['$q','$window','$timeout','$http','egHatch','egAuth','egIDL','egOrg','egEnv', function($q , $window , $timeout , $http , egHatch , egAuth , egIDL , egOrg , egEnv) { - var service = {}; + var service = { + include_settings : [ + 'circ.staff_client.receipt.alert_text', + 'circ.staff_client.receipt.event_text', + 'circ.staff_client.receipt.footer_text', + 'circ.staff_client.receipt.header_text', + 'circ.staff_client.receipt.notice_text' + ] + }; + service.template_base_path = 'share/print_templates/t_'; @@ -52,6 +61,26 @@ function($q , $window , $timeout , $http , egHatch , egAuth , egIDL , egOrg , eg scope.staff = egIDL.toHash(egAuth.user()); scope.current_location = egIDL.toHash(egOrg.get(egAuth.user().ws_ou())); + + return service.fetch_includes(scope); + } + + // Retrieve org settings for receipt includes and add them + // to the print scope under scope.includes. + service.fetch_includes = function(scope) { + // org settings for the workstation org are cached + // within egOrg. No need to cache them locally. + return egOrg.settings(service.include_settings).then( + + function(settings) { + scope.includes = {}; + angular.forEach(settings, function(val, key) { + // strip the settings prefix so you just have + // e.g. scope.includes.alert_text + scope.includes[key.split(/\./).pop()] = val; + }); + } + ); } service.last_print = {}; @@ -59,14 +88,14 @@ function($q , $window , $timeout , $http , egHatch , egAuth , egIDL , egOrg , eg // Template has been fetched (or no template needed) // Process the template and send the result off to the printer. service.print_content = function(args) { - service.fleshPrintScope(args.scope); + return service.fleshPrintScope(args.scope).then(function() { + var promise = egHatch.usePrinting() ? + service.print_via_hatch(args) : + service.print_via_browser(args); - var promise = egHatch.usePrinting() ? - service.print_via_hatch(args) : - service.print_via_browser(args); - - return promise['finally']( - function() { service.clear_print_content() }); + return promise['finally']( + function() { service.clear_print_content() }); + }); } service.print_via_hatch = function(args) { -- 2.43.2