From: dbs Date: Tue, 12 Apr 2011 13:42:03 +0000 (+0000) Subject: We trust in 2.0 for spine label printing and formatting now X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=0f1cb9924c733ea34a3f03e0e9007d075ec1585f;p=contrib%2FConifer.git We trust in 2.0 for spine label printing and formatting now git-svn-id: svn://svn.open-ils.org/ILS-Contrib/conifer/branches/rel_2_0@1332 6d9bc8c9-1ec2-4278-b937-99fde70a366f --- diff --git a/xul/server/cat/spine_labels.js b/xul/server/cat/spine_labels.js deleted file mode 100644 index 2d16945bd8..0000000000 --- a/xul/server/cat/spine_labels.js +++ /dev/null @@ -1,298 +0,0 @@ - function my_init() { - try { - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); - if (typeof JSAN == 'undefined') { throw( $("commonStrings").getString('common.jsan.missing') ); } - JSAN.errorLevel = "die"; // none, warn, or die - JSAN.addRepository('/xul/server/'); - JSAN.use('util.error'); g.error = new util.error(); - g.error.sdump('D_TRACE','my_init() for spine_labels.xul'); - - JSAN.use('util.network'); g.network = new util.network(); - - g.cgi = new CGI(); - - g.barcodes = []; - if (g.cgi.param('barcodes')) { - g.barcodes = g.barcodes.concat( JSON2js(g.cgi.param('barcodes')) ); - } - JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.stash_retrieve(); - if (g.data.temp_barcodes_for_labels) { - g.barcodes = g.barcodes.concat( g.data.temp_barcodes_for_labels ); - g.data.temp_barcodes_for_labels = null; g.data.stash('temp_barcodes_for_labels'); - } - - JSAN.use('circ.util'); - g.cols = circ.util.columns( {} ); - g.col_map = {}; - for (var i = 0; i < g.cols.length; i++) { - g.col_map[ g.cols[i].id ] = { 'regex' : new RegExp('%' + g.cols[i].id + '%',"g"), 'render' : g.cols[i].render }; - } - - g.volumes = {}; - - for (var i = 0; i < g.barcodes.length; i++) { - var copy = g.network.simple_request( 'FM_ACP_RETRIEVE_VIA_BARCODE.authoritative', [ g.barcodes[i] ] ); - if (typeof copy.ilsevent != 'undefined') throw(copy); - if (!g.volumes[ copy.call_number() ]) { - var volume = g.network.simple_request( 'FM_ACN_RETRIEVE.authoritative', [ copy.call_number() ] ); - if (typeof volume.ilsevent != 'undefined') throw(volume); - var record = g.network.simple_request('MODS_SLIM_RECORD_RETRIEVE.authoritative', [ volume.record() ]); - volume.record( record ); - g.volumes[ volume.id() ] = volume; - } - if (g.volumes[ copy.call_number() ].copies()) { - var copies = g.volumes[ copy.call_number() ].copies(); - copies.push( copy ); - g.volumes[ copy.call_number() ].copies( copies ); - } else { - g.volumes[ copy.call_number() ].copies( [ copy ] ); - } - } - - generate(); - - if (typeof xulG != 'undefined') $('close').hidden = true; - - } catch(E) { - try { - g.error.standard_unexpected_error_alert('/xul/server/cat/spine_labels.xul',E); - } catch(F) { - alert('FIXME: ' + js2JSON(E)); - } - } - } - - function show_macros() { - JSAN.use('util.functional'); - alert( util.functional.map_list( g.cols, function(o) { return '%' + o.id + '%'; } ).join(" ") ); - } - - function $(id) { return document.getElementById(id); } - - function generate() { - try { - var idx = 0; - JSAN.use('util.text'); JSAN.use('util.money'); - JSAN.use('util.widgets'); util.widgets.remove_children('panel'); var pn = $('panel'); $('preview').disabled = false; - var lw = Number($('lw').value) || 8; /* spine label width */ - var ll = Number($('ll').value) || 9; /* spine label length */ - var plw = Number($('plw').value) || 28; /* pocket label width */ - var pll = Number($('pll').value) || 9; /* pocket label length */ - for (var i in g.volumes) { - var vb = document.createElement('vbox'); pn.appendChild(vb); vb.setAttribute('name','template'); vb.setAttribute('acn_id',g.volumes[i].id()); - var ds = document.createElement('description'); vb.appendChild(ds); - ds.appendChild( document.createTextNode( g.volumes[i].label() ) ); - var ds2 = document.createElement('description'); vb.appendChild(ds2); - ds2.appendChild( document.createTextNode( g.volumes[i].copies().length + ( - g.volumes[i].copies().length == 1 ? $("catStrings").getString('staff.cat.spine_labels.copy') : $("catStrings").getString('staff.cat.spine_labels.copies')) ) ); - ds2.setAttribute('style','color: green'); - var hb = document.createElement('hbox'); vb.appendChild(hb); - - var gb = document.createElement('groupbox'); hb.appendChild(gb); - /* take the call number and split it on whitespace */ - var names = String(g.volumes[i].label()).split(/\s+/); - var j = 0; - while (j < ll || j < pll) { - var hb2 = document.createElement('hbox'); gb.appendChild(hb2); - - /* spine */ - if (j < ll) { - var tb = document.createElement('textbox'); hb2.appendChild(tb); - tb.value = ''; - tb.setAttribute('class','plain'); tb.setAttribute('style','font-family: Arial, Helvetica, sans-serif'); tb.setAttribute('font-weight','bold'); - tb.setAttribute('size',lw+1); tb.setAttribute('maxlength',lw); - tb.setAttribute('name','spine'); - var name = names.shift(); if (name) { - name = String( name ); - /* if the name is greater than the label width... */ - if (name.length > lw) { - /* then try to split it on periods */ - var sname = name.split(/\./); - if (sname.length > 1) { - /* if we can, then put the periods back in on each splitted element */ - if (name.match(/^\./)) sname[0] = '.' + sname[0]; - for (var k = 1; k < sname.length; k++) sname[k] = '.' + sname[k]; - /* and put all but the first one back into the names array */ - names = sname.slice(1).concat( names ); - /* if the name fragment is still greater than the label width... */ - if (sname[0].length > lw) { - /* then just truncate and throw the rest back into the names array */ - tb.value = sname[0].substr(0,lw); - names = [ sname[0].substr(lw) ].concat( names ); - } else { - /* otherwise we're set */ - tb.value = sname[0]; - } - } else { - /* if we can't split on periods, then just truncate and throw the rest back into the names array */ - tb.value = name.substr(0,lw); - names = [ name.substr(lw) ].concat( names ); - } - } else { - /* otherwise we're set */ - tb.value = name; - } - } - } - - /* pocket */ - if ($('pl').checked && j < pll) { - var tb2 = document.createElement('textbox'); hb2.appendChild(tb2); - tb2.value = ''; - tb2.setAttribute('class','plain'); tb2.setAttribute('style','font-family: Arial, Helvetica, sans-serif'); tb2.setAttribute('font-weight','bold'); - tb2.setAttribute('size',plw+1); tb2.setAttribute('maxlength',plw); - tb2.setAttribute('name','pocket'); - if ($('title').checked && $('title_line').value == j + 1 && instanceOf(g.volumes[i].record(),mvr)) { - if (g.volumes[i].record().title()) { - tb2.value = util.text.wrap_on_space( g.volumes[i].record().title(), plw )[0]; - } else { - tb2.value = ''; - } - } - if ($('title_r').checked && $('title_r_line').value == j + 1 && instanceOf(g.volumes[i].record(),mvr)) { - if (g.volumes[i].record().title()) { - tb2.value = ( ($('title_r_indent').checked ? ' ' : '') + util.text.wrap_on_space( g.volumes[i].record().title(), plw )[1]).substr(0,plw); - } else { - tb2.value = ''; - } - } - if ($('author').checked && $('author_line').value == j + 1 && instanceOf(g.volumes[i].record(),mvr)) { - if (g.volumes[i].record().author()) { - tb2.value = g.volumes[i].record().author().substr(0,plw); - } else { - tb2.value = ''; - } - } - if ($('call_number').checked && $('call_number_line').value == j + 1) { - tb2.value = g.volumes[i].label().substr(0,plw); - } - if ($('owning_lib_shortname').checked && $('owning_lib_shortname_line').value == j + 1) { - var lib = g.volumes[i].owning_lib(); - if (!instanceOf(lib,aou)) lib = g.data.hash.aou[ lib ]; - tb2.value = lib.shortname().substr(0,plw); - } - if ($('owning_lib').checked && $('owning_lib_line').value == j + 1) { - var lib = g.volumes[i].owning_lib(); - if (!instanceOf(lib,aou)) lib = g.data.hash.aou[ lib ]; - tb2.value = lib.name().substr(0,plw); - } - if ($('shelving_location').checked && $('shelving_location_line').value == j + 1) { - tb2.value = '%location%'; - } - if ($('barcode').checked && $('barcode_line').value == j + 1) { - tb2.value = '%barcode%'; - } - if ($('custom1').checked && $('custom1_line').value == j + 1) { - tb2.value = $('custom1_tb').value; - } - if ($('custom2').checked && $('custom2_line').value == j + 1) { - tb2.value = $('custom2_tb').value; - } - if ($('custom3').checked && $('custom3_line').value == j + 1) { - tb2.value = $('custom3_tb').value; - } - if ($('custom4').checked && $('custom4_line').value == j + 1) { - tb2.value = $('custom4_tb').value; - } - } - - j++; - } - - idx++; - } - } catch(E) { - g.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.spine_labels.generate.std_unexpeceted_err'),E); - } - } - - function expand_macros(text,copy,volume,record) { - var my = { 'acp' : copy, 'acn' : volume, 'mvr' : record }; - var obj = { 'data' : g.data }; - for (var i in g.col_map) { - var re = g.col_map[i].regex; - if (text.match(re)) { - try { - text = text.replace(re, (typeof g.col_map[i].render == 'function' ? g.col_map[i].render(my) : eval( g.col_map[i].render ) ) ); - } catch(E) { - g.error.sdump('D_ERROR','spine_labels.js, expand_macros() = ' + E); - } - } - } - return text; - } - - function preview(idx) { - try { - netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); - var pt = Number( $('pt').value ) || 10; /* font size */ - var lm = Number($('lm').value); if (lm == NaN) lm = 11; /* left margin */ - var mm = Number($('mm').value); if (mm == NaN) mm = 2; /* middle margin */ - var lw = Number($('lw').value) || 8; var ll = Number($('ll').value) || 9; /* spine label width and length */ - var plw = Number($('plw').value) || 28; var pll = Number($('pll').value) || 9; /* pocket label width and length */ - var html = ""; - html += "" - html += ""; - html += "Spine Labels\n"; - var nl = document.getElementsByAttribute('name','template'); - for (var i = 0; i < nl.length; i++) { - if (typeof idx == 'undefined' || idx == null) { } else { - if (idx != i) continue; - } - var volume = g.volumes[ nl[i].getAttribute('acn_id') ]; - - for (var j = 0; j < volume.copies().length; j++) { - var copy = volume.copies()[j]; - if (i == 0) { - html += '
\n';
-                            } else {
-                                html += '
\n';
-                            }
-                            var gb = nl[i].getElementsByTagName('groupbox')[0];
-                            var nl2 = gb.getElementsByAttribute('name','spine');
-                            for (var k = 0; k < nl2.length; k++) {
-                                for (var m = 0; m < lm; m++) html += ' ';
-                                html += util.text.preserve_string_in_html(expand_macros( nl2[k].value, copy, volume, volume.record() ).substr(0,lw));
-                                if ($('pl').checked) {
-                                    var sib = nl2[k].nextSibling;
-                                    if (sib) {
-                                        for (var m = 0; m < lw - nl2[k].value.length; m++) html += ' ';
-                                        for (var m = 0; m < mm; m++) html += ' ';
-                                        html += util.text.preserve_string_in_html(expand_macros( sib.value, copy, volume, volume.record() ).substr(0,plw));
-                                    }
-                                }
-                                html += '\n';
-                            }
-                            html += '
\n'; - } - } - html += ''; - JSAN.use('util.window'); var win = new util.window(); - var loc = ( urls.XUL_REMOTE_BROWSER ); - //+ '?url=' + window.escape('about:blank') + '&show_print_button=1&alternate_print=1&no_xulG=1&title=' + window.escape('Spine Labels'); - var w = win.open( loc, 'spine_preview', 'chrome,resizable,width=750,height=550'); - w.xulG = { - 'url' : 'about:blank', - 'show_print_button' : 1, - 'alternate_print' : 1, - 'no_xulG' : 1, - 'title' : $("catStrings").getString('staff.cat.spine_labels.preview.title'), - 'on_url_load' : function(b) { - try { - netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); - if (typeof w.xulG.written == 'undefined') { - w.xulG.written = true; - w.g.browser.get_content().document.write(html); - w.g.browser.get_content().document.close(); - } - } catch(E) { - alert(E); - } - } - }; - } catch(E) { - g.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.spine_labels.preview.std_unexpected_err'),E); - } - } - - diff --git a/xul/server/cat/volume_copy_creator.js b/xul/server/cat/volume_copy_creator.js deleted file mode 100644 index fa7ba9e22a..0000000000 --- a/xul/server/cat/volume_copy_creator.js +++ /dev/null @@ -1,475 +0,0 @@ -const g_max_copies_that_can_be_added_at_a_time_per_volume = 100; -var g = {}; - -function my_init() { - try { - - /***********************************************************************************************************/ - /* Initial setup */ - - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); - if (typeof JSAN == 'undefined') { throw( $("commonStrings").getString('common.jsan.missing') ); } - JSAN.errorLevel = "die"; // none, warn, or die - JSAN.addRepository('/xul/server/'); - JSAN.use('util.error'); g.error = new util.error(); - g.error.sdump('D_TRACE','my_init() for cat/volume_copy_creator.xul'); - - JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.init({'via':'stash'}); - JSAN.use('util.widgets'); JSAN.use('util.functional'); - - JSAN.use('util.network'); g.network = new util.network(); - - /***********************************************************************************************************/ - /* What record am I dealing with? Am I adding just copies or copies and volumes? */ - - g.doc_id = xul_param('doc_id'); - var sb = document.getElementById('summary_box'); while(sb.firstChild) sb.removeChild(sb.lastChild); - var summary = document.createElement('iframe'); sb.appendChild(summary); - summary.setAttribute('src',urls.XUL_BIB_BRIEF); - summary.setAttribute('flex','1'); - get_contentWindow(summary).xulG = { 'docid' : g.doc_id }; - - g.copy_shortcut = xul_param('copy_shortcut',{'JSON2js_if_cgi':true}); - g.error.sdump('D_ERROR','location.href = ' + location.href + '\n\ncopy_short cut = ' + g.copy_shortcut + '\n\nou_ids = ' + xul_param('ou_ids')); - - var ou_ids = xul_param('ou_ids',{'JSON2js_if_cgi' : true, 'concat' : true});; - - /***********************************************************************************************************/ - /* For the call number drop down */ - - var cn_blob; - try { - cn_blob = g.network.simple_request('BLOB_MARC_CALLNUMBERS_RETRIEVE',[g.doc_id]); - } catch(E) { - cn_blob = []; - } - if ((!g.copy_shortcut)) { - var hbox = document.getElementById('marc_cn'); - var ml = util.widgets.make_menulist( - util.functional.map_list( - cn_blob, - function(o) { - for (var i in o) { - return [ o[i], i ]; - } - } - ).sort( - function(a,b) { - a = a[1]; b = b[1]; - /* Return LC call number first; good for most universities */ - if (a == '050') return -1; - if (b == '050') return 1; - /* Return NLM call number next; good for our health libraries */ - if (a == '060') return -1; - if (b == '060') return 1; - /* Return Dewey next; good for Universite de Hearst */ - if (a == '082') return -1; - if (b == '082') return 1; - if (a == '092') return -1; - if (b == '092') return 1; - if (a < b) return -1; - if (a > b) return 1; - return 0; - } - ) - ); hbox.appendChild(ml); - ml.setAttribute('editable','true'); - ml.setAttribute('width', '200'); - var btn = document.createElement('button'); - btn.setAttribute('label',$('catStrings').getString('staff.cat.volume_copy_creator.my_init.btn.label')); - btn.setAttribute('accesskey','A'); - btn.setAttribute('image','/xul/server/skin/media/images/down_arrow.gif'); - hbox.appendChild(btn); - btn.addEventListener( - 'command', - function() { - var nl = document.getElementsByTagName('textbox'); - for (var i = 0; i < nl.length; i++) { - if (nl[i].getAttribute('rel_vert_pos')==2 - && !nl[i].disabled) nl[i].value = ml.value; - } - if (g.last_focus) setTimeout( function() { g.last_focus.focus(); }, 0 ); - }, - false - ); - } - - /***********************************************************************************************************/ - /* render the orgs and volumes/input */ - - var rows = document.getElementById('rows'); - - var node_id = 0; - for (var i = 0; i < ou_ids.length; i++) { - try { - var org = g.data.hash.aou[ ou_ids[i] ]; - if ( get_bool( g.data.hash.aout[ org.ou_type() ].can_have_vols() ) ) { - var row = document.createElement('row'); rows.appendChild(row); row.setAttribute('ou_id',ou_ids[i]); - g.render_library_label(row,ou_ids[i]); - g.render_volume_count_entry(row,ou_ids[i]); - } - } catch(E) { - g.error.sdump('D_ERROR',E); - } - } - - g.load_prefs(); - - } catch(E) { - var err_msg = $("commonStrings").getFormattedString('common.exception', ['cat/volume_copy_creator.js', E]); - try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); dump(js2JSON(E)); } - alert(err_msg); - } -} - -g.render_library_label = function(row,ou_id) { - var label = document.createElement('label'); row.appendChild(label); - label.setAttribute('ou_id',ou_id); - label.setAttribute('value',g.data.hash.aou[ ou_id ].shortname()); -} - -g.render_volume_count_entry = function(row,ou_id) { - var hb = document.createElement('vbox'); row.appendChild(hb); - var tb = document.createElement('textbox'); hb.appendChild(tb); - tb.setAttribute('ou_id',ou_id); tb.setAttribute('size','3'); tb.setAttribute('cols','3'); - tb.setAttribute('rel_vert_pos','1'); - if ( (!g.copy_shortcut) && (!g.last_focus) ) { tb.focus(); g.last_focus = tb; } - var node; - function render_copy_count_entry(ev) { - if (ev.target.disabled) return; - if (! isNaN( Number( ev.target.value) ) ) { - if ( Number( ev.target.value ) > g_max_copies_that_can_be_added_at_a_time_per_volume ) { - g.error.yns_alert($("catStrings").getFormattedString('staff.cat.volume_copy_creator.render_volume_count_entry.message', [g_max_copies_that_can_be_added_at_a_time_per_volume]), - $("catStrings").getString('staff.cat.volume_copy_creator.render_volume_count_entry.title'), - $("catStrings").getString('staff.cat.volume_copy_creator.render_volume_count_entry.ok_label'),null,null,''); - return; - } - if (node) { row.removeChild(node); node = null; } - //ev.target.disabled = true; - node = g.render_callnumber_copy_count_entry(row,ou_id,ev.target.value); - } - } - util.widgets.apply_vertical_tab_on_enter_handler( - tb, - function() { render_copy_count_entry({'target':tb}); setTimeout(function(){util.widgets.vertical_tab(tb);},0); } - ); - tb.addEventListener( 'change', render_copy_count_entry, false); - tb.addEventListener( 'focus', function(ev) { g.last_focus = ev.target; }, false ); - setTimeout( - function() { - try { - if (g.copy_shortcut) { - JSAN.use('util.functional'); - tb.value = util.functional.map_object_to_list( - g.copy_shortcut[ou_id], - function(o,i) { - return g.copy_shortcut[ou_id][i]; - } - ).length - render_copy_count_entry({'target':tb}); - tb.disabled = true; - } - } catch(E) { - alert(E); - } - }, 0 - ); -} - -g.render_callnumber_copy_count_entry = function(row,ou_id,count) { - var grid = util.widgets.make_grid( [ {}, {} ] ); row.appendChild(grid); - grid.setAttribute('flex','1'); - grid.setAttribute('ou_id',ou_id); - var rows = grid.lastChild; - var r = document.createElement('row'); rows.appendChild( r ); - var x = document.createElement('label'); r.appendChild(x); - x.setAttribute('value', $("catStrings").getString('staff.cat.volume_copy_creator.render_callnumber_copy_count_entry.call_nums')); x.setAttribute('style','font-weight: bold'); - x = document.createElement('label'); r.appendChild(x); - x.setAttribute('value',$("catStrings").getString('staff.cat.volume_copy_creator.render_callnumber_copy_count_entry.num_of_copies')); x.setAttribute('style','font-weight: bold'); - x.setAttribute('size','3'); x.setAttribute('cols','3'); - - - function handle_change(tb1,tb2,hb3) { - if (tb1.value == '') return; - if (isNaN( Number( tb2.value ) )) return; - if ( Number( tb2.value ) > g_max_copies_that_can_be_added_at_a_time_per_volume ) { - g.error.yns_alert($("catStrings").getFormattedString('staff.cat.volume_copy_creator.render_volume_count_entry.message', [g_max_copies_that_can_be_added_at_a_time_per_volume]), - $("catStrings").getString('staff.cat.volume_copy_creator.render_volume_count_entry.title'), - $("catStrings").getString('staff.cat.volume_copy_creator.render_volume_count_entry.ok_label'),null,null,''); - return; - } - - //if (tb1.disabled || tb2.disabled) return; - - //tb1.disabled = true; - //tb2.disabled = true; - - util.widgets.remove_children(hb3); - - g.render_barcode_entry(hb3,tb1.value,Number(tb2.value),ou_id); - document.getElementById("Create").disabled = false; - } - - function handle_change_tb1(ev) { - var _tb1 = ev.target; - var _hb1 = _tb1.parentNode; - var _hb2 = _hb1.nextSibling; - var _tb2 = _hb2.firstChild; - var _hb3 = _hb2.nextSibling; - handle_change(_tb1,_tb2,_hb3); - } - - function handle_change_tb2(ev) { - var _tb2 = ev.target; - var _hb2 = _tb2.parentNode; - var _hb1 = _hb2.previousSibling; - var _tb1 = _hb1.firstChild; - var _hb3 = _hb2.nextSibling; - handle_change(_tb1,_tb2,_hb3); - } - - for (var i = 0; i < count; i++) { - var r = document.createElement('row'); rows.appendChild(r); - var hb1 = document.createElement('vbox'); r.appendChild(hb1); - var hb2 = document.createElement('vbox'); r.appendChild(hb2); - var hb3 = document.createElement('vbox'); r.appendChild(hb3); - var tb1 = document.createElement('textbox'); hb1.appendChild(tb1); - tb1.setAttribute('rel_vert_pos','2'); - tb1.setAttribute('ou_id',ou_id); - util.widgets.apply_vertical_tab_on_enter_handler( - tb1, - function() { handle_change_tb1({'target':tb1}); setTimeout(function(){util.widgets.vertical_tab(tb1);},0); } - ); - var tb2 = document.createElement('textbox'); hb2.appendChild(tb2); - tb2.setAttribute('size','3'); tb2.setAttribute('cols','3'); - tb2.setAttribute('rel_vert_pos','3'); - tb2.setAttribute('ou_id',ou_id); - util.widgets.apply_vertical_tab_on_enter_handler( - tb2, - function() { handle_change_tb2({'target':tb2}); setTimeout(function(){util.widgets.vertical_tab(tb2);},0); } - ); - - tb1.addEventListener( 'change', handle_change_tb1, false); - tb1.addEventListener( 'focus', function(ev) { g.last_focus = ev.target; }, false ); - tb2.addEventListener( 'change', handle_change_tb2, false); - tb2.addEventListener( 'focus', function(ev) { g.last_focus = ev.target; }, false ); - if ( !g.last_focus ) { tb2.focus(); g.last_focus = tb2; } - - setTimeout( - function(idx,tb){ - return function() { - try { - JSAN.use('util.functional'); - if (g.copy_shortcut) { - var label = util.functional.map_object_to_list( - g.copy_shortcut[ou_id], - function(o,i) { - return i; - } - )[idx]; - tb.value = label; handle_change_tb1({'target':tb}); - tb.disabled = true; - } - } catch(E) { - alert(E); - } - } - }(i,tb1),0 - ); - } - - return grid; -} - -g.render_barcode_entry = function(node,callnumber,count,ou_id) { - try { - function ready_to_create(ev) { - document.getElementById("Create").disabled = false; - } - - JSAN.use('util.barcode'); - - for (var i = 0; i < count; i++) { - var tb = document.createElement('textbox'); node.appendChild(tb); - tb.setAttribute('ou_id',ou_id); - tb.setAttribute('callnumber',callnumber); - tb.setAttribute('rel_vert_pos','4'); - util.widgets.apply_vertical_tab_on_enter_handler( - tb, - function() { ready_to_create({'target':tb}); setTimeout(function(){util.widgets.vertical_tab(tb);},0); } - ); - //tb.addEventListener('change',ready_to_create,false); - tb.addEventListener('change', function(ev) { - var barcode = String( ev.target.value ).replace(/\s/g,''); - if (barcode != ev.target.value) ev.target.value = barcode; - if ($('check_barcodes').checked && ! util.barcode.check(barcode) ) { - g.error.yns_alert($("catStrings").getFormattedString('staff.cat.volume_copy_creator.render_barcode_entry.alert_message', [barcode]), - $("catStrings").getString('staff.cat.volume_copy_creator.render_barcode_entry.alert_title'), - $("catStrings").getString('staff.cat.volume_copy_creator.render_barcode_entry.alert_ok_button'),null,null, - $("catStrings").getString('staff.cat.volume_copy_creator.render_barcode_entry.alert_confirm')); - setTimeout( function() { ev.target.select(); ev.target.focus(); }, 0); - } - }, false); - tb.addEventListener( 'focus', function(ev) { g.last_focus = ev.target; }, false ); - } - } catch(E) { - g.error.sdump('D_ERROR','g.render_barcode_entry: ' + E); - } -} - -g.new_node_id = -1; - -g.stash_and_close = function() { - - try { - - var nl = document.getElementsByTagName('textbox'); - - var volumes_hash = {}; - - var barcodes = []; - - for (var i = 0; i < nl.length; i++) { - if ( nl[i].getAttribute('rel_vert_pos') == 4 ) barcodes.push( nl[i] ); - if ( nl[i].getAttribute('rel_vert_pos') == 2 ) { - var ou_id = nl[i].getAttribute('ou_id'); - var callnumber = nl[i].value; - if (typeof volumes_hash[ou_id] == 'undefined') { volumes_hash[ou_id] = {} } - if (typeof volumes_hash[ou_id][callnumber] == 'undefined') { volumes_hash[ou_id][callnumber] = [] } - } - }; - - for (var i = 0; i < barcodes.length; i++) { - var ou_id = barcodes[i].getAttribute('ou_id'); - var callnumber = barcodes[i].getAttribute('callnumber'); - var barcode = barcodes[i].value; - - if (typeof volumes_hash[ou_id] == 'undefined') { volumes_hash[ou_id] = {} } - if (typeof volumes_hash[ou_id][callnumber] == 'undefined') { volumes_hash[ou_id][callnumber] = [] } - - if (barcode != '') volumes_hash[ou_id][callnumber].push( barcode ); - } - - var volumes = []; - var copies = []; - var volume_labels = {}; - - for (var ou_id in volumes_hash) { - for (var cn in volumes_hash[ou_id]) { - - var acn_id = g.network.simple_request( - 'FM_ACN_FIND_OR_CREATE', - [ ses(), cn, g.doc_id, ou_id ] - ); - - if (typeof acn_id.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; - } - - volume_labels[ acn_id ] = { 'label' : cn, 'owning_lib' : ou_id }; - - for (var i = 0; i < volumes_hash[ou_id][cn].length; i++) { - var copy = new acp(); - copy.id( g.new_node_id-- ); - copy.isnew('1'); - copy.barcode( volumes_hash[ou_id][cn][i] ); - copy.call_number( acn_id ); - copy.circ_lib(ou_id); - /* FIXME -- use constants */ - copy.deposit(0); - copy.price(0); - copy.deposit_amount(0); - copy.fine_level(2); - copy.loan_duration(2); - copy.location(1); - copy.status(0); - copy.circulate(get_db_true()); - copy.holdable(get_db_true()); - copy.opac_visible(get_db_true()); - copy.ref(get_db_false()); - copies.push( copy ); - } - } - } - - JSAN.use('util.window'); var win = new util.window(); - if (copies.length > 0) { - JSAN.use('cat.util'); - copies = cat.util.spawn_copy_editor( { 'edit' : 1, 'docid' : g.doc_id, 'copies' : copies }); - try { - //case 1706 /* ITEM_BARCODE_EXISTS */ : - if (copies && copies.length > 0 && $('print_labels').checked) { - JSAN.use('util.functional'); - JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.stash_retrieve(); - data.temp_barcodes_for_labels = util.functional.map_list( copies, function(o){return o.barcode();}) ; - data.stash('temp_barcodes_for_labels'); - var w = win.open( - urls.XUL_SPINE_LABEL, - 'spine_labels', - 'chrome,resizable,width=750,height=550' - ); - } - } catch(E) { - g.error.standard_unexpected_error_alert($(catStrings).getString('staff.cat.volume_copy_creator.stash_and_close.tree_err2'),E); - } - } - - if (typeof window.refresh == 'function') window.refresh(); - - window.close(); - - } catch(E) { - g.error.standard_unexpected_error_alert($(catStrings).getString('staff.cat.volume_copy_creator.stash_and_close.tree_err3'),E); - } -} - -g.load_prefs = function() { - try { - netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); - JSAN.use('util.file'); var file = new util.file('volume_copy_creator.prefs'); - if (file._file.exists()) { - var prefs = file.get_object(); file.close(); - if (prefs.check_barcodes) { - if ( prefs.check_barcodes == 'false' ) { - $('check_barcodes').checked = false; - } else { - $('check_barcodes').checked = prefs.check_barcodes; - } - } else { - $('check_barcodes').checked = false; - } - if (prefs.print_labels) { - if ( prefs.print_labels == 'false' ) { - $('print_labels').checked = false; - } else { - $('print_labels').checked = prefs.print_labels; - } - } else { - $('print_labels').checked = false; - } - - } - } catch(E) { - g.error.standard_unexpected_error_alert($(catStrings).getString('staff.cat.volume_copy_creator.load_prefs.err_retrieving_prefs'),E); - - } -} - -g.save_prefs = function () { - try { - netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); - JSAN.use('util.file'); var file = new util.file('volume_copy_creator.prefs'); - file.set_object( - { - 'check_barcodes' : $('check_barcodes').checked, - 'print_labels' : $('print_labels').checked, - } - ); - file.close(); - } catch(E) { - g.error.standard_unexpected_error_alert($(catStrings).getString('staff.cat.volume_copy_creator.save_prefs.err_storing_prefs'),E); - } -} - - diff --git a/xul/server/skin/print.css b/xul/server/skin/print.css deleted file mode 100644 index af98ca5eac..0000000000 --- a/xul/server/skin/print.css +++ /dev/null @@ -1,12 +0,0 @@ -.first_pre { - page-break-after: always; - margin-top: -0.20cm; - font-family: Arial, Helvetica, sans-serif; - font-weight: bold; -} - -.not_first_pre { - page-break-after: always; - font-family: Arial, Helvetica, sans-serif; - font-weight: bold; -}