tweaks
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 9 Feb 2006 23:32:54 +0000 (23:32 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 9 Feb 2006 23:32:54 +0000 (23:32 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@3023 dcc99617-32d9-48b4-a31d-7c20da2025e4

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

index 203ede7..38338b7 100644 (file)
@@ -147,9 +147,12 @@ sub simplereq {
 }
 
 sub get_storage_session {
+
        if(     $storage_session and 
                        $storage_session->connected and
+                       $storage_session->transport_connected and
                        $storage_session->app eq 'open-ils.storage' ) {
+
                $logger->debug("get_storage_session(): returning existing session");
                return $storage_session;
        }
index 66e7922..044674d 100644 (file)
@@ -529,7 +529,8 @@ sub checkout {
        $evt = _update_checkout_copy($ctx);
        return $evt if $evt;
 
-       $evt = _handle_related_holds($ctx);
+       my $holds;
+       ($holds, $evt) = _handle_related_holds($ctx);
        return $evt if $evt;
 
 
@@ -538,10 +539,11 @@ sub checkout {
        my $record = $U->record_to_mvr($ctx->{title}) unless $ctx->{precat};
 
        return OpenILS::Event->new('SUCCESS', 
-               payload         => { 
-                       copy            => $U->unflesh_copy($ctx->{copy}),
-                       circ            => $ctx->{circ},
-                       record  => $record,
+               payload => { 
+                       copy                                    => $U->unflesh_copy($ctx->{copy}),
+                       circ                                    => $ctx->{circ},
+                       record                          => $record,
+                       holds_fulfilled => $holds,
                } );
 }
 
@@ -744,7 +746,9 @@ sub _handle_related_holds {
        my $patron      = $ctx->{patron};
        my $holds       = $holdcode->fetch_related_holds($copy->id);
        $U->logmark;
+       my @fulfilled;
 
+       # XXX should we fulfill all the holds or just the first
        if(ref($holds) && @$holds) {
 
                # for now, just sort by id to get what should be the oldest hold
@@ -759,11 +763,12 @@ sub _handle_related_holds {
                        $hold->fulfillment_time('now');
                        my $r = $ctx->{session}->request(
                                "open-ils.storage.direct.action.hold_request.update", $hold )->gather(1);
-                       return $U->DB_UPDATE_FAILED( $hold ) unless $r;
+                       return (undef,$U->DB_UPDATE_FAILED( $hold )) unless $r;
+                       push( @fulfilled, $hold->id );
                }
        }
 
-       return undef;
+       return (\@fulfilled, undef);
 }
 
 
index 846f4e0..3f7f736 100644 (file)
@@ -309,7 +309,10 @@ __PACKAGE__->register_method(
        NOTE
 
 sub capture_copy {
-       my( $self, $client, $login_session, $barcode, $flesh ) = @_;
+       my( $self, $client, $login_session, $params ) = @_;
+       my %params = %$params;
+       my $barcode = $params{barcode};
+
 
        my( $user, $target, $copy, $hold, $evt );
 
@@ -320,7 +323,7 @@ sub capture_copy {
        $evt = $apputils->check_perms($user->id, $user->home_ou, "COPY_CHECKIN");
        return $evt if $evt;
 
-       $logger->info("Capturing copy with barcode $barcode, flesh=$flesh");
+       $logger->info("Capturing copy with barcode $barcode");
 
        my $session = $apputils->start_db_session();
 
@@ -357,19 +360,21 @@ sub capture_copy {
                "open-ils.storage.direct.asset.copy.update", $copy )->gather(1);
        if(!$stat) { throw OpenSRF::EX ("Error updating copy " . $copy->id); }
 
-       
-       my $title = undef;
-       if($flesh) {
-               ($title, $evt) = $apputils->fetch_record_by_copy( $copy->id );
+       my $payload = { hold => $hold };
+       $payload->{copy} = $copy if $params{flesh_copy};
+
+       if($params{flesh_record}) {
+               my $record;
+               ($record, $evt) = $apputils->fetch_record_by_copy( $copy->id );
                return $evt if $evt;
-               $title = $apputils->record_to_mvr($title);
-       } 
+               $record = $apputils->record_to_mvr($record);
+               $payload->{record} = $record;
+       }
 
        $apputils->commit_db_session($session);
 
-       my $payload = { copy => $copy, record => $title, hold => $hold, };
-
-       return OpenILS::Event->new('ROUTE_ITEM', route_to => $hold->pickup_lib, payload => $payload );
+       return OpenILS::Event->new('ROUTE_ITEM', 
+               route_to => $hold->pickup_lib, payload => $payload );
 }
 
 sub _build_hold_transit {