Bugzilla – Attachment 194510 Details for
Bug 42000
Add info about bookings on result page
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 42000: Add bookings count info on result page
Bug-42000-Add-bookings-count-info-on-result-page.patch (text/plain), 3.59 KB, created by
Thibaud Guillot (thibaud_g)
on 2026-03-05 14:09:09 UTC
(
hide
)
Description:
Bug 42000: Add bookings count info on result page
Filename:
MIME Type:
Creator:
Thibaud Guillot (thibaud_g)
Created:
2026-03-05 14:09:09 UTC
Size:
3.59 KB
patch
obsolete
>From b4faaf1b93a34625386c22af5f04eabf1cc50b10 Mon Sep 17 00:00:00 2001 >From: Thibaud Guillot <thibaud.guillot@biblibre.com> >Date: Thu, 5 Mar 2026 14:20:59 +0100 >Subject: [PATCH] Bug 42000: Add bookings count info on result page >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Display number of bookings if: >- items are bookable and syspref booking enabled of course >- at least on item is available for booking >- exclude past bookings and completed bookings (checked out normally) > >Test plan: > >1) Apply this patch and restart_all >2) Perform a search and see new bookings count info > >Display number of bookings if: >- items are bookable >- at least on item is available for booking >- exclude past bookings and completed bookings (checkouts normally) > >Sponsored by: Association de Gestion des Ã…uvres Sociales d'Inria (AGOS) >--- > catalogue/search.pl | 16 ++++++++++++++++ > .../prog/en/modules/catalogue/results.tt | 3 +++ > 2 files changed, 19 insertions(+) > >diff --git a/catalogue/search.pl b/catalogue/search.pl >index 957a9f9dcfc..ea3aa8fadf8 100755 >--- a/catalogue/search.pl >+++ b/catalogue/search.pl >@@ -160,6 +160,7 @@ use Koha::SearchFilters; > > use URI::Escape; > use JSON qw( decode_json encode_json ); >+use Koha::DateUtils qw( dt_from_string ); > > my $DisplayMultiPlaceHold = C4::Context->preference("DisplayMultiPlaceHold"); > >@@ -694,6 +695,21 @@ if ($hits) { > $line->{has_local_cover_image} = > $line->{biblio_object} ? $line->{biblio_object}->cover_images->count : 0; > } >+ >+ if ( $line->{biblio_object} ) { >+ my $bookable_items_count = $line->{biblio_object}->bookable_items->count; >+ if ( $bookable_items_count > 0 ) { >+ my $today = dt_from_string()->ymd; >+ $line->{future_bookings_count} = $line->{biblio_object}->bookings->search({ >+ start_date => { '>=' => $today }, >+ status => { '-not_in' => ['cancelled', 'completed'] } >+ })->count; >+ $line->{has_bookable_items} = 1; >+ } else { >+ $line->{future_bookings_count} = 0; >+ $line->{has_bookable_items} = 0; >+ } >+ } > } > my ( > $page_numbers, $hits_to_paginate, $pages, $current_page_number, $previous_page_offset, $next_page_offset, >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt >index 6ac67649634..8c5247bdd22 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt >@@ -708,6 +708,9 @@ > [% ELSE %] > <span>Holds ([% SEARCH_RESULT.biblio_object.holds.count | html %])</span> > [% END %] >+ [% IF Koha.Preference('EnableBooking') && CAN_user_circulate_manage_bookings && SEARCH_RESULT.has_bookable_items %] >+ | <a href="/cgi-bin/koha/bookings/list.pl?biblionumber=[% SEARCH_RESULT.biblionumber | html %]#bookings">Bookings ([% SEARCH_RESULT.future_bookings_count | html %])</a> >+ [% END %] > [% END # /IF SEARCH_RESULT.norequests %] > [% IF Koha.Preference('UseRecalls') and CAN_user_recalls %] > | >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 42000
: 194510