simplified hold status logic to rely on existing data
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 14 Aug 2006 21:54:52 +0000 (21:54 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 14 Aug 2006 21:54:52 +0000 (21:54 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@5507 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm

index e6f8958..1ebe9c4 100644 (file)
@@ -477,31 +477,24 @@ __PACKAGE__->register_method(
        NOTE
 
 sub retrieve_hold_status {
-       my($self, $client, $login_session, $hold_id) = @_;
-
-
-       my( $requestor, $target, $hold, $copy, $transit, $evt );
-
-       ( $hold, $evt ) = $apputils->fetch_hold($hold_id);
-       return $evt if $evt;
-
-       ( $requestor, $target, $evt ) = $apputils->checkses_requestor(
-               $login_session, $hold->usr, 'VIEW_HOLD' );
-       return $evt if $evt;
+       my($self, $client, $auth, $hold_id) = @_;
 
-       return 1 unless (defined($hold->current_copy));
-       
-       ( $copy, $evt ) = $apputils->fetch_copy($hold->current_copy);
-       return $evt if $evt;
+       my $e = new_editor(authtoken => $auth);
+       return $e->event unless $e->checkauth;
+       my $hold = $e->retrieve_action_hold_request($hold_id)
+               or return $e->event;
+       return $e->event unless $e->allowed('VIEW_HOLD');
 
-       return 4 if ($hold->capture_time and $copy->circ_lib eq $hold->pickup_lib);
+       return 1 unless $hold->current_copy;
+       return 2 unless $hold->capture_time;
 
-       ( $transit, $evt ) = $apputils->fetch_hold_transit_by_hold( $hold->id );
-       return 4 if(ref($transit) and defined($transit->dest_recv_time) ); 
+       my $copy = $e->retrieve_asset_copy($hold->current_copy)
+               or return $e->event;
 
-       return 3 if defined($hold->capture_time);
+       return 3 if $copy->status == OILS_COPY_STATUS_IN_TRANSIT;
+       return 4 if $copy->status == OILS_COPY_STATUS_ON_HOLDS_SHELF;
 
-       return 2;
+       return -1;
 }