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