3 # A Class for hiding the ILS's concept of the item from the OpenSIP
7 package OpenILS::SIP::Item;
8 use strict; use warnings;
10 use Sys::Syslog qw(syslog);
13 use OpenILS::SIP::Transaction;
14 use OpenILS::Application::AppUtils;
15 my $U = 'OpenILS::Application::AppUtils';
20 my ($class, $item_id) = @_;
21 my $type = ref($class) || $class;
22 my $self = bless( {}, $type );
24 syslog('LOG_DEBUG', "Loading item $item_id...");
25 return undef unless $item_id;
27 my $e = OpenILS::SIP->editor();
30 my $copy = $e->search_asset_copy(
32 { barcode => $item_id },
36 acp => [ 'circ_lib', 'call_number' ],
37 acn => [ 'owning_lib', 'record' ],
46 syslog("LOG_DEBUG", "OpenILS: Item '%s' : not found", $item_id);
50 my ($circ) = $U->fetch_open_circulation($copy->id);
52 # if i am checked out, set $self->{patron} to the user's barcode
53 my $user = $e->retrieve_actor_user(
56 { flesh => 1, flesh_fields => { "au" => [ 'card' ] } }
60 my $bc = ($user) ? $user->card->barcode : "";
61 $self->{patron} = $bc;
62 $self->{patron_object} = $user;
64 syslog('LOG_DEBUG', "Open circulation exists on $item_id : user = $bc");
67 $self->{id} = $item_id;
68 $self->{copy} = $copy;
69 $self->{volume} = $copy->call_number;
70 $self->{record} = $copy->call_number->record;
71 $self->{mods} = $U->record_to_mvr($self->{record}) if $self->{record}->marc;
73 syslog("LOG_DEBUG", "Item('$item_id'): found with title '%s'", $self->title_id);
88 sub sip_item_properties {
94 my ($self, $props) = @_;
95 my $status = OpenILS::SIP::Transaction->new;
96 $self->{sip_item_properties} = $props;
109 return ($self->{mods}) ? $self->{mods}->title : $self->{copy}->dummy_title;
112 sub permanent_location {
114 return $self->{volume}->owning_lib->name;
117 sub current_location {
119 return $self->{copy}->circ_lib->name;
124 sub sip_circulation_status {
129 sub sip_security_marker {
150 return $self->{volume}->owning_lib->name;
158 sub hold_queue_position {
159 my ($self, $patron_id) = @_;
173 sub hold_pickup_date {
178 # message to display on console
181 return $self->{screen_msg} || '';
188 return $self->{print_line} || '';
192 # An item is available for a patron if
193 # 1) It's not checked out and (there's no hold queue OR patron
194 # is at the front of the queue)
196 # 2) It's checked out to the patron and there's no hold queue
198 my ($self, $for_patron) = @_;