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

(-)a/Koha/ArticleRequest.pm (-38 / +62 lines)
Lines 42-47 Koha::ArticleRequest - Koha Article Request Object class Link Here
42
42
43
=head3 request
43
=head3 request
44
44
45
    $article_request->request;
46
47
Marks the article as requested. Send a notification if appropriate.
48
45
=cut
49
=cut
46
50
47
sub request {
51
sub request {
Lines 55-60 sub request { Link Here
55
59
56
=head3 set_pending
60
=head3 set_pending
57
61
62
    $article_request->set_pending;
63
64
Marks the article as pending. Send a notification if appropriate.
65
58
=cut
66
=cut
59
67
60
sub set_pending {
68
sub set_pending {
Lines 68-73 sub set_pending { Link Here
68
76
69
=head3 process
77
=head3 process
70
78
79
    $article_request->process;
80
81
Marks the article as in process. Send a notification if appropriate.
82
71
=cut
83
=cut
72
84
73
sub process {
85
sub process {
Lines 81-86 sub process { Link Here
81
93
82
=head3 complete
94
=head3 complete
83
95
96
    $article_request->complete;
97
98
Marks the article as completed. Send a notification if appropriate.
99
84
=cut
100
=cut
85
101
86
sub complete {
102
sub complete {
Lines 94-99 sub complete { Link Here
94
110
95
=head3 cancel
111
=head3 cancel
96
112
113
    $article_request->cancel;
114
115
Marks the article as cancelled. Send a notification if appropriate.
116
97
=cut
117
=cut
98
118
99
sub cancel {
119
sub cancel {
Lines 106-148 sub cancel { Link Here
106
    return $self;
126
    return $self;
107
}
127
}
108
128
109
=head3 notify
110
111
=cut
112
113
sub notify {
114
    my ($self) = @_;
115
116
    my $status = $self->status;
117
118
    require C4::Letters;
119
    if (
120
        my $letter = C4::Letters::GetPreparedLetter(
121
            module                 => 'circulation',
122
            letter_code            => "AR_$status", # AR_REQUESTED, AR_PENDING, AR_PROCESSING, AR_COMPLETED, AR_CANCELED
123
            message_transport_type => 'email',
124
            lang                   => $self->borrower->lang,
125
            tables                 => {
126
                article_requests => $self->id,
127
                borrowers        => $self->borrowernumber,
128
                biblio           => $self->biblionumber,
129
                biblioitems      => $self->biblionumber,
130
                items            => $self->itemnumber,
131
                branches         => $self->branchcode,
132
            },
133
        )
134
      )
135
    {
136
        C4::Letters::EnqueueLetter(
137
            {
138
                letter                 => $letter,
139
                borrowernumber         => $self->borrowernumber,
140
                message_transport_type => 'email',
141
            }
142
        ) or warn "can't enqueue letter ". $letter->{code};
143
    }
144
}
145
146
=head3 biblio
129
=head3 biblio
147
130
148
Returns the Koha::Biblio object for this article request
131
Returns the Koha::Biblio object for this article request
Lines 218-223 sub store { Link Here
218
201
219
=head2 Internal methods
202
=head2 Internal methods
220
203
204
=head3 notify
205
206
    $self->notify();
207
208
internal method to be called when changing an article request status.
209
If a letter exists for the new status, it enqueues it.
210
211
=cut
212
213
sub notify {
214
    my ($self) = @_;
215
216
    my $status = $self->status;
217
218
    require C4::Letters;
219
    if (
220
        my $letter = C4::Letters::GetPreparedLetter(
221
            module                 => 'circulation',
222
            letter_code            => "AR_$status", # AR_REQUESTED, AR_PENDING, AR_PROCESSING, AR_COMPLETED, AR_CANCELED
223
            message_transport_type => 'email',
224
            lang                   => $self->borrower->lang,
225
            tables                 => {
226
                article_requests => $self->id,
227
                borrowers        => $self->borrowernumber,
228
                biblio           => $self->biblionumber,
229
                biblioitems      => $self->biblionumber,
230
                items            => $self->itemnumber,
231
                branches         => $self->branchcode,
232
            },
233
        )
234
      )
235
    {
236
        C4::Letters::EnqueueLetter(
237
            {
238
                letter                 => $letter,
239
                borrowernumber         => $self->borrowernumber,
240
                message_transport_type => 'email',
241
            }
242
        ) or warn "can't enqueue letter ". $letter->{code};
243
    }
244
}
245
221
=head3 _type
246
=head3 _type
222
247
223
=cut
248
=cut
224
- 

Return to bug 27944