$logger->info("vol-update: updating copy ".$copy->id);
my $orig_copy = $editor->retrieve_asset_copy($copy->id);
- my $orig_vol = $editor->retrieve_asset_call_number($copy->call_number);
+
+ # Call-number may have changed, find the original
+ my $orig_vol_id = $editor->json_query({select => {acp => ['call_number']}, from => 'acp', where => {id => $copy->id}});
+ my $orig_vol = $editor->retrieve_asset_call_number($orig_vol_id->[0]->{call_number});
$copy->editor($editor->requestor->id);
$copy->edit_date('now');
my $evt = OpenILS::Application::Cat::BibCommon->delete_rec($editor, $vol->record);
return $evt if $evt;
}
- }
+
+ } else {
+
+ # this may be the last copy attached to the volume.
+
+ if($U->ou_ancestor_setting_value(
+ $editor->requestor->ws_ou, 'cat.volume.delete_on_empty', $editor)) {
+
+ # if this volume is "empty" and not mid-delete, delete it.
+ unless($U->is_true($vol->deleted) || $vol->isdeleted) {
+
+ my $copies = $editor->search_asset_copy(
+ [{call_number => $vol->id, deleted => 'f'}, {limit => 1}], {idlist => 1});
+
+ if(!@$copies) {
+ my $evt = $class->delete_volume($editor, $vol, $override, 0, 1);
+ return $evt if $evt;
+ }
+ }
+ }
+ }
return undef;
}
'interval'
);
+INSERT INTO config.org_unit_setting_type
+( name, label, description, datatype ) VALUES
+( 'cat.volume.delete_on_empty',
+ oils_i18n_gettext('cat.volume.delete_on_empty', 'Cat: Delete volume with last copy', 'coust', 'label'),
+ oils_i18n_gettext('cat.volume.delete_on_empty', 'Automatically delete a volume when the last linked copy is deleted', 'coust', 'description'),
+ 'bool'
+);
+
document.getElementById('commonStrings').getString('common.confirm')
);
- if (r == 0) {
+ if (r == 0) { // delete vols
for (var i = 0; i < list.length; i++) {
list[i].isdeleted('1');
}
- var robj = obj.network.simple_request(
- 'FM_ACN_TREE_UPDATE',
- [ ses(), list, true ],
- null,
- {
- 'title' : document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_volume.override'),
- 'overridable_events' : [
- ]
- }
- );
- if (robj == null) throw(robj);
- if (typeof robj.ilsevent != 'undefined') {
- if (robj.ilsevent == 1206 /* VOLUME_NOT_EMPTY */) {
- alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_volume.copies_remain'));
- return;
+ var params = {};
+ loop: while(true) {
+ var robj = obj.network.simple_request(
+ 'FM_ACN_TREE_UPDATE',
+ [ ses(), list, true, params ],
+ null,
+ {
+ 'title' : document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_volume.override'),
+ 'overridable_events' : [
+ ]
+ }
+ );
+ if (robj == null) throw(robj);
+ if (typeof robj.ilsevent != 'undefined') {
+ if (robj.ilsevent == 1206 /* VOLUME_NOT_EMPTY */) {
+ var r2 = obj.error.yns_alert(
+ document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_volume.copies_remain'),
+ document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_volume.title'),
+ document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_volume.copies_remain.confirm'),
+ document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_volume.copies_remain.cancel'),
+ null,
+ document.getElementById('commonStrings').getString('common.confirm')
+ );
+ if (r2 == 0) { // delete vols and copies
+ params.force_delete_copies = true;
+ continue loop;
+ }
+ } else {
+ if (robj.ilsevent != 0) throw(robj);
+ }
}
- if (robj.ilsevent != 0) throw(robj);
+ break loop;
}
obj.refresh_list();
}
for (var i = 0; i < list.length; i++) {
list[i].isdeleted('1');
}
- var robj = obj.network.simple_request(
- 'FM_ACN_TREE_UPDATE',
- [ ses(), list, true ],
- null,
- {
- 'title' : document.getElementById('circStrings').getString('staff.circ.copy_status.delete_volumes.override'),
- 'overridable_events' : [
- ]
- }
- );
- if (robj == null) throw(robj);
- if (typeof robj.ilsevent != 'undefined') {
- if (robj.ilsevent == 1206 /* VOLUME_NOT_EMPTY */) {
- alert(document.getElementById('circStrings').getString('staff.circ.copy_status.delete_volumes.delete_copies'));
- return;
+ var params = {};
+ loop: while(true) {
+ var robj = obj.network.simple_request(
+ 'FM_ACN_TREE_UPDATE',
+ [ ses(), list, true, params ],
+ null,
+ {
+ 'title' : document.getElementById('circStrings').getString('staff.circ.copy_status.delete_volumes.override'),
+ 'overridable_events' : [
+ ]
+ }
+ );
+ if (robj == null) throw(robj);
+ if (typeof robj.ilsevent != 'undefined') {
+ if (robj.ilsevent == 1206 /* VOLUME_NOT_EMPTY */) {
+ var r2 = obj.error.yns_alert(
+ document.getElementById('circStrings').getString('staff.circ.copy_status.delete_volumes.delete_copies'),
+ document.getElementById('circStrings').getString('staff.circ.copy_status.delete_volumes.title'),
+ document.getElementById('circStrings').getString('staff.circ.copy_status.delete_volumes.delete_copies.confirm'),
+ document.getElementById('circStrings').getString('staff.circ.copy_status.delete_volumes.delete_copies.cancel'),
+ null,
+ document.getElementById('commonStrings').getString('common.confirm')
+ );
+ if (r2 == 0) { // delete vols and copies
+ params.force_delete_copies = true;
+ continue loop;
+ }
+ } else {
+ if (robj.ilsevent != 0) { throw(robj); }
+ }
}
- if (robj.ilsevent != 0) { throw(robj); }
+ break loop;
}
alert(document.getElementById('circStrings').getString('staff.circ.copy_status.delete_volumes.success'));
}
staff.cat.copy_browser.delete_volume.delete=Delete
staff.cat.copy_browser.delete_volume.cancel=Cancel
staff.cat.copy_browser.delete_volume.override=Override Delete Failure?
-staff.cat.copy_browser.delete_volume.copies_remain=You must delete all the copies on the volume before you may delete the volume itself.
+staff.cat.copy_browser.delete_volume.copies_remain=You must delete all the items on the volume before you may delete the volume itself.
+staff.cat.copy_browser.delete_volume.copies_remain.confirm=Delete Volume and Items
+staff.cat.copy_browser.delete_volume.copies_remain.cancel=Cancel Delete
staff.cat.copy_browser.delete_volume.exception=copy browser -> delete volumes
staff.cat.copy_browser.mark_library.alert=Library + Record marked as Volume Transfer Destination
staff.cat.copy_browser.mark_library.prompt=Choose just one Library to mark as Volume Transfer Destination
staff.circ.copy_status.delete_volumes.delete=Delete
staff.circ.copy_status.delete_volumes.cancel=Cancel
staff.circ.copy_status.delete_volumes.override=Override Delete Failure?
-staff.circ.copy_status.delete_volumes.delete_copies=You must delete all the copies on the volume before you may delete the volume itself.
+staff.circ.copy_status.delete_volumes.delete_copies=You must delete all the items on the volume before you may delete the volume itself.
+staff.circ.copy_status.delete_volumes.delete_copies.confirm=Delete Volume and Items
+staff.circ.copy_status.delete_volumes.delete_copies.cancel=Cancel Delete
staff.circ.copy_status.delete_volumes.success=Volumes deleted.
staff.circ.copy_status.mark_volume.status=Volume marked as Item Transfer Destination
staff.circ.copy_status.mark_volume.prompt=Choose just one Volume to mark as Item Transfer Destination