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