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);
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()
);
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; return 0; } ), //g.OpenILS.data.list.billing_type.sort(),
function(obj) { return [ obj.name(), obj.id() ]; } //function(obj) { return [ obj, obj ]; }
),
- billing_list.sort( function(a,b) { if (a.name()>b.name()) return 1; if (a.name()<b.name()) return -1; return 0; } )[0].id()
+ override_default_billing_type || billing_list.sort( function(a,b) { if (a.name()>b.name()) return 1; if (a.name()<b.name()) return -1; return 0; } )[0].id()
);
ml.setAttribute('id','billing_type');
document.getElementById('menu_placeholder').appendChild(ml);
if ( g.OpenILS.data.hash.cbt[ ml.value ] ) {
$('bill_amount').value = g.OpenILS.data.hash.cbt[ ml.value ].default_price();
}
+ var override_default_price = xul_param('override_default_price',{'modal_xulG':true});
+ if (override_default_price) {
+ $('bill_amount').value = override_default_price;
+ }
$('bill_amount').select(); $('bill_amount').focus();
+ g.circ = xul_param('circ',{'modal_xulG':true});
if (xul_param('xact_id',{'modal_xulG':true})) {
g.mbts_id = xul_param('xact_id',{'modal_xulG':true});
$('summary').hidden = false;
function patron_bill_finish() {
try {
+ var do_not_process_bill = xul_param('do_not_process_bill',{'modal_xulG':true});
var xact_id = xul_param('xact_id',{'modal_xulG':true});
- if (!xact_id) {
- var grocery = new mg();
- grocery.isnew('1');
- grocery.billing_location( g.OpenILS.data.list.au[0].ws_ou() );
- grocery.usr( g.au_obj.id() );
- grocery.note( $('bill_note').value );
- xact_id = g.network.request(
- api.FM_MG_CREATE.app,
- api.FM_MG_CREATE.method,
- [ ses(), grocery ]
- );
- }
- if (typeof xact_id.ilsevent == 'undefined') {
- JSAN.use('util.money');
- var billing = new mb();
- billing.isnew('1');
- billing.note( $('bill_note').value );
- billing.xact( xact_id );
- billing.amount( util.money.sanitize( $('bill_amount').value ) );
- billing.btype( $('billing_type').value );
- billing.billing_type( g.OpenILS.data.hash.cbt[$('billing_type').value].name() );
- var mb_id = g.network.request(
- api.FM_MB_CREATE.app,
- api.FM_MB_CREATE.method,
- [ ses(), billing ]
+
+ if (do_not_process_bill) {
+
+ update_modal_xulG(
+ {
+ 'proceed' : true,
+ 'cbt_id' : $('billing_type').value,
+ 'amount' : $('bill_amount').value,
+ 'note' : $('bill_note').value
+ }
);
- if (typeof mb_id.ilsevent != 'undefined') throw(mb_id);
- //alert($('patronStrings').getString('staff.patron.bill_wizard.patron_bill_finish.billing_added'));
+
} else {
- throw(xact_id);
+
+ if (!xact_id) {
+ var grocery = new mg();
+ grocery.isnew('1');
+ grocery.billing_location( g.OpenILS.data.list.au[0].ws_ou() );
+ grocery.usr( g.au_obj.id() );
+ grocery.note( $('bill_note').value );
+ xact_id = g.network.request(
+ api.FM_MG_CREATE.app,
+ api.FM_MG_CREATE.method,
+ [ ses(), grocery ]
+ );
+ }
+ if (typeof xact_id.ilsevent == 'undefined') {
+ JSAN.use('util.money');
+ var billing = new mb();
+ billing.isnew('1');
+ billing.note( $('bill_note').value );
+ billing.xact( xact_id );
+ billing.amount( util.money.sanitize( $('bill_amount').value ) );
+ billing.btype( $('billing_type').value );
+ billing.billing_type( g.OpenILS.data.hash.cbt[$('billing_type').value].name() );
+ var mb_id = g.network.request(
+ api.FM_MB_CREATE.app,
+ api.FM_MB_CREATE.method,
+ [ ses(), billing ]
+ );
+ if (typeof mb_id.ilsevent != 'undefined') throw(mb_id);
+ //alert($('patronStrings').getString('staff.patron.bill_wizard.patron_bill_finish.billing_added'));
+ } else {
+ throw(xact_id);
+ }
+
}
} catch(E) {
g.error.standard_unexpected_error_alert('bill_wizard',E);