Bugzilla – Attachment 162253 Details for
Bug 33737
Add bookings to patron details
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33737: Add bookings tab to patron details
Bug-33737-Add-bookings-tab-to-patron-details.patch (text/plain), 9.29 KB, created by
Martin Renvoize (ashimema)
on 2024-02-18 17:29:21 UTC
(
hide
)
Description:
Bug 33737: Add bookings tab to patron details
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2024-02-18 17:29:21 UTC
Size:
9.29 KB
patch
obsolete
>From 068df4b23b93e99bfdeb1a1d711cf542dc9a8f7c Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >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. >--- > Koha/Bookings.pm | 23 +++++ > Koha/Patron.pm | 14 +++ > .../prog/en/includes/patron-detail-tabs.inc | 11 +++ > .../prog/en/modules/members/moremember.tt | 85 ++++++++++++++++++- > members/moremember.pl | 5 ++ > 5 files changed, 137 insertions(+), 1 deletion(-) > >diff --git a/Koha/Bookings.pm b/Koha/Bookings.pm >index 44bc032b02d..00137489686 100644 >--- a/Koha/Bookings.pm >+++ b/Koha/Bookings.pm >@@ -20,6 +20,8 @@ package Koha::Bookings; > use Modern::Perl; > > use Koha::Database; >+use Koha::DateUtils qw(dt_from_string); >+ > use Koha::Booking; > > use base qw(Koha::Objects); >@@ -32,8 +34,29 @@ Koha::Bookings - Koha Booking object set class > > =head2 Class Methods > >+=head3 filter_by_active >+ >+ Koha::Bookings->filter_by_active; >+ >+Returns set of Koha bookings objects that are currently active. >+ >+Active is defined as having a end date in the future. >+ > =cut > >+sub filter_by_active { >+ my ($self) = @_; >+ >+ my $dtf = Koha::Database->new->schema->storage->datetime_parser; >+ my $now = $dtf->format_datetime(dt_from_string()); >+ >+ return $self->search( >+ { >+ end_date => { '>=' => $now } >+ } >+ ); >+} >+ > =head3 type > > =cut >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index 5b0bd9ea7f5..f0e3fd3610b 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -1591,6 +1591,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 8b4659064b1..430d7ef9ac2 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,9 @@ > [% WRAPPER tab_item tabname= "holds" %] > <span>Holds ([% holds_count || 0 | html %])</span> > [% END %] >+ [% WRAPPER tab_item tabname="bookings" %] >+ <span>Bookings ([% bookings_count || 0 | html %])</span> >+ [% END %] > [% END %] > > [% IF Koha.Preference('UseRecalls') %] >@@ -215,6 +218,14 @@ > <p>Patron has nothing on hold.</p> > [% END %] > [% END # /tab_panel#holds %] >+ >+ [% WRAPPER tab_panel tabname="bookings" %] >+ [% IF ( bookings_count ) %] >+ <table id="bookings-table" style="width: 100% !Important;"></table> >+ [% ELSE %] >+ <p>Patron has nothing booked.</p> >+ [% 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 bb230f3c3dc..664ed654f01 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >@@ -670,7 +670,6 @@ > </div> <!-- /div.row --> > > [% INCLUDE 'patron-detail-tabs.inc' patronpage = "borrower" %] >- > </main> > </div> <!-- /.col-sm-10.col-sm-push-2 --> > >@@ -685,6 +684,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 %] >@@ -720,6 +721,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 %] >@@ -748,7 +751,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 = '<button type="button" class="btn btn-default btn-xs cancel-action" data-toggle="modal" data-target="#cancelBookingModal" data-booking="'+row.booking_id+'"><i class="fa fa-trash" aria-hidden="true"></i> '+_("Cancel")+'</button>'; >+ return result; >+ } >+ }] >+ }, [], 1, { patron_id: "[% patron.borrowernumber | html %]", end_date: { ">=": today.toISOString() } }); >+ }; >+ }); >+ // Bookings >+ > }); >+ > function uncheck_sibling(me){ > nodename=me.getAttribute("name"); > if (nodename =="barcodes[]"){ >diff --git a/members/moremember.pl b/members/moremember.pl >index 2f70c487054..e5833a0b8d2 100755 >--- a/members/moremember.pl >+++ b/members/moremember.pl >@@ -217,6 +217,11 @@ if ( C4::Context->preference('UseRecalls') ) { > $template->param( waiting_recalls => $waiting_recalls ); > } > >+my $bookings = $patron->bookings->filter_by_active; >+$template->param( >+ bookings_count => $bookings->count() >+); >+ > my $no_issues_charge_guarantees = C4::Context->preference("NoIssuesChargeGuarantees"); > $no_issues_charge_guarantees = undef unless looks_like_number( $no_issues_charge_guarantees ); > if ( defined $no_issues_charge_guarantees ) { >-- >2.43.2
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 33737
:
161045
|
161046
|
161047
|
162253
|
162254
|
162255
|
162256
|
163557
|
164994
|
164995
|
164996
|
164997
|
166513
|
166514
|
166515
|
166516
|
166565
|
166566
|
166567
|
166568
|
166570
|
166573
|
166577