const rel_vert_pos_part = 8;
var g = {};
g.use_defaults = true;
+g.acn_map = {}; // store retrieved acn objects here by id
function my_init() {
try {
var volumes = [];
var copies = [];
- var volume_labels = {};
+ var volume_data = {};
function new_copy(acp_id,ou_id,acn_id,barcode) {
var copy = new acp();
continue;
}
- volume_labels[ acn_id ] = {
+ var my_acn;
+ if (typeof g.acn_map[ acn_id ] == 'undefined') {
+ my_acn = g.network.simple_request(
+ 'FM_ACN_RETRIEVE.authoritative',
+ [ acn_id ]
+ );
+ if (typeof my_acn.ilsevent != 'undefined') {
+ g.error.standard_unexpected_error_alert($("catStrings").getFormattedString('staff.cat.volume_copy_creator.stash_and_close.problem_with_volume', [cn]), acn_id);
+ continue;
+ }
+ g.acn_map[ acn_id ] = my_acn;
+ }
+ my_acn = g.acn_map[ acn_id ];
+
+ volume_data[ acn_id ] = {
'label' : cn_label,
'owning_lib' : ou_id
};
for (var i in volumes_hash[ou_id][cn_label].call_number_data) {
- volume_labels[ acn_id ][ i ] = volumes_hash[ou_id][cn_label].call_number_data[i];
+ volume_data[ acn_id ][ i ] = volumes_hash[ou_id][cn_label].call_number_data[i];
+ }
+
+ if (volume_data[ acn_id ][ 'acnc_id' ]) {
+ var new_value = volume_data[ acn_id ][ 'acnc_id' ];
+ if (Number(my_acn.label_class()) != Number(new_value)) {
+ my_acn.label_class( Number(new_value) );
+ my_acn.ischanged( get_db_true() );
+ }
+ }
+ if (volume_data[ acn_id ][ 'ancp_id' ]) {
+ var new_value = volume_data[ acn_id ][ 'ancp_id' ];
+ if (Number(my_acn.prefix()) != Number(new_value)) {
+ my_acn.prefix( Number(new_value) );
+ my_acn.ischanged( get_db_true() );
+ }
+ }
+ if (volume_data[ acn_id ][ 'acns_id' ]) {
+ var new_value = volume_data[ acn_id ][ 'acns_id' ];
+ if (Number(my_acn.suffix()) != Number(new_value)) {
+ my_acn.suffix( Number(new_value) );
+ my_acn.ischanged( get_db_true() );
+ }
+ }
+
+ if (get_bool( my_acn.ischanged() )) {
+ dump('******\nPUSHING my_acn = ' + js2JSON(my_acn) + '\n',4);
+ volumes.push( my_acn );
+ } else {
+ dump('******\nNOT PUSHING my_acn = ' + js2JSON(my_acn) + '\n',4);
}
for (var i = 0; i < volumes_hash[ou_id][cn_label].barcode_data.length; i++) {
}
xulG.copies = copies;
- return copies;
+ xulG.volumes = volumes;
+ return { 'copies' : copies, 'volumes' : volumes };
} catch(E) {
g.error.standard_unexpected_error_alert('Error in volume_copy_creator.js, g.gather_copies():',E);
try {
+ var volumes;
var copies;
if (xulG.unified_interface) {
copies = xulG.copies;
+ volumes = xulG.volumes;
} else {
- copies = g.gather_copies();
+ var blob = g.gather_copies();
+ copies = blob.copies;
+ volumes = blob.volumes;
}
var dont_close = false;
if (param == 'edit') {
copies = cat.util.spawn_copy_editor( { 'edit' : true, 'docid' : g.doc_id, 'copies' : copies, 'caller_handles_update' : true });
}
+ if (typeof xul_param('update_volume') == 'function') {
+ xul_param('update_volume')(volumes);
+ } else {
+ var r = g.network.simple_request(
+ 'FM_ACN_TREE_UPDATE',
+ [ ses(),volumes, false, { 'auto_merge_vols' : false } ]
+ );
+ if (typeof r.ilsevent != 'undefined') {
+ g.error.standard_unexpected_error_alert('volume update',r);
+ }
+ }
if (typeof xul_param('update_copy') == 'function') {
xul_param('update_copy')(copies);
} else {