in patron retrieval interface for checkouts, replace the barcode.exist call with...
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 23 Dec 2008 19:41:09 +0000 (19:41 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 23 Dec 2008 19:41:09 +0000 (19:41 +0000)
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
Open-ILS/xul/staff_client/chrome/content/main/constants.js
Open-ILS/xul/staff_client/server/patron/barcode_entry.xul

index 55d048d..538989f 100644 (file)
@@ -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;
 
index e23b807..2d12a70 100644 (file)
@@ -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' },
index 37eb69b..03c9141 100644 (file)
 
                                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;
                                                }