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