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