]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/xul/staff_client/server/circ/checkout.js
handle PATRON_INACTIVE just in case
[working/Evergreen.git] / Open-ILS / xul / staff_client / server / circ / checkout.js
1 dump('entering circ.checkout.js\n');
2
3 if (typeof circ == 'undefined') circ = {};
4 circ.checkout = function (params) {
5
6         JSAN.use('util.error'); this.error = new util.error();
7         JSAN.use('util.network'); this.network = new util.network();
8         JSAN.use('OpenILS.data'); this.data = new OpenILS.data(); this.data.init({'via':'stash'});
9 }
10
11 circ.checkout.prototype = {
12
13         'init' : function( params ) {
14
15                 var obj = this;
16
17                 obj.patron_id = params['patron_id'];
18                 obj.patron = obj.network.simple_request('FM_AU_RETRIEVE_VIA_ID',[ses(),obj.patron_id]);
19
20                 JSAN.use('circ.util');
21                 var columns = circ.util.columns( 
22                         { 
23                                 'barcode' : { 'hidden' : false },
24                                 'title' : { 'hidden' : false },
25                                 'due_date' : { 'hidden' : false },
26                         } 
27                 );
28
29                 JSAN.use('util.list'); obj.list = new util.list('checkout_list');
30                 obj.list.init(
31                         {
32                                 'columns' : columns,
33                                 'map_row_to_column' : circ.util.std_map_row_to_column(),
34                                 'on_select' : function() {
35                                         var sel = obj.list.retrieve_selection();
36                                         document.getElementById('clip_button').disabled = sel.length < 1;
37                                 }
38                         }
39                 );
40                 
41                 JSAN.use('util.controller'); obj.controller = new util.controller();
42                 obj.controller.init(
43                         {
44                                 'control_map' : {
45                                         'sel_clip' : [
46                                                 ['command'],
47                                                 function() { obj.list.clipboard(); }
48                                         ],
49                                         'checkout_menu_placeholder' : [
50                                                 ['render'],
51                                                 function(e) {
52                                                         return function() {
53                                                                 JSAN.use('util.widgets'); JSAN.use('util.functional'); JSAN.use('util.fm_utils');
54                                                                 var items = [ [ 'Barcode:' , 'barcode' ] ].concat(
55                                                                         util.functional.map_list(
56                                                                                 util.functional.filter_list(
57                                                                                         obj.data.list.cnct,
58                                                                                         function(o) {
59                                                                                                 return util.fm_utils.compare_aou_a_is_b_or_ancestor(o.owning_lib(), obj.data.list.au[0].ws_ou());
60                                                                                         }
61                                                                                 ),
62                                                                                 function(o) {
63                                                                                         return [ o.name(), o.id() ];
64                                                                                 }
65                                                                         )
66                                                                 );
67                                                                 g.error.sdump('D_TRACE','items = ' + js2JSON(items));
68                                                                 util.widgets.remove_children( e );
69                                                                 var ml = util.widgets.make_menulist(
70                                                                         items
71                                                                 );
72                                                                 e.appendChild( ml );
73                                                                 ml.setAttribute('id','checkout_menulist');
74                                                                 ml.setAttribute('accesskey','');
75                                                                 ml.addEventListener(
76                                                                         'command',
77                                                                         function(ev) {
78                                                                                 var tb = obj.controller.view.checkout_barcode_entry_textbox;
79                                                                                 var db = document.getElementById('duedate_hbox');
80                                                                                 if (ev.target.value == 'barcode') {
81                                                                                         db.hidden = false;
82                                                                                         tb.disabled = false;
83                                                                                         tb.value = '';
84                                                                                         tb.focus();
85                                                                                 } else {
86                                                                                         db.hidden = true;
87                                                                                         tb.disabled = true;
88                                                                                         tb.value = 'Non-Cataloged';
89                                                                                 }
90                                                                         }, false
91                                                                 );
92                                                                 obj.controller.view.checkout_menu = ml;
93                                                         };
94                                                 },
95                                         ],
96                                         'checkout_barcode_entry_textbox' : [
97                                                 ['keypress'],
98                                                 function(ev) {
99                                                         if (ev.keyCode && ev.keyCode == 13) {
100                                                                 obj.checkout( { barcode: ev.target.value } );
101                                                         }
102                                                 }
103                                         ],
104                                         'checkout_duedate_menu' : [
105                                                 ['change'],
106                                                 function(ev) { 
107                                                         try {
108                                                                 obj.check_date(ev.target);
109                                                                 ev.target.parentNode.setAttribute('style','');
110                                                         } catch(E) {
111                                                                 ev.target.parentNode.setAttribute('style','background-color: red');
112                                                                 alert(E + '\nUse this format: YYYY-MM-DD');
113                                                                 try {
114                                                                         ev.target.inputField.select();
115                                                                         ev.target.inputField.focus();
116                                                                 } catch(E) { /* this should work, let me try on other platforms */ 
117                                                                         obj.error.sdump('D_ERROR','menulist.inputField: ' + E);
118                                                                 }
119                                                         }
120                                                 }
121                                         ],
122                                         'cmd_broken' : [
123                                                 ['command'],
124                                                 function() { alert('Not Yet Implemented'); }
125                                         ],
126                                         'cmd_checkout_submit' : [
127                                                 ['command'],
128                                                 function() {
129                                                         var params = {}; var count = 1;
130
131                                                         if (obj.controller.view.checkout_menu.value == 'barcode' ||
132                                                                 obj.controller.view.checkout_menu.value == '') {
133                                                                 params.barcode = obj.controller.view.checkout_barcode_entry_textbox.value;
134                                                         } else {
135                                                                 params.noncat = 1;
136                                                                 params.noncat_type = obj.controller.view.checkout_menu.value;
137                                                                 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
138                                                                 var r = window.prompt('Enter the number of ' + obj.data.hash.cnct[ params.noncat_type].name() + ' circulating:','1','Non-cataloged Items');
139                                                                 if (r) {
140                                                                         count = Number(r);
141                                                                         if (count > 0) {
142                                                                                 if (count > 99) {
143                                                                                         obj.error.yns_alert('You tried to circulate ' + count + ' ' + obj.data.hash.cnct[ params.noncat_type].name() + '.  The maximum is 99 per action.','Non-cataloged Circulation','OK',null,null,'Check here to confirm this message.');
144                                                                                         return;
145                                                                                 } else if (count > 20) {
146                                                                                         r = obj.error.yns_alert('Are you sure you want to circulate ' + count + ' ' + obj.data.hash.cnct[ params.noncat_type].name() + '?','Non-cataloged Circulation','Yes','No',null,'Check here to confirm this message.');
147                                                                                         if (r != 0) return;
148                                                                                 }
149                                                                         } else {
150                                                                                 r = obj.error.yns_alert('Error with non-cataloged checkout.  ' + r + ' is not a valid number.','Non-cataloged Circulation','Ok',null,null,'Check here to confirm this message.');
151                                                                                 return;
152                                                                         }
153                                                                 } else {
154                                                                         return;
155                                                                 }
156                                                         }
157                                                         for (var i = 0; i < count; i++) {
158                                                                 obj.checkout( params );
159                                                         }
160                                                 }
161                                         ],
162                                         'cmd_checkout_print' : [
163                                                 ['command'],
164                                                 function() {
165                                                         try {
166                                                                 obj.print();
167                                                         } catch(E) {
168                                                                 obj.error.standard_unexpected_error_alert('cmd_checkout_print',E);
169                                                         }
170
171                                                 }
172                                         ],
173                                         'cmd_checkout_reprint' : [
174                                                 ['command'],
175                                                 function() {
176                                                         JSAN.use('util.print'); var print = new util.print();
177                                                         print.reprint_last();
178                                                 }
179                                         ],
180                                         'cmd_checkout_done' : [
181                                                 ['command'],
182                                                 function() {
183                                                         try {
184                                                                 if (document.getElementById('checkout_auto').checked) {
185                                                                         obj.print(true,function() { 
186                                                                                 obj.list.clear();
187                                                                                 xulG.set_tab(urls.XUL_PATRON_BARCODE_ENTRY,{},{}); 
188                                                                         });
189                                                                 } else {
190                                                                         obj.print(false,function() {
191                                                                                 obj.list.clear();
192                                                                                 xulG.set_tab(urls.XUL_PATRON_BARCODE_ENTRY,{},{});
193                                                                         });
194                                                                 }
195                                                         } catch(E) {
196                                                                 obj.error.standard_unexpected_error_alert('cmd_checkout_done',E);
197                                                         }
198                                                 }
199                                         ],
200                                 }
201                         }
202                 );
203                 this.controller.render();
204                 this.controller.view.checkout_barcode_entry_textbox.focus();
205
206                 this.check_disable();
207
208         },
209
210         'check_disable' : function() {
211                 var obj = this;
212                 try {
213                         if (typeof xulG.check_stop_checkouts == 'function') {
214                                 var disable = xulG.check_stop_checkouts();
215                                 if (disable) {
216                                         document.getElementById('checkout_submit_barcode_button').disabled = true;
217                                         document.getElementById('checkout_done').disabled = true;
218                                         obj.controller.view.checkout_menu.disabled = true;
219                                         obj.controller.view.checkout_barcode_entry_textbox.disabled = true;
220                                 } else {
221                                         document.getElementById('checkout_submit_barcode_button').disabled = false;
222                                         document.getElementById('checkout_done').disabled = false;
223                                         obj.controller.view.checkout_menu.disabled = false;
224                                         obj.controller.view.checkout_barcode_entry_textbox.disabled = false;
225                                 }
226                         }
227                 } catch(E) {
228                         obj.error.standard_unexpected_error_alert('Error determining whether to disable checkout.',E);
229                 }
230         },
231
232         'print' : function(silent,f) {
233                 var obj = this;
234                 try {
235                         obj.list.on_all_fleshed = function() {
236                                 try {
237                                         var params = { 
238                                                 'patron' : obj.patron, 
239                                                 'lib' : obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ],
240                                                 'staff' : obj.data.list.au[0],
241                                                 'header' : obj.data.print_list_templates.checkout.header,
242                                                 'line_item' : obj.data.print_list_templates.checkout.line_item,
243                                                 'footer' : obj.data.print_list_templates.checkout.footer,
244                                                 'type' : obj.data.print_list_templates.checkout.type,
245                                                 'list' : obj.list.dump(),
246                                         };
247                                         if (silent) params.no_prompt = true;
248                                         JSAN.use('util.print'); var print = new util.print();
249                                         print.tree_list( params );
250                                         setTimeout(function(){obj.list.on_all_fleshed = null;if (typeof f == 'function') f();},0);
251                                 } catch(E) {
252                                         obj.error.standard_unexpected_error_alert('print',E);
253                                 }
254                         }
255                         obj.list.full_retrieve();
256                 } catch(E) {
257                         obj.error.standard_unexpected_error_alert('print',E);
258                 }
259         },
260
261         'check_date' : function(node) {
262                 JSAN.use('util.date');
263                 try {
264                         if (node.value == 'Normal') return true;
265                         var pattern = node.value.match(/Today \+ (\d+) days/);
266                         if (pattern) {
267                                 var today = new Date();
268                                 var todayPlus = new Date(); todayPlus.setTime( today.getTime() + 24*60*60*1000*pattern[1] );
269                                 node.value = util.date.formatted_date(todayPlus,"%F");
270                         }
271                         if (! util.date.check('YYYY-MM-DD',node.value) ) { throw('Invalid Date'); }
272                         if (util.date.check_past('YYYY-MM-DD',node.value) ) { throw('Due date needs to be after today.'); }
273                         if ( util.date.formatted_date(new Date(),'%F') == node.value) { throw('Due date needs to be after today.'); }
274                         return true;
275                 } catch(E) {
276                         throw(E);
277                 }
278         },
279
280         'checkout' : function(params) {
281                 var obj = this;
282
283                 try { obj.check_date(obj.controller.view.checkout_duedate_menu); } catch(E) { return; }
284                 if (obj.controller.view.checkout_duedate_menu.value != 'Normal') {
285                         params.due_date = obj.controller.view.checkout_duedate_menu.value;
286                 }
287
288                 if (! (params.barcode||params.noncat)) return;
289
290                 /**********************************************************************************************************************/
291                 /* This does the actual checkout/renewal, but is called after a permit test further below */
292                 function check_out(params) {
293
294                         var checkout = obj.network.request(
295                                 api.CHECKOUT.app,
296                                 api.CHECKOUT.method,
297                                 [ ses(), params ]
298                         );
299
300                         if (checkout.ilsevent == 0) {
301
302                                 if (!checkout.payload) checkout.payload = {};
303
304                                 if (!checkout.payload.circ) {
305                                         checkout.payload.circ = new aoc();
306                                         /*********************************************************************************************/
307                                         /* Non Cat */
308                                         if (checkout.payload.noncat_circ) {
309                                                 checkout.payload.circ.circ_lib( checkout.payload.noncat_circ.circ_lib() );
310                                                 checkout.payload.circ.circ_staff( checkout.payload.noncat_circ.staff() );
311                                                 checkout.payload.circ.usr( checkout.payload.noncat_circ.patron() );
312                                                 
313                                                 JSAN.use('util.date');
314                                                 var c = checkout.payload.noncat_circ.circ_time();
315                                                 var d = c == "now" ? new Date() : util.date.db_date2Date( c );
316                                                 var t =obj.data.hash.cnct[ checkout.payload.noncat_circ.item_type() ];
317                                                 var cd = t.circ_duration() || "14 days";
318                                                 var i = util.date.interval_to_seconds( cd ) * 1000;
319                                                 d.setTime( Date.parse(d) + i );
320                                                 checkout.payload.circ.due_date( util.date.formatted_date(d,'%F') );
321
322                                         }
323                                 }
324
325                                 if (!checkout.payload.record) {
326                                         checkout.payload.record = new mvr();
327                                         /*********************************************************************************************/
328                                         /* Non Cat */
329                                         if (checkout.payload.noncat_circ) {
330                                                 checkout.payload.record.title(
331                                                         obj.data.hash.cnct[ checkout.payload.noncat_circ.item_type() ].name()
332                                                 );
333                                         }
334                                 }
335
336                                 if (!checkout.payload.copy) {
337                                         checkout.payload.copy = new acp();
338                                         checkout.payload.copy.barcode( '' );
339                                 }
340
341                                 /*********************************************************************************************/
342                                 /* Override mvr title/author with dummy title/author for Pre cat */
343                                 if (checkout.payload.copy.dummy_title())  checkout.payload.record.title( checkout.payload.copy.dummy_title() );
344                                 if (checkout.payload.copy.dummy_author())  checkout.payload.record.author( checkout.payload.copy.dummy_author() );
345
346                                 obj.list.append(
347                                         {
348                                                 'row' : {
349                                                         'my' : {
350                                                         'circ' : checkout.payload.circ,
351                                                         'mvr' : checkout.payload.record,
352                                                         'acp' : checkout.payload.copy
353                                                         }
354                                                 }
355                                         //I could override map_row_to_column here
356                                         }
357                                 );
358                                 if (typeof obj.on_checkout == 'function') {
359                                         obj.on_checkout(checkout.payload);
360                                 }
361                                 if (typeof window.xulG == 'object' && typeof window.xulG.on_list_change == 'function') {
362                                         window.xulG.on_list_change(checkout.payload);
363                                 } else {
364                                         obj.error.sdump('D_CIRC','circ.checkout: No external .on_checkout()\n');
365                                 }
366
367                         } else {
368                                 throw(checkout);
369                         }
370                 }
371
372                 /**********************************************************************************************************************/
373                 /* Permissibility test before checkout */
374                 try {
375
376                         params.patron = obj.patron_id;
377
378                         var permit = obj.network.request(
379                                 api.CHECKOUT_PERMIT.app,
380                                 api.CHECKOUT_PERMIT.method,
381                                 [ ses(), params ],
382                                 null,
383                                 {
384                                         'title' : 'Override Checkout Failure?',
385                                         'overridable_events' : [ 
386                                                 1212 /* PATRON_EXCEEDS_OVERDUE_COUNT */,
387                                                 1215 /* CIRC_EXCEEDS_COPY_RANGE */,
388                                                 7002 /* PATRON_EXCEEDS_CHECKOUT_COUNT */,
389                                                 7003 /* COPY_CIRC_NOT_ALLOWED */,
390                                                 7004 /* COPY_NOT_AVAILABLE */, 
391                                                 7006 /* COPY_IS_REFERENCE */, 
392                                                 7010 /* COPY_ALERT_MESSAGE */,
393                                                 7013 /* PATRON_EXCEEDS_FINES */,
394                                         ],
395                                         'text' : {
396                                                 '7004' : function(r) {
397                                                         //return obj.data.hash.ccs[ r.payload ].name();
398                                                         return r.payload.status().name();
399                                                         //return r.payload.name();
400                                                         //return r.payload;
401                                                 },
402                                                 '7010' : function(r) {
403                                                         return r.payload;
404                                                 },
405                                         }
406                                 }
407                         );
408
409                         if (!permit) throw(permit);
410
411                         function test_event(list,ev) {
412                                 if (typeof list.ilsevent != 'undefined' ) {
413                                         if (list.ilsevent == ev) {
414                                                 return list;
415                                         } else {
416                                                 return false;
417                                         }
418                                 } else {
419                                         for (var i = 0; i < list.length; i++) {
420                                                 if (typeof list[i].ilsevent != 'undefined') {
421                                                         if (list[i].ilsevent == ev) return list[i];
422                                                 }
423                                         }
424                                         return false;
425                                 }
426                         }
427
428                         /**********************************************************************************************************************/
429                         /* Normal case, proceed with checkout */
430                         if (permit.ilsevent == 0) {
431
432                                 JSAN.use('util.sound'); var sound = new util.sound(); sound.circ_good();
433                                 params.permit_key = permit.payload;
434                                 check_out( params );
435
436                         /**********************************************************************************************************************/
437                         /* Item not cataloged or barcode mis-scan.  Prompt for pre-cat option */
438                         } else {
439                         
440                                 var found_handled = false; var found_not_handled = false; var msg = ''; 
441
442                                 if (test_event(permit,1202 /* ITEM_NOT_CATALOGED */)) {
443
444                                         if ( 1 == obj.error.yns_alert(
445                                                 'Mis-scan or non-cataloged item.  Checkout as a pre-cataloged item?',
446                                                 'Alert',
447                                                 'Cancel',
448                                                 'Pre-Cat',
449                                                 null,
450                                                 'Check here to confirm this action'
451                                         ) ) {
452
453                                                 obj.data.dummy_title = ''; obj.data.dummy_author = ''; obj.data.stash('dummy_title','dummy_author');
454                                                 JSAN.use('util.window'); var win = new util.window();
455                                                 win.open(urls.XUL_PRE_CAT, 'dummy_fields', 'chrome,resizable,modal');
456                                                 obj.data.stash_retrieve();
457
458                                                 params.permit_key = permit.payload;
459                                                 params.dummy_title = obj.data.dummy_title;
460                                                 params.dummy_author = obj.data.dummy_author;
461                                                 params.precat = 1;
462
463                                                 if (params.dummy_title != '') { check_out( params ); } else { throw('Checkout cancelled'); }
464                                         } 
465                                 };
466
467                                 var test_permit;
468                                 if (typeof permit.ilsevent != 'undefined') { test_permit = [ permit ]; } else { test_permit = permit; }
469
470                                 for (var i = 0; i < test_permit.length; i++) {
471                                         dump('found [' + test_permit[i].ilsevent + ']\n');
472                                         switch(test_permit[i].ilsevent) {
473                                                 case 1212 /* PATRON_EXCEEDS_OVERDUE_COUNT */ :
474                                                         found_handled = true;
475                                                 break;
476                                                 case 1215 /* CIRC_EXCEEDS_COPY_RANGE */ :
477                                                         found_handled = true;
478                                                 break;
479                                                 case 1217 /* PATRON_INACTIVE */ :
480                                                         found_handled = true;
481                                                         msg += 'This patron is inactive and may not circulate items.\n';
482                                                         obj.error.yns_alert(msg,'Check Out Failed','OK',null,null,'Check here to confirm this message');
483                                                 break;
484                                                 case 7013 /* PATRON_EXCEEDS_FINES */ :
485                                                         found_handled = true;
486                                                 break;
487                                                 case 7002 /* PATRON_EXCEEDS_CHECKOUT_COUNT */ :
488                                                         found_handled = true;
489                                                 break;
490                                                 case 7003 /* COPY_CIRC_NOT_ALLOWED */ :
491                                                         found_handled = true;
492                                                 break;
493                                                 case 7004 /* COPY_NOT_AVAILABLE */ :
494                                                         msg += test_permit[i].desc + '\n' + 'Copy status = ' + ( test_permit[i].payload.status().name() ) + '\n';
495                                                         found_handled = true;
496                                                 break;
497                                                 case 7006 /* COPY_IS_REFERENCE */ :
498                                                         msg += test_permit[i].desc + '\n';
499                                                         found_handled = true;
500                                                 break;
501                                                 case 7010 /* COPY_ALERT_MESSAGE */ :
502                                                         msg += test_permit[i].desc + '\n' + 'Alert Message = ' + test_permit[i].payload + '\n';
503                                                         found_handled = true;
504                                                 break;
505                                                 case 1202 /* ITEM_NOT_CATALOGED */ :
506                                                         found_handled = true;
507                                                 break;
508                                                 case 5000 /* PERM_FAILURE */ :
509                                                         msg += test_permit[i].desc + '\n' + 'Permission Denied = ' + test_permit[i].ilsperm + '\n';
510                                                         found_handled = true;
511                                                 break;
512                                                 case 1702 /* OPEN_CIRCULATION_EXISTS */ :
513                                                         msg += test_permit[i].desc + '\n';
514                                                         found_handled = true;
515
516                                                         var my_copy = obj.network.simple_request('FM_ACP_RETRIEVE_VIA_BARCODE',[params.barcode]);
517                                                         if (typeof my_copy.ilsevent != 'undefined') throw(my_copy);
518                                                         var my_circ = obj.network.simple_request('FM_CIRC_RETRIEVE_VIA_COPY',[ses(),my_copy.id(),1]);
519                                                         if (typeof my_circ.ilsevent != 'undefined') throw(my_copy);
520                                                         my_circ = my_circ[0];
521                                                         var due_date = my_circ.due_date() ? my_circ.due_date().substr(0,10) : null;
522                                                         JSAN.use('util.date'); var today = util.date.formatted_date(new Date(),'%F');
523                                                         if (due_date) if (today > due_date) msg += '\nThis item was due on ' + due_date + '.\n';
524                                                         var r = obj.error.yns_alert(msg,'Check Out Failed','Cancel','Checkin then Checkout', due_date ? (today > due_date ? 'Forgiving Checkin then Checkout' : null) : null,'Check here to confirm this message');
525                                                         JSAN.use('circ.util');
526                                                         switch(r) {
527                                                                 case 1:
528                                                                         circ.util.checkin_via_barcode( ses(), params.barcode );
529                                                                         obj.checkout(params);
530                                                                 break;
531                                                                 case 2:
532                                                                         circ.util.checkin_via_barcode( ses(), params.barcode, due_date );
533                                                                         obj.checkout(params);
534                                                                 break;
535                                                         }
536                                                 break;
537                                                 case 7014 /* COPY_IN_TRANSIT */ :
538                                                         msg += test_permit[i].desc + '\n';
539                                                         found_handled = true;
540                                                         var r = obj.error.yns_alert(msg,'Check Out Failed','Cancel','Abort Transit then Checkout',null,'Check here to confirm this message');
541                                                         switch(r) {
542                                                                 case 1:
543                                                                         var robj = obj.network.simple_request('FM_ATC_VOID',[ ses(), { 'barcode' : params.barcode } ]);
544                                                                         if (typeof robj.ilsevent == 'undefined') {
545                                                                                 obj.checkout(params);
546                                                                         } else {
547                                                                                 if (robj.ilsevent != 5000 /* PERM_FAILURE */) throw(robj);
548                                                                         }
549                                                                 break;
550                                                         }
551                                                 break;
552                                                 case -1 /* NETWORK_FAILURE */ :
553                                                         msg += 'There was a network failure.\n';
554                                                         found_handled = true;
555                                                         obj.error.yns_alert(msg,'Check Out Failed','OK',null,null,'Check here to confirm this message');
556                                                 break;
557                                                 default:
558                                                         msg += 'FIXME: ' + js2JSON(test_permit[i]) + '\n';
559                                                         found_not_handled = true;
560                                                 break;
561                                         }
562                                 }
563                                 
564                                 if (found_not_handled) {
565                                         obj.error.standard_unexpected_error_alert(msg,permit);
566                                 }
567
568                                 obj.controller.view.checkout_barcode_entry_textbox.select();
569                                 obj.controller.view.checkout_barcode_entry_textbox.focus();
570                         }
571
572                 } catch(E) {
573                         if (typeof E.ilsevent != 'undefined' && E.ilsevent == -1) {
574                                 obj.error.standard_network_error_alert('Check Out Failed.  If you wish to use the offline interface, in the top menubar select Circulation -> Offline Interface');
575                         } else {
576                                 obj.error.standard_unexpected_error_alert('Check Out Failed',E);
577                         }
578                         if (typeof obj.on_failure == 'function') {
579                                 obj.on_failure(E);
580                         }
581                         if (typeof window.xulG == 'object' && typeof window.xulG.on_failure == 'function') {
582                                 obj.error.sdump('D_CIRC','circ.checkout: Calling external .on_failure()\n');
583                                 window.xulG.on_failure(E);
584                         } else {
585                                 obj.error.sdump('D_CIRC','circ.checkout: No external .on_failure()\n');
586                         }
587                 }
588
589         },
590
591         'on_checkout' : function() {
592                 this.controller.view.checkout_menu.selectedIndex = 0;
593                 this.controller.view.checkout_barcode_entry_textbox.disabled = false;
594                 this.controller.view.checkout_barcode_entry_textbox.value = '';
595                 this.controller.view.checkout_barcode_entry_textbox.focus();
596                 document.getElementById('duedate_hbox').hidden = false;
597         },
598
599         'on_failure' : function() {
600                 this.controller.view.checkout_barcode_entry_textbox.select();
601                 this.controller.view.checkout_barcode_entry_textbox.focus();
602         }
603 }
604
605 dump('exiting circ.checkout.js\n');