# search for what should be the best holds for this copy to fulfill
my $best_holds = $U->storagereq(
- "open-ils.storage.action.hold_request.nearest_hold.atomic",
+ "open-ils.storage.action.hold_request.nearest_hold.atomic",
$user->ws_ou, $copy->id, 10, $hold_stall_interval );
unless(@$best_holds) {
my $copy = $hold->current_copy;
- if($copy_status) {
+ if($copy_status or $copy_status == 0) {
# if a clear-shelf copy status is defined, update the copy
$copy->status($copy_status);
$copy->edit_date('now');
$e->update_asset_copy($copy) or return $e->die_event;
}
- my ($alt_hold) = __PACKAGE__->find_nearest_permitted_hold($e, $copy, $e->requestor, 1);
+ push(@holds, $hold);
+ }
- if($alt_hold) {
+ if ($e->commit) {
- # copy is needed for a hold
- $client->respond({action => 'hold', copy => $copy, hold_id => $hold->id});
+ for my $hold (@holds) {
- } elsif($copy->circ_lib != $e->requestor->ws_ou) {
+ my $copy = $hold->current_copy;
- # copy needs to transit
- $client->respond({action => 'transit', copy => $copy, hold_id => $hold->id});
+ my ($alt_hold) = __PACKAGE__->find_nearest_permitted_hold($e, $copy, $e->requestor, 1);
- } else {
+ if($alt_hold) {
+
+ # copy is needed for a hold
+ $client->respond({action => 'hold', copy => $copy, hold_id => $hold->id});
- # copy needs to go back to the shelf
- $client->respond({action => 'shelf', copy => $copy, hold_id => $hold->id});
+ } elsif($copy->circ_lib != $e->requestor->ws_ou) {
+
+ # copy needs to transit
+ $client->respond({action => 'transit', copy => $copy, hold_id => $hold->id});
+
+ } else {
+
+ # copy needs to go back to the shelf
+ $client->respond({action => 'shelf', copy => $copy, hold_id => $hold->id});
+ }
}
- push(@holds, $hold);
- }
+ # tell the client we're done
+ $client->respond_complete;
- $e->commit;
+ # fire off the hold cancelation trigger
+ my $trigger = OpenSRF::AppSession->connect('open-ils.trigger');
- # tell the client we're done
- $client->respond_complete;
+ for my $hold (@holds) {
- # fire off the hold cancelation trigger
- my $trigger = OpenSRF::AppSession->connect('open-ils.trigger');
+ my $req = $trigger->request(
+ 'open-ils.trigger.event.autocreate',
+ 'hold_request.cancel.expire_holds_shelf',
+ $hold, $org_id);
- for my $hold (@holds) {
+ # wait for response so don't flood the service
+ $req->recv;
+ }
- my $req = $trigger->request(
- 'open-ils.trigger.event.autocreate',
- 'hold_request.cancel.expire_holds_shelf',
- $hold, $org_id);
+ $trigger->disconnect;
- # wait for response so don't flood the service
- $req->recv;
+ } else {
+ # tell the client we're done
+ $client->respond_complete;
}
-
- $trigger->disconnect;
}
-
__PACKAGE__->register_method(
method => 'usr_hold_summary',
api_name => 'open-ils.circ.holds.user_summary',