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