webstaff: fix support of the disabled automatic print attempt type list
authorGalen Charlton <gmc@esilibrary.com>
Wed, 16 Nov 2016 05:34:06 +0000 (00:34 -0500)
committerGalen Charlton <gmc@esilibrary.com>
Wed, 16 Nov 2016 05:34:06 +0000 (00:34 -0500)
This patch ensures that the disabled automatic print attempt type list
setting is now honored. In addition, if bill payment receipts are
disabled via the setting, the "Receipt on Pay" and "# Copies" widgets
are not displayed on the bill payment page.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Open-ILS/src/templates/staff/circ/patron/t_bills.tt2
Open-ILS/web/js/ui/default/staff/circ/patron/bills.js
Open-ILS/web/js/ui/default/staff/circ/patron/checkout.js
Open-ILS/web/js/ui/default/staff/circ/services/circ.js

index 4378e32..fcf8012 100644 (file)
 <!-- pull-right is causing the content to flow several pixels 
 off to the right.  flex-row is honoring the boundaries better. 
 not sure what's up, there. -->
-<div class="flex-row">
+<div class="flex-row" ng-if="!disable_auto_print">
   <div class="flex-cell"></div>
   <form class="form-inline" role="form">
    <div class="checkbox">
index 37c2a18..7c869b3 100644 (file)
@@ -13,7 +13,7 @@ function($q , egCore , egWorkLog , patronSvc) {
     service.fetchBillSettings = function() {
         if (service.settings) return $q.when(service.settings);
         return egCore.org.settings(
-            ['ui.circ.billing.uncheck_bills_and_unfocus_payment_box','ui.circ.billing.amount_warn','ui.circ.billing.amount_limit']
+            ['ui.circ.billing.uncheck_bills_and_unfocus_payment_box','ui.circ.billing.amount_warn','ui.circ.billing.amount_limit','circ.staff_client.do_not_auto_attempt_print']
         ).then(function(s) {return service.settings = s});
     }
 
@@ -151,6 +151,7 @@ function($scope , $q , $routeParams , egCore , egConfirmDialog , $location,
     $scope.warn_amount = 1000;
     $scope.max_amount = 100000;
     $scope.amount_verified = false;
+    $scope.disable_auto_print = false;
 
     // pre-define list-returning funcs in case we access them
     // before the grid instantiates
@@ -303,7 +304,7 @@ function($scope , $q , $routeParams , egCore , egConfirmDialog , $location,
             $scope.payment_type, make_payments, note, $scope.check_number)
         .then(function(payment_ids) {
 
-            if ($scope.receipt_on_pay) {
+            if (!$scope.disable_auto_print && $scope.receipt_on_pay) {
                 printReceipt(
                     $scope.payment_type, payment_ids, make_payments, note);
             }
@@ -409,6 +410,11 @@ function($scope , $q , $routeParams , egCore , egConfirmDialog , $location,
         if (s['ui.circ.billing.amount_limit']) {
             $scope.max_amount = Number(s['ui.circ.billing.amount_limit']);
         }
+        if (s['circ.staff_client.do_not_auto_attempt_print'] && angular.isArray(s['circ.staff_client.do_not_auto_attempt_print'])) {
+            $scope.disable_auto_print = Boolean(
+                s['circ.staff_client.do_not_auto_attempt_print'].indexOf('Bill Pay') > -1
+            );
+        }
     });
 
     $scope.gridControls.allItemsRetrieved = function() {
index cf3c8f1..82d6e82 100644 (file)
@@ -76,7 +76,9 @@ function($scope , $q , $routeParams , egCore , egUser , patronSvc ,
         'circ.staff_client.do_not_auto_attempt_print'
     ]).then(function(settings) { 
         printOnComplete = !Boolean(
-            settings['circ.staff_client.do_not_auto_attempt_print']);
+            angular.isArray(settings['circ.staff_client.do_not_auto_attempt_print']) &&
+            (settings['circ.staff_client.do_not_auto_attempt_print'].indexOf('Checkout') > -1)
+        );
     });
 
     egCirc.get_noncat_types().then(function(list) {
index 753f54b..a2692ea 100644 (file)
@@ -13,16 +13,30 @@ function($uibModal , $q , egCore , egAlertDialog , egConfirmDialog,
     var service = {
         // auto-override these events after the first override
         auto_override_checkout_events : {},
-        require_initials : false
+        require_initials : false,
+        never_auto_print : {
+            hold_shelf_slip : false,
+            hold_transit_slip : false,
+            transit_slip : false
+        }
     };
 
     egCore.startup.go().finally(function() {
         egCore.org.settings([
             'ui.staff.require_initials.patron_standing_penalty',
             'ui.admin.work_log.max_entries',
-            'ui.admin.patron_log.max_entries'
+            'ui.admin.patron_log.max_entries',
+            'circ.staff_client.do_not_auto_attempt_print'
         ]).then(function(set) {
             service.require_initials = Boolean(set['ui.staff.require_initials.patron_standing_penalty']);
+            if (angular.isArray(set['circ.staff_client.do_not_auto_attempt_print'])) {
+                if (set['circ.staff_client.do_not_auto_attempt_print'].indexOf('Hold Slip') > 1)
+                    service.never_auto_print['hold_shelf_slip'] = true;
+                if (set['circ.staff_client.do_not_auto_attempt_print'].indexOf('Hold/Transit Slip') > 1)
+                    service.never_auto_print['hold_transit_slip'] = true;
+                if (set['circ.staff_client.do_not_auto_attempt_print'].indexOf('Transit Slip') > 1)
+                    service.never_auto_print['transit_slip'] = true;
+            }
         });
     });
 
@@ -1358,7 +1372,17 @@ function($uibModal , $q , egCore , egAlertDialog , egConfirmDialog,
 
         return service.collect_route_data(tmpl, evt, params, options)
         .then(function(data) {
-            
+
+            var template = data.transit ?
+                (data.patron ? 'hold_transit_slip' : 'transit_slip') :
+                'hold_shelf_slip';
+            if (service.never_auto_print[template]) {
+                // do not show the dialog or print if the
+                // disabled automatic print attempt type list includes
+                // the specified template
+                return;
+            }
+
             // All actions flow from the print data
 
             var print_context = {
@@ -1385,11 +1409,7 @@ function($uibModal , $q , egCore , egAlertDialog , egConfirmDialog,
             if (evt.payload.hold) sound += '.hold';
             egCore.audio.play(sound);
 
-            function print_transit() {
-                var template = data.transit ? 
-                    (data.patron ? 'hold_transit_slip' : 'transit_slip') :
-                    'hold_shelf_slip';
-
+            function print_transit(template) {
                 return egCore.print.print({
                     context : 'default', 
                     template : template, 
@@ -1400,7 +1420,7 @@ function($uibModal , $q , egCore , egAlertDialog , egConfirmDialog,
             // when auto-print is on, skip the dialog and go straight
             // to printing.
             if (options.auto_print_holds_transits) 
-                return print_transit();
+                return print_transit(template);
 
             return $uibModal.open({
                 templateUrl: tmpl,
@@ -1419,7 +1439,7 @@ function($uibModal , $q , egCore , egAlertDialog , egConfirmDialog,
 
                     $scope.print = function() { 
                         $uibModalInstance.close();
-                        print_transit();
+                        print_transit(template);
                     }
                 }]