1 dump('entering circ.checkout.js\n');
3 if (typeof patron == 'undefined') patron = {};
4 circ.checkout = function (params) {
6 JSAN.use('util.error'); this.error = new util.error();
7 JSAN.use('main.network'); this.network = new main.network();
9 JSAN.use('OpenILS.data'); this.OpenILS = {};
10 this.OpenILS.data = new OpenILS.data(); this.OpenILS.data.init({'via':'stash'});
13 circ.checkout.prototype = {
15 'init' : function( params ) {
19 obj.session = params['session'];
20 obj.patron_id = params['patron_id'];
22 JSAN.use('main.list'); obj.list = new main.list('checkout_list');
23 //FIXME//getString used to wrap StringBundles, but we need to do the entity/div thing
24 function getString(s) { return obj.OpenILS.data.entities[s]; }
29 'id' : 'acp_id', 'label' : getString('staff.acp_label_id'), 'flex' : 1,
30 'primary' : false, 'hidden' : true, 'render' : 'my.acp.id()'
33 'id' : 'circ_id', 'label' : getString('staff.circ_label_id'), 'flex' : 1,
34 'primary' : false, 'hidden' : true, 'render' : 'my.circ.id()'
37 'id' : 'mvr_doc_id', 'label' : getString('staff.mvr_label_doc_id'), 'flex' : 1,
38 'primary' : false, 'hidden' : true, 'render' : 'my.mvr.doc_id()'
41 'id' : 'barcode', 'label' : getString('staff.acp_label_barcode'), 'flex' : 1,
42 'primary' : false, 'hidden' : true, 'render' : 'my.acp.barcode()'
45 'id' : 'call_number', 'label' : getString('staff.acp_label_call_number'), 'flex' : 1,
46 'primary' : false, 'hidden' : true, 'render' : 'my.acp.call_number()'
49 'id' : 'copy_number', 'label' : getString('staff.acp_label_copy_number'), 'flex' : 1,
50 'primary' : false, 'hidden' : true, 'render' : 'my.acp.copy_number()'
53 'id' : 'location', 'label' : getString('staff.acp_label_location'), 'flex' : 1,
54 'primary' : false, 'hidden' : true, 'render' : 'my.acp.location()'
57 'id' : 'loan_duration', 'label' : getString('staff.acp_label_loan_duration'), 'flex' : 1,
58 'primary' : false, 'hidden' : true, 'render' : 'my.acp.loan_duration()'
61 'id' : 'circ_lib', 'label' : getString('staff.acp_label_circ_lib'), 'flex' : 1,
62 'primary' : false, 'hidden' : true, 'render' : 'my.acp.circ_lib()'
65 'id' : 'fine_level', 'label' : getString('staff.acp_label_fine_level'), 'flex' : 1,
66 'primary' : false, 'hidden' : true, 'render' : 'my.acp.fine_level()'
69 'id' : 'deposit', 'label' : getString('staff.acp_label_deposit'), 'flex' : 1,
70 'primary' : false, 'hidden' : true, 'render' : 'my.acp.deposit()'
73 'id' : 'deposit_amount', 'label' : getString('staff.acp_label_deposit_amount'), 'flex' : 1,
74 'primary' : false, 'hidden' : true, 'render' : 'my.acp.deposit_amount()'
77 'id' : 'price', 'label' : getString('staff.acp_label_price'), 'flex' : 1,
78 'primary' : false, 'hidden' : true, 'render' : 'my.acp.price()'
81 'id' : 'circ_as_type', 'label' : getString('staff.acp_label_circ_as_type'), 'flex' : 1,
82 'primary' : false, 'hidden' : true, 'render' : 'my.acp.circ_as_type()'
85 'id' : 'circ_modifier', 'label' : getString('staff.acp_label_circ_modifier'), 'flex' : 1,
86 'primary' : false, 'hidden' : true, 'render' : 'my.acp.circ_modifier()'
89 'id' : 'xact_start', 'label' : getString('staff.circ_label_xact_start'), 'flex' : 1,
90 'primary' : false, 'hidden' : true, 'render' : 'my.circ.xact_start()'
93 'id' : 'xact_finish', 'label' : getString('staff.circ_label_xact_finish'), 'flex' : 1,
94 'primary' : false, 'hidden' : true, 'render' : 'my.circ.xact_finish()'
97 'id' : 'due_date', 'label' : getString('staff.circ_label_due_date'), 'flex' : 1,
98 'primary' : false, 'hidden' : false, 'render' : 'my.circ.due_date().substr(0,10)'
101 'id' : 'title', 'label' : getString('staff.mvr_label_title'), 'flex' : 2,
102 'primary' : false, 'hidden' : false, 'render' : 'my.mvr.title()'
105 'id' : 'author', 'label' : getString('staff.mvr_label_author'), 'flex' : 1,
106 'primary' : false, 'hidden' : false, 'render' : 'my.mvr.author()'
109 'id' : 'renewal_remaining', 'label' : getString('staff.circ_label_renewal_remaining'), 'flex' : 0,
110 'primary' : false, 'hidden' : true, 'render' : 'my.circ.renewal_remaining()'
113 'id' : 'status', 'label' : getString('staff.acp_label_status'), 'flex' : 1,
114 'primary' : false, 'hidden' : true, 'render' : 'obj.OpenILS.data.hash.ccs[ my.acp.status() ].name()'
117 'map_row_to_column' : function(row,col) {
118 // row contains { 'my' : { 'acp' : {}, 'circ' : {}, 'mvr' : {} } }
119 // col contains one of the objects listed above in columns
121 return eval( col.render );
126 JSAN.use('main.controller'); obj.controller = new main.controller();
130 'checkout_barcode_entry_textbox' : [
133 if (ev.keyCode && ev.keyCode == 13) {
140 function() { alert('Not Yet Implemented'); }
142 'cmd_checkout_submit_barcode' : [
148 'cmd_checkout_print' : [
153 'cmd_checkout_reprint' : [
158 'cmd_checkout_done' : [
166 this.controller.view.checkout_barcode_entry_textbox.focus();
170 'checkout' : function() {
173 var barcode = obj.controller.view.checkout_barcode_entry_textbox.value;
174 var permit = obj.network.request(
175 api.checkout_permit_via_barcode.app,
176 api.checkout_permit_via_barcode.method,
177 [ obj.session, barcode, obj.patron_id, 0 ]
180 if (permit.status == 0) {
181 var checkout = obj.network.request(
182 api.checkout_via_barcode.app,
183 api.checkout_via_barcode.method,
184 [ obj.session, barcode, obj.patron_id ]
190 'circ' : checkout.circ,
191 'mvr' : checkout.record,
192 'acp' : checkout.copy
195 //I could override map_row_to_column here
198 if (typeof obj.on_checkout == 'function') {
199 obj.on_checkout(checkout);
201 if (typeof window.xulG == 'object' && typeof window.xulG.on_checkout == 'function') {
202 obj.error.sdump('D_CIRC','circ.checkout: Calling external .on_checkout()\n');
203 window.xulG.on_checkout(checkout);
205 obj.error.sdump('D_CIRC','circ.checkout: No external .on_checkout()\n');
212 alert('FIXME: need special alert and error handling\n'
214 if (typeof obj.on_failure == 'function') {
217 if (typeof window.xulG == 'object' && typeof window.xulG.on_failure == 'function') {
218 obj.error.sdump('D_CIRC','circ.checkout: Calling external .on_failure()\n');
219 window.xulG.on_failure(E);
221 obj.error.sdump('D_CIRC','circ.checkout: No external .on_failure()\n');
227 'on_checkout' : function() {
228 this.controller.view.checkout_barcode_entry_textbox.value = '';
229 this.controller.view.checkout_barcode_entry_textbox.focus();
232 'on_failure' : function() {
233 this.controller.view.checkout_barcode_entry_textbox.select();
234 this.controller.view.checkout_barcode_entry_textbox.focus();
238 dump('exiting circ.checkout.js\n');