Bug 23185: Realistic POD for Koha::Objects->search
[srvgit] / Koha / ArticleRequest.pm
index 217e187..2c47dd0 100644 (file)
@@ -4,18 +4,18 @@ package Koha::ArticleRequest;
 #
 # This file is part of Koha.
 #
-# Koha is free software; you can redistribute it and/or modify it under the
-# terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 3 of the License, or (at your option) any later
-# version.
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
 #
-# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
 #
-# You should have received a copy of the GNU General Public License along
-# with Koha; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
 
 use Modern::Perl;
 
@@ -26,7 +26,6 @@ use Koha::Patrons;
 use Koha::Biblios;
 use Koha::Items;
 use Koha::Libraries;
-use Koha::ArticleRequest::Status;
 use Koha::DateUtils qw(dt_from_string);
 
 use base qw(Koha::Object);
@@ -49,6 +48,7 @@ sub open {
     my ($self) = @_;
 
     $self->status(Koha::ArticleRequest::Status::Pending);
+    $self->SUPER::store();
     $self->notify();
     return $self;
 }
@@ -102,11 +102,13 @@ sub notify {
 
     my $status = $self->status;
 
+    require C4::Letters;
     if (
         my $letter = C4::Letters::GetPreparedLetter(
             module                 => 'circulation',
-            letter_code            => "AR_$status",
+            letter_code            => "AR_$status", # AR_PENDING, AR_PROCESSING, AR_COMPLETED, AR_CANCELED
             message_transport_type => 'email',
+            lang                   => $self->borrower->lang,
             tables                 => {
                 article_requests => $self->id,
                 borrowers        => $self->borrowernumber,
@@ -186,23 +188,18 @@ sub branch {
 
 =head3 store
 
-Override the default store behavior so that new opan requests
+Override the default store behavior so that new opac requests
 will have notifications sent.
 
 =cut
 
 sub store {
     my ($self) = @_;
-
-    if ( $self->in_storage() ) {
-        my $now = dt_from_string();
-        $self->updated_on($now);
-
-        return $self->SUPER::store();
-    }
-    else {
-        $self->open();
-        return $self->SUPER::store();
+    if ( $self->in_storage ) {
+        return $self->SUPER::store;
+    } else {
+        $self->created_on( dt_from_string() );
+        return $self->open;
     }
 }