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);
63 $self->status(Koha::ArticleRequest::Status::Processing);
76 $self->status(Koha::ArticleRequest::Status::Completed);
87 my ( $self, $notes ) = @_;
89 $self->status(Koha::ArticleRequest::Status::Canceled);
90 $self->notes($notes) if $notes;
103 my $status = $self->status;
106 my $letter = C4::Letters::GetPreparedLetter(
107 module => 'circulation',
108 letter_code => "AR_$status",
109 message_transport_type => 'email',
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,
121 C4::Letters::EnqueueLetter(
124 borrowernumber => $self->borrowernumber,
125 message_transport_type => 'email',
127 ) or warn "can't enqueue letter $letter";
133 Returns the Koha::Biblio object for this article request
140 $self->{_biblio} ||= Koha::Biblios->find( $self->biblionumber() );
142 return $self->{_biblio};
147 Returns the Koha::Item object for this article request
154 $self->{_item} ||= Koha::Items->find( $self->itemnumber() );
156 return $self->{_item};
161 Returns the Koha::Patron object for this article request
168 $self->{_borrower} ||= Koha::Patrons->find( $self->borrowernumber() );
170 return $self->{_borrower};
175 Returns the Koha::Library object for this article request
182 $self->{_branch} ||= Koha::Libraries->find( $self->branchcode() );
184 return $self->{_branch};
189 Override the default store behavior so that new opan requests
190 will have notifications sent.
197 if ( $self->in_storage() ) {
198 my $now = dt_from_string();
199 $self->updated_on($now);
201 return $self->SUPER::store();
205 return $self->SUPER::store();
214 return 'ArticleRequest';
219 Kyle M Hall <kyle@bywatersolutions.com>