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