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