From 2652801981e9505ac05dde0fc2129eb6bc3e1582 Mon Sep 17 00:00:00 2001 From: Billy Horn Date: Tue, 4 Oct 2016 14:45:30 -0700 Subject: [PATCH] LP#1621799: disable checkout for inactive patrons Add search_barcode variable to patronSvc Add function fetchedWithInactiveCard to patronSvc Add check to disable checkout for fetchedWithInactiveCard Signed-off-by: Billy Horn Signed-off-by: Kathy Lussier --- .../js/ui/default/staff/circ/patron/app.js | 29 ++++++++++--------- .../ui/default/staff/circ/patron/checkout.js | 3 +- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/Open-ILS/web/js/ui/default/staff/circ/patron/app.js b/Open-ILS/web/js/ui/default/staff/circ/patron/app.js index 350a48af9b..356bdfebe2 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/patron/app.js +++ b/Open-ILS/web/js/ui/default/staff/circ/patron/app.js @@ -230,7 +230,9 @@ function($q , $timeout , $location , egCore, egUser , $locale) { // event types manually overridden, which should always be // overridden for checkouts to this patron for this instance of // the interface. - checkout_overrides : {}, + checkout_overrides : {}, + //holds the searched barcode + search_barcode : null, }; // when we change the default patron, we need to clear out any @@ -248,7 +250,6 @@ function($q , $timeout , $location , egCore, egUser , $locale) { service.alertsShown = false; service.patronExpired = false; service.patronExpiresSoon = false; - service.retrievedWithInactive = false; service.invalidAddresses = false; } service.resetPatronLists(); // initialize @@ -417,7 +418,13 @@ function($q , $timeout , $location , egCore, egUser , $locale) { return $q.when(fail); } - + //resolves to true if the patron was fetched with an inactive card + service.fetchedWithInactiveCard = function() { + var bc = service.search_barcode + var cards = service.current.cards(); + var card = cards.filter(function(c) { return c.barcode() == bc })[0]; + return (card && card.active() == 'f'); + } // resolves to true if there is any aspect of the patron account // which should produce a message in the alerts panel service.checkAlerts = function() { @@ -438,14 +445,8 @@ function($q , $timeout , $location , egCore, egUser , $locale) { } // see if the user was retrieved with an inactive card - if (bc = $location.search().card) { - var card = p.cards().filter( - function(c) { return c.barcode() == bc })[0]; - - if (card && card.active() == 'f') { - service.hasAlerts = true; - service.retrievedWithInactive = true; - } + if(service.fetchedWithInactiveCard()){ + service.hasAlerts = true; } // regardless of whether we know of alerts, we still need @@ -692,6 +693,7 @@ function($scope , $location , egCore , egConfirmDialog , egUser , patronSvc) { $location .path('/circ/patron/' + user_id + '/checkout') .search('card', $scope.args.barcode); + patronSvc.search_barcode = $scope.args.barcode; } // create an opt-in=yes response for the loaded user @@ -878,7 +880,8 @@ function($scope, $q, $routeParams, $timeout, $window, $location, egCore, delete patronSvc.urlSearch; } else { - + patronSvc.search_barcode = $scope.searchArgs.card; + var search = compileSearch($scope.searchArgs); if (Object.keys(search) == 0) return $q.when(); @@ -1302,7 +1305,7 @@ function($scope, $routeParams , $location , egCore , patronSvc) { .then(function() { $scope.patronExpired = patronSvc.patronExpired; $scope.patronExpiresSoon = patronSvc.patronExpiresSoon; - $scope.retrievedWithInactive = patronSvc.retrievedWithInactive; + $scope.retrievedWithInactive = patronSvc.fetchedWithInactiveCard(); $scope.invalidAddresses = patronSvc.invalidAddresses; }); diff --git a/Open-ILS/web/js/ui/default/staff/circ/patron/checkout.js b/Open-ILS/web/js/ui/default/staff/circ/patron/checkout.js index 3f82de710f..cf3c8f1104 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/patron/checkout.js +++ b/Open-ILS/web/js/ui/default/staff/circ/patron/checkout.js @@ -30,7 +30,8 @@ function($scope , $q , $routeParams , egCore , egUser , patronSvc , !patronSvc.current || patronSvc.current.active() == 'f' || patronSvc.current.deleted() == 't' || - patronSvc.current.card().active() == 'f' + patronSvc.current.card().active() == 'f' || + patronSvc.fetchedWithInactiveCard() ); } -- 2.43.2