From 839c67f8e3d3c4e1b99062880b256f7ae71ad56c Mon Sep 17 00:00:00 2001 From: phasefx Date: Mon, 2 Nov 2009 06:47:32 +0000 Subject: [PATCH] FEATURE: bill patron dialog on mark item damage given certain org settings. allows you to override the item price for the purpose of billing and optionally specify an arbitrary billing type. TODO: see if we need to either disable the note field in the dialog or have the middle layer make use of it. See if we need to display both the billing type and the btype in the bills interface, or if the btype is meant to replace the billing type git-svn-id: svn://svn.open-ils.org/ILS/trunk@14717 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/xul/staff_client/server/cat/util.js | 38 +++-- .../server/locale/en-US/cat.properties | 5 - .../xul/staff_client/server/patron/bill_wizard.js | 176 +++++++++++++-------- 3 files changed, 130 insertions(+), 89 deletions(-) diff --git a/Open-ILS/xul/staff_client/server/cat/util.js b/Open-ILS/xul/staff_client/server/cat/util.js index 011587662b..09cb7f11dc 100644 --- a/Open-ILS/xul/staff_client/server/cat/util.js +++ b/Open-ILS/xul/staff_client/server/cat/util.js @@ -355,21 +355,31 @@ 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 r1 = error.yns_alert( - $("catStrings").getFormattedString('staff.cat.util.mark_item_damaged.charge_patron_prompt.message', [ - copies[i].barcode(), - patron_name, - circ_obj.checkin_time().substr(0,10), // FIXME: need to replace with something better - util.money.sanitize(robj.payload.charge) ]), - $("catStrings").getString('staff.cat.util.mark_item_damaged.charge_patron_prompt.title'), - $("catStrings").getString('staff.cat.util.mark_item_damaged.charge_patron_prompt.ok_label'), - $("catStrings").getString('staff.cat.util.mark_item_damaged.charge_patron_prompt.cancel_label'), null, - $("catStrings").getString('staff.cat.util.mark_item_damaged.charge_patron_prompt.confirm_action')); - - robj = network.simple_request('MARK_ITEM_DAMAGED',[ ses(), copies[i].id(), {'apply_fines' : r1 == 0 ? 'apply' : 'noapply'} ]); + JSAN.use('util.window'); var win = new util.window(); + var my_xulG = win.open( + urls.XUL_PATRON_BILL_WIZARD, + 'billwizard', + 'chrome,resizable,modal', + { + 'patron' : patron_obj, + 'patron_id' : patron_obj.id(), + 'circ' : circ_obj, + 'xact_id' : circ_obj.id(), + 'do_not_process_bill' : true, + 'override_default_billing_type' : 7, /* Damaged Item */ + 'override_default_price' : util.money.sanitize( robj.payload.charge ) + } + ); + + var params = {}; + params.apply_fines = my_xulG.proceed ? 'apply' : 'noapply'; + if (my_xulG.proceed) { + params.override_amount = my_xulG.amount; + params.override_btype = my_xulG.cbt_id; + params.override_note = my_xulG.note; + } + robj = network.simple_request('MARK_ITEM_DAMAGED',[ ses(), copies[i].id(), params ]); if (typeof robj.ilsevent != 'undefined') { throw(robj); } break; default: throw(robj); diff --git a/Open-ILS/xul/staff_client/server/locale/en-US/cat.properties b/Open-ILS/xul/staff_client/server/locale/en-US/cat.properties index 3d3a2951c0..9b601e0a63 100644 --- a/Open-ILS/xul/staff_client/server/locale/en-US/cat.properties +++ b/Open-ILS/xul/staff_client/server/locale/en-US/cat.properties @@ -348,11 +348,6 @@ staff.cat.util.mark_item_damaged.checkin.no_checkin=Cancel staff.cat.util.mark_item_damaged.checkin.forgiving_checkin=Forgiving Checkin staff.cat.util.mark_item_damaged.checkin.confirm_action=Check here to confirm this action staff.cat.util.mark_item_damaged.item_circulating_to_patron=Item %1$s is checked out to patron, %2$s, and is due on %3$s. -staff.cat.util.mark_item_damaged.charge_patron_prompt.message=Item %1$s will be marked damaged. Was returned on %3$s for %2$s. Charge this patron $%4$s for the damage? -staff.cat.util.mark_item_damaged.charge_patron_prompt.title=Charge Patron For Damaged Item? -staff.cat.util.mark_item_damaged.charge_patron_prompt.ok_label=OK -staff.cat.util.mark_item_damaged.charge_patron_prompt.cancel_label=Cancel -staff.cat.util.mark_item_damaged.charge_patron_prompt.confirm_action=Check here to confirm this action staff.cat.util.mark_item_damaged.marking_error=Error marking item %1$s damaged. staff.cat.util.mark_item_damaged.one_item_damaged=Item marked Damaged staff.cat.util.mark_item_damaged.multiple_item_damaged=%1$s items marked Damaged. 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..ff77218727 100644 --- a/Open-ILS/xul/staff_client/server/patron/bill_wizard.js +++ b/Open-ILS/xul/staff_client/server/patron/bill_wizard.js @@ -22,55 +22,68 @@ function retrieve_mbts() { function retrieve_circ() { JSAN.use('util.widgets'); - g.network.simple_request('FM_CIRC_RETRIEVE_VIA_ID', [ ses(), g.mbts_id ], - function (req) { - var r_circ = req.getResultObject(); - if (instanceOf(r_circ,circ)) { - - $('title_label').hidden = false; - $('checked_out_label').hidden = false; - $('due_label').hidden = false; - $('checked_in_label').hidden = false; - $('checked_out').value = r_circ.xact_start() ? r_circ.xact_start().toString().substr(0,10) : ''; - $('checked_in').value = r_circ.checkin_time() ? r_circ.checkin_time().toString().substr(0,10) : ''; - $('due').value = r_circ.due_date() ? r_circ.due_date().toString().substr(0,10) : ''; - - g.network.simple_request( - 'MODS_SLIM_RECORD_RETRIEVE_VIA_COPY.authoritative', - [ r_circ.target_copy() ], - function (rreq) { - var r_mvr = rreq.getResultObject(); - if (instanceOf(r_mvr,mvr)) { - util.widgets.remove_children('title'); - $('title').appendChild( document.createTextNode( r_mvr.title() ) ); - } else { - g.network.simple_request( - 'FM_ACP_RETRIEVE', - [ r_circ.target_copy() ], - function (rrreq) { - var r_acp = rrreq.getResultObject(); - if (instanceOf(r_acp,acp)) { - util.widgets.remove_children('title'); - $('title').appendChild( document.createTextNode( r_acp.dummy_title() ) ); - } - } - ); + + function render_circ(r_circ) { + + $('title_label').hidden = false; + $('checked_out_label').hidden = false; + $('due_label').hidden = false; + $('checked_in_label').hidden = false; + $('checked_out').value = r_circ.xact_start() ? r_circ.xact_start().toString().substr(0,10) : ''; + $('checked_in').value = r_circ.checkin_time() ? r_circ.checkin_time().toString().substr(0,10) : ''; + $('due').value = r_circ.due_date() ? r_circ.due_date().toString().substr(0,10) : ''; + + g.network.simple_request( + 'MODS_SLIM_RECORD_RETRIEVE_VIA_COPY.authoritative', + [ typeof r_circ.target_copy() == 'object' ? r_circ.target_copy().id() : r_circ.target_copy() ], + function (rreq) { + var r_mvr = rreq.getResultObject(); + if (instanceOf(r_mvr,mvr)) { + util.widgets.remove_children('title'); + $('title').appendChild( document.createTextNode( r_mvr.title() ) ); + } else { + g.network.simple_request( + 'FM_ACP_RETRIEVE', + [ typeof r_circ.target_copy() == 'object' ? r_circ.target_copy().id() : r_circ.target_copy() ], + function (rrreq) { + var r_acp = rrreq.getResultObject(); + if (instanceOf(r_acp,acp)) { + util.widgets.remove_children('title'); + $('title').appendChild( document.createTextNode( r_acp.dummy_title() ) ); + } } - } - ); + ); + } + } + ); + + } + if (g.circ) { + render_circ(g.circ); + } else { + g.network.simple_request('FM_CIRC_RETRIEVE_VIA_ID', [ ses(), g.mbts_id ], + function (req) { + var r_circ = req.getResultObject(); + if (instanceOf(r_circ,circ)) { + render_circ(r_circ); + } } - } - ); + ); + } } function retrieve_patron() { + JSAN.use('patron.util'); + g.patron_id = xul_param('patron_id',{'modal_xulG':true}); + g.au_obj = xul_param('patron',{'modal_xulG':true}); - if (g.patron_id) { - JSAN.use('patron.util'); + if (! g.au_obj) { g.au_obj = patron.util.retrieve_fleshed_au_via_id( ses(), g.patron_id ); - + } + + if (g.au_obj) { $('patron_name').setAttribute('value', patron.util.format_name( g.au_obj ) + ' : ' + g.au_obj.card().barcode() ); @@ -93,13 +106,14 @@ function patron_bill_init() { JSAN.use('util.money'); JSAN.use('util.widgets'); JSAN.use('util.functional'); - var billing_list = util.functional.filter_list( g.OpenILS.data.list.cbt, function (x) { return x.id() >= 100 } ); + var override_default_billing_type = xul_param('override_default_billing_type',{'modal_xulG':true}); + var billing_list = util.functional.filter_list( g.OpenILS.data.list.cbt, function (x) { return x.id() >= 100 || x.id() == override_default_billing_type } ); var ml = util.widgets.make_menulist( util.functional.map_list( billing_list.sort( function(a,b) { if (a.name()>b.name()) return 1; if (a.name()b.name()) return 1; if (a.name()b.name()) return 1; if (a.name()