added support for setting hold expire time using an interval defined in the org unit...
[Evergreen.git] / Open-ILS / src / perlmods / OpenILS / Application / Circ / Holds.pm
index 97bf16f..f02962c 100644 (file)
@@ -18,10 +18,12 @@ package OpenILS::Application::Circ::Holds;
 use base qw/OpenILS::Application/;
 use strict; use warnings;
 use OpenILS::Application::AppUtils;
+use DateTime;
 use Data::Dumper;
 use OpenSRF::EX qw(:try);
 use OpenILS::Perm;
 use OpenILS::Event;
+use OpenSRF::Utils;
 use OpenSRF::Utils::Logger qw(:logger);
 use OpenILS::Utils::CStoreEditor q/:funcs/;
 use OpenILS::Utils::PermitHold;
@@ -34,6 +36,7 @@ my $U = $apputils;
 
 
 
+
 __PACKAGE__->register_method(
        method  => "create_hold",
        api_name        => "open-ils.circ.holds.create",
@@ -138,6 +141,13 @@ sub create_hold {
                        }
                }
 
+        # set the configured expire time
+        my $interval = $U->ou_ancestor_setting_value($recipient->home_ou, OILS_SETTING_HOLD_EXPIRE);
+        if($interval) {
+            my $date = DateTime->now->add(seconds => OpenSRF::Utils::interval_to_seconds($interval));
+            $hold->expire_time($U->epoch2ISO8601($date->epoch));
+        }
+
                $hold->requestor($e->requestor->id); 
                $hold->request_lib($e->requestor->ws_ou);
                $hold->selection_ou($hold->pickup_lib) unless $hold->selection_ou;