]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/xul/staff_client/server/circ/checkin.js
Patch from Lebbeous Fogle-Weekley to change the behavior of the "Show Item Details...
[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                             circ.util.item_details_new(
165                                 util.functional.map_list(
166                                     obj.selection_list,
167                                     function(o) { return o.barcode; }
168                                 )
169                             );
170                         }
171                     ],
172                     'sel_backdate' : [
173                         ['command'],
174                         function() {
175                             try {
176                                 JSAN.use('circ.util');
177                                 var circ_ids = []; var circ_row_map = {};
178                                 for (var i = 0; i < obj.selection_list.length; i++) {
179                                     var circ_id = obj.selection_list[i].circ_id; 
180                                     var copy_id = obj.selection_list[i].copy_id; 
181                                     if (!circ_id) {
182                                         var blob = obj.network.simple_request('FM_ACP_DETAILS',[ses(),copy_id]);
183                                         if (blob.circ) circ_id = blob.circ.id();
184                                     }
185                                     if (!circ_id) continue;
186                                     if (! circ_row_map[ circ_id ]) { circ_row_map[ circ_id ] = []; }
187                                     circ_row_map[ circ_id ].push( obj.selection_list[i].unique_row_counter );
188                                     circ_ids.push( circ_id );
189                                 }
190                                 var robj = circ.util.backdate_post_checkin( circ_ids );
191                                 if (robj.complete) {
192                                     var bad_circs = {};
193                                     for (var i = 0; i < robj.bad_circs.length; i++) {
194                                         bad_circs[ robj.bad_circs[i].circ_id ] = robj.bad_circs[i].result;
195                                     }
196                                     for (var circ_id in circ_row_map) {
197                                         var row_array = circ_row_map[circ_id];
198                                         for (var i = 0; i < row_array.length; i++) {
199                                             var row_data = obj.row_map[ row_array[i] ];
200                                             if (row_data.row.my.circ) {
201                                                 if (bad_circs[ circ_id ]) {
202                                                     row_data.row_properties = 'backdate_failed';
203                                                 } else {
204                                                     row_data.row_properties = 'backdate_succeeded';
205                                                     row_data.row.my.circ.checkin_time( robj.backdate );
206                                                 }
207                                             }
208                                             obj.list.refresh_row( row_data );
209                                         } 
210                                     }
211                                 }
212                             } catch(E) {
213                                 alert('Error in checkin.js, sel_backdate: ' + E);
214                             }
215                         }
216                     ],
217                     'sel_mark_items_damaged' : [
218                         ['command'],
219                         function() {
220                             var funcs = [];
221                             JSAN.use('cat.util'); JSAN.use('util.functional');
222                             cat.util.mark_item_damaged( util.functional.map_list( obj.selection_list, function(o) { return o.copy_id; } ) );
223                         }
224                     ],
225                     'sel_bucket' : [
226                         ['command'],
227                         function() {
228                             JSAN.use('cat.util');
229                             cat.util.add_copies_to_bucket(obj.selection_list);
230                         }
231                     ],
232                     'checkin_barcode_entry_textbox' : [
233                         ['keypress'],
234                         function(ev) {
235                             if (ev.keyCode && ev.keyCode == 13) {
236                                 obj.checkin();
237                             }
238                         }
239                     ],
240                     'checkin_effective_date_label' : [
241                         ['render'],
242                         function(e) {
243                             return function() {
244                                 obj.controller.view.checkin_effective_datepicker.value =
245                                     util.date.formatted_date(new Date(),'%F');
246                             };
247                         }
248                     ],
249                     'checkin_effective_datepicker' : [
250                         ['change'],
251                         function(ev) {
252                             if (ev.target.nodeName == 'datepicker') {
253                                 try {
254                                     if ( ev.target.dateValue > new Date() ) throw(document.getElementById('circStrings').getString('staff.circ.future_date'));
255                                     var x = document.getElementById('background');
256                                     if (x) {
257                                         if ( ev.target.value == util.date.formatted_date(new Date(),'%F') ) {
258                                             //addCSSClass(x,'checkin_screen_normal');
259                                             removeCSSClass(x,'checkin_screen_backdating');
260                                             removeCSSClass(document.getElementById('background'),'checkin_screen_do_not_alert_on_precat');
261                                             removeCSSClass(document.getElementById('background'),'checkin_screen_suppress_holds_and_transits');
262                                             removeCSSClass(document.getElementById('background'),'checkin_screen_amnesty_mode');
263                                             removeCSSClass(document.getElementById('background'),'checkin_screen_checkin_auto_print_slips');
264                                             document.getElementById('background-text').setAttribute('value',document.getElementById('circStrings').getString('staff.circ.process_item'));
265                                         } else {
266                                             addCSSClass(x,'checkin_screen_backdating');
267                                             //removeCSSClass(x,'checkin_screen_normal');
268                                             document.getElementById('background-text').setAttribute('value',document.getElementById('circStrings').getFormattedString('staff.circ.backdated_checkin', [ev.target.value]));
269                                         }
270                                     }
271                                 } catch(E) {
272                                     var x = document.getElementById('background');
273                                     if (x) {
274                                         //addCSSClass(x,'checkin_screen_normal');
275                                         removeCSSClass(x,'checkin_screen_backdating');
276                                         removeCSSClass(document.getElementById('background'),'checkin_screen_do_not_alert_on_precat');
277                                         removeCSSClass(document.getElementById('background'),'checkin_screen_suppress_holds_and_transits');
278                                         removeCSSClass(document.getElementById('background'),'checkin_screen_amnesty_mode');
279                                         removeCSSClass(document.getElementById('background'),'checkin_screen_checkin_auto_print_slips');
280                                         document.getElementById('background-text').setAttribute('value',document.getElementById('circStrings').getString('staff.circ.process_item'));
281                                     }
282                                     dump('checkin:effective_date: ' + E + '\n');
283                                     ev.target.disabled = true;
284                                     //alert(document.getElementById('circStrings').getFormattedString('staff.circ.backdate.exception', [E]));
285                                     ev.target.value = util.date.formatted_date(new Date(),'%F');
286                                     ev.target.disabled = false;
287                                     JSAN.use('util.sound'); var sound = new util.sound(); sound.bad();
288                                     
289                                 }
290                             }
291                         }
292                     ],
293                     'cmd_broken' : [
294                         ['command'],
295                         function() { alert(document.getElementById('circStrings').getString('staff.circ.unimplemented')); }
296                     ],
297                     'cmd_checkin_submit_barcode' : [
298                         ['command'],
299                         function() {
300                             obj.checkin();
301                         }
302                     ],
303                     'cmd_checkin_print' : [
304                         ['command'],
305                         function() {
306                             var p = { 
307                                 'template' : 'checkin'
308                             };
309                             obj.list.print(p);
310                         }
311                     ],
312                     'cmd_csv_to_clipboard' : [ ['command'], function() { 
313                         obj.list.dump_csv_to_clipboard(); 
314                         obj.controller.view.checkin_barcode_entry_textbox.focus();
315                     } ],
316                     'cmd_csv_to_printer' : [ ['command'], function() { 
317                         obj.list.dump_csv_to_printer(); 
318                         obj.controller.view.checkin_barcode_entry_textbox.focus();
319                     } ],
320                     'cmd_csv_to_file' : [ ['command'], function() { 
321                         obj.list.dump_csv_to_file( { 'defaultFileName' : 'checked_in.txt' } ); 
322                         obj.controller.view.checkin_barcode_entry_textbox.focus();
323                     } ],
324                     'cmd_do_not_alert_on_precat' : [ ['command'], function(ev) {
325                         dump('in cmd_do_not_alert_on_precat\n');
326                         var bg = document.getElementById('background');
327                         var cb = document.getElementById('do_not_alert_on_precat');
328                         var ind = document.getElementById('do_not_alert_on_precat_indicator');
329                         var cn = 'checkin_screen_do_not_alert_on_precat';
330                         if (cb.getAttribute('checked') == 'true') { addCSSClass(bg,cn); } else { removeCSSClass(bg,cn); }
331                         ind.hidden = cb.getAttribute('checked') != 'true'; 
332                         document.getElementById('checkin_barcode_entry_textbox').focus();
333                         return true;
334                     } ],
335                     'cmd_suppress_holds_and_transits' : [ ['command'], function(ev) {
336                         dump('in cmd_suppress_holds_and_transits\n');
337                         var bg = document.getElementById('background');
338                         var cb = document.getElementById('suppress_holds_and_transits');
339                         var ind = document.getElementById('suppress_holds_and_transits_indicator');
340                         var cn = 'checkin_screen_suppress_holds_and_transits';
341                         if (cb.getAttribute('checked') == 'true') { addCSSClass(bg,cn); } else { removeCSSClass(bg,cn); }
342                         ind.hidden = cb.getAttribute('checked') != 'true'; 
343                         document.getElementById('checkin_barcode_entry_textbox').focus();
344                         return true;
345                     } ],
346                     'cmd_amnesty_mode' : [ ['command'], function(ev) {
347                         dump('in cmd_amnesty_mode\n');
348                         var bg = document.getElementById('background');
349                         var cb = document.getElementById('amnesty_mode');
350                         var ind = document.getElementById('amnesty_mode_indicator');
351                         var cn = 'checkin_screen_amnesty_mode';
352                         if (cb.getAttribute('checked') == 'true') { addCSSClass(bg,cn); } else { removeCSSClass(bg,cn); }
353                         ind.hidden = cb.getAttribute('checked') != 'true'; 
354                         document.getElementById('checkin_barcode_entry_textbox').focus();
355                         return true;
356                     } ],
357                     'cmd_checkin_auto_print_slips' : [ ['command'], function(ev) {
358                         dump('in cmd_checkin_auto_print_slips\n');
359                         var bg = document.getElementById('background');
360                         var cb = document.getElementById('checkin_auto_print_slips');
361                         var ind = document.getElementById('checkin_auto_print_slips_indicator');
362                         var cn = 'checkin_screen_checkin_auto_print_slips';
363                         if (cb.getAttribute('checked') == 'true') { addCSSClass(bg,cn); } else { removeCSSClass(bg,cn); }
364                         ind.hidden = cb.getAttribute('checked') != 'true'; 
365                         document.getElementById('checkin_barcode_entry_textbox').focus();
366                         return true;
367                     } ]
368                 }
369             }
370         );
371         this.controller.render();
372         this.controller.view.checkin_barcode_entry_textbox.focus();
373
374     },
375
376     'gen_list_retrieve_row_func' : function() {
377         var obj = this;
378         return function(params) {
379             try {
380                 var row = params.row;
381                 if (typeof params.on_retrieve == 'function') params.on_retrieve(row);
382
383                 if (row.my.mbts && ( document.getElementById('no_change_label') || document.getElementById('fine_tally') ) ) {
384                     var bill = row.my.mbts;
385                     if (Number(bill.balance_owed()) == 0) { return; }
386                     if (document.getElementById('no_change_label')) {
387                         var m = document.getElementById('no_change_label').getAttribute('value');
388                         document.getElementById('no_change_label').setAttribute(
389                             'value', 
390                             m + document.getElementById('circStrings').getFormattedString('staff.circ.utils.billable.amount', [row.my.acp.barcode(), util.money.sanitize(bill.balance_owed())]) + '  '
391                         );
392                         document.getElementById('no_change_label').setAttribute('hidden','false');
393                     }
394                     if (document.getElementById('fine_tally')) {
395                         var amount = Number( document.getElementById('fine_tally').getAttribute('amount') ) + Number( bill.balance_owed() );
396                         document.getElementById('fine_tally').setAttribute('amount',amount);
397                         document.getElementById('fine_tally').setAttribute(
398                             'value',
399                             document.getElementById('circStrings').getFormattedString('staff.circ.utils.fine_tally_text', [ util.money.sanitize( amount ) ])
400                         );
401                         document.getElementById('fine_tally').setAttribute('hidden','false');
402                     }
403                 }
404
405             } catch(E) {
406                 alert('Error in checkin.js, list_retrieve_row(): ' + E);
407             }
408             return row;
409         };
410     },
411
412     'test_barcode' : function(bc) {
413         var obj = this;
414         var x = document.getElementById('strict_barcode');
415         if (x && x.checked != true) return true;
416         var good = util.barcode.check(bc);
417         if (good) {
418             return true;
419         } else {
420             if ( 1 == obj.error.yns_alert(
421                         document.getElementById('circStrings').getFormattedString('staff.circ.check_digit.bad', [bc]),
422                         document.getElementById('circStrings').getString('staff.circ.barcode.bad'),
423                         document.getElementById('circStrings').getString('staff.circ.cancel'),
424                         document.getElementById('circStrings').getString('staff.circ.barcode.accept'),
425                         null,
426                         document.getElementById('circStrings').getString('staff.circ.confirm'),
427                         '/xul/server/skin/media/images/bad_barcode.png'
428             ) ) {
429                 return true;
430             } else {
431                 return false;
432             }
433         }
434     },
435
436     'checkin' : function() {
437         var obj = this;
438         try {
439             var barcode = obj.controller.view.checkin_barcode_entry_textbox.value;
440             if (!barcode) return;
441             if (barcode) {
442                 if ( obj.test_barcode(barcode) ) { /* good */ } else { /* bad */ return; }
443             }
444             var backdate = obj.controller.view.checkin_effective_datepicker.value;
445             var auto_print = document.getElementById('checkin_auto_print_slips');
446             if (auto_print) auto_print = auto_print.getAttribute('checked') == 'true';
447             JSAN.use('circ.util');
448             var params = { 
449                 'barcode' : barcode,
450                 'disable_textbox' : function() { 
451                     obj.controller.view.checkin_barcode_entry_textbox.disabled = true; 
452                     obj.controller.view.cmd_checkin_submit_barcode.setAttribute('disabled', 'true'); 
453                 },
454                 'enable_textbox' : function() { 
455                     obj.controller.view.checkin_barcode_entry_textbox.disabled = false; 
456                     obj.controller.view.cmd_checkin_submit_barcode.setAttribute('disabled', 'false'); 
457                 },
458                 'checkin_result' : function(checkin) {
459                     obj.controller.view.checkin_barcode_entry_textbox.disabled = false;
460                     obj.controller.view.cmd_checkin_submit_barcode.setAttribute('disabled', 'false'); 
461                     obj.checkin2(checkin,backdate);
462                 }
463             }; 
464             var suppress_holds_and_transits = document.getElementById('suppress_holds_and_transits');
465             if (suppress_holds_and_transits) suppress_holds_and_transits = suppress_holds_and_transits.getAttribute('checked') == 'true';
466             if (suppress_holds_and_transits) params.noop = 1;
467             var amnesty_mode = document.getElementById('amnesty_mode');
468             if (amnesty_mode) amnesty_mode = amnesty_mode.getAttribute('checked') == 'true';
469             if (amnesty_mode) params.void_overdues = 1;
470             circ.util.checkin_via_barcode(
471                 ses(), 
472                 params,
473                 backdate, 
474                 auto_print
475             );
476         } catch(E) {
477             obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.exception', [E]), E);
478             if (typeof obj.on_failure == 'function') {
479                 obj.on_failure(E);
480             }
481             if (typeof window.xulG == 'object' && typeof window.xulG.on_failure == 'function') {
482                 obj.error.sdump('D_CIRC', document.getElementById('circStrings').getString('staff.circ.util.checkin.exception.external') + '\n');
483                 window.xulG.on_failure(E);
484             } else {
485                 obj.error.sdump('D_CIRC', document.getElementById('circStrings').getString('staff.circ.util.checkin.exception.no_external') + '\n');
486             }
487         }
488
489     },
490
491     'checkin2' : function(checkin,backdate) {
492         var obj = this;
493         try {
494             if (!checkin) return obj.on_failure(); /* circ.util.checkin handles errors and returns null currently */
495             if (checkin.ilsevent == 7010 /* COPY_ALERT_MESSAGE */
496                 || checkin.ilsevent == 1203 /* COPY_BAD_STATUS */
497                 || checkin.ilsevent == -1 /* offline */
498                 || checkin.ilsevent == 1502 /* ASSET_COPY_NOT_FOUND */
499                 || checkin.ilsevent == 1203 /* COPY_BAD_STATUS */
500                 || checkin.ilsevent == 7009 /* CIRC_CLAIMS_RETURNED */ 
501                 || checkin.ilsevent == 7011 /* COPY_STATUS_LOST */ 
502                 || checkin.ilsevent == 7012 /* COPY_STATUS_MISSING */) return obj.on_failure();
503             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 ) } );
504             if (checkin.circ && checkin.circ.checkin_time() == 'now') checkin.circ.checkin_time(backdate);
505             if (document.getElementById('trim_list')) {
506                 var x = document.getElementById('trim_list');
507                 if (x.checked) { obj.list.trim_list = 20; } else { obj.list.trim_list = null; }
508             }
509             obj.list.append(
510                 {
511                     'retrieve_id' : retrieve_id,
512                     'row' : {
513                         'my' : {
514                             'circ' : checkin.circ,
515                             'mbts' : checkin.circ ? checkin.circ.billable_transaction().summary() : null,
516                             'mvr' : checkin.record,
517                             'acp' : checkin.copy,
518                             'au' : checkin.patron,
519                             'status' : checkin.status,
520                             'route_to' : checkin.route_to,
521                             'message' : checkin.message
522                         }
523                     },
524                     'to_top' : true,
525                     'on_append' : function(rparams) { obj.row_map[ rparams.unique_row_counter ] = rparams; },
526                     'on_remove' : function(unique_row_counter) { delete obj.row_map[ unique_row_counter ]; }
527                 }
528             );
529             obj.list.node.view.selection.select(0);
530
531             JSAN.use('util.sound'); var sound = new util.sound(); sound.circ_good();
532
533             if (typeof obj.on_checkin == 'function') {
534                 obj.on_checkin(checkin);
535             }
536             if (typeof window.xulG == 'object' && typeof window.xulG.on_checkin == 'function') {
537                 obj.error.sdump('D_CIRC', document.getElementById('circStrings').getString('staff.circ.checkin.exception.external') + '\n');
538                 window.xulG.on_checkin(checkin);
539             } else {
540                 obj.error.sdump('D_CIRC', document.getElementById('circStrings').getString('staff.circ.checkin.exception.no_external') + '\n');
541             }
542
543             return true;
544
545         } catch(E) {
546             obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin2.exception', [E]));
547             if (typeof obj.on_failure == 'function') {
548                 obj.on_failure(E);
549             }
550             if (typeof window.xulG == 'object' && typeof window.xulG.on_failure == 'function') {
551                 obj.error.sdump('D_CIRC', document.getElementById('circStrings').getString('staff.circ.checkin2.exception.external') + '\n');
552                 window.xulG.on_failure(E);
553             } else {
554                 obj.error.sdump('D_CIRC', document.getElementById('circStrings').getString('staff.circ.checkin2.exception.no_external') + '\n');
555             }
556         }
557
558     },
559
560     'on_checkin' : function() {
561         this.controller.view.checkin_barcode_entry_textbox.disabled = false;
562         this.controller.view.checkin_barcode_entry_textbox.select();
563         this.controller.view.checkin_barcode_entry_textbox.value = '';
564         this.controller.view.checkin_barcode_entry_textbox.focus();
565     },
566
567     'on_failure' : function() {
568         this.controller.view.checkin_barcode_entry_textbox.disabled = false;
569         this.controller.view.checkin_barcode_entry_textbox.select();
570         this.controller.view.checkin_barcode_entry_textbox.focus();
571     },
572     
573     'spawn_copy_editor' : function() {
574
575         var obj = this;
576
577         JSAN.use('util.functional');
578
579         var list = obj.selection_list;
580
581         list = util.functional.map_list(
582             list,
583             function (o) {
584                 return o.copy_id;
585             }
586         );
587
588         JSAN.use('cat.util'); cat.util.spawn_copy_editor( { 'copy_ids' : list, 'edit' : 1 } );
589
590     }
591
592 }
593
594 dump('exiting circ.checkin.js\n');