From 4a9776c5b6d13ba9e972332e97a6531f0b79ecf3 Mon Sep 17 00:00:00 2001 From: erickson Date: Fri, 6 Feb 2009 17:52:57 +0000 Subject: [PATCH] new method for un-canceling holds. request_time and expire_time are reset if appropriate org-unit-setting is enabled git-svn-id: svn://svn.open-ils.org/ILS/trunk@12097 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../src/perlmods/OpenILS/Application/Circ/Holds.pm | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm index 2907463ccd..b777ec459d 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm @@ -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", -- 2.11.0