Browse Source

Bug 27131: Add get_items_that_can_fill

Signed-off-by: Andrew Nugged <nugged@gmail.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
21.05.x
Jonathan Druart 3 years ago
parent
commit
919caa19c8
  1. 34
      Koha/Holds.pm
  2. 19
      circ/pendingreserves.pl

34
Koha/Holds.pm

@ -92,6 +92,40 @@ sub forced_hold_level {
return;
}
sub get_items_that_can_fill {
my ( $self ) = @_;
my @biblionumbers = $self->get_column('biblionumber');
my @branchtransfers = map { $_->itemnumber }
Koha::Item::Transfers->search(
{ datearrived => undef },
{
columns => ['itemnumber'],
collapse => 1,
}
);
my @waiting_holds = map { $_->itemnumber }
Koha::Holds->search(
{ 'found' => 'W' },
{
columns => ['itemnumber'],
collapse => 1,
}
);
return Koha::Items->search(
{
biblionumber => { in => \@biblionumbers },
itemlost => 0,
withdrawn => 0,
notforloan => 0,
onloan => undef,
itemnumber => { -not_in => [ @branchtransfers, @waiting_holds ] },
}
);
}
=head3 type
=cut

19
circ/pendingreserves.pl

@ -188,27 +188,14 @@ if ( C4::Context->preference('IndependentBranches') ){
}
# get all distinct unfulfilled reserves
my @biblionumbers = Koha::Holds->search(
my $holds = Koha::Holds->search(
{ %where },
{ join => 'itembib', alias => 'reserve', distinct => 1, columns => qw[me.biblionumber] }
)->get_column('biblionumber');
my @branchtransfers = map { $_->itemnumber } Koha::Item::Transfers->search({ datearrived => undef }, { columns => [ 'itemnumber' ], collapse => 1 });
my @waiting_holds = map { $_->itemnumber } Koha::Holds->search({'found' => 'W'}, { columns => [ 'itemnumber' ], collapse => 1 });
my @all_items = Koha::Items->search(
{
biblionumber => { in => \@biblionumbers },
itemlost => 0,
withdrawn => 0,
notforloan => 0,
onloan => undef,
itemnumber => { -not_in => [ @branchtransfers, @waiting_holds ] },
}
);
my @biblionumbers = $holds->get_column('biblionumber');
my $all_items;
foreach my $item ( @all_items ) {
foreach my $item ( $holds->get_items_that_can_fill ) {
push @{$all_items->{$item->biblionumber}}, $item;
}

Loading…
Cancel
Save