From 77bc7387508d2e1d548e1f688448f512a1e19737 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 1 May 2014 15:03:54 -0400 Subject: [PATCH] checkout from patron barcode entry UI * includes opt-in logic * includes link from splash page Signed-off-by: Bill Erickson --- Open-ILS/src/templates/staff/circ/patron/index.tt2 | 9 ++ .../src/templates/staff/circ/patron/t_bcsearch.tt2 | 28 ++++++ Open-ILS/src/templates/staff/t_splash.tt2 | 14 ++- .../web/js/ui/default/staff/circ/patron/app.js | 100 +++++++++++++++++++++ 4 files changed, 149 insertions(+), 2 deletions(-) create mode 100644 Open-ILS/src/templates/staff/circ/patron/t_bcsearch.tt2 diff --git a/Open-ILS/src/templates/staff/circ/patron/index.tt2 b/Open-ILS/src/templates/staff/circ/patron/index.tt2 index 7a99b7b12d..14c87b7873 100644 --- a/Open-ILS/src/templates/staff/circ/patron/index.tt2 +++ b/Open-ILS/src/templates/staff/circ/patron/index.tt2 @@ -19,6 +19,15 @@ + + + [% END %]
diff --git a/Open-ILS/src/templates/staff/circ/patron/t_bcsearch.tt2 b/Open-ILS/src/templates/staff/circ/patron/t_bcsearch.tt2 new file mode 100644 index 0000000000..8396e23a4d --- /dev/null +++ b/Open-ILS/src/templates/staff/circ/patron/t_bcsearch.tt2 @@ -0,0 +1,28 @@ + +
+
+ + + + + + + + +
+
+ +
+
+ [% l('Barcode Not Found: [_1]', '{{bcNotFound}}') %] +
+ + diff --git a/Open-ILS/src/templates/staff/t_splash.tt2 b/Open-ILS/src/templates/staff/t_splash.tt2 index cc8e5cfacc..d259698db3 100644 --- a/Open-ILS/src/templates/staff/t_splash.tt2 +++ b/Open-ILS/src/templates/staff/t_splash.tt2 @@ -14,13 +14,17 @@
@@ -51,6 +55,12 @@ [% l('Evergreen Documentation') %] +
+ + + [% l('Workstation Administration') %] + +
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 e2ebb303ac..2fa5a190af 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 @@ -52,6 +52,13 @@ angular.module('egPatronApp', ['ngRoute', 'ui.bootstrap', resolve : resolver }); + $routeProvider.when('/circ/patron/bcsearch', { + templateUrl: './circ/patron/t_bcsearch', + controller: 'PatronBarcodeSearchCtrl', + resolve : resolver + }); + + $routeProvider.when('/circ/patron/:id/checkout', { templateUrl: './circ/patron/t_checkout', controller: 'PatronCheckoutCtrl', @@ -152,6 +159,12 @@ function($q , $timeout , egNet, egAuth, egUser, egEnv, egOrg) { "unable to fetch user "+id+': '+js2JSON(err)) } ); + } else { + + // reset with no patron + service.resetPatronLists(); + service.current = null; + service.patron_stats = null; } } @@ -215,6 +228,93 @@ function($scope, $q, $filter, egNet, egAuth, egUser, patronSvc, egEnv, e $scope.patron_stats = function() { return patronSvc.patron_stats } }]) +.controller('PatronBarcodeSearchCtrl', + ['$scope','$location','egAuth','egNet','egEvent','egOrg','egConfirmDialog','egUser','egAppStrings','patronSvc', +function($scope , $location , egAuth , egNet , egEvent , egOrg , egConfirmDialog , egUser , egAppStrings , patronSvc) { + $scope.selectMe = true; // focus text input + patronSvc.setDefault(); // clear the default user + + // jump to the patron checkout UI + function loadPatron(user_id) { + $location.path('/circ/patron/' + user_id + '/checkout'); + } + + // create an opt-in=yes response for the loaded user + function createOptIn(user_id) { + egNet.request( + 'open-ils.actor', + 'open-ils.actor.user.org_unit_opt_in.create', + egAuth.token(), user_id).then(function(resp) { + if (evt = egEvent.parse(resp)) return alert(evt); + loadPatron(user_id); + } + ); + } + + $scope.submitBarcode = function(args) { + $scope.bcNotFound = null; + if (!args.barcode) return; + + // blur so next time it's set to true it will re-apply select() + $scope.selectMe = false; + + var user_id; + + // lookup barcode + egNet.request( + 'open-ils.actor', + 'open-ils.actor.get_barcodes', + egAuth.token(), egAuth.user().ws_ou(), 'actor', args.barcode) + + .then(function(resp) { // get_barcodes + + if (evt = egEvent.parse(resp)) { + alert(evt); // FIXME + return; + } + + if (!resp || !resp[0]) { + $scope.bcNotFound = args.barcode; + $scope.selectMe = true; + return; + } + + // see if an opt-in request is needed + user_id = resp[0].id; + return egNet.request( + 'open-ils.actor', + 'open-ils.actor.user.org_unit_opt_in.check', + egAuth.token(), user_id); + + }).then(function(optInResp) { // opt_in_check + + if (evt = egEvent.parse(optInResp)) { + alert(evt); // FIXME + return; + } + + if (optInResp == 1) { + // opt-in handled or not needed + return loadPatron(user_id); + } + + // opt-in needed, show the opt-in dialog + egUser.get(user_id, {useFields : []}) + + .then(function(user) { // retrieve user + egConfirmDialog.open( + egAppStrings.OPT_IN_DIALOG, '', + { org : egOrg.get(egAuth.user().ws_ou()), + user : user, + ok : function() { createOptIn(user.id()) }, + cancel : function() {} + } + ); + }) + }); + } +}]) + /** * Manages patron search -- 2.11.0