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 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
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.
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.
29 use Koha::ArticleRequest::Status;
30 use Koha::DateUtils qw(dt_from_string);
32 use base qw(Koha::Object);
36 Koha::ArticleRequest - Koha Article Request Object class
51 $self->status(Koha::ArticleRequest::Status::Pending);
52 $self->SUPER::store();
64 $self->status(Koha::ArticleRequest::Status::Processing);
77 $self->status(Koha::ArticleRequest::Status::Completed);
88 my ( $self, $notes ) = @_;
90 $self->status(Koha::ArticleRequest::Status::Canceled);
91 $self->notes($notes) if $notes;
104 my $status = $self->status;
108 my $letter = C4::Letters::GetPreparedLetter(
109 module => 'circulation',
110 letter_code => "AR_$status", # AR_PENDING, AR_PROCESSING, AR_COMPLETED, AR_CANCELED
111 message_transport_type => 'email',
112 lang => $self->borrower->lang,
114 article_requests => $self->id,
115 borrowers => $self->borrowernumber,
116 biblio => $self->biblionumber,
117 biblioitems => $self->biblionumber,
118 items => $self->itemnumber,
119 branches => $self->branchcode,
124 C4::Letters::EnqueueLetter(
127 borrowernumber => $self->borrowernumber,
128 message_transport_type => 'email',
130 ) or warn "can't enqueue letter $letter";
136 Returns the Koha::Biblio object for this article request
143 $self->{_biblio} ||= Koha::Biblios->find( $self->biblionumber() );
145 return $self->{_biblio};
150 Returns the Koha::Item object for this article request
157 $self->{_item} ||= Koha::Items->find( $self->itemnumber() );
159 return $self->{_item};
164 Returns the Koha::Patron object for this article request
171 $self->{_borrower} ||= Koha::Patrons->find( $self->borrowernumber() );
173 return $self->{_borrower};
178 Returns the Koha::Library object for this article request
185 $self->{_branch} ||= Koha::Libraries->find( $self->branchcode() );
187 return $self->{_branch};
192 Override the default store behavior so that new opan requests
193 will have notifications sent.
200 if ( $self->in_storage() ) {
201 my $now = dt_from_string();
202 $self->updated_on($now);
204 return $self->SUPER::store();
208 return $self->SUPER::store();
217 return 'ArticleRequest';
222 Kyle M Hall <kyle@bywatersolutions.com>