3 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
4 if (typeof JSAN == 'undefined') { throw( "The JSAN library object is missing."); }
5 JSAN.errorLevel = "die"; // none, warn, or die
6 JSAN.addRepository('..');
7 JSAN.use('util.error'); g.error = new util.error();
8 g.error.sdump('D_TRACE','my_init() for offline_checkout.xul');
10 if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') {
11 try { window.xulG.set_tab_name('Standalone'); } catch(E) { alert(E); }
14 JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.init({'via':'stash'});
16 JSAN.use('util.list'); g.list = new util.list('checkout_list');
17 JSAN.use('circ.util');
19 'columns' : circ.util.offline_inhouse_use_columns(),
20 'map_row_to_column' : circ.util.std_map_row_to_column(),
23 $('i_barcode').addEventListener('keypress',handle_keypress,false);
24 $('enter').addEventListener('command',handle_enter,false);
25 $('submit').addEventListener('command',next_patron,false);
27 $('i_barcode').focus();
29 JSAN.use('util.file');
30 var file = new util.file('offline_delta');
31 if (file._file.exists()) { g.delta = file.get_object()[0]; file.close(); } else { g.delta = 0; }
34 var err_msg = "!! This software has encountered an error. Please tell your friendly " +
35 "system administrator or software developer the following:\ncirc/offline_in_house_use.xul\n" + E + '\n';
36 try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
41 function $(id) { return document.getElementById(id); }
43 function handle_keypress(ev) {
44 if ( (! ev.keyCode) || (ev.keyCode != 13) ) return;
46 case $('i_barcode') : handle_enter(); break;
51 function handle_enter(ev) {
52 JSAN.use('util.barcode');
53 if ( ($('strict_i_barcode').checked) && (! util.barcode.check($('i_barcode').value)) ) {
54 var r = g.error.yns_alert('This barcode has a bad checkdigit.','Barcode Warning','Ok','Clear',null,'Check here to confirm this message');
58 $('i_barcode').value = '';
59 $('i_barcode').focus();
70 function append_to_list() {
74 JSAN.use('util.date');
78 my.type = 'in_house_use';
79 my.timestamp = parseInt( new Date().getTime() / 1000) + g.delta;
80 my.use_time = util.date.formatted_date(new Date(),"%F %H:%M:%s");
82 var i_barcode = $('i_barcode').value;
83 if (! i_barcode) return;
84 my.barcode = i_barcode;
86 var count = $('count').value;
87 if (!Number(count) || count < 1) count = 1;
90 g.list.append( { 'row' : { 'my' : my } } );
92 var x = $('i_barcode'); x.value = ''; x.focus();
96 dump(E+'\n'); alert(E);
101 function next_patron() {
103 JSAN.use('util.file'); var file = new util.file('pending_xacts');
104 var rows = g.list.dump_with_keys();
105 for (var i = 0; i < rows.length; i++) {
106 var row = rows[i]; row.delta = g.delta;
107 file.append_object(row);
111 if ($('print_receipt').checked) {
114 'header' : g.data.print_list_templates.offline_inhouse_use.header,
115 'line_item' : g.data.print_list_templates.offline_inhouse_use.line_item,
116 'footer' : g.data.print_list_templates.offline_inhouse_use.footer,
117 'type' : g.data.print_list_templates.offline_inhouse_use.type,
118 'list' : g.list.dump(),
120 JSAN.use('util.print'); var print = new util.print();
121 print.tree_list( params );
123 g.error.sdump('D_ERROR','print: ' + E);
124 alert('print: ' + E);
131 x = $('i_barcode'); x.value = ''; x.focus();
134 dump(E+'\n'); alert(E);