X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=Koha%2FPatron.pm;h=24daaeeb96a370d0b03c577f8d2ad1297beeaab8;hb=bf1563e60b31244f4ea977eb84954fb8501ed59a;hp=93c2186dbc1caa6fb42194d9d8377e90890e2b1e;hpb=d2a4c327466f448d2018b1dbf537d9f588d96604;p=koha-ffzg.git diff --git a/Koha/Patron.pm b/Koha/Patron.pm index 93c2186dbc..24daaeeb96 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -359,6 +359,73 @@ sub move_to_deleted { return Koha::Database->new->schema->resultset('Deletedborrower')->create($patron_infos); } +=head3 article_requests + +my @requests = $borrower->article_requests(); +my $requests = $borrower->article_requests(); + +Returns either a list of ArticleRequests objects, +or an ArtitleRequests object, depending on the +calling context. + +=cut + +sub article_requests { + my ( $self ) = @_; + + $self->{_article_requests} ||= Koha::ArticleRequests->search({ borrowernumber => $self->borrowernumber() }); + + return $self->{_article_requests}; +} + +=head3 article_requests_current + +my @requests = $patron->article_requests_current + +Returns the article requests associated with this patron that are incomplete + +=cut + +sub article_requests_current { + my ( $self ) = @_; + + $self->{_article_requests_current} ||= Koha::ArticleRequests->search( + { + borrowernumber => $self->id(), + -or => [ + { status => Koha::ArticleRequest::Status::Pending }, + { status => Koha::ArticleRequest::Status::Processing } + ] + } + ); + + return $self->{_article_requests_current}; +} + +=head3 article_requests_finished + +my @requests = $biblio->article_requests_finished + +Returns the article requests associated with this patron that are completed + +=cut + +sub article_requests_finished { + my ( $self, $borrower ) = @_; + + $self->{_article_requests_finished} ||= Koha::ArticleRequests->search( + { + borrowernumber => $self->id(), + -or => [ + { status => Koha::ArticleRequest::Status::Completed }, + { status => Koha::ArticleRequest::Status::Canceled } + ] + } + ); + + return $self->{_article_requests_finished}; +} + =head3 type =cut