Bug 29002: (follow-up) Add bookings count to side menu
This patch adds booking counts to the bookings option in the side menu for biblio display pages. Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Janet McGowan <janet.mcgowan@ptfs-europe.com> Signed-off-by: Caroline Cyr La Rose <caroline.cyr-la-rose@inlibro.com> Signed-off-by: Laurence Rault <laurence.rault@biblibre.com> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
674d240f03
commit
6bfe8467cb
4 changed files with 22 additions and 1 deletions
|
@ -24,10 +24,13 @@ use base qw( Template::Plugin );
|
|||
|
||||
use Koha::Holds;
|
||||
use Koha::Biblios;
|
||||
use Koha::Database;
|
||||
use Koha::Patrons;
|
||||
use Koha::ArticleRequests;
|
||||
use Koha::Recalls;
|
||||
|
||||
use Koha::DateUtils qw(dt_from_string);
|
||||
|
||||
sub HoldsCount {
|
||||
my ( $self, $biblionumber ) = @_;
|
||||
|
||||
|
@ -72,4 +75,18 @@ sub CanBook {
|
|||
return $biblio->bookable_items->count ? 1 : 0;
|
||||
}
|
||||
|
||||
sub BookingsCount {
|
||||
my ( $self, $biblionumber ) = @_;
|
||||
|
||||
my $biblio = Koha::Biblios->find($biblionumber);
|
||||
|
||||
my $now = dt_from_string;
|
||||
my $dtf = Koha::Database->new->schema->storage->datetime_parser;
|
||||
return $biblio->bookings->search(
|
||||
{
|
||||
start_date => { '>' => $dtf->format_datetime($now) }
|
||||
}
|
||||
)->count;
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
[%- ELSE -%]
|
||||
<li>
|
||||
[%- END -%]
|
||||
<a href="/cgi-bin/koha/bookings/list.pl?biblionumber=[% biblio_object_id | url %]">Bookings</a>
|
||||
<a href="/cgi-bin/koha/bookings/list.pl?biblionumber=[% biblio_object_id | url %]">Bookings (<span class="bookings_count">[% Biblio.BookingsCount( biblio_object_id ) | html %]</span>)</a>
|
||||
</li>
|
||||
[% END %]
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ $("#cancelBookingForm").on('submit', function(e) {
|
|||
if (timeline) {
|
||||
timeline.itemsData.remove(Number(booking_id));
|
||||
}
|
||||
$('.bookings_count').html(parseInt($('.bookings_count').html(), 10)-1);
|
||||
$('#cancelBookingModal').modal('hide');
|
||||
});
|
||||
|
||||
|
|
|
@ -326,6 +326,9 @@ $("#placeBookingForm").on('submit', function(e) {
|
|||
});
|
||||
}
|
||||
|
||||
// Update bookings counts
|
||||
$('.bookings_count').html(parseInt($('.bookings_count').html(), 10)+1);
|
||||
|
||||
// Close modal
|
||||
$('#placeBookingModal').modal('hide');
|
||||
|
||||
|
|
Loading…
Reference in a new issue