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