Bug 14699: Reword "Select all/Clear all" and change their behaviour
[koha.git] / Koha / Patrons.pm
blob431817902f3219e31a26b86801b4dd0d91ffaa8d
1 package Koha::Patrons;
3 # Copyright ByWater Solutions 2014
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 3 of the License, or (at your option) any later
10 # version.
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 use Modern::Perl;
22 use Carp;
24 use Koha::Database;
26 use Koha::ArticleRequests;
27 use Koha::ArticleRequest::Status;
28 use Koha::Patron;
30 use base qw(Koha::Objects);
32 =head1 NAME
34 Koha::Patron - Koha Patron Object class
36 =head1 API
38 =head2 Class Methods
40 =cut
42 =head3 search_housebound_choosers
44 Returns all Patrons which are Housebound choosers.
46 =cut
48 sub search_housebound_choosers {
49 my ( $self ) = @_;
50 my $cho = $self->_resultset
51 ->search_related('housebound_role', {
52 housebound_chooser => 1,
53 })->search_related('borrowernumber');
54 return Koha::Patrons->_new_from_dbic($cho);
57 =head3 search_housebound_deliverers
59 Returns all Patrons which are Housebound deliverers.
61 =cut
63 sub search_housebound_deliverers {
64 my ( $self ) = @_;
65 my $del = $self->_resultset
66 ->search_related('housebound_role', {
67 housebound_deliverer => 1,
68 })->search_related('borrowernumber');
69 return Koha::Patrons->_new_from_dbic($del);
72 =head3 guarantor
74 Returns a Koha::Patron object for this borrower's guarantor
76 =cut
78 sub guarantor {
79 my ( $self ) = @_;
81 return Koha::Patrons->find( $self->guarantorid() );
84 =head3 article_requests
86 my @requests = $borrower->article_requests();
87 my $requests = $borrower->article_requests();
89 Returns either a list of ArticleRequests objects,
90 or an ArtitleRequests object, depending on the
91 calling context.
93 =cut
95 sub article_requests {
96 my ( $self ) = @_;
98 $self->{_article_requests} ||= Koha::ArticleRequests->search({ borrowernumber => $self->borrowernumber() });
100 return $self->{_article_requests};
103 =head3 article_requests_current
105 my @requests = $patron->article_requests_current
107 Returns the article requests associated with this patron that are incomplete
109 =cut
111 sub article_requests_current {
112 my ( $self ) = @_;
114 $self->{_article_requests_current} ||= Koha::ArticleRequests->search(
116 borrowernumber => $self->id(),
117 -or => [
118 { status => Koha::ArticleRequest::Status::Pending },
119 { status => Koha::ArticleRequest::Status::Processing }
124 return $self->{_article_requests_current};
127 =head3 article_requests_finished
129 my @requests = $biblio->article_requests_finished
131 Returns the article requests associated with this patron that are completed
133 =cut
135 sub article_requests_finished {
136 my ( $self, $borrower ) = @_;
138 $self->{_article_requests_finished} ||= Koha::ArticleRequests->search(
140 borrowernumber => $self->id(),
141 -or => [
142 { status => Koha::ArticleRequest::Status::Completed },
143 { status => Koha::ArticleRequest::Status::Canceled }
148 return $self->{_article_requests_finished};
151 =head3 type
153 =cut
155 sub _type {
156 return 'Borrower';
159 sub object_class {
160 return 'Koha::Patron';
163 =head1 AUTHOR
165 Kyle M Hall <kyle@bywatersolutions.com>
167 =cut