}
);
+__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 ) = @_;
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',
<!ENTITY staff.cat.opac.mark_for_hold_transfer.accesskey "">
<!ENTITY staff.cat.opac.mark_for_hold_transfer.label "Mark as Title Hold Transfer Destination">
<!ENTITY staff.cat.opac.transfer_title_holds.accesskey "">
-<!ENTITY staff.cat.opac.transfer_title_holds.label "Transfer Title Holds">
+<!ENTITY staff.cat.opac.transfer_title_holds.label "Transfer All Title Holds">
<!ENTITY staff.cat.opac.delete_record.accesskey "D">
<!ENTITY staff.cat.opac.delete_record.label "Delete Record">
<!ENTITY staff.cat.opac.undelete_record.accesskey "U">
'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' },
'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 };
}
}
+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();
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.
['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
}
}
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);