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