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

(-)a/Koha/Patron.pm (-28 lines)
Lines 1015-1048 sub article_requests { Link Here
1015
    return Koha::ArticleRequests->_new_from_dbic( scalar $self->_result->article_requests );
1015
    return Koha::ArticleRequests->_new_from_dbic( scalar $self->_result->article_requests );
1016
}
1016
}
1017
1017
1018
=head3 article_requests_current
1019
1020
    my $current_article_requests = $patron->article_requests_current
1021
1022
Returns the article requests associated with this patron that are incomplete
1023
1024
=cut
1025
1026
sub article_requests_current {
1027
    my ( $self ) = @_;
1028
1029
    return $self->article_requests->filter_by_current;
1030
}
1031
1032
=head3 article_requests_finished
1033
1034
    my $finished_article_requests = $biblio->article_requests_finished
1035
1036
Returns the article requests associated with this patron that are completed
1037
1038
=cut
1039
1040
sub article_requests_finished {
1041
    my ( $self ) = @_;
1042
1043
    return $self->article_requests->filter_by_finished;
1044
}
1045
1046
=head3 add_enrolment_fee_if_needed
1018
=head3 add_enrolment_fee_if_needed
1047
1019
1048
my $enrolment_fee = $patron->add_enrolment_fee_if_needed($renewal);
1020
my $enrolment_fee = $patron->add_enrolment_fee_if_needed($renewal);
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-article-requests.inc (-2 / +4 lines)
Lines 1-5 Link Here
1
[% USE Context %]
2
[% SET current_article_requests = Context.Scalar( Context.Scalar( patron, 'article_requests' ), 'filter_by_current' ) %]
1
<div id="article-requests">
3
<div id="article-requests">
2
[% IF patron.article_requests_current.count %]
4
[% IF current_article_requests.count > 0 %]
3
    <table id="article-requests-table" class="table table-bordered table-striped">
5
    <table id="article-requests-table" class="table table-bordered table-striped">
4
        <thead>
6
        <thead>
5
            <tr>
7
            <tr>
Lines 20-26 Link Here
20
        </thead>
22
        </thead>
21
23
22
        <tbody>
24
        <tbody>
23
            [% FOREACH ar IN patron.article_requests_current %]
25
            [% FOREACH ar IN current_article_requests %]
24
                <tr>
26
                <tr>
25
                    <td class="article-request-record-title">
27
                    <td class="article-request-record-title">
26
                        <a class="article-request-title" href="/cgi-bin/koha/circ/request-article.pl?biblionumber=[% ar.biblionumber | html %]">
28
                        <a class="article-request-title" href="/cgi-bin/koha/circ/request-article.pl?biblionumber=[% ar.biblionumber | html %]">
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (-1 / +3 lines)
Lines 1-5 Link Here
1
[% USE raw %]
1
[% USE raw %]
2
[% USE Asset %]
2
[% USE Asset %]
3
[% USE Context %]
3
[% USE Koha %]
4
[% USE Koha %]
4
[% USE Branches %]
5
[% USE Branches %]
5
[% USE KohaDates %]
6
[% USE KohaDates %]
Lines 780-787 Link Here
780
                            </li>
781
                            </li>
781
782
782
                            [% IF Koha.Preference('ArticleRequests') %]
783
                            [% IF Koha.Preference('ArticleRequests') %]
784
                                [% SET current_article_requests = Context.Scalar( Context.Scalar( patron, 'article_requests' ), 'filter_by_current' ) %]
783
                                <li>
785
                                <li>
784
                                    <a href="#article-requests" id="article-requests-tab"> [% patron.article_requests_current.count | html %] Article requests</a>
786
                                    <a href="#article-requests" id="article-requests-tab"> [% current_article_requests.count | html %] Article requests</a>
785
                                </li>
787
                                </li>
786
                            [% END %]
788
                            [% END %]
787
789
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt (-1 / +3 lines)
Lines 1-5 Link Here
1
[% USE raw %]
1
[% USE raw %]
2
[% USE Asset %]
2
[% USE Asset %]
3
[% USE Context %]
3
[% USE Koha %]
4
[% USE Koha %]
4
[% USE Branches %]
5
[% USE Branches %]
5
[% USE ItemTypes %]
6
[% USE ItemTypes %]
Lines 695-702 Link Here
695
                                </li>
696
                                </li>
696
                            [% END %]
697
                            [% END %]
697
                            [% IF Koha.Preference('ArticleRequests') %]
698
                            [% IF Koha.Preference('ArticleRequests') %]
699
                                [% SET article_requests = Context.Scalar( Context.Scalar( patron, 'article_requests' ), 'filter_by_current') %]
698
                                <li>
700
                                <li>
699
                                    <a href="#article-requests" id="article-requests-tab"> [% patron.article_requests_current.count | html %] Article requests</a>
701
                                    <a href="#article-requests" id="article-requests-tab"> [% article_requests.count | html %] Article requests</a>
700
                                </li>
702
                                </li>
701
                            [% END %]
703
                            [% END %]
702
704
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt (-1 / +1 lines)
Lines 866-872 Link Here
866
                                    <caption class="sr-only">Article requests</caption>
866
                                    <caption class="sr-only">Article requests</caption>
867
                                    <tr><td>You have no article requests currently.</td></tr>
867
                                    <tr><td>You have no article requests currently.</td></tr>
868
                                </table>
868
                                </table>
869
                            [% END # IF article_requests_current.count %]
869
                            [% END # IF current_article_requests_count %]
870
                        </div> <!-- / #opac-user-article-requests -->
870
                        </div> <!-- / #opac-user-article-requests -->
871
                    [% END %]
871
                    [% END %]
872
872
(-)a/opac/opac-user.pl (-1 / +1 lines)
Lines 387-393 if ( C4::Context->preference('AllowPatronToSetFinesVisibilityForGuarantor') Link Here
387
}
387
}
388
388
389
if ( C4::Context->preference("ArticleRequests") ) {
389
if ( C4::Context->preference("ArticleRequests") ) {
390
    my @current_article_requests = $patron->article_requests_current->as_list;
390
    my @current_article_requests = $patron->article_requests->filter_by_current->as_list;
391
    $template->param(
391
    $template->param(
392
        current_article_requests => \@current_article_requests,
392
        current_article_requests => \@current_article_requests,
393
        current_article_requests_count => scalar @current_article_requests,
393
        current_article_requests_count => scalar @current_article_requests,
(-)a/t/db_dependent/Koha/Patron.t (-86 / +1 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 12;
22
use Test::More tests => 10;
23
use Test::Exception;
23
use Test::Exception;
24
use Test::Warn;
24
use Test::Warn;
25
25
Lines 846-932 subtest 'article_requests() tests' => sub { Link Here
846
846
847
    $schema->storage->txn_rollback;
847
    $schema->storage->txn_rollback;
848
};
848
};
849
850
subtest 'article_requests_current() tests' => sub {
851
852
    plan tests => 7;
853
854
    $schema->storage->txn_begin;
855
856
    my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
857
    my $item   = $builder->build_sample_item;
858
859
    my $article_request = Koha::ArticleRequest->new(
860
        {
861
            borrowernumber => $patron->id,
862
            biblionumber   => $item->biblionumber,
863
            itemnumber     => $item->itemnumber,
864
            title          => "Boo",
865
        }
866
    )->request();
867
868
    my $ar = $patron->article_requests();
869
    is( ref($ar), 'Koha::ArticleRequests',
870
        '$patron->article_requests returns Koha::ArticleRequests object' );
871
    is( $ar->next->id, $article_request->id,
872
        'Returned article request matches' );
873
874
    is( $patron->article_requests_current()->count(),
875
        1, 'Open request returned for article_requests_current' );
876
    $article_request->set_pending();
877
    is( $patron->article_requests_current()->count(),
878
        1, 'Pending request returned for article_requests_current' );
879
    $article_request->process();
880
    is( $patron->article_requests_current()->count(),
881
        1, 'Processing request returned for article_requests_current' );
882
    $article_request->complete();
883
    is( $patron->article_requests_current()->count(),
884
        0, 'Completed request not returned for article_requests_current' );
885
    $article_request->cancel();
886
    is( $patron->article_requests_current()->count(),
887
        0, 'Canceled request not returned for article_requests_current' );
888
889
    $schema->storage->txn_rollback;
890
};
891
892
subtest 'article_requests_finished() tests' => sub {
893
894
    plan tests => 7;
895
896
    $schema->storage->txn_begin;
897
898
    my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
899
    my $item   = $builder->build_sample_item;
900
901
    my $article_request = Koha::ArticleRequest->new(
902
        {
903
            borrowernumber => $patron->id,
904
            biblionumber   => $item->biblionumber,
905
            itemnumber     => $item->itemnumber,
906
            title          => "Boo",
907
        }
908
    )->request();
909
910
    my $ar = $patron->article_requests();
911
    is( ref($ar), 'Koha::ArticleRequests',
912
        '$patron->article_requests returns Koha::ArticleRequests object' );
913
    is( $ar->next->id, $article_request->id,
914
        'Returned article request matches' );
915
916
    is( $patron->article_requests_finished->count,
917
        0, 'Open request returned for article_requests_finished' );
918
    $article_request->set_pending();
919
    is( $patron->article_requests_finished->count,
920
        0, 'Pending request returned for article_requests_finished' );
921
    $article_request->process();
922
    is( $patron->article_requests_finished->count,
923
        0, 'Processing request returned for article_requests_finished' );
924
    $article_request->complete();
925
    is( $patron->article_requests_finished->count,
926
        1, 'Completed request returned for article_requests_finished' );
927
    $article_request->cancel();
928
    is( $patron->article_requests_finished->count,
929
        1, 'Cancelled request not returned for article_requests_finished' );
930
931
    $schema->storage->txn_rollback;
932
};
933
- 

Return to bug 29083