[open-ils-commits] r15472 - trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ (phasefx)
svn at svn.open-ils.org
svn at svn.open-ils.org
Mon Feb 8 13:32:19 EST 2010
Author: phasefx
Date: 2010-02-08 13:32:15 -0500 (Mon, 08 Feb 2010)
New Revision: 15472
Modified:
trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm
Log:
Method for moving title holds from their current bibs to a new bib.
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm 2010-02-08 17:40:51 UTC (rev 15471)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm 2010-02-08 18:32:15 UTC (rev 15472)
@@ -2333,7 +2333,57 @@
return $e->json_query($query)->[0];
}
+__PACKAGE__->register_method(
+ method => 'change_hold_title',
+ api_name => 'open-ils.circ.hold.change_title',
+ signature => {
+ desc => q/
+ Updates all title level holds targeting the specified bibs to point a new bib./,
+ params => [
+ {desc => 'Authentication Token', type => 'string'},
+ {desc => 'New Target Bib Id', type => 'number'},
+ {desc => 'Old Target Bib Ids', type => 'array'},
+ ],
+ return => { desc => '1 on success' }
+ }
+);
+sub change_hold_title {
+ my( $self, $client, $auth, $new_bib_id, $bib_ids ) = @_;
+ my $e = new_editor(authtoken=>$auth, xact=>1);
+ return $e->event unless $e->checkauth;
+ my $holds = $e->json_query({
+ "select"=>{"ahr"=>["id"]},
+ "from"=>"ahr",
+ "where"=>{
+ cancel_time => undef,
+ fulfillment_time => undef,
+ hold_type => 'T',
+ target => $bib_ids
+ }
+ });
+
+ for my $hold_id (@$holds) {
+ my $hold = $e->retrieve_action_hold_request([$hold_id->{id}, {
+ flesh=> 1,
+ flesh_fields=>{ahr=>['usr']}
+ }
+ ]);
+ $e->allowed('UPDATE_HOLD', $hold->usr->home_ou) or return $e->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 );
+ unless ($e->update_action_hold_request($hold)) {
+ my $evt = $e->event;
+ $logger->error("Error updating hold " . $evt->textcode . ":" . $evt->desc . ":" . $evt->stacktrace);
+ }
+ }
+
+ $e->commit;
+
+ return 1;
+}
+
+
1;
More information about the open-ils-commits
mailing list