Main Koha release repository https://koha-community.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

67 lines
1.7 KiB

  1. package Koha::Template::Plugin::Biblio;
  2. # Copyright ByWater Solutions 2015
  3. # This file is part of Koha.
  4. #
  5. # Koha is free software; you can redistribute it and/or modify it
  6. # under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 3 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # Koha is distributed in the hope that it will be useful, but
  11. # WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with Koha; if not, see <http://www.gnu.org/licenses>.
  17. use Modern::Perl;
  18. use Template::Plugin;
  19. use base qw( Template::Plugin );
  20. use Koha::Holds;
  21. use Koha::Biblios;
  22. use Koha::Patrons;
  23. use Koha::ArticleRequests;
  24. use Koha::ArticleRequest::Status;
  25. sub HoldsCount {
  26. my ( $self, $biblionumber ) = @_;
  27. my $holds = Koha::Holds->search( { biblionumber => $biblionumber } );
  28. return $holds->count();
  29. }
  30. sub ArticleRequestsActiveCount {
  31. my ( $self, $biblionumber ) = @_;
  32. my $ar = Koha::ArticleRequests->search(
  33. {
  34. biblionumber => $biblionumber,
  35. status => [
  36. -or => [
  37. status => Koha::ArticleRequest::Status::Pending,
  38. status => Koha::ArticleRequest::Status::Processing
  39. ]
  40. ]
  41. }
  42. );
  43. return $ar->count();
  44. }
  45. sub CanArticleRequest {
  46. my ( $self, $biblionumber, $borrowernumber ) = @_;
  47. my $biblio = Koha::Biblios->find( $biblionumber );
  48. my $borrower = Koha::Patrons->find( $borrowernumber );
  49. return $biblio ? $biblio->can_article_request( $borrower ) : 0;
  50. }
  51. 1;