From 2b5bd4c9be9b752f5916c806362cb959db30e72b Mon Sep 17 00:00:00 2001 From: Petro Vashchuk Date: Wed, 5 May 2021 16:30:26 +0300 Subject: [PATCH] Bug 28286: show "Place hold" button if item is holdable This patch adds "filter_by_for_hold" method in "Items.pm" and uses it in "cat-toolbar.inc" instead of "filter_by_for_load". To reproduce the bug: 1) go to /cgi-bin/koha/catalogue/detail.pl?biblionumber=XXX that has item with notforloan value set as "Ordered" (-1) 2) see that button "Place hold" is not present 3) apply the patch 4) refresh the page and ensure that "Place hold" button appears even if item is "Ordered" --- Koha/Items.pm | 15 ++++++++++++++- .../prog/en/includes/cat-toolbar.inc | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Koha/Items.pm b/Koha/Items.pm index 2d81a24c59..ead1086d21 100644 --- a/Koha/Items.pm +++ b/Koha/Items.pm @@ -47,7 +47,20 @@ Return the items of the set that are loanable sub filter_by_for_loan { my ($self) = @_; - return $self->search( { notforloan => [ 0, undef ] } ); + return $self->search( { notforloan => 0 } ); +} + +=head3 filter_by_for_hold + + my $filtered_items = $items->filter_by_for_hold; + +Return the items of the set that are holdable + +=cut + +sub filter_by_for_hold { + my ($self) = @_; + return $self->search( { notforloan => { '<' => 1 } } ); # items with negative or zero notforloan value are holdable } =head3 filter_by_visible_in_opac diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc index a467c7a27f..e0ba1e8b18 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc @@ -168,7 +168,7 @@ CAN_user_serials_create_subscription ) %] [% IF ( CAN_user_reserveforothers ) %] [%# biblio.items.filter_by_for_loan.count %] [% SET items = biblio.items %] - [% IF Context.Scalar(Context.Scalar(items, "filter_by_for_loan"), "count") %] + [% IF Context.Scalar(Context.Scalar(items, "filter_by_for_hold"), "count") %] [% IF ( holdfor ) %]