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