]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/xul/staff_client/server/circ/checkin.js
experiment: asynchronous check-in via checkbox toggle. also removes call number...
[working/Evergreen.git] / Open-ILS / xul / staff_client / server / circ / checkin.js
1 dump('entering circ.checkin.js\n');
2
3 if (typeof circ == 'undefined') circ = {};
4 circ.checkin = 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('util.barcode');
9     JSAN.use('util.date');
10     this.OpenILS = {}; JSAN.use('OpenILS.data'); this.OpenILS.data = new OpenILS.data(); this.OpenILS.data.init({'via':'stash'});
11     this.data = this.OpenILS.data;
12 }
13
14 circ.checkin.prototype = {
15
16     'selection_list' : [],
17     'row_map' : {},
18
19     'init' : function( params ) {
20
21         var obj = this;
22
23         JSAN.use('circ.util'); JSAN.use('patron.util');
24         var columns = circ.util.columns( 
25             { 
26                 'barcode' : { 'hidden' : false },
27                 'title' : { 'hidden' : false },
28                 'location' : { 'hidden' : false },
29                 'status' : { 'hidden' : false },
30                 'route_to' : { 'hidden' : false },
31                 'alert_message' : { 'hidden' : false },
32                 'checkin_time' : { 'hidden' : false }
33             },
34             {
35                 'except_these' : [ 'uses', 'checkin_time_full', 'call_number' ]
36             }
37         ).concat(
38             patron.util.columns( { 'family_name' : { 'hidden' : 'false' } } )
39
40         ).concat(
41             patron.util.mbts_columns( {}, { 'except_these' : [ 'total_paid', 'total_owed', 'xact_start', 'xact_finish', 'xact_type' ] } )
42
43         ).sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
44
45         JSAN.use('util.list'); obj.list = new util.list('checkin_list');
46         obj.list.init(
47             {
48                 'columns' : columns,
49                 'map_row_to_columns' : circ.util.std_map_row_to_columns(),
50                 'retrieve_row' : obj.gen_list_retrieve_row_func(),
51                 'on_select' : function(ev) {
52                     try {
53                         JSAN.use('util.functional');
54                         var sel = obj.list.retrieve_selection();
55                         obj.selection_list = util.functional.map_list(
56                             sel,
57                             function(o) { var p = JSON2js(o.getAttribute('retrieve_id')); p.unique_row_counter = o.getAttribute('unique_row_counter'); return p; }
58                         );
59                         obj.error.sdump('D_TRACE', 'circ/copy_status: selection list = ' + js2JSON(obj.selection_list) );
60                         if (obj.selection_list.length == 0) {
61                             obj.controller.view.sel_edit.setAttribute('disabled','true');
62                             obj.controller.view.sel_backdate.setAttribute('disabled','true');
63                             obj.controller.view.sel_opac.setAttribute('disabled','true');
64                             obj.controller.view.sel_patron.setAttribute('disabled','true');
65                             obj.controller.view.sel_last_patron.setAttribute('disabled','true');
66                             obj.controller.view.sel_copy_details.setAttribute('disabled','true');
67                             obj.controller.view.sel_bucket.setAttribute('disabled','true');
68                             obj.controller.view.sel_spine.setAttribute('disabled','true');
69                             obj.controller.view.sel_transit_abort.setAttribute('disabled','true');
70                             obj.controller.view.sel_clip.setAttribute('disabled','true');
71                             obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','true');
72                             obj.controller.view.sel_mark_missing_pieces.setAttribute('disabled','true');
73                         } else {
74                             obj.controller.view.sel_edit.setAttribute('disabled','false');
75                             obj.controller.view.sel_backdate.setAttribute('disabled','false');
76                             obj.controller.view.sel_opac.setAttribute('disabled','false');
77                             obj.controller.view.sel_patron.setAttribute('disabled','false');
78                             obj.controller.view.sel_last_patron.setAttribute('disabled','false');
79                             obj.controller.view.sel_copy_details.setAttribute('disabled','false');
80                             obj.controller.view.sel_bucket.setAttribute('disabled','false');
81                             obj.controller.view.sel_spine.setAttribute('disabled','false');
82                             obj.controller.view.sel_transit_abort.setAttribute('disabled','false');
83                             obj.controller.view.sel_clip.setAttribute('disabled','false');
84                             obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','false');
85                             obj.controller.view.sel_mark_missing_pieces.setAttribute('disabled','false');
86                         }
87                     } catch(E) {
88                         alert('FIXME: ' + E);
89                     }
90                 }
91             }
92         );
93         
94         JSAN.use('util.controller'); obj.controller = new util.controller();
95         obj.controller.init(
96             {
97                 'control_map' : {
98                     'save_columns' : [ [ 'command' ], function() { obj.list.save_columns(); } ],
99                     'sel_clip' : [
100                         ['command'],
101                         function() { 
102                             obj.list.clipboard(); 
103                             obj.controller.view.checkin_barcode_entry_textbox.focus();
104                         }
105                     ],
106                     'sel_edit' : [
107                         ['command'],
108                         function() {
109                             try {
110                                 obj.spawn_copy_editor();
111                             } catch(E) {
112                                 alert(E);
113                             }
114                         }
115                     ],
116                     'sel_spine' : [
117                         ['command'],
118                         function() {
119                             JSAN.use('cat.util');
120                             cat.util.spawn_spine_editor(obj.selection_list);
121                         }
122                     ],
123                     'sel_opac' : [
124                         ['command'],
125                         function() {
126                             JSAN.use('cat.util');
127                             cat.util.show_in_opac(obj.selection_list);
128                         }
129                     ],
130                     'sel_transit_abort' : [
131                         ['command'],
132                         function() {
133                             JSAN.use('circ.util');
134                             circ.util.abort_transits(obj.selection_list);
135                         }
136                     ],
137                     'sel_patron' : [
138                         ['command'],
139                         function() {
140                             JSAN.use('circ.util');
141                             circ.util.show_last_few_circs(obj.selection_list);
142                         }
143                     ],
144                     'sel_last_patron' : [
145                         ['command'],
146                         function() {
147                             var patrons = {};
148                             for (var i = 0; i < obj.selection_list.length; i++) {
149                                 var circs = obj.network.simple_request('FM_CIRC_RETRIEVE_VIA_COPY',[ses(),obj.selection_list[i].copy_id,1]);
150                                 if (circs.length > 0) {
151                                     patrons[circs[0].usr()] = 1;
152                                 } else {
153                                     alert(document.getElementById('circStrings').getFormattedString('staff.circ.item_no_circs', [obj.selection_list[i].barcode]));
154                                 }
155                             }
156                             for (var i in patrons) {
157                                 xulG.new_patron_tab({},{'id' : i});
158                             }
159                         }
160                     ],
161                     'sel_copy_details' : [
162                         ['command'],
163                         function() {
164                             JSAN.use('circ.util');
165                             circ.util.item_details_new(
166                                 util.functional.map_list(
167                                     obj.selection_list,
168                                     function(o) { return o.barcode; }
169                                 )
170                             );
171                         }
172                     ],
173                     'sel_backdate' : [
174                         ['command'],
175                         function() {
176                             try {
177                                 JSAN.use('circ.util');
178                                 var circ_ids = []; var circ_row_map = {};
179                                 for (var i = 0; i < obj.selection_list.length; i++) {
180                                     var circ_id = obj.selection_list[i].circ_id; 
181                                     var copy_id = obj.selection_list[i].copy_id; 
182                                     if (!circ_id) {
183                                         var blob = obj.network.simple_request('FM_ACP_DETAILS',[ses(),copy_id]);
184                                         if (blob.circ) circ_id = blob.circ.id();
185                                     }
186                                     if (!circ_id) continue;
187                                     if (! circ_row_map[ circ_id ]) { circ_row_map[ circ_id ] = []; }
188                                     circ_row_map[ circ_id ].push( obj.selection_list[i].unique_row_counter );
189                                     circ_ids.push( circ_id );
190                                 }
191                                 var robj = circ.util.backdate_post_checkin( circ_ids );
192                                 if (robj.complete) {
193                                     var bad_circs = {};
194                                     for (var i = 0; i < robj.bad_circs.length; i++) {
195                                         bad_circs[ robj.bad_circs[i].circ_id ] = robj.bad_circs[i].result;
196                                     }
197                                     for (var circ_id in circ_row_map) {
198                                         var row_array = circ_row_map[circ_id];
199                                         for (var i = 0; i < row_array.length; i++) {
200                                             var row_data = obj.row_map[ row_array[i] ];
201                                             if (row_data.row.my.circ) {
202                                                 if (bad_circs[ circ_id ]) {
203                                                     row_data.row_properties = 'backdate_failed';
204                                                 } else {
205                                                     row_data.row_properties = 'backdate_succeeded';
206                                                     row_data.row.my.circ.checkin_time( robj.backdate );
207                                                 }
208                                             }
209                                             obj.list.refresh_row( row_data );
210                                         } 
211                                     }
212                                 }
213                             } catch(E) {
214                                 alert('Error in checkin.js, sel_backdate: ' + E);
215                             }
216                         }
217                     ],
218                     'sel_mark_items_damaged' : [
219                         ['command'],
220                         function() {
221                             var funcs = [];
222                             JSAN.use('cat.util'); JSAN.use('util.functional');
223                             cat.util.mark_item_damaged( util.functional.map_list( obj.selection_list, function(o) { return o.copy_id; } ) );
224                         }
225                     ],
226                     'sel_mark_missing_pieces' : [
227                         ['command'],
228                         function() {
229                             var funcs = [];
230                             JSAN.use('cat.util'); JSAN.use('util.functional');
231                             cat.util.mark_item_as_missing_pieces( util.functional.map_list( obj.selection_list, function(o) { return o.copy_id; } ) );
232                         }
233                     ],
234                     'sel_bucket' : [
235                         ['command'],
236                         function() {
237                             JSAN.use('cat.util');
238                             cat.util.add_copies_to_bucket(obj.selection_list);
239                         }
240                     ],
241                     'checkin_barcode_entry_textbox' : [
242                         ['keypress'],
243                         function(ev) {
244                             if (ev.keyCode && ev.keyCode == 13) {
245                                 obj.checkin();
246                             }
247                         }
248                     ],
249                     'checkin_effective_date_label' : [
250                         ['render'],
251                         function(e) {
252                             return function() {
253                                 obj.controller.view.checkin_effective_datepicker.value =
254                                     util.date.formatted_date(new Date(),'%F');
255                             };
256                         }
257                     ],
258                     'checkin_effective_datepicker' : [
259                         ['change'],
260                         function(ev) {
261                             if (ev.target.nodeName == 'datepicker') {
262                                 try {
263                                     if ( ev.target.dateValue > new Date() ) throw(document.getElementById('circStrings').getString('staff.circ.future_date'));
264                                     var x = document.getElementById('background');
265                                     if (x) {
266                                         if ( ev.target.value == util.date.formatted_date(new Date(),'%F') ) {
267                                             //addCSSClass(x,'checkin_screen_normal');
268                                             removeCSSClass(x,'checkin_screen_backdating');
269                                             removeCSSClass(document.getElementById('background'),'checkin_screen_do_not_alert_on_precat');
270                                             removeCSSClass(document.getElementById('background'),'checkin_screen_suppress_holds_and_transits');
271                                             removeCSSClass(document.getElementById('background'),'checkin_screen_amnesty_mode');
272                                             removeCSSClass(document.getElementById('background'),'checkin_screen_checkin_auto_print_slips');
273                                             document.getElementById('background-text').setAttribute('value',document.getElementById('circStrings').getString('staff.circ.process_item'));
274                                         } else {
275                                             addCSSClass(x,'checkin_screen_backdating');
276                                             //removeCSSClass(x,'checkin_screen_normal');
277                                             document.getElementById('background-text').setAttribute('value',document.getElementById('circStrings').getFormattedString('staff.circ.backdated_checkin', [ev.target.value]));
278                                         }
279                                     }
280                                 } catch(E) {
281                                     var x = document.getElementById('background');
282                                     if (x) {
283                                         //addCSSClass(x,'checkin_screen_normal');
284                                         removeCSSClass(x,'checkin_screen_backdating');
285                                         removeCSSClass(document.getElementById('background'),'checkin_screen_do_not_alert_on_precat');
286                                         removeCSSClass(document.getElementById('background'),'checkin_screen_suppress_holds_and_transits');
287                                         removeCSSClass(document.getElementById('background'),'checkin_screen_amnesty_mode');
288                                         removeCSSClass(document.getElementById('background'),'checkin_screen_checkin_auto_print_slips');
289                                         document.getElementById('background-text').setAttribute('value',document.getElementById('circStrings').getString('staff.circ.process_item'));
290                                     }
291                                     dump('checkin:effective_date: ' + E + '\n');
292                                     ev.target.disabled = true;
293                                     //alert(document.getElementById('circStrings').getFormattedString('staff.circ.backdate.exception', [E]));
294                                     ev.target.value = util.date.formatted_date(new Date(),'%F');
295                                     ev.target.disabled = false;
296                                     JSAN.use('util.sound'); var sound = new util.sound(); sound.bad();
297                                     
298                                 }
299                             }
300                         }
301                     ],
302                     'cmd_broken' : [
303                         ['command'],
304                         function() { alert(document.getElementById('circStrings').getString('staff.circ.unimplemented')); }
305                     ],
306                     'cmd_checkin_submit_barcode' : [
307                         ['command'],
308                         function() {
309                             obj.checkin();
310                         }
311                     ],
312                     'cmd_checkin_print' : [
313                         ['command'],
314                         function() {
315                             var p = { 
316                                 'printer_context' : 'receipt',
317                                 'template' : 'checkin'
318                             };
319                             obj.list.print(p);
320                         }
321                     ],
322                     'cmd_csv_to_clipboard' : [ ['command'], function() { 
323                         obj.list.dump_csv_to_clipboard(); 
324                         obj.controller.view.checkin_barcode_entry_textbox.focus();
325                     } ],
326                     'cmd_csv_to_printer' : [ ['command'], function() { 
327                         obj.list.dump_csv_to_printer(); 
328                         obj.controller.view.checkin_barcode_entry_textbox.focus();
329                     } ],
330                     'cmd_csv_to_file' : [ ['command'], function() { 
331                         obj.list.dump_csv_to_file( { 'defaultFileName' : 'checked_in.txt' } ); 
332                         obj.controller.view.checkin_barcode_entry_textbox.focus();
333                     } ],
334                     'cmd_do_not_alert_on_precat' : [ ['command'], function(ev) {
335                         dump('in cmd_do_not_alert_on_precat\n');
336                         var bg = document.getElementById('background');
337                         var cb = document.getElementById('do_not_alert_on_precat');
338                         var ind = document.getElementById('do_not_alert_on_precat_indicator');
339                         var cn = 'checkin_screen_do_not_alert_on_precat';
340                         if (cb.getAttribute('checked') == 'true') { addCSSClass(bg,cn); } else { removeCSSClass(bg,cn); }
341                         ind.hidden = cb.getAttribute('checked') != 'true'; 
342                         document.getElementById('checkin_barcode_entry_textbox').focus();
343                         return true;
344                     } ],
345                     'cmd_suppress_holds_and_transits' : [ ['command'], function(ev) {
346                         dump('in cmd_suppress_holds_and_transits\n');
347                         var bg = document.getElementById('background');
348                         var cb = document.getElementById('suppress_holds_and_transits');
349                         var ind = document.getElementById('suppress_holds_and_transits_indicator');
350                         var cn = 'checkin_screen_suppress_holds_and_transits';
351                         if (cb.getAttribute('checked') == 'true') { addCSSClass(bg,cn); } else { removeCSSClass(bg,cn); }
352                         ind.hidden = cb.getAttribute('checked') != 'true'; 
353                         document.getElementById('checkin_barcode_entry_textbox').focus();
354                         return true;
355                     } ],
356                     'cmd_amnesty_mode' : [ ['command'], function(ev) {
357                         dump('in cmd_amnesty_mode\n');
358                         var bg = document.getElementById('background');
359                         var cb = document.getElementById('amnesty_mode');
360                         var ind = document.getElementById('amnesty_mode_indicator');
361                         var cn = 'checkin_screen_amnesty_mode';
362                         if (cb.getAttribute('checked') == 'true') { addCSSClass(bg,cn); } else { removeCSSClass(bg,cn); }
363                         ind.hidden = cb.getAttribute('checked') != 'true'; 
364                         document.getElementById('checkin_barcode_entry_textbox').focus();
365                         return true;
366                     } ],
367                     'cmd_checkin_auto_print_slips' : [ ['command'], function(ev) {
368                         dump('in cmd_checkin_auto_print_slips\n');
369                         var bg = document.getElementById('background');
370                         var cb = document.getElementById('checkin_auto_print_slips');
371                         var ind = document.getElementById('checkin_auto_print_slips_indicator');
372                         var cn = 'checkin_screen_checkin_auto_print_slips';
373                         if (cb.getAttribute('checked') == 'true') { addCSSClass(bg,cn); } else { removeCSSClass(bg,cn); }
374                         ind.hidden = cb.getAttribute('checked') != 'true'; 
375                         document.getElementById('checkin_barcode_entry_textbox').focus();
376                         return true;
377                     } ]
378                 }
379             }
380         );
381         this.controller.render();
382         this.controller.view.checkin_barcode_entry_textbox.focus();
383
384     },
385
386     'gen_list_retrieve_row_func' : function() {
387         var obj = this;
388         return function(params) {
389             try {
390                 var row = params.row;
391                 if (typeof params.on_retrieve == 'function') params.on_retrieve(row);
392
393                 if (row.my.mbts && ( document.getElementById('no_change_label') || document.getElementById('fine_tally') ) ) {
394                     var bill = row.my.mbts;
395                     if (Number(bill.balance_owed()) == 0) { return; }
396                     if (document.getElementById('no_change_label')) {
397                         var m = document.getElementById('no_change_label').getAttribute('value');
398                         document.getElementById('no_change_label').setAttribute(
399                             'value', 
400                             m + document.getElementById('circStrings').getFormattedString('staff.circ.utils.billable.amount', [row.my.acp.barcode(), util.money.sanitize(bill.balance_owed())]) + '  '
401                         );
402                         document.getElementById('no_change_label').setAttribute('hidden','false');
403                     }
404                     if (document.getElementById('fine_tally')) {
405                         var amount = Number( document.getElementById('fine_tally').getAttribute('amount') ) + Number( bill.balance_owed() );
406                         document.getElementById('fine_tally').setAttribute('amount',amount);
407                         document.getElementById('fine_tally').setAttribute(
408                             'value',
409                             document.getElementById('circStrings').getFormattedString('staff.circ.utils.fine_tally_text', [ util.money.sanitize( amount ) ])
410                         );
411                         document.getElementById('fine_tally').setAttribute('hidden','false');
412                     }
413                 }
414
415             } catch(E) {
416                 alert('Error in checkin.js, list_retrieve_row(): ' + E);
417             }
418             return row;
419         };
420     },
421
422     'test_barcode' : function(bc) {
423         var obj = this;
424         var x = document.getElementById('strict_barcode');
425         if (x && x.checked != true) return true;
426         var good = util.barcode.check(bc);
427         if (good) {
428             return true;
429         } else {
430             if ( 1 == obj.error.yns_alert(
431                         document.getElementById('circStrings').getFormattedString('staff.circ.check_digit.bad', [bc]),
432                         document.getElementById('circStrings').getString('staff.circ.barcode.bad'),
433                         document.getElementById('circStrings').getString('staff.circ.cancel'),
434                         document.getElementById('circStrings').getString('staff.circ.barcode.accept'),
435                         null,
436                         document.getElementById('circStrings').getString('staff.circ.confirm'),
437                         '/xul/server/skin/media/images/bad_barcode.png'
438             ) ) {
439                 return true;
440             } else {
441                 return false;
442             }
443         }
444     },
445
446     'checkin' : function() {
447         var obj = this;
448         try {
449             var textbox = obj.controller.view.checkin_barcode_entry_textbox;
450             var async = false;
451             var async_checkbox = document.getElementById('async_checkin');
452             if (async_checkbox) { async = async_checkbox.getAttribute('checked') == 'true'; }
453             var barcode = textbox.value;
454             if (async) {
455                 textbox.value = ''; textbox.focus();
456             }
457             if (!barcode) return;
458             if (barcode) {
459                 if ( obj.test_barcode(barcode) ) { /* good */ } else { /* bad */ return; }
460             }
461             var backdate = obj.controller.view.checkin_effective_datepicker.value;
462             var auto_print = document.getElementById('checkin_auto_print_slips');
463             if (auto_print) auto_print = auto_print.getAttribute('checked') == 'true';
464             JSAN.use('circ.util');
465             var params = { 
466                 'barcode' : barcode,
467                 'disable_textbox' : function() { 
468                     if (!async) {
469                         textbox.disabled = true; 
470                         textbox.setAttribute('disabled', 'true'); 
471                     }
472                 },
473                 'enable_textbox' : function() { 
474                     textbox.disabled = false; 
475                     textbox.setAttribute('disabled', 'false'); 
476                 },
477                 'checkin_result' : function(checkin) {
478                     textbox.disabled = false;
479                     //obj.controller.view.cmd_checkin_submit_barcode.setAttribute('disabled', 'false'); 
480                     obj.checkin2(checkin,backdate);
481                 }
482             }; 
483             var suppress_holds_and_transits = document.getElementById('suppress_holds_and_transits');
484             if (suppress_holds_and_transits) suppress_holds_and_transits = suppress_holds_and_transits.getAttribute('checked') == 'true';
485             if (suppress_holds_and_transits) params.noop = 1;
486             var amnesty_mode = document.getElementById('amnesty_mode');
487             if (amnesty_mode) amnesty_mode = amnesty_mode.getAttribute('checked') == 'true';
488             if (amnesty_mode) params.void_overdues = 1;
489             circ.util.checkin_via_barcode(
490                 ses(), 
491                 params,
492                 backdate, 
493                 auto_print,
494                 async
495             );
496         } catch(E) {
497             obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.exception', [E]), E);
498             if (typeof obj.on_failure == 'function') {
499                 obj.on_failure(E);
500             }
501             if (typeof window.xulG == 'object' && typeof window.xulG.on_failure == 'function') {
502                 obj.error.sdump('D_CIRC', document.getElementById('circStrings').getString('staff.circ.util.checkin.exception.external') + '\n');
503                 window.xulG.on_failure(E);
504             } else {
505                 obj.error.sdump('D_CIRC', document.getElementById('circStrings').getString('staff.circ.util.checkin.exception.no_external') + '\n');
506             }
507         }
508
509     },
510
511     'checkin2' : function(checkin,backdate) {
512         var obj = this;
513         try {
514             if (!checkin) return obj.on_failure(); /* circ.util.checkin handles errors and returns null currently */
515             if (checkin.ilsevent == 7010 /* COPY_ALERT_MESSAGE */
516                 || checkin.ilsevent == 1203 /* COPY_BAD_STATUS */
517                 || checkin.ilsevent == -1 /* offline */
518                 || checkin.ilsevent == 1502 /* ASSET_COPY_NOT_FOUND */
519                 || checkin.ilsevent == 1203 /* COPY_BAD_STATUS */
520                 || checkin.ilsevent == 7009 /* CIRC_CLAIMS_RETURNED */ 
521                 || checkin.ilsevent == 7011 /* COPY_STATUS_LOST */ 
522                 || checkin.ilsevent == 7012 /* COPY_STATUS_MISSING */) return obj.on_failure();
523             var retrieve_id = js2JSON( { 'circ_id' : checkin.circ ? checkin.circ.id() : null , 'copy_id' : checkin.copy.id(), 'barcode' : checkin.copy.barcode(), 'doc_id' : (typeof checkin.record != 'undefined' ? ( typeof checkin.record.ilsevent == 'undefined' ? checkin.record.doc_id() : null ) : null ) } );
524             if (checkin.circ && checkin.circ.checkin_time() == 'now') checkin.circ.checkin_time(backdate);
525             if (document.getElementById('trim_list')) {
526                 var x = document.getElementById('trim_list');
527                 if (x.checked) { obj.list.trim_list = 20; } else { obj.list.trim_list = null; }
528             }
529             obj.list.append(
530                 {
531                     'retrieve_id' : retrieve_id,
532                     'row' : {
533                         'my' : {
534                             'circ' : checkin.circ,
535                             'mbts' : checkin.circ ? checkin.circ.billable_transaction().summary() : null,
536                             'mvr' : checkin.record,
537                             'acp' : checkin.copy,
538                             'au' : checkin.patron,
539                             'status' : checkin.status,
540                             'route_to' : checkin.route_to,
541                             'message' : checkin.message
542                         }
543                     },
544                     'to_top' : true,
545                     'on_append' : function(rparams) { obj.row_map[ rparams.unique_row_counter ] = rparams; },
546                     'on_remove' : function(unique_row_counter) { delete obj.row_map[ unique_row_counter ]; }
547                 }
548             );
549             obj.list.node.view.selection.select(0);
550
551             JSAN.use('util.sound'); var sound = new util.sound(); sound.circ_good();
552
553             if (typeof obj.on_checkin == 'function') {
554                 obj.on_checkin(checkin);
555             }
556             if (typeof window.xulG == 'object' && typeof window.xulG.on_checkin == 'function') {
557                 obj.error.sdump('D_CIRC', document.getElementById('circStrings').getString('staff.circ.checkin.exception.external') + '\n');
558                 window.xulG.on_checkin(checkin);
559             } else {
560                 obj.error.sdump('D_CIRC', document.getElementById('circStrings').getString('staff.circ.checkin.exception.no_external') + '\n');
561             }
562
563             return true;
564
565         } catch(E) {
566             obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin2.exception', [E]));
567             if (typeof obj.on_failure == 'function') {
568                 obj.on_failure(E);
569             }
570             if (typeof window.xulG == 'object' && typeof window.xulG.on_failure == 'function') {
571                 obj.error.sdump('D_CIRC', document.getElementById('circStrings').getString('staff.circ.checkin2.exception.external') + '\n');
572                 window.xulG.on_failure(E);
573             } else {
574                 obj.error.sdump('D_CIRC', document.getElementById('circStrings').getString('staff.circ.checkin2.exception.no_external') + '\n');
575             }
576         }
577
578     },
579
580     'on_checkin' : function() {
581         var async = false;
582         var async_checkbox = document.getElementById('async_checkin');
583         if (async_checkbox) { async = async_checkbox.getAttribute('checked') == 'true'; }
584         if (!async) {
585             this.controller.view.checkin_barcode_entry_textbox.disabled = false;
586             this.controller.view.checkin_barcode_entry_textbox.select();
587             this.controller.view.checkin_barcode_entry_textbox.value = '';
588             this.controller.view.checkin_barcode_entry_textbox.focus();
589         }
590     },
591
592     'on_failure' : function() {
593         var async = false;
594         var async_checkbox = document.getElementById('async_checkin');
595         if (async_checkbox) { async = async_checkbox.getAttribute('checked') == 'true'; }
596         if (!async) {
597             this.controller.view.checkin_barcode_entry_textbox.disabled = false;
598             this.controller.view.checkin_barcode_entry_textbox.select();
599             this.controller.view.checkin_barcode_entry_textbox.focus();
600         }
601     },
602     
603     'spawn_copy_editor' : function() {
604
605         var obj = this;
606
607         JSAN.use('util.functional');
608
609         var list = obj.selection_list;
610
611         list = util.functional.map_list(
612             list,
613             function (o) {
614                 return o.copy_id;
615             }
616         );
617
618         JSAN.use('cat.util'); cat.util.spawn_copy_editor( { 'copy_ids' : list, 'edit' : 1 } );
619
620     }
621
622 }
623
624 dump('exiting circ.checkin.js\n');