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

(-)a/C4/Letters.pm (-12 / +13 lines)
Lines 762-779 sub _parseletter_sth { Link Here
762
    #       broke things for the rest of us. prepare_cached is a better
762
    #       broke things for the rest of us. prepare_cached is a better
763
    #       way to cache statement handles anyway.
763
    #       way to cache statement handles anyway.
764
    my $query = 
764
    my $query = 
765
    ($table eq 'biblio'       ) ? "SELECT * FROM $table WHERE   biblionumber = ?"                                  :
765
    ($table eq 'biblio'       )    ? "SELECT * FROM $table WHERE   biblionumber = ?"                                  :
766
    ($table eq 'biblioitems'  ) ? "SELECT * FROM $table WHERE   biblionumber = ?"                                  :
766
    ($table eq 'biblioitems'  )    ? "SELECT * FROM $table WHERE   biblionumber = ?"                                  :
767
    ($table eq 'items'        ) ? "SELECT * FROM $table WHERE     itemnumber = ?"                                  :
767
    ($table eq 'items'        )    ? "SELECT * FROM $table WHERE     itemnumber = ?"                                  :
768
    ($table eq 'issues'       ) ? "SELECT * FROM $table WHERE     itemnumber = ?"                                  :
768
    ($table eq 'issues'       )    ? "SELECT * FROM $table WHERE     itemnumber = ?"                                  :
769
    ($table eq 'old_issues'   ) ? "SELECT * FROM $table WHERE     itemnumber = ? ORDER BY timestamp DESC LIMIT 1"  :
769
    ($table eq 'old_issues'   )    ? "SELECT * FROM $table WHERE     itemnumber = ? ORDER BY timestamp DESC LIMIT 1"  :
770
    ($table eq 'reserves'     ) ? "SELECT * FROM $table WHERE borrowernumber = ? and biblionumber = ?"             :
770
    ($table eq 'reserves'     )    ? "SELECT * FROM $table WHERE borrowernumber = ? and biblionumber = ?"             :
771
    ($table eq 'borrowers'    ) ? "SELECT * FROM $table WHERE borrowernumber = ?"                                  :
771
    ($table eq 'borrowers'    )    ? "SELECT * FROM $table WHERE borrowernumber = ?"                                  :
772
    ($table eq 'branches'     ) ? "SELECT * FROM $table WHERE     branchcode = ?"                                  :
772
    ($table eq 'branches'     )    ? "SELECT * FROM $table WHERE     branchcode = ?"                                  :
773
    ($table eq 'suggestions'  ) ? "SELECT * FROM $table WHERE   suggestionid = ?"                                  :
773
    ($table eq 'suggestions'  )    ? "SELECT * FROM $table WHERE   suggestionid = ?"                                  :
774
    ($table eq 'aqbooksellers') ? "SELECT * FROM $table WHERE             id = ?"                                  :
774
    ($table eq 'aqbooksellers')    ? "SELECT * FROM $table WHERE             id = ?"                                  :
775
    ($table eq 'aqorders'     ) ? "SELECT * FROM $table WHERE    ordernumber = ?"                                  :
775
    ($table eq 'aqorders'     )    ? "SELECT * FROM $table WHERE    ordernumber = ?"                                  :
776
    ($table eq 'opac_news'    ) ? "SELECT * FROM $table WHERE          idnew = ?"                                  :
776
    ($table eq 'opac_news'    )    ? "SELECT * FROM $table WHERE          idnew = ?"                                  :
777
    ($table eq 'article_requests') ? "SELECT * FROM $table WHERE             id = ?"                                  :
777
    ($table eq 'borrower_modifications') ? "SELECT * FROM $table WHERE verification_token = ?" :
778
    ($table eq 'borrower_modifications') ? "SELECT * FROM $table WHERE verification_token = ?" :
778
    ($table eq 'subscription') ? "SELECT * FROM $table WHERE subscriptionid = ?" :
779
    ($table eq 'subscription') ? "SELECT * FROM $table WHERE subscriptionid = ?" :
779
    ($table eq 'serial') ? "SELECT * FROM $table WHERE serialid = ?" :
780
    ($table eq 'serial') ? "SELECT * FROM $table WHERE serialid = ?" :
(-)a/Koha/ArticleRequest.pm (+223 lines)
Line 0 Link Here
1
package Koha::ArticleRequest;
2
3
# Copyright ByWater Solutions 2015
4
#
5
# This file is part of Koha.
6
#
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
10
# version.
11
#
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.
15
#
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.
19
20
use Modern::Perl;
21
22
use Carp;
23
24
use Koha::Database;
25
use Koha::Borrowers;
26
use Koha::Biblios;
27
use Koha::Items;
28
use Koha::Libraries;
29
use Koha::ArticleRequest::Status;
30
use Koha::DateUtils qw(dt_from_string);
31
32
use base qw(Koha::Object);
33
34
=head1 NAME
35
36
Koha::ArticleRequest - Koha Article Request Object class
37
38
=head1 API
39
40
=head2 Class Methods
41
42
=cut
43
44
=head3 open
45
46
=cut
47
48
sub open {
49
    my ($self) = @_;
50
51
    $self->status(Koha::ArticleRequest::Status::Pending);
52
    $self->notify();
53
    return $self;
54
}
55
56
=head3 process
57
58
=cut
59
60
sub process {
61
    my ($self) = @_;
62
63
    $self->status(Koha::ArticleRequest::Status::Processing);
64
    $self->store();
65
    $self->notify();
66
    return $self;
67
}
68
69
=head3 complete
70
71
=cut
72
73
sub complete {
74
    my ($self) = @_;
75
76
    $self->status(Koha::ArticleRequest::Status::Completed);
77
    $self->store();
78
    $self->notify();
79
    return $self;
80
}
81
82
=head3 cancel
83
84
=cut
85
86
sub cancel {
87
    my ( $self, $notes ) = @_;
88
89
    $self->status(Koha::ArticleRequest::Status::Canceled);
90
    $self->notes($notes) if $notes;
91
    $self->store();
92
    $self->notify();
93
    return $self;
94
}
95
96
=head3 notify
97
98
=cut
99
100
sub notify {
101
    my ($self) = @_;
102
103
    my $status = $self->status;
104
105
    if (
106
        my $letter = C4::Letters::GetPreparedLetter(
107
            module                 => 'circulation',
108
            letter_code            => "AR_$status",
109
            message_transport_type => 'email',
110
            tables                 => {
111
                article_requests => $self->id,
112
                borrowers        => $self->borrowernumber,
113
                biblio           => $self->biblionumber,
114
                biblioitems      => $self->biblionumber,
115
                items            => $self->itemnumber,
116
                branches         => $self->branchcode,
117
            },
118
        )
119
      )
120
    {
121
        C4::Letters::EnqueueLetter(
122
            {
123
                letter                 => $letter,
124
                borrowernumber         => $self->borrowernumber,
125
                message_transport_type => 'email',
126
            }
127
        ) or warn "can't enqueue letter $letter";
128
    }
129
}
130
131
=head3 biblio
132
133
Returns the Koha::Biblio object for this article request
134
135
=cut
136
137
sub biblio {
138
    my ($self) = @_;
139
140
    $self->{_biblio} ||= Koha::Biblios->find( $self->biblionumber() );
141
142
    return $self->{_biblio};
143
}
144
145
=head3 item
146
147
Returns the Koha::Item object for this article request
148
149
=cut
150
151
sub item {
152
    my ($self) = @_;
153
154
    $self->{_item} ||= Koha::Items->find( $self->itemnumber() );
155
156
    return $self->{_item};
157
}
158
159
=head3 borrower
160
161
Returns the Koha::Borrower object for this article request
162
163
=cut
164
165
sub borrower {
166
    my ($self) = @_;
167
168
    $self->{_borrower} ||= Koha::Borrowers->find( $self->borrowernumber() );
169
170
    return $self->{_borrower};
171
}
172
173
=head3 branch
174
175
Returns the Koha::Library object for this article request
176
177
=cut
178
179
sub branch {
180
    my ($self) = @_;
181
182
    $self->{_branch} ||= Koha::Libraries->find( $self->branchcode() );
183
184
    return $self->{_branch};
185
}
186
187
=head3 store
188
189
Override the default store behavior so that new opan requests
190
will have notifications sent.
191
192
=cut
193
194
sub store {
195
    my ($self) = @_;
196
197
    if ( $self->in_storage() ) {
198
        my $now = dt_from_string();
199
        $self->updated_on($now);
200
201
        return $self->SUPER::store();
202
    }
203
    else {
204
        $self->open();
205
        return $self->SUPER::store();
206
    }
207
}
208
209
=head3 type
210
211
=cut
212
213
sub type {
214
    return 'ArticleRequest';
215
}
216
217
=head1 AUTHOR
218
219
Kyle M Hall <kyle@bywatersolutions.com>
220
221
=cut
222
223
1;
(-)a/Koha/ArticleRequest/Status.pm (+44 lines)
Line 0 Link Here
1
package Koha::ArticleRequest::Status;
2
3
# Copyright ByWater Solutions 2015
4
#
5
# This file is part of Koha.
6
#
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
10
# version.
11
#
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.
15
#
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.
19
20
use Modern::Perl;
21
22
sub Pending {
23
    return 'PENDING';
24
}
25
26
sub Processing {
27
    return 'PROCESSING';
28
}
29
30
sub Completed {
31
    return 'COMPLETED';
32
}
33
34
sub Canceled {
35
    return 'CANCELED';
36
}
37
38
=head1 AUTHOR
39
40
Kyle M Hall <kyle@bywatersolutions.com>
41
42
=cut
43
44
1;
(-)a/Koha/ArticleRequests.pm (+103 lines)
Line 0 Link Here
1
package Koha::ArticleRequests;
2
3
# Copyright ByWater Solutions 2015
4
#
5
# This file is part of Koha.
6
#
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
10
# version.
11
#
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.
15
#
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.
19
20
use Modern::Perl;
21
22
use Carp;
23
24
use Koha::Database;
25
26
use Koha::ArticleRequest;
27
use Koha::ArticleRequest::Status;
28
29
use base qw(Koha::Objects);
30
31
=head1 NAME
32
33
Koha::ArticleRequests - Koha ArticleRequests Object class
34
35
=head1 API
36
37
=head2 Class Methods
38
39
=cut
40
41
=head3 pending
42
43
=cut
44
45
sub pending {
46
    my ( $self, $branchcode ) = @_;
47
    my $params = { status => Koha::ArticleRequest::Status::Pending };
48
    $params->{branchcode} = $branchcode if $branchcode;
49
    return Koha::ArticleRequests->search( $params );
50
}
51
52
=head3 processing
53
54
=cut
55
56
sub processing {
57
    my ( $self, $branchcode ) = @_;
58
    my $params = { status => Koha::ArticleRequest::Status::Processing };
59
    $params->{branchcode} = $branchcode if $branchcode;
60
    return Koha::ArticleRequests->search( $params );
61
}
62
63
=head3 completed
64
65
=cut
66
67
sub completed {
68
    my ( $self, $branchcode ) = @_;
69
    my $params = { status => Koha::ArticleRequest::Status::Completed };
70
    $params->{branchcode} = $branchcode if $branchcode;
71
    return Koha::ArticleRequests->search( $params );
72
}
73
74
=head3 canceled
75
76
=cut
77
78
sub canceled {
79
    my ( $self, $branchcode ) = @_;
80
    my $params = { status => Koha::ArticleRequest::Status::Canceled };
81
    $params->{branchcode} = $branchcode if $branchcode;
82
    return Koha::ArticleRequests->search( $params );
83
}
84
85
=head3 type
86
87
=cut
88
89
sub type {
90
    return 'ArticleRequest';
91
}
92
93
sub object_class {
94
    return 'Koha::ArticleRequest';
95
}
96
97
=head1 AUTHOR
98
99
Kyle M Hall <kyle@bywatersolutions.com>
100
101
=cut
102
103
1;
(-)a/Koha/Biblio.pm (+210 lines)
Lines 27-32 use Koha::Database; Link Here
27
27
28
use base qw(Koha::Object);
28
use base qw(Koha::Object);
29
29
30
use C4::Circulation qw(GetIssuingRule);
31
use Koha::Items;
32
use Koha::Biblioitems;
33
use Koha::ArticleRequests;
34
use Koha::ArticleRequest::Status;
35
30
=head1 NAME
36
=head1 NAME
31
37
32
Koha::Biblio - Koha Biblio Object class
38
Koha::Biblio - Koha Biblio Object class
Lines 53-58 sub subtitles { Link Here
53
    return map { $_->{subfield} } @{ GetRecordValue( 'subtitle', GetMarcBiblio( $self->id ), $self->frameworkcode ) };
59
    return map { $_->{subfield} } @{ GetRecordValue( 'subtitle', GetMarcBiblio( $self->id ), $self->frameworkcode ) };
54
}
60
}
55
61
62
=head3 can_article_request
63
64
my $bool = $biblio->can_article_request( $borrower );
65
66
Returns true if article requests can be made for this record
67
68
$borrower must be a Koha::Borrower object
69
70
=cut
71
72
sub can_article_request {
73
    my ( $self, $borrower ) = @_;
74
75
    my $rule = $self->article_request_type($borrower);
76
    return q{} if $rule eq 'item_only' && !$self->items()->count();
77
    return 1 if $rule && $rule ne 'no';
78
79
    return q{};
80
}
81
82
=head3 article_request_type
83
84
my $type = $biblio->article_request_type( $borrower );
85
86
Returns the article request type based on items, or on the record
87
itself if there are no items.
88
89
$borrower must be a Koha::Borrower object
90
91
=cut
92
93
sub article_request_type {
94
    my ( $self, $borrower ) = @_;
95
96
    return q{} unless $borrower;
97
98
    my $rule = $self->article_request_type_for_items( $borrower );
99
    return $rule if $rule;
100
101
    # If the record has no items that are requestable, go by the record itemtype
102
    $rule = $self->article_request_type_for_bib($borrower);
103
    return $rule if $rule;
104
105
    return q{};
106
}
107
108
=head3 article_request_type_for_bib
109
110
my $type = $biblio->article_request_type_for_bib
111
112
Returns the article request type 'yes', 'no', 'item_only', 'bib_only', for the given record
113
114
=cut
115
116
sub article_request_type_for_bib {
117
    my ( $self, $borrower ) = @_;
118
119
    return q{} unless $borrower;
120
121
    my $borrowertype = $borrower->categorycode;
122
    my $itemtype     = $self->itemtype();
123
124
    my $rules        = C4::Circulation::GetIssuingRule( $borrowertype, $itemtype );
125
126
    return $rules->{article_requests} || q{};
127
}
128
129
=head3 article_request_type_for_items
130
131
my $type = $biblio->article_request_type_for_items
132
133
Returns the article request type 'yes', 'no', 'item_only', 'bib_only', for the given record's items
134
135
If there is a conflict where some items are 'bib_only' and some are 'item_only', 'bib_only' will be returned.
136
137
=cut
138
139
sub article_request_type_for_items {
140
    my ( $self, $borrower ) = @_;
141
142
    my $counts;
143
    foreach my $item ( $self->items()->as_list() ) {
144
        my $rule = $item->article_request_type($borrower);
145
        return $rule if $rule eq 'bib_only';    # we don't need to go any further
146
        $counts->{$rule}++;
147
    }
148
149
    return 'item_only' if $counts->{item_only};
150
    return 'yes'       if $counts->{yes};
151
    return 'no'        if $counts->{no};
152
    return q{};
153
}
154
155
=head3 article_requests
156
157
my @requests = $biblio->article_requests
158
159
Returns the article requests associated with this Biblio
160
161
=cut
162
163
sub article_requests {
164
    my ( $self, $borrower ) = @_;
165
166
    $self->{_article_requests} ||= Koha::ArticleRequests->search( { biblionumber => $self->biblionumber() } );
167
168
    return wantarray ? $self->{_article_requests}->as_list : $self->{_article_requests};
169
}
170
171
=head3 article_requests_current
172
173
my @requests = $biblio->article_requests_current
174
175
Returns the article requests associated with this Biblio that are incomplete
176
177
=cut
178
179
sub article_requests_current {
180
    my ( $self, $borrower ) = @_;
181
182
    $self->{_article_requests_current} ||= Koha::ArticleRequests->search(
183
        {
184
            biblionumber => $self->biblionumber(),
185
            -or          => [
186
                { status => Koha::ArticleRequest::Status::Pending },
187
                { status => Koha::ArticleRequest::Status::Processing }
188
            ]
189
        }
190
    );
191
192
    return wantarray ? $self->{_article_requests_current}->as_list : $self->{_article_requests_current};
193
}
194
195
=head3 article_requests_finished
196
197
my @requests = $biblio->article_requests_finished
198
199
Returns the article requests associated with this Biblio that are completed
200
201
=cut
202
203
sub article_requests_finished {
204
    my ( $self, $borrower ) = @_;
205
206
    $self->{_article_requests_finished} ||= Koha::ArticleRequests->search(
207
        {
208
            biblionumber => $self->biblionumber(),
209
            -or          => [
210
                { status => Koha::ArticleRequest::Status::Completed },
211
                { status => Koha::ArticleRequest::Status::Canceled }
212
            ]
213
        }
214
    );
215
216
    return wantarray ? $self->{_article_requests_finished}->as_list : $self->{_article_requests_finished};
217
}
218
219
=head3 items
220
221
my @items = $biblio->items();
222
my $items = $biblio->items();
223
224
Returns a list of Koha::Item objects or a Koha::Items object of
225
items associated with this bib
226
227
=cut
228
229
sub items {
230
    my ( $self ) = @_;
231
232
    $self->{_items} ||= Koha::Items->search({ biblionumber => $self->biblionumber() });
233
234
    return $self->{_items};
235
}
236
237
=head3 itemtype
238
239
my $itemtype = $biblio->itemtype();
240
241
Returns the itemtype for this record.
242
243
=cut
244
245
sub itemtype {
246
    my ( $self ) = @_;
247
248
    return $self->_biblioitem()->itemtype();
249
}
250
251
=head3 _biblioitem
252
253
my $field = $self->_biblioitem()->itemtype
254
255
Returns the related Koha::Biblioitem object for this Biblio object
256
257
=cut
258
259
sub _biblioitem {
260
    my ($self) = @_;
261
262
    $self->{_biblioitem} ||= Koha::Biblioitems->find( { biblionumber => $self->biblionumber() } );
263
264
    return $self->{_biblioitem};
265
}
56
266
57
=head3 type
267
=head3 type
58
268
(-)a/Koha/Biblios.pm (-1 / +1 lines)
Lines 1-6 Link Here
1
package Koha::Biblios;
1
package Koha::Biblios;
2
2
3
# Copyright ByWater Solutions 2014
3
# Copyright ByWater Solutions 2015
4
#
4
#
5
# This file is part of Koha.
5
# This file is part of Koha.
6
#
6
#
(-)a/Koha/Borrower.pm (+70 lines)
Lines 23-28 use Carp; Link Here
23
23
24
use Koha::Database;
24
use Koha::Database;
25
25
26
use Koha::ArticleRequests;
27
use Koha::ArticleRequest::Status;
28
26
use base qw(Koha::Object);
29
use base qw(Koha::Object);
27
30
28
=head1 NAME
31
=head1 NAME
Lines 47-52 sub guarantor { Link Here
47
    return Koha::Borrowers->find( $self->guarantorid() );
50
    return Koha::Borrowers->find( $self->guarantorid() );
48
}
51
}
49
52
53
=head3 article_requests
54
55
my @requests = $borrower->article_requests();
56
my $requests = $borrower->article_requests();
57
58
Returns either a list of ArticleRequests objects,
59
or an ArtitleRequests object, depending on the
60
calling context.
61
62
=cut
63
64
sub article_requests {
65
    my ( $self ) = @_;
66
67
    $self->{_article_requests} ||= Koha::ArticleRequests->search({ borrowernumber => $self->borrowernumber() });
68
69
    return $self->{_article_requests};
70
}
71
72
=head3 article_requests_current
73
74
my @requests = $patron->article_requests_current
75
76
Returns the article requests associated with this patron that are incomplete
77
78
=cut
79
80
sub article_requests_current {
81
    my ( $self ) = @_;
82
83
    $self->{_article_requests_current} ||= Koha::ArticleRequests->search(
84
        {
85
            borrowernumber => $self->id(),
86
            -or          => [
87
                { status => Koha::ArticleRequest::Status::Pending },
88
                { status => Koha::ArticleRequest::Status::Processing }
89
            ]
90
        }
91
    );
92
93
    return $self->{_article_requests_current};
94
}
95
96
=head3 article_requests_finished
97
98
my @requests = $biblio->article_requests_finished
99
100
Returns the article requests associated with this patron that are completed
101
102
=cut
103
104
sub article_requests_finished {
105
    my ( $self, $borrower ) = @_;
106
107
    $self->{_article_requests_finished} ||= Koha::ArticleRequests->search(
108
        {
109
            borrowernumber => $self->id(),
110
            -or          => [
111
                { status => Koha::ArticleRequest::Status::Completed },
112
                { status => Koha::ArticleRequest::Status::Canceled }
113
            ]
114
        }
115
    );
116
117
    return $self->{_article_requests_finished};
118
}
119
50
=head3 type
120
=head3 type
51
121
52
=cut
122
=cut
(-)a/Koha/Item.pm (+46 lines)
Lines 23-28 use Carp; Link Here
23
23
24
use Koha::Database;
24
use Koha::Database;
25
25
26
use C4::Context;
27
use C4::Circulation qw(GetIssuingRule);
26
use Koha::Borrowers;
28
use Koha::Borrowers;
27
use Koha::Libraries;
29
use Koha::Libraries;
28
30
Lines 107-112 sub last_returned_by { Link Here
107
    }
109
    }
108
}
110
}
109
111
112
=head3 can_article_request
113
114
my $bool = $item->can_article_request( $borrower )
115
116
Returns true if item can be specifically requested
117
118
$borrower must be a Koha::Borrower object
119
120
=cut
121
122
sub can_article_request {
123
    my ( $self, $borrower ) = @_;
124
125
    my $rule = $self->article_request_type($borrower);
126
127
    return 1 if $rule && $rule ne 'no' && $rule ne 'bib_only';
128
    return q{};
129
}
130
131
=head3 article_request_type
132
133
my $type = $item->article_request_type( $borrower )
134
135
returns 'yes', 'no', 'bib_only', or 'item_only'
136
137
$borrower must be a Koha::Borrower object
138
139
=cut
140
141
sub article_request_type {
142
    my ( $self, $borrower ) = @_;
143
144
    my $branch_control = C4::Context->preference('HomeOrHoldingBranch');
145
    my $branchcode =
146
        $branch_control eq 'homebranch'    ? $self->homebranch
147
      : $branch_control eq 'holdingbranch' ? $self->holdingbranch
148
      :                                      undef;
149
    my $borrowertype = $borrower->categorycode;
150
    my $itemtype = $self->effective_itemtype();
151
    my $rules = GetIssuingRule( $borrowertype, $itemtype, $branchcode );
152
153
    return $rules->{article_requests} || q{};
154
}
155
110
=head3 type
156
=head3 type
111
157
112
=cut
158
=cut
(-)a/Koha/Template/Plugin/Biblio.pm (-1 / +31 lines)
Lines 23-28 use Template::Plugin; Link Here
23
use base qw( Template::Plugin );
23
use base qw( Template::Plugin );
24
24
25
use Koha::Holds;
25
use Koha::Holds;
26
use Koha::Biblios;
27
use Koha::Borrowers;
28
use Koha::ArticleRequests;
29
use Koha::ArticleRequest::Status;
26
30
27
sub HoldsCount {
31
sub HoldsCount {
28
    my ( $self, $biblionumber ) = @_;
32
    my ( $self, $biblionumber ) = @_;
Lines 32-35 sub HoldsCount { Link Here
32
    return $holds->count();
36
    return $holds->count();
33
}
37
}
34
38
39
sub ArticleRequestsActiveCount {
40
    my ( $self, $biblionumber ) = @_;
41
42
    my $ar = Koha::ArticleRequests->search(
43
        {
44
            biblionumber => $biblionumber,
45
            status       => [
46
                -or => [
47
                    status => Koha::ArticleRequest::Status::Pending,
48
                    status => Koha::ArticleRequest::Status::Processing
49
                ]
50
            ]
51
        }
52
    );
53
54
    return $ar->count();
55
}
56
57
sub CanArticleRequest {
58
    my ( $self, $biblionumber, $borrowernumber ) = @_;
59
60
    my $biblio = Koha::Biblios->find( $biblionumber );
61
    my $borrower = Koha::Borrowers->find( $borrowernumber );
62
63
    return $biblio ? $biblio->can_article_request( $borrower ) : 0;
64
}
65
35
1;
66
1;
36
- 

Return to bug 14610