From 5626db6dea87d360faaa0aabc8ce3f65ded709e9 Mon Sep 17 00:00:00 2001 From: phasefx Date: Mon, 22 Dec 2008 21:59:28 +0000 Subject: [PATCH] retrieve patron button on verify credentials interface git-svn-id: svn://svn.open-ils.org/ILS/trunk@11658 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../src/perlmods/OpenILS/Application/Actor.pm | 33 +++++++++++++++++++ Open-ILS/web/opac/locale/en-US/lang.dtd | 2 ++ .../chrome/content/auth/verify_credentials.js | 23 +++++++++++++ .../content/auth/verify_credentials.xul | 2 ++ .../chrome/content/main/constants.js | 1 + 5 files changed, 61 insertions(+) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm b/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm index 0c01d2d8bc..f7fcd23574 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm @@ -3009,6 +3009,39 @@ sub verify_user_password { return 0; } +__PACKAGE__->register_method ( + method => 'retrieve_usr_id_via_barcode_or_usrname', + api_name => "open-ils.actor.user.retrieve_id_by_barcode_or_username", + signature => q/ + Given a barcode or username returns the id for the user or + a failure event. + / +); + +sub retrieve_usr_id_via_barcode_or_usrname { + my($self, $conn, $auth, $barcode, $username) = @_; + my $e = new_editor(authtoken => $auth); + return $e->die_event unless $e->checkauth; + my $user; + my $user_by_barcode; + my $user_by_username; + if($barcode) { + my $card = $e->search_actor_card([ + {barcode => $barcode}, + {flesh => 1, flesh_fields => {ac => ['usr']}}])->[0] or return OpenILS::Event->new( 'ACTOR_USER_NOT_FOUND' ); + $user_by_barcode = $card->usr; + $user = $user_by_barcode; + } + if ($username) { + $user_by_username = $e->search_actor_user({usrname => $username})->[0] or return OpenILS::Event->new( 'ACTOR_USER_NOT_FOUND' ); + + $user = $user_by_username; + } + return OpenILS::Event->new( 'ACTOR_USER_NOT_FOUND' ) if (!$user); + return OpenILS::Event->new( 'ACTOR_USER_NOT_FOUND' ) if ($user_by_username && $user_by_barcode && $user_by_username->id != $user_by_barcode->id); + return $e->event unless $e->allowed('VIEW_USER', $user->home_ou); + return $user->id; +} __PACKAGE__->register_method ( diff --git a/Open-ILS/web/opac/locale/en-US/lang.dtd b/Open-ILS/web/opac/locale/en-US/lang.dtd index 6617b1a6d7..fab2bdfde3 100644 --- a/Open-ILS/web/opac/locale/en-US/lang.dtd +++ b/Open-ILS/web/opac/locale/en-US/lang.dtd @@ -190,6 +190,8 @@ + + diff --git a/Open-ILS/xul/staff_client/chrome/content/auth/verify_credentials.js b/Open-ILS/xul/staff_client/chrome/content/auth/verify_credentials.js index f5c6ef5ee1..cca01789af 100644 --- a/Open-ILS/xul/staff_client/chrome/content/auth/verify_credentials.js +++ b/Open-ILS/xul/staff_client/chrome/content/auth/verify_credentials.js @@ -72,6 +72,29 @@ function verify_init() { }, false ); + document.getElementById('cmd_retrieve').addEventListener( + 'command', + function() { + var barcode = document.getElementById('barcode_prompt').value; + var name = document.getElementById('name_prompt').value; + var req = net.simple_request( + 'FM_AU_ID_RETRIEVE_VIA_BARCODE_OR_USERNAME', + [ + ses(), + barcode, + name + ] + ); + if (typeof req.ilsevent != 'undefined') { + alert (req.desc); + document.getElementById('name_prompt').focus(); + } else { + var url = xulG.url_prefix( urls.XUL_PATRON_DISPLAY ); + xulG.set_tab( url, {}, { 'id' : req } ); + } + }, + false + ); document.getElementById('name_prompt').focus(); diff --git a/Open-ILS/xul/staff_client/chrome/content/auth/verify_credentials.xul b/Open-ILS/xul/staff_client/chrome/content/auth/verify_credentials.xul index 3af412bf25..d17818f18f 100644 --- a/Open-ILS/xul/staff_client/chrome/content/auth/verify_credentials.xul +++ b/Open-ILS/xul/staff_client/chrome/content/auth/verify_credentials.xul @@ -40,6 +40,7 @@ + @@ -65,6 +66,7 @@