From 295506bb7efe639c3e68fe6c395ab91ee2474af8 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 | 13 +++++++++++++ .../intranet-tmpl/prog/en/includes/cat-toolbar.inc | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Koha/Items.pm b/Koha/Items.pm index 2d81a24c59..0d661580ad 100644 --- a/Koha/Items.pm +++ b/Koha/Items.pm @@ -50,6 +50,19 @@ sub filter_by_for_loan { return $self->search( { notforloan => [ 0, undef ] } ); } +=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 } } ); +} + =head3 filter_by_visible_in_opac my $filered_items = $items->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 ) %]