From: Jason Etheridge Date: Mon, 27 Jun 2011 19:30:04 +0000 (-0400) Subject: middle layer method for changing the target and resetting specified holds X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=50dec2d7a8fc706f3df109351f1a56db8851bd96;p=working%2FEvergreen.git middle layer method for changing the target and resetting specified holds Signed-off-by: Jason Etheridge --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm index de3f75e772..6d47aeb281 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm @@ -3422,6 +3422,22 @@ __PACKAGE__->register_method( } ); +__PACKAGE__->register_method( + method => 'change_hold_title_for_specific_holds', + api_name => 'open-ils.circ.hold.change_title.specific_holds', + signature => { + desc => q/ + Updates specified holds to target new bib./, + params => [ + { desc => 'Authentication Token', type => 'string' }, + { desc => 'New Target Bib Id', type => 'number' }, + { desc => 'Holds Ids for holds to update', type => 'array' }, + ], + return => { desc => '1 on success' } + } +); + + sub change_hold_title { my( $self, $client, $auth, $new_bib_id, $bib_ids ) = @_; @@ -3458,6 +3474,41 @@ sub change_hold_title { return 1; } +sub change_hold_title_for_specific_holds { + my( $self, $client, $auth, $new_bib_id, $hold_ids ) = @_; + + my $e = new_editor(authtoken=>$auth, xact=>1); + return $e->die_event unless $e->checkauth; + + my $holds = $e->search_action_hold_request( + [ + { + cancel_time => undef, + fulfillment_time => undef, + hold_type => 'T', + id => $hold_ids + }, + { + flesh => 1, + flesh_fields => { ahr => ['usr'] } + } + ], + { substream => 1 } + ); + + for my $hold (@$holds) { + $e->allowed('UPDATE_HOLD', $hold->usr->home_ou) or return $e->die_event; + $logger->info("Changing hold " . $hold->id . " target from " . $hold->target . " to $new_bib_id in title hold target change"); + $hold->target( $new_bib_id ); + $e->update_action_hold_request($hold) or return $e->die_event; + } + + $e->commit; + + _reset_hold($self, $e->requestor, $_) for @$holds; + + return 1; +} __PACKAGE__->register_method( method => 'rec_hold_count',