From bd987c7046d335a9525b65d12601be43e3bddccb Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 12 Jan 2024 14:02:29 +0100 Subject: [PATCH] Bug 35787: Remove Koha::Template::Plugin::Biblio::CanBook We can replace it with biblio.items.filter_by_bookable, no need to have this TT method. Additionally there was no test for it. Test plan: Make sure the Bookings tab on the left of the biblio detail page is displayed when needed. Note that there is also a "Place booking" button that should appear in the toolbar. Signed-off-by: Tomas Cohen Arazi Signed-off-by: Katrin Fischer --- Koha/Template/Plugin/Biblio.pm | 8 -------- .../intranet-tmpl/prog/en/includes/biblio-view-menu.inc | 2 +- koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc | 2 +- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/Koha/Template/Plugin/Biblio.pm b/Koha/Template/Plugin/Biblio.pm index d23eb094b6..457227c9d7 100644 --- a/Koha/Template/Plugin/Biblio.pm +++ b/Koha/Template/Plugin/Biblio.pm @@ -71,14 +71,6 @@ sub RecallsCount { return $recalls->count; } -sub CanBook { - my ( $self, $biblionumber ) = @_; - - my $biblio = Koha::Biblios->find($biblionumber); - return 0 unless $biblio; - return $biblio->bookable_items->count ? 1 : 0; -} - sub BookingsCount { my ( $self, $biblionumber ) = @_; diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/biblio-view-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/biblio-view-menu.inc index c7fbc727e8..e75e1954ff 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/biblio-view-menu.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/biblio-view-menu.inc @@ -50,7 +50,7 @@ Items - [% IF ( Biblio.CanBook(biblio_object_id) && CAN_user_circulate_manage_bookings ) %] + [% IF ( CAN_user_circulate_manage_bookings && biblio.items.filter_by_bookable.count ) %] [%- IF ( bookingsview ) -%]
  • [%- ELSE -%] 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 de8f090b1b..2832bd2a84 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc @@ -235,7 +235,7 @@ [% END %] [% END %] -[% IF ( CAN_user_circulate_manage_bookings && Biblio.CanBook(biblionumber) ) %] +[% IF ( CAN_user_circulate_manage_bookings && biblio.items.filter_by_bookable.count ) %]
    [% END %] -- 2.39.5