1 function $(id) { return document.getElementById(id); }
3 function retrieve_mbts() {
4 g.network.simple_request('FM_MBTS_RETRIEVE.authoritative',[ses(),g.mbts_id],
7 g.mbts = req.getResultObject();
8 $('mbts_id').value = g.mbts.id();
9 $('mbts_xact_type').value = g.mbts.xact_type();
10 $('mbts_xact_start').value = util.date.formatted_date( g.mbts.xact_start(), '%{localized}' );
11 $('mbts_xact_finish').value = g.mbts.xact_finish() ? util.date.formatted_date( g.mbts.xact_finish(), '%{localized}' ) : '';
12 $('mbts_total_owed').value = g.mbts.total_owed() ? util.money.sanitize( g.mbts.total_owed() ) : '';
13 $('mbts_total_paid').value = g.mbts.total_paid() ? util.money.sanitize( g.mbts.total_paid() ) : '';
14 $('mbts_balance_owed').value = g.mbts.balance_owed() ? util.money.sanitize( g.mbts.balance_owed() ) : '';
15 $('xact_type').value = g.mbts.xact_type(); $('xact_type').disabled = true;
17 g.error.sdump('D_ERROR',E);
23 function retrieve_circ() {
24 JSAN.use('util.widgets');
26 function render_circ(r_circ) {
28 $('title_label').hidden = false;
29 $('checked_out_label').hidden = false;
30 $('due_label').hidden = false;
31 $('checked_in_label').hidden = false;
32 $('checked_out').value = r_circ.xact_start() ? util.date.formatted_date( r_circ.xact_start(), '%{localized}' ) : '';
33 $('checked_in').value = r_circ.checkin_time() ? util.date.formatted_date( r_circ.checkin_time(), '%{localized}' ) : '';
34 $('due').value = r_circ.due_date() ? util.date.formatted_date( r_circ.due_date(), '%{localized}' ) : '';
36 g.network.simple_request(
37 'MODS_SLIM_RECORD_RETRIEVE_VIA_COPY.authoritative',
38 [ typeof r_circ.target_copy() == 'object' ? r_circ.target_copy().id() : r_circ.target_copy() ],
40 var r_mvr = rreq.getResultObject();
41 if (instanceOf(r_mvr,mvr)) {
42 util.widgets.remove_children('title');
43 $('title').appendChild( document.createTextNode( r_mvr.title() ) );
45 g.network.simple_request(
47 [ typeof r_circ.target_copy() == 'object' ? r_circ.target_copy().id() : r_circ.target_copy() ],
49 var r_acp = rrreq.getResultObject();
50 if (instanceOf(r_acp,acp)) {
51 util.widgets.remove_children('title');
52 $('title').appendChild( document.createTextNode( r_acp.dummy_title() ) );
65 g.network.simple_request('FM_CIRC_RETRIEVE_VIA_ID', [ ses(), g.mbts_id ],
67 var r_circ = req.getResultObject();
68 if (instanceOf(r_circ,circ)) {
76 function retrieve_patron() {
77 JSAN.use('patron.util');
79 g.patron_id = xul_param('patron_id');
80 g.au_obj = xul_param('patron');
83 g.au_obj = patron.util.retrieve_fleshed_au_via_id( ses(), g.patron_id );
87 $('patron_name').setAttribute('value',
88 patron.util.format_name( g.au_obj ) + ' : ' + g.au_obj.card().barcode()
94 function patron_bill_init() {
96 if (typeof JSAN == 'undefined') { throw( $("commonStrings").getString('common.jsan.missing') ); }
97 JSAN.errorLevel = "die"; // none, warn, or die
98 JSAN.addRepository('/xul/server/');
99 JSAN.use('util.error'); g.error = new util.error();
100 g.error.sdump('D_TRACE','my_init() for patron_display.xul');
101 g.OpenILS = {}; JSAN.use('OpenILS.data'); g.OpenILS.data = new OpenILS.data();
102 g.OpenILS.data.init({'via':'stash'});
103 JSAN.use('util.network'); g.network = new util.network();
104 JSAN.use('util.date');
105 JSAN.use('util.money');
106 JSAN.use('util.widgets');
107 JSAN.use('util.functional');
108 var override_default_billing_type = xul_param('override_default_billing_type');
109 var billing_list = util.functional.filter_list( g.OpenILS.data.list.cbt, function (x) { return x.id() >= 100 || x.id() == override_default_billing_type } );
110 var ml = util.widgets.make_menulist(
111 util.functional.map_list(
112 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(),
113 function(obj) { return [ obj.name(), obj.id() ]; } //function(obj) { return [ obj, obj ]; }
115 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()
117 ml.setAttribute('id','billing_type');
118 document.getElementById('menu_placeholder').appendChild(ml);
122 if ( g.OpenILS.data.hash.cbt[ ml.value ] ) {
123 $('bill_amount').value = g.OpenILS.data.hash.cbt[ ml.value ].default_price();
131 $('wizard_billing_location').setAttribute('value', g.OpenILS.data.hash.aou[ g.OpenILS.data.list.au[0].ws_ou() ].name() );
133 if ( g.OpenILS.data.hash.cbt[ ml.value ] ) {
134 $('bill_amount').value = g.OpenILS.data.hash.cbt[ ml.value ].default_price();
136 var override_default_price = xul_param('override_default_price');
137 if (override_default_price) {
138 $('bill_amount').value = override_default_price;
140 $('bill_amount').select(); $('bill_amount').focus();
142 g.circ = xul_param('circ');
143 if (xul_param('xact_id')) {
144 g.mbts_id = xul_param('xact_id');
145 $('summary').hidden = false;
151 var err_msg = $("commonStrings").getFormattedString('common.exception', ['patron/bill_wizard.xul', E]);
152 try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
158 function patron_bill_finish() {
160 var do_not_process_bill = xul_param('do_not_process_bill');
161 var xact_id = xul_param('xact_id');
163 if (do_not_process_bill) {
166 xulG.cbt_id = $('billing_type').value;
167 xulG.amount = $('bill_amount').value;
168 xulG.note = $('bill_note').value;
173 var grocery = new mg();
175 grocery.billing_location( g.OpenILS.data.list.au[0].ws_ou() );
176 grocery.usr( g.au_obj.id() );
177 grocery.note( $('bill_note').value );
178 xact_id = g.network.request(
179 api.FM_MG_CREATE.app,
180 api.FM_MG_CREATE.method,
184 if (typeof xact_id.ilsevent == 'undefined') {
185 JSAN.use('util.money');
186 var billing = new mb();
188 billing.note( $('bill_note').value );
189 billing.xact( xact_id );
190 billing.amount( util.money.sanitize( $('bill_amount').value ) );
191 billing.btype( $('billing_type').value );
192 billing.billing_type( g.OpenILS.data.hash.cbt[$('billing_type').value].name() );
193 var mb_id = g.network.request(
194 api.FM_MB_CREATE.app,
195 api.FM_MB_CREATE.method,
198 if (typeof mb_id.ilsevent != 'undefined') throw(mb_id);
199 //alert($('patronStrings').getString('staff.patron.bill_wizard.patron_bill_finish.billing_added'));
202 xulG.xact_id = xact_id;
210 g.error.standard_unexpected_error_alert('bill_wizard',E);