1 package Koha::Template::Plugin::Biblio;
3 # Copyright ByWater Solutions 2015
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
23 use base qw( Template::Plugin );
29 use Koha::ArticleRequests;
32 use Koha::DateUtils qw(dt_from_string);
35 my ( $self, $biblionumber ) = @_;
37 my $holds = Koha::Holds->search( { biblionumber => $biblionumber } );
39 return $holds->count();
42 sub ArticleRequestsActiveCount {
43 my ( $self, $biblionumber ) = @_;
45 my $ar = Koha::ArticleRequests->search(
47 biblionumber => $biblionumber
54 sub CanArticleRequest {
55 my ( $self, $biblionumber, $borrowernumber ) = @_;
57 my $biblio = Koha::Biblios->find( $biblionumber );
58 my $borrower = Koha::Patrons->find( $borrowernumber );
60 return $biblio ? $biblio->can_article_request( $borrower ) : 0;
64 my ( $self, $biblionumber ) = @_;
66 my $recalls = Koha::Recalls->search({ biblio_id => $biblionumber, completed => 0 });
68 return $recalls->count;
72 my ( $self, $biblionumber ) = @_;
74 my $biblio = Koha::Biblios->find($biblionumber);
75 return $biblio->bookable_items->count ? 1 : 0;
79 my ( $self, $biblionumber ) = @_;
81 my $biblio = Koha::Biblios->find($biblionumber);
83 my $now = dt_from_string;
84 my $dtf = Koha::Database->new->schema->storage->datetime_parser;
85 return $biblio->bookings->search( { start_date => { '>' => $dtf->format_datetime($now) } } )->count;