From 9b7099763411e52a3697aa8cefb5f842fc99418e Mon Sep 17 00:00:00 2001 From: phasefx Date: Mon, 17 Dec 2007 22:55:58 +0000 Subject: [PATCH] refactoring.. moved some list print/clipboard functions into list.js git-svn-id: svn://svn.open-ils.org/ILS/trunk@8232 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../chrome/content/circ/offline_checkin.js | 22 +++----- .../chrome/content/circ/offline_checkout.js | 25 ++++----- .../chrome/content/circ/offline_in_house_use.js | 19 +++---- .../chrome/content/circ/offline_renew.js | 21 +++----- .../xul/staff_client/chrome/content/util/list.js | 41 ++++++++++++++ .../server/admin/offline_manage_xacts.js | 12 +---- .../xul/staff_client/server/admin/transit_list.js | 34 ++---------- .../xul/staff_client/server/cat/copy_buckets.js | 22 +------- .../xul/staff_client/server/cat/record_buckets.js | 22 +------- Open-ILS/xul/staff_client/server/cat/z3950.js | 11 +--- Open-ILS/xul/staff_client/server/circ/checkin.js | 38 ++----------- Open-ILS/xul/staff_client/server/circ/checkout.js | 63 +++++++--------------- .../xul/staff_client/server/circ/copy_status.js | 40 ++------------ .../xul/staff_client/server/circ/hold_capture.js | 27 ++-------- .../xul/staff_client/server/circ/in_house_use.js | 38 ++----------- .../staff_client/server/patron/bill_history.xul | 30 +++-------- Open-ILS/xul/staff_client/server/patron/holds.js | 41 +++----------- Open-ILS/xul/staff_client/server/patron/items.js | 41 +++----------- .../staff_client/server/patron/search_result.js | 34 +++--------- 19 files changed, 149 insertions(+), 432 deletions(-) diff --git a/Open-ILS/xul/staff_client/chrome/content/circ/offline_checkin.js b/Open-ILS/xul/staff_client/chrome/content/circ/offline_checkin.js index f7b784778b..26fa0fe938 100644 --- a/Open-ILS/xul/staff_client/chrome/content/circ/offline_checkin.js +++ b/Open-ILS/xul/staff_client/chrome/content/circ/offline_checkin.js @@ -113,26 +113,20 @@ function next_patron() { if ($('print_receipt').checked) { try { - var params = { - 'header' : g.data.print_list_templates.offline_checkin.header, - 'line_item' : g.data.print_list_templates.offline_checkin.line_item, - 'footer' : g.data.print_list_templates.offline_checkin.footer, - 'type' : g.data.print_list_templates.offline_checkin.type, - 'list' : g.list.dump(), - }; - JSAN.use('util.print'); var print = new util.print(); - print.tree_list( params ); + var params = { + 'template' : 'offline_checkin', + 'callback' : function() { + g.list.clear(); + var x = $('i_barcode'); x.value = ''; x.focus(); + } + }; + g.list.print( params ); } catch(E) { g.error.sdump('D_ERROR','print: ' + E); alert('print: ' + E); } } - g.list.clear(); - - var x; - x = $('i_barcode'); x.value = ''; x.focus(); - } catch(E) { dump(E+'\n'); alert(E); } diff --git a/Open-ILS/xul/staff_client/chrome/content/circ/offline_checkout.js b/Open-ILS/xul/staff_client/chrome/content/circ/offline_checkout.js index a9deca83ea..4a90ab94c6 100644 --- a/Open-ILS/xul/staff_client/chrome/content/circ/offline_checkout.js +++ b/Open-ILS/xul/staff_client/chrome/content/circ/offline_checkout.js @@ -272,28 +272,21 @@ function next_patron(cancel) { try { var params = { 'patron_barcode' : $('p_barcode').value, - 'header' : g.data.print_list_templates.offline_checkout.header, - 'line_item' : g.data.print_list_templates.offline_checkout.line_item, - 'footer' : g.data.print_list_templates.offline_checkout.footer, - 'type' : g.data.print_list_templates.offline_checkout.type, - 'list' : g.list.dump(), + 'template' : 'offline_checkout', + 'callback' : function() { + g.list.clear(); + var x = $('i_barcode'); x.value = ''; + x = $('p_barcode'); x.value = ''; + x.setAttribute('disabled','false'); x.disabled = false; + x.focus(); + } }; - JSAN.use('util.print'); var print = new util.print(); - print.tree_list( params ); + g.list.print( params ); } catch(E) { g.error.sdump('D_ERROR','print: ' + E); alert('print: ' + E); } } - - g.list.clear(); - - var x; - x = $('i_barcode'); x.value = ''; - x = $('p_barcode'); x.value = ''; - x.setAttribute('disabled','false'); x.disabled = false; - x.focus(); - } catch(E) { dump(E+'\n'); alert(E); } diff --git a/Open-ILS/xul/staff_client/chrome/content/circ/offline_in_house_use.js b/Open-ILS/xul/staff_client/chrome/content/circ/offline_in_house_use.js index a82e82235f..9f825ccb3f 100644 --- a/Open-ILS/xul/staff_client/chrome/content/circ/offline_in_house_use.js +++ b/Open-ILS/xul/staff_client/chrome/content/circ/offline_in_house_use.js @@ -117,25 +117,18 @@ function next_patron() { if ($('print_receipt').checked) { try { var params = { - 'header' : g.data.print_list_templates.offline_inhouse_use.header, - 'line_item' : g.data.print_list_templates.offline_inhouse_use.line_item, - 'footer' : g.data.print_list_templates.offline_inhouse_use.footer, - 'type' : g.data.print_list_templates.offline_inhouse_use.type, - 'list' : g.list.dump(), + 'template' : 'offline_inhouse_use', + 'callback' : function() { + g.list.clear(); + var x = $('i_barcode'); x.value = ''; x.focus(); + } }; - JSAN.use('util.print'); var print = new util.print(); - print.tree_list( params ); + g.list.print( params ); } catch(E) { g.error.sdump('D_ERROR','print: ' + E); alert('print: ' + E); } } - - g.list.clear(); - - var x; - x = $('i_barcode'); x.value = ''; x.focus(); - } catch(E) { dump(E+'\n'); alert(E); } diff --git a/Open-ILS/xul/staff_client/chrome/content/circ/offline_renew.js b/Open-ILS/xul/staff_client/chrome/content/circ/offline_renew.js index 1437a7ebbe..1892e1e20a 100644 --- a/Open-ILS/xul/staff_client/chrome/content/circ/offline_renew.js +++ b/Open-ILS/xul/staff_client/chrome/content/circ/offline_renew.js @@ -223,27 +223,20 @@ function next_patron(cancel) { try { var params = { 'patron_barcode' : $('p_barcode').value, - 'header' : g.data.print_list_templates.offline_renew.header, - 'line_item' : g.data.print_list_templates.offline_renew.line_item, - 'footer' : g.data.print_list_templates.offline_renew.footer, - 'type' : g.data.print_list_templates.offline_renew.type, - 'list' : g.list.dump(), + 'template' : 'offline_renew', + 'callback' : function() { + g.list.clear(); + var x = $('i_barcode'); x.value = ''; + x = $('p_barcode'); x.value = ''; x.focus(); + } }; - JSAN.use('util.print'); var print = new util.print(); - print.tree_list( params ); + g.list.print( params ); } catch(E) { g.error.sdump('D_ERROR','print: ' + E); alert('print: ' + E); } } } - - g.list.clear(); - - var x; - x = $('i_barcode'); x.value = ''; - x = $('p_barcode'); x.value = ''; x.focus(); - } catch(E) { dump(E+'\n'); alert(E); } diff --git a/Open-ILS/xul/staff_client/chrome/content/util/list.js b/Open-ILS/xul/staff_client/chrome/content/util/list.js index da2fb2f7e5..50327c2b7a 100644 --- a/Open-ILS/xul/staff_client/chrome/content/util/list.js +++ b/Open-ILS/xul/staff_client/chrome/content/util/list.js @@ -1080,6 +1080,47 @@ util.list.prototype = { } }, + 'print' : function(params) { + if (!params) params = {}; + switch(this.node.nodeName) { + case 'tree' : return this._print_tree(params); break; + default: throw('NYI: Need ._print() for ' + this.node.nodeName); break; + } + }, + + '_print_tree' : function(params) { + var obj = this; + try { + JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.stash_retrieve(); + if (!params.staff && data.list.au && data.list.au[0]) { + params.staff = data.list.au[0]; + } + if (!params.lib && data.list.au && data.list.au[0] && data.list.au[0].ws_ou() && data.hash.aou && data.hash.aou[ data.list.au[0].ws_ou() ]) { + params.lib = data.hash.aou[ data.list.au[0].ws_ou() ]; + params.lib.children(null); + } + if (params.template && data.print_list_templates[ params.template ]) { + var template = data.print_list_templates[ params.template ]; + for (var i in template) params[i] = template[i]; + } + obj.wrap_in_full_retrieve( + function() { + try { + if (!params.list) params.list = obj.dump_with_keys(); + JSAN.use('util.print'); var print = new util.print(); + print.tree_list( params ); + if (typeof params.callback == 'function') params.callback(); + } catch(E) { + obj.error.standard_unexpected_error_alert('inner _print_tree',E); + } + } + ); + + } catch(E) { + obj.error.standard_unexpected_error_alert('_print_tree',E); + } + }, + 'dump_selected_with_keys' : function(params) { var obj = this; switch(this.node.nodeName) { diff --git a/Open-ILS/xul/staff_client/server/admin/offline_manage_xacts.js b/Open-ILS/xul/staff_client/server/admin/offline_manage_xacts.js index 73f856ae99..cfb7a4c801 100644 --- a/Open-ILS/xul/staff_client/server/admin/offline_manage_xacts.js +++ b/Open-ILS/xul/staff_client/server/admin/offline_manage_xacts.js @@ -320,17 +320,7 @@ admin.offline_manage_xacts.prototype = { 'command', function(ev) { try { - obj.error_list.on_all_fleshed = - function() { - try { - dump( obj.error_list.dump_csv() + '\n' ); - copy_to_clipboard(obj.error_list.dump_csv()); - setTimeout(function(){ obj.error_list.on_all_fleshed = null; },0); - } catch(E) { - obj.error.standard_unexpected_error_alert('export',E); - } - } - obj.error_list.full_retrieve(); + obj.error_list.dump_csv_to_clipboard(); } catch(E) { obj.error.standard_unexpected_error_alert('export',E); } diff --git a/Open-ILS/xul/staff_client/server/admin/transit_list.js b/Open-ILS/xul/staff_client/server/admin/transit_list.js index fc66e3ad00..46ab60a4eb 100644 --- a/Open-ILS/xul/staff_client/server/admin/transit_list.js +++ b/Open-ILS/xul/staff_client/server/admin/transit_list.js @@ -421,37 +421,11 @@ admin.transit_list.prototype = { 'print_list' : function(which_list) { var obj = this; try { - var list = which_list == 0 ? obj.list : obj.list2; - - if (list.on_all_fleshed != null) { - var r = window.confirm('This list is busy retrieving/rendering rows for a pending action. Would you like to abort the pending action and proceed?'); - if (!r) return; - } - list.on_all_fleshed = - function() { - try { - dump( js2JSON( list.dump_with_keys() ) + '\n' ); - obj.data.stash_retrieve(); - var lib = obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ]; - lib.children(null); - var p = { - 'lib' : lib, - 'staff' : obj.data.list.au[0], - 'header' : obj.data.print_list_templates.transit_list.header, - 'line_item' : obj.data.print_list_templates.transit_list.line_item, - 'footer' : obj.data.print_list_templates.transit_list.footer, - 'type' : obj.data.print_list_templates.transit_list.type, - 'list' : list.dump_with_keys(), - }; - JSAN.use('util.print'); var print = new util.print(); - print.tree_list( p ); - setTimeout(function(){ list.on_all_fleshed = null; },0); - } catch(E) { - obj.error.standard_unexpected_error_alert('print',E); - } - } - list.full_retrieve(); + var p = { + 'template' : 'transit_list' + }; + list.print(p); } catch(E) { obj.error.standard_unexpected_error_alert('print',E); } diff --git a/Open-ILS/xul/staff_client/server/cat/copy_buckets.js b/Open-ILS/xul/staff_client/server/cat/copy_buckets.js index a3e3f03383..d3d7ed9487 100644 --- a/Open-ILS/xul/staff_client/server/cat/copy_buckets.js +++ b/Open-ILS/xul/staff_client/server/cat/copy_buckets.js @@ -575,31 +575,13 @@ cat.copy_buckets.prototype = { 'cmd_copy_buckets_export' : [ ['command'], function() { - obj.list2.on_all_fleshed = function() { - try { - dump(obj.list2.dump_csv() + '\n'); - copy_to_clipboard(obj.list2.dump_csv()); - setTimeout(function(){obj.list2.on_all_fleshed = null;},0); - } catch(E) { - alert(E); - } - } - obj.list2.full_retrieve(); + obj.list2.dump_csv_to_clipboard(); } ], 'cmd_export1' : [ ['command'], function() { - obj.list1.on_all_fleshed = function() { - try { - dump(obj.list1.dump_csv() + '\n'); - copy_to_clipboard(obj.list1.dump_csv()); - setTimeout(function(){obj.list1.on_all_fleshed = null;},0); - } catch(E) { - alert(E); - } - } - obj.list1.full_retrieve(); + obj.list1.dump_csv_to_clipboard(); } ], diff --git a/Open-ILS/xul/staff_client/server/cat/record_buckets.js b/Open-ILS/xul/staff_client/server/cat/record_buckets.js index 651af6aeaa..c8698c47d5 100644 --- a/Open-ILS/xul/staff_client/server/cat/record_buckets.js +++ b/Open-ILS/xul/staff_client/server/cat/record_buckets.js @@ -448,32 +448,14 @@ cat.record_buckets.prototype = { 'cmd_record_buckets_export' : [ ['command'], function() { - obj.list2.on_all_fleshed = function() { - try { - dump(obj.list2.dump_csv() + '\n'); - copy_to_clipboard(obj.list2.dump_csv()); - setTimeout(function(){obj.list2.on_all_fleshed = null;},0); - } catch(E) { - alert(E); - } - } - obj.list2.full_retrieve(); + obj.list2.dump_csv_to_clipboard(); } ], 'cmd_export1' : [ ['command'], function() { - obj.list1.on_all_fleshed = function() { - try { - dump(obj.list1.dump_csv() + '\n'); - copy_to_clipboard(obj.list1.dump_csv()); - setTimeout(function(){obj.list1.on_all_fleshed = null;},0); - } catch(E) { - alert(E); - } - } - obj.list1.full_retrieve(); + obj.list1.dump_csv_to_clipboard(); } ], diff --git a/Open-ILS/xul/staff_client/server/cat/z3950.js b/Open-ILS/xul/staff_client/server/cat/z3950.js index 2e02511e76..4cf522f5eb 100644 --- a/Open-ILS/xul/staff_client/server/cat/z3950.js +++ b/Open-ILS/xul/staff_client/server/cat/z3950.js @@ -82,16 +82,7 @@ cat.z3950.prototype = { 'cmd_export' : [ ['command'], function() { - obj.list.on_all_fleshed = function() { - try { - dump(obj.list.dump_csv() + '\n'); - copy_to_clipboard(obj.list.dump_csv()); - setTimeout(function(){obj.list.on_all_fleshed = null;},0); - } catch(E) { - obj.error.standard_unexpected_error_alert('Failure during export.',E); - } - } - obj.list.full_retrieve(); + obj.list.dump_csv_to_clipboard(); } ], 'cmd_broken' : [ diff --git a/Open-ILS/xul/staff_client/server/circ/checkin.js b/Open-ILS/xul/staff_client/server/circ/checkin.js index 05a68087b9..50688213d6 100644 --- a/Open-ILS/xul/staff_client/server/circ/checkin.js +++ b/Open-ILS/xul/staff_client/server/circ/checkin.js @@ -236,44 +236,16 @@ circ.checkin.prototype = { 'cmd_checkin_print' : [ ['command'], function() { - obj.list.on_all_fleshed = function() { - try { - dump( js2JSON( obj.list.dump_with_keys() ) + '\n' ); - obj.OpenILS.data.stash_retrieve(); - var lib = obj.OpenILS.data.hash.aou[ obj.OpenILS.data.list.au[0].ws_ou() ]; - lib.children(null); - var p = { - 'lib' : lib, - 'staff' : obj.OpenILS.data.list.au[0], - 'header' : obj.OpenILS.data.print_list_templates.checkin.header, - 'line_item' : obj.OpenILS.data.print_list_templates.checkin.line_item, - 'footer' : obj.OpenILS.data.print_list_templates.checkin.footer, - 'type' : obj.OpenILS.data.print_list_templates.checkin.type, - 'list' : obj.list.dump_with_keys(), - }; - JSAN.use('util.print'); var print = new util.print(); - print.tree_list( p ); - setTimeout(function(){obj.list.on_all_fleshed = null;},0); - } catch(E) { - alert(E); - } - } - obj.list.full_retrieve(); + var p = { + 'template' : 'checkin' + }; + obj.list.print(p); } ], 'cmd_checkin_export' : [ ['command'], function() { - obj.list.on_all_fleshed = function() { - try { - dump(obj.list.dump_csv() + '\n'); - copy_to_clipboard(obj.list.dump_csv()); - setTimeout(function(){obj.list.on_all_fleshed = null;},0); - } catch(E) { - alert(E); - } - } - obj.list.full_retrieve(); + obj.list.dump_csv_to_clipboard(); } ], diff --git a/Open-ILS/xul/staff_client/server/circ/checkout.js b/Open-ILS/xul/staff_client/server/circ/checkout.js index d657ffba1e..6753f3c608 100644 --- a/Open-ILS/xul/staff_client/server/circ/checkout.js +++ b/Open-ILS/xul/staff_client/server/circ/checkout.js @@ -266,39 +266,25 @@ circ.checkout.prototype = { var obj = this; try { obj.patron = obj.network.simple_request('FM_AU_FLESHED_RETRIEVE_VIA_ID',[ses(),obj.patron_id]); - dump( js2JSON( obj.list.dump_with_keys() ) + '\n' ); - obj.list.on_all_fleshed = function() { - try { - var params = { - 'patron' : obj.patron, - 'lib' : obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ], - 'staff' : obj.data.list.au[0], - 'header' : obj.data.print_list_templates.checkout.header, - 'line_item' : obj.data.print_list_templates.checkout.line_item, - 'footer' : obj.data.print_list_templates.checkout.footer, - 'type' : obj.data.print_list_templates.checkout.type, - 'list' : obj.list.dump_with_keys(), - }; - if (silent) params.no_prompt = true; - JSAN.use('util.print'); var print = new util.print(); - print.tree_list( params ); - setTimeout( - function(){ - obj.list.on_all_fleshed = null; - if (typeof f == 'function') { - setTimeout( - function() { - f(); - }, 1000 - ) - } } - , 1000 - ); - } catch(E) { - obj.error.standard_unexpected_error_alert('print',E); - } - } - obj.list.full_retrieve(); + var params = { + 'patron' : obj.patron, + 'header' : 'checkout', + 'callback' : function() { + setTimeout( + function(){ + if (typeof f == 'function') { + setTimeout( + function() { + f(); + }, 1000 + ) + } + }, 1000 + ); + } + }; + if (silent) params.no_prompt = true; + obj.list.print(params); } catch(E) { obj.error.standard_unexpected_error_alert('print',E); } @@ -307,16 +293,7 @@ circ.checkout.prototype = { 'export_list' : function(silent,f) { var obj = this; try { - obj.list.on_all_fleshed = function() { - try { - dump( obj.list.dump_csv() + '\n' ); - copy_to_clipboard(obj.list.dump_csv()); - setTimeout(function(){obj.list.on_all_fleshed = null;if (typeof f == 'function') f();},0); - } catch(E) { - obj.error.standard_unexpected_error_alert('print',E); - } - } - obj.list.full_retrieve(); + obj.list.dump_csv_to_clipboard(); } catch(E) { obj.error.standard_unexpected_error_alert('export',E); } diff --git a/Open-ILS/xul/staff_client/server/circ/copy_status.js b/Open-ILS/xul/staff_client/server/circ/copy_status.js index f173c4583a..ab8f8f0f17 100644 --- a/Open-ILS/xul/staff_client/server/circ/copy_status.js +++ b/Open-ILS/xul/staff_client/server/circ/copy_status.js @@ -318,30 +318,10 @@ circ.copy_status.prototype = { ['command'], function() { try { - obj.list.on_all_fleshed = - function() { - try { - dump( js2JSON( obj.list.dump_with_keys() ) + '\n' ); - obj.data.stash_retrieve(); - var lib = obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ]; - lib.children(null); - var p = { - 'lib' : lib, - 'staff' : obj.data.list.au[0], - 'header' : obj.data.print_list_templates.item_status.header, - 'line_item' : obj.data.print_list_templates.item_status.line_item, - 'footer' : obj.data.print_list_templates.item_status.footer, - 'type' : obj.data.print_list_templates.item_status.type, - 'list' : obj.list.dump_with_keys(), - }; - JSAN.use('util.print'); var print = new util.print(); - print.tree_list( p ); - setTimeout(function(){ obj.list.on_all_fleshed = null; },0); - } catch(E) { - obj.error.standard_unexpected_error_alert('print',E); - } - } - obj.list.full_retrieve(); + var p = { + 'template' : 'item_status' + }; + obj.list.print(p); } catch(E) { obj.error.standard_unexpected_error_alert('print',E); } @@ -351,17 +331,7 @@ circ.copy_status.prototype = { ['command'], function() { try { - obj.list.on_all_fleshed = - function() { - try { - dump( obj.list.dump_csv() + '\n' ); - copy_to_clipboard(obj.list.dump_csv()); - setTimeout(function(){ obj.list.on_all_fleshed = null; },0); - } catch(E) { - obj.error.standard_unexpected_error_alert('export',E); - } - } - obj.list.full_retrieve(); + obj.list.dump_csv_to_clipboard(); } catch(E) { obj.error.standard_unexpected_error_alert('export',E); } diff --git a/Open-ILS/xul/staff_client/server/circ/hold_capture.js b/Open-ILS/xul/staff_client/server/circ/hold_capture.js index 22b1eaf1ed..cc544a0505 100644 --- a/Open-ILS/xul/staff_client/server/circ/hold_capture.js +++ b/Open-ILS/xul/staff_client/server/circ/hold_capture.js @@ -60,29 +60,10 @@ circ.hold_capture.prototype = { 'cmd_hold_capture_print' : [ ['command'], function() { - obj.list.on_all_fleshed = function() { - try { - dump( js2JSON( obj.list.dump_with_keys() ) + '\n' ); - obj.OpenILS.data.stash_retrieve(); - var lib = obj.OpenILS.data.hash.aou[ obj.OpenILS.data.list.au[0].ws_ou() ]; - lib.children(null); - var p = { - 'lib' : lib, - 'staff' : obj.OpenILS.data.list.au[0], - 'header' : obj.OpenILS.data.print_list_templates.hold_capture.header, - 'line_item' : obj.OpenILS.data.print_list_templates.hold_capture.line_item, - 'footer' : obj.OpenILS.data.print_list_templates.hold_capture.footer, - 'type' : obj.OpenILS.data.print_list_templates.hold_capture.type, - 'list' : obj.list.dump_with_keys(), - }; - JSAN.use('util.print'); var print = new util.print(); - print.tree_list( p ); - setTimeout(function(){obj.list.on_all_fleshed = null;},0); - } catch(E) { - alert(E); - } - } - obj.list.full_retrieve(); + var p = { + 'template' : 'hold_capture' + }; + obj.list.print(p); } ], 'cmd_hold_capture_reprint' : [ diff --git a/Open-ILS/xul/staff_client/server/circ/in_house_use.js b/Open-ILS/xul/staff_client/server/circ/in_house_use.js index 763888bc88..9c2d24e72d 100644 --- a/Open-ILS/xul/staff_client/server/circ/in_house_use.js +++ b/Open-ILS/xul/staff_client/server/circ/in_house_use.js @@ -155,44 +155,16 @@ circ.in_house_use.prototype = { 'cmd_in_house_use_print' : [ ['command'], function() { - obj.list.on_all_fleshed = function() { - try { - dump( js2JSON( obj.list.dump_with_keys() ) + '\n' ); - obj.data.stash_retrieve(); - var lib = obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ]; - lib.children(null); - var p = { - 'lib' : lib, - 'staff' : obj.data.list.au[0], - 'header' : obj.data.print_list_templates.in_house_use.header, - 'line_item' : obj.data.print_list_templates.in_house_use.line_item, - 'footer' : obj.data.print_list_templates.in_house_use.footer, - 'type' : obj.data.print_list_templates.in_house_use.type, - 'list' : obj.list.dump_with_keys(), - }; - JSAN.use('util.print'); var print = new util.print(); - print.tree_list( p ); - setTimeout(function(){obj.list.on_all_fleshed = null;},0); - } catch(E) { - alert(E); - } - } - obj.list.full_retrieve(); + var p = { + 'template' : 'in_house_use' + }; + obj.list.print(p); } ], 'cmd_in_house_use_export' : [ ['command'], function() { - obj.list.on_all_fleshed = function() { - try { - dump(obj.list.dump_csv() + '\n'); - copy_to_clipboard(obj.list.dump_csv()); - setTimeout(function(){obj.list.on_all_fleshed = null;},0); - } catch(E) { - alert(E); - } - } - obj.list.full_retrieve(); + obj.list.dump_csv_to_clipboard(); } ], diff --git a/Open-ILS/xul/staff_client/server/patron/bill_history.xul b/Open-ILS/xul/staff_client/server/patron/bill_history.xul index eaf4974920..f4d9763b04 100644 --- a/Open-ILS/xul/staff_client/server/patron/bill_history.xul +++ b/Open-ILS/xul/staff_client/server/patron/bill_history.xul @@ -323,29 +323,13 @@ function print_bills() { try { - g.bill_list.on_all_fleshed = function() { - try { - var template = 'bills_historical'; if (xul_param('current')) template = 'bills_current'; - JSAN.use('patron.util'); - var params = { - 'patron' : patron.util.retrieve_au_via_id(ses(),g.patron_id), - 'lib' : g.data.hash.aou[ g.data.list.au[0].ws_ou() ], - 'staff' : g.data.list.au[0], - 'header' : g.data.print_list_templates[template].header, - 'line_item' : g.data.print_list_templates[template].line_item, - 'footer' : g.data.print_list_templates[template].footer, - 'type' : g.data.print_list_templates[template].type, - 'list' : g.bill_list.dump_with_keys(), - //'modal' : true, - }; - JSAN.use('util.print'); var print = new util.print(); - print.tree_list( params ); - setTimeout(function(){ g.bill_list.on_all_fleshed = null; },0); - } catch(E) { - g.error.standard_unexpected_error_alert('printing bills', E); - } - } - g.bill_list.full_retrieve(); + var template = 'bills_historical'; if (xul_param('current')) template = 'bills_current'; + JSAN.use('patron.util'); + var params = { + 'patron' : patron.util.retrieve_au_via_id(ses(),g.patron_id), + 'template' : template + }; + g.bill_list.print(params); } catch(E) { g.error.standard_unexpected_error_alert('printing bills', E); } diff --git a/Open-ILS/xul/staff_client/server/patron/holds.js b/Open-ILS/xul/staff_client/server/patron/holds.js index b4222a802e..ff6f4b0b23 100644 --- a/Open-ILS/xul/staff_client/server/patron/holds.js +++ b/Open-ILS/xul/staff_client/server/patron/holds.js @@ -195,29 +195,12 @@ patron.holds.prototype = { ['command'], function() { try { - dump(js2JSON(obj.list.dump_with_keys()) + '\n'); - function flesh_callback() { - try { - JSAN.use('patron.util'); - var params = { - 'patron' : patron.util.retrieve_au_via_id(ses(),obj.patron_id), - 'lib' : obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ], - 'staff' : obj.data.list.au[0], - 'header' : obj.data.print_list_templates.holds.header, - 'line_item' : obj.data.print_list_templates.holds.line_item, - 'footer' : obj.data.print_list_templates.holds.footer, - 'type' : obj.data.print_list_templates.holds.type, - 'list' : obj.list.dump_with_keys(), - }; - JSAN.use('util.print'); var print = new util.print(); - print.tree_list( params ); - setTimeout(function(){obj.list.on_all_fleshed = null;},0); - } catch(E) { - obj.error.standard_unexpected_error_alert('print 2',E); - } - } - obj.list.on_all_fleshed = flesh_callback; - obj.list.full_retrieve(); + JSAN.use('patron.util'); + var params = { + 'patron' : patron.util.retrieve_au_via_id(ses(),obj.patron_id), + 'template' : 'holds' + }; + obj.list.print(params); } catch(E) { obj.error.standard_unexpected_error_alert('print 1',E); } @@ -227,17 +210,7 @@ patron.holds.prototype = { ['command'], function() { try { - function flesh_callback() { - try { - dump(obj.list.dump_csv() + '\n'); - copy_to_clipboard(obj.list.dump_csv()); - setTimeout(function(){obj.list.on_all_fleshed = null;},0); - } catch(E) { - obj.error.standard_unexpected_error_alert('export 2',E); - } - } - obj.list.on_all_fleshed = flesh_callback; - obj.list.full_retrieve(); + obj.list.dump_csv_to_clipboard(); } catch(E) { obj.error.standard_unexpected_error_alert('export 1',E); } diff --git a/Open-ILS/xul/staff_client/server/patron/items.js b/Open-ILS/xul/staff_client/server/patron/items.js index 6e8da28da1..deef6ec20c 100644 --- a/Open-ILS/xul/staff_client/server/patron/items.js +++ b/Open-ILS/xul/staff_client/server/patron/items.js @@ -200,29 +200,12 @@ patron.items.prototype = { var obj = this; try { var list = (which==2 ? obj.list2 : obj.list); - dump(js2JSON( list.dump_with_keys() ) + '\n'); - function flesh_callback() { - try { - JSAN.use('patron.util'); - var params = { - 'patron' : patron.util.retrieve_fleshed_au_via_id(ses(),obj.patron_id), - 'lib' : obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ], - 'staff' : obj.data.list.au[0], - 'header' : obj.data.print_list_templates.items_out.header, - 'line_item' : obj.data.print_list_templates.items_out.line_item, - 'footer' : obj.data.print_list_templates.items_out.footer, - 'type' : obj.data.print_list_templates.items_out.type, - 'list' : list.dump_with_keys(), - }; - JSAN.use('util.print'); var print = new util.print(); - print.tree_list( params ); - setTimeout(function(){list.on_all_fleshed = null;},0); - } catch(E) { - obj.error.standard_unexpected_error_alert('printing 2',E); - } - } - list.on_all_fleshed = flesh_callback; - list.full_retrieve(); + JSAN.use('patron.util'); + var params = { + 'patron' : patron.util.retrieve_fleshed_au_via_id(ses(),obj.patron_id), + 'template' : 'items_out' + }; + list.print( params ); } catch(E) { obj.error.standard_unexpected_error_alert('printing 1',E); } @@ -232,17 +215,7 @@ patron.items.prototype = { var obj = this; try { var list = (which==2 ? obj.list2 : obj.list); - function flesh_callback() { - try { - dump( list.dump_csv() + '\n'); - copy_to_clipboard(list.dump_csv()); - setTimeout(function(){list.on_all_fleshed = null;},0); - } catch(E) { - obj.error.standard_unexpected_error_alert('export 2',E); - } - } - list.on_all_fleshed = flesh_callback; - list.full_retrieve(); + list.dump_csv_to_clipboard(); } catch(E) { obj.error.standard_unexpected_error_alert('export 1',E); } diff --git a/Open-ILS/xul/staff_client/server/patron/search_result.js b/Open-ILS/xul/staff_client/server/patron/search_result.js index 1e1ee51f60..ff472eade2 100644 --- a/Open-ILS/xul/staff_client/server/patron/search_result.js +++ b/Open-ILS/xul/staff_client/server/patron/search_result.js @@ -94,32 +94,14 @@ patron.search_result.prototype = { 'cmd_search_print' : [ ['command'], function() { - dump( js2JSON( obj.list.dump_with_keys() ) ); - JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'}); - obj.list.on_all_fleshed = function() { - try { - dump( js2JSON( obj.list.dump_with_keys() ) + '\n' ); - obj.OpenILS.data.stash_retrieve(); - var lib = data.hash.aou[ data.list.au[0].ws_ou() ]; - lib.children(null); - var p = { - 'lib' : lib, - 'staff' : data.list.au[0], - 'header' : data.print_list_templates.patron.header, - 'line_item' : data.print_list_templates.patron.line_item, - 'footer' : data.print_list_templates.patron.footer, - 'type' : data.print_list_templates.patron.type, - 'list' : obj.list.dump_with_keys(), - }; - JSAN.use('util.print'); var print = new util.print(); - print.tree_list( p ); - setTimeout(function(){obj.list.on_all_fleshed = null;},0); - } catch(E) { - alert(E); - } - } - obj.list.full_retrieve(); - + try { + var p = { + 'template' : 'patron' + }; + obj.list.print( p ); + } catch(E) { + obj.error.standard_unexpected_error_alert('patron search print',E); + } } ], 'cmd_sel_clip' : [ -- 2.11.0