From 902d7e4fb0fc9d3e98a6db5e7b3197ab43dccfac Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Mon, 15 May 2023 16:30:26 +0100 Subject: [PATCH] Bug 29002: Add bookings view This patch adds a new view to the biblio details page to display any bookings that may have been made. Test plan 1) Run through the steps from the previous patch 2) Note the appearance of a new 'Bookings' option in the left menu 3) Click the bookings option to load the new bookings page for the biblio 4) See that the booking from the previous patch appears on the page 5) Sign off Signed-off-by: Martin Renvoize Signed-off-by: Janet McGowan Signed-off-by: Caroline Cyr La Rose Signed-off-by: Laurence Rault Signed-off-by: Kyle M Hall Signed-off-by: Tomas Cohen Arazi --- api/v1/swagger/paths/biblios.yaml | 3 + bookings/list.pl | 46 ++++++ .../prog/en/includes/biblio-view-menu.inc | 8 + .../prog/en/modules/bookings/list.tt | 141 ++++++++++++++++++ .../prog/js/place_booking_modal.js | 8 +- 5 files changed, 205 insertions(+), 1 deletion(-) create mode 100755 bookings/list.pl create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/bookings/list.tt diff --git a/api/v1/swagger/paths/biblios.yaml b/api/v1/swagger/paths/biblios.yaml index c0eb8be6f8..55dfd57c73 100644 --- a/api/v1/swagger/paths/biblios.yaml +++ b/api/v1/swagger/paths/biblios.yaml @@ -342,6 +342,9 @@ x-koha-authorization: permissions: circulation: "1" + x-koha-embed: + - item + - patron "/biblios/{biblio_id}/checkouts": get: x-mojo-to: Biblios#get_checkouts diff --git a/bookings/list.pl b/bookings/list.pl new file mode 100755 index 0000000000..35979fdb33 --- /dev/null +++ b/bookings/list.pl @@ -0,0 +1,46 @@ +#!/usr/bin/perl + +# Copyright PTFS Europe 2021 +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; + +use CGI qw ( -utf8 ); + +use C4::Output qw( output_html_with_http_headers ); +use C4::Auth qw( get_template_and_user ); + +my $input = CGI->new; +my ( $template, $borrowernumber, $cookie, $flags ) = get_template_and_user( + { + template_name => "bookings/list.tt", + query => $input, + type => "intranet", + flagsrequired => { circulation => 1 }, + } +); + +my $biblionumber = $input->param('biblionumber'); +my $biblio = Koha::Biblios->find($biblionumber); + +$template->param( + biblionumber => $biblionumber, + biblio => $biblio, + bookingsview => 1, +); + +output_html_with_http_headers $input, $cookie, $template->output; 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 90b3287f1b..60ce97db40 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,6 +50,14 @@ Items + [%- IF ( bookingsview ) -%] +
  • + [%- ELSE -%] +
  • + [%- END -%] + Bookings +
  • + [%- IF ( CAN_user_reserveforothers ) -%] [%- IF ( holdsview ) -%]
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/bookings/list.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/bookings/list.tt new file mode 100644 index 0000000000..52834a6aab --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/bookings/list.tt @@ -0,0 +1,141 @@ +[% USE raw %] +[% USE Asset %] +[% USE KohaDates %] +[% SET footerjs = 1 %] +[% INCLUDE 'doc-head-open.inc' %] +Bookings for [% INCLUDE 'biblio-title-head.inc' %] › Bookings › Circulation › Koha +[% INCLUDE 'doc-head-close.inc' %] + + + + +[% INCLUDE 'header.inc' %] +[% INCLUDE 'circ-search.inc' %] + + + +
    +
    +
    +
    +
    +
    +
    + +
    +
    +

    Bookings for [% INCLUDE 'biblio-title-head.inc' %]

    +
    +
    +
    +
    +
    +
    + +
    + +
    +
    + + [% INCLUDE modals/place_booking.inc %] + + [% MACRO jsinclude BLOCK %] + [% Asset.js("lib/dayjs/dayjs.min.js") | $raw %] + [% INCLUDE 'datatables.inc' %] + [% INCLUDE 'columns_settings.inc' %] + [% INCLUDE 'calendar.inc' %] + [% INCLUDE 'select2.inc' %] + [% INCLUDE 'js-date-format.inc' %] + [% Asset.js("js/place_booking_modal.js") | $raw %] + + [% END %] + +[% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/place_booking_modal.js b/koha-tmpl/intranet-tmpl/prog/js/place_booking_modal.js index 17e034b34a..0748a6ee0c 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/place_booking_modal.js +++ b/koha-tmpl/intranet-tmpl/prog/js/place_booking_modal.js @@ -308,9 +308,15 @@ $("#placeBookingForm").on('submit', function(e) { ); posting.done(function(data) { + // Update bookings page as required + if (typeof bookings_table !== 'undefined' && bookings_table !== null) { + bookings_table.api().ajax.reload(); + } + + // Close modal $('#placeBookingModal').modal('hide'); - // Reset modal form + // Reset form $('#booking_patron_id').val(null).trigger('change'); $('#booking_item_id').val(null).trigger('change'); $("#period").get(0)._flatpickr.clear(); -- 2.39.5