View | Details | Raw Unified | Return to bug 29083
Collapse All | Expand All

(-)a/Koha/Patron.pm (-35 / +8 lines)
Lines 983-1008 sub can_request_article { Link Here
983
983
984
=head3 article_requests
984
=head3 article_requests
985
985
986
my @requests = $borrower->article_requests();
986
    my $article_requests = $patron->article_requests;
987
my $requests = $borrower->article_requests();
988
987
989
Returns either a list of ArticleRequests objects,
988
Returns the patron article requests.
990
or an ArtitleRequests object, depending on the
991
calling context.
992
989
993
=cut
990
=cut
994
991
995
sub article_requests {
992
sub article_requests {
996
    my ( $self ) = @_;
993
    my ($self) = @_;
997
998
    $self->{_article_requests} ||= Koha::ArticleRequests->search({ borrowernumber => $self->borrowernumber() });
999
994
1000
    return $self->{_article_requests};
995
    return Koha::ArticleRequests->_new_from_dbic( scalar $self->_result->article_requests );
1001
}
996
}
1002
997
1003
=head3 article_requests_current
998
=head3 article_requests_current
1004
999
1005
my @requests = $patron->article_requests_current
1000
    my $current_article_requests = $patron->article_requests_current
1006
1001
1007
Returns the article requests associated with this patron that are incomplete
1002
Returns the article requests associated with this patron that are incomplete
1008
1003
Lines 1011-1033 Returns the article requests associated with this patron that are incomplete Link Here
1011
sub article_requests_current {
1006
sub article_requests_current {
1012
    my ( $self ) = @_;
1007
    my ( $self ) = @_;
1013
1008
1014
    $self->{_article_requests_current} ||= Koha::ArticleRequests->search(
1009
    return $self->article_requests->filter_by_current;
1015
        {
1016
            borrowernumber => $self->id(),
1017
            -or          => [
1018
                { status => Koha::ArticleRequest::Status::Requested },
1019
                { status => Koha::ArticleRequest::Status::Pending },
1020
                { status => Koha::ArticleRequest::Status::Processing }
1021
            ]
1022
        }
1023
    );
1024
1025
    return $self->{_article_requests_current};
1026
}
1010
}
1027
1011
1028
=head3 article_requests_finished
1012
=head3 article_requests_finished
1029
1013
1030
my @requests = $biblio->article_requests_finished
1014
    my $finished_article_requests = $biblio->article_requests_finished
1031
1015
1032
Returns the article requests associated with this patron that are completed
1016
Returns the article requests associated with this patron that are completed
1033
1017
Lines 1036-1052 Returns the article requests associated with this patron that are completed Link Here
1036
sub article_requests_finished {
1020
sub article_requests_finished {
1037
    my ( $self, $borrower ) = @_;
1021
    my ( $self, $borrower ) = @_;
1038
1022
1039
    $self->{_article_requests_finished} ||= Koha::ArticleRequests->search(
1023
    return $self->article_requests->filter_by_finished;
1040
        {
1041
            borrowernumber => $self->id(),
1042
            -or          => [
1043
                { status => Koha::ArticleRequest::Status::Completed },
1044
                { status => Koha::ArticleRequest::Status::Canceled }
1045
            ]
1046
        }
1047
    );
1048
1049
    return $self->{_article_requests_finished};
1050
}
1024
}
1051
1025
1052
=head3 add_enrolment_fee_if_needed
1026
=head3 add_enrolment_fee_if_needed
1053
- 

Return to bug 29083