Lines 106-113
sub new {
Link Here
|
106 |
my $biblio = Koha::Biblios->find( $self->{biblionumber} ); |
106 |
my $biblio = Koha::Biblios->find( $self->{biblionumber} ); |
107 |
my $holds = $biblio->current_holds->unblessed; |
107 |
my $holds = $biblio->current_holds->unblessed; |
108 |
$self->{hold_queue} = $holds; |
108 |
$self->{hold_queue} = $holds; |
109 |
$self->{hold_shelf} = [( grep { defined $_->{found} and $_->{found} eq 'W' } @{$self->{hold_queue}} )]; |
109 |
$self->{hold_attached} = [( grep { defined $_->{found} and ( $_->{found} eq 'W' or $_->{found} eq 'P' ) } @{$self->{hold_queue}} )]; |
110 |
$self->{pending_queue} = [( grep {(! defined $_->{found}) or $_->{found} ne 'W' } @{$self->{hold_queue}} )]; |
110 |
$self->{pending_queue} = [( grep {(! defined $_->{found}) or ( $_->{found} ne 'W' and $_->{found} ne 'P' ) } @{$self->{hold_queue}} )]; |
111 |
$self->{title} = $biblio->title; |
111 |
$self->{title} = $biblio->title; |
112 |
$self->{author} = $biblio->author; |
112 |
$self->{author} = $biblio->author; |
113 |
bless $self, $type; |
113 |
bless $self, $type; |
Lines 144-151
my %fields = (
Link Here
|
144 |
|
144 |
|
145 |
sub next_hold { |
145 |
sub next_hold { |
146 |
my $self = shift; |
146 |
my $self = shift; |
147 |
# use Data::Dumper; warn "next_hold() hold_shelf: " . Dumper($self->{hold_shelf}); warn "next_hold() pending_queue: " . $self->{pending_queue}; |
147 |
# use Data::Dumper; warn "next_hold() hold_attached: " . Dumper($self->{hold_attached}); warn "next_hold() pending_queue: " . $self->{pending_queue}; |
148 |
foreach (@{$self->hold_shelf}) { # If this item was taken from the hold shelf, then that reserve still governs |
148 |
foreach (@{$self->hold_attached}) { # If this item was taken from the hold shelf, then that reserve still governs |
149 |
next unless ($_->{itemnumber} and $_->{itemnumber} == $self->{itemnumber}); |
149 |
next unless ($_->{itemnumber} and $_->{itemnumber} == $self->{itemnumber}); |
150 |
return $_; |
150 |
return $_; |
151 |
} |
151 |
} |
Lines 271-277
sub sip_circulation_status {
Link Here
|
271 |
elsif ( $self->{borrowernumber} ) { |
271 |
elsif ( $self->{borrowernumber} ) { |
272 |
return '04'; # charged |
272 |
return '04'; # charged |
273 |
} |
273 |
} |
274 |
elsif ( grep { $_->{itemnumber} == $self->{itemnumber} } @{ $self->{hold_shelf} } ) { |
274 |
elsif ( grep { $_->{itemnumber} == $self->{itemnumber} } @{ $self->{hold_attached} } ) { |
275 |
return '08'; # waiting on hold shelf |
275 |
return '08'; # waiting on hold shelf |
276 |
} |
276 |
} |
277 |
else { |
277 |
else { |
Lines 310-319
sub pending_queue {
Link Here
|
310 |
(defined $self->{pending_queue}) or return []; |
310 |
(defined $self->{pending_queue}) or return []; |
311 |
return $self->{pending_queue}; |
311 |
return $self->{pending_queue}; |
312 |
} |
312 |
} |
313 |
sub hold_shelf { |
313 |
sub hold_attached { |
314 |
my $self = shift; |
314 |
my $self = shift; |
315 |
(defined $self->{hold_shelf}) or return []; |
315 |
(defined $self->{hold_attached}) or return []; |
316 |
return $self->{hold_shelf}; |
316 |
return $self->{hold_attached}; |
317 |
} |
317 |
} |
318 |
|
318 |
|
319 |
sub hold_queue_position { |
319 |
sub hold_queue_position { |
Lines 355-361
sub hold_pickup_date {
Link Here
|
355 |
# AND no pending (i.e. non-W) hold queue |
355 |
# AND no pending (i.e. non-W) hold queue |
356 |
# OR |
356 |
# OR |
357 |
# 2) not checked out |
357 |
# 2) not checked out |
358 |
# AND (not on hold_shelf OR is on hold_shelf for patron) |
358 |
# AND (not on hold_attached OR is on hold_attached for patron) |
359 |
# |
359 |
# |
360 |
# What this means is we are consciously allowing the patron to checkout (but not renew) an item that DOES |
360 |
# What this means is we are consciously allowing the patron to checkout (but not renew) an item that DOES |
361 |
# have non-W holds on it, but has not been "picked" from the stacks. That is to say, the |
361 |
# have non-W holds on it, but has not been "picked" from the stacks. That is to say, the |
Lines 367-379
sub hold_pickup_date {
Link Here
|
367 |
sub available { |
367 |
sub available { |
368 |
my ($self, $for_patron) = @_; |
368 |
my ($self, $for_patron) = @_; |
369 |
my $count = (defined $self->{pending_queue}) ? scalar @{$self->{pending_queue}} : 0; |
369 |
my $count = (defined $self->{pending_queue}) ? scalar @{$self->{pending_queue}} : 0; |
370 |
my $count2 = (defined $self->{hold_shelf} ) ? scalar @{$self->{hold_shelf} } : 0; |
370 |
my $count2 = (defined $self->{hold_attached} ) ? scalar @{$self->{hold_attached} } : 0; |
371 |
$debug and print STDERR "availability check: pending_queue size $count, hold_shelf size $count2\n"; |
371 |
$debug and print STDERR "availability check: pending_queue size $count, hold_attached size $count2\n"; |
372 |
if (defined($self->{borrowernumber})) { |
372 |
if (defined($self->{borrowernumber})) { |
373 |
($self->{borrowernumber} eq $for_patron) or return 0; |
373 |
($self->{borrowernumber} eq $for_patron) or return 0; |
374 |
return ($count ? 0 : 1); |
374 |
return ($count ? 0 : 1); |
375 |
} else { # not checked out |
375 |
} else { # not checked out |
376 |
($count2) and return $self->barcode_is_borrowernumber($for_patron, $self->{hold_shelf}[0]->{borrowernumber}); |
376 |
($count2) and return $self->barcode_is_borrowernumber($for_patron, $self->{hold_attached}[0]->{borrowernumber}); |
377 |
} |
377 |
} |
378 |
return 0; |
378 |
return 0; |
379 |
} |
379 |
} |