]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/xul/staff_client/server/circ/util.js
Merge branch 'master' of git.evergreen-ils.org:Evergreen into template-toolkit-opac
[Evergreen.git] / Open-ILS / xul / staff_client / server / circ / util.js
1 dump('entering circ/util.js\n');
2 // vim:noet:sw=4:ts=4:
3
4 if (typeof circ == 'undefined') { var circ = {}; }
5 circ.util = {};
6
7 circ.util.EXPORT_OK    = [
8     'offline_checkout_columns', 'offline_checkin_columns', 'offline_renew_columns', 'offline_inhouse_use_columns',
9     'columns', 'hold_columns', 'checkin_via_barcode', 'std_map_row_to_columns',
10     'show_last_few_circs', 'abort_transits', 'transit_columns', 'work_log_columns', 'renew_via_barcode', 'backdate_post_checkin', 'batch_hold_update'
11 ];
12 circ.util.EXPORT_TAGS    = { ':all' : circ.util.EXPORT_OK };
13
14 circ.util.abort_transits = function(selection_list) {
15     var obj = {};
16     JSAN.use('util.error'); obj.error = new util.error();
17     JSAN.use('util.network'); obj.network = new util.network();
18     JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
19     JSAN.use('util.functional');
20     var copies = util.functional.map_list( selection_list, function(o){return o.copy_id;}).join(', ');
21     var msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.abort_transits.confirm', [copies]);
22     var r = obj.error.yns_alert(
23         msg,
24         document.getElementById('circStrings').getString('staff.circ.utils.abort_transits.title'),
25         document.getElementById('circStrings').getString('staff.circ.utils.yes'),
26         document.getElementById('circStrings').getString('staff.circ.utils.no'),
27         null,
28         document.getElementById('circStrings').getString('staff.circ.confirm')
29     );
30     if (r == 0) {
31         try {
32             for (var i = 0; i < selection_list.length; i++) {
33                 var copy_id = selection_list[i].copy_id;
34                 var robj = obj.network.simple_request('FM_ATC_VOID',[ ses(), { 'copyid' : copy_id } ]);
35                 if (typeof robj.ilsevent != 'undefined') {
36                     switch(Number(robj.ilsevent)) {
37                         case 1225 /* TRANSIT_ABORT_NOT_ALLOWED */ :
38                             alert(document.getElementById('circString').getFormattedString('staff.circ.utils.abort_transits.not_allowed', [copy_id]) + '\n' + robj.desc);
39                         break;
40                         case 1504 /* ACTION_TRANSIT_COPY_NOT_FOUND */ :
41                             alert(document.getElementById('circString').getString('staff.circ.utils.abort_transits.not_found'));
42                         break;
43                         case 5000 /* PERM_FAILURE */ :
44                         break;
45                         default:
46                             throw(robj);
47                         break;
48                     }
49                 }
50             }
51         } catch(E) {
52             obj.error.standard_unexpected_error_alert(document.getElementById('circString').getString('staff.circ.utils.abort_transits.unexpected_error'),E);
53         }
54     }
55 };
56
57 circ.util.show_copy_details = function(copy_id) {
58     var obj = {};
59     JSAN.use('util.error'); obj.error = new util.error();
60     JSAN.use('util.window'); obj.win = new util.window();
61     JSAN.use('util.network'); obj.network = new util.network();
62     JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
63
64     if (typeof copy_id == 'object' && copy_id != null) copy_id = copy_id.id();
65
66     try {
67         var url = xulG.url_prefix( urls.XUL_COPY_DETAILS ); // + '?copy_id=' + copy_id;
68         var my_xulG = obj.win.open( url, 'show_copy_details', 'chrome,resizable,modal', { 'copy_id' : copy_id, 'new_tab' : xulG.new_tab, 'url_prefix' : xulG.url_prefix } );
69
70         if (typeof my_xulG.retrieve_these_patrons == 'undefined') return;
71         var patrons = my_xulG.retrieve_these_patrons;
72         for (var j = 0; j < patrons.length; j++) {
73             if (typeof window.xulG == 'object' && typeof window.xulG.new_tab == 'function') {
74                 try {
75                     window.xulG.new_patron_tab( {}, { 'id' : patrons[j] } );
76                 } catch(E) {
77                     obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.utils.retrieve_patron.failure'), E);
78                 }
79             }
80         }
81
82     } catch(E) {
83         obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.utils.retrieve_copy.failure'),E);
84     }
85 };
86
87 circ.util.item_details_new = function(barcodes) {
88     try {
89         var content_params = {
90             'from_item_details_new': true,
91             'barcodes': barcodes
92         };
93         xulG.new_tab(urls.XUL_COPY_STATUS, {}, content_params);
94     } catch(E) {
95         JSAN.use('util.error');
96         (new util.error()).standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.utils.retrieve_copy.failure'),E);
97     }
98 };
99
100 circ.util.backdate_post_checkin = function(circ_ids) {
101     var obj = {};
102     JSAN.use('util.error'); obj.error = new util.error();
103     JSAN.use('util.window'); obj.win = new util.window();
104     JSAN.use('util.network'); obj.network = new util.network();
105     JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
106     JSAN.use('util.sound'); obj.sound = new util.sound();
107
108     var circStrings = document.getElementById('circStrings');
109
110     dojo.forEach(
111         circ_ids,
112         function(element,idx,list) {
113             if (typeof element == 'object' && element != null) list[idx] = element.id();
114         }
115     );
116
117     try {
118         var url = xulG.url_prefix( urls.XUL_BACKDATE );
119         var my_xulG = obj.win.open( url, 'backdate_post_checkin', 'chrome,resizable,modal', { 'circ_ids' : circ_ids } );
120
121         return my_xulG;
122
123     } catch(E) {
124         obj.error.standard_unexpected_error_alert(circStrings.getString('staff.circ.utils.retrieve_copy.failure'),E);
125     }
126 };
127
128
129 circ.util.show_last_few_circs = function(selection_list) {
130     var obj = {};
131     JSAN.use('util.error'); obj.error = new util.error();
132     JSAN.use('util.window'); obj.win = new util.window();
133     JSAN.use('util.network'); obj.network = new util.network();
134     JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
135
136     for (var i = 0; i < selection_list.length; i++) {
137         try {
138             if (typeof selection_list[i].copy_id == 'undefined' || selection_list[i].copy_id == null) continue;
139             var url = xulG.url_prefix( urls.XUL_CIRC_SUMMARY ); // + '?copy_id=' + selection_list[i].copy_id + '&count=' + count;
140             var my_xulG = obj.win.open( url, 'show_last_few_circs', 'chrome,resizable,modal', { 'copy_id' : selection_list[i].copy_id, 'new_tab' : xulG.new_tab, 'url_prefix': xulG.url_prefix } );
141
142             if (typeof my_xulG.retrieve_these_patrons == 'undefined') continue;
143             var patrons = my_xulG.retrieve_these_patrons;
144             for (var j = 0; j < patrons.length; j++) {
145                 if (typeof window.xulG == 'object' && typeof window.xulG.new_tab == 'function') {
146                     try {
147                         window.xulG.new_patron_tab( {}, { 'id' : patrons[j] } );
148                     } catch(E) {
149                         obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.utils.retrieve_patron.failure') ,E);
150                     }
151                 }
152             }
153
154         } catch(E) {
155             obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.utils.retrieve_circs.failure') ,E);
156         }
157     }
158 };
159
160 circ.util.offline_checkout_columns = function(modify,params) {
161
162     var c = [
163         {
164             'id' : 'timestamp',
165             'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.timestamp'),
166             'flex' : 1,
167             'primary' : false,
168             'hidden' : true,
169             'editable' : false, 'render' : function(my) { return my.timestamp; }
170         },
171         {
172             'id' : 'checkout_time',
173             'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.checkout_time'),
174             'flex' : 1,
175             'primary' : false,
176             'hidden' : true,
177             'editable' : false, 'render' : function(my) { return my.checkout_time; }
178         },
179         {
180             'id' : 'type',
181             'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.type'),
182             'flex' : 1,
183             'primary' : false,
184             'hidden' : true,
185             'editable' : false, 'render' : function(my) { return my.type; }
186         },
187         {
188             'id' : 'noncat',
189             'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.noncat'),
190             'flex' : 1,
191             'primary' : false,
192             'hidden' : true,
193             'editable' : false, 'render' : function(my) { return my.noncat; }
194         },
195         {
196             'id' : 'noncat_type',
197             'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.noncat_type'),
198             'flex' : 1,
199             'primary' : false,
200             'hidden' : true,
201             'editable' : false, 'render' : function(my) { return my.noncat_type; }
202         },
203         {
204             'id' : 'noncat_count',
205             'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.count'),
206             'sort_type' : 'number',
207             'flex' : 1,
208             'primary' : false,
209             'hidden' : false,
210             'editable' : false, 'render' : function(my) { return my.noncat_count; }
211         },
212         {
213             'id' : 'patron_barcode',
214             'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.patron_barcode'),
215             'flex' : 1,
216             'primary' : false,
217             'hidden' : true,
218             'editable' : false, 'render' : function(my) { return my.patron_barcode; }
219         },
220         {
221             'id' : 'barcode',
222             'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.item_barcode'),
223             'flex' : 2,
224             'primary' : true,
225             'hidden' : false,
226             'editable' : false, 'render' : function(my) { return my.barcode; }
227         },
228         {
229             'id' : 'due_date',
230             'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.due_date'),
231             'flex' : 1,
232             'primary' : false,
233             'hidden' : false,
234             'editable' : false, 'render' : function(my) { return my.due_date; }
235         },
236         {
237             'id' : 'due_time',
238             'label' : document.getElementById('commonStrings').getString('staff.circ_label_due_time'),
239             'flex' : 1,
240             'primary' : false,
241             'hidden' : false,
242             'editable' : false, 'render' : function(my) { return my.due_time; }
243         }
244
245     ];
246     if (modify) for (var i = 0; i < c.length; i++) {
247         if (modify[ c[i].id ]) {
248             for (var j in modify[ c[i].id ]) {
249                 c[i][j] = modify[ c[i].id ][j];
250             }
251         }
252     }
253     if (params) {
254         if (params.just_these) {
255             JSAN.use('util.functional');
256             var new_c = [];
257             for (var i = 0; i < params.just_these.length; i++) {
258                 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
259                 new_c.push( function(y){ return y; }( x ) );
260             }
261             c = new_c;
262         }
263         if (params.except_these) {
264             JSAN.use('util.functional');
265             var new_c = [];
266             for (var i = 0; i < c.length; i++) {
267                 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
268                 if (!x) new_c.push(c[i]);
269             }
270             c = new_c;
271         }
272
273     }
274     return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
275 };
276
277 circ.util.offline_checkin_columns = function(modify,params) {
278
279     var c = [
280         {
281             'id' : 'timestamp',
282             'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.timestamp'),
283             'flex' : 1,
284             'primary' : false,
285             'hidden' : true,
286             'editable' : false, 'render' : function(my) { return my.timestamp; }
287         },
288         {
289             'id' : 'backdate',
290             'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.backdate'),
291             'flex' : 1,
292             'primary' : false,
293             'hidden' : true,
294             'editable' : false, 'render' : function(my) { return my.backdate; }
295         },
296         {
297             'id' : 'type',
298             'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.type'),
299             'flex' : 1,
300             'primary' : false,
301             'hidden' : true,
302             'editable' : false, 'render' : function(my) { return my.type; }
303         },
304         {
305             'id' : 'barcode',
306             'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.item_barcode'),
307             'flex' : 2,
308             'primary' : true,
309             'hidden' : false,
310             'editable' : false, 'render' : function(my) { return my.barcode; }
311         }
312     ];
313     if (modify) for (var i = 0; i < c.length; i++) {
314         if (modify[ c[i].id ]) {
315             for (var j in modify[ c[i].id ]) {
316                 c[i][j] = modify[ c[i].id ][j];
317             }
318         }
319     }
320     if (params) {
321         if (params.just_these) {
322             JSAN.use('util.functional');
323             var new_c = [];
324             for (var i = 0; i < params.just_these.length; i++) {
325                 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
326                 new_c.push( function(y){ return y; }( x ) );
327             }
328             c = new_c;
329         }
330         if (params.except_these) {
331             JSAN.use('util.functional');
332             var new_c = [];
333             for (var i = 0; i < c.length; i++) {
334                 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
335                 if (!x) new_c.push(c[i]);
336             }
337             c = new_c;
338         }
339
340     }
341     return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
342 };
343
344 circ.util.offline_renew_columns = function(modify,params) {
345
346     var c = [
347         {
348             'id' : 'timestamp',
349             'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.timestamp'),
350             'flex' : 1,
351             'primary' : false,
352             'hidden' : true,
353             'editable' : false, 'render' : function(my) { return my.timestamp; }
354         },
355         {
356             'id' : 'checkout_time',
357             'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.checkout_time'),
358             'flex' : 1,
359             'primary' : false,
360             'hidden' : true,
361             'editable' : false, 'render' : function(my) { return my.checkout_time; }
362         },
363         {
364             'id' : 'type',
365             'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.type'),
366             'flex' : 1,
367             'primary' : false,
368             'hidden' : true,
369             'editable' : false, 'render' : function(my) { return my.type; }
370         },
371         {
372             'id' : 'patron_barcode',
373             'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.patron_barcode'),
374             'flex' : 1,
375             'primary' : false,
376             'hidden' : true,
377             'editable' : false, 'render' : function(my) { return my.patron_barcode; }
378         },
379         {
380             'id' : 'barcode',
381             'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.item_barcode'),
382             'flex' : 2,
383             'primary' : true,
384             'hidden' : false,
385             'editable' : false, 'render' : function(my) { return my.barcode; }
386         },
387         {
388             'id' : 'due_date',
389             'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.due_date'),
390             'flex' : 1,
391             'primary' : false,
392             'hidden' : false,
393             'editable' : false, 'render' : function(my) { return my.due_date; }
394         },
395         {
396             'id' : 'due_time',
397             'label' : document.getElementById('commonStrings').getString('staff.circ_label_due_time'),
398             'flex' : 1,
399             'primary' : false,
400             'hidden' : false,
401             'editable' : false, 'render' : function(my) { return my.due_time; }
402         }
403     ];
404     if (modify) for (var i = 0; i < c.length; i++) {
405         if (modify[ c[i].id ]) {
406             for (var j in modify[ c[i].id ]) {
407                 c[i][j] = modify[ c[i].id ][j];
408             }
409         }
410     }
411     if (params) {
412         if (params.just_these) {
413             JSAN.use('util.functional');
414             var new_c = [];
415             for (var i = 0; i < params.just_these.length; i++) {
416                 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
417                 new_c.push( function(y){ return y; }( x ) );
418             }
419             c = new_c;
420         }
421         if (params.except_these) {
422             JSAN.use('util.functional');
423             var new_c = [];
424             for (var i = 0; i < c.length; i++) {
425                 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
426                 if (!x) new_c.push(c[i]);
427             }
428             c = new_c;
429         }
430
431     }
432     return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
433 };
434
435 circ.util.offline_inhouse_use_columns = function(modify,params) {
436
437     var c = [
438         {
439             'id' : 'timestamp',
440             'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.timestamp'),
441             'flex' : 1,
442             'primary' : false,
443             'hidden' : true,
444             'editable' : false, 'render' : function(my) { return my.timestamp; }
445         },
446         {
447             'id' : 'use_time',
448             'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.use_time'),
449             'flex' : 1,
450             'primary' : false,
451             'hidden' : true,
452             'editable' : false, 'render' : function(my) { return my.use_time; }
453         },
454         {
455             'id' : 'type',
456             'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.type'),
457             'flex' : 1,
458             'primary' : false,
459             'hidden' : true,
460             'editable' : false, 'render' : function(my) { return my.type; }
461         },
462         {
463             'id' : 'count',
464             'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.count'),
465             'sort_type' : 'number',
466             'flex' : 1,
467             'primary' : false,
468             'hidden' : false,
469             'editable' : false, 'render' : function(my) { return my.count; }
470         },
471         {
472             'id' : 'barcode',
473             'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.item_barcode'),
474             'flex' : 2,
475             'primary' : true,
476             'hidden' : false,
477             'editable' : false, 'render' : function(my) { return my.barcode; }
478         }
479     ];
480     if (modify) for (var i = 0; i < c.length; i++) {
481         if (modify[ c[i].id ]) {
482             for (var j in modify[ c[i].id ]) {
483                 c[i][j] = modify[ c[i].id ][j];
484             }
485         }
486     }
487     if (params) {
488         if (params.just_these) {
489             JSAN.use('util.functional');
490             var new_c = [];
491             for (var i = 0; i < params.just_these.length; i++) {
492                 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
493                 new_c.push( function(y){ return y; }( x ) );
494             }
495             c = new_c;
496         }
497         if (params.except_these) {
498             JSAN.use('util.functional');
499             var new_c = [];
500             for (var i = 0; i < c.length; i++) {
501                 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
502                 if (!x) new_c.push(c[i]);
503             }
504             c = new_c;
505         }
506
507     }
508     return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
509 };
510
511 circ.util.columns = function(modify,params) {
512
513     JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
514     JSAN.use('util.network'); var network = new util.network();
515     JSAN.use('util.money');
516
517     var c = [
518         {
519             'id' : 'acp_id',
520             'fm_class' : 'acp',
521             'label' : document.getElementById('commonStrings').getString('staff.acp_label_id'),
522             'flex' : 1,
523             'primary' : false,
524             'hidden' : true,
525             'editable' : false, 'render' : function(my) { return my.acp.id(); },
526             'persist' : 'hidden width ordinal'
527         },
528         {
529             'id' : 'circ_id',
530             'fm_class' : 'circ',
531             'label' : document.getElementById('commonStrings').getString('staff.circ_label_id'),
532             'flex' : 1,
533             'primary' : false,
534             'hidden' : true,
535             'editable' : false, 'render' : function(my) { return my.circ ? my.circ.id() : ""; },
536             'persist' : 'hidden width ordinal'
537         },
538         {
539             'id' : 'mvr_doc_id',
540             'fm_class' : 'mvr',
541             'label' : document.getElementById('commonStrings').getString('staff.mvr_label_doc_id'),
542             'flex' : 1,
543             'primary' : false,
544             'hidden' : true,
545             'editable' : false, 'render' : function(my) { return my.mvr.doc_id(); },
546             'persist' : 'hidden width ordinal'
547         },
548         {
549             'persist' : 'hidden width ordinal',
550             'id' : 'service',
551             'label' : 'Service',
552             'flex' : 1,
553             'primary' : false,
554             'hidden' : true,
555             'editable' : false, 'render' : function(my) { return my.service; }
556         },
557         {
558             'id' : 'barcode',
559             'fm_class' : 'acp',
560             'label' : document.getElementById('commonStrings').getString('staff.acp_label_barcode'),
561             'flex' : 1,
562             'primary' : false,
563             'hidden' : true,
564             'editable' : false, 'render' : function(my) { return my.acp.barcode(); },
565             'persist' : 'hidden width ordinal'
566         },
567         {
568             'id' : 'call_number',
569             'fm_class' : 'acp',
570             'label' : document.getElementById('commonStrings').getString('staff.acp_label_call_number'),
571             'flex' : 1,
572             'primary' : false,
573             'hidden' : true,
574             'editable' : false, 'render' : function(my,scratch_data) {
575                 var acn_id;
576                 if (my.acn) {
577                     if (typeof my.acn == 'object') {
578                         acn_id = my.acn.id();
579                     } else {
580                         acn_id = my.acn;
581                     }
582                 } else if (my.acp) {
583                     if (typeof my.acp.call_number() == 'object') {
584                         acn_id = my.acp.call_number().id();
585                     } else {
586                         acn_id = my.acp.call_number();
587                     }
588                 }
589                 if (!acn_id && acn_id != 0) {
590                     return '';
591                 } else if (acn_id == -1) {
592                     return document.getElementById('circStrings').getString('staff.circ.utils.not_cataloged');
593                 } else if (acn_id == -2) {
594                     return document.getElementById('circStrings').getString('staff.circ.utils.retrieving');
595                 } else {
596                     if (!my.acn) {
597                         if (typeof scratch_data['acn_map'] == 'undefined') {
598                             scratch_data['acn_map'] = {};
599                         }
600                         if (typeof scratch_data['acn_map'][ acn_id ] == 'undefined') {
601                             var x = network.simple_request("FM_ACN_RETRIEVE.authoritative",[ acn_id ]);
602                             if (x.ilsevent) {
603                                 return document.getElementById('circStrings').getString('staff.circ.utils.not_cataloged');
604                             } else {
605                                 my.acn = x;
606                                 scratch_data['acn_map'][ acn_id ] = my.acn;
607                             }
608                         } else {
609                             my.acn = scratch_data['acn_map'][ acn_id ];
610                         }
611                     }
612                     return my.acn.label();
613                 }
614             },
615             'persist' : 'hidden width ordinal'
616         },
617         {
618             'id' : 'owning_lib',
619             'fm_class' : 'acn',
620             'label' : document.getElementById('circStrings').getString('staff.circ.utils.owning_lib'),
621             'flex' : 1,
622             'primary' : false,
623             'hidden' : true,
624             'editable' : false, 'render' : function(my) {
625                 if (Number(my.acn.owning_lib())>=0) {
626                     return data.hash.aou[ my.acn.owning_lib() ].shortname();
627                 } else {
628                     return my.acn.owning_lib().shortname();
629                 }
630             },
631             'persist' : 'hidden width ordinal'
632         },
633         {
634             'id' : 'prefix',
635             'fm_class' : 'acn',
636             'label' : document.getElementById('circStrings').getString('staff.circ.utils.prefix'),
637             'flex' : 1,
638             'primary' : false,
639             'hidden' : true,
640             'editable' : false, 'render' : function(my) {
641                 if (typeof my.acn == 'undefined') return '';
642                 return (typeof my.acn.prefix() == 'object')
643                     ? my.acn.prefix().label()
644                     : data.lookup("acnp", my.acn.prefix() ).label();
645             },
646             'persist' : 'hidden width ordinal'
647         },
648         {
649             'id' : 'suffix',
650             'fm_class' : 'acn',
651             'label' : document.getElementById('circStrings').getString('staff.circ.utils.suffix'),
652             'flex' : 1,
653             'primary' : false,
654             'hidden' : true,
655             'editable' : false, 'render' : function(my) {
656                 if (typeof my.acn == 'undefined') return '';
657                 return (typeof my.acn.suffix() == 'object')
658                     ? my.acn.suffix().label()
659                     : data.lookup("acns", my.acn.suffix() ).label();
660             },
661             'persist' : 'hidden width ordinal'
662         },
663         {
664             'id' : 'label_class',
665             'fm_class' : 'acn',
666             'label' : document.getElementById('circStrings').getString('staff.circ.utils.label_class'),
667             'flex' : 1,
668             'primary' : false,
669             'hidden' : true,
670             'editable' : false, 'render' : function(my) {
671                 if (typeof my.acn == 'undefined') return '';
672                 return (typeof my.acn.label_class() == 'object') ? my.acn.label_class().name() : my.acn.label_class();
673             },
674             'persist' : 'hidden width ordinal'
675         },
676         {
677             'id' : 'parts',
678             'fm_class' : 'acp',
679             'label' : document.getElementById('commonStrings').getString('staff.acp_label_parts'),
680             'flex' : 1,
681             'sort_type' : 'number',
682             'primary' : false,
683             'hidden' : true,
684             'editable' : false, 'render' : function(my) {
685                 if (! my.acp.parts()) return '';
686                 var parts = my.acp.parts();
687                 var display_string = '';
688                 for (var i = 0; i < parts.length; i++) {
689                     if (my.doc_id) {
690                         if (my.doc_id == parts[i].record()) {
691                             return parts[i].label();
692                         }
693                     } else {
694                         if (i != 0) display_string += ' : ';
695                         display_string += parts[i].label();
696                     }
697                 }
698                 return display_string;
699             },
700             'persist' : 'hidden width ordinal'
701         },
702         {
703             'id' : 'copy_number',
704             'fm_class' : 'acp',
705             'label' : document.getElementById('commonStrings').getString('staff.acp_label_copy_number'),
706             'flex' : 1,
707             'sort_type' : 'number',
708             'primary' : false,
709             'hidden' : true,
710             'editable' : false, 'render' : function(my) { return my.acp.copy_number(); },
711             'persist' : 'hidden width ordinal'
712         },
713         {
714             'id' : 'location',
715             'fm_class' : 'acp',
716             'label' : document.getElementById('commonStrings').getString('staff.acp_label_location'),
717             'flex' : 1,
718             'primary' : false,
719             'hidden' : true,
720             'editable' : false, 'render' : function(my) {
721                 if (Number(my.acp.location())>=0) {
722                     return data.lookup("acpl", my.acp.location() ).name();
723                 } else {
724                     return my.acp.location().name();
725                 }
726             },
727             'persist' : 'hidden width ordinal'
728         },
729         {
730             'id' : 'loan_duration',
731             'fm_class' : 'acp',
732             'label' : document.getElementById('commonStrings').getString('staff.acp_label_loan_duration'),
733             'flex' : 1,
734             'primary' : false,
735             'hidden' : true,
736             'editable' : false, 'render' : function(my) {
737                 switch(Number(my.acp.loan_duration())) {
738                     case 1:
739                         return document.getElementById('circStrings').getString('staff.circ.utils.loan_duration.short');
740                         break;
741                     case 2:
742                         return document.getElementById('circStrings').getString('staff.circ.utils.loan_duration.normal');
743                         break;
744                     case 3:
745                         return document.getElementById('circStrings').getString('staff.circ.utils.loan_duration.long');
746                         break;
747                 };
748             },
749             'persist' : 'hidden width ordinal'
750         },
751         {
752             'id' : 'circ_lib',
753             'fm_class' : 'acp',
754             'label' : document.getElementById('commonStrings').getString('staff.acp_label_circ_lib'),
755             'flex' : 1,
756             'primary' : false,
757             'hidden' : true,
758             'editable' : false, 'render' : function(my) {
759                 if (Number(my.acp.circ_lib())>=0) {
760                     return data.hash.aou[ my.acp.circ_lib() ].shortname();
761                 } else {
762                     return my.acp.circ_lib().shortname();
763                 }
764             },
765             'persist' : 'hidden width ordinal'
766         },
767         {
768             'id' : 'fine_level',
769             'fm_class' : 'acp',
770             'label' : document.getElementById('commonStrings').getString('staff.acp_label_fine_level'),
771             'flex' : 1,
772             'primary' : false,
773             'hidden' : true,
774             'editable' : false, 'render' : function(my) {
775                 switch(Number(my.acp.fine_level())) {
776                     case 1:
777                         return document.getElementById('circStrings').getString('staff.circ.utils.fine_level.low');
778                         break;
779                     case 2:
780                         return document.getElementById('circStrings').getString('staff.circ.utils.fine_level.normal');
781                         break;
782                     case 3:
783                         return document.getElementById('circStrings').getString('staff.circ.utils.fine_level.high');
784                         break;
785                 };
786             },
787             'persist' : 'hidden width ordinal'
788         },
789         {
790             'id' : 'circulate',
791             'fm_class' : 'acp',
792             'label' : document.getElementById('circStrings').getString('staff.circ.utils.circulate'),
793             'flex' : 1,
794             'primary' : false,
795             'hidden' : true,
796             'editable' : false, 'render' : function(my) {
797                 if (get_bool( my.acp.circulate() )) {
798                     return document.getElementById('circStrings').getString('staff.circ.utils.yes');
799                 } else {
800                     return document.getElementById('circStrings').getString('staff.circ.utils.no');
801                 }
802             },
803             'persist' : 'hidden width ordinal'
804         },
805         {
806             'id' : 'deleted',
807             'fm_class' : 'acp',
808             'label' : document.getElementById('circStrings').getString('staff.circ.utils.deleted'),
809             'flex' : 1,
810             'primary' : false,
811             'hidden' : true,
812             'editable' : false, 'render' : function(my) {
813                 if (get_bool( my.acp.deleted() )) {
814                     return document.getElementById('circStrings').getString('staff.circ.utils.yes');
815                 } else {
816                     return document.getElementById('circStrings').getString('staff.circ.utils.no');
817                 }
818             },
819             'persist' : 'hidden width ordinal'
820         },
821         {
822             'id' : 'holdable',
823             'fm_class' : 'acp',
824             'label' : document.getElementById('circStrings').getString('staff.circ.utils.holdable'),
825             'flex' : 1,
826             'primary' : false,
827             'hidden' : true,
828             'editable' : false, 'render' : function(my) {
829                 if (get_bool( my.acp.holdable() )) {
830                     return document.getElementById('circStrings').getString('staff.circ.utils.yes');
831                 } else {
832                     return document.getElementById('circStrings').getString('staff.circ.utils.no');
833                 }
834             },
835             'persist' : 'hidden width ordinal'
836         },
837         {
838             'id' : 'floating',
839             'fm_class' : 'acp',
840             'label' : document.getElementById('circStrings').getString('staff.circ.utils.floating'),
841             'flex' : 1,
842             'primary' : false,
843             'hidden' : true,
844             'editable' : false, 'render' : function(my) {
845                 if (get_bool( my.acp.floating() )) {
846                     return document.getElementById('circStrings').getString('staff.circ.utils.yes');
847                 } else {
848                     return document.getElementById('circStrings').getString('staff.circ.utils.no');
849                 }
850             },
851             'persist' : 'hidden width ordinal'
852         },
853
854         {
855             'id' : 'opac_visible',
856             'fm_class' : 'acp',
857             'label' : document.getElementById('circStrings').getString('staff.circ.utils.opac_visible'),
858             'flex' : 1,
859             'primary' : false,
860             'hidden' : true,
861             'editable' : false, 'render' : function(my) {
862                 if (get_bool( my.acp.opac_visible() )) {
863                     return document.getElementById('circStrings').getString('staff.circ.utils.yes');
864                 } else {
865                     return document.getElementById('circStrings').getString('staff.circ.utils.no');
866                 }
867             },
868             'persist' : 'hidden width ordinal'
869         },
870         {
871             'persist' : 'hidden width ordinal',
872             'id' : 'acp_mint_condition',
873             'fm_class' : 'acp',
874             'label' : document.getElementById('circStrings').getString('staff.circ.utils.acp_mint_condition'),
875             'flex' : 0,
876             'primary' : false,
877             'hidden' : true,
878             'editable' : false, 'render' : function(my) {
879                 if (get_bool( my.acp.mint_condition() )) {
880                     return document.getElementById('circStrings').getString('staff.circ.utils.acp_mint_condition.true');
881                 } else {
882                     return document.getElementById('circStrings').getString('staff.circ.utils.acp_mint_condition.false');
883                 }
884             }
885         },
886         {
887             'persist' : 'hidden width ordinal',
888             'fm_class' : 'acp',
889             'id' : 'ref',
890             'label' : document.getElementById('circStrings').getString('staff.circ.utils.reference'),
891             'flex' : 1,
892             'primary' : false,
893             'hidden' : true,
894             'editable' : false, 'render' : function(my) {
895                 if (get_bool( my.acp.ref() )) {
896                     return document.getElementById('circStrings').getString('staff.circ.utils.yes');
897                 } else {
898                     return document.getElementById('circStrings').getString('staff.circ.utils.no');
899                 }
900             }
901         },
902         {
903             'persist' : 'hidden width ordinal',
904             'fm_class' : 'acp',
905             'id' : 'deposit',
906             'label' : document.getElementById('circStrings').getString('staff.circ.utils.deposit'),
907             'flex' : 1,
908             'primary' : false,
909             'hidden' : true,
910             'editable' : false, 'render' : function(my) {
911                 if (get_bool( my.acp.deposit() )) {
912                     return document.getElementById('circStrings').getString('staff.circ.utils.yes');
913                 } else {
914                     return document.getElementById('circStrings').getString('staff.circ.utils.no');
915                 }
916             }
917         },
918         {
919             'persist' : 'hidden width ordinal',
920             'fm_class' : 'acp',
921             'id' : 'deposit_amount',
922             'label' : document.getElementById('commonStrings').getString('staff.acp_label_deposit_amount'),
923             'flex' : 1,
924             'primary' : false,
925             'hidden' : true,
926             'editable' : false, 'render' : function(my) {
927                 if (my.acp.price() == null) {
928                     return document.getElementById('circStrings').getString('staff.circ.utils.unset');
929                 } else {
930                     return util.money.sanitize(my.acp.deposit_amount());
931                 }
932             },
933             'sort_type' : 'money'
934         },
935         {
936             'persist' : 'hidden width ordinal',
937             'fm_class' : 'acp',
938             'id' : 'price',
939             'label' : document.getElementById('commonStrings').getString('staff.acp_label_price'),
940             'flex' : 1,
941             'primary' : false,
942             'hidden' : true,
943             'editable' : false, 'render' : function(my) {
944                 if (my.acp.price() == null) {
945                     return document.getElementById('circStrings').getString('staff.circ.utils.unset');
946                 } else {
947                     return util.money.sanitize(my.acp.price());
948                 }
949             },
950             'sort_type' : 'money'
951         },
952         {
953             'persist' : 'hidden width ordinal',
954             'fm_class' : 'acp',
955             'id' : 'circ_as_type',
956             'label' : document.getElementById('commonStrings').getString('staff.acp_label_circ_as_type'),
957             'flex' : 1,
958             'primary' : false,
959             'hidden' : true,
960             'editable' : false, 'render' : function(my) { return my.acp.circ_as_type(); }
961         },
962         {
963             'persist' : 'hidden width ordinal',
964             'fm_class' : 'acp',
965             'id' : 'circ_modifier',
966             'label' : document.getElementById('commonStrings').getString('staff.acp_label_circ_modifier'),
967             'flex' : 1,
968             'primary' : false,
969             'hidden' : true,
970             'editable' : false, 'render' : function(my) { var cm = my.acp.circ_modifier(); return document.getElementById('commonStrings').getFormattedString('staff.circ_modifier.display',[cm,data.hash.ccm[cm].name(),data.hash.ccm[cm].description()]); }
971         },
972         {
973             'id' : 'status_changed_time',
974             'fm_class' : 'acp',
975             'label' : document.getElementById('circStrings').getString('staff.circ.utils.status_changed_time'),
976             'flex' : 1,
977             'sort_type' : 'date',
978             'primary' : false,
979             'hidden' : true,
980             'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.acp.status_changed_time(), '%{localized}' ); },
981             'persist' : 'hidden width ordinal'
982         },
983         {
984             'persist' : 'hidden width ordinal',
985             'fm_class' : 'circ',
986             'id' : 'checkout_lib',
987             'label' : document.getElementById('circStrings').getString('staff.circ.utils.checkout_lib'),
988             'flex' : 1,
989             'primary' : false,
990             'hidden' : true,
991             'editable' : false, 'render' : function(my) {
992                 if (my.circ) {
993                     return data.hash.aou[ my.circ.circ_lib() ].shortname();
994                 } else {
995                     return "";
996                 }
997             }
998         },
999         {
1000             'persist' : 'hidden width ordinal',
1001             'fm_class' : 'circ',
1002             'id' : 'xact_start',
1003             'label' : document.getElementById('circStrings').getString('staff.circ.utils.xact_start'),
1004             'flex' : 1,
1005             'sort_type' : 'date',
1006             'primary' : false,
1007             'hidden' : true,
1008             'editable' : false, 'render' : function(my) {
1009                 if (my.circ) {
1010                     return util.date.formatted_date( my.circ.xact_start(), '%{localized}' );
1011                 } else {
1012                     return "";
1013                 }
1014             }
1015         },
1016         {
1017             'persist' : 'hidden width ordinal',
1018             'fm_class' : 'circ',
1019             'id' : 'checkin_time',
1020             'label' : document.getElementById('circStrings').getString('staff.circ.utils.checkin_time'),
1021             'flex' : 1,
1022             'sort_type' : 'date',
1023             'primary' : false,
1024             'hidden' : true,
1025             'editable' : false, 'render' : function(my) {
1026                 if (my.circ) {
1027                     return util.date.formatted_date( my.circ.checkin_time(), '%{localized}' );
1028                 } else {
1029                     return "";
1030                 }
1031             }
1032         },
1033         {
1034             'persist' : 'hidden width ordinal',
1035             'fm_class' : 'circ',
1036             'id' : 'xact_finish',
1037             'label' : document.getElementById('circStrings').getString('staff.circ.utils.xact_finish'),
1038             'flex' : 1,
1039             'sort_type' : 'date',
1040             'primary' : false,
1041             'hidden' : true,
1042             'editable' : false, 'render' : function(my) { return my.circ ? util.date.formatted_date( my.circ.xact_finish(), '%{localized}' ) : ""; },
1043         },
1044         {
1045             'persist' : 'hidden width ordinal',
1046             'fm_class' : 'circ',
1047             'id' : 'due_date',
1048             'label' : document.getElementById('commonStrings').getString('staff.circ_label_due_date'),
1049             'flex' : 1,
1050             'sort_type' : 'date',
1051             'primary' : false,
1052             'hidden' : true,
1053             'editable' : false, 'render' : function(my) {
1054                 if (my.circ) {
1055                     return util.date.formatted_date( my.circ.due_date(), '%{localized}' );
1056                 } else {
1057                     return "";
1058                 }
1059             }
1060         },
1061         {
1062             'persist' : 'hidden width ordinal',
1063             'fm_class' : 'acp',
1064             'id' : 'acp_create_date',
1065             'label' : document.getElementById('circStrings').getString('staff.circ.utils.create_date'),
1066             'flex' : 1,
1067             'sort_type' : 'date',
1068             'primary' : false,
1069             'hidden' : true,
1070             'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.acp.create_date(), '%{localized}' ); }
1071         },
1072         {
1073             'persist' : 'hidden width ordinal',
1074             'fm_class' : 'acp',
1075             'id' : 'acp_edit_date',
1076             'label' : document.getElementById('circStrings').getString('staff.circ.utils.edit_date'),
1077             'flex' : 1,
1078             'sort_type' : 'date',
1079             'primary' : false,
1080             'hidden' : true,
1081             'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.acp.edit_date(), '%{localized}' ); }
1082         },
1083         {
1084             'persist' : 'hidden width ordinal',
1085             'fm_class' : 'mvr',
1086             'id' : 'title',
1087             'label' : document.getElementById('commonStrings').getString('staff.mvr_label_title'),
1088             'flex' : 2,
1089             'sort_type' : 'title',
1090             'primary' : false,
1091             'hidden' : true,
1092             'editable' : false, 'render' : function(my) {
1093                 if (my.mvr) {
1094                     if (my.mvr.doc_id() == -1) {
1095                         return my.acp.dummy_title();
1096                     } else {
1097                         return my.mvr.title();
1098                     }
1099                 } else {
1100                     return my.acp.dummy_title();
1101                 }
1102             }
1103         },
1104         {
1105             'persist' : 'hidden width ordinal',
1106             'fm_class' : 'mvr',
1107             'id' : 'author',
1108             'label' : document.getElementById('commonStrings').getString('staff.mvr_label_author'),
1109             'flex' : 1,
1110             'primary' : false,
1111             'hidden' : true,
1112             'editable' : false, 'render' : function(my) {
1113                 if (my.mvr) {
1114                     if (my.mvr.doc_id() == -1) {
1115                         return my.acp.dummy_author();
1116                     } else {
1117                         return my.mvr.author();
1118                     }
1119                 } else {
1120                     return my.acp.dummy_author();
1121                 }
1122             }
1123         },
1124         {
1125             'persist' : 'hidden width ordinal',
1126             'fm_class' : 'mvr',
1127             'id' : 'edition',
1128             'label' : document.getElementById('circStrings').getString('staff.circ.utils.edition'),
1129             'flex' : 1,
1130             'primary' : false,
1131             'hidden' : true,
1132             'editable' : false, 'render' : function(my) { return my.mvr.edition(); }
1133         },
1134         {
1135             'persist' : 'hidden width ordinal',
1136             'fm_class' : 'mvr',
1137             'id' : 'isbn',
1138             'label' : document.getElementById('circStrings').getString('staff.circ.utils.isbn'),
1139             'flex' : 1,
1140             'primary' : false,
1141             'hidden' : true,
1142             'editable' : false, 'render' : function(my) { 
1143                 if (my.mvr) {
1144                     if (my.mvr.doc_id() == -1) {
1145                         return my.acp.dummy_isbn();
1146                     } else {
1147                         return my.mvr.isbn();
1148                     }
1149                 } else {
1150                     return my.acp.dummy_isbn();
1151                 }
1152             }
1153         },
1154         {
1155             'persist' : 'hidden width ordinal',
1156             'fm_class' : 'mvr',
1157             'id' : 'pubdate',
1158             'label' : document.getElementById('circStrings').getString('staff.circ.utils.pubdate'),
1159             'flex' : 1,
1160             'primary' : false,
1161             'hidden' : true,
1162             'editable' : false, 'render' : function(my) { return my.mvr.pubdate(); }
1163         },
1164         {
1165             'persist' : 'hidden width ordinal',
1166             'fm_class' : 'mvr',
1167             'id' : 'publisher',
1168             'label' : document.getElementById('circStrings').getString('staff.circ.utils.publisher'),
1169             'flex' : 1,
1170             'primary' : false,
1171             'hidden' : true,
1172             'editable' : false, 'render' : function(my) { return my.mvr.publisher(); }
1173         },
1174         {
1175             'persist' : 'hidden width ordinal',
1176             'fm_class' : 'mvr',
1177             'id' : 'tcn',
1178             'label' : document.getElementById('circStrings').getString('staff.circ.utils.tcn'),
1179             'flex' : 1,
1180             'primary' : false,
1181             'hidden' : true,
1182             'editable' : false, 'render' : function(my) { return my.mvr.tcn(); }
1183         },
1184         {
1185             'persist' : 'hidden width ordinal',
1186             'fm_class' : 'circ',
1187             'id' : 'renewal_remaining',
1188             'label' : document.getElementById('commonStrings').getString('staff.circ_label_renewal_remaining'),
1189             'flex' : 0,
1190             'primary' : false,
1191             'hidden' : true,
1192             'editable' : false, 'render' : function(my) {
1193                 if (my.circ) {
1194                     return my.circ.renewal_remaining();
1195                 } else {
1196                     return "";
1197                 }
1198             },
1199             'sort_type' : 'number'
1200         },
1201         {
1202             'persist' : 'hidden width ordinal',
1203             'fm_class' : 'circ',
1204             'id' : 'stop_fines',
1205             'label' : document.getElementById('circStrings').getString('staff.circ.utils.stop_fines'),
1206             'flex' : 0,
1207             'primary' : false,
1208             'hidden' : true,
1209             'editable' : false, 'render' : function(my) {
1210                 if (my.circ) {
1211                     return my.circ.stop_fines();
1212                 } else {
1213                     return "";
1214                 }
1215             }
1216         },
1217         {
1218             'persist' : 'hidden width ordinal',
1219             'fm_class' : 'circ',
1220             'id' : 'stop_fines_time',
1221             'label' : document.getElementById('circStrings').getString('staff.circ.utils.stop_fines_time'),
1222             'flex' : 0,
1223             'sort_type' : 'date',
1224             'primary' : false,
1225             'hidden' : true,
1226             'editable' : false, 'render' : function(my) {
1227                 if (my.circ) {
1228                     return util.date.formatted_date( my.circ.stop_fines_time(), '%{localized}' );
1229                 } else {
1230                     return "";
1231                 }
1232             }
1233         },
1234         {
1235             'persist' : 'hidden width ordinal',
1236             'fm_class' : 'acp',
1237             'id' : 'acp_status',
1238             'label' : document.getElementById('commonStrings').getString('staff.acp_label_status'),
1239             'flex' : 1,
1240             'primary' : false,
1241             'hidden' : true,
1242             'editable' : false, 'render' : function(my) {
1243                 if (Number(my.acp.status())>=0) {
1244                     return data.hash.ccs[ my.acp.status() ].name();
1245                 } else {
1246                     return my.acp.status().name();
1247                 }
1248             }
1249         },
1250         {
1251             'persist' : 'hidden width ordinal',
1252             'id' : 'route_to',
1253             'label' : document.getElementById('circStrings').getString('staff.circ.utils.route_to'),
1254             'flex' : 1,
1255             'primary' : false,
1256             'hidden' : true,
1257             'editable' : false, 'render' : function(my) { return my.route_to.toString(); }
1258         },
1259         {
1260             'persist' : 'hidden width ordinal',
1261             'id' : 'message',
1262             'label' : document.getElementById('circStrings').getString('staff.circ.utils.message'),
1263             'flex' : 1,
1264             'primary' : false,
1265             'hidden' : true,
1266             'editable' : false, 'render' : function(my) { return my.message.toString(); }
1267         },
1268         {
1269             'persist' : 'hidden width ordinal',
1270             'id' : 'uses',
1271             'label' : document.getElementById('circStrings').getString('staff.circ.utils.uses'),
1272             'flex' : 1,
1273             'primary' : false,
1274             'hidden' : true,
1275             'editable' : false, 'render' : function(my) { return my.uses; },
1276             'sort_type' : 'number'
1277         },
1278         {
1279             'persist' : 'hidden width ordinal',
1280             'fm_class' : 'acp',
1281             'id' : 'alert_message',
1282             'label' : document.getElementById('circStrings').getString('staff.circ.utils.alert_message'),
1283             'flex' : 1,
1284             'primary' : false,
1285             'hidden' : true,
1286             'editable' : false, 'render' : function(my) { return my.acp.alert_message(); }
1287         },
1288         {
1289             'persist' : 'hidden width ordinal',
1290             'fm_class' : 'circ',
1291             'id' : 'checkin_workstation',
1292             'label' : document.getElementById('circStrings').getString('staff.circ.utils.checkin_workstation'),
1293             'flex' : 1,
1294             'primary' : false,
1295             'hidden' : true,
1296             'editable' : false, 'render' : function(my) { return my.circ ? ( typeof my.circ.checkin_workstation() == 'object' ? my.circ.checkin_workstation().name() : my.circ.checkin_workstation() ) : ""; },
1297         },
1298         {
1299             'persist' : 'hidden width ordinal',
1300             'fm_class' : 'circ',
1301             'id' : 'checkout_workstation',
1302             'label' : document.getElementById('circStrings').getString('staff.circ.utils.checkout_workstation'),
1303             'flex' : 1,
1304             'primary' : false,
1305             'hidden' : true,
1306             'editable' : false, 'render' : function(my) { return my.circ ? ( typeof my.circ.workstation() == 'object' ? my.circ.workstation().name() : my.circ.workstation() ) : ""; },
1307         },
1308         {
1309             'persist' : 'hidden width ordinal',
1310             'fm_class' : 'circ',
1311             'id' : 'checkout_workstation_top_of_chain',
1312             'label' : document.getElementById('circStrings').getString('staff.circ.utils.checkout_workstation_top_of_chain'),
1313             'flex' : 1,
1314             'primary' : false,
1315             'hidden' : true,
1316             'editable' : false, 'render' : function(my) { if (my.circ&&!my.original_circ) { if(!get_bool(my.circ.desk_renewal())&&!get_bool(my.circ.opac_renewal())&&!get_bool(my.circ.phone_renewal())){my.original_circ = my.circ;}}; return my.original_circ ? ( typeof my.original_circ.workstation() == 'object' ? my.original_circ.workstation().name() : my.original_circ.workstation() ) : ""; },
1317         },
1318         {
1319             'persist' : 'hidden width ordinal',
1320             'fm_class' : 'circ',
1321             'id' : 'checkin_scan_time',
1322             'label' : document.getElementById('circStrings').getString('staff.circ.utils.checkin_scan_time'),
1323             'flex' : 1,
1324             'sort_type' : 'date',
1325             'primary' : false,
1326             'hidden' : true,
1327             'editable' : false, 'render' : function(my) { return my.circ ? util.date.formatted_date( my.circ.checkin_scan_time(), '%{localized}' ) : ""; },
1328         },
1329         {
1330             'persist' : 'hidden width ordinal',
1331             'fm_class' : 'bre',
1332             'id' : 'owner',
1333             'label' : document.getElementById('circStrings').getString('staff.circ.utils.owner'),
1334             'flex' : 1,
1335             'primary' : false,
1336             'hidden' : true,
1337             'editable' : false, 'render' : function(my) { return my.bre ? (typeof my.bre.owner() == 'object' ? my.bre.owner().shortname() : data.hash.aou[my.bre.owner()].shortname() ) : ''; }
1338         },
1339         {
1340             'persist' : 'hidden width ordinal',
1341             'fm_class' : 'bre',
1342             'id' : 'creator',
1343             'label' : document.getElementById('circStrings').getString('staff.circ.utils.creator'),
1344             'flex' : 1,
1345             'primary' : false,
1346             'hidden' : true,
1347             'editable' : false, 'render' : function(my) { return my.bre ? (typeof my.bre.creator() == 'object' ? my.bre.creator().usrname() : '#' + my.bre.creator() ) : ''; }
1348         },
1349         {
1350             'persist' : 'hidden width ordinal',
1351             'fm_class' : 'bre',
1352             'id' : 'editor',
1353             'label' : document.getElementById('circStrings').getString('staff.circ.utils.editor'),
1354             'flex' : 1,
1355             'primary' : false,
1356             'hidden' : true,
1357             'editable' : false, 'render' : function(my) { return my.bre ? (typeof my.bre.editor() == 'object' ? my.bre.editor().usrname() : '#' + my.bre.editor() ) : ''; }
1358         },
1359         {
1360             'persist' : 'hidden width ordinal',
1361             'fm_class' : 'bre',
1362             'id' : 'create_date',
1363             'label' : document.getElementById('circStrings').getString('staff.circ.utils.bre.create_date'),
1364             'flex' : 1,
1365             'sort_type' : 'date',
1366             'primary' : false,
1367             'hidden' : true,
1368             'editable' : false, 'render' : function(my) { return my.bre ? util.date.formatted_date( my.bre.create_date(), '%{localized}' ) : ''; }
1369         },
1370         {
1371             'persist' : 'hidden width ordinal',
1372             'fm_class' : 'bre',
1373             'id' : 'edit_date',
1374             'label' : document.getElementById('circStrings').getString('staff.circ.utils.bre.edit_date'),
1375             'flex' : 1,
1376             'sort_type' : 'date',
1377             'primary' : false,
1378             'hidden' : true,
1379             'editable' : false, 'render' : function(my) { return my.bre ? util.date.formatted_date( my.bre.edit_date(), '%{localized}' ) : ''; }
1380         },
1381         {
1382             'persist' : 'hidden width ordinal',
1383             'fm_class' : 'bre',
1384             'id' : 'tcn_value',
1385             'label' : document.getElementById('circStrings').getString('staff.circ.utils.tcn'),
1386             'flex' : 1,
1387             'primary' : false,
1388             'hidden' : true,
1389             'editable' : false, 'render' : function(my) { return my.bre ? my.bre.tcn_value() : ''; }
1390         },
1391         {
1392             'persist' : 'hidden width ordinal',
1393             'fm_class' : 'bre',
1394             'id' : 'tcn_source',
1395             'label' : document.getElementById('circStrings').getString('staff.circ.utils.tcn_source'),
1396             'flex' : 1,
1397             'primary' : false,
1398             'hidden' : true,
1399             'editable' : false, 'render' : function(my) { return my.bre ? my.bre.tcn_source() : ''; }
1400         }
1401
1402     ];
1403     for (var i = 0; i < c.length; i++) {
1404         if (modify[ c[i].id ]) {
1405             for (var j in modify[ c[i].id ]) {
1406                 c[i][j] = modify[ c[i].id ][j];
1407             }
1408         }
1409     }
1410     if (params) {
1411         if (params.just_these) {
1412             JSAN.use('util.functional');
1413             var new_c = [];
1414             for (var i = 0; i < params.just_these.length; i++) {
1415                 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
1416                 new_c.push( function(y){ return y; }( x ) );
1417             }
1418             c = new_c;
1419         }
1420         if (params.except_these) {
1421             JSAN.use('util.functional');
1422             var new_c = [];
1423             for (var i = 0; i < c.length; i++) {
1424                 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
1425                 if (!x) new_c.push(c[i]);
1426             }
1427             c = new_c;
1428         }
1429     }
1430     return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
1431 };
1432
1433 circ.util.work_log_columns = function(modify,params) {
1434
1435     JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
1436
1437     var c = [
1438         {
1439             'persist' : 'hidden width ordinal',
1440             'id' : 'message',
1441             'label' : document.getElementById('circStrings').getString('staff.circ.work_log_column.message'),
1442             'flex' : 3,
1443             'primary' : true,
1444             'hidden' : false,
1445             'editable' : false, 'render' : function(my) { return my.message; }
1446         },
1447         {
1448             'persist' : 'hidden width ordinal',
1449             'id' : 'when',
1450             'label' : document.getElementById('circStrings').getString('staff.circ.work_log_column.when'),
1451             'flex' : 1,
1452             'primary' : false,
1453             'hidden' : false,
1454             'editable' : false, 'render' : function(my) { return String( my.when ); }
1455         }
1456
1457     ];
1458     for (var i = 0; i < c.length; i++) {
1459         if (modify[ c[i].id ]) {
1460             for (var j in modify[ c[i].id ]) {
1461                 c[i][j] = modify[ c[i].id ][j];
1462             }
1463         }
1464     }
1465     if (params) {
1466         if (params.just_these) {
1467             JSAN.use('util.functional');
1468             var new_c = [];
1469             for (var i = 0; i < params.just_these.length; i++) {
1470                 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
1471                 new_c.push( function(y){ return y; }( x ) );
1472             }
1473             c = new_c;
1474         }
1475         if (params.except_these) {
1476             JSAN.use('util.functional');
1477             var new_c = [];
1478             for (var i = 0; i < c.length; i++) {
1479                 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
1480                 if (!x) new_c.push(c[i]);
1481             }
1482             c = new_c;
1483         }
1484
1485     }
1486     return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
1487 };
1488
1489 circ.util.transit_columns = function(modify,params) {
1490
1491     JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
1492
1493     var c = [
1494         {
1495             'persist' : 'hidden width ordinal',
1496             'id' : 'transit_item_barcode',
1497             'label' : document.getElementById('circStrings').getString('staff.circ.utils.barcode'),
1498             'flex' : 1,
1499             'primary' : false,
1500             'hidden' : true,
1501             'editable' : false, 'render' : function(my) { return my.acp.barcode(); }
1502         },
1503         {
1504             'persist' : 'hidden width ordinal',
1505             'id' : 'transit_item_title',
1506             'label' : document.getElementById('circStrings').getString('staff.circ.utils.title'),
1507             'flex' : 1,
1508             'primary' : false,
1509             'hidden' : true,
1510             'editable' : false, 'render' : function(my) {
1511                 try { return my.mvr.title(); }
1512                 catch(E) { return my.acp.dummy_title(); }
1513             }
1514         },
1515         {
1516             'persist' : 'hidden width ordinal',
1517             'id' : 'transit_item_author',
1518             'label' : document.getElementById('circStrings').getString('staff.circ.utils.author'),
1519             'flex' : 1,
1520             'primary' : false,
1521             'hidden' : true,
1522             'editable' : false, 'render' : function(my) {
1523                 try { return my.mvr.author(); }
1524                 catch(E) { return my.acp.dummy_author(); }
1525             }
1526         },
1527         {
1528             'persist' : 'hidden width ordinal',
1529             'id' : 'transit_item_callnumber',
1530             'label' : document.getElementById('circStrings').getString('staff.circ.utils.callnumber'),
1531             'flex' : 1,
1532             'primary' : false,
1533             'hidden' : true,
1534             'editable' : false, 'render' : function(my) { return my.acn.label(); }
1535         },
1536         {
1537             'persist' : 'hidden width ordinal',
1538             'id' : 'transit_id',
1539             'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_id'),
1540             'flex' : 1,
1541             'primary' : false,
1542             'hidden' : true,
1543             'editable' : false, 'render' : function(my) { return my.atc.id(); }
1544         },
1545         {
1546             'persist' : 'hidden width ordinal',
1547             'id' : 'transit_source',
1548             'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_source'),
1549             'flex' : 1,
1550             'primary' : false,
1551             'hidden' : false,
1552             'editable' : false, 'render' : function(my) {
1553                 if (typeof my.atc.source() == "object") {
1554                     return my.atc.source().shortname();
1555                 } else {
1556                     return data.hash.aou[ my.atc.source() ].shortname();
1557                 }
1558             }
1559         },
1560         {
1561             'persist' : 'hidden width ordinal',
1562             'id' : 'transit_source_send_time',
1563             'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_source_send_time'),
1564             'flex' : 1,
1565             'sort_type' : 'date',
1566             'primary' : false,
1567             'hidden' : false,
1568             'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.atc.source_send_time(), '%{localized}' ); }
1569         },
1570         {
1571             'persist' : 'hidden width ordinal',
1572             'id' : 'transit_dest_lib',
1573             'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_dest'),
1574             'flex' : 1,
1575             'primary' : false,
1576             'hidden' : false,
1577             'editable' : false, 'render' : function(my) {
1578                 if (typeof my.atc.dest() == "object") {
1579                     return my.atc.dest().shortname();
1580                 } else {
1581                     return data.hash.aou[ my.atc.dest() ].shortname();
1582                 }
1583             }
1584         },
1585         {
1586             'persist' : 'hidden width ordinal',
1587             'id' : 'transit_dest_recv_time',
1588             'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_dest_recv_time'),
1589             'flex' : 1,
1590             'sort_type' : 'date',
1591             'primary' : false,
1592             'hidden' : false,
1593             'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.atc.dest_recv_time(), '%{localized}' ); }
1594         },
1595         {
1596             'persist' : 'hidden width ordinal',
1597             'id' : 'transit_target_copy',
1598             'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_target_copy'),
1599             'flex' : 1,
1600             'primary' : false,
1601             'hidden' : true,
1602             'editable' : false, 'render' : function(my) { return my.atc.target_copy(); }
1603         },
1604     ];
1605     for (var i = 0; i < c.length; i++) {
1606         if (modify[ c[i].id ]) {
1607             for (var j in modify[ c[i].id ]) {
1608                 c[i][j] = modify[ c[i].id ][j];
1609             }
1610         }
1611     }
1612     if (params) {
1613         if (params.just_these) {
1614             JSAN.use('util.functional');
1615             var new_c = [];
1616             for (var i = 0; i < params.just_these.length; i++) {
1617                 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
1618                 new_c.push( function(y){ return y; }( x ) );
1619             }
1620             c = new_c;
1621         }
1622         if (params.except_these) {
1623             JSAN.use('util.functional');
1624             var new_c = [];
1625             for (var i = 0; i < c.length; i++) {
1626                 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
1627                 if (!x) new_c.push(c[i]);
1628             }
1629             c = new_c;
1630         }
1631
1632     }
1633     return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
1634 };
1635
1636 circ.util.hold_columns = function(modify,params) {
1637
1638     JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
1639
1640     var c = [
1641         {
1642             'id' : 'post_clear_shelf_action',
1643             'flex' : 1, 'primary' : false, 'hidden' : true, 'editable' : false, 
1644             'label' : document.getElementById('circStrings').getString('staff.circ.utils.hold_post_clear_shelf_action.label'),
1645             'render' : function(my) { 
1646                 return my.post_clear_shelf_action ? document.getElementById('circStrings').getString('staff.circ.utils.hold_post_clear_shelf_action.' + my.post_clear_shelf_action) : '';
1647             }
1648         },
1649         {
1650             'persist' : 'hidden width ordinal',
1651             'id' : 'cancel_time',
1652             'label' : document.getElementById('circStrings').getString('staff.circ.utils.hold_cancel_time'),
1653             'flex' : 1,
1654             'sort_type' : 'date',
1655             'primary' : false,
1656             'hidden' : true,
1657             'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.ahr.cancel_time(), '%{localized}' ); }
1658         },
1659         {
1660             'persist' : 'hidden width ordinal',
1661             'id' : 'cancel_cause',
1662             'label' : document.getElementById('circStrings').getString('staff.circ.utils.hold_cancel_cause'),
1663             'flex' : 1,
1664             'primary' : false,
1665             'hidden' : true,
1666             'editable' : false, 'render' : function(my) { return typeof my.ahr.cancel_cause == 'object' ? my.ahr.cancel_cause().label() : data.hash.ahrcc[ my.ahr.cancel_cause() ].label(); }
1667         },
1668         {
1669             'persist' : 'hidden width ordinal',
1670             'id' : 'cancel_note',
1671             'label' : document.getElementById('circStrings').getString('staff.circ.utils.hold_cancel_note'),
1672             'flex' : 1,
1673             'primary' : false,
1674             'hidden' : true,
1675             'editable' : false, 'render' : function(my) { return my.ahr.cancel_note(); }
1676         },
1677         {
1678             'persist' : 'hidden width ordinal',
1679             'id' : 'request_lib',
1680             'label' : document.getElementById('circStrings').getString('staff.circ.utils.request_lib'),
1681             'flex' : 1,
1682             'primary' : false,
1683             'hidden' : true,
1684             'editable' : false, 'render' : function(my) {
1685                 if (Number(my.ahr.request_lib())>=0) {
1686                     return data.hash.aou[ my.ahr.request_lib() ].name();
1687                 } else {
1688                     return my.ahr.request_lib().name();
1689                 }
1690             }
1691         },
1692         {
1693             'persist' : 'hidden width ordinal',
1694             'id' : 'request_lib_shortname',
1695             'label' : document.getElementById('circStrings').getString('staff.circ.utils.request_lib_shortname'),
1696             'flex' : 0,
1697             'primary' : false,
1698             'hidden' : true,
1699             'editable' : false, 'render' : function(my) {
1700                 if (Number(my.ahr.request_lib())>=0) {
1701                     return data.hash.aou[ my.ahr.request_lib() ].shortname();
1702                 } else {
1703                     return my.ahr.request_lib().shortname();
1704                 }
1705             }
1706         },
1707         {
1708             'persist' : 'hidden width ordinal',
1709             'id' : 'request_time',
1710             'label' : document.getElementById('circStrings').getString('staff.circ.utils.request_time'),
1711             'flex' : 0,
1712             'sort_type' : 'date',
1713             'primary' : false,
1714             'hidden' : true,
1715             'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.ahr.request_time(), '%{localized}' ); }
1716         },
1717         {
1718             'persist' : 'hidden width ordinal',
1719             'id' : 'shelf_time',
1720             'label' : document.getElementById('circStrings').getString('staff.circ.utils.holds.shelf_time'),
1721             'flex' : 0,
1722             'sort_type' : 'date',
1723             'primary' : false,
1724             'hidden' : true,
1725             'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.ahr.shelf_time(), '%{localized}' ); }
1726         },
1727         {
1728             'persist' : 'hidden width ordinal',
1729             'id' : 'shelf_expire_time',
1730             'label' : document.getElementById('circStrings').getString('staff.circ.utils.holds.shelf_expire_time'),
1731             'flex' : 0,
1732             'sort_type' : 'date',
1733             'primary' : false,
1734             'hidden' : true,
1735             'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.ahr.shelf_expire_time(), '%{localized}' ); }
1736         },
1737         {
1738             'persist' : 'hidden width ordinal',
1739             'id' : 'available_time',
1740             'label' : document.getElementById('circStrings').getString('staff.circ.utils.available_time'),
1741             'flex' : 1,
1742             'sort_type' : 'date',
1743             'primary' : false,
1744             'hidden' : false,
1745             'editable' : false, 'render' : function(my) {
1746                 if (my.ahr.transit() && my.ahr.transit().dest_recv_time()) {
1747                     return util.date.formatted_date( my.ahr.transit().dest_recv_time(), '%{localized}' );
1748                 }
1749                 if (!my.ahr.transit() && my.ahr.capture_time()) {
1750                     return util.date.formatted_date( my.ahr.capture_time(), '%{localized}' );
1751                 }
1752                 return "";
1753             }
1754         },
1755         {
1756             'persist' : 'hidden width ordinal',
1757             'id' : 'capture_time',
1758             'label' : document.getElementById('circStrings').getString('staff.circ.utils.capture_time'),
1759             'flex' : 1,
1760             'sort_type' : 'date',
1761             'primary' : false,
1762             'hidden' : true,
1763             'editable' : false, 'render' : function(my) { return my.ahr.capture_time() ? util.date.formatted_date( my.ahr.capture_time(), '%{localized}' ) : ""; }
1764         },
1765         {
1766             'persist' : 'hidden width ordinal',
1767             'id' : 'ahr_status',
1768             'label' : document.getElementById('commonStrings').getString('staff.ahr_status_label'),
1769             'flex' : 1,
1770             'primary' : false,
1771             'hidden' : false,
1772             'editable' : false, 'render' : function(my) {
1773                 switch (Number(my.status)) {
1774                     case 1:
1775                         return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.1');
1776                         break;
1777                     case 2:
1778                         return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.2');
1779                         break;
1780                     case 3:
1781                         return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.3');
1782                         break;
1783                     case 4:
1784                         return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.4');
1785                         break;
1786                     case 5:
1787                         return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.5');
1788                         break;
1789                     case 6:
1790                         return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.6');
1791                         break;
1792                     default:
1793                         return my.status;
1794                         break;
1795                 };
1796             }
1797         },
1798         {
1799             'persist' : 'hidden width ordinal',
1800             'id' : 'hold_type',
1801             'label' : document.getElementById('commonStrings').getString('staff.ahr_hold_type_label'),
1802             'flex' : 0,
1803             'primary' : false,
1804             'hidden' : true,
1805             'editable' : false, 'render' : function(my) { return my.ahr.hold_type(); }
1806         },
1807         {
1808             'persist' : 'hidden width ordinal',
1809             'id' : 'ahr_mint_condition',
1810             'label' : document.getElementById('circStrings').getString('staff.circ.utils.ahr_mint_condition'),
1811             'flex' : 0,
1812             'primary' : false,
1813             'hidden' : true,
1814             'editable' : false, 'render' : function(my) {
1815                 if (get_bool( my.ahr.mint_condition() )) {
1816                     return document.getElementById('circStrings').getString('staff.circ.utils.ahr_mint_condition.true');
1817                 } else {
1818                     return document.getElementById('circStrings').getString('staff.circ.utils.ahr_mint_condition.false');
1819                 }
1820             }
1821         },
1822         {
1823             'persist' : 'hidden width ordinal',
1824             'id' : 'frozen',
1825             'label' : document.getElementById('circStrings').getString('staff.circ.utils.active'),
1826             'flex' : 0,
1827             'primary' : false,
1828             'hidden' : true,
1829             'editable' : false, 'render' : function(my) {
1830                 if (!get_bool( my.ahr.frozen() )) {
1831                     return document.getElementById('circStrings').getString('staff.circ.utils.yes');
1832                 } else {
1833                     return document.getElementById('circStrings').getString('staff.circ.utils.no');
1834                 }
1835             }
1836         },
1837         {
1838             'persist' : 'hidden width ordinal',
1839             'id' : 'thaw_date',
1840             'label' : document.getElementById('circStrings').getString('staff.circ.utils.thaw_date'),
1841             'flex' : 0,
1842             'sort_type' : 'date',
1843             'primary' : false,
1844             'hidden' : true,
1845             'editable' : false, 'render' : function(my) {
1846                 if (my.ahr.thaw_date() == null) {
1847                     return document.getElementById('circStrings').getString('staff.circ.utils.thaw_date.none');
1848                 } else {
1849                     return util.date.formatted_date( my.ahr.thaw_date(), '%{localized}' );
1850                 }
1851             }
1852         },
1853         {
1854             'persist' : 'hidden width ordinal',
1855             'id' : 'pickup_lib',
1856             'label' : document.getElementById('circStrings').getString('staff.circ.utils.pickup_lib'),
1857             'flex' : 1,
1858             'primary' : false,
1859             'hidden' : true,
1860             'editable' : false, 'render' : function(my) {
1861                 if (Number(my.ahr.pickup_lib())>=0) {
1862                     return data.hash.aou[ my.ahr.pickup_lib() ].name();
1863                 } else {
1864                     return my.ahr.pickup_lib().name();
1865                 }
1866             }
1867         },
1868         {
1869             'persist' : 'hidden width ordinal',
1870             'id' : 'pickup_lib_shortname',
1871             'label' : document.getElementById('commonStrings').getString('staff.ahr_pickup_lib_label'),
1872             'flex' : 0,
1873             'primary' : false,
1874             'hidden' : true,
1875             'editable' : false, 'render' : function(my) {
1876                 if (Number(my.ahr.pickup_lib())>=0) {
1877                     return data.hash.aou[ my.ahr.pickup_lib() ].shortname();
1878                 } else {
1879                     return my.ahr.pickup_lib().shortname();
1880                 }
1881             }
1882         },
1883         {
1884             'persist' : 'hidden width ordinal',
1885             'id' : 'current_copy',
1886             'label' : document.getElementById('commonStrings').getString('staff.ahr_current_copy_label'),
1887             'flex' : 1,
1888             'primary' : false,
1889             'hidden' : true,
1890             'editable' : false, 'render' : function(my) {
1891                 if (my.acp) {
1892                     return my.acp.barcode();
1893                 } else {
1894                     return document.getElementById('circStrings').getString('staff.circ.utils.current_copy.none');
1895                 }
1896             }
1897         },
1898         {
1899             'persist' : 'hidden width ordinal',
1900             'id' : 'current_copy_location',
1901             'label' : document.getElementById('commonStrings').getString('staff.ahr_current_copy_location_label'),
1902             'flex' : 1,
1903             'primary' : false,
1904             'hidden' : true,
1905             'editable' : false, 'render' : function(my) {
1906                 if (!my.acp) { return ""; } else { if (Number(my.acp.location())>=0) return data.lookup("acpl", my.acp.location() ).name(); else return my.acp.location().name(); }
1907             }
1908         },
1909         {
1910             'persist' : 'hidden width ordinal',
1911             'id' : 'email_notify',
1912             'label' : document.getElementById('commonStrings').getString('staff.ahr_email_notify_label'),
1913             'flex' : 1,
1914             'primary' : false,
1915             'hidden' : true,
1916             'editable' : false, 'render' : function(my) {
1917                 if (get_bool(my.ahr.email_notify())) {
1918                     return document.getElementById('circStrings').getString('staff.circ.utils.yes');
1919                 } else {
1920                     return document.getElementById('circStrings').getString('staff.circ.utils.no');
1921                 }
1922             }
1923         },
1924         {
1925             'persist' : 'hidden width ordinal',
1926             'id' : 'expire_date',
1927             'label' : document.getElementById('commonStrings').getString('staff.ahr_expire_date_label'),
1928             'flex' : 1,
1929             'sort_type' : 'date',
1930             'primary' : false,
1931             'hidden' : true,
1932             'editable' : false, 'render' : function(my) { return my.ahr.expire_time() ? util.date.formatted_date( my.ahr.expire_time(), '%{localized}' ) : ''; }
1933         },
1934         {
1935             'persist' : 'hidden width ordinal',
1936             'id' : 'fulfillment_time',
1937             'label' : document.getElementById('commonStrings').getString('staff.ahr_fulfillment_time_label'),
1938             'flex' : 1,
1939             'sort_type' : 'date',
1940             'primary' : false,
1941             'hidden' : true,
1942             'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.ahr.fulfillment_time(), '%{localized}' ); }
1943         },
1944         {
1945             'persist' : 'hidden width ordinal',
1946             'id' : 'holdable_formats',
1947             'label' : document.getElementById('commonStrings').getString('staff.ahr_holdable_formats_label'),
1948             'flex' : 1,
1949             'primary' : false,
1950             'hidden' : true,
1951             'editable' : false, 'render' : function(my) { return my.ahr.holdable_formats(); }
1952         },
1953         {
1954             'persist' : 'hidden width ordinal',
1955             'id' : 'holdable_part',
1956             'label' : document.getElementById('commonStrings').getString('staff.ahr_holdable_part_label'),
1957             'flex' : 1,
1958             'primary' : false,
1959             'hidden' : true,
1960             'editable' : false, 'render' : function(my) { return my.part.label(); }
1961         },
1962         {
1963             'persist' : 'hidden width ordinal',
1964             'id' : 'issuance_label',
1965             'label' : document.getElementById('commonStrings').getString('staff.ahr_issuance_label_label'),
1966             'flex' : 1,
1967             'primary' : false,
1968             'hidden' : true,
1969             'editable' : false, 'render' : function(my) { return my.issuance.label(); }
1970         },
1971         {
1972             'persist' : 'hidden width ordinal',
1973             'id' : 'ahr_id',
1974             'label' : document.getElementById('commonStrings').getString('staff.ahr_id_label'),
1975             'flex' : 1,
1976             'primary' : false,
1977             'hidden' : true,
1978             'editable' : false, 'render' : function(my) { return my.ahr.id(); }
1979         },
1980         {
1981             'persist' : 'hidden width ordinal',
1982             'id' : 'phone_notify',
1983             'label' : document.getElementById('commonStrings').getString('staff.ahr_phone_notify_label'),
1984             'flex' : 1,
1985             'primary' : false,
1986             'hidden' : true,
1987             'editable' : false, 'render' : function(my) { return my.ahr.phone_notify(); }
1988         },
1989         {
1990             'persist' : 'hidden width ordinal',
1991             'id' : 'prev_check_time',
1992             'label' : document.getElementById('commonStrings').getString('staff.ahr_prev_check_time_label'),
1993             'flex' : 1,
1994             'sort_type' : 'date',
1995             'primary' : false,
1996             'hidden' : true,
1997             'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.ahr.prev_check_time(), '%{localized}' ); }
1998         },
1999         {
2000             'persist' : 'hidden width ordinal',
2001             'id' : 'requestor',
2002             'label' : document.getElementById('commonStrings').getString('staff.ahr_requestor_label'),
2003             'flex' : 1,
2004             'primary' : false,
2005             'hidden' : true,
2006             'editable' : false, 'render' : function(my) { return my.ahr.requestor(); }
2007         },
2008         {
2009             'persist' : 'hidden width ordinal',
2010             'id' : 'selection_depth',
2011             'label' : document.getElementById('commonStrings').getString('staff.ahr_selection_depth_label'),
2012             'flex' : 1,
2013             'primary' : false,
2014             'hidden' : true,
2015             'editable' : false, 'render' : function(my) { return my.ahr.selection_depth(); }
2016         },
2017         {
2018             'persist' : 'hidden width ordinal',
2019             'id' : 'top_of_queue',
2020             'label' : document.getElementById('commonStrings').getString('staff.ahr_top_of_queue_label'),
2021             'flex' : 1,
2022             'primary' : false,
2023             'hidden' : true,
2024             'editable' : false, 'render' : function(my) { return get_bool( my.ahr.cut_in_line() ) ? document.getElementById('commonStrings').getString('common.yes') : document.getElementById('commonStrings').getString('common.no') ; }
2025         },
2026         {
2027             'persist' : 'hidden width ordinal',
2028             'id' : 'target',
2029             'label' : document.getElementById('commonStrings').getString('staff.ahr_target_label'),
2030             'flex' : 1,
2031             'primary' : false,
2032             'hidden' : true,
2033             'editable' : false, 'render' : function(my) { return my.ahr.target(); }
2034         },
2035         {
2036             'persist' : 'hidden width ordinal',
2037             'id' : 'usr',
2038             'label' : document.getElementById('commonStrings').getString('staff.ahr_usr_label'),
2039             'flex' : 1,
2040             'primary' : false,
2041             'hidden' : true,
2042             'editable' : false, 'render' : function(my) { return my.ahr.usr(); }
2043         },
2044         {
2045             'persist' : 'hidden width ordinal',
2046             'id' : 'title',
2047             'label' : document.getElementById('commonStrings').getString('staff.mvr_label_title'),
2048             'flex' : 1,
2049             'sort_type' : 'title',
2050             'primary' : false,
2051             'hidden' : true,
2052             'editable' : false, 'render' : function(my) {
2053                 if (my.mvr) {
2054                     return my.mvr.title();
2055                 } else {
2056                     return document.getElementById('circStrings').getString('staff.circ.utils.title.none');
2057                 }
2058             }
2059         },
2060         {
2061             'persist' : 'hidden width ordinal',
2062             'id' : 'author',
2063             'label' : document.getElementById('commonStrings').getString('staff.mvr_label_author'),
2064             'flex' : 1,
2065             'primary' : false,
2066             'hidden' : true,
2067             'editable' : false, 'render' : function(my) {
2068                 if (my.mvr) {
2069                     return my.mvr.author();
2070                 } else {
2071                     return document.getElementById('circStrings').getString('staff.circ.utils.author.none');
2072                 }
2073             }
2074         },
2075         {
2076             'persist' : 'hidden width ordinal',
2077             'id' : 'edition',
2078             'label' : document.getElementById('circStrings').getString('staff.circ.utils.edition'),
2079             'flex' : 1,
2080             'primary' : false,
2081             'hidden' : true,
2082             'editable' : false, 'render' : function(my) { return my.mvr.edition(); }
2083         },
2084         {
2085             'persist' : 'hidden width ordinal',
2086             'id' : 'isbn',
2087             'label' : document.getElementById('circStrings').getString('staff.circ.utils.isbn'),
2088             'flex' : 1,
2089             'primary' : false,
2090             'hidden' : true,
2091             'editable' : false, 'render' : function(my) { return my.mvr.isbn(); }
2092         },
2093         {
2094             'persist' : 'hidden width ordinal',
2095             'id' : 'pubdate',
2096             'label' : document.getElementById('circStrings').getString('staff.circ.utils.pubdate'),
2097             'flex' : 1,
2098             'primary' : false,
2099             'hidden' : true,
2100             'editable' : false, 'render' : function(my) { return my.mvr.pubdate(); }
2101         },
2102         {
2103             'persist' : 'hidden width ordinal',
2104             'id' : 'publisher',
2105             'label' : document.getElementById('circStrings').getString('staff.circ.utils.publisher'),
2106             'flex' : 1,
2107             'primary' : false,
2108             'hidden' : true,
2109             'editable' : false, 'render' : function(my) { return my.mvr.publisher(); }
2110         },
2111         {
2112             'persist' : 'hidden width ordinal',
2113             'id' : 'tcn',
2114             'label' : document.getElementById('circStrings').getString('staff.circ.utils.tcn'),
2115             'flex' : 1,
2116             'primary' : false,
2117             'hidden' : true,
2118             'editable' : false, 'render' : function(my) { return my.mvr.tcn(); }
2119         },
2120         {
2121             'persist' : 'hidden width ordinal',
2122             'id' : 'notify_time',
2123             'label' : document.getElementById('circStrings').getString('staff.circ.utils.notify_time'),
2124             'flex' : 1,
2125             'sort_type' : 'date',
2126             'primary' : false,
2127             'hidden' : true,
2128             'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.ahr.notify_time(), '%{localized}' ); }
2129         },
2130         {
2131             'persist' : 'hidden width ordinal',
2132             'id' : 'notify_count',
2133             'label' : document.getElementById('circStrings').getString('staff.circ.utils.notify_count'),
2134             'flex' : 1,
2135             'primary' : false,
2136             'hidden' : true,
2137             'editable' : false, 'render' : function(my) { return my.ahr.notify_count(); }
2138         },
2139         {
2140             'persist' : 'hidden width ordinal',
2141             'id' : 'transit_source',
2142             'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_source'),
2143             'flex' : 1,
2144             'primary' : false,
2145             'hidden' : true,
2146             'editable' : false, 'render' : function(my) {
2147                 if (my.ahr.transit()) {
2148                     return data.hash.aou[ my.ahr.transit().source() ].shortname();
2149                 } else {
2150                     return "";
2151                 }
2152             }
2153         },
2154         {
2155             'persist' : 'hidden width ordinal',
2156             'id' : 'transit_source_send_time',
2157             'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_source_send_time'),
2158             'flex' : 1,
2159             'sort_type' : 'date',
2160             'primary' : false,
2161             'hidden' : true,
2162             'editable' : false, 'render' : function(my) { return my.ahr.transit() ?  util.date.formatted_date( my.ahr.transit().source_send_time(), '%{localized}' ) : ""; }
2163         },
2164         {
2165             'persist' : 'hidden width ordinal',
2166             'id' : 'transit_dest_lib',
2167             'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_dest'),
2168             'flex' : 1,
2169             'primary' : false,
2170             'hidden' : true,
2171             'editable' : false, 'render' : function(my) { return my.ahr.transit() ?  data.hash.aou[ my.ahr.transit().dest() ].shortname() : ""; }
2172         },
2173         {
2174             'persist' : 'hidden width ordinal',
2175             'id' : 'transit_dest_recv_time',
2176             'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_dest_recv_time'),
2177             'flex' : 1,
2178             'sort_type' : 'date',
2179             'primary' : false,
2180             'hidden' : true,
2181             'editable' : false, 'render' : function(my) { return my.ahr.transit() ?  util.date.formatted_date( my.ahr.transit().dest_recv_time(), '%{localized}' ) : ""; }
2182         },
2183         {
2184             'persist' : 'hidden width ordinal',
2185             'id' : 'patron_barcode',
2186             'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.patron_barcode'),
2187             'flex' : 1,
2188             'primary' : false,
2189             'hidden' : true,
2190             'editable' : false, 'render' : function(my) { return my.patron_barcode ? my.patron_barcode : ""; }
2191         },
2192         {
2193             'persist' : 'hidden width ordinal',
2194             'id' : 'patron_family_name',
2195             'label' : document.getElementById('circStrings').getString('staff.circ.utils.patron_family_name'),
2196             'flex' : 1,
2197             'primary' : false,
2198             'hidden' : true,
2199             'editable' : false, 'render' : function(my) { return my.patron_family_name ? my.patron_family_name : ""; }
2200         },
2201         {
2202             "persist": "hidden width ordinal",
2203             "id": "patron_alias",
2204             'label' : document.getElementById('circStrings').getString('staff.circ.utils.patron_alias'),
2205             'flex' : 1,
2206             'primary' : false,
2207             'hidden' : true,
2208             'editable' : false, 'render' : function(my) { return my.patron_alias ? my.patron_alias : ""; }
2209         },
2210         {
2211             'persist' : 'hidden width ordinal',
2212             'id' : 'patron_first_given_name',
2213             'label' : document.getElementById('circStrings').getString('staff.circ.utils.patron_first_given_name'),
2214             'flex' : 1,
2215             'primary' : false,
2216             'hidden' : true,
2217             'editable' : false, 'render' : function(my) { return my.patron_first_given_name ? my.patron_first_given_name : ""; }
2218         },
2219         {
2220             'persist' : 'hidden width ordinal',
2221             'id' : 'callnumber',
2222             'label' : document.getElementById('circStrings').getString('staff.circ.utils.callnumber'),
2223             'flex' : 1,
2224             'primary' : false,
2225             'hidden' : true,
2226             'editable' : false, 'render' : function(my) { return my.acn.label(); }
2227         },
2228                 {
2229             'persist' : 'hidden width ordinal',
2230             'id' : 'total_holds',
2231             'label' : document.getElementById('circStrings').getString('staff.circ.utils.total_holds'),
2232             'flex' : 1,
2233             'primary' : false,
2234             'hidden' : true,
2235             'editable' : false, 'render' : function(my) { return my.total_holds; }
2236         },
2237                 {
2238             'persist' : 'hidden width ordinal',
2239             'id' : 'queue_position',
2240             'label' : document.getElementById('circStrings').getString('staff.circ.utils.queue_position'),
2241             'flex' : 1,
2242             'primary' : false,
2243             'hidden' : true,
2244             'editable' : false, 'render' : function(my) { return my.queue_position; }
2245         },
2246                 {
2247             'persist' : 'hidden width ordinal',
2248             'id' : 'potential_copies',
2249             'label' : document.getElementById('circStrings').getString('staff.circ.utils.potential_copies'),
2250             'flex' : 1,
2251             'primary' : false,
2252             'hidden' : true,
2253             'editable' : false, 'render' : function(my) { return my.potential_copies; }
2254         },
2255                 {
2256             'persist' : 'hidden width ordinal',
2257             'id' : 'estimated_wait',
2258             'label' : document.getElementById('circStrings').getString('staff.circ.utils.estimated_wait'),
2259             'flex' : 1,
2260             'primary' : false,
2261             'hidden' : true,
2262             'editable' : false, 'render' : function(my) { return my.estimated_wait; }
2263         },
2264         {
2265             'persist' : 'hidden width ordinal',
2266             'id' : 'hold_note',
2267             'label' : document.getElementById('circStrings').getString('staff.circ.utils.hold_note'),
2268             'flex' : 1,
2269             'primary' : false,
2270             'hidden' : true,
2271             'editable' : false, 'render' : function(my) { return my.ahrn_count; }
2272         },
2273         {
2274             'persist' : 'hidden width ordinal',
2275             'id' : 'staff_hold',
2276             'label' : document.getElementById('circStrings').getString('staff.circ.utils.staff_hold'),
2277             'flex' : 1,
2278             'primary' : false,
2279             'hidden' : true,
2280             'editable' : false, 
2281             'render' : function(my) {
2282                 if (my.ahr.usr() != my.ahr.requestor()){
2283                     return document.getElementById('circStrings').getString('staff.circ.utils.yes');
2284                 } else {
2285                     return document.getElementById('circStrings').getString('staff.circ.utils.no');
2286                 }
2287             }
2288         }
2289     ];
2290     for (var i = 0; i < c.length; i++) {
2291         if (modify[ c[i].id ]) {
2292             for (var j in modify[ c[i].id ]) {
2293                 c[i][j] = modify[ c[i].id ][j];
2294             }
2295         }
2296     }
2297     if (params) {
2298         if (params.just_these) {
2299             JSAN.use('util.functional');
2300             var new_c = [];
2301             for (var i = 0; i < params.just_these.length; i++) {
2302                 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
2303                 new_c.push( function(y){ return y; }( x ) );
2304             }
2305             c = new_c;
2306         }
2307         if (params.except_these) {
2308             JSAN.use('util.functional');
2309             var new_c = [];
2310             for (var i = 0; i < c.length; i++) {
2311                 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
2312                 if (!x) new_c.push(c[i]);
2313             }
2314             c = new_c;
2315         }
2316
2317     }
2318     return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
2319 };
2320 /*
2321 circ.util.std_map_row_to_column = function(error_value) {
2322     return function(row,col) {
2323         // row contains { 'my' : { 'acp' : {}, 'circ' : {}, 'mvr' : {} } }
2324         // col contains one of the objects listed above in columns
2325
2326         // mimicking some of the obj in circ.checkin and circ.checkout where map_row_to_column is usually defined
2327         var obj = {};
2328         JSAN.use('util.error'); obj.error = new util.error();
2329         JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
2330         JSAN.use('util.network'); obj.network = new util.network();
2331         JSAN.use('util.money');
2332
2333         var my = row.my;
2334         var value;
2335         try {
2336             value = eval( col.render );
2337         } catch(E) {
2338             obj.error.sdump('D_WARN','map_row_to_column: ' + E);
2339             if (error_value) value = error_value; else value = '   ';
2340         }
2341         return value;
2342     }
2343 };
2344 */
2345 circ.util.std_map_row_to_columns = function(error_value) {
2346     return function(row,cols,scratch) {
2347         // row contains { 'my' : { 'acp' : {}, 'circ' : {}, 'mvr' : {} } }
2348         // cols contains all of the objects listed above in columns
2349         // scratch is a temporary space shared by all cells/rows (or just per row if not explicitly passed in)
2350         if (!scratch) { scratch = {}; }
2351
2352         var obj = {};
2353         JSAN.use('util.error'); obj.error = new util.error();
2354         JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
2355         JSAN.use('util.network'); obj.network = new util.network();
2356         JSAN.use('util.money');
2357
2358         var my = row.my;
2359         var values = [];
2360         var cmd = '';
2361         try {
2362             for (var i = 0; i < cols.length; i++) {
2363                 switch (typeof cols[i].render) {
2364                     case 'function': try { values[i] = cols[i].render(my,scratch); } catch(E) { values[i] = error_value; obj.error.sdump('D_COLUMN_RENDER_ERROR',E); } break;
2365                     case 'string' : cmd += 'try { ' + cols[i].render + '; values['+i+'] = v; } catch(E) { values['+i+'] = error_value; }'; break;
2366                     default: cmd += 'values['+i+'] = "??? '+(typeof cols[i].render)+'"; ';
2367                 }
2368             }
2369             if (cmd) eval( cmd );
2370         } catch(E) {
2371             obj.error.sdump('D_WARN','map_row_to_column: ' + E);
2372             if (error_value) { value = error_value; } else { value = '   ' };
2373         }
2374         return values;
2375     }
2376 };
2377
2378 circ.util.checkin_via_barcode = function(session,params,backdate,auto_print,async) {
2379     try {
2380         JSAN.use('util.error'); var error = new util.error();
2381         JSAN.use('util.network'); var network = new util.network();
2382         JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
2383         JSAN.use('util.date'); JSAN.use('util.functional');
2384
2385         if (backdate && (backdate == util.date.formatted_date(new Date(),'%Y-%m-%d')) ) backdate = null;
2386
2387         //var params = { 'barcode' : barcode };
2388         if (backdate) params.backdate = util.date.formatted_date(backdate,'%{iso8601}');
2389
2390         if (typeof params.disable_textbox == 'function') {
2391             try { params.disable_textbox(); }
2392             catch(E) { error.sdump('D_ERROR','params.disable_textbox() = ' + E); };
2393         }
2394
2395         function checkin_callback(req) {
2396             JSAN.use('util.error'); var error = new util.error();
2397             try {
2398                 var check = req.getResultObject();
2399                 var r = circ.util.checkin_via_barcode2(session,params,backdate,auto_print,check);
2400                 try {
2401                     error.work_log(
2402                         document.getElementById('circStrings').getFormattedString(
2403                             'staff.circ.work_log_checkin_attempt.' + r.what_happened + '.message',
2404                             [
2405                                 ses('staff_usrname'),
2406                                 r.payload.patron ? r.payload.patron.family_name() : '',
2407                                 r.payload.patron ? r.payload.patron.card().barcode() : '',
2408                                 r.payload.copy ? r.payload.copy.barcode() : '',
2409                                 r.route_to ? r.route_to : ''
2410                             ]
2411                         ), {
2412                             'au_id' : r.payload.patron ? r.payload.patron.id() : '',
2413                             'au_family_name' : r.payload.patron ? r.payload.patron.family_name() : '',
2414                             'au_barcode' : r.payload.patron ? r.payload.patron.card().barcode() : '',
2415                             'acp_barcode' : r.payload.copy ? r.payload.copy.barcode() : ''
2416                         }
2417                     );
2418                 } catch(E) {
2419                     error.sdump('D_ERROR','Error with work_logging in server/circ/checkout.js, _checkout:' + E);
2420                 }
2421
2422                 if (typeof params.checkin_result == 'function') {
2423                     try { params.checkin_result(r); } catch(E) { error.sdump('D_ERROR','params.checkin_result() = ' + E); };
2424                 }
2425                 if (typeof async == 'function') async(check);
2426                 return check;
2427             } catch(E) {
2428                 error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.error', ['1']), E);
2429                 if (typeof params.enable_textbox == 'function') {
2430                     try { params.enable_textbox(); }
2431                     catch(E) { error.sdump('D_ERROR','params.disable_textbox() = ' + E); };
2432                 }
2433                 return null;
2434             }
2435         }
2436
2437         var suppress_popups = data.hash.aous['ui.circ.suppress_checkin_popups'];
2438
2439         var check = network.request(
2440             api.CHECKIN_VIA_BARCODE.app,
2441             api.CHECKIN_VIA_BARCODE.method,
2442             [ session, util.functional.filter_object( params, function(i,o) { return typeof o != 'function'; } ) ],
2443             async ? checkin_callback : null,
2444             {
2445                 'title' : document.getElementById('circStrings').getString('staff.circ.utils.checkin.override'),
2446                 'auto_override_these_events' : suppress_popups ? [
2447                     null /* custom event */,
2448                     1203 /* COPY_BAD_STATUS */,
2449                     1213 /* PATRON_BARRED */,
2450                     1217 /* PATRON_INACTIVE */,
2451                     1224 /* PATRON_ACCOUNT_EXPIRED */,
2452                     1234 /* ITEM_DEPOSIT_PAID */,
2453                     7009 /* CIRC_CLAIMS_RETURNED */,
2454                     7010 /* COPY_ALERT_MESSAGE */,
2455                     7011 /* COPY_STATUS_LOST */,
2456                     7012 /* COPY_STATUS_MISSING */,
2457                     7013 /* PATRON_EXCEEDS_FINES */
2458                 ] : [],
2459                 'overridable_events' : [
2460                     null /* custom event */,
2461                     1203 /* COPY_BAD_STATUS */,
2462                     1213 /* PATRON_BARRED */,
2463                     1217 /* PATRON_INACTIVE */,
2464                     1224 /* PATRON_ACCOUNT_EXPIRED */,
2465                     1234 /* ITEM_DEPOSIT_PAID */,
2466                     7009 /* CIRC_CLAIMS_RETURNED */,
2467                     7010 /* COPY_ALERT_MESSAGE */,
2468                     7011 /* COPY_STATUS_LOST */,
2469                     7012 /* COPY_STATUS_MISSING */,
2470                     7013 /* PATRON_EXCEEDS_FINES */
2471                 ],
2472                 'text' : {
2473                     '1203' : function(r) {
2474                         return typeof r.payload.status() == 'object' ? r.payload.status().name() : data.hash.ccs[ r.payload.status() ].name();
2475                     },
2476                     '1234' : function(r) {
2477                         return document.getElementById('circStrings').getString('staff.circ.utils.checkin.override.item_deposit_paid.warning');
2478                     },
2479                     '7010' : function(r) {
2480                         return r.payload;
2481                     }
2482                 }
2483             }
2484         );
2485         if (! async ) {
2486             return checkin_callback( { 'getResultObject' : function() { return check; } } );
2487         }
2488
2489
2490     } catch(E) {
2491         JSAN.use('util.error'); var error = new util.error();
2492         error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.error', ['2']), E);
2493         if (typeof params.enable_textbox == 'function') {
2494             try { params.enable_textbox(); } catch(E) { error.sdump('D_ERROR','params.disable_textbox() = ' + E); };
2495         }
2496         return null;
2497     }
2498 };
2499
2500 circ.util.checkin_via_barcode2 = function(session,params,backdate,auto_print,check) {
2501     try {
2502         JSAN.use('util.error'); var error = new util.error();
2503         JSAN.use('util.network'); var network = new util.network();
2504         JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
2505         JSAN.use('util.date');
2506         JSAN.use('util.sound'); var sound = new util.sound();
2507
2508         dump('check = ' + error.pretty_print( js2JSON( check ) ) + '\n' );
2509
2510         check.message = check.textcode;
2511
2512         if (check.payload && check.payload.copy) { check.copy = check.payload.copy; }
2513         if (check.payload && check.payload.volume) { check.volume = check.payload.volume; }
2514         if (check.payload && check.payload.record) { check.record = check.payload.record; }
2515         if (check.payload && check.payload.circ) { check.circ = check.payload.circ; }
2516         if (check.payload && check.payload.patron) { check.patron = check.payload.patron; }
2517
2518         if (!check.route_to) { check.route_to = '   '; }
2519
2520         var no_change_label = document.getElementById('no_change_label');
2521
2522         if (no_change_label) {
2523             no_change_label.setAttribute('value','');
2524             no_change_label.setAttribute('hidden','true');
2525             no_change_label.setAttribute('onclick','');
2526             removeCSSClass(no_change_label,'click_link');
2527             no_change_label.setAttribute('unique_row_counter','');
2528         }
2529
2530         var msg = '';
2531         var print_list = [];
2532         var print_data = { 
2533             'error' : '',
2534             'error_msg' : '',
2535             'cancelled' : '',
2536             'route_to' : '',
2537             'route_to_msg' : '',
2538             'route_to_org_fullname' : '',
2539             'destination_shelf' : '',
2540             'destination_shelf_msg' : '',
2541             'courier_code' : '',
2542             'street1' : '',
2543             'street2' : '',
2544             'city_state_zip' : '',
2545             'city' : '',
2546             'state' : '',
2547             'county' : '',
2548             'country' : '',
2549             'post_code' : '',
2550             'item_barcode' : '',
2551             'item_barcode_msg' : '',
2552             'item_title' : '',
2553             'item_title_msg' : '',
2554             'item_author' : '',
2555             'item_author_msg' : '',
2556             'hold_for_msg' : '',
2557             'hold_for_alias' : '',
2558             'hold_for_family_name' : '',
2559             'hold_for_first_given_name' : '',
2560             'hold_for_second_given_name' : '',
2561             'user_barcode' : '',
2562             'user_barcode_msg' : '',
2563             'notify_by_phone' : '',
2564             'notify_by_phone_msg' : '',
2565             'notify_by_email' : '',
2566             'notify_by_email_msg' : '',
2567             'request_date' : '',
2568             'request_date_msg' : '',
2569             'shelf_expire_time' : '',
2570             'slip_date' : '',
2571             'slip_date_msg' : '',
2572             'user' : '',
2573             'user_stat_cat_entries' : ''
2574         };
2575
2576         if (check.payload && check.payload.cancelled_hold_transit) {
2577             print_data.cancelled = document.getElementById('circStrings').getString('staff.circ.utils.transit_hold_cancelled');
2578             msg += print_data.cancelled;
2579             msg += '\n\n';
2580         }
2581
2582         /* SUCCESS  /  NO_CHANGE  /  ITEM_NOT_CATALOGED */
2583         if (check.ilsevent == 0 || check.ilsevent == 3 || check.ilsevent == 1202) {
2584             try { check.route_to = data.lookup('acpl', check.copy.location() ).name(); }
2585             catch(E) {
2586                 print_data.error_msg = document.getElementById('commonStrings').getString('common.error');
2587                 print_data.error_msg += '\nFIXME: ' + E + '\n';
2588                 msg += print_data.error_msg;
2589             }
2590             if (check.ilsevent == 3 /* NO_CHANGE */) {
2591                 //msg = 'This item is already checked in.\n';
2592                 check.what_happened = 'no_change';
2593                 if (no_change_label) {
2594                     var m = no_change_label.getAttribute('value');
2595                     var text = document.getElementById('circStrings').getFormattedString('staff.circ.utils.item_checked_in', [params.barcode]);
2596                     no_change_label.setAttribute('value', m + text + '  ');
2597                     no_change_label.setAttribute('hidden','false');
2598                     no_change_label.setAttribute('onclick','');
2599                     removeCSSClass(no_change_label,'click_link');
2600                     no_change_label.setAttribute('unique_row_counter','');
2601                     if (typeof params.info_blurb == 'function') {
2602                         params.info_blurb( text );
2603                     }
2604                 }
2605             }
2606             if (check.ilsevent == 1202 /* ITEM_NOT_CATALOGED */ && check.copy.status() != 11) {
2607                 check.what_happened = 'error';
2608                 var copy_status = (data.hash.ccs[ check.copy.status() ] ? data.hash.ccs[ check.copy.status() ].name() : check.copy.status().name() );
2609                 var err_msg = document.getElementById('commonStrings').getString('common.error');
2610                 err_msg += '\nFIXME --';
2611                 err_msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.item_not_cataloged', [copy_status]);
2612                 err_msg += '\n';
2613                 msg += err_msg;
2614                 print_data.error_msg += err_msg;
2615             }
2616             switch(Number(check.copy.status())) {
2617                 case 0: /* AVAILABLE */
2618                 case 7: /* RESHELVING */
2619                     check.what_happened = 'success';
2620                     if (msg) {
2621                         print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2622                         print_data.route_to = check.route_to;
2623                         msg += print_data.route_to_msg;
2624                         msg += '\n';
2625                     }
2626                 break;
2627                 case 8: /* ON HOLDS SHELF */
2628                     check.what_happened = 'hold_shelf';
2629                     check.route_to = document.getElementById('circStrings').getString('staff.circ.route_to.hold_shelf');
2630                     if (check.payload.hold) {
2631                         if (check.payload.hold.pickup_lib() != data.list.au[0].ws_ou()) {
2632                             check.what_happened = 'error';
2633                             var err_msg = document.getElementById('commonStrings').getString('common.error');
2634                             err_msg += '\nFIXME: ';
2635                             err_msg += document.getElementById('circStrings').getString('staff.circ.utils.route_item_error');
2636                             err_msg += '\n';
2637                             msg += err_msg;
2638                             print_data.error_msg += err_msg;
2639                         } else {
2640                             print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2641                             print_data.route_to = check.route_to;
2642                             var behind_the_desk_support = String( data.hash.aous['circ.holds.behind_desk_pickup_supported'] ) == 'true';
2643                             if (behind_the_desk_support) {
2644                                var usr_settings = network.simple_request('FM_AUS_RETRIEVE',[ses(),check.payload.hold.usr()]); 
2645                                 if (typeof usr_settings['circ.holds_behind_desk'] != 'undefined') {
2646                                     if (usr_settings['circ.holds_behind_desk']) {
2647                                         print_data.prefer_behind_holds_desk = true;
2648                                         check.route_to = document.getElementById('circStrings').getString('staff.circ.route_to.private_hold_shelf');
2649                                         print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2650                                         print_data.route_to = check.route_to;
2651                                     } else {
2652                                         check.route_to = document.getElementById('circStrings').getString('staff.circ.route_to.public_hold_shelf');
2653                                         print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2654                                         print_data.route_to = check.route_to;
2655                                     }
2656                                 } else {
2657                                     check.route_to = document.getElementById('circStrings').getString('staff.circ.route_to.public_hold_shelf');
2658                                     print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2659                                     print_data.route_to = check.route_to;
2660                                 }
2661                             }
2662                             print_data.destination_shelf_msg = print_data.route_to_msg;
2663                             print_data.destination_shelf = print_data.route_to;
2664                             msg += print_data.route_to_msg;
2665                             msg += '\n';
2666                         }
2667                     } else {
2668                         check.what_happened = 'error';
2669                         var err_msg = document.getElementById('commonStrings').getString('common.error');
2670                         err_msg += '\nFIXME: ';
2671                         err_msg += document.getElementById('circStrings').getString('staff.circ.utils.route_item_status_error');
2672                         err_msg += '\n';
2673                         msg += err_msg;
2674                         print_data.error_msg += err_msg;
2675                     }
2676                     JSAN.use('util.date');
2677                     if (check.payload.hold) {
2678                         JSAN.use('patron.util');
2679                         msg += '\n';
2680                         print_data.item_barcode_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [check.payload.copy.barcode()]);
2681                         print_data.item_barcode = check.payload.copy.barcode();
2682                         msg += print_data.item_barcode_msg;
2683                         msg += '\n';
2684                         var payload_title  = (check.payload.record ? check.payload.record.title() : check.payload.copy.dummy_title() );
2685                         print_data.item_title_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.title', [payload_title]);
2686                         print_data.item_title = payload_title;
2687                         msg += print_data.item_title_msg;
2688                         msg += '\n';
2689                         var au_obj = patron.util.retrieve_fleshed_au_via_id( session, check.payload.hold.usr() );
2690                         print_data.user = au_obj;
2691                         print_data.user_stat_cat_entries = [];
2692                         var entries = au_obj.stat_cat_entries();
2693                         for (var i = 0; i < entries.length; i++) {
2694                             var stat_cat = data.hash.my_actsc[ entries[i].stat_cat() ];
2695                             if (!stat_cat) {
2696                                 stat_cat = data.lookup('actsc', entries[i].stat_cat());
2697                             }
2698                             print_data.user_stat_cat_entries.push( { 
2699                                 'id' : entries[i].id(),
2700                                 'stat_cat' : {
2701                                     'id' : stat_cat.id(),
2702                                     'name' : stat_cat.name(),
2703                                     'opac_visible' : stat_cat.opac_visible(),
2704                                     'owner' : stat_cat.owner(),
2705                                     'usr_summary' : stat_cat.usr_summary()
2706                                 },
2707                                 'stat_cat_entry' : entries[i].stat_cat_entry(),
2708                                 'target_usr' : entries[i].target_usr() 
2709                             } );
2710                         }
2711                         msg += '\n';
2712                         if (au_obj.alias()) {
2713                             print_data.hold_for_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.patron_alias',  [au_obj.alias()]);
2714                             print_data.hold_for_alias = au_obj.alias();
2715                             msg += print_data.hold_for_msg;
2716                         } else {
2717                             print_data.hold_for_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.patron',  [au_obj.family_name() ? au_obj.family_name() : '', au_obj.first_given_name() ? au_obj.first_given_name() : '', au_obj.second_given_name() ? au_obj.second_given_name() : '']);
2718                             msg += print_data.hold_for_msg;
2719                             print_data.hold_for_family_name = au_obj.family_name() ? au_obj.family_name() : '';
2720                             print_data.hold_for_first_given_name = au_obj.first_given_name() ? au_obj.first_given_name() : '';
2721                             print_data.hold_for_second_given_name = au_obj.second_given_name() ? au_obj.second_given_name() : '';
2722                         }
2723                         msg += '\n';
2724                         print_data.user_barcode_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [au_obj.card().barcode()]);
2725                         print_data.user_barcode = au_obj.card().barcode();
2726                         msg += print_data.user_barcode_msg;
2727                         msg += '\n';
2728                         if (check.payload.hold.phone_notify()) {
2729                             print_data.notify_by_phone_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.phone_notify', [check.payload.hold.phone_notify()]);
2730                             print_data.notify_by_phone = check.payload.hold.phone_notify();
2731                             msg += print_data.notify_by_phone_msg;
2732                             msg += '\n';
2733                         }
2734                         if (get_bool(check.payload.hold.email_notify())) {
2735                             var payload_email = au_obj.email() ? au_obj.email() : '';
2736                             print_data.notify_by_email_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.email_notify', [payload_email]);
2737                             print_data.notify_by_email = payload_email;
2738                             msg += print_data.notify_by_email_msg;
2739                             msg += '\n';
2740                         }
2741                         msg += '\n';
2742                         var notes = check.payload.hold.notes();
2743                         print_data.notes_raw = notes;
2744                         for (var i = 0; i < notes.length; i++) {
2745                             if ( get_bool( notes[i].slip() ) ) {
2746                                 var temp_msg;
2747                                 if ( get_bool( notes[i].staff() ) ) {
2748                                     temp_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.notes.staff_note', [ notes[i].title(), notes[i].body() ]);
2749                                 } else {
2750                                     temp_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.notes.patron_note', [ notes[i].title(), notes[i].body() ]);
2751                                 }
2752                                 msg += temp_msg + '\n';
2753                                 print_list.push(
2754                                     {
2755                                         'formatted_note' : temp_msg,
2756                                         'note_title' : notes[i].title(),
2757                                         'note_body' : notes[i].body(),
2758                                         'note_public' : notes[i].pub(),
2759                                         'note_by_staff' : notes[i].staff()
2760                                     }
2761                                 );
2762                             }
2763                         }
2764                         msg += '\n';
2765                         msg += '\n';
2766                         print_data.request_date = util.date.formatted_date(check.payload.hold.request_time(),'%F');
2767                         print_data.request_date_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.request_date', [print_data.request_date]);
2768                         print_data.shelf_expire_time = check.payload.hold.shelf_expire_time();
2769                         msg += print_data.request_date_msg;
2770                         msg += '\n';
2771                     }
2772                     var rv = 0;
2773                     var suppress_popups = data.hash.aous['ui.circ.suppress_checkin_popups'];
2774                     if (suppress_popups) {
2775                         rv = auto_print ? 0 : -1; auto_print = true; // skip dialog and PRINT or DO NOT PRINT based on Auto-Print checkbox
2776                     }
2777                     var x = data.hash.aous['circ.staff_client.do_not_auto_attempt_print'];
2778                     var no_print_prompting = x ? ( x.indexOf( "Hold Slip" ) > -1) : false;
2779                     if (no_print_prompting) {
2780                         rv = -1; auto_print = true; // DO NOT PRINT and skip dialog
2781                     }
2782                     print_data.slip_date = util.date.formatted_date(new Date(),'%F');
2783                     print_data.slip_date_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.slip_date', [print_data.slip_date]);
2784                     msg += print_data.slip_date_msg;
2785                     msg += '\n';
2786                     print_data.payload = check.payload;
2787
2788                     if (!auto_print) {
2789                         rv = error.yns_alert_formatted(
2790                             msg,
2791                             document.getElementById('circStrings').getString('staff.circ.utils.hold_slip'),
2792                             document.getElementById('circStrings').getString('staff.circ.utils.hold_slip.print.yes'),
2793                             document.getElementById('circStrings').getString('staff.circ.utils.hold_slip.print.no'),
2794                             null,
2795                             document.getElementById('circStrings').getString('staff.circ.confirm.msg'),
2796                             '/xul/server/skin/media/images/turtle.gif'
2797                         );
2798                     } else {
2799                         if (suppress_popups && !no_print_prompting) {
2800                             // FIXME: Add SFX and/or GFX
2801                             sound.circ_bad();
2802                         }
2803                     }
2804                     if (rv == 0) {
2805                         try {
2806                             JSAN.use('util.print'); var print = new util.print();
2807                             var old_template = String( data.hash.aous['ui.circ.old_harcoded_slip_template'] ) == 'true';
2808                             if (old_template) {
2809                                 msg = msg.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\n/g,'<br/>');
2810                                 print.simple( msg , { 'no_prompt' : true, 'content_type' : 'text/html' } );
2811                             } else {
2812                                 var template = 'hold_slip';
2813                                 var parms = {
2814                                     'patron' : print_data.user,
2815                                     'lib' : data.hash.aou[ check.payload.hold.pickup_lib() ],
2816                                     'staff' : data.list.au[0],
2817                                     'header' : data.print_list_templates[ template ].header,
2818                                     'line_item' : data.print_list_templates[ template ].line_item,
2819                                     'footer' : data.print_list_templates[ template ].footer,
2820                                     'type' : data.print_list_templates[ template ].type,
2821                                     'list' : print_list,
2822                                     'data' : print_data
2823                                 };
2824                                 if ($('printer_prompt')) {
2825                                     if (! $('printer_prompt').checked) { parms.no_prompt = true; }
2826                                 }
2827                                 print.tree_list( parms );
2828                             }
2829                         } catch(E) {
2830                             var err_msg = document.getElementById('commonStrings').getString('common.error');
2831                             err_msg += '\nFIXME: ' + E + '\n';
2832                             dump(err_msg);
2833                             alert(err_msg);
2834                         }
2835                     }
2836                     msg = '';
2837                     if (no_change_label) {
2838                         var m = no_change_label.getAttribute('value');
2839                         var text = document.getElementById('circStrings').getFormattedString('staff.circ.utils.capture', [params.barcode]);
2840                         m += text + '  ';
2841                         no_change_label.setAttribute('value', m);
2842                         no_change_label.setAttribute('hidden','false');
2843                         no_change_label.setAttribute('onclick','');
2844                         removeCSSClass(no_change_label,'click_link');
2845                         no_change_label.setAttribute('unique_row_counter','');
2846                         if (typeof params.info_blurb == 'function') {
2847                             params.info_blurb( text );
2848                         }
2849                     }
2850                 break;
2851                 case 6: /* IN TRANSIT */
2852                     check.what_happened = 'error';
2853                     check.route_to = 'TRANSIT SHELF??';
2854                     print_data.route_to;
2855                     var err_msg = document.getElementById('commonStrings').getString('common.error');
2856                     err_msg += "\nFIXME -- I didn't think we could get here.\n";
2857                     print_data.error_msg += err_msg;
2858                     msg += err_msg;
2859                 break;
2860                 case 11: /* CATALOGING */
2861                     check.what_happened = 'cataloging';
2862                     check.route_to = 'CATALOGING';
2863                     print_data.route_to;
2864                     var suppress_popups = data.hash.aous['ui.circ.suppress_checkin_popups'];
2865                     var x = document.getElementById('do_not_alert_on_precat');
2866                     var do_not_alert_on_precats = x ? ( x.getAttribute('checked') == 'true' ) : false;
2867                     if ( !suppress_popups && !do_not_alert_on_precats ) {
2868                         print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2869                         msg += print_data.route_to_msg;
2870                     } else {
2871                         if (suppress_popups && !do_not_alert_on_precats) {
2872                             // FIXME: add SFX and/or GFX
2873                             sound.circ_bad();
2874                         }
2875                     }
2876                     if (no_change_label) {
2877                         var m = no_change_label.getAttribute('value');
2878                         var needs_cat = document.getElementById('circStrings').getFormattedString('staff.circ.utils.needs_cataloging', [params.barcode]);
2879                         no_change_label.setAttribute('value', m + needs_cat + '  ');
2880                         no_change_label.setAttribute('hidden','false');
2881                         no_change_label.setAttribute('onclick','');
2882                         removeCSSClass(no_change_label,'click_link');
2883                         no_change_label.setAttribute('unique_row_counter','');
2884                         if (typeof params.info_blurb == 'function') {
2885                             params.info_blurb( needs_cat );
2886                         }
2887                     }
2888                 break;
2889                 case 15: // ON_RESERVATION_SHELF
2890                     check.route_to = 'RESERVATION SHELF';
2891                     check.what_happened = "reservation_shelf";
2892                     if (check.payload.reservation) {
2893                         if (check.payload.reservation.pickup_lib() != data.list.au[0].ws_ou()) {
2894                             msg += document.getElementById('commonStrings').getString('common.error');
2895                             msg += '\nFIXME: ';
2896                             msg += document.getElementById('circStrings').getString('staff.circ.utils.route_item_error');
2897                             msg += '\n';
2898                         } else {
2899                             msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2900                             msg += '.\n';
2901                         }
2902                     } else {
2903                         msg += document.getElementById('commonStrings').getString('common.error');
2904                         msg += '\nFIXME: ';
2905                         msg += document.getElementById('circStrings').getString('staff.circ.utils.reservation_status_error');
2906                         msg += '\n';
2907                     }
2908                     JSAN.use('util.date');
2909                     if (check.payload.reservation) {
2910                         JSAN.use('patron.util');
2911                         msg += '\n';
2912                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.reservation.barcode', [check.payload.copy.barcode()]);
2913                         msg += '\n';
2914                         var payload_title  = (check.payload.record ? check.payload.record.title() : check.payload.copy.dummy_title() );
2915                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.reservation.title', [payload_title]);
2916                         msg += '\n';
2917                         var au_obj =
2918                             typeof(check.payload.reservation.usr().card) == "function" ?
2919                                 check.payload.reservation.usr() :
2920                                 patron.util.retrieve_fleshed_au_via_id(session, check.payload.reservation.usr());
2921                         msg += '\n';
2922                         if (au_obj.alias()) {
2923                             msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.reservation.patron_alias',  [au_obj.alias()]);
2924                         } else {
2925                             msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.reservation.patron',  [au_obj.family_name() || "", au_obj.first_given_name() || "", au_obj.second_given_name() || ""]);
2926                         }
2927                         msg += '\n';
2928                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.reservation.barcode', [au_obj.card().barcode()]);
2929                         msg += '\n';
2930                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.reservation.request_date', [util.date.formatted_date(check.payload.reservation.request_time(),'%F %H:%M')]);
2931                         msg += '\n';
2932
2933                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.reservation.start_date', [util.date.formatted_date(check.payload.reservation.start_time(),'%F %H:%M')]);
2934                         msg += '\n';
2935                     }
2936                     var rv = 0;
2937                     msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.reservation.slip_date', [util.date.formatted_date(new Date(),'%F')]);
2938                     msg += '\n';
2939                     if (!auto_print) {
2940                         rv = error.yns_alert_formatted(
2941                             msg,
2942                             document.getElementById('circStrings').getString('staff.circ.utils.reservation_slip'),
2943                             document.getElementById('circStrings').getString('staff.circ.utils.reservation_slip.print.yes'),
2944                             document.getElementById('circStrings').getString('staff.circ.utils.reservation_slip.print.no'),
2945                             null,
2946                             document.getElementById('circStrings').getString('staff.circ.confirm.msg'),
2947                             '/xul/server/skin/media/images/turtle.gif'
2948                         );
2949                     }
2950                     if (rv == 0) {
2951                         try {
2952                             JSAN.use('util.print'); var print = new util.print();
2953                             msg = msg.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\n/g,'<br/>');
2954                             print.simple( msg , { 'no_prompt' : true, 'content_type' : 'text/html' } );
2955                         } catch(E) {
2956                             var err_msg = document.getElementById('commonStrings').getString('common.error');
2957                             err_msg += '\nFIXME: ' + E + '\n';
2958                             dump(err_msg);
2959                             alert(err_msg);
2960                         }
2961                     }
2962                     msg = '';
2963                     if (no_change_label) {
2964                         var m = no_change_label.getAttribute('value');
2965                         var text = document.getElementById('circStrings').getFormattedString('staff.circ.utils.reservation_capture', [params.barcode]);
2966                         m += text + '  ';
2967                         no_change_label.setAttribute('value', m);
2968                         no_change_label.setAttribute('hidden','false');
2969                         no_change_label.setAttribute('onclick','');
2970                         removeCSSClass(no_change_label,'click_link');
2971                         no_change_label.setAttribute('unique_row_counter','');
2972                         if (typeof params.info_blurb == 'function') {
2973                             params.info_blurb( text );
2974                         }
2975                     }
2976                 break;
2977                 default:
2978                     check.what_happened = 'error';
2979                     msg += document.getElementById('commonStrings').getString('common.error');
2980                     var copy_status = data.hash.ccs[check.copy.status()] ? data.hash.ccs[check.copy.status()].name() : check.copy.status().name();
2981                     msg += '\n';
2982                     var error_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.copy_status.error', [copy_status]);
2983                     print_data.error_msg += error_msg;
2984                     msg += error_msg;
2985                     msg += '\n';
2986                     print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2987                     msg += print_data.route_to_msg;
2988                 break;
2989             }
2990             if (msg) {
2991                 error.yns_alert(
2992                     msg,
2993                     document.getElementById('circStrings').getString('staff.circ.alert'),
2994                     null,
2995                     document.getElementById('circStrings').getString('staff.circ.utils.msg.ok'),
2996                     null,
2997                     document.getElementById('circStrings').getString('staff.circ.confirm.msg')
2998                 );
2999             }
3000         } else /* ROUTE_ITEM */ if (check.ilsevent == 7000) {
3001
3002             check.what_happened = 'transit';
3003             var lib = data.hash.aou[ check.org ];
3004             check.route_to = lib.shortname();
3005             print_data.route_to = check.route_to;
3006             print_data.route_to_org = lib;
3007             print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.destination', [check.route_to]);
3008             print_data.route_to_org_fullname = lib.name();
3009             var aous_req = network.simple_request('FM_AOUS_SPECIFIC_RETRIEVE',[ lib.id(), 'lib.courier_code' ]);
3010             if (aous_req) {
3011                 print_data.courier_code = aous_req.value || '';
3012             }
3013             msg += print_data.route_to_msg;
3014             msg += '\n\n';
3015             msg += lib.name();
3016             msg += '\n';
3017             try {
3018                 if (lib.holds_address() ) {
3019                     var a = network.simple_request('FM_AOA_RETRIEVE',[ lib.holds_address() ]);
3020                     if (typeof a.ilsevent != 'undefined') throw(a);
3021                     if (a.street1()) { msg += a.street1() + '\n'; print_data.street1 = a.street1(); }
3022                     if (a.street2()) { msg += a.street2() + '\n'; print_data.street2 = a.street2(); }
3023                     print_data.city_state_zip = (a.city() ? a.city() + ', ' : '') + (a.state() ? a.state() + ' ' : '') + (a.post_code() ? a.post_code() : '');
3024                     print_data.city = a.city();
3025                     print_data.state = a.state();
3026                     print_data.county = a.county();
3027                     print_data.country = a.country();
3028                     print_data.post_code = a.post_code();
3029                     msg += print_data.city_state_zip + '\n';
3030                 } else {
3031                     print_data.street1 = document.getElementById('circStrings').getString('staff.circ.utils.route_to.no_address');
3032                     print_data.no_address = true;
3033                     msg += print_data.street1;
3034                     msg += '\n';
3035                 }
3036             } catch(E) {
3037                 var err_msg = document.getElementById('circStrings').getString('staff.circ.utils.route_to.no_address.error');
3038                 print_data.error_msg += err_msg + '\n';
3039                 msg += err_msg + '\n';
3040                 error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.utils.route_to.no_address.error'), E);
3041             }
3042             msg += '\n';
3043             print_data.item_barcode_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [check.payload.copy.barcode()]);
3044             print_data.item_barcode = check.payload.copy.barcode();
3045             msg += print_data.item_barcode_msg;
3046             msg += '\n';
3047             var payload_title  = (check.payload.record ? check.payload.record.title() : check.payload.copy.dummy_title() );
3048             print_data.item_title_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.title', [payload_title]);
3049             print_data.item_title = payload_title;
3050             msg += print_data.item_title_msg;
3051             msg += '\n';
3052             var payload_author = (check.payload.record ? check.payload.record.author() :check.payload.copy.dummy_author());
3053             print_data.item_author_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.author', [payload_author]);
3054             print_data.item_author = payload_author;
3055             msg += print_data.item_author_msg;
3056             msg += '\n';
3057             JSAN.use('util.date');
3058             if (check.payload.hold) {
3059                 check.what_happened = 'transit_for_hold';
3060                 JSAN.use('patron.util');
3061                 var au_obj = patron.util.retrieve_fleshed_au_via_id( session, check.payload.hold.usr() );
3062                 print_data.user = au_obj;
3063                 print_data.user_stat_cat_entries = [];
3064                 var entries = au_obj.stat_cat_entries();
3065                 for (var i = 0; i < entries.length; i++) {
3066                     var stat_cat = data.hash.my_actsc[ entries[i].stat_cat() ];
3067                     if (!stat_cat) {
3068                         stat_cat = data.lookup('actsc', entries[i].stat_cat());
3069                     }
3070                     print_data.user_stat_cat_entries.push( { 
3071                         'id' : entries[i].id(),
3072                         'stat_cat' : {
3073                             'id' : stat_cat.id(),
3074                             'name' : stat_cat.name(),
3075                             'opac_visible' : stat_cat.opac_visible(),
3076                             'owner' : stat_cat.owner(),
3077                             'usr_summary' : stat_cat.usr_summary()
3078                         },
3079                         'stat_cat_entry' : entries[i].stat_cat_entry(),
3080                         'target_usr' : entries[i].target_usr() 
3081                     } );
3082                 }
3083                 msg += '\n';
3084                 if (au_obj.alias()) {
3085                     print_data.hold_for_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.patron_alias',  [au_obj.alias()]);
3086                     print_data.hold_for_alias = au_obj.alias();
3087                     msg += print_data.hold_for_msg;
3088                 } else {
3089                     print_data.hold_for_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.patron',  [au_obj.family_name() ? au_obj.family_name() : '', au_obj.first_given_name() ? au_obj.first_given_name() : '', au_obj.second_given_name() ? au_obj.second_given_name() : '']);
3090                     msg += print_data.hold_for_msg;
3091                     print_data.hold_for_family_name = au_obj.family_name() ? au_obj.family_name() : '';
3092                     print_data.hold_for_first_given_name = au_obj.first_given_name() ? au_obj.first_given_name() : '';
3093                     print_data.hold_for_second_given_name = au_obj.second_given_name() ? au_obj.second_given_name() : '';
3094                 }
3095                 msg += '\n';
3096                 print_data.user_barcode_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [au_obj.card().barcode()]);
3097                 print_data.user_barcode = au_obj.card().barcode();
3098                 msg += print_data.user_barcode_msg;
3099                 msg += '\n';
3100                 if (check.payload.hold.phone_notify()) {
3101                     print_data.notify_by_phone_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.phone_notify', [check.payload.hold.phone_notify()]);
3102                     print_data.notify_by_phone = check.payload.hold.phone_notify();
3103                     msg += print_data.notify_by_phone_msg;
3104                     msg += '\n';
3105                 }
3106                 if (get_bool(check.payload.hold.email_notify())) {
3107                     var payload_email = au_obj.email() ? au_obj.email() : '';
3108                     print_data.notify_by_email_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.email_notify', [payload_email]);
3109                     print_data.notify_by_email = payload_email;
3110                     msg += print_data.notify_by_email_msg;
3111                     msg += '\n';
3112                 }
3113                 msg += '\n';
3114                 var notes = check.payload.hold.notes();
3115                 print_data.notes_raw = notes;
3116                 for (var i = 0; i < notes.length; i++) {
3117                     if ( get_bool( notes[i].slip() ) ) {
3118                         var temp_msg;
3119                         if ( get_bool( notes[i].staff() ) ) {
3120                             temp_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.notes.staff_note', [ notes[i].title(), notes[i].body() ]);
3121                         } else {
3122                             temp_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.notes.patron_note', [ notes[i].title(), notes[i].body() ]);
3123                         }
3124                         msg += temp_msg + '\n';
3125                         print_list.push(
3126                             {
3127                                 'formatted_note' : temp_msg,
3128                                 'note_title' : notes[i].title(),
3129                                 'note_body' : notes[i].body(),
3130                                 'note_public' : notes[i].pub(),
3131                                 'note_by_staff' : notes[i].staff()
3132                             }
3133                         );
3134                     }
3135                 }
3136                 msg += '\n';
3137                 msg += '\n';
3138                 print_data.request_date = util.date.formatted_date(check.payload.hold.request_time(),'%F');
3139                 print_data.request_date_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.request_date', [print_data.request_date]);
3140                 msg += print_data.request_date_msg;
3141                 msg += '\n';
3142                 var destination_shelf = document.getElementById('circStrings').getString('staff.circ.route_to.hold_shelf');
3143                 print_data.destination_shelf_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [destination_shelf]);
3144                 print_data.destination_shelf = destination_shelf;
3145                 var behind_the_desk_support = String( data.hash.aous['circ.holds.behind_desk_pickup_supported'] ) == 'true';
3146                 if (behind_the_desk_support) {
3147                    var usr_settings = network.simple_request('FM_AUS_RETRIEVE',[ses(),check.payload.hold.usr()]); 
3148                     if (typeof usr_settings['circ.holds_behind_desk'] != 'undefined') {
3149                         if (usr_settings['circ.holds_behind_desk']) {
3150                             print_data.prefer_behind_holds_desk = true;
3151                             destination_shelf = document.getElementById('circStrings').getString('staff.circ.route_to.private_hold_shelf');
3152                             print_data.destination_shelf_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [destination_shelf]);
3153                             print_data.destination_shelf = destination_shelf;
3154                         } else {
3155                             destination_shelf = document.getElementById('circStrings').getString('staff.circ.route_to.public_hold_shelf');
3156                             print_data.destination_shelf_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [destination_shelf]);
3157                             print_data.destination_shelf = destination_shelf;
3158                         }
3159                     } else {
3160                         destination_shelf = document.getElementById('circStrings').getString('staff.circ.route_to.public_hold_shelf');
3161                         print_data.destination_shelf_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [destination_shelf]);
3162                         print_data.destination_shelf = destination_shelf;
3163                     }
3164                 }
3165             }
3166             var rv = 0;
3167             var suppress_popups = data.hash.aous['ui.circ.suppress_checkin_popups'];
3168             if (suppress_popups) {
3169                 rv = auto_print ? 0 : -1; auto_print = true; // skip dialog and PRINT or DO NOT PRINT based on Auto-Print checkbox
3170             }
3171             var x = data.hash.aous['circ.staff_client.do_not_auto_attempt_print'];
3172             var no_print_prompting = x ? (x.indexOf( check.payload.hold ? "Hold/Transit Slip" : "Transit Slip" ) > -1) : false;
3173             if (no_print_prompting) {
3174                 rv = -1; auto_print = true; // DO NOT PRINT and skip dialog
3175             }
3176             print_data.slip_date = util.date.formatted_date(new Date(),'%F');
3177             print_data.slip_date_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.slip_date', [print_data.slip_date]);
3178             msg += print_data.slip_date_msg;
3179             print_data.payload = check.payload;
3180
3181             if (!auto_print) {
3182                 rv = error.yns_alert_formatted(
3183                     msg,
3184                     document.getElementById('circStrings').getString('staff.circ.utils.transit_slip'),
3185                     document.getElementById('circStrings').getString('staff.circ.utils.transit_slip.print.yes'),
3186                     document.getElementById('circStrings').getString('staff.circ.utils.transit_slip.print.no'),
3187                     null,
3188                     document.getElementById('circStrings').getString('staff.circ.confirm.msg'),
3189                     '/xul/server/skin/media/images/turtle.gif'
3190                 );
3191             } else {
3192                 if (suppress_popups && !no_print_prompting) {
3193                     // FIXME: add SFX and/or GFX
3194                     sound.circ_bad();
3195                 }
3196             }
3197             if (rv == 0) {
3198                 try {
3199                     JSAN.use('util.print'); var print = new util.print();
3200                     var old_template = String( data.hash.aous['ui.circ.old_harcoded_slip_template'] ) == 'true';
3201                     if (old_template) {
3202                         msg = msg.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\n/g,'<br/>');
3203                         print.simple( msg , { 'no_prompt' : true, 'content_type' : 'text/html' } );
3204                     } else {
3205                         var template = check.payload.hold ? 'hold_transit_slip' : 'transit_slip';
3206                         var parms = {
3207                             'patron' : print_data.user,
3208                             'lib' : data.hash.aou[ data.list.au[0].ws_ou() ],
3209                             'staff' : data.list.au[0],
3210                             'header' : data.print_list_templates[ template ].header,
3211                             'line_item' : data.print_list_templates[ template ].line_item,
3212                             'footer' : data.print_list_templates[ template ].footer,
3213                             'type' : data.print_list_templates[ template ].type,
3214                             'list' : print_list,
3215                             'data' : print_data 
3216                         };
3217                         if ($('printer_prompt')) {
3218                             if (! $('printer_prompt').checked) { parms.no_prompt = true; }
3219                         }
3220                         print.tree_list( parms );
3221                     }
3222                 } catch(E) {
3223                     var err_msg = document.getElementById('commonStrings').getString('common.error');
3224                     err_msg += '\nFIXME: ' + E + '\n';
3225                     dump(err_msg);
3226                     alert(err_msg);
3227                 }
3228             }
3229             if (no_change_label) {
3230                 var m = no_change_label.getAttribute('value');
3231                 var trans_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.in_transit', [params.barcode]);
3232                 no_change_label.setAttribute('value', m + trans_msg + '  ');
3233                 no_change_label.setAttribute('hidden','false');
3234                 no_change_label.setAttribute('onclick','');
3235                 removeCSSClass(no_change_label,'click_link');
3236                 no_change_label.setAttribute('unique_row_counter','');
3237                 if (typeof params.info_blurb == 'function') {
3238                     params.info_blurb( trans_msg );
3239                 }
3240             }
3241
3242         } else /* ASSET_COPY_NOT_FOUND */ if (check.ilsevent == 1502) {
3243
3244             check.what_happened = 'not_found';
3245             check.route_to = 'CATALOGING';
3246             var mis_scan_msg = document.getElementById('circStrings').getFormattedString('staff.circ.copy_status.status.copy_not_found', [params.barcode]);
3247             var suppress_popups = data.hash.aous['ui.circ.suppress_checkin_popups'];
3248             if (!suppress_popups) {
3249                 error.yns_alert(
3250                     mis_scan_msg,
3251                     document.getElementById('circStrings').getString('staff.circ.alert'),
3252                     null,
3253                     document.getElementById('circStrings').getString('staff.circ.utils.msg.ok'),
3254                     null,
3255                     document.getElementById('circStrings').getString('staff.circ.confirm.msg')
3256                 );
3257             } else {
3258                 // FIXME: add SFX and/or GFX
3259                 sound.circ_bad();
3260             }
3261             if (no_change_label) {
3262                 var m = no_change_label.getAttribute('value');
3263                 no_change_label.setAttribute('value',m + mis_scan_msg + '  ');
3264                 no_change_label.setAttribute('hidden','false');
3265                 no_change_label.setAttribute('onclick','');
3266                 removeCSSClass(no_change_label,'click_link');
3267                 no_change_label.setAttribute('unique_row_counter','');
3268                 if (typeof params.info_blurb == 'function') {
3269                     params.info_blurb( mis_scan_msg );
3270                 }
3271             }
3272
3273         } else /* HOLD_CAPTURE_DELAYED */ if (check.ilsevent == 7019) {
3274
3275             check.what_happened = 'hold_capture_delayed';
3276             var rv = 0;
3277             msg += document.getElementById('circStrings').getString('staff.circ.utils.hold_capture_delayed.description');
3278             var suppress_popups = data.hash.aous['ui.circ.suppress_checkin_popupst'];
3279             if (!suppress_popups) {
3280                 rv = error.yns_alert_formatted(
3281                     msg,
3282                     document.getElementById('circStrings').getString('staff.circ.utils.hold_capture_delayed.titlebar'),
3283                     document.getElementById('circStrings').getString('staff.circ.utils.hold_capture_delayed.prompt_for_nocapture'),
3284                     document.getElementById('circStrings').getString('staff.circ.utils.hold_capture_delayed.prompt_for_capture'),
3285                     null,
3286                     document.getElementById('circStrings').getString('staff.circ.confirm.msg'),
3287                     '/xul/server/skin/media/images/stop_sign.png'
3288                 );
3289             } else {
3290                 // FIXME: add SFX and/or GFX
3291                 sound.circ_bad();
3292             }
3293             params.capture = rv == 0 ? 'nocapture' : 'capture';
3294
3295             return circ.util.checkin_via_barcode(session,params,backdate,auto_print,false);
3296
3297         } else /* NETWORK TIMEOUT */ if (check.ilsevent == -1) {
3298             check.what_happened = 'error';
3299             error.standard_network_error_alert(document.getElementById('circStrings').getString('staff.circ.checkin.suggest_offline'));
3300         } else {
3301
3302             if (check.ilsevent == null) { return null; /* handled */ }
3303             switch (Number(check.ilsevent)) {
3304                 case 1203 /* COPY_BAD_STATUS */ :
3305                 case 1213 /* PATRON_BARRED */ :
3306                 case 1217 /* PATRON_INACTIVE */ :
3307                 case 1224 /* PATRON_ACCOUNT_EXPIRED */ :
3308                 case 1234 /* ITEM_DEPOSIT_PAID */ :
3309                 case 7009 /* CIRC_CLAIMS_RETURNED */ :
3310                 case 7010 /* COPY_ALERT_MESSAGE */ :
3311                 case 7011 /* COPY_STATUS_LOST */ :
3312                 case 7012 /* COPY_STATUS_MISSING */ :
3313                 case 7013 /* PATRON_EXCEEDS_FINES */ :
3314                     return null; /* handled */
3315                 break;
3316             }
3317
3318             throw(check);
3319
3320         }
3321
3322         return check;
3323     } catch(E) {
3324         JSAN.use('util.error'); var error = new util.error();
3325         error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.error', ['3']), E);
3326         return null;
3327     }
3328 };
3329
3330 circ.util.renew_via_barcode = function ( params, async ) {
3331     try {
3332         var obj = {};
3333         JSAN.use('util.network'); obj.network = new util.network();
3334         JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.stash_retrieve();
3335
3336         function renew_callback(req) {
3337             try {
3338                 JSAN.use('util.error'); var error = new util.error();
3339                 var renew = req.getResultObject();
3340                 if (typeof renew.ilsevent != 'undefined') renew = [ renew ];
3341                 for (var j = 0; j < renew.length; j++) {
3342                     switch(renew[j].ilsevent == null ? null : Number(renew[j].ilsevent)) {
3343                         case 0 /* SUCCESS */ : break;
3344                         case null /* custom event */ : break;
3345                         case 5000 /* PERM_FAILURE */: break;
3346                         case 1212 /* PATRON_EXCEEDS_OVERDUE_COUNT */ : break;
3347                         case 1213 /* PATRON_BARRED */ : break;
3348                         case 1215 /* CIRC_EXCEEDS_COPY_RANGE */ : break;
3349                         case 1224 /* PATRON_ACCOUNT_EXPIRED */ : break;
3350                         case 1232 /* ITEM_DEPOSIT_REQUIRED */ : break;
3351                         case 1233 /* ITEM_RENTAL_FEE_REQUIRED */ : break;
3352                         case 1234 /* ITEM_DEPOSIT_PAID */ : break;
3353                         case 1500 /* ACTION_CIRCULATION_NOT_FOUND */ : break;
3354                         case 1502 /* ASSET_COPY_NOT_FOUND */ : 
3355                             var mis_scan_msg = document.getElementById('circStrings').getFormattedString('staff.circ.copy_status.status.copy_not_found', [params.barcode]);
3356                             error.yns_alert(
3357                                 mis_scan_msg,
3358                                 document.getElementById('circStrings').getString('staff.circ.alert'),
3359                                 null,
3360                                 document.getElementById('circStrings').getString('staff.circ.utils.msg.ok'),
3361                                 null,
3362                                 document.getElementById('circStrings').getString('staff.circ.confirm.msg')
3363                             );
3364                             if (no_change_label) {
3365                                 var m = no_change_label.getAttribute('value');
3366                                 no_change_label.setAttribute('value',m + mis_scan_msg + '  ');
3367                                 no_change_label.setAttribute('hidden','false');
3368                                 no_change_label.setAttribute('onclick','');
3369                                 removeCSSClass(no_change_label,'click_link');
3370                                 no_change_label.setAttribute('unique_row_counter','');
3371                                 if (typeof params.info_blurb == 'function') {
3372                                     params.info_blurb( mis_scan_msg );
3373                                 }
3374                             }
3375                         break;
3376                         case 7002 /* PATRON_EXCEEDS_CHECKOUT_COUNT */ : break;
3377                         case 7003 /* COPY_CIRC_NOT_ALLOWED */ : break;
3378                         case 7004 /* COPY_NOT_AVAILABLE */ : break;
3379                         case 7006 /* COPY_IS_REFERENCE */ : break;
3380                         case 7007 /* COPY_NEEDED_FOR_HOLD */ : break;
3381                         case 7008 /* MAX_RENEWALS_REACHED */ : break;
3382                         case 7009 /* CIRC_CLAIMS_RETURNED */ : break;
3383                         case 7010 /* COPY_ALERT_MESSAGE */ : break;
3384                         case 7013 /* PATRON_EXCEEDS_FINES */ : break;
3385                         default:
3386                             throw(renew);
3387                         break;
3388                     }
3389                 }
3390                 try {
3391                     var ibarcode = renew[0].payload.copy ? renew[0].payload.copy.barcode() : params.barcode;
3392                     var p_id = renew[0].payload.patron ? renew[0].payload.patron.id() : renew[0].payload.circ.usr();
3393                     var pname; var pbarcode; 
3394                     if (renew[0].patron) {
3395                         pname = renew[0].payload.patron.family_name();
3396                         pbarcode = typeof renew[0].payload.patron.card() == 'object' ? renew[0].payload.patron.card().barcode() : null;
3397                     } else {
3398                         if (circ.util.renew_via_barcode.last_usr_id == p_id) {
3399                             pname = circ.util.renew_via_barcode.last_pname;
3400                             pbarcode = circ.util.renew_via_barcode.last_pbarcode;
3401                         } else {
3402                             JSAN.use('patron.util'); var p = patron.util.retrieve_fleshed_au_via_id(ses(),p_id);
3403                             pname = p.family_name();
3404                             pbarcode = typeof p.card() == 'object' ? p.card().barcode() : null;
3405                             if (pname) {
3406                                 circ.util.renew_via_barcode.last_usr_id = p_id;
3407                                 circ.util.renew_via_barcode.last_pname = pname;
3408                                 circ.util.renew_via_barcode.last_pbarcode = pbarcode;
3409                             }
3410                         } 
3411                     }
3412                     error.work_log(
3413                         document.getElementById('circStrings').getFormattedString(
3414                             'staff.circ.work_log_renew.message',
3415                             [
3416                                 ses('staff_usrname'),
3417                                 pname ? pname : '???',
3418                                 pbarcode ? pbarcode : '???',
3419                                 ibarcode ? ibarcode : '???'
3420                             ]
3421                         ), {
3422                             'au_id' : p_id,
3423                             'au_family_name' : pname,
3424                             'au_barcode' : pbarcode,
3425                             'acp_barcode' : ibarcode
3426                         }
3427                     );
3428                 } catch(E) {
3429                     error.sdump('D_ERROR','Error with work_logging in server/circ/util.js, renew_via_barcode():' + E);
3430                 }
3431                 if (typeof async == 'function') async(renew);
3432                 return renew;
3433             } catch(E) {
3434                 JSAN.use('util.error'); var error = new util.error();
3435                 error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.renew_failed.error', [params.barcode]), E);
3436                 return null;
3437             }
3438         }
3439
3440         var renew = obj.network.simple_request(
3441             'CHECKOUT_RENEW',
3442             [ ses(), params ],
3443             async ? renew_callback : null,
3444             {
3445                 'title' : document.getElementById('circStrings').getString('staff.circ.checkin.renew_failed.override'),
3446                 'overridable_events' : [
3447                     null /* custom event */,
3448                     1212 /* PATRON_EXCEEDS_OVERDUE_COUNT */,
3449                     1213 /* PATRON_BARRED */,
3450                     1215 /* CIRC_EXCEEDS_COPY_RANGE */,
3451                     1232 /* ITEM_DEPOSIT_REQUIRED */,
3452                     1233 /* ITEM_RENTAL_FEE_REQUIRED */,
3453                     1234 /* ITEM_DEPOSIT_PAID */,
3454                     7002 /* PATRON_EXCEEDS_CHECKOUT_COUNT */,
3455                     7003 /* COPY_CIRC_NOT_ALLOWED */,
3456                     7004 /* COPY_NOT_AVAILABLE */,
3457                     7006 /* COPY_IS_REFERENCE */,
3458                     7007 /* COPY_NEEDED_FOR_HOLD */,
3459                     7008 /* MAX_RENEWALS_REACHED */,
3460                     7009 /* CIRC_CLAIMS_RETURNED */,
3461                     7010 /* COPY_ALERT_MESSAGE */,
3462                     7013 /* PATRON_EXCEEDS_FINES */,
3463                 ],
3464                 'text' : {
3465                     '1212' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
3466                     '1213' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
3467                     '1215' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
3468                     '1232' : function(r) {
3469                         return document.getElementById('circStrings').getFormattedString('staff.circ.renew.override.item_deposit_required.warning.barcode', [params.barcode]);
3470                     },
3471                     '1233' : function(r) {
3472                         return document.getElementById('circStrings').getFormattedString('staff.circ.renew.override.item_rental_fee_required.warning.barcode', [params.barcode]);
3473                     },
3474                     '1234' : function(r) {
3475                         return document.getElementById('circStrings').getFormattedString('staff.circ.utils.checkin.override.item_deposit_paid.warning');
3476                     },
3477                     '7002' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
3478                     '7003' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
3479                     '7004' : function(r) {
3480                         return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode.status', [params.barcode, typeof r.payload.status() == 'object' ? r.payload.status().name() : obj.data.hash.ccs[ r.payload.status() ].name()]);
3481                     },
3482                     '7006' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
3483                     '7007' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
3484                     '7008' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
3485                     '7009' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
3486                     '7010' : function(r) {
3487                         return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode.msg', [params.barcode, r.payload]);
3488                     },
3489                     '7013' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); }
3490                 }
3491             }
3492         );
3493         if (! async ) {
3494             return renew_callback( { 'getResultObject' : function() { return renew; } } );
3495         }
3496
3497     } catch(E) {
3498         JSAN.use('util.error'); var error = new util.error();
3499         error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.renew_failed.error', [params.barcode]), E);
3500         return null;
3501     }
3502 };
3503
3504 circ.util.batch_hold_update = function ( hold_ids, field_changes, params ) {
3505     try {
3506         JSAN.use('util.sound'); var sound = new util.sound();
3507         var change_list = []; var idx = -1; var bad_holds = [];
3508         dojo.forEach(
3509             hold_ids,
3510             function(el) {
3511                 change_list.push( function(id,fc){ var clone = JSON2js(js2JSON(fc)); clone.id = id; return clone; }(el,field_changes) ); // Is there a better way to do this?
3512             }
3513         );
3514         if (params.progressmeter) { params.progressmeter.value = 0; params.progressmeter.hidden = false; }
3515         fieldmapper.standardRequest(
3516             [ api.FM_AHR_UPDATE_BATCH.app, api.FM_AHR_UPDATE_BATCH.method ],
3517             {   async: true,
3518                 params: [ses(), null, change_list],
3519                 onresponse: function(r) {
3520                     idx++; 
3521                     if (params.progressmeter) { params.progressmeter.value = Number( params.progressmeter.value ) + 100/hold_ids.length; }
3522                     var result = r.recv().content();
3523                     if (result != hold_ids[ idx ]) {
3524                         bad_holds.push( { 'hold_id' : hold_ids[ idx ], 'result' : result } );
3525                     }
3526                 },
3527                 oncomplete: function() {
3528                     if (bad_holds.length > 0) {
3529                         sound.circ_bad();
3530                         alert( $('circStrings').getFormattedString('staff.circ.hold_update.hold_ids.failed',[ bad_holds.length ]) );
3531                     } else {
3532                         sound.circ_good();
3533                     }
3534                     if (typeof params.oncomplete == 'function') {
3535                         params.oncomplete( bad_holds );
3536                     }
3537                     if (params.progressmeter) { params.progressmeter.value = 0; params.progressmeter.hidden = true; }
3538                 },
3539                 onerror: function(r) {
3540                     alert('Error in circ/util.js, batch_hold_update(), onerror: ' + r);
3541                 }
3542             }
3543         );
3544     } catch(E) {
3545         alert('Error in circ.util.js, circ.util.batch_hold_update(): ' + E);
3546     }
3547 };
3548
3549 circ.util.find_acq_po = function(session, copy_id) {
3550     dojo.require("openils.Util");
3551     fieldmapper.standardRequest(
3552         ["open-ils.acq", "open-ils.acq.lineitem.retrieve.by_copy_id.authoritative"], {
3553             "params": [session, copy_id, {"clear_marc": true}],
3554             "onresponse": function(r) {
3555                 if (r = openils.Util.readResponse(r)) {
3556                     if (r.purchase_order()) {
3557                         var url = urls.XUL_BROWSER + "?url=" +
3558                             xulG.url_prefix(
3559                                 escape(urls.EG_ACQ_PO_VIEW +
3560                                     "/" + r.purchase_order() + "/" + r.id())
3561                             );
3562                         window.xulG.new_tab(
3563                             url, {"browser": true}, {
3564                                 "no_xulG": false,
3565                                 "show_print_button": false,
3566                                 "show_nav_buttons": true
3567                             }
3568                         );
3569                     } else {
3570                         /* unlikely: got an LI with no PO */
3571                         alert(dojo.byId("circStrings").getFormattedString(
3572                             "staff.circ.utils.find_acq_po.no_po", [r.id()]
3573                         ));
3574                     }
3575                 }
3576             }
3577         }
3578     );
3579 };
3580
3581 dump('exiting circ/util.js\n');