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', 'status' ],
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;
128 # 05 Charged; not to be recalled until earliest recall date
131 # 08 Waiting on hold shelf
132 # 09 Waiting to be re-shelved
133 # 10 In transit between library locations
134 # 11 Claimed returned
137 sub sip_circulation_status {
139 return '03' if $self->{copy}->status->name =~ /available/i;
140 return '04' if $self->{copy}->status->name =~ /checked out/i;
141 return '06' if $self->{copy}->status->name =~ /in process/i;
142 return '08' if $self->{copy}->status->name =~ /on holds shelf/i;
143 return '09' if $self->{copy}->status->name =~ /reshelving/i;
144 return '10' if $self->{copy}->status->name =~ /in transit/i;
145 return '12' if $self->{copy}->status->name =~ /lost/i;
149 sub sip_security_marker {
170 return $self->{volume}->owning_lib->name;
178 sub hold_queue_position {
179 my ($self, $patron_id) = @_;
185 my $e = OpenILS::SIP->editor();
187 my $circ = $e->search_action_circulation(
188 { target_copy => $self->{copy}->id, stop_fines => undef } )->[0];
191 # if not, lets look for other circs we can check in
192 $circ = $e->search_action_circulation(
194 target_copy => $self->{copy}->id,
195 xact_finish => undef,
196 stop_fines => [ 'CLAIMSRETURNED', 'LOST', 'LONGOVERDUE' ]
200 return $circ->due_date if $circ;
209 sub hold_pickup_date {
214 # message to display on console
217 return $self->{screen_msg} || '';
224 return $self->{print_line} || '';
228 # An item is available for a patron if
229 # 1) It's not checked out and (there's no hold queue OR patron
230 # is at the front of the queue)
232 # 2) It's checked out to the patron and there's no hold queue
234 my ($self, $for_patron) = @_;