From: Jason Etheridge Date: Mon, 27 Jun 2011 18:41:52 +0000 (-0400) Subject: Saner behavior for Actions for Selected Holds -> Transfer to Marked Title X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=3ceb08279ef050aaf9bad7b0914bb24fa8b2a23e;p=evergreen%2Fequinox.git Saner behavior for Actions for Selected Holds -> Transfer to Marked Title * Transfer the actual selected title holds, rather than all title holds for the bibs referenced by those selected. * middle layer method for changing the target and resetting specified holds * label change for clarity, Transfer All Title Holds Signed-off-by: Jason Etheridge Signed-off-by: Bill Erickson --- 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', diff --git a/Open-ILS/web/opac/locale/en-US/lang.dtd b/Open-ILS/web/opac/locale/en-US/lang.dtd index a1faa6968a..63e992714d 100644 --- a/Open-ILS/web/opac/locale/en-US/lang.dtd +++ b/Open-ILS/web/opac/locale/en-US/lang.dtd @@ -300,7 +300,7 @@ - + diff --git a/Open-ILS/xul/staff_client/chrome/content/main/constants.js b/Open-ILS/xul/staff_client/chrome/content/main/constants.js index 6743d9588f..d02c17224f 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/constants.js +++ b/Open-ILS/xul/staff_client/chrome/content/main/constants.js @@ -145,6 +145,7 @@ var api = { 'FM_AHR_RESET' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.hold.reset' }, 'FM_AHR_STATUS' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.hold.status.retrieve' }, 'TRANSFER_TITLE_HOLDS' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.hold.change_title' }, + 'TRANSFER_SPECIFIC_TITLE_HOLDS' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.hold.change_title.specific_holds' }, 'FM_AHRCC_PCRUD_SEARCH' : { 'app' : 'open-ils.pcrud', 'method' : 'open-ils.pcrud.search.ahrcc.atomic', 'secure' : false }, 'FM_AIHU_CREATE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.in_house_use.create' }, 'FM_ANCC_RETRIEVE_VIA_ID' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.non_cataloged_circulation.retrieve' }, diff --git a/Open-ILS/xul/staff_client/server/cat/util.js b/Open-ILS/xul/staff_client/server/cat/util.js index 98e7e4956b..ea543b7722 100644 --- a/Open-ILS/xul/staff_client/server/cat/util.js +++ b/Open-ILS/xul/staff_client/server/cat/util.js @@ -9,7 +9,7 @@ cat.util.EXPORT_OK = [ 'spawn_copy_editor', 'add_copies_to_bucket', 'show_in_opac', 'spawn_spine_editor', 'transfer_copies', 'transfer_title_holds', 'mark_item_missing', 'mark_item_damaged', 'replace_barcode', 'fast_item_add', 'make_bookable', 'edit_new_brsrc', 'edit_new_bresv', 'batch_edit_volumes', 'render_fine_level', - 'render_loan_duration', 'mark_item_as_missing_pieces' + 'render_loan_duration', 'mark_item_as_missing_pieces', 'transfer_specific_title_holds' ]; cat.util.EXPORT_TAGS = { ':all' : cat.util.EXPORT_OK }; @@ -115,6 +115,37 @@ cat.util.transfer_title_holds = function(old_targets) { } } +cat.util.transfer_specific_title_holds = function(hold_ids,unique_targets) { + JSAN.use('OpenILS.data'); var data = new OpenILS.data(); + JSAN.use('util.network'); var network = new util.network(); + try { + data.stash_retrieve(); + var target = data.marked_record_for_hold_transfer; + if (!target) { + var m = $("catStrings").getString('staff.cat.opac.title_for_hold_transfer.destination_needed.label'); + alert(m); + return; + } + if (unique_targets.length > 1) { + var m = $("catStrings").getString('staff.cat.opac.title_for_hold_transfer.many_bibs.warning'); + if (! window.confirm(m)) { + return; + } + } + var robj = network.simple_request('TRANSFER_SPECIFIC_TITLE_HOLDS',[ ses(), target, hold_ids ]); + if (robj == 1) { + var m = $("catStrings").getString('staff.cat.opac.title_for_hold_transfer.success.label'); + alert(m); + } else { + var m = $("catStrings").getString('staff.cat.opac.title_for_hold_transfer.failure.label'); + alert(m); + } + } catch(E) { + alert('Error in cat.util.transfer_title.holds(): ' + E); + } +} + + cat.util.transfer_copies = function(params) { JSAN.use('util.error'); var error = new util.error(); JSAN.use('OpenILS.data'); var data = new OpenILS.data(); diff --git a/Open-ILS/xul/staff_client/server/locale/en-US/cat.properties b/Open-ILS/xul/staff_client/server/locale/en-US/cat.properties index f75c4e9ca4..f035034882 100644 --- a/Open-ILS/xul/staff_client/server/locale/en-US/cat.properties +++ b/Open-ILS/xul/staff_client/server/locale/en-US/cat.properties @@ -281,6 +281,7 @@ staff.cat.opac.set_tab_name=Record: %1$s staff.cat.opac.title_for_hold_transfer.destination_needed.label=Need to mark a record as a Title Hold Transfer Destination first. staff.cat.opac.title_for_hold_transfer.success.label=Holds transferred. staff.cat.opac.title_for_hold_transfer.failure.label=Holds not transferred. +staff.cat.opac.title_for_hold_transfer.many_bibs.warning=WARNING: Move selected holds from multiple bibs to single targeted bib? staff.cat.record_buckets.tab_name=Record Buckets staff.cat.record_buckets.save_file_as=Save File As staff.cat.record_buckets.export_records.alert=File not downloaded. diff --git a/Open-ILS/xul/staff_client/server/patron/holds.js b/Open-ILS/xul/staff_client/server/patron/holds.js index 085c54ab6b..c48600917d 100644 --- a/Open-ILS/xul/staff_client/server/patron/holds.js +++ b/Open-ILS/xul/staff_client/server/patron/holds.js @@ -1198,16 +1198,23 @@ patron.holds.prototype = { ['command'], function() { try { - var targets = []; + var hids = []; + var unique_targets = []; + var seen_target = {}; for (var i = 0; i < obj.retrieve_ids.length; i++) { - var htarget = obj.retrieve_ids[i].target; + var hid = obj.retrieve_ids[i].id; + var htarget = obj.retrieve_ids[i].id; var htype = obj.retrieve_ids[i].type; switch(htype) { case 'M' : continue; // not supported break; case 'T' : - targets.push( htarget ); + hids.push( hid ); + if (! seen_target[htarget]) { + unique_targets.push( htarget ); + seen_target[htarget] = 1; + } break; case 'V' : continue; // not supported @@ -1221,7 +1228,7 @@ patron.holds.prototype = { } } JSAN.use('cat.util'); - cat.util.transfer_title_holds(targets); + cat.util.transfer_specific_title_holds(hids,unique_targets); obj.clear_and_retrieve(); } catch(E) { obj.error.standard_unexpected_error_alert('',E);