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