Lines 108-115
sub new {
Link Here
|
108 |
my $biblio = Koha::Biblios->find( $self->{biblionumber} ); |
108 |
my $biblio = Koha::Biblios->find( $self->{biblionumber} ); |
109 |
my $holds = $biblio->current_holds->unblessed; |
109 |
my $holds = $biblio->current_holds->unblessed; |
110 |
$self->{hold_queue} = $holds; |
110 |
$self->{hold_queue} = $holds; |
111 |
$self->{hold_shelf} = [( grep { defined $_->{found} and $_->{found} eq 'W' } @{$self->{hold_queue}} )]; |
111 |
$self->{hold_attached} = [( grep { defined $_->{found} and ( $_->{found} eq 'W' or $_->{found} eq 'P' ) } @{$self->{hold_queue}} )]; |
112 |
$self->{pending_queue} = [( grep {(! defined $_->{found}) or $_->{found} ne 'W' } @{$self->{hold_queue}} )]; |
112 |
$self->{pending_queue} = [( grep {(! defined $_->{found}) or ( $_->{found} ne 'W' and $_->{found} ne 'P' ) } @{$self->{hold_queue}} )]; |
113 |
$self->{title} = $biblio->title; |
113 |
$self->{title} = $biblio->title; |
114 |
$self->{author} = $biblio->author; |
114 |
$self->{author} = $biblio->author; |
115 |
bless $self, $type; |
115 |
bless $self, $type; |
Lines 148-155
my %fields = (
Link Here
|
148 |
|
148 |
|
149 |
sub next_hold { |
149 |
sub next_hold { |
150 |
my $self = shift; |
150 |
my $self = shift; |
151 |
# use Data::Dumper; warn "next_hold() hold_shelf: " . Dumper($self->{hold_shelf}); warn "next_hold() pending_queue: " . $self->{pending_queue}; |
151 |
# use Data::Dumper; warn "next_hold() hold_attached: " . Dumper($self->{hold_attached}); warn "next_hold() pending_queue: " . $self->{pending_queue}; |
152 |
foreach (@{$self->hold_shelf}) { # If this item was taken from the hold shelf, then that reserve still governs |
152 |
foreach (@{$self->hold_attached}) { # If this item was taken from the hold shelf, then that reserve still governs |
153 |
next unless ($_->{itemnumber} and $_->{itemnumber} == $self->{itemnumber}); |
153 |
next unless ($_->{itemnumber} and $_->{itemnumber} == $self->{itemnumber}); |
154 |
return $_; |
154 |
return $_; |
155 |
} |
155 |
} |
Lines 275-281
sub sip_circulation_status {
Link Here
|
275 |
elsif ( $self->{borrowernumber} ) { |
275 |
elsif ( $self->{borrowernumber} ) { |
276 |
return '04'; # charged |
276 |
return '04'; # charged |
277 |
} |
277 |
} |
278 |
elsif ( grep { $_->{itemnumber} == $self->{itemnumber} } @{ $self->{hold_shelf} } ) { |
278 |
elsif ( grep { $_->{itemnumber} == $self->{itemnumber} } @{ $self->{hold_attached} } ) { |
279 |
return '08'; # waiting on hold shelf |
279 |
return '08'; # waiting on hold shelf |
280 |
} |
280 |
} |
281 |
else { |
281 |
else { |
Lines 314-323
sub pending_queue {
Link Here
|
314 |
(defined $self->{pending_queue}) or return []; |
314 |
(defined $self->{pending_queue}) or return []; |
315 |
return $self->{pending_queue}; |
315 |
return $self->{pending_queue}; |
316 |
} |
316 |
} |
317 |
sub hold_shelf { |
317 |
sub hold_attached { |
318 |
my $self = shift; |
318 |
my $self = shift; |
319 |
(defined $self->{hold_shelf}) or return []; |
319 |
(defined $self->{hold_attached}) or return []; |
320 |
return $self->{hold_shelf}; |
320 |
return $self->{hold_attached}; |
321 |
} |
321 |
} |
322 |
|
322 |
|
323 |
sub hold_queue_position { |
323 |
sub hold_queue_position { |
Lines 359-365
sub hold_pickup_date {
Link Here
|
359 |
# AND no pending (i.e. non-W) hold queue |
359 |
# AND no pending (i.e. non-W) hold queue |
360 |
# OR |
360 |
# OR |
361 |
# 2) not checked out |
361 |
# 2) not checked out |
362 |
# AND (not on hold_shelf OR is on hold_shelf for patron) |
362 |
# AND (not on hold_attached OR is on hold_attached for patron) |
363 |
# |
363 |
# |
364 |
# What this means is we are consciously allowing the patron to checkout (but not renew) an item that DOES |
364 |
# What this means is we are consciously allowing the patron to checkout (but not renew) an item that DOES |
365 |
# have non-W holds on it, but has not been "picked" from the stacks. That is to say, the |
365 |
# have non-W holds on it, but has not been "picked" from the stacks. That is to say, the |
Lines 371-383
sub hold_pickup_date {
Link Here
|
371 |
sub available { |
371 |
sub available { |
372 |
my ($self, $for_patron) = @_; |
372 |
my ($self, $for_patron) = @_; |
373 |
my $count = (defined $self->{pending_queue}) ? scalar @{$self->{pending_queue}} : 0; |
373 |
my $count = (defined $self->{pending_queue}) ? scalar @{$self->{pending_queue}} : 0; |
374 |
my $count2 = (defined $self->{hold_shelf} ) ? scalar @{$self->{hold_shelf} } : 0; |
374 |
my $count2 = (defined $self->{hold_attached} ) ? scalar @{$self->{hold_attached} } : 0; |
375 |
$debug and print STDERR "availability check: pending_queue size $count, hold_shelf size $count2\n"; |
375 |
$debug and print STDERR "availability check: pending_queue size $count, hold_attached size $count2\n"; |
376 |
if (defined($self->{borrowernumber})) { |
376 |
if (defined($self->{borrowernumber})) { |
377 |
($self->{borrowernumber} eq $for_patron) or return 0; |
377 |
($self->{borrowernumber} eq $for_patron) or return 0; |
378 |
return ($count ? 0 : 1); |
378 |
return ($count ? 0 : 1); |
379 |
} else { # not checked out |
379 |
} else { # not checked out |
380 |
($count2) and return $self->barcode_is_borrowernumber($for_patron, $self->{hold_shelf}[0]->{borrowernumber}); |
380 |
($count2) and return $self->barcode_is_borrowernumber($for_patron, $self->{hold_attached}[0]->{borrowernumber}); |
381 |
} |
381 |
} |
382 |
return 0; |
382 |
return 0; |
383 |
} |
383 |
} |