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
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.
26 use Koha
::ArticleRequests
;
27 use Koha
::ArticleRequest
::Status
;
30 use base
qw(Koha::Objects);
34 Koha::Patron - Koha Patron Object class
42 =head3 search_housebound_choosers
44 Returns all Patrons which are Housebound choosers.
48 sub search_housebound_choosers
{
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.
63 sub search_housebound_deliverers
{
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);
74 Returns a Koha::Patron object for this borrower's guarantor
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
95 sub article_requests
{
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
111 sub article_requests_current
{
114 $self->{_article_requests_current
} ||= Koha
::ArticleRequests
->search(
116 borrowernumber
=> $self->id(),
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
135 sub article_requests_finished
{
136 my ( $self, $borrower ) = @_;
138 $self->{_article_requests_finished
} ||= Koha
::ArticleRequests
->search(
140 borrowernumber
=> $self->id(),
142 { status
=> Koha
::ArticleRequest
::Status
::Completed
},
143 { status
=> Koha
::ArticleRequest
::Status
::Canceled
}
148 return $self->{_article_requests_finished
};
160 return 'Koha::Patron';
165 Kyle M Hall <kyle@bywatersolutions.com>