1 dump('entering circ.checkin.js\n');
3 if (typeof circ == 'undefined') circ = {};
4 circ.checkin = function (params) {
6 JSAN.use('util.error'); this.error = new util.error();
7 JSAN.use('util.network'); this.network = new util.network();
9 this.OpenILS = {}; JSAN.use('OpenILS.data'); this.OpenILS.data = new OpenILS.data(); this.OpenILS.data.init({'via':'stash'});
12 circ.checkin.prototype = {
14 'init' : function( params ) {
18 obj.session = params['session'];
20 JSAN.use('circ.util');
21 var columns = circ.util.columns(
23 'barcode' : { 'hidden' : false },
24 'title' : { 'hidden' : false },
25 'status' : { 'hidden' : false },
26 //'checkin_status' : { 'hidden' : false },
27 'checkin_route_to' : { 'hidden' : false },
28 'checkin_text' : { 'hidden' : false, 'flex' : 3 },
31 dump('columns = ' + js2JSON(columns) + '\n');
33 JSAN.use('util.list'); obj.list = new util.list('checkin_list');
37 'map_row_to_column' : circ.util.std_map_row_to_column(),
41 JSAN.use('util.controller'); obj.controller = new util.controller();
45 'checkin_barcode_entry_textbox' : [
48 if (ev.keyCode && ev.keyCode == 13) {
53 'checkin_effective_date_label' : [
57 obj.controller.view.checkin_effective_date_textbox.value =
58 util.date.formatted_date(new Date(),'%F');
62 'checkin_effective_date_textbox' : [
65 if (ev.target.nodeName == 'textbox') {
68 var darray = ev.target.value.split('-');
69 var year = darray[0]; var month = darray[1]; var day = darray[2];
70 if ( (!year) || (year.length != 4) || (!parseInt(year)) ) flag = true;
71 if ( (!month) || (month.length !=2) || (!parseInt(month)) ) flag = true;
72 if ( (!day) || (day.length !=2) || (!parseInt(day)) ) flag = true;
74 throw('invalid date format');
76 var d = new Date( year, month - 1, day );
77 if (d.toString() == 'Invalid Date') throw('Invalid Date');
78 if ( d > new Date() ) throw('Future Date');
79 ev.target.value = util.date.formatted_date(d,'%F');
82 dump('checkin:effective_date: ' + E + '\n');
83 ev.target.value = util.date.formatted_date(new Date(),'%F');
90 function() { alert('Not Yet Implemented'); }
92 'cmd_checkin_submit_barcode' : [
98 'cmd_checkin_print' : [
103 'cmd_checkin_reprint' : [
108 'cmd_checkin_done' : [
116 this.controller.render();
117 this.controller.view.checkin_barcode_entry_textbox.focus();
121 'checkin' : function() {
124 var barcode = obj.controller.view.checkin_barcode_entry_textbox.value;
125 var backdate = obj.controller.view.checkin_effective_date_textbox.value;
126 JSAN.use('circ.util');
127 var checkin = circ.util.checkin_via_barcode(
128 obj.session, barcode, backdate
134 'circ' : checkin.circ,
135 'mvr' : checkin.record,
136 'acp' : checkin.copy,
137 'status' : checkin.status,
138 'route_to' : checkin.route_to,
139 'text' : checkin.text,
142 //I could override map_row_to_column here
145 if (typeof obj.on_checkin == 'function') {
146 obj.on_checkin(checkin);
148 if (typeof window.xulG == 'object' && typeof window.xulG.on_checkin == 'function') {
149 obj.error.sdump('D_CIRC','circ.checkin: Calling external .on_checkin()\n');
150 window.xulG.on_checkin(checkin);
152 obj.error.sdump('D_CIRC','circ.checkin: No external .on_checkin()\n');
156 alert('FIXME: need special alert and error handling\n'
158 if (typeof obj.on_failure == 'function') {
161 if (typeof window.xulG == 'object' && typeof window.xulG.on_failure == 'function') {
162 obj.error.sdump('D_CIRC','circ.checkin: Calling external .on_failure()\n');
163 window.xulG.on_failure(E);
165 obj.error.sdump('D_CIRC','circ.checkin: No external .on_failure()\n');
171 'on_checkin' : function() {
172 this.controller.view.checkin_barcode_entry_textbox.value = '';
173 this.controller.view.checkin_barcode_entry_textbox.focus();
176 'on_failure' : function() {
177 this.controller.view.checkin_barcode_entry_textbox.select();
178 this.controller.view.checkin_barcode_entry_textbox.focus();
182 dump('exiting circ.checkin.js\n');