From ea07eb6d03c1114b1075e3496ea772ca7bd6fac2 Mon Sep 17 00:00:00 2001 From: phasefx Date: Wed, 14 Oct 2009 05:03:20 +0000 Subject: [PATCH] Add a patron.util.format_name() function and have every XUL interface which shows the patron's name make use of it. Add .alias to the name thus rendered in parenthesis. git-svn-id: svn://svn.open-ils.org/ILS/trunk@14410 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/xul/staff_client/server/cat/util.js | 15 ++++++++++++--- Open-ILS/xul/staff_client/server/circ/circ_brief.xul | 5 ++--- Open-ILS/xul/staff_client/server/patron/bill_details.js | 7 ++++++- Open-ILS/xul/staff_client/server/patron/bill_wizard.js | 7 ++++++- Open-ILS/xul/staff_client/server/patron/display.js | 9 ++++++--- Open-ILS/xul/staff_client/server/patron/hold_details.js | 7 ++++++- Open-ILS/xul/staff_client/server/patron/info_notes.xul | 7 ++++++- Open-ILS/xul/staff_client/server/patron/summary.js | 6 +++++- Open-ILS/xul/staff_client/server/patron/util.js | 12 +----------- 9 files changed, 50 insertions(+), 25 deletions(-) diff --git a/Open-ILS/xul/staff_client/server/cat/util.js b/Open-ILS/xul/staff_client/server/cat/util.js index 2797678b0a..8a1b977b95 100644 --- a/Open-ILS/xul/staff_client/server/cat/util.js +++ b/Open-ILS/xul/staff_client/server/cat/util.js @@ -321,7 +321,12 @@ cat.util.mark_item_damaged = function(copy_ids) { auto_checkin = true; JSAN.use('patron.util'); var patron_obj = patron.util.retrieve_fleshed_au_via_id( ses(), my_circ.usr() ); - var patron_name = patron.util.format_name( patron_obj ) + ' : ' + patron_obj.card().barcode(); + var patron_name = ( patron_obj.prefix() ? patron_obj.prefix() + ' ' : '') + + patron_obj.family_name() + ', ' + + patron_obj.first_given_name() + ' ' + + ( patron_obj.second_given_name() ? patron_obj.second_given_name() + ' ' : '' ) + + ( patron_obj.suffix() ? patron_obj.suffix() : '') + + ' : ' + patron_obj.card().barcode() var msg = $("catStrings").getFormattedString('staff.cat.util.mark_item_damaged.item_circulating_to_patron', [ copies[i].barcode(), patron_name, @@ -355,8 +360,12 @@ cat.util.mark_item_damaged = function(copy_ids) { JSAN.use('util.money'); var circ_obj = robj.payload.circ; var patron_obj = circ_obj.usr(); - JSAN.use('patron.util'); - var patron_name = patron.util.format_name( patron_obj ) + ' : ' + patron_obj.card().barcode(); + var patron_name = ( patron_obj.prefix() ? patron_obj.prefix() + ' ' : '') + + patron_obj.family_name() + ', ' + + patron_obj.first_given_name() + ' ' + + ( patron_obj.second_given_name() ? patron_obj.second_given_name() + ' ' : '' ) + + ( patron_obj.suffix() ? patron_obj.suffix() : '') + + ' : ' + patron_obj.card().barcode() var r1 = error.yns_alert( $("catStrings").getFormattedString('staff.cat.util.mark_item_damaged.charge_patron_prompt.message', [ diff --git a/Open-ILS/xul/staff_client/server/circ/circ_brief.xul b/Open-ILS/xul/staff_client/server/circ/circ_brief.xul index c95ecb4b47..7589b026a6 100644 --- a/Open-ILS/xul/staff_client/server/circ/circ_brief.xul +++ b/Open-ILS/xul/staff_client/server/circ/circ_brief.xul @@ -72,9 +72,8 @@ g.patron_id = r_circ.usr(); $('add_billing').disabled = false; g.network.simple_request('FM_AU_FLESHED_RETRIEVE_VIA_ID',[ ses(), r_circ.usr() ], function(preq) { var r_au = preq.getResultObject(); - JSAN.use('patron.util'); - $('patron_name').value = patron.util.format_name( r_au ) + ' : ' + r_au.card().barcode(); - patron.util.set_penalty_css(r_au); + $('patron_name').value = r_au.family_name() + ', ' + r_au.first_given_name() + ' ' + (r_au.second_given_name() ? r_au.second_given_name() + ' : ' + r_au.card().barcode() : ''); + JSAN.use('patron.util'); patron.util.set_penalty_css(r_au); }); } catch(E) { diff --git a/Open-ILS/xul/staff_client/server/patron/bill_details.js b/Open-ILS/xul/staff_client/server/patron/bill_details.js index f479c4d7d2..92ed9ca5f8 100644 --- a/Open-ILS/xul/staff_client/server/patron/bill_details.js +++ b/Open-ILS/xul/staff_client/server/patron/bill_details.js @@ -8,7 +8,12 @@ function retrieve_patron() { g.au_obj = patron.util.retrieve_fleshed_au_via_id( ses(), g.patron_id ); $('patron_name').setAttribute('value', - patron.util.format_name( g.au_obj ) + ' : ' + g.au_obj.card().barcode() + ( g.au_obj.prefix() ? g.au_obj.prefix() + ' ' : '') + + g.au_obj.family_name() + ', ' + + g.au_obj.first_given_name() + ' ' + + ( g.au_obj.second_given_name() ? g.au_obj.second_given_name() + ' ': '' ) + + ( g.au_obj.suffix() ? g.au_obj.suffix() : '') + + ' : ' + g.au_obj.card().barcode() ); } diff --git a/Open-ILS/xul/staff_client/server/patron/bill_wizard.js b/Open-ILS/xul/staff_client/server/patron/bill_wizard.js index 9d15e55bcb..21a28e55e2 100644 --- a/Open-ILS/xul/staff_client/server/patron/bill_wizard.js +++ b/Open-ILS/xul/staff_client/server/patron/bill_wizard.js @@ -72,7 +72,12 @@ function retrieve_patron() { g.au_obj = patron.util.retrieve_fleshed_au_via_id( ses(), g.patron_id ); $('patron_name').setAttribute('value', - patron.util.format_name( g.au_obj ) + ' : ' + g.au_obj.card().barcode() + ( g.au_obj.prefix() ? g.au_obj.prefix() + ' ' : '') + + g.au_obj.family_name() + ', ' + + g.au_obj.first_given_name() + ' ' + + ( g.au_obj.second_given_name() ? g.au_obj.second_given_name() + ' ' : '' ) + + ( g.au_obj.suffix() ? g.au_obj.suffix() : '') + + ' : ' + g.au_obj.card().barcode() ); } diff --git a/Open-ILS/xul/staff_client/server/patron/display.js b/Open-ILS/xul/staff_client/server/patron/display.js index 884cbe3d93..975d5b7ba9 100644 --- a/Open-ILS/xul/staff_client/server/patron/display.js +++ b/Open-ILS/xul/staff_client/server/patron/display.js @@ -428,11 +428,14 @@ patron.display.prototype = { ['render'], function(e) { return function() { - JSAN.use('patron.util'); e.setAttribute('value', - patron.util.format_name( obj.patron ) + ( obj.patron.prefix() ? obj.patron.prefix() + ' ' : '') + + obj.patron.family_name() + ', ' + + obj.patron.first_given_name() + ' ' + + ( obj.patron.second_given_name() ? obj.patron.second_given_name() + ' ' : '' ) + + ( obj.patron.suffix() ? obj.patron.suffix() : '') ); - patron.util.set_penalty_css(obj.patron); + JSAN.use('patron.util'); patron.util.set_penalty_css(obj.patron); }; } ], diff --git a/Open-ILS/xul/staff_client/server/patron/hold_details.js b/Open-ILS/xul/staff_client/server/patron/hold_details.js index 7f321d2c0d..96f3ea36b8 100644 --- a/Open-ILS/xul/staff_client/server/patron/hold_details.js +++ b/Open-ILS/xul/staff_client/server/patron/hold_details.js @@ -83,7 +83,12 @@ function render_patron() { var au_obj = patron.util.retrieve_fleshed_au_via_id( ses(), g.ahr.usr() ); $('patron_name').setAttribute('value', - patron.util.format_name( au_obj ) + ' : ' + au_obj.card().barcode() + ( au_obj.prefix() ? au_obj.prefix() + ' ' : '') + + au_obj.family_name() + ', ' + + au_obj.first_given_name() + ' ' + + ( au_obj.second_given_name() ? au_obj.second_given_name() + ' ' : '' ) + + ( au_obj.suffix() ? au_obj.suffix() : '') + + ' : ' + au_obj.card().barcode() ); } } diff --git a/Open-ILS/xul/staff_client/server/patron/info_notes.xul b/Open-ILS/xul/staff_client/server/patron/info_notes.xul index cc0ddf4efc..f62f0dc321 100644 --- a/Open-ILS/xul/staff_client/server/patron/info_notes.xul +++ b/Open-ILS/xul/staff_client/server/patron/info_notes.xul @@ -166,7 +166,12 @@ p.simple( '
' + '

'+ $("patronStrings").getString('staff.patron.info_notes.render_notes.pertaining_to') + ' ' + - patron.util.format_name( patron_obj ) + ' : ' + ( patron_obj.prefix() ? patron_obj.prefix() + ' ' : '') + + patron_obj.family_name() + ', ' + + patron_obj.first_given_name() + ' ' + + ( patron_obj.second_given_name() ? patron_obj.second_given_name() + ' ' : '' ) + + ( patron_obj.suffix() ? patron_obj.suffix() : '') + + ' : ' + patron_obj.card().barcode() + '

' + '

"' + g.notes[id].title() + '"' + $("patronStrings").getFormattedString('staff.patron.info_notes.render_notes.created_on', [g.notes[id].create_date().toString().substr(0,10), staff_obj[0], g.data.hash.aou[ staff_obj[3] ].shortname()]) diff --git a/Open-ILS/xul/staff_client/server/patron/summary.js b/Open-ILS/xul/staff_client/server/patron/summary.js index 2e4e351896..0181e096f4 100644 --- a/Open-ILS/xul/staff_client/server/patron/summary.js +++ b/Open-ILS/xul/staff_client/server/patron/summary.js @@ -638,7 +638,11 @@ patron.summary.prototype = { obj.patron = robj; JSAN.use('patron.util'); util.widgets.set_text('patron_name', - patron.util.format_name( obj.patron ) + ( obj.patron.prefix() ? obj.patron.prefix() + ' ' : '') + + obj.patron.family_name() + ', ' + + obj.patron.first_given_name() + ' ' + + ( obj.patron.second_given_name() ? obj.patron.second_given_name() + ' ' : '' ) + + ( obj.patron.suffix() ? obj.patron.suffix() : '') ); patron.util.set_penalty_css(obj.patron); JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'}); diff --git a/Open-ILS/xul/staff_client/server/patron/util.js b/Open-ILS/xul/staff_client/server/patron/util.js index e690cb6745..1cca1d9d32 100644 --- a/Open-ILS/xul/staff_client/server/patron/util.js +++ b/Open-ILS/xul/staff_client/server/patron/util.js @@ -6,7 +6,7 @@ patron.util = {}; patron.util.EXPORT_OK = [ 'columns', 'mbts_columns', 'mb_columns', 'mp_columns', /*'std_map_row_to_column',*/ 'std_map_row_to_columns', 'retrieve_au_via_id', 'retrieve_fleshed_au_via_id', 'retrieve_fleshed_au_via_barcode', 'set_penalty_css', 'retrieve_name_via_id', - 'merge', 'ausp_columns', 'format_name' + 'merge', 'ausp_columns' ]; patron.util.EXPORT_TAGS = { ':all' : patron.util.EXPORT_OK }; @@ -808,14 +808,4 @@ patron.util.merge = function(record_ids) { } } -patron.util.format_name = function(patron_obj) { - var patron_name = ( patron_obj.prefix() ? patron_obj.prefix() + ' ' : '') + - patron_obj.family_name() + ', ' + - patron_obj.first_given_name() + ' ' + - ( patron_obj.second_given_name() ? patron_obj.second_given_name() + ' ' : '' ) + - ( patron_obj.suffix() ? patron_obj.suffix() : '') + - ( patron_obj.alias() ? ' (' + patron_obj.alias() + ')' : ''); - return patron_name; -} - dump('exiting patron/util.js\n'); -- 2.11.0