Browse Source

Bug 20936: (follow-up) add biblio and item relation to old holds and set a limit on search holds

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
20.11.x
Agustin Moyano 4 years ago
committed by Jonathan Druart
parent
commit
d812bf9d27
  1. 24
      Koha/Schema/Result/OldReserve.pm
  2. 32
      opac/opac-holdshistory.pl

24
Koha/Schema/Result/OldReserve.pm

@ -324,6 +324,30 @@ __PACKAGE__->belongs_to(
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2020-11-06 11:00:40
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:7weIpuc0RpZ/MxFn94E8dg
__PACKAGE__->belongs_to(
"item",
"Koha::Schema::Result::Item",
{ itemnumber => "itemnumber" },
{
is_deferrable => 1,
join_type => "LEFT",
on_delete => "CASCADE",
on_update => "CASCADE",
},
);
__PACKAGE__->belongs_to(
"biblio",
"Koha::Schema::Result::Biblio",
{ biblionumber => "biblionumber" },
{
is_deferrable => 1,
join_type => "LEFT",
on_delete => "CASCADE",
on_update => "CASCADE",
},
);
__PACKAGE__->add_columns(
'+item_level_hold' => { is_boolean => 1 },
'+lowestPriority' => { is_boolean => 1 },

32
opac/opac-holdshistory.pl

@ -24,6 +24,8 @@ use C4::Auth;
use C4::Output;
use Koha::Patrons;
use Koha::Holds;
use Koha::Old::Holds;
my $query = CGI->new;
my @all_holds;
@ -42,10 +44,26 @@ my ( $template, $patron_id, $cookie ) = get_template_and_user(
}
);
my $patron = Koha::Patrons->find( $patron_id );
my $patron = Koha::Patrons->find($patron_id);
my $holds = $patron->holds;
my $old_holds = $patron->old_holds;
my $sort = $query->param('sort');
$sort = 'reservedate' unless $sort;
my $unlimit = $query->param('unlimit');
my $ops = {
prefetch => ['biblio', 'item'],
order_by => $sort
};
$ops->{rows} = 50 unless $unlimit;
my $holds = Koha::Holds->search({
borrowernumber => $patron_id
}, $ops);
my $old_holds = Koha::Old::Holds->search({
borrowernumber => $patron_id
}, $ops);
while (my $hold = $holds->next) {
push @all_holds, $hold;
@ -55,19 +73,13 @@ while (my $hold = $old_holds->next) {
push @all_holds, $hold;
}
my $sort = $query->param('sort');
$sort = 'reservedate' unless $sort;
if($sort eq 'reservedate') {
@all_holds = sort {$b->$sort cmp $a->$sort} @all_holds;
} else {
my ($obj, $col) = split /\./, $sort;
@all_holds = sort {$a->$obj->$col cmp $b->$obj->$col} @all_holds;
@all_holds = sort { ( $a->$obj && $a->$obj->$col || '' ) cmp ( $b->$obj && $b->$obj->$col || '' ) } @all_holds;
}
my $unlimit = $query->param('unlimit');
unless($unlimit) {
@all_holds = splice(@all_holds, 0, 50);
}

Loading…
Cancel
Save