]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/xul/staff_client/server/circ/util.js
add Current Shelf Library column to xul interfaces
[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('circStrings').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('circStrings').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('circStrings').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_shelf_lib',
2164             'label' : document.getElementById('circStrings').getString('staff.circ.utils.current_shelf_lib'),
2165             'flex' : 1,
2166             'primary' : false,
2167             'hidden' : true,
2168             'editable' : false, 'render' : function(my) {
2169                 if (Number(my.ahr.current_shelf_lib())>=0) {
2170                     return data.hash.aou[ my.ahr.current_shelf_lib() ].name();
2171                 } else {
2172                     return my.ahr.current_shelf_lib().name();
2173                 }
2174             }
2175         },
2176         {
2177             'persist' : 'hidden width ordinal',
2178             'id' : 'current_shelf_lib_shortname',
2179             'label' : document.getElementById('commonStrings').getString('staff.ahr_current_shelf_lib_label'),
2180             'flex' : 0,
2181             'primary' : false,
2182             'hidden' : true,
2183             'editable' : false, 'render' : function(my) {
2184                 if (Number(my.ahr.current_shelf_lib())>=0) {
2185                     return data.hash.aou[ my.ahr.current_shelf_lib() ].shortname();
2186                 } else {
2187                     return my.ahr.current_shelf_lib().shortname();
2188                 }
2189             }
2190         },
2191
2192         {
2193             'persist' : 'hidden width ordinal',
2194             'id' : 'current_copy',
2195             'label' : document.getElementById('commonStrings').getString('staff.ahr_current_copy_label'),
2196             'flex' : 1,
2197             'primary' : false,
2198             'hidden' : true,
2199             'editable' : false, 'render' : function(my) {
2200                 if (my.acp) {
2201                     return my.acp.barcode();
2202                 } else {
2203                     return document.getElementById('circStrings').getString('staff.circ.utils.current_copy.none');
2204                 }
2205             }
2206         },
2207         {
2208             'persist' : 'hidden width ordinal',
2209             'id' : 'current_copy_location',
2210             'label' : document.getElementById('commonStrings').getString('staff.ahr_current_copy_location_label'),
2211             'flex' : 1,
2212             'primary' : false,
2213             'hidden' : true,
2214             'editable' : false, 'render' : function(my) {
2215                 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(); }
2216             }
2217         },
2218         {
2219             'persist' : 'hidden width ordinal',
2220             'id' : 'email_notify',
2221             'label' : document.getElementById('commonStrings').getString('staff.ahr_email_notify_label'),
2222             'flex' : 1,
2223             'primary' : false,
2224             'hidden' : true,
2225             'editable' : false, 'render' : function(my) {
2226                 if (get_bool(my.ahr.email_notify())) {
2227                     return document.getElementById('circStrings').getString('staff.circ.utils.yes');
2228                 } else {
2229                     return document.getElementById('circStrings').getString('staff.circ.utils.no');
2230                 }
2231             }
2232         },
2233         {
2234             'persist' : 'hidden width ordinal',
2235             'id' : 'expire_date',
2236             'label' : document.getElementById('commonStrings').getString('staff.ahr_expire_date_label'),
2237             'flex' : 1,
2238             'sort_type' : 'date',
2239             'primary' : false,
2240             'hidden' : true,
2241             'editable' : false, 'render' : function(my) { return my.ahr.expire_time() ? util.date.formatted_date( my.ahr.expire_time(), '%{localized}' ) : ''; }
2242             ,'sort_value' : function(my) {
2243                 return util.date.db_date2Date(
2244                     my.ahr
2245                     ? my.ahr.expire_time()
2246                     : null
2247                 ).getTime();
2248             }
2249         },
2250         {
2251             'persist' : 'hidden width ordinal',
2252             'id' : 'fulfillment_time',
2253             'label' : document.getElementById('commonStrings').getString('staff.ahr_fulfillment_time_label'),
2254             'flex' : 1,
2255             'sort_type' : 'date',
2256             'primary' : false,
2257             'hidden' : true,
2258             'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.ahr.fulfillment_time(), '%{localized}' ); }
2259             ,'sort_value' : function(my) {
2260                 return util.date.db_date2Date(
2261                     my.ahr
2262                     ? my.ahr.fulfillment_time()
2263                     : null
2264                 ).getTime();
2265             }
2266         },
2267         {
2268             'persist' : 'hidden width ordinal',
2269             'id' : 'holdable_formats',
2270             'label' : document.getElementById('commonStrings').getString('staff.ahr_holdable_formats_label'),
2271             'flex' : 1,
2272             'primary' : false,
2273             'hidden' : true,
2274             'editable' : false, 'render' : function(my) { return my.ahr.holdable_formats(); }
2275         },
2276         {
2277             'persist' : 'hidden width ordinal',
2278             'id' : 'holdable_part',
2279             'label' : document.getElementById('commonStrings').getString('staff.ahr_holdable_part_label'),
2280             'flex' : 1,
2281             'primary' : false,
2282             'hidden' : true,
2283             'editable' : false, 'render' : function(my) { return my.part.label(); }
2284         },
2285         {
2286             'persist' : 'hidden width ordinal',
2287             'id' : 'issuance_label',
2288             'label' : document.getElementById('commonStrings').getString('staff.ahr_issuance_label_label'),
2289             'flex' : 1,
2290             'primary' : false,
2291             'hidden' : true,
2292             'editable' : false, 'render' : function(my) { return my.issuance.label(); }
2293         },
2294         {
2295             'persist' : 'hidden width ordinal',
2296             'id' : 'ahr_id',
2297             'label' : document.getElementById('commonStrings').getString('staff.ahr_id_label'),
2298             'flex' : 1,
2299             'primary' : false,
2300             'hidden' : true,
2301             'editable' : false, 'render' : function(my) { return my.ahr.id(); }
2302         },
2303         {
2304             'persist' : 'hidden width ordinal',
2305             'id' : 'phone_notify',
2306             'label' : document.getElementById('commonStrings').getString('staff.ahr_phone_notify_label'),
2307             'flex' : 1,
2308             'primary' : false,
2309             'hidden' : true,
2310             'editable' : false, 'render' : function(my) { return my.ahr.phone_notify(); }
2311         },
2312         {
2313             'persist' : 'hidden width ordinal',
2314             'id' : 'sms_notify',
2315             'label' : document.getElementById('commonStrings').getString('staff.ahr_sms_notify_label'),
2316             'flex' : 1,
2317             'primary' : false,
2318             'hidden' : true,
2319             'editable' : false, 'render' : function(my) { return my.ahr.sms_notify(); }
2320         },
2321         {
2322             'persist' : 'hidden width ordinal',
2323             'id' : 'sms_carrier',
2324             'label' : document.getElementById('commonStrings').getString('staff.ahr_sms_carrier_label'),
2325             'flex' : 1,
2326             'primary' : false,
2327             'hidden' : true,
2328             'editable' : false, 'render' : function(my) { return data.hash.csc[ my.ahr.sms_carrier() ].name(); }
2329         },
2330         {
2331             'persist' : 'hidden width ordinal',
2332             'id' : 'prev_check_time',
2333             'label' : document.getElementById('commonStrings').getString('staff.ahr_prev_check_time_label'),
2334             'flex' : 1,
2335             'sort_type' : 'date',
2336             'primary' : false,
2337             'hidden' : true,
2338             'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.ahr.prev_check_time(), '%{localized}' ); }
2339             ,'sort_value' : function(my) {
2340                 return util.date.db_date2Date(
2341                     my.ahr
2342                     ? my.ahr.prev_check_time()
2343                     : null
2344                 ).getTime();
2345             }
2346         },
2347         {
2348             'persist' : 'hidden width ordinal',
2349             'id' : 'requestor',
2350             'label' : document.getElementById('commonStrings').getString('staff.ahr_requestor_label'),
2351             'flex' : 1,
2352             'primary' : false,
2353             'hidden' : true,
2354             'editable' : false, 'render' : function(my) { return my.ahr.requestor(); }
2355         },
2356         {
2357             'persist' : 'hidden width ordinal',
2358             'id' : 'selection_depth',
2359             'label' : document.getElementById('commonStrings').getString('staff.ahr_selection_depth_label'),
2360             'flex' : 1,
2361             'primary' : false,
2362             'hidden' : true,
2363             'editable' : false, 'render' : function(my) { return my.ahr.selection_depth(); }
2364         },
2365         {
2366             'persist' : 'hidden width ordinal',
2367             'id' : 'top_of_queue',
2368             'label' : document.getElementById('commonStrings').getString('staff.ahr_top_of_queue_label'),
2369             'flex' : 1,
2370             'primary' : false,
2371             'hidden' : true,
2372             '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') ; }
2373         },
2374         {
2375             'persist' : 'hidden width ordinal',
2376             'id' : 'target',
2377             'label' : document.getElementById('commonStrings').getString('staff.ahr_target_label'),
2378             'flex' : 1,
2379             'primary' : false,
2380             'hidden' : true,
2381             'editable' : false, 'render' : function(my) { return my.ahr.target(); }
2382         },
2383         {
2384             'persist' : 'hidden width ordinal',
2385             'id' : 'usr',
2386             'label' : document.getElementById('commonStrings').getString('staff.ahr_usr_label'),
2387             'flex' : 1,
2388             'primary' : false,
2389             'hidden' : true,
2390             'editable' : false, 'render' : function(my) { return my.ahr.usr(); }
2391         },
2392         {
2393             'persist' : 'hidden width ordinal',
2394             'id' : 'title',
2395             'label' : document.getElementById('commonStrings').getString('staff.mvr_label_title'),
2396             'flex' : 1,
2397             'sort_type' : 'title',
2398             'primary' : false,
2399             'hidden' : true,
2400             'editable' : false, 'render' : function(my) {
2401                 if (my.mvr) {
2402                     return my.mvr.title();
2403                 } else {
2404                     return document.getElementById('circStrings').getString('staff.circ.utils.title.none');
2405                 }
2406             }
2407         },
2408         {
2409             'persist' : 'hidden width ordinal',
2410             'id' : 'author',
2411             'label' : document.getElementById('commonStrings').getString('staff.mvr_label_author'),
2412             'flex' : 1,
2413             'primary' : false,
2414             'hidden' : true,
2415             'editable' : false, 'render' : function(my) {
2416                 if (my.mvr) {
2417                     return my.mvr.author();
2418                 } else {
2419                     return document.getElementById('circStrings').getString('staff.circ.utils.author.none');
2420                 }
2421             }
2422         },
2423         {
2424             'persist' : 'hidden width ordinal',
2425             'id' : 'edition',
2426             'label' : document.getElementById('circStrings').getString('staff.circ.utils.edition'),
2427             'flex' : 1,
2428             'primary' : false,
2429             'hidden' : true,
2430             'editable' : false, 'render' : function(my) { return my.mvr.edition(); }
2431         },
2432         {
2433             'persist' : 'hidden width ordinal',
2434             'id' : 'isbn',
2435             'label' : document.getElementById('circStrings').getString('staff.circ.utils.isbn'),
2436             'flex' : 1,
2437             'primary' : false,
2438             'hidden' : true,
2439             'editable' : false, 'render' : function(my) { return my.mvr.isbn(); }
2440         },
2441         {
2442             'persist' : 'hidden width ordinal',
2443             'id' : 'pubdate',
2444             'label' : document.getElementById('circStrings').getString('staff.circ.utils.pubdate'),
2445             'flex' : 1,
2446             'primary' : false,
2447             'hidden' : true,
2448             'editable' : false, 'render' : function(my) { return my.mvr.pubdate(); }
2449         },
2450         {
2451             'persist' : 'hidden width ordinal',
2452             'id' : 'publisher',
2453             'label' : document.getElementById('circStrings').getString('staff.circ.utils.publisher'),
2454             'flex' : 1,
2455             'primary' : false,
2456             'hidden' : true,
2457             'editable' : false, 'render' : function(my) { return my.mvr.publisher(); }
2458         },
2459         {
2460             'persist' : 'hidden width ordinal',
2461             'id' : 'tcn',
2462             'label' : document.getElementById('circStrings').getString('staff.circ.utils.tcn'),
2463             'flex' : 1,
2464             'primary' : false,
2465             'hidden' : true,
2466             'editable' : false, 'render' : function(my) { return my.mvr.tcn(); }
2467         },
2468         {
2469             'persist' : 'hidden width ordinal',
2470             'id' : 'notify_time',
2471             'label' : document.getElementById('circStrings').getString('staff.circ.utils.notify_time'),
2472             'flex' : 1,
2473             'sort_type' : 'date',
2474             'primary' : false,
2475             'hidden' : true,
2476             'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.ahr.notify_time(), '%{localized}' ); }
2477             ,'sort_value' : function(my) {
2478                 return util.date.db_date2Date(
2479                     my.ahr
2480                     ? my.ahr.notify_time()
2481                     : null
2482                 ).getTime();
2483             }
2484         },
2485         {
2486             'persist' : 'hidden width ordinal',
2487             'id' : 'notify_count',
2488             'label' : document.getElementById('circStrings').getString('staff.circ.utils.notify_count'),
2489             'flex' : 1,
2490             'primary' : false,
2491             'hidden' : true,
2492             'editable' : false, 'render' : function(my) { return my.ahr.notify_count(); }
2493         },
2494         {
2495             'persist' : 'hidden width ordinal',
2496             'id' : 'transit_source',
2497             'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_source'),
2498             'flex' : 1,
2499             'primary' : false,
2500             'hidden' : true,
2501             'editable' : false, 'render' : function(my) {
2502                 if (my.ahr.transit()) {
2503                     return data.hash.aou[ my.ahr.transit().source() ].shortname();
2504                 } else {
2505                     return "";
2506                 }
2507             }
2508         },
2509         {
2510             'persist' : 'hidden width ordinal',
2511             'id' : 'transit_source_send_time',
2512             'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_source_send_time'),
2513             'flex' : 1,
2514             'sort_type' : 'date',
2515             'primary' : false,
2516             'hidden' : true,
2517             'editable' : false, 'render' : function(my) { return my.ahr.transit() ?  util.date.formatted_date( my.ahr.transit().source_send_time(), '%{localized}' ) : ""; }
2518             ,'sort_value' : function(my) {
2519                 return util.date.db_date2Date(
2520                     my.ahr
2521                     ? my.ahr.transit().source_send_time()
2522                     : null
2523                 ).getTime();
2524             }
2525         },
2526         {
2527             'persist' : 'hidden width ordinal',
2528             'id' : 'transit_dest_lib',
2529             'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_dest'),
2530             'flex' : 1,
2531             'primary' : false,
2532             'hidden' : true,
2533             'editable' : false, 'render' : function(my) { return my.ahr.transit() ?  data.hash.aou[ my.ahr.transit().dest() ].shortname() : ""; }
2534         },
2535         {
2536             'persist' : 'hidden width ordinal',
2537             'id' : 'transit_dest_recv_time',
2538             'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_dest_recv_time'),
2539             'flex' : 1,
2540             'sort_type' : 'date',
2541             'primary' : false,
2542             'hidden' : true,
2543             'editable' : false, 'render' : function(my) { return my.ahr.transit() ?  util.date.formatted_date( my.ahr.transit().dest_recv_time(), '%{localized}' ) : ""; }
2544             ,'sort_value' : function(my) {
2545                 return util.date.db_date2Date(
2546                     my.ahr
2547                     ? my.ahr.transit().dest_recv_time()
2548                     : null
2549                 ).getTime();
2550             }
2551         },
2552         {
2553             'persist' : 'hidden width ordinal',
2554             'id' : 'patron_barcode',
2555             'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.patron_barcode'),
2556             'flex' : 1,
2557             'primary' : false,
2558             'hidden' : true,
2559             'editable' : false, 'render' : function(my) { return my.patron_barcode ? my.patron_barcode : ""; }
2560         },
2561         {
2562             'persist' : 'hidden width ordinal',
2563             'id' : 'patron_family_name',
2564             'label' : document.getElementById('circStrings').getString('staff.circ.utils.patron_family_name'),
2565             'flex' : 1,
2566             'primary' : false,
2567             'hidden' : true,
2568             'editable' : false, 'render' : function(my) { return my.patron_family_name ? my.patron_family_name : ""; }
2569         },
2570         {
2571             "persist": "hidden width ordinal",
2572             "id": "patron_alias",
2573             'label' : document.getElementById('circStrings').getString('staff.circ.utils.patron_alias'),
2574             'flex' : 1,
2575             'primary' : false,
2576             'hidden' : true,
2577             'editable' : false, 'render' : function(my) { return my.patron_alias ? my.patron_alias : ""; }
2578         },
2579         {
2580             'persist' : 'hidden width ordinal',
2581             'id' : 'patron_first_given_name',
2582             'label' : document.getElementById('circStrings').getString('staff.circ.utils.patron_first_given_name'),
2583             'flex' : 1,
2584             'primary' : false,
2585             'hidden' : true,
2586             'editable' : false, 'render' : function(my) { return my.patron_first_given_name ? my.patron_first_given_name : ""; }
2587         },
2588         {
2589             'id' : 'callnumber',
2590             'fm_class' : 'acp',
2591             'label' : document.getElementById('commonStrings').getString('staff.acp_label_call_number'),
2592             'flex' : 1,
2593             'primary' : false,
2594             'hidden' : true,
2595             'editable' : false, 'render' : function(my,scratch_data) {
2596                 var acn_id;
2597                 if (my.acn) {
2598                     if (typeof my.acn == 'object') {
2599                         acn_id = my.acn.id();
2600                     } else {
2601                         acn_id = my.acn;
2602                     }
2603                 } else if (my.acp) {
2604                     if (typeof my.acp.call_number() == 'object' && my.acp.call_number() != null) {
2605                         acn_id = my.acp.call_number().id();
2606                     } else {
2607                         acn_id = my.acp.call_number();
2608                     }
2609                 }
2610                 if (!acn_id && acn_id != 0) {
2611                     return '';
2612                 } else if (acn_id == -1) {
2613                     return document.getElementById('circStrings').getString('staff.circ.utils.not_cataloged');
2614                 } else if (acn_id == -2) {
2615                     return document.getElementById('circStrings').getString('staff.circ.utils.retrieving');
2616                 } else {
2617                     if (!my.acn) {
2618                         if (typeof scratch_data == 'undefined' || scratch_data == null) {
2619                             scratch_data = {};
2620                         }
2621                         if (typeof scratch_data['acn_map'] == 'undefined') {
2622                             scratch_data['acn_map'] = {};
2623                         }
2624                         if (typeof scratch_data['acn_map'][ acn_id ] == 'undefined') {
2625                             var x = network.simple_request("FM_ACN_RETRIEVE.authoritative",[ acn_id ]);
2626                             if (x.ilsevent) {
2627                                 return document.getElementById('circStrings').getString('staff.circ.utils.not_cataloged');
2628                             } else {
2629                                 my.acn = x;
2630                                 scratch_data['acn_map'][ acn_id ] = my.acn;
2631                             }
2632                         } else {
2633                             my.acn = scratch_data['acn_map'][ acn_id ];
2634                         }
2635                     }
2636                     return my.acn.label();
2637                 }
2638             },
2639             'persist' : 'hidden width ordinal'
2640         },
2641         {
2642             'id' : 'prefix',
2643             'fm_class' : 'acn',
2644             'label' : document.getElementById('circStrings').getString('staff.circ.utils.prefix'),
2645             'flex' : 1,
2646             'primary' : false,
2647             'hidden' : true,
2648             'editable' : false, 'render' : function(my) {
2649                 if (typeof my.acn == 'undefined') return '';
2650                 return (typeof my.acn.prefix() == 'object')
2651                     ? my.acn.prefix().label()
2652                     : data.lookup("acnp", my.acn.prefix() ).label();
2653             },
2654             'persist' : 'hidden width ordinal'
2655         },
2656         {
2657             'id' : 'suffix',
2658             'fm_class' : 'acn',
2659             'label' : document.getElementById('circStrings').getString('staff.circ.utils.suffix'),
2660             'flex' : 1,
2661             'primary' : false,
2662             'hidden' : true,
2663             'editable' : false, 'render' : function(my) {
2664                 if (typeof my.acn == 'undefined') return '';
2665                 return (typeof my.acn.suffix() == 'object')
2666                     ? my.acn.suffix().label()
2667                     : data.lookup("acns", my.acn.suffix() ).label();
2668             },
2669             'persist' : 'hidden width ordinal'
2670         },
2671         {
2672             'persist' : 'hidden width ordinal',
2673             'id' : 'total_holds',
2674             'label' : document.getElementById('circStrings').getString('staff.circ.utils.total_holds'),
2675             'flex' : 1,
2676             'primary' : false,
2677             'hidden' : true,
2678             'editable' : false, 'render' : function(my) { return my.total_holds; }
2679         },
2680                 {
2681             'persist' : 'hidden width ordinal',
2682             'id' : 'queue_position',
2683             'sort_type' : 'number',
2684             'label' : document.getElementById('circStrings').getString('staff.circ.utils.queue_position'),
2685             'flex' : 1,
2686             'primary' : false,
2687             'hidden' : true,
2688             'editable' : false, 'render' : function(my) { return my.queue_position; }
2689         },
2690                 {
2691             'persist' : 'hidden width ordinal',
2692             'id' : 'potential_copies',
2693             'label' : document.getElementById('circStrings').getString('staff.circ.utils.potential_copies'),
2694             'flex' : 1,
2695             'primary' : false,
2696             'hidden' : true,
2697             'editable' : false, 'render' : function(my) { return my.potential_copies; }
2698         },
2699                 {
2700             'persist' : 'hidden width ordinal',
2701             'id' : 'estimated_wait',
2702             'label' : document.getElementById('circStrings').getString('staff.circ.utils.estimated_wait'),
2703             'flex' : 1,
2704             'primary' : false,
2705             'hidden' : true,
2706             'editable' : false, 'render' : function(my) { return my.estimated_wait; }
2707         },
2708         {
2709             'persist' : 'hidden width ordinal',
2710             'id' : 'hold_note',
2711             'label' : document.getElementById('circStrings').getString('staff.circ.utils.hold_note'),
2712             'flex' : 1,
2713             'primary' : false,
2714             'hidden' : true,
2715             'editable' : false, 'render' : function(my) { return my.ahrn_count; }
2716         },
2717         {
2718             'persist' : 'hidden width ordinal',
2719             'id' : 'hold_note_text',
2720             'label' : document.getElementById('circStrings').getString('staff.circ.utils.hold_note_text'),
2721             'flex' : 1,
2722             'primary' : false,
2723             'hidden' : true,
2724             'editable' : false, 'render' : function(my) {
2725                 var s = '';
2726                 var notes = my.ahr.notes();
2727                 for (var i = 0; i < notes.length; i++) {
2728                     s += notes[i].title() + ':' + notes[i].body() + '; \n';
2729                 }
2730                 return s;
2731             }
2732         },
2733         {
2734             'persist' : 'hidden width ordinal',
2735             'id' : 'staff_hold',
2736             'label' : document.getElementById('circStrings').getString('staff.circ.utils.staff_hold'),
2737             'flex' : 1,
2738             'primary' : false,
2739             'hidden' : true,
2740             'editable' : false, 
2741             'render' : function(my) {
2742                 if (my.ahr.usr() != my.ahr.requestor()){
2743                     return document.getElementById('circStrings').getString('staff.circ.utils.yes');
2744                 } else {
2745                     return document.getElementById('circStrings').getString('staff.circ.utils.no');
2746                 }
2747             }
2748         }
2749     ];
2750     for (var i = 0; i < c.length; i++) {
2751         if (modify[ c[i].id ]) {
2752             for (var j in modify[ c[i].id ]) {
2753                 c[i][j] = modify[ c[i].id ][j];
2754             }
2755         }
2756     }
2757     if (params) {
2758         if (params.just_these) {
2759             JSAN.use('util.functional');
2760             var new_c = [];
2761             for (var i = 0; i < params.just_these.length; i++) {
2762                 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
2763                 new_c.push( function(y){ return y; }( x ) );
2764             }
2765             c = new_c;
2766         }
2767         if (params.except_these) {
2768             JSAN.use('util.functional');
2769             var new_c = [];
2770             for (var i = 0; i < c.length; i++) {
2771                 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
2772                 if (!x) new_c.push(c[i]);
2773             }
2774             c = new_c;
2775         }
2776
2777     }
2778     return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
2779 };
2780
2781 circ.util.checkin_via_barcode = function(session,params,backdate,auto_print,async) {
2782     try {
2783         JSAN.use('util.error'); var error = new util.error();
2784         JSAN.use('util.network'); var network = new util.network();
2785         JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
2786         JSAN.use('util.date'); JSAN.use('util.functional');
2787
2788         if (backdate && (backdate == util.date.formatted_date(new Date(),'%Y-%m-%d')) ) backdate = null;
2789
2790         //var params = { 'barcode' : barcode };
2791         if (backdate) params.backdate = util.date.formatted_date(backdate,'%{iso8601}');
2792
2793         if (typeof params.disable_textbox == 'function') {
2794             try { params.disable_textbox(); }
2795             catch(E) { error.sdump('D_ERROR','params.disable_textbox() = ' + E); };
2796         }
2797
2798         function checkin_callback(req) {
2799             JSAN.use('util.error'); var error = new util.error();
2800             try {
2801                 var check = req.getResultObject();
2802                 var r = circ.util.checkin_via_barcode2(session,params,backdate,auto_print,check);
2803                 try {
2804                     error.work_log(
2805                         document.getElementById('circStrings').getFormattedString(
2806                             'staff.circ.work_log_checkin_attempt.' + r.what_happened + '.message',
2807                             [
2808                                 ses('staff_usrname'),
2809                                 r.payload.patron ? r.payload.patron.family_name() : '',
2810                                 r.payload.patron ? r.payload.patron.card().barcode() : '',
2811                                 r.payload.copy ? r.payload.copy.barcode() : '',
2812                                 r.route_to ? r.route_to : ''
2813                             ]
2814                         ), {
2815                             'au_id' : r.payload.patron ? r.payload.patron.id() : '',
2816                             'au_family_name' : r.payload.patron ? r.payload.patron.family_name() : '',
2817                             'au_barcode' : r.payload.patron ? r.payload.patron.card().barcode() : '',
2818                             'acp_barcode' : r.payload.copy ? r.payload.copy.barcode() : ''
2819                         }
2820                     );
2821                 } catch(E) {
2822                     error.sdump('D_ERROR','Error with work_logging in server/circ/checkout.js, _checkout:' + E);
2823                 }
2824
2825                 if (typeof params.checkin_result == 'function') {
2826                     try { params.checkin_result(r); } catch(E) { error.sdump('D_ERROR','params.checkin_result() = ' + E); };
2827                 }
2828                 if (typeof async == 'function') async(check);
2829                 return check;
2830             } catch(E) {
2831                 error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.error', ['1']), E);
2832                 if (typeof params.enable_textbox == 'function') {
2833                     try { params.enable_textbox(); }
2834                     catch(E) { error.sdump('D_ERROR','params.disable_textbox() = ' + E); };
2835                 }
2836                 return null;
2837             }
2838         }
2839
2840         var suppress_popups = data.hash.aous['ui.circ.suppress_checkin_popups'];
2841
2842         var check = network.request(
2843             api.CHECKIN_VIA_BARCODE.app,
2844             api.CHECKIN_VIA_BARCODE.method,
2845             [ session, util.functional.filter_object( params, function(i,o) { return typeof o != 'function'; } ) ],
2846             async ? checkin_callback : null,
2847             {
2848                 'title' : document.getElementById('circStrings').getString('staff.circ.utils.checkin.override'),
2849                 'auto_override_these_events' : suppress_popups ? [
2850                     null /* custom event */,
2851                     1203 /* COPY_BAD_STATUS */,
2852                     1213 /* PATRON_BARRED */,
2853                     1217 /* PATRON_INACTIVE */,
2854                     1224 /* PATRON_ACCOUNT_EXPIRED */,
2855                     1234 /* ITEM_DEPOSIT_PAID */,
2856                     7009 /* CIRC_CLAIMS_RETURNED */,
2857                     7010 /* COPY_ALERT_MESSAGE */,
2858                     7011 /* COPY_STATUS_LOST */,
2859                     7012 /* COPY_STATUS_MISSING */,
2860                     7013 /* PATRON_EXCEEDS_FINES */
2861                 ] : [],
2862                 'overridable_events' : [
2863                     null /* custom event */,
2864                     1203 /* COPY_BAD_STATUS */,
2865                     1213 /* PATRON_BARRED */,
2866                     1217 /* PATRON_INACTIVE */,
2867                     1224 /* PATRON_ACCOUNT_EXPIRED */,
2868                     1234 /* ITEM_DEPOSIT_PAID */,
2869                     7009 /* CIRC_CLAIMS_RETURNED */,
2870                     7010 /* COPY_ALERT_MESSAGE */,
2871                     7011 /* COPY_STATUS_LOST */,
2872                     7012 /* COPY_STATUS_MISSING */,
2873                     7013 /* PATRON_EXCEEDS_FINES */,
2874                     11103 /* TRANSIT_CHECKIN_INTERVAL_BLOCK */ 
2875                 ],
2876                 'text' : {
2877                     '1203' : function(r) {
2878                         return typeof r.payload.status() == 'object' ? r.payload.status().name() : data.hash.ccs[ r.payload.status() ].name();
2879                     },
2880                     '1234' : function(r) {
2881                         return document.getElementById('circStrings').getString('staff.circ.utils.checkin.override.item_deposit_paid.warning');
2882                     },
2883                     '7010' : function(r) {
2884                         return r.payload;
2885                     }
2886                 }
2887             }
2888         );
2889         if (! async ) {
2890             return checkin_callback( { 'getResultObject' : function() { return check; } } );
2891         }
2892
2893
2894     } catch(E) {
2895         JSAN.use('util.error'); var error = new util.error();
2896         error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.error', ['2']), E);
2897         if (typeof params.enable_textbox == 'function') {
2898             try { params.enable_textbox(); } catch(E) { error.sdump('D_ERROR','params.disable_textbox() = ' + E); };
2899         }
2900         return null;
2901     }
2902 };
2903
2904 circ.util.checkin_via_barcode2 = function(session,params,backdate,auto_print,check) {
2905     try {
2906         JSAN.use('util.error'); var error = new util.error();
2907         JSAN.use('util.network'); var network = new util.network();
2908         JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
2909         JSAN.use('util.date');
2910         JSAN.use('util.sound'); var sound = new util.sound();
2911
2912         dump('check = ' + error.pretty_print( js2JSON( check ) ) + '\n' );
2913
2914         check.message = check.textcode;
2915
2916         if (check.payload && check.payload.copy) { check.copy = check.payload.copy; }
2917         if (check.payload && check.payload.volume) { check.volume = check.payload.volume; }
2918         if (check.payload && check.payload.record) { check.record = check.payload.record; }
2919         if (check.payload && check.payload.circ) { check.circ = check.payload.circ; }
2920         if (check.payload && check.payload.patron) { check.patron = check.payload.patron; }
2921
2922         if (!check.route_to) { check.route_to = '   '; }
2923
2924         var no_change_label = document.getElementById('no_change_label');
2925
2926         if (no_change_label) {
2927             no_change_label.setAttribute('value','');
2928             no_change_label.setAttribute('hidden','true');
2929             no_change_label.setAttribute('onclick','');
2930             removeCSSClass(no_change_label,'click_link');
2931             no_change_label.setAttribute('unique_row_counter','');
2932         }
2933
2934         var msg = '';
2935         var print_list = [];
2936         var print_data = { 
2937             'error' : '',
2938             'error_msg' : '',
2939             'cancelled' : '',
2940             'route_to' : '',
2941             'route_to_msg' : '',
2942             'route_to_org_fullname' : '',
2943             'destination_shelf' : '',
2944             'destination_shelf_msg' : '',
2945             'courier_code' : '',
2946             'street1' : '',
2947             'street2' : '',
2948             'city_state_zip' : '',
2949             'city' : '',
2950             'state' : '',
2951             'county' : '',
2952             'country' : '',
2953             'post_code' : '',
2954             'item_barcode' : '',
2955             'item_barcode_msg' : '',
2956             'item_title' : '',
2957             'item_title_msg' : '',
2958             'item_author' : '',
2959             'item_author_msg' : '',
2960             'hold_for_msg' : '',
2961             'hold_for_alias' : '',
2962             'hold_for_family_name' : '',
2963             'hold_for_first_given_name' : '',
2964             'hold_for_second_given_name' : '',
2965             'user_barcode' : '',
2966             'user_barcode_msg' : '',
2967             'notify_by_phone' : '',
2968             'notify_by_phone_msg' : '',
2969             'notify_by_email' : '',
2970             'notify_by_email_msg' : '',
2971             'notify_by_text' : '',
2972             'notify_by_text_msg' : '',
2973             'request_date' : '',
2974             'request_date_msg' : '',
2975             'shelf_expire_time' : '',
2976             'slip_date' : '',
2977             'slip_date_msg' : '',
2978             'user' : '',
2979             'user_stat_cat_entries' : ''
2980         };
2981
2982         if (check.payload && check.payload.cancelled_hold_transit) {
2983             print_data.cancelled = document.getElementById('circStrings').getString('staff.circ.utils.transit_hold_cancelled');
2984             msg += print_data.cancelled;
2985             msg += '\n\n';
2986         }
2987
2988         var suppress_popups = data.hash.aous['ui.circ.suppress_checkin_popups'];
2989
2990         /* SUCCESS  /  NO_CHANGE  /  ITEM_NOT_CATALOGED */
2991         if (check.ilsevent == 0 || check.ilsevent == 3 || check.ilsevent == 1202) {
2992             try {
2993                 var acpl = data.lookup('acpl', check.copy.location()); 
2994                 check.route_to = acpl.name();
2995                 check.checkin_alert = isTrue(acpl.checkin_alert()) && !suppress_popups;
2996             } catch(E) {
2997                 print_data.error_msg = document.getElementById('commonStrings').getString('common.error');
2998                 print_data.error_msg += '\nFIXME: ' + E + '\n';
2999                 msg += print_data.error_msg;
3000             }
3001             if (check.ilsevent == 3 /* NO_CHANGE */) {
3002                 //msg = 'This item is already checked in.\n';
3003                 check.what_happened = 'no_change';
3004                 sound.special('checkin.no_change');
3005                 if (no_change_label) {
3006                     var m = no_change_label.getAttribute('value');
3007                     var text = document.getElementById('circStrings').getFormattedString('staff.circ.utils.item_checked_in', [params.barcode]);
3008                     no_change_label.setAttribute('value', m + text + '  ');
3009                     no_change_label.setAttribute('hidden','false');
3010                     no_change_label.setAttribute('onclick','');
3011                     removeCSSClass(no_change_label,'click_link');
3012                     no_change_label.setAttribute('unique_row_counter','');
3013                     if (typeof params.info_blurb == 'function') {
3014                         params.info_blurb( text );
3015                     }
3016                 }
3017             }
3018             if (check.ilsevent == 1202 /* ITEM_NOT_CATALOGED */ && check.copy.status() != 11) {
3019                 check.what_happened = 'error';
3020                 sound.special('checkin.error');
3021                 var copy_status = (data.hash.ccs[ check.copy.status() ] ? data.hash.ccs[ check.copy.status() ].name() : check.copy.status().name() );
3022                 var err_msg = document.getElementById('commonStrings').getString('common.error');
3023                 err_msg += '\nFIXME --';
3024                 err_msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.item_not_cataloged', [copy_status]);
3025                 err_msg += '\n';
3026                 msg += err_msg;
3027                 print_data.error_msg += err_msg;
3028             }
3029             switch(Number(check.copy.status())) {
3030                 case 0: /* AVAILABLE */
3031                 case 7: /* RESHELVING */
3032                     check.what_happened = 'success';
3033                     sound.special('checkin.success');
3034                     if (msg || check.checkin_alert) {
3035                         print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
3036                         print_data.route_to = check.route_to;
3037                         msg += print_data.route_to_msg;
3038                         msg += '\n';
3039                     }
3040                 break;
3041                 case 8: /* ON HOLDS SHELF */
3042                     check.what_happened = 'hold_shelf';
3043                     sound.special('checkin.hold_shelf');
3044                     check.route_to = document.getElementById('circStrings').getString('staff.circ.route_to.hold_shelf');
3045                     if (check.payload.hold) {
3046                         if (check.payload.hold.pickup_lib() != data.list.au[0].ws_ou()) {
3047                             check.what_happened = 'error';
3048                             sound.special('checkin.error');
3049                             var err_msg = document.getElementById('commonStrings').getString('common.error');
3050                             err_msg += '\nFIXME: ';
3051                             err_msg += document.getElementById('circStrings').getString('staff.circ.utils.route_item_error');
3052                             err_msg += '\n';
3053                             msg += err_msg;
3054                             print_data.error_msg += err_msg;
3055                         } else {
3056                             print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
3057                             print_data.route_to = check.route_to;
3058                             var behind_the_desk_support = String( data.hash.aous['circ.holds.behind_desk_pickup_supported'] ) == 'true';
3059                             if (behind_the_desk_support) {
3060                                var usr_settings = network.simple_request('FM_AUS_RETRIEVE',[ses(),check.payload.hold.usr()]); 
3061                                 if (typeof usr_settings['circ.holds_behind_desk'] != 'undefined') {
3062                                     if (usr_settings['circ.holds_behind_desk']) {
3063                                         print_data.prefer_behind_holds_desk = true;
3064                                         check.route_to = document.getElementById('circStrings').getString('staff.circ.route_to.private_hold_shelf');
3065                                         print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
3066                                         print_data.route_to = check.route_to;
3067                                     } else {
3068                                         check.route_to = document.getElementById('circStrings').getString('staff.circ.route_to.public_hold_shelf');
3069                                         print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
3070                                         print_data.route_to = check.route_to;
3071                                     }
3072                                 } else {
3073                                     check.route_to = document.getElementById('circStrings').getString('staff.circ.route_to.public_hold_shelf');
3074                                     print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
3075                                     print_data.route_to = check.route_to;
3076                                 }
3077                             }
3078                             print_data.destination_shelf_msg = print_data.route_to_msg;
3079                             print_data.destination_shelf = print_data.route_to;
3080                             msg += print_data.route_to_msg;
3081                             msg += '\n';
3082                         }
3083                     } else {
3084                         check.what_happened = 'error';
3085                         sound.special('checkin.error');
3086                         var err_msg = document.getElementById('commonStrings').getString('common.error');
3087                         err_msg += '\nFIXME: ';
3088                         err_msg += document.getElementById('circStrings').getString('staff.circ.utils.route_item_status_error');
3089                         err_msg += '\n';
3090                         msg += err_msg;
3091                         print_data.error_msg += err_msg;
3092                     }
3093                     JSAN.use('util.date');
3094                     if (check.payload.hold) {
3095                         JSAN.use('patron.util');
3096                         msg += '\n';
3097                         print_data.item_barcode_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [check.payload.copy.barcode()]);
3098                         print_data.item_barcode = check.payload.copy.barcode();
3099                         msg += print_data.item_barcode_msg;
3100                         msg += '\n';
3101                         var payload_title  = (check.payload.record ? check.payload.record.title() : check.payload.copy.dummy_title() );
3102                         print_data.item_title_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.title', [payload_title]);
3103                         print_data.item_title = payload_title;
3104                         msg += print_data.item_title_msg;
3105                         msg += '\n';
3106                         var au_obj = patron.util.retrieve_fleshed_au_via_id( session, check.payload.hold.usr() );
3107                         print_data.user = au_obj;
3108                         print_data.user_stat_cat_entries = [];
3109                         var entries = au_obj.stat_cat_entries();
3110                         for (var i = 0; i < entries.length; i++) {
3111                             var stat_cat = data.hash.my_actsc[ entries[i].stat_cat() ];
3112                             if (!stat_cat) {
3113                                 stat_cat = data.lookup('actsc', entries[i].stat_cat());
3114                             }
3115                             print_data.user_stat_cat_entries.push( { 
3116                                 'id' : entries[i].id(),
3117                                 'stat_cat' : {
3118                                     'id' : stat_cat.id(),
3119                                     'name' : stat_cat.name(),
3120                                     'opac_visible' : stat_cat.opac_visible(),
3121                                     'owner' : stat_cat.owner(),
3122                                     'usr_summary' : stat_cat.usr_summary()
3123                                 },
3124                                 'stat_cat_entry' : entries[i].stat_cat_entry(),
3125                                 'target_usr' : entries[i].target_usr() 
3126                             } );
3127                         }
3128                         msg += '\n';
3129                         if (au_obj.alias()) {
3130                             print_data.hold_for_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.patron_alias',  [au_obj.alias()]);
3131                             print_data.hold_for_alias = au_obj.alias();
3132                             msg += print_data.hold_for_msg;
3133                         } else {
3134                             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() : '']);
3135                             msg += print_data.hold_for_msg;
3136                             print_data.hold_for_family_name = au_obj.family_name() ? au_obj.family_name() : '';
3137                             print_data.hold_for_first_given_name = au_obj.first_given_name() ? au_obj.first_given_name() : '';
3138                             print_data.hold_for_second_given_name = au_obj.second_given_name() ? au_obj.second_given_name() : '';
3139                         }
3140                         msg += '\n';
3141                         print_data.user_barcode_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [au_obj.card().barcode()]);
3142                         print_data.user_barcode = au_obj.card().barcode();
3143                         msg += print_data.user_barcode_msg;
3144                         msg += '\n';
3145                         if (check.payload.hold.phone_notify()) {
3146                             print_data.notify_by_phone_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.phone_notify', [check.payload.hold.phone_notify()]);
3147                             print_data.notify_by_phone = check.payload.hold.phone_notify();
3148                             msg += print_data.notify_by_phone_msg;
3149                             msg += '\n';
3150                         }
3151                         if (check.payload.hold.sms_notify()) {
3152                             print_data.notify_by_text_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.sms_notify', [check.payload.hold.sms_notify()]);
3153                             print_data.notify_by_text = check.payload.hold.sms_notify();
3154                             msg += print_data.notify_by_text_msg;
3155                             msg += '\n';
3156                         }
3157                         if (get_bool(check.payload.hold.email_notify())) {
3158                             var payload_email = au_obj.email() ? au_obj.email() : '';
3159                             print_data.notify_by_email_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.email_notify', [payload_email]);
3160                             print_data.notify_by_email = payload_email;
3161                             msg += print_data.notify_by_email_msg;
3162                             msg += '\n';
3163                         }
3164                         msg += '\n';
3165                         var notes = check.payload.hold.notes();
3166                         print_data.notes_raw = notes;
3167                         for (var i = 0; i < notes.length; i++) {
3168                             if ( get_bool( notes[i].slip() ) ) {
3169                                 var temp_msg;
3170                                 if ( get_bool( notes[i].staff() ) ) {
3171                                     temp_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.notes.staff_note', [ notes[i].title(), notes[i].body() ]);
3172                                 } else {
3173                                     temp_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.notes.patron_note', [ notes[i].title(), notes[i].body() ]);
3174                                 }
3175                                 msg += temp_msg + '\n';
3176                                 print_list.push(
3177                                     {
3178                                         'formatted_note' : temp_msg,
3179                                         'note_title' : notes[i].title(),
3180                                         'note_body' : notes[i].body(),
3181                                         'note_public' : notes[i].pub(),
3182                                         'note_by_staff' : notes[i].staff()
3183                                     }
3184                                 );
3185                             }
3186                         }
3187                         msg += '\n';
3188                         msg += '\n';
3189                         print_data.request_date = util.date.formatted_date(check.payload.hold.request_time(),'%F');
3190                         print_data.request_date_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.request_date', [print_data.request_date]);
3191                         print_data.shelf_expire_time = check.payload.hold.shelf_expire_time();
3192                         msg += print_data.request_date_msg;
3193                         msg += '\n';
3194                     }
3195                     var rv = 0;
3196                     if (suppress_popups) {
3197                         rv = auto_print ? 0 : -1; auto_print = true; // skip dialog and PRINT or DO NOT PRINT based on Auto-Print checkbox
3198                     }
3199                     var x = data.hash.aous['circ.staff_client.do_not_auto_attempt_print'];
3200                     var no_print_prompting = x ? ( x.indexOf( "Hold Slip" ) > -1) : false;
3201                     if (no_print_prompting) {
3202                         rv = -1; auto_print = true; // DO NOT PRINT and skip dialog
3203                     }
3204                     print_data.slip_date = util.date.formatted_date(new Date(),'%F');
3205                     print_data.slip_date_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.slip_date', [print_data.slip_date]);
3206                     msg += print_data.slip_date_msg;
3207                     msg += '\n';
3208                     print_data.payload = check.payload;
3209
3210                     if (!auto_print) {
3211                         rv = error.yns_alert_formatted(
3212                             msg,
3213                             document.getElementById('circStrings').getString('staff.circ.utils.hold_slip'),
3214                             document.getElementById('circStrings').getString('staff.circ.utils.hold_slip.print.yes'),
3215                             document.getElementById('circStrings').getString('staff.circ.utils.hold_slip.print.no'),
3216                             null,
3217                             document.getElementById('circStrings').getString('staff.circ.confirm.msg'),
3218                             '/xul/server/skin/media/images/turtle.gif'
3219                         );
3220                     } else {
3221                         if (suppress_popups && !no_print_prompting) {
3222                             // FIXME: Add SFX and/or GFX
3223                             sound.circ_bad();
3224                         }
3225                     }
3226                     if (rv == 0) {
3227                         try {
3228                             JSAN.use('util.print'); var print = new util.print();
3229                             var old_template = String( data.hash.aous['ui.circ.old_harcoded_slip_template'] ) == 'true';
3230                             if (old_template) {
3231                                 msg = msg.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\n/g,'<br/>');
3232                                 print.simple( msg , { 'no_prompt' : true, 'content_type' : 'text/html' } );
3233                             } else {
3234                                 var template = 'hold_slip';
3235                                 var parms = {
3236                                     'patron' : print_data.user,
3237                                     'lib' : data.hash.aou[ check.payload.hold.pickup_lib() ],
3238                                     'staff' : data.list.au[0],
3239                                     'header' : data.print_list_templates[ template ].header,
3240                                     'line_item' : data.print_list_templates[ template ].line_item,
3241                                     'footer' : data.print_list_templates[ template ].footer,
3242                                     'type' : data.print_list_templates[ template ].type,
3243                                     'list' : print_list,
3244                                     'data' : print_data,
3245                                     'context' : data.print_list_templates[ template ].context,
3246                                 };
3247                                 if ($('printer_prompt')) {
3248                                     if (! $('printer_prompt').checked) { parms.no_prompt = true; }
3249                                 }
3250                                 print.tree_list( parms );
3251                             }
3252                         } catch(E) {
3253                             var err_msg = document.getElementById('commonStrings').getString('common.error');
3254                             err_msg += '\nFIXME: ' + E + '\n';
3255                             dump(err_msg);
3256                             alert(err_msg);
3257                         }
3258                     }
3259                     msg = '';
3260                     if (no_change_label) {
3261                         var m = no_change_label.getAttribute('value');
3262                         var text = document.getElementById('circStrings').getFormattedString('staff.circ.utils.capture', [params.barcode]);
3263                         m += text + '  ';
3264                         no_change_label.setAttribute('value', m);
3265                         no_change_label.setAttribute('hidden','false');
3266                         no_change_label.setAttribute('onclick','');
3267                         removeCSSClass(no_change_label,'click_link');
3268                         no_change_label.setAttribute('unique_row_counter','');
3269                         if (typeof params.info_blurb == 'function') {
3270                             params.info_blurb( text );
3271                         }
3272                     }
3273                 break;
3274                 case 6: /* IN TRANSIT */
3275                     check.what_happened = 'error';
3276                     sound.special('checkin.error');
3277                     check.route_to = 'TRANSIT SHELF??';
3278                     print_data.route_to;
3279                     var err_msg = document.getElementById('commonStrings').getString('common.error');
3280                     err_msg += "\nFIXME -- I didn't think we could get here.\n";
3281                     print_data.error_msg += err_msg;
3282                     msg += err_msg;
3283                 break;
3284                 case 11: /* CATALOGING */
3285                     check.what_happened = 'cataloging';
3286                     sound.special('checkin.cataloging');
3287                     check.route_to = 'CATALOGING';
3288                     print_data.route_to;
3289                     var x = document.getElementById('do_not_alert_on_precat');
3290                     var do_not_alert_on_precats = x ? ( x.getAttribute('checked') == 'true' ) : false;
3291                     if ( !suppress_popups && !do_not_alert_on_precats ) {
3292                         print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
3293                         msg += print_data.route_to_msg;
3294                     } else {
3295                         if (suppress_popups && !do_not_alert_on_precats) {
3296                             // FIXME: add SFX and/or GFX
3297                             sound.circ_bad();
3298                         }
3299                     }
3300                     if (no_change_label) {
3301                         var m = no_change_label.getAttribute('value');
3302                         var needs_cat = document.getElementById('circStrings').getFormattedString('staff.circ.utils.needs_cataloging', [params.barcode]);
3303                         no_change_label.setAttribute('value', m + needs_cat + '  ');
3304                         no_change_label.setAttribute('hidden','false');
3305                         no_change_label.setAttribute('onclick','');
3306                         removeCSSClass(no_change_label,'click_link');
3307                         no_change_label.setAttribute('unique_row_counter','');
3308                         if (typeof params.info_blurb == 'function') {
3309                             params.info_blurb( needs_cat );
3310                         }
3311                     }
3312                 break;
3313                 case 15: // ON_RESERVATION_SHELF
3314                     check.route_to = 'RESERVATION SHELF';
3315                     check.what_happened = "reservation_shelf";
3316                     sound.special('checkin.reservation_shelf');
3317                     if (check.payload.reservation) {
3318                         if (check.payload.reservation.pickup_lib() != data.list.au[0].ws_ou()) {
3319                             msg += document.getElementById('commonStrings').getString('common.error');
3320                             msg += '\nFIXME: ';
3321                             msg += document.getElementById('circStrings').getString('staff.circ.utils.route_item_error');
3322                             msg += '\n';
3323                         } else {
3324                             msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
3325                             msg += '.\n';
3326                         }
3327                     } else {
3328                         msg += document.getElementById('commonStrings').getString('common.error');
3329                         msg += '\nFIXME: ';
3330                         msg += document.getElementById('circStrings').getString('staff.circ.utils.reservation_status_error');
3331                         msg += '\n';
3332                     }
3333                     JSAN.use('util.date');
3334                     if (check.payload.reservation) {
3335                         JSAN.use('patron.util');
3336                         msg += '\n';
3337                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.reservation.barcode', [check.payload.copy.barcode()]);
3338                         msg += '\n';
3339                         var payload_title  = (check.payload.record ? check.payload.record.title() : check.payload.copy.dummy_title() );
3340                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.reservation.title', [payload_title]);
3341                         msg += '\n';
3342                         var au_obj =
3343                             typeof(check.payload.reservation.usr().card) == "function" ?
3344                                 check.payload.reservation.usr() :
3345                                 patron.util.retrieve_fleshed_au_via_id(session, check.payload.reservation.usr());
3346                         msg += '\n';
3347                         if (au_obj.alias()) {
3348                             msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.reservation.patron_alias',  [au_obj.alias()]);
3349                         } else {
3350                             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() || ""]);
3351                         }
3352                         msg += '\n';
3353                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.reservation.barcode', [au_obj.card().barcode()]);
3354                         msg += '\n';
3355                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.reservation.request_date', [util.date.formatted_date(check.payload.reservation.request_time(),'%F %H:%M')]);
3356                         msg += '\n';
3357
3358                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.reservation.start_date', [util.date.formatted_date(check.payload.reservation.start_time(),'%F %H:%M')]);
3359                         msg += '\n';
3360                     }
3361                     var rv = 0;
3362                     msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.reservation.slip_date', [util.date.formatted_date(new Date(),'%F')]);
3363                     msg += '\n';
3364                     if (!auto_print) {
3365                         rv = error.yns_alert_formatted(
3366                             msg,
3367                             document.getElementById('circStrings').getString('staff.circ.utils.reservation_slip'),
3368                             document.getElementById('circStrings').getString('staff.circ.utils.reservation_slip.print.yes'),
3369                             document.getElementById('circStrings').getString('staff.circ.utils.reservation_slip.print.no'),
3370                             null,
3371                             document.getElementById('circStrings').getString('staff.circ.confirm.msg'),
3372                             '/xul/server/skin/media/images/turtle.gif'
3373                         );
3374                     }
3375                     if (rv == 0) {
3376                         try {
3377                             JSAN.use('util.print'); var print = new util.print();
3378                             msg = msg.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\n/g,'<br/>');
3379                             print.simple( msg , { 'no_prompt' : true, 'content_type' : 'text/html' } );
3380                         } catch(E) {
3381                             var err_msg = document.getElementById('commonStrings').getString('common.error');
3382                             err_msg += '\nFIXME: ' + E + '\n';
3383                             dump(err_msg);
3384                             alert(err_msg);
3385                         }
3386                     }
3387                     msg = '';
3388                     if (no_change_label) {
3389                         var m = no_change_label.getAttribute('value');
3390                         var text = document.getElementById('circStrings').getFormattedString('staff.circ.utils.reservation_capture', [params.barcode]);
3391                         m += text + '  ';
3392                         no_change_label.setAttribute('value', m);
3393                         no_change_label.setAttribute('hidden','false');
3394                         no_change_label.setAttribute('onclick','');
3395                         removeCSSClass(no_change_label,'click_link');
3396                         no_change_label.setAttribute('unique_row_counter','');
3397                         if (typeof params.info_blurb == 'function') {
3398                             params.info_blurb( text );
3399                         }
3400                     }
3401                 break;
3402                 default:
3403                     check.what_happened = 'error';
3404                     sound.special('checkin.error');
3405                     msg += document.getElementById('commonStrings').getString('common.error');
3406                     var copy_status = data.hash.ccs[check.copy.status()] ? data.hash.ccs[check.copy.status()].name() : check.copy.status().name();
3407                     msg += '\n';
3408                     var error_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.copy_status.error', [copy_status]);
3409                     print_data.error_msg += error_msg;
3410                     msg += error_msg;
3411                     msg += '\n';
3412                     print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
3413                     msg += print_data.route_to_msg;
3414                 break;
3415             }
3416             if (msg) {
3417                 error.yns_alert(
3418                     msg,
3419                     document.getElementById('circStrings').getString('staff.circ.alert'),
3420                     null,
3421                     document.getElementById('circStrings').getString('staff.circ.utils.msg.ok'),
3422                     null,
3423                     document.getElementById('circStrings').getString('staff.circ.confirm.msg')
3424                 );
3425             }
3426         } else /* ROUTE_ITEM */ if (check.ilsevent == 7000) {
3427
3428             check.what_happened = 'transit';
3429             sound.special('checkin.transit');
3430             var lib = data.hash.aou[ check.org ];
3431             check.route_to = lib.shortname();
3432             print_data.route_to = check.route_to;
3433             print_data.route_to_org = lib;
3434             print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.destination', [check.route_to]);
3435             print_data.route_to_org_fullname = lib.name();
3436             var aous_req = network.simple_request('FM_AOUS_SPECIFIC_RETRIEVE',[ lib.id(), 'lib.courier_code' ]);
3437             if (aous_req) {
3438                 print_data.courier_code = aous_req.value || '';
3439             }
3440             msg += print_data.route_to_msg;
3441             msg += '\n\n';
3442             msg += lib.name();
3443             msg += '\n';
3444             try {
3445                 if (lib.holds_address() ) {
3446                     var a = network.simple_request('FM_AOA_RETRIEVE',[ lib.holds_address() ]);
3447                     if (typeof a.ilsevent != 'undefined') throw(a);
3448                     if (a.street1()) { msg += a.street1() + '\n'; print_data.street1 = a.street1(); }
3449                     if (a.street2()) { msg += a.street2() + '\n'; print_data.street2 = a.street2(); }
3450                     print_data.city_state_zip = (a.city() ? a.city() + ', ' : '') + (a.state() ? a.state() + ' ' : '') + (a.post_code() ? a.post_code() : '');
3451                     print_data.city = a.city();
3452                     print_data.state = a.state();
3453                     print_data.county = a.county();
3454                     print_data.country = a.country();
3455                     print_data.post_code = a.post_code();
3456                     msg += print_data.city_state_zip + '\n';
3457                 } else {
3458                     print_data.street1 = document.getElementById('circStrings').getString('staff.circ.utils.route_to.no_address');
3459                     print_data.no_address = true;
3460                     msg += print_data.street1;
3461                     msg += '\n';
3462                 }
3463             } catch(E) {
3464                 var err_msg = document.getElementById('circStrings').getString('staff.circ.utils.route_to.no_address.error');
3465                 print_data.error_msg += err_msg + '\n';
3466                 msg += err_msg + '\n';
3467                 error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.utils.route_to.no_address.error'), E);
3468             }
3469             msg += '\n';
3470             print_data.item_barcode_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [check.payload.copy.barcode()]);
3471             print_data.item_barcode = check.payload.copy.barcode();
3472             msg += print_data.item_barcode_msg;
3473             msg += '\n';
3474             var payload_title  = (check.payload.record ? check.payload.record.title() : check.payload.copy.dummy_title() );
3475             print_data.item_title_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.title', [payload_title]);
3476             print_data.item_title = payload_title;
3477             msg += print_data.item_title_msg;
3478             msg += '\n';
3479             var payload_author = (check.payload.record ? check.payload.record.author() :check.payload.copy.dummy_author());
3480             print_data.item_author_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.author', [payload_author]);
3481             print_data.item_author = payload_author;
3482             msg += print_data.item_author_msg;
3483             msg += '\n';
3484             JSAN.use('util.date');
3485             if (check.payload.hold) {
3486                 check.what_happened = 'transit_for_hold';
3487                 sound.special('checkin.transit_for_hold');
3488                 JSAN.use('patron.util');
3489                 var au_obj = patron.util.retrieve_fleshed_au_via_id( session, check.payload.hold.usr() );
3490                 print_data.user = au_obj;
3491                 print_data.user_stat_cat_entries = [];
3492                 var entries = au_obj.stat_cat_entries();
3493                 for (var i = 0; i < entries.length; i++) {
3494                     var stat_cat = data.hash.my_actsc[ entries[i].stat_cat() ];
3495                     if (!stat_cat) {
3496                         stat_cat = data.lookup('actsc', entries[i].stat_cat());
3497                     }
3498                     print_data.user_stat_cat_entries.push( { 
3499                         'id' : entries[i].id(),
3500                         'stat_cat' : {
3501                             'id' : stat_cat.id(),
3502                             'name' : stat_cat.name(),
3503                             'opac_visible' : stat_cat.opac_visible(),
3504                             'owner' : stat_cat.owner(),
3505                             'usr_summary' : stat_cat.usr_summary()
3506                         },
3507                         'stat_cat_entry' : entries[i].stat_cat_entry(),
3508                         'target_usr' : entries[i].target_usr() 
3509                     } );
3510                 }
3511                 msg += '\n';
3512                 if (au_obj.alias()) {
3513                     print_data.hold_for_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.patron_alias',  [au_obj.alias()]);
3514                     print_data.hold_for_alias = au_obj.alias();
3515                     msg += print_data.hold_for_msg;
3516                 } else {
3517                     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() : '']);
3518                     msg += print_data.hold_for_msg;
3519                     print_data.hold_for_family_name = au_obj.family_name() ? au_obj.family_name() : '';
3520                     print_data.hold_for_first_given_name = au_obj.first_given_name() ? au_obj.first_given_name() : '';
3521                     print_data.hold_for_second_given_name = au_obj.second_given_name() ? au_obj.second_given_name() : '';
3522                 }
3523                 msg += '\n';
3524                 print_data.user_barcode_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [au_obj.card().barcode()]);
3525                 print_data.user_barcode = au_obj.card().barcode();
3526                 msg += print_data.user_barcode_msg;
3527                 msg += '\n';
3528                 if (check.payload.hold.phone_notify()) {
3529                     print_data.notify_by_phone_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.phone_notify', [check.payload.hold.phone_notify()]);
3530                     print_data.notify_by_phone = check.payload.hold.phone_notify();
3531                     msg += print_data.notify_by_phone_msg;
3532                     msg += '\n';
3533                 }
3534                 if (check.payload.hold.sms_notify()) {
3535                     print_data.notify_by_text_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.sms_notify', [check.payload.hold.sms_notify()]);
3536                     print_data.notify_by_text = check.payload.hold.sms_notify();
3537                     msg += print_data.notify_by_text_msg;
3538                     msg += '\n';
3539                 }
3540                 if (get_bool(check.payload.hold.email_notify())) {
3541                     var payload_email = au_obj.email() ? au_obj.email() : '';
3542                     print_data.notify_by_email_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.email_notify', [payload_email]);
3543                     print_data.notify_by_email = payload_email;
3544                     msg += print_data.notify_by_email_msg;
3545                     msg += '\n';
3546                 }
3547                 msg += '\n';
3548                 var notes = check.payload.hold.notes();
3549                 print_data.notes_raw = notes;
3550                 for (var i = 0; i < notes.length; i++) {
3551                     if ( get_bool( notes[i].slip() ) ) {
3552                         var temp_msg;
3553                         if ( get_bool( notes[i].staff() ) ) {
3554                             temp_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.notes.staff_note', [ notes[i].title(), notes[i].body() ]);
3555                         } else {
3556                             temp_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.notes.patron_note', [ notes[i].title(), notes[i].body() ]);
3557                         }
3558                         msg += temp_msg + '\n';
3559                         print_list.push(
3560                             {
3561                                 'formatted_note' : temp_msg,
3562                                 'note_title' : notes[i].title(),
3563                                 'note_body' : notes[i].body(),
3564                                 'note_public' : notes[i].pub(),
3565                                 'note_by_staff' : notes[i].staff()
3566                             }
3567                         );
3568                     }
3569                 }
3570                 msg += '\n';
3571                 msg += '\n';
3572                 print_data.request_date = util.date.formatted_date(check.payload.hold.request_time(),'%F');
3573                 print_data.request_date_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.request_date', [print_data.request_date]);
3574                 msg += print_data.request_date_msg;
3575                 msg += '\n';
3576                 var destination_shelf = document.getElementById('circStrings').getString('staff.circ.route_to.hold_shelf');
3577                 print_data.destination_shelf_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [destination_shelf]);
3578                 print_data.destination_shelf = destination_shelf;
3579                 var behind_the_desk_support = String( data.hash.aous['circ.holds.behind_desk_pickup_supported'] ) == 'true';
3580                 if (behind_the_desk_support) {
3581                    var usr_settings = network.simple_request('FM_AUS_RETRIEVE',[ses(),check.payload.hold.usr()]); 
3582                     if (typeof usr_settings['circ.holds_behind_desk'] != 'undefined') {
3583                         if (usr_settings['circ.holds_behind_desk']) {
3584                             print_data.prefer_behind_holds_desk = true;
3585                             destination_shelf = document.getElementById('circStrings').getString('staff.circ.route_to.private_hold_shelf');
3586                             print_data.destination_shelf_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [destination_shelf]);
3587                             print_data.destination_shelf = destination_shelf;
3588                         } else {
3589                             destination_shelf = document.getElementById('circStrings').getString('staff.circ.route_to.public_hold_shelf');
3590                             print_data.destination_shelf_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [destination_shelf]);
3591                             print_data.destination_shelf = destination_shelf;
3592                         }
3593                     } else {
3594                         destination_shelf = document.getElementById('circStrings').getString('staff.circ.route_to.public_hold_shelf');
3595                         print_data.destination_shelf_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [destination_shelf]);
3596                         print_data.destination_shelf = destination_shelf;
3597                     }
3598                 }
3599             }
3600             var rv = 0;
3601             if (suppress_popups) {
3602                 rv = auto_print ? 0 : -1; auto_print = true; // skip dialog and PRINT or DO NOT PRINT based on Auto-Print checkbox
3603             }
3604             var x = data.hash.aous['circ.staff_client.do_not_auto_attempt_print'];
3605             var no_print_prompting = x ? (x.indexOf( check.payload.hold ? "Hold/Transit Slip" : "Transit Slip" ) > -1) : false;
3606             if (no_print_prompting) {
3607                 rv = -1; auto_print = true; // DO NOT PRINT and skip dialog
3608             }
3609             print_data.slip_date = util.date.formatted_date(new Date(),'%F');
3610             print_data.slip_date_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.slip_date', [print_data.slip_date]);
3611             msg += print_data.slip_date_msg;
3612             print_data.payload = check.payload;
3613
3614             if (!auto_print) {
3615                 rv = error.yns_alert_formatted(
3616                     msg,
3617                     document.getElementById('circStrings').getString('staff.circ.utils.transit_slip'),
3618                     document.getElementById('circStrings').getString('staff.circ.utils.transit_slip.print.yes'),
3619                     document.getElementById('circStrings').getString('staff.circ.utils.transit_slip.print.no'),
3620                     null,
3621                     document.getElementById('circStrings').getString('staff.circ.confirm.msg'),
3622                     '/xul/server/skin/media/images/turtle.gif'
3623                 );
3624             } else {
3625                 if (suppress_popups && !no_print_prompting) {
3626                     // FIXME: add SFX and/or GFX
3627                     sound.circ_bad();
3628                 }
3629             }
3630             if (rv == 0) {
3631                 try {
3632                     JSAN.use('util.print'); var print = new util.print();
3633                     var old_template = String( data.hash.aous['ui.circ.old_harcoded_slip_template'] ) == 'true';
3634                     if (old_template) {
3635                         msg = msg.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\n/g,'<br/>');
3636                         print.simple( msg , { 'no_prompt' : true, 'content_type' : 'text/html' } );
3637                     } else {
3638                         var template = check.payload.hold ? 'hold_transit_slip' : 'transit_slip';
3639                         var parms = {
3640                             'patron' : print_data.user,
3641                             'lib' : data.hash.aou[ data.list.au[0].ws_ou() ],
3642                             'staff' : data.list.au[0],
3643                             'header' : data.print_list_templates[ template ].header,
3644                             'line_item' : data.print_list_templates[ template ].line_item,
3645                             'footer' : data.print_list_templates[ template ].footer,
3646                             'type' : data.print_list_templates[ template ].type,
3647                             'list' : print_list,
3648                             'data' : print_data,
3649                             'context' : data.print_list_templates[ template ].context,
3650                         };
3651                         if ($('printer_prompt')) {
3652                             if (! $('printer_prompt').checked) { parms.no_prompt = true; }
3653                         }
3654                         print.tree_list( parms );
3655                     }
3656                 } catch(E) {
3657                     var err_msg = document.getElementById('commonStrings').getString('common.error');
3658                     err_msg += '\nFIXME: ' + E + '\n';
3659                     dump(err_msg);
3660                     alert(err_msg);
3661                 }
3662             }
3663             if (no_change_label) {
3664                 var m = no_change_label.getAttribute('value');
3665                 var trans_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.in_transit', [params.barcode]);
3666                 no_change_label.setAttribute('value', m + trans_msg + '  ');
3667                 no_change_label.setAttribute('hidden','false');
3668                 no_change_label.setAttribute('onclick','');
3669                 removeCSSClass(no_change_label,'click_link');
3670                 no_change_label.setAttribute('unique_row_counter','');
3671                 if (typeof params.info_blurb == 'function') {
3672                     params.info_blurb( trans_msg );
3673                 }
3674             }
3675
3676         } else /* ASSET_COPY_NOT_FOUND */ if (check.ilsevent == 1502) {
3677
3678             check.what_happened = 'not_found';
3679             sound.special('checkin.not_found');
3680             check.route_to = 'CATALOGING';
3681             var mis_scan_msg = document.getElementById('circStrings').getFormattedString('staff.circ.copy_status.status.copy_not_found', [params.barcode]);
3682             if (!suppress_popups) {
3683                 error.yns_alert(
3684                     mis_scan_msg,
3685                     document.getElementById('circStrings').getString('staff.circ.alert'),
3686                     null,
3687                     document.getElementById('circStrings').getString('staff.circ.utils.msg.ok'),
3688                     null,
3689                     document.getElementById('circStrings').getString('staff.circ.confirm.msg')
3690                 );
3691             } else {
3692                 // FIXME: add SFX and/or GFX
3693                 sound.circ_bad();
3694             }
3695             if (no_change_label) {
3696                 var m = no_change_label.getAttribute('value');
3697                 no_change_label.setAttribute('value',m + mis_scan_msg + '  ');
3698                 no_change_label.setAttribute('hidden','false');
3699                 no_change_label.setAttribute('onclick','');
3700                 removeCSSClass(no_change_label,'click_link');
3701                 no_change_label.setAttribute('unique_row_counter','');
3702                 if (typeof params.info_blurb == 'function') {
3703                     params.info_blurb( mis_scan_msg );
3704                 }
3705             }
3706
3707         } else /* HOLD_CAPTURE_DELAYED */ if (check.ilsevent == 7019) {
3708
3709             check.what_happened = 'hold_capture_delayed';
3710             sound.special('checkin.hold_capture_delayed');
3711             var rv = 0;
3712             msg += document.getElementById('circStrings').getString('staff.circ.utils.hold_capture_delayed.description');
3713             if (!suppress_popups) {
3714                 rv = error.yns_alert_formatted(
3715                     msg,
3716                     document.getElementById('circStrings').getString('staff.circ.utils.hold_capture_delayed.titlebar'),
3717                     document.getElementById('circStrings').getString('staff.circ.utils.hold_capture_delayed.prompt_for_nocapture'),
3718                     document.getElementById('circStrings').getString('staff.circ.utils.hold_capture_delayed.prompt_for_capture'),
3719                     null,
3720                     document.getElementById('circStrings').getString('staff.circ.confirm.msg'),
3721                     '/xul/server/skin/media/images/stop_sign.png'
3722                 );
3723             } else {
3724                 // FIXME: add SFX and/or GFX
3725                 sound.circ_bad();
3726             }
3727             params.capture = rv == 0 ? 'nocapture' : 'capture';
3728
3729             return circ.util.checkin_via_barcode(session,params,backdate,auto_print,false);
3730
3731         } else /* NETWORK TIMEOUT */ if (check.ilsevent == -1) {
3732             check.what_happened = 'error';
3733             sound.special('checkin.error');
3734             error.standard_network_error_alert(document.getElementById('circStrings').getString('staff.circ.checkin.suggest_offline'));
3735         } else {
3736
3737             if (check.ilsevent == null) { return null; /* handled */ }
3738             switch (Number(check.ilsevent)) {
3739                 case 1203 /* COPY_BAD_STATUS */ :
3740                 case 1213 /* PATRON_BARRED */ :
3741                 case 1217 /* PATRON_INACTIVE */ :
3742                 case 1224 /* PATRON_ACCOUNT_EXPIRED */ :
3743                 case 1234 /* ITEM_DEPOSIT_PAID */ :
3744                 case 7009 /* CIRC_CLAIMS_RETURNED */ :
3745                 case 7010 /* COPY_ALERT_MESSAGE */ :
3746                 case 7011 /* COPY_STATUS_LOST */ :
3747                 case 7012 /* COPY_STATUS_MISSING */ :
3748                 case 7013 /* PATRON_EXCEEDS_FINES */ :
3749                     return null; /* handled */
3750                 break;
3751             }
3752
3753             throw(check);
3754
3755         }
3756
3757         return check;
3758     } catch(E) {
3759         JSAN.use('util.error'); var error = new util.error();
3760         error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.error', ['3']), E);
3761         return null;
3762     }
3763 };
3764
3765 circ.util.renew_via_barcode = function ( params, async ) {
3766     try {
3767         var obj = {};
3768         JSAN.use('util.network'); obj.network = new util.network();
3769         JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.stash_retrieve();
3770
3771         function renew_callback(req) {
3772             try {
3773                 JSAN.use('util.error'); var error = new util.error();
3774                 var renew = req.getResultObject();
3775                 if (typeof renew.ilsevent != 'undefined') renew = [ renew ];
3776                 for (var j = 0; j < renew.length; j++) {
3777                     switch(renew[j].ilsevent == null ? null : Number(renew[j].ilsevent)) {
3778                         case 0 /* SUCCESS */ : break;
3779                         case null /* custom event */ : break;
3780                         case 5000 /* PERM_FAILURE */: break;
3781                         case 1212 /* PATRON_EXCEEDS_OVERDUE_COUNT */ : break;
3782                         case 7002 /* PATRON_EXCEEDS_CHECKOUT_COUNT */ : break;
3783                         case 1213 /* PATRON_BARRED */ : break;
3784                         case 1215 /* CIRC_EXCEEDS_COPY_RANGE */ : break;
3785                         case 1224 /* PATRON_ACCOUNT_EXPIRED */ : break;
3786                         case 1232 /* ITEM_DEPOSIT_REQUIRED */ : break;
3787                         case 1233 /* ITEM_RENTAL_FEE_REQUIRED */ : break;
3788                         case 1234 /* ITEM_DEPOSIT_PAID */ : break;
3789                         case 1236 /* PATRON_EXCEEDS_LOST_COUNT */ : break;
3790                         case 1500 /* ACTION_CIRCULATION_NOT_FOUND */ : break;
3791                         case 1502 /* ASSET_COPY_NOT_FOUND */ : 
3792                             var mis_scan_msg = document.getElementById('circStrings').getFormattedString('staff.circ.copy_status.status.copy_not_found', [params.barcode]);
3793                             error.yns_alert(
3794                                 mis_scan_msg,
3795                                 document.getElementById('circStrings').getString('staff.circ.alert'),
3796                                 null,
3797                                 document.getElementById('circStrings').getString('staff.circ.utils.msg.ok'),
3798                                 null,
3799                                 document.getElementById('circStrings').getString('staff.circ.confirm.msg')
3800                             );
3801                             if (no_change_label) {
3802                                 var m = no_change_label.getAttribute('value');
3803                                 no_change_label.setAttribute('value',m + mis_scan_msg + '  ');
3804                                 no_change_label.setAttribute('hidden','false');
3805                                 no_change_label.setAttribute('onclick','');
3806                                 removeCSSClass(no_change_label,'click_link');
3807                                 no_change_label.setAttribute('unique_row_counter','');
3808                                 if (typeof params.info_blurb == 'function') {
3809                                     params.info_blurb( mis_scan_msg );
3810                                 }
3811                             }
3812                         break;
3813                         case 7002 /* PATRON_EXCEEDS_CHECKOUT_COUNT */ : break;
3814                         case 7003 /* COPY_CIRC_NOT_ALLOWED */ : break;
3815                         case 7004 /* COPY_NOT_AVAILABLE */ : break;
3816                         case 7006 /* COPY_IS_REFERENCE */ : break;
3817                         case 7007 /* COPY_NEEDED_FOR_HOLD */ : break;
3818                         case 7008 /* MAX_RENEWALS_REACHED */ : break;
3819                         case 7009 /* CIRC_CLAIMS_RETURNED */ : break;
3820                         case 7010 /* COPY_ALERT_MESSAGE */ : break;
3821                         case 7013 /* PATRON_EXCEEDS_FINES */ : break;
3822                         default:
3823                             throw(renew);
3824                         break;
3825                     }
3826                 }
3827                 try {
3828                     var ibarcode = renew[0].payload.copy ? renew[0].payload.copy.barcode() : params.barcode;
3829                     var p_id = renew[0].payload.patron ? renew[0].payload.patron.id() : renew[0].payload.circ.usr();
3830                     var pname; var pbarcode; 
3831                     if (renew[0].patron) {
3832                         pname = renew[0].payload.patron.family_name();
3833                         pbarcode = typeof renew[0].payload.patron.card() == 'object' ? renew[0].payload.patron.card().barcode() : null;
3834                     } else {
3835                         if (circ.util.renew_via_barcode.last_usr_id == p_id) {
3836                             pname = circ.util.renew_via_barcode.last_pname;
3837                             pbarcode = circ.util.renew_via_barcode.last_pbarcode;
3838                         } else {
3839                             JSAN.use('patron.util'); var p = patron.util.retrieve_fleshed_au_via_id(ses(),p_id);
3840                             pname = p.family_name();
3841                             pbarcode = typeof p.card() == 'object' ? p.card().barcode() : null;
3842                             if (pname) {
3843                                 circ.util.renew_via_barcode.last_usr_id = p_id;
3844                                 circ.util.renew_via_barcode.last_pname = pname;
3845                                 circ.util.renew_via_barcode.last_pbarcode = pbarcode;
3846                             }
3847                         } 
3848                     }
3849                     error.work_log(
3850                         document.getElementById('circStrings').getFormattedString(
3851                             'staff.circ.work_log_renew.message',
3852                             [
3853                                 ses('staff_usrname'),
3854                                 pname ? pname : '???',
3855                                 pbarcode ? pbarcode : '???',
3856                                 ibarcode ? ibarcode : '???'
3857                             ]
3858                         ), {
3859                             'au_id' : p_id,
3860                             'au_family_name' : pname,
3861                             'au_barcode' : pbarcode,
3862                             'acp_barcode' : ibarcode
3863                         }
3864                     );
3865                 } catch(E) {
3866                     error.sdump('D_ERROR','Error with work_logging in server/circ/util.js, renew_via_barcode():' + E);
3867                 }
3868                 if (typeof async == 'function') async(renew);
3869                 return renew;
3870             } catch(E) {
3871                 JSAN.use('util.error'); var error = new util.error();
3872                 error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.renew_failed.error', [params.barcode]), E);
3873                 return null;
3874             }
3875         }
3876
3877         var renew = obj.network.simple_request(
3878             'CHECKOUT_RENEW',
3879             [ ses(), params ],
3880             async ? renew_callback : null,
3881             {
3882                 'title' : document.getElementById('circStrings').getString('staff.circ.checkin.renew_failed.override'),
3883                 'overridable_events' : [
3884                     null /* custom event */,
3885                     1212 /* PATRON_EXCEEDS_OVERDUE_COUNT */,
3886                     1213 /* PATRON_BARRED */,
3887                     1215 /* CIRC_EXCEEDS_COPY_RANGE */,
3888                     1232 /* ITEM_DEPOSIT_REQUIRED */,
3889                     1233 /* ITEM_RENTAL_FEE_REQUIRED */,
3890                     1234 /* ITEM_DEPOSIT_PAID */,
3891                     1236 /* PATRON_EXCEEDS_LOST_COUNT */,
3892                     7002 /* PATRON_EXCEEDS_CHECKOUT_COUNT */,
3893                     7003 /* COPY_CIRC_NOT_ALLOWED */,
3894                     7004 /* COPY_NOT_AVAILABLE */,
3895                     7006 /* COPY_IS_REFERENCE */,
3896                     7007 /* COPY_NEEDED_FOR_HOLD */,
3897                     7008 /* MAX_RENEWALS_REACHED */,
3898                     7009 /* CIRC_CLAIMS_RETURNED */,
3899                     7010 /* COPY_ALERT_MESSAGE */,
3900                     7013 /* PATRON_EXCEEDS_FINES */,
3901                 ],
3902                 'text' : {
3903                     '1212' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
3904                     '1213' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
3905                     '1215' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
3906                     '1232' : function(r) {
3907                         return document.getElementById('circStrings').getFormattedString('staff.circ.renew.override.item_deposit_required.warning.barcode', [params.barcode]);
3908                     },
3909                     '1233' : function(r) {
3910                         return document.getElementById('circStrings').getFormattedString('staff.circ.renew.override.item_rental_fee_required.warning.barcode', [params.barcode]);
3911                     },
3912                     '1234' : function(r) {
3913                         return document.getElementById('circStrings').getFormattedString('staff.circ.utils.checkin.override.item_deposit_paid.warning');
3914                     },
3915                     '1236' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
3916                     '7002' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
3917                     '7003' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
3918                     '7004' : function(r) {
3919                         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()]);
3920                     },
3921                     '7006' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
3922                     '7007' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
3923                     '7008' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
3924                     '7009' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
3925                     '7010' : function(r) {
3926                         return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode.msg', [params.barcode, r.payload]);
3927                     },
3928                     '7013' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); }
3929                 }
3930             }
3931         );
3932         if (! async ) {
3933             return renew_callback( { 'getResultObject' : function() { return renew; } } );
3934         }
3935
3936     } catch(E) {
3937         JSAN.use('util.error'); var error = new util.error();
3938         error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.renew_failed.error', [params.barcode]), E);
3939         return null;
3940     }
3941 };
3942
3943 circ.util.batch_hold_update = function ( hold_ids, field_changes, params ) {
3944     try {
3945         JSAN.use('util.sound'); var sound = new util.sound();
3946         var change_list = []; var idx = -1; var bad_holds = [];
3947         dojo.forEach(
3948             hold_ids,
3949             function(el) {
3950                 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?
3951             }
3952         );
3953         if (params.progressmeter) { params.progressmeter.value = 0; params.progressmeter.hidden = false; }
3954         fieldmapper.standardRequest(
3955             [ api.FM_AHR_UPDATE_BATCH.app, api.FM_AHR_UPDATE_BATCH.method ],
3956             {   async: true,
3957                 params: [ses(), null, change_list],
3958                 onresponse: function(r) {
3959                     idx++; 
3960                     if (params.progressmeter) { params.progressmeter.value = Number( params.progressmeter.value ) + 100/hold_ids.length; }
3961                     var result = r.recv().content();
3962                     if (result != hold_ids[ idx ]) {
3963                         bad_holds.push( { 'hold_id' : hold_ids[ idx ], 'result' : result } );
3964                     }
3965                 },
3966                 oncomplete: function() {
3967                     if (bad_holds.length > 0) {
3968                         sound.circ_bad();
3969                         alert( $('circStrings').getFormattedString('staff.circ.hold_update.hold_ids.failed',[ bad_holds.length ]) );
3970                     } else {
3971                         sound.circ_good();
3972                     }
3973                     if (typeof params.oncomplete == 'function') {
3974                         params.oncomplete( bad_holds );
3975                     }
3976                     if (params.progressmeter) { params.progressmeter.value = 0; params.progressmeter.hidden = true; }
3977                 },
3978                 onerror: function(r) {
3979                     alert('Error in circ/util.js, batch_hold_update(), onerror: ' + r);
3980                 }
3981             }
3982         );
3983     } catch(E) {
3984         alert('Error in circ.util.js, circ.util.batch_hold_update(): ' + E);
3985     }
3986 };
3987
3988 circ.util.find_acq_po = function(session, copy_id) {
3989     dojo.require("openils.Util");
3990     fieldmapper.standardRequest(
3991         ["open-ils.acq", "open-ils.acq.lineitem.retrieve.by_copy_id.authoritative"], {
3992             "params": [session, copy_id, {"clear_marc": true}],
3993             "onresponse": function(r) {
3994                 if (r = openils.Util.readResponse(r)) {
3995                     if (r.purchase_order()) {
3996                         var url = urls.XUL_BROWSER + "?url=" +
3997                             window.escape(
3998                                 xulG.url_prefix('EG_ACQ_PO_VIEW/')
3999                                     + r.purchase_order() + "/" + r.id()
4000                             );
4001                         window.xulG.new_tab(
4002                             url, {"browser": true}, {
4003                                 "no_xulG": false,
4004                                 "show_print_button": false,
4005                                 "show_nav_buttons": true
4006                             }
4007                         );
4008                     } else {
4009                         /* unlikely: got an LI with no PO */
4010                         alert(dojo.byId("circStrings").getFormattedString(
4011                             "staff.circ.utils.find_acq_po.no_po", [r.id()]
4012                         ));
4013                     }
4014                 }
4015             }
4016         }
4017     );
4018 };
4019
4020 dump('exiting circ/util.js\n');