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 <esther@bywatersolutions.com> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
parent
f30293fcc1
commit
cee9da8efc
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -29,6 +29,10 @@
|
|||
[% WRAPPER tab_item tabname= "holds" %]
|
||||
<span>Holds ([% holds_count || 0 | html %])</span>
|
||||
[% END %]
|
||||
[% WRAPPER tab_item tabname="bookings" %]
|
||||
[% SET bookings_count = patron.bookings.filter_by_future.count %]
|
||||
<span>Bookings ([% bookings_count || 0 | html %])</span>
|
||||
[% END %]
|
||||
[% END %]
|
||||
|
||||
[% IF Koha.Preference('UseRecalls') %]
|
||||
|
|
@ -221,6 +225,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') %]
|
||||
|
|
|
|||
|
|
@ -696,7 +696,6 @@
|
|||
</div> <!-- /div.row -->
|
||||
|
||||
[% INCLUDE 'patron-detail-tabs.inc' patronpage = "borrower" %]
|
||||
|
||||
</main>
|
||||
</div> <!-- /.col-sm-10.col-sm-push-2 -->
|
||||
|
||||
|
|
@ -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 = '<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[]"){
|
||||
|
|
|
|||
Loading…
Reference in New Issue