# 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 },
use C4::Output;
use Koha::Patrons;
+use Koha::Holds;
+use Koha::Old::Holds;
my $query = CGI->new;
my @all_holds;
}
);
-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;
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);
}