From 692d318ef3a5b77f40702e1398f4ccbf36e6342c Mon Sep 17 00:00:00 2001 From: phasefx Date: Tue, 23 Dec 2008 19:41:09 +0000 Subject: [PATCH] in patron retrieval interface for checkouts, replace the barcode.exist call with one that returns the user id or an event on failure git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_4@11667 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/perlmods/OpenILS/Application/Actor.pm | 36 ++++++++++++++++++++++ .../staff_client/chrome/content/main/constants.js | 1 + .../staff_client/server/patron/barcode_entry.xul | 14 +++++---- 3 files changed, 45 insertions(+), 6 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm b/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm index 55d048d011..538989fb3f 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm @@ -2947,5 +2947,41 @@ sub retrieve_org_hours { } +__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; +} + + + 1; diff --git a/Open-ILS/xul/staff_client/chrome/content/main/constants.js b/Open-ILS/xul/staff_client/chrome/content/main/constants.js index e23b8077db..2d12a704c3 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/constants.js +++ b/Open-ILS/xul/staff_client/chrome/content/main/constants.js @@ -115,6 +115,7 @@ const api = { 'FM_ATC_VOID' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.transit.abort' }, 'FM_ATC_RETRIEVE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.transit.retrieve', 'secure' : false }, 'FM_ATC_RETRIEVE_VIA_AOU' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.transit.retrieve_by_lib', 'secure' : false }, + 'FM_AU_ID_RETRIEVE_VIA_BARCODE_OR_USERNAME' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.retrieve_id_by_barcode_or_username' }, 'FM_AU_IDS_RETRIEVE_VIA_HASH' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.patron.search.advanced' }, 'FM_AU_LIST_RETRIEVE_VIA_GROUP' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.usergroup.members.retrieve' }, 'FM_AU_LIST_RETRIEVE_VIA_GROUP.authoritative' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.usergroup.members.retrieve.authoritative' }, diff --git a/Open-ILS/xul/staff_client/server/patron/barcode_entry.xul b/Open-ILS/xul/staff_client/server/patron/barcode_entry.xul index 37eb69b9e1..03c91415f7 100644 --- a/Open-ILS/xul/staff_client/server/patron/barcode_entry.xul +++ b/Open-ILS/xul/staff_client/server/patron/barcode_entry.xul @@ -94,18 +94,20 @@ tb.disabled = true; document.getElementById('progress').setAttribute('hidden','false'); - net.simple_request('PATRON_BARCODE_EXISTS.authoritative',[ ses(), barcode ], + net.simple_request('FM_AU_ID_RETRIEVE_VIA_BARCODE_OR_USERNAME',[ ses(), barcode, null ], function(req) { document.getElementById('progress').setAttribute('hidden','true'); tb.disabled = false; tb.select(); tb.focus(); ; var robj = req.getResultObject(); if (typeof robj.ilsevent != 'undefined') { sound.bad(); - add_msg($("patronStrings").getFormattedString('staff.patron.barcode_entry.barcode_retrieval_problem', [barcode, js2JSON(robj)])); - return; - } else if (robj == 0) { - sound.bad(); - add_msg($("patronStrings").getFormattedString('staff.patron.barcode_entry.barcode_not_found', [barcode])); + switch(Number(robj.ilsevent)) { + case 1002 /* ACTOR_USER_NOT_FOUND */: + add_msg($("patronStrings").getFormattedString('staff.patron.barcode_entry.barcode_not_found', [barcode])); + break; + default: + add_msg($("patronStrings").getFormattedString('staff.patron.barcode_entry.barcode_retrieval_problem', [barcode, js2JSON(robj)])); + } return; } -- 2.11.0