1 package Koha::ArticleRequest;
3 # Copyright ByWater Solutions 2015
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
28 use Koha::DateUtils qw( dt_from_string );
29 use Koha::ArticleRequest::Status;
31 use base qw(Koha::Object);
35 Koha::ArticleRequest - Koha Article Request Object class
50 $self->status(Koha::ArticleRequest::Status::Requested);
51 $self->SUPER::store();
63 $self->status(Koha::ArticleRequest::Status::Pending);
64 $self->SUPER::store();
76 $self->status(Koha::ArticleRequest::Status::Processing);
89 $self->status(Koha::ArticleRequest::Status::Completed);
100 my ( $self, $notes ) = @_;
102 $self->status(Koha::ArticleRequest::Status::Canceled);
103 $self->notes($notes) if $notes;
116 my $status = $self->status;
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,
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,
136 C4::Letters::EnqueueLetter(
139 borrowernumber => $self->borrowernumber,
140 message_transport_type => 'email',
142 ) or warn "can't enqueue letter ". $letter->{code};
148 Returns the Koha::Biblio object for this article request
155 $self->{_biblio} ||= Koha::Biblios->find( $self->biblionumber() );
157 return $self->{_biblio};
162 Returns the Koha::Item object for this article request
169 $self->{_item} ||= Koha::Items->find( $self->itemnumber() );
171 return $self->{_item};
176 Returns the Koha::Patron object for this article request
183 $self->{_borrower} ||= Koha::Patrons->find( $self->borrowernumber() );
185 return $self->{_borrower};
190 Returns the Koha::Library object for this article request
197 $self->{_branch} ||= Koha::Libraries->find( $self->branchcode() );
199 return $self->{_branch};
204 Override the default store behavior so that new opac requests
205 will have notifications sent.
211 if ( $self->in_storage ) {
212 return $self->SUPER::store;
214 $self->created_on( dt_from_string() );
215 return $self->request;
219 =head2 Internal methods
226 return 'ArticleRequest';
231 Kyle M Hall <kyle@bywatersolutions.com>