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