-
-=head DEPRECATED
-__PACKAGE__->register_method(
- method => "capture_copy",
- api_name => "open-ils.circ.hold.capture_copy.barcode",
- notes => <<" NOTE");
- Captures a copy to fulfil a hold
- Params is login session and copy barcode
- Optional param is 'flesh'. If set, we also return the
- relevant copy and title
- login mus have COPY_CHECKIN permissions (since this is essentially
- copy checkin)
- NOTE
-
-# XXX deprecate me XXX
-
-sub capture_copy {
- my( $self, $client, $login_session, $params ) = @_;
- my %params = %$params;
- my $barcode = $params{barcode};
-
-
- my( $user, $target, $copy, $hold, $evt );
-
- ( $user, $evt ) = $apputils->checkses($login_session);
- return $evt if $evt;
-
- # am I allowed to checkin a copy?
- $evt = $apputils->check_perms($user->id, $user->home_ou, "COPY_CHECKIN");
- return $evt if $evt;
-
- $logger->info("Capturing copy with barcode $barcode");
-
- my $session = $apputils->start_db_session();
-
- ($copy, $evt) = $apputils->fetch_copy_by_barcode($barcode);
- return $evt if $evt;
-
- $logger->debug("Capturing copy " . $copy->id);
-
- #( $hold, $evt ) = _find_local_hold_for_copy($session, $copy, $user);
- ( $hold, $evt ) = $self->find_nearest_permitted_hold($session, $copy, $user);
- return $evt if $evt;
-
- warn "Found hold " . $hold->id . "\n";
- $logger->info("We found a hold " .$hold->id. "for capturing copy with barcode $barcode");
-
- $hold->current_copy($copy->id);
- $hold->capture_time("now");
-
- #update the hold
- my $stat = $session->request(
- "open-ils.storage.direct.action.hold_request.update", $hold)->gather(1);
- if(!$stat) { throw OpenSRF::EX::ERROR
- ("Error updating hold request " . $copy->id); }
-
- $copy->status(OILS_COPY_STATUS_ON_HOLDS_SHELF); #status on holds shelf
-
- # if the staff member capturing this item is not at the pickup lib
- if( $user->home_ou ne $hold->pickup_lib ) {
- $self->_build_hold_transit( $login_session, $session, $hold, $user, $copy );
- }
-
- $copy->editor($user->id);
- $copy->edit_date("now");
- $stat = $session->request(
- "open-ils.storage.direct.asset.copy.update", $copy )->gather(1);
- if(!$stat) { throw OpenSRF::EX ("Error updating 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;
- $record = $apputils->record_to_mvr($record);
- $payload->{record} = $record;
- }
-
- $apputils->commit_db_session($session);
-
- return OpenILS::Event->new('ROUTE_ITEM',
- route_to => $hold->pickup_lib, payload => $payload );
-}
-
-sub _build_hold_transit {
- my( $self, $login_session, $session, $hold, $user, $copy ) = @_;
- my $trans = Fieldmapper::action::hold_transit_copy->new;
-
- $trans->hold($hold->id);
- $trans->source($user->home_ou);
- $trans->dest($hold->pickup_lib);
- $trans->source_send_time("now");
- $trans->target_copy($copy->id);
- $trans->copy_status($copy->status);
-
- my $meth = $self->method_lookup("open-ils.circ.hold_transit.create");
- my ($stat) = $meth->run( $login_session, $trans, $session );
- if(!$stat) { throw OpenSRF::EX ("Error creating new hold transit"); }
- else { $copy->status(6); } #status in transit
-}
-
-
-
-__PACKAGE__->register_method(
- method => "create_hold_transit",
- api_name => "open-ils.circ.hold_transit.create",
- notes => <<" NOTE");
- Creates a new transit object
- NOTE
-
-sub create_hold_transit {
- my( $self, $client, $login_session, $transit, $session ) = @_;
-
- my( $user, $evt ) = $apputils->checkses($login_session);
- return $evt if $evt;
- $evt = $apputils->check_perms($user->id, $user->home_ou, "CREATE_TRANSIT");
- return $evt if $evt;
-
- my $ses;
- if($session) { $ses = $session; }
- else { $ses = OpenSRF::AppSession->create("open-ils.storage"); }
-
- return $ses->request(
- "open-ils.storage.direct.action.hold_transit_copy.create", $transit )->gather(1);
-}
-
-=cut
-
-
sub find_local_hold {
my( $class, $session, $copy, $user ) = @_;
return $class->find_nearest_permitted_hold($session, $copy, $user);
}
-
-
-
-
sub fetch_open_hold_by_current_copy {
my $class = shift;
my $copyid = shift;