From cee9da8efcff2f854e108f75a28319c8d4768272 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Tue, 7 Dec 2021 14:38:06 +0000 Subject: [PATCH] Bug 33737: Add bookings tab to patron details This patch adds a new 'bookings' tab to the bottom of the members details pages. When a patron has any future or current bookings against their record the tab will display the number of bookings in the tab name and on clicking the tab a bookings table will display the current and upcoming bookings. Signed-off-by: Esther Melander Signed-off-by: Marcel de Rooy Signed-off-by: Katrin Fischer --- Koha/Bookings.pm | 4 - Koha/Patron.pm | 14 +++ .../prog/en/includes/patron-detail-tabs.inc | 12 +++ .../prog/en/modules/members/moremember.tt | 85 ++++++++++++++++++- 4 files changed, 110 insertions(+), 5 deletions(-) diff --git a/Koha/Bookings.pm b/Koha/Bookings.pm index 7f73a73ed3..b9bea5072c 100644 --- a/Koha/Bookings.pm +++ b/Koha/Bookings.pm @@ -32,8 +32,6 @@ Koha::Bookings - Koha Booking object set class =head2 Class Methods -=cut - =head3 filter_by_future $bookings->filter_by_future; @@ -49,8 +47,6 @@ sub filter_by_future { =head2 Internal Methods -=cut - =head3 _type =cut diff --git a/Koha/Patron.pm b/Koha/Patron.pm index d4b848db56..1524419a7d 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -1594,6 +1594,20 @@ sub curbside_pickups { return Koha::CurbsidePickups->_new_from_dbic($curbside_pickups_rs); } +=head3 bookings + + my $bookings = $item->bookings(); + +Returns the bookings for this patron. + +=cut + +sub bookings { + my ( $self, $params ) = @_; + my $bookings_rs = $self->_result->bookings->search($params); + return Koha::Bookings->_new_from_dbic( $bookings_rs ); +} + =head3 return_claims my $return_claims = $patron->return_claims diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-detail-tabs.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-detail-tabs.inc index b8ad2eb3b7..17f68d2ae0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-detail-tabs.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-detail-tabs.inc @@ -29,6 +29,10 @@ [% WRAPPER tab_item tabname= "holds" %] Holds ([% holds_count || 0 | html %]) [% END %] + [% WRAPPER tab_item tabname="bookings" %] + [% SET bookings_count = patron.bookings.filter_by_future.count %] + Bookings ([% bookings_count || 0 | html %]) + [% END %] [% END %] [% IF Koha.Preference('UseRecalls') %] @@ -221,6 +225,14 @@

Patron has nothing on hold.

[% END %] [% END # /tab_panel#holds %] + + [% WRAPPER tab_panel tabname="bookings" %] + [% IF ( bookings_count ) %] +
+ [% ELSE %] +

Patron has nothing booked.

+ [% END %] + [% END %] [% END %] [% IF Koha.Preference('UseRecalls') %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt index cd209c43cc..44098addba 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt @@ -696,7 +696,6 @@ [% INCLUDE 'patron-detail-tabs.inc' patronpage = "borrower" %] - @@ -711,6 +710,8 @@ [% INCLUDE 'modals/resolve_return_claim.inc' %] [% END %] + [% INCLUDE modals/cancel_booking.inc %] + [% MACRO jsinclude BLOCK %] [% INCLUDE 'datatables.inc' %] [% Asset.js("lib/jquery/plugins/rowGroup/dataTables.rowGroup.min.js") | $raw %] @@ -746,6 +747,8 @@ [% END %] [% Asset.js("js/holds.js") | $raw %] [% INCLUDE 'calendar.inc' %] + [% Asset.js("js/bookings.js") | $raw %] + [% Asset.js("js/cancel_booking_modal.js") | $raw %] [% INCLUDE 'str/members-menu.inc' %] [% Asset.js("js/members-menu.js") | $raw %] [% Asset.js("js/recalls.js") | $raw %] @@ -774,7 +777,87 @@ $('#guarantees_finesandcharges-tab').click(); }); + // Bookings + var bookings_table; + // Load bookings table on tab selection + $("#bookings-tab").on( "click", function(){ + if ( !bookings_table ) { + var today = new Date(); + var bookings_table_url = "/api/v1/bookings"; + bookings_table = $('#bookings-table').kohaTable({ + "ajax": { + "url": bookings_table_url + }, + "embed": [ + "biblio", + "item", + "patron" + ], + "columns": [{ + "data": "booking_id", + "title": "Booking ID", + "visible": false, + "searchable": false, + "orderable": false + }, + { + "data": "biblio.title", + "title": "Title", + "searchable": true, + "orderable": true, + "render": function(data,type,row,meta) { + return row.biblio.title; + } + }, + { + "data": "item.external_id", + "title": "Item", + "searchable": true, + "orderable": true, + "defaultContent": "Any item", + "render": function(data,type,row,meta) { + if ( row.item ) { + return row.item.external_id; + } else { + return null; + } + } + }, + { + "data": "start_date", + "title": "Start date", + "searchable": true, + "orderable": true, + "render": function(data, type, row, meta) { + return $datetime(row.start_date); + } + }, + { + "data": "end_date", + "title": "End date", + "searchable": true, + "orderable": true, + "render": function(data, type, row, meta) { + return $datetime(row.end_date); + } + }, + { + "data": "", + "title": "Actions", + "searchable": false, + "orderable": false, + "render": function(data, type, row, meta) { + var result = ''; + return result; + } + }] + }, [], 1, { patron_id: "[% patron.borrowernumber | html %]", end_date: { ">=": today.toISOString() } }); + }; + }); + // Bookings + }); + function uncheck_sibling(me){ nodename=me.getAttribute("name"); if (nodename =="barcodes[]"){ -- 2.39.5