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

(-)a/Koha/Biblio.pm (-28 lines)
Lines 354-387 sub article_requests { Link Here
354
    return Koha::ArticleRequests->_new_from_dbic( scalar $self->_result->article_requests );
354
    return Koha::ArticleRequests->_new_from_dbic( scalar $self->_result->article_requests );
355
}
355
}
356
356
357
=head3 article_requests_current
358
359
    my $current_article_requests = $biblio->article_requests_current
360
361
Returns the article requests associated with this biblio that are incomplete
362
363
=cut
364
365
sub article_requests_current {
366
    my ( $self ) = @_;
367
368
    return $self->article_requests->filter_by_current;
369
}
370
371
=head3 article_requests_finished
372
373
    my $finished_article_requests = $biblio->article_requests_finished
374
375
Returns the article requests associated with this biblio that are completed
376
377
=cut
378
379
sub article_requests_finished {
380
    my ( $self, $borrower ) = @_;
381
382
    return $self->article_requests->filter_by_finished;
383
}
384
385
=head3 items
357
=head3 items
386
358
387
my $items = $biblio->items();
359
my $items = $biblio->items();
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/request-article.tt (-2 / +4 lines)
Lines 1-5 Link Here
1
[% USE raw %]
1
[% USE raw %]
2
[% USE Asset %]
2
[% USE Asset %]
3
[% USE Context %]
3
[% USE KohaDates %]
4
[% USE KohaDates %]
4
[% USE Branches %]
5
[% USE Branches %]
5
[% USE ItemTypes %]
6
[% USE ItemTypes %]
Lines 284-290 Link Here
284
285
285
                    [% END %]
286
                    [% END %]
286
287
287
                    [% IF biblio.article_requests_current && !patron %]
288
                    [% SET biblio_current_article_requests = Context.Scalar( Context.Scalar( biblio, 'article_requests' ), 'filter_by_current' ) %]
289
                    [% IF biblio_current_article_requests.count > 0 && !patron %]
288
                        <fieldset class="rows left" id="current-article-requests-fieldset">
290
                        <fieldset class="rows left" id="current-article-requests-fieldset">
289
                            <legend>Current article requests</legend>
291
                            <legend>Current article requests</legend>
290
292
Lines 307-313 Link Here
307
                                    <th>&nbsp;</th>
309
                                    <th>&nbsp;</th>
308
                                </tr>
310
                                </tr>
309
311
310
                                [% FOREACH ar IN biblio.article_requests_current %]
312
                                [% FOREACH ar IN biblio_current_article_requests %]
311
                                    <tr>
313
                                    <tr>
312
                                        <td>[% ar.created_on | $KohaDates %]</td>
314
                                        <td>[% ar.created_on | $KohaDates %]</td>
313
                                        <td><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% ar.borrowernumber | uri %]">[% ar.borrower.firstname | html %] [% ar.borrower.surname | html %]</a></td>
315
                                        <td><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% ar.borrowernumber | uri %]">[% ar.borrower.firstname | html %] [% ar.borrower.surname | html %]</a></td>
(-)a/t/db_dependent/Koha/Biblio.t (-88 / +1 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 18;
20
use Test::More tests => 16;
21
21
22
use C4::Biblio qw( AddBiblio ModBiblio );
22
use C4::Biblio qw( AddBiblio ModBiblio );
23
use Koha::Database;
23
use Koha::Database;
Lines 724-812 subtest 'article_requests() tests' => sub { Link Here
724
724
725
    $schema->storage->txn_rollback;
725
    $schema->storage->txn_rollback;
726
};
726
};
727
728
subtest 'article_requests_current() tests' => sub {
729
730
    plan tests => 7;
731
732
    $schema->storage->txn_begin;
733
734
    my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
735
    my $item   = $builder->build_sample_item;
736
    my $biblio = $item->biblio;
737
738
    my $article_request = Koha::ArticleRequest->new(
739
        {
740
            borrowernumber => $patron->id,
741
            biblionumber   => $biblio->id,
742
            itemnumber     => $item->id,
743
            title          => $biblio->title,
744
        }
745
    )->request();
746
747
    my $ar = $biblio->article_requests();
748
    is( ref($ar), 'Koha::ArticleRequests',
749
        '$biblio->article_requests returns Koha::ArticleRequests object' );
750
    is( $ar->next->id, $article_request->id,
751
        'Returned article request matches' );
752
753
    is( $biblio->article_requests_current()->count(),
754
        1, 'Open request returned for article_requests_current' );
755
    $article_request->set_pending();
756
    is( $biblio->article_requests_current()->count(),
757
        1, 'Pending request returned for article_requests_current' );
758
    $article_request->process();
759
    is( $biblio->article_requests_current()->count(),
760
        1, 'Processing request returned for article_requests_current' );
761
    $article_request->complete();
762
    is( $biblio->article_requests_current()->count(),
763
        0, 'Completed request not returned for article_requests_current' );
764
    $article_request->cancel();
765
    is( $biblio->article_requests_current()->count(),
766
        0, 'Canceled request not returned for article_requests_current' );
767
768
    $schema->storage->txn_rollback;
769
};
770
771
subtest 'article_requests_finished() tests' => sub {
772
773
    plan tests => 7;
774
775
    $schema->storage->txn_begin;
776
777
    my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
778
    my $item   = $builder->build_sample_item;
779
    my $biblio = $item->biblio;
780
781
    my $article_request = Koha::ArticleRequest->new(
782
        {
783
            borrowernumber => $patron->id,
784
            biblionumber   => $biblio->id,
785
            itemnumber     => $item->id,
786
            title          => $biblio->title,
787
        }
788
    )->request();
789
790
    my $ar = $biblio->article_requests();
791
    is( ref($ar), 'Koha::ArticleRequests',
792
        '$biblio->article_requests returns Koha::ArticleRequests object' );
793
    is( $ar->next->id, $article_request->id,
794
        'Returned article request matches' );
795
796
    is( $biblio->article_requests_finished->count,
797
        0, 'Open request returned for article_requests_finished' );
798
    $article_request->set_pending();
799
    is( $biblio->article_requests_finished->count,
800
        0, 'Pending request returned for article_requests_finished' );
801
    $article_request->process();
802
    is( $biblio->article_requests_finished->count,
803
        0, 'Processing request returned for article_requests_finished' );
804
    $article_request->complete();
805
    is( $biblio->article_requests_finished->count,
806
        1, 'Completed request returned for article_requests_finished' );
807
    $article_request->cancel();
808
    is( $biblio->article_requests_finished->count,
809
        1, 'Cancelled request not returned for article_requests_finished' );
810
811
    $schema->storage->txn_rollback;
812
};
813
- 

Return to bug 29084