new method for un-canceling holds. request_time and expire_time are reset if appropr...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 6 Feb 2009 17:52:57 +0000 (17:52 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 6 Feb 2009 17:52:57 +0000 (17:52 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@12097 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm

index 2907463..b777ec4 100644 (file)
@@ -454,6 +454,46 @@ sub retrieve_holds_by_pickup_lib {
        }
 }
 
+
+__PACKAGE__->register_method(
+       method  => "uncancel_hold",
+       api_name        => "open-ils.circ.hold.uncancel"
+);
+
+sub uncancel_hold {
+       my($self, $client, $auth, $hold_id) = @_;
+       my $e = new_editor(authtoken=>$auth, xact=>1);
+       return $e->event unless $e->checkauth;
+
+       my $hold = $e->retrieve_action_hold_request($hold_id)
+               or return $e->die_event;
+    return $e->die_event unless $e->allowed('CANCEL_HOLDS', $hold->request_lib);
+
+    return 0 if $hold->fulfillment_time;
+    return 1 unless $hold->cancel_time;
+
+    # if configured to reset the request time, also reset the expire time
+    if($U->ou_ancestor_setting_value(
+        $hold->request_lib, 'circ.hold_reset_request_time_on_uncancel', $e)) {
+
+        $hold->request_time('now');
+        my $interval = $U->ou_ancestor_setting_value($hold->request_lib, 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->clear_cancel_time;
+    $e->update_action_hold_request($hold) or return $e->die_event;
+    $e->commit;
+
+    $U->storagereq('open-ils.storage.action.hold_request.copy_targeter', undef, $hold_id);
+
+    return 1;
+}
+
+
 __PACKAGE__->register_method(
        method  => "cancel_hold",
        api_name        => "open-ils.circ.hold.cancel",