]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/xul/staff_client/server/circ/util.js
LP 1169193 transit_slip macro for copy status
[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     for (var i = 0; i < c.length; i++) {
2768         if (modify[ c[i].id ]) {
2769             for (var j in modify[ c[i].id ]) {
2770                 c[i][j] = modify[ c[i].id ][j];
2771             }
2772         }
2773     }
2774     if (params) {
2775         if (params.just_these) {
2776             JSAN.use('util.functional');
2777             var new_c = [];
2778             for (var i = 0; i < params.just_these.length; i++) {
2779                 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
2780                 new_c.push( function(y){ return y; }( x ) );
2781             }
2782             c = new_c;
2783         }
2784         if (params.except_these) {
2785             JSAN.use('util.functional');
2786             var new_c = [];
2787             for (var i = 0; i < c.length; i++) {
2788                 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
2789                 if (!x) new_c.push(c[i]);
2790             }
2791             c = new_c;
2792         }
2793
2794     }
2795     return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
2796 };
2797
2798 circ.util.checkin_via_barcode = function(session,params,backdate,auto_print,async) {
2799     try {
2800         JSAN.use('util.error'); var error = new util.error();
2801         JSAN.use('util.network'); var network = new util.network();
2802         JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
2803         JSAN.use('util.date'); JSAN.use('util.functional');
2804
2805         if (backdate && (backdate == util.date.formatted_date(new Date(),'%Y-%m-%d')) ) backdate = null;
2806
2807         //var params = { 'barcode' : barcode };
2808         if (backdate) params.backdate = util.date.formatted_date(backdate,'%{iso8601}');
2809
2810         if (typeof params.disable_textbox == 'function') {
2811             try { params.disable_textbox(); }
2812             catch(E) { error.sdump('D_ERROR','params.disable_textbox() = ' + E); };
2813         }
2814
2815         function checkin_callback(req) {
2816             JSAN.use('util.error'); var error = new util.error();
2817             try {
2818                 var check = req.getResultObject();
2819                 var r = circ.util.checkin_via_barcode2(session,params,backdate,auto_print,check);
2820                 try {
2821                     error.work_log(
2822                         document.getElementById('circStrings').getFormattedString(
2823                             'staff.circ.work_log_checkin_attempt.' + r.what_happened + '.message',
2824                             [
2825                                 ses('staff_usrname'),
2826                                 r.payload.patron ? r.payload.patron.family_name() : '',
2827                                 r.payload.patron ? r.payload.patron.card().barcode() : '',
2828                                 r.payload.copy ? r.payload.copy.barcode() : '',
2829                                 r.route_to ? r.route_to : ''
2830                             ]
2831                         ), {
2832                             'au_id' : r.payload.patron ? r.payload.patron.id() : '',
2833                             'au_family_name' : r.payload.patron ? r.payload.patron.family_name() : '',
2834                             'au_barcode' : r.payload.patron ? r.payload.patron.card().barcode() : '',
2835                             'acp_barcode' : r.payload.copy ? r.payload.copy.barcode() : ''
2836                         }
2837                     );
2838                 } catch(E) {
2839                     error.sdump('D_ERROR','Error with work_logging in server/circ/checkout.js, _checkout:' + E);
2840                 }
2841
2842                 if (typeof params.checkin_result == 'function') {
2843                     try { params.checkin_result(r); } catch(E) { error.sdump('D_ERROR','params.checkin_result() = ' + E); };
2844                 }
2845                 if (typeof async == 'function') async(check);
2846                 return check;
2847             } catch(E) {
2848                 error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.error', ['1']), E);
2849                 if (typeof params.enable_textbox == 'function') {
2850                     try { params.enable_textbox(); }
2851                     catch(E) { error.sdump('D_ERROR','params.disable_textbox() = ' + E); };
2852                 }
2853                 return null;
2854             }
2855         }
2856
2857         var suppress_popups = data.hash.aous['ui.circ.suppress_checkin_popups'];
2858
2859         var check = network.request(
2860             api.CHECKIN_VIA_BARCODE.app,
2861             api.CHECKIN_VIA_BARCODE.method,
2862             [ session, util.functional.filter_object( params, function(i,o) { return typeof o != 'function'; } ) ],
2863             async ? checkin_callback : null,
2864             {
2865                 'title' : document.getElementById('circStrings').getString('staff.circ.utils.checkin.override'),
2866                 'auto_override_these_events' : suppress_popups ? [
2867                     null /* custom event */,
2868                     1203 /* COPY_BAD_STATUS */,
2869                     1213 /* PATRON_BARRED */,
2870                     1217 /* PATRON_INACTIVE */,
2871                     1224 /* PATRON_ACCOUNT_EXPIRED */,
2872                     1234 /* ITEM_DEPOSIT_PAID */,
2873                     7009 /* CIRC_CLAIMS_RETURNED */,
2874                     7010 /* COPY_ALERT_MESSAGE */,
2875                     7011 /* COPY_STATUS_LOST */,
2876                     7025 /* COPY_STATUS_LONG_OVERDUE */, 
2877                     7012 /* COPY_STATUS_MISSING */,
2878                     7013 /* PATRON_EXCEEDS_FINES */
2879                 ] : [],
2880                 'overridable_events' : [
2881                     null /* custom event */,
2882                     1203 /* COPY_BAD_STATUS */,
2883                     1213 /* PATRON_BARRED */,
2884                     1217 /* PATRON_INACTIVE */,
2885                     1224 /* PATRON_ACCOUNT_EXPIRED */,
2886                     1234 /* ITEM_DEPOSIT_PAID */,
2887                     7009 /* CIRC_CLAIMS_RETURNED */,
2888                     7010 /* COPY_ALERT_MESSAGE */,
2889                     7011 /* COPY_STATUS_LOST */,
2890                     7025 /* COPY_STATUS_LONG_OVERDUE */, 
2891                     7012 /* COPY_STATUS_MISSING */,
2892                     7013 /* PATRON_EXCEEDS_FINES */,
2893                     11103 /* TRANSIT_CHECKIN_INTERVAL_BLOCK */ 
2894                 ],
2895                 'text' : {
2896                     '1203' : function(r) {
2897                         return typeof r.payload.status() == 'object' ? r.payload.status().name() : data.hash.ccs[ r.payload.status() ].name();
2898                     },
2899                     '1234' : function(r) {
2900                         return document.getElementById('circStrings').getString('staff.circ.utils.checkin.override.item_deposit_paid.warning');
2901                     },
2902                     '7010' : function(r) {
2903                         return r.payload;
2904                     }
2905                 }
2906             }
2907         );
2908         if (! async ) {
2909             return checkin_callback( { 'getResultObject' : function() { return check; } } );
2910         }
2911
2912
2913     } catch(E) {
2914         JSAN.use('util.error'); var error = new util.error();
2915         error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.error', ['2']), E);
2916         if (typeof params.enable_textbox == 'function') {
2917             try { params.enable_textbox(); } catch(E) { error.sdump('D_ERROR','params.disable_textbox() = ' + E); };
2918         }
2919         return null;
2920     }
2921 };
2922
2923 circ.util.checkin_via_barcode2 = function(session,params,backdate,auto_print,check) {
2924     try {
2925         JSAN.use('util.error'); var error = new util.error();
2926         JSAN.use('util.network'); var network = new util.network();
2927         JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
2928         JSAN.use('util.date');
2929         JSAN.use('util.sound'); var sound = new util.sound();
2930
2931         dump('check = ' + error.pretty_print( js2JSON( check ) ) + '\n' );
2932
2933         check.message = check.textcode;
2934
2935         if (check.payload && check.payload.copy) { check.copy = check.payload.copy; }
2936         if (check.payload && check.payload.volume) { check.volume = check.payload.volume; }
2937         if (check.payload && check.payload.record) { check.record = check.payload.record; }
2938         if (check.payload && check.payload.circ) { check.circ = check.payload.circ; }
2939         if (check.payload && check.payload.patron) { check.patron = check.payload.patron; }
2940
2941         if (!check.route_to) { check.route_to = '   '; }
2942
2943         var no_change_label = document.getElementById('no_change_label');
2944
2945         if (no_change_label) {
2946             no_change_label.setAttribute('value','');
2947             no_change_label.setAttribute('hidden','true');
2948             no_change_label.setAttribute('onclick','');
2949             removeCSSClass(no_change_label,'click_link');
2950             no_change_label.setAttribute('unique_row_counter','');
2951         }
2952
2953         var msg = '';
2954         var print_list = [];
2955         var print_data = { 
2956             'error' : '',
2957             'error_msg' : '',
2958             'cancelled' : '',
2959             'route_to' : '',
2960             'route_to_msg' : '',
2961             'route_to_org_fullname' : '',
2962             'destination_shelf' : '',
2963             'destination_shelf_msg' : '',
2964             'courier_code' : '',
2965             'street1' : '',
2966             'street2' : '',
2967             'city_state_zip' : '',
2968             'city' : '',
2969             'state' : '',
2970             'county' : '',
2971             'country' : '',
2972             'post_code' : '',
2973             'item_barcode' : '',
2974             'item_barcode_msg' : '',
2975             'item_title' : '',
2976             'item_title_msg' : '',
2977             'item_author' : '',
2978             'item_author_msg' : '',
2979             'hold_for_msg' : '',
2980             'hold_for_alias' : '',
2981             'hold_for_family_name' : '',
2982             'hold_for_first_given_name' : '',
2983             'hold_for_second_given_name' : '',
2984             'user_barcode' : '',
2985             'user_barcode_msg' : '',
2986             'notify_by_phone' : '',
2987             'notify_by_phone_msg' : '',
2988             'notify_by_email' : '',
2989             'notify_by_email_msg' : '',
2990             'notify_by_text' : '',
2991             'notify_by_text_msg' : '',
2992             'request_date' : '',
2993             'request_date_msg' : '',
2994             'shelf_expire_time' : '',
2995             'slip_date' : '',
2996             'slip_date_msg' : '',
2997             'user' : '',
2998             'user_stat_cat_entries' : '',
2999             'transit_copy_status' : ''
3000         };
3001
3002         if (check.payload && check.payload.cancelled_hold_transit) {
3003             print_data.cancelled = document.getElementById('circStrings').getString('staff.circ.utils.transit_hold_cancelled');
3004             msg += print_data.cancelled;
3005             msg += '\n\n';
3006         }
3007
3008         var suppress_popups = data.hash.aous['ui.circ.suppress_checkin_popups'];
3009
3010         /* SUCCESS  /  NO_CHANGE  /  ITEM_NOT_CATALOGED */
3011         if (check.ilsevent == 0 || check.ilsevent == 3 || check.ilsevent == 1202) {
3012             try {
3013                 var acpl = data.lookup('acpl', check.copy.location()); 
3014                 check.route_to = acpl.name();
3015                 check.checkin_alert = isTrue(acpl.checkin_alert()) && !suppress_popups;
3016             } catch(E) {
3017                 print_data.error_msg = document.getElementById('commonStrings').getString('common.error');
3018                 print_data.error_msg += '\nFIXME: ' + E + '\n';
3019                 msg += print_data.error_msg;
3020             }
3021             if (check.ilsevent == 3 /* NO_CHANGE */) {
3022                 //msg = 'This item is already checked in.\n';
3023                 check.what_happened = 'no_change';
3024                 sound.special('checkin.no_change');
3025                 if (no_change_label) {
3026                     var m = no_change_label.getAttribute('value');
3027                     var text = document.getElementById('circStrings').getFormattedString('staff.circ.utils.item_checked_in', [params.barcode]);
3028                     no_change_label.setAttribute('value', m + text + '  ');
3029                     no_change_label.setAttribute('hidden','false');
3030                     no_change_label.setAttribute('onclick','');
3031                     removeCSSClass(no_change_label,'click_link');
3032                     no_change_label.setAttribute('unique_row_counter','');
3033                     if (typeof params.info_blurb == 'function') {
3034                         params.info_blurb( text );
3035                     }
3036                 }
3037             }
3038             if (check.ilsevent == 1202 /* ITEM_NOT_CATALOGED */ && check.copy.status() != 11) {
3039                 check.what_happened = 'error';
3040                 sound.special('checkin.error');
3041                 var copy_status = (data.hash.ccs[ check.copy.status() ] ? data.hash.ccs[ check.copy.status() ].name() : check.copy.status().name() );
3042                 var err_msg = document.getElementById('commonStrings').getString('common.error');
3043                 err_msg += '\nFIXME --';
3044                 err_msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.item_not_cataloged', [copy_status]);
3045                 err_msg += '\n';
3046                 msg += err_msg;
3047                 print_data.error_msg += err_msg;
3048             }
3049             switch(Number(check.copy.status())) {
3050                 case 0: /* AVAILABLE */
3051                 case 7: /* RESHELVING */
3052                     check.what_happened = 'success';
3053                     sound.special('checkin.success');
3054                     if (msg || check.checkin_alert) {
3055                         print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
3056                         print_data.route_to = check.route_to;
3057                         msg += print_data.route_to_msg;
3058                         msg += '\n';
3059                     }
3060                 break;
3061                 case 8: /* ON HOLDS SHELF */
3062                     check.what_happened = 'hold_shelf';
3063                     sound.special('checkin.hold_shelf');
3064                     check.route_to = document.getElementById('circStrings').getString('staff.circ.route_to.hold_shelf');
3065                     if (check.payload.hold) {
3066                         if (check.payload.hold.pickup_lib() != data.list.au[0].ws_ou()) {
3067                             check.what_happened = 'error';
3068                             sound.special('checkin.error');
3069                             var err_msg = document.getElementById('commonStrings').getString('common.error');
3070                             err_msg += '\nFIXME: ';
3071                             err_msg += document.getElementById('circStrings').getString('staff.circ.utils.route_item_error');
3072                             err_msg += '\n';
3073                             msg += err_msg;
3074                             print_data.error_msg += err_msg;
3075                         } else {
3076                             print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
3077                             print_data.route_to = check.route_to;
3078                             var behind_the_desk_support = String( data.hash.aous['circ.holds.behind_desk_pickup_supported'] ) == 'true';
3079                             if (behind_the_desk_support) {
3080                                var usr_settings = network.simple_request('FM_AUS_RETRIEVE',[ses(),check.payload.hold.usr()]); 
3081                                 if (typeof usr_settings['circ.holds_behind_desk'] != 'undefined') {
3082                                     if (usr_settings['circ.holds_behind_desk']) {
3083                                         print_data.prefer_behind_holds_desk = true;
3084                                         check.route_to = document.getElementById('circStrings').getString('staff.circ.route_to.private_hold_shelf');
3085                                         print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
3086                                         print_data.route_to = check.route_to;
3087                                     } else {
3088                                         check.route_to = document.getElementById('circStrings').getString('staff.circ.route_to.public_hold_shelf');
3089                                         print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
3090                                         print_data.route_to = check.route_to;
3091                                     }
3092                                 } else {
3093                                     check.route_to = document.getElementById('circStrings').getString('staff.circ.route_to.public_hold_shelf');
3094                                     print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
3095                                     print_data.route_to = check.route_to;
3096                                 }
3097                             }
3098                             print_data.destination_shelf_msg = print_data.route_to_msg;
3099                             print_data.destination_shelf = print_data.route_to;
3100                             msg += print_data.route_to_msg;
3101                             msg += '\n';
3102                         }
3103                     } else {
3104                         check.what_happened = 'error';
3105                         sound.special('checkin.error');
3106                         var err_msg = document.getElementById('commonStrings').getString('common.error');
3107                         err_msg += '\nFIXME: ';
3108                         err_msg += document.getElementById('circStrings').getString('staff.circ.utils.route_item_status_error');
3109                         err_msg += '\n';
3110                         msg += err_msg;
3111                         print_data.error_msg += err_msg;
3112                     }
3113                     JSAN.use('util.date');
3114                     if (check.payload.hold) {
3115                         JSAN.use('patron.util');
3116                         msg += '\n';
3117                         print_data.item_barcode_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [check.payload.copy.barcode()]);
3118                         print_data.item_barcode = check.payload.copy.barcode();
3119                         msg += print_data.item_barcode_msg;
3120                         msg += '\n';
3121                         var payload_title  = (check.payload.record ? check.payload.record.title() : check.payload.copy.dummy_title() );
3122                         print_data.item_title_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.title', [payload_title]);
3123                         print_data.item_title = payload_title;
3124                         msg += print_data.item_title_msg;
3125                         msg += '\n';
3126                         var au_obj = patron.util.retrieve_fleshed_au_via_id( session, check.payload.hold.usr() );
3127                         print_data.user = au_obj;
3128                         print_data.user_stat_cat_entries = [];
3129                         var entries = au_obj.stat_cat_entries();
3130                         for (var i = 0; i < entries.length; i++) {
3131                             var stat_cat = data.hash.my_actsc[ entries[i].stat_cat() ];
3132                             if (!stat_cat) {
3133                                 stat_cat = data.lookup('actsc', entries[i].stat_cat());
3134                             }
3135                             print_data.user_stat_cat_entries.push( { 
3136                                 'id' : entries[i].id(),
3137                                 'stat_cat' : {
3138                                     'id' : stat_cat.id(),
3139                                     'name' : stat_cat.name(),
3140                                     'opac_visible' : stat_cat.opac_visible(),
3141                                     'owner' : stat_cat.owner(),
3142                                     'usr_summary' : stat_cat.usr_summary()
3143                                 },
3144                                 'stat_cat_entry' : entries[i].stat_cat_entry(),
3145                                 'target_usr' : entries[i].target_usr() 
3146                             } );
3147                         }
3148                         msg += '\n';
3149                         if (au_obj.alias()) {
3150                             print_data.hold_for_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.patron_alias',  [au_obj.alias()]);
3151                             print_data.hold_for_alias = au_obj.alias();
3152                             msg += print_data.hold_for_msg;
3153                         } else {
3154                             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() : '']);
3155                             msg += print_data.hold_for_msg;
3156                             print_data.hold_for_family_name = au_obj.family_name() ? au_obj.family_name() : '';
3157                             print_data.hold_for_first_given_name = au_obj.first_given_name() ? au_obj.first_given_name() : '';
3158                             print_data.hold_for_second_given_name = au_obj.second_given_name() ? au_obj.second_given_name() : '';
3159                         }
3160                         msg += '\n';
3161                         print_data.user_barcode_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [au_obj.card().barcode()]);
3162                         print_data.user_barcode = au_obj.card().barcode();
3163                         msg += print_data.user_barcode_msg;
3164                         msg += '\n';
3165                         if (check.payload.hold.phone_notify()) {
3166                             print_data.notify_by_phone_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.phone_notify', [check.payload.hold.phone_notify()]);
3167                             print_data.notify_by_phone = check.payload.hold.phone_notify();
3168                             msg += print_data.notify_by_phone_msg;
3169                             msg += '\n';
3170                         }
3171                         if (check.payload.hold.sms_notify()) {
3172                             print_data.notify_by_text_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.sms_notify', [check.payload.hold.sms_notify()]);
3173                             print_data.notify_by_text = check.payload.hold.sms_notify();
3174                             msg += print_data.notify_by_text_msg;
3175                             msg += '\n';
3176                         }
3177                         if (get_bool(check.payload.hold.email_notify())) {
3178                             var payload_email = au_obj.email() ? au_obj.email() : '';
3179                             print_data.notify_by_email_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.email_notify', [payload_email]);
3180                             print_data.notify_by_email = payload_email;
3181                             msg += print_data.notify_by_email_msg;
3182                             msg += '\n';
3183                         }
3184                         msg += '\n';
3185                         var notes = check.payload.hold.notes();
3186                         print_data.notes_raw = notes;
3187                         for (var i = 0; i < notes.length; i++) {
3188                             if ( get_bool( notes[i].slip() ) ) {
3189                                 var temp_msg;
3190                                 if ( get_bool( notes[i].staff() ) ) {
3191                                     temp_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.notes.staff_note', [ notes[i].title(), notes[i].body() ]);
3192                                 } else {
3193                                     temp_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.notes.patron_note', [ notes[i].title(), notes[i].body() ]);
3194                                 }
3195                                 msg += temp_msg + '\n';
3196                                 print_list.push(
3197                                     {
3198                                         'formatted_note' : temp_msg,
3199                                         'note_title' : notes[i].title(),
3200                                         'note_body' : notes[i].body(),
3201                                         'note_public' : notes[i].pub(),
3202                                         'note_by_staff' : notes[i].staff()
3203                                     }
3204                                 );
3205                             }
3206                         }
3207                         msg += '\n';
3208                         msg += '\n';
3209                         print_data.request_date = util.date.formatted_date(check.payload.hold.request_time(),'%F');
3210                         print_data.request_date_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.request_date', [print_data.request_date]);
3211                         print_data.shelf_expire_time = check.payload.hold.shelf_expire_time();
3212                         msg += print_data.request_date_msg;
3213                         msg += '\n';
3214                     }
3215                     var rv = 0;
3216                     if (suppress_popups) {
3217                         rv = auto_print ? 0 : -1; auto_print = true; // skip dialog and PRINT or DO NOT PRINT based on Auto-Print checkbox
3218                     }
3219                     var x = data.hash.aous['circ.staff_client.do_not_auto_attempt_print'];
3220                     var no_print_prompting = x ? ( x.indexOf( "Hold Slip" ) > -1) : false;
3221                     if (no_print_prompting) {
3222                         rv = -1; auto_print = true; // DO NOT PRINT and skip dialog
3223                     }
3224                     print_data.slip_date = util.date.formatted_date(new Date(),'%F');
3225                     print_data.slip_date_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.slip_date', [print_data.slip_date]);
3226                     msg += print_data.slip_date_msg;
3227                     msg += '\n';
3228                     print_data.payload = check.payload;
3229
3230                     if (!auto_print) {
3231                         rv = error.yns_alert_formatted(
3232                             msg,
3233                             document.getElementById('circStrings').getString('staff.circ.utils.hold_slip'),
3234                             document.getElementById('circStrings').getString('staff.circ.utils.hold_slip.print.yes'),
3235                             document.getElementById('circStrings').getString('staff.circ.utils.hold_slip.print.no'),
3236                             null,
3237                             document.getElementById('circStrings').getString('staff.circ.confirm.msg'),
3238                             '/xul/server/skin/media/images/turtle.gif'
3239                         );
3240                     } else {
3241                         if (suppress_popups && !no_print_prompting) {
3242                             // FIXME: Add SFX and/or GFX
3243                             sound.circ_bad();
3244                         }
3245                     }
3246                     if (rv == 0) {
3247                         try {
3248                             JSAN.use('util.print'); var print = new util.print();
3249                             var old_template = String( data.hash.aous['ui.circ.old_harcoded_slip_template'] ) == 'true';
3250                             if (old_template) {
3251                                 msg = msg.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\n/g,'<br/>');
3252                                 print.simple( msg , { 'no_prompt' : true, 'content_type' : 'text/html' } );
3253                             } else {
3254                                 var template = 'hold_slip';
3255                                 var parms = {
3256                                     'patron' : print_data.user,
3257                                     'lib' : data.hash.aou[ check.payload.hold.pickup_lib() ],
3258                                     'staff' : data.list.au[0],
3259                                     'header' : data.print_list_templates[ template ].header,
3260                                     'line_item' : data.print_list_templates[ template ].line_item,
3261                                     'footer' : data.print_list_templates[ template ].footer,
3262                                     'type' : data.print_list_templates[ template ].type,
3263                                     'list' : print_list,
3264                                     'data' : print_data,
3265                                     'context' : data.print_list_templates[ template ].context,
3266                                 };
3267                                 if ($('printer_prompt')) {
3268                                     if (! $('printer_prompt').checked) { parms.no_prompt = true; }
3269                                 }
3270                                 print.tree_list( parms );
3271                             }
3272                         } catch(E) {
3273                             var err_msg = document.getElementById('commonStrings').getString('common.error');
3274                             err_msg += '\nFIXME: ' + E + '\n';
3275                             dump(err_msg);
3276                             alert(err_msg);
3277                         }
3278                     }
3279                     msg = '';
3280                     if (no_change_label) {
3281                         var m = no_change_label.getAttribute('value');
3282                         var text = document.getElementById('circStrings').getFormattedString('staff.circ.utils.capture', [params.barcode]);
3283                         m += text + '  ';
3284                         no_change_label.setAttribute('value', m);
3285                         no_change_label.setAttribute('hidden','false');
3286                         no_change_label.setAttribute('onclick','');
3287                         removeCSSClass(no_change_label,'click_link');
3288                         no_change_label.setAttribute('unique_row_counter','');
3289                         if (typeof params.info_blurb == 'function') {
3290                             params.info_blurb( text );
3291                         }
3292                     }
3293                 break;
3294                 case 6: /* IN TRANSIT */
3295                     check.what_happened = 'error';
3296                     sound.special('checkin.error');
3297                     check.route_to = 'TRANSIT SHELF??';
3298                     print_data.route_to;
3299                     var err_msg = document.getElementById('commonStrings').getString('common.error');
3300                     err_msg += "\nFIXME -- I didn't think we could get here.\n";
3301                     print_data.error_msg += err_msg;
3302                     msg += err_msg;
3303                 break;
3304                 case 11: /* CATALOGING */
3305                     check.what_happened = 'cataloging';
3306                     sound.special('checkin.cataloging');
3307                     check.route_to = 'CATALOGING';
3308                     print_data.route_to;
3309                     var x = document.getElementById('do_not_alert_on_precat');
3310                     var do_not_alert_on_precats = x ? ( x.getAttribute('checked') == 'true' ) : false;
3311                     if ( !suppress_popups && !do_not_alert_on_precats ) {
3312                         print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
3313                         msg += print_data.route_to_msg;
3314                     } else {
3315                         if (suppress_popups && !do_not_alert_on_precats) {
3316                             // FIXME: add SFX and/or GFX
3317                             sound.circ_bad();
3318                         }
3319                     }
3320                     if (no_change_label) {
3321                         var m = no_change_label.getAttribute('value');
3322                         var needs_cat = document.getElementById('circStrings').getFormattedString('staff.circ.utils.needs_cataloging', [params.barcode]);
3323                         no_change_label.setAttribute('value', m + needs_cat + '  ');
3324                         no_change_label.setAttribute('hidden','false');
3325                         no_change_label.setAttribute('onclick','');
3326                         removeCSSClass(no_change_label,'click_link');
3327                         no_change_label.setAttribute('unique_row_counter','');
3328                         if (typeof params.info_blurb == 'function') {
3329                             params.info_blurb( needs_cat );
3330                         }
3331                     }
3332                 break;
3333                 case 15: // ON_RESERVATION_SHELF
3334                     check.route_to = 'RESERVATION SHELF';
3335                     check.what_happened = "reservation_shelf";
3336                     sound.special('checkin.reservation_shelf');
3337                     if (check.payload.reservation) {
3338                         if (check.payload.reservation.pickup_lib() != data.list.au[0].ws_ou()) {
3339                             msg += document.getElementById('commonStrings').getString('common.error');
3340                             msg += '\nFIXME: ';
3341                             msg += document.getElementById('circStrings').getString('staff.circ.utils.route_item_error');
3342                             msg += '\n';
3343                         } else {
3344                             msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
3345                             msg += '.\n';
3346                         }
3347                     } else {
3348                         msg += document.getElementById('commonStrings').getString('common.error');
3349                         msg += '\nFIXME: ';
3350                         msg += document.getElementById('circStrings').getString('staff.circ.utils.reservation_status_error');
3351                         msg += '\n';
3352                     }
3353                     JSAN.use('util.date');
3354                     if (check.payload.reservation) {
3355                         JSAN.use('patron.util');
3356                         msg += '\n';
3357                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.reservation.barcode', [check.payload.copy.barcode()]);
3358                         msg += '\n';
3359                         var payload_title  = (check.payload.record ? check.payload.record.title() : check.payload.copy.dummy_title() );
3360                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.reservation.title', [payload_title]);
3361                         msg += '\n';
3362                         var au_obj =
3363                             typeof(check.payload.reservation.usr().card) == "function" ?
3364                                 check.payload.reservation.usr() :
3365                                 patron.util.retrieve_fleshed_au_via_id(session, check.payload.reservation.usr());
3366                         msg += '\n';
3367                         if (au_obj.alias()) {
3368                             msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.reservation.patron_alias',  [au_obj.alias()]);
3369                         } else {
3370                             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() || ""]);
3371                         }
3372                         msg += '\n';
3373                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.reservation.barcode', [au_obj.card().barcode()]);
3374                         msg += '\n';
3375                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.reservation.request_date', [util.date.formatted_date(check.payload.reservation.request_time(),'%F %H:%M')]);
3376                         msg += '\n';
3377
3378                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.reservation.start_date', [util.date.formatted_date(check.payload.reservation.start_time(),'%F %H:%M')]);
3379                         msg += '\n';
3380                     }
3381                     var rv = 0;
3382                     msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.reservation.slip_date', [util.date.formatted_date(new Date(),'%F')]);
3383                     msg += '\n';
3384                     if (!auto_print) {
3385                         rv = error.yns_alert_formatted(
3386                             msg,
3387                             document.getElementById('circStrings').getString('staff.circ.utils.reservation_slip'),
3388                             document.getElementById('circStrings').getString('staff.circ.utils.reservation_slip.print.yes'),
3389                             document.getElementById('circStrings').getString('staff.circ.utils.reservation_slip.print.no'),
3390                             null,
3391                             document.getElementById('circStrings').getString('staff.circ.confirm.msg'),
3392                             '/xul/server/skin/media/images/turtle.gif'
3393                         );
3394                     }
3395                     if (rv == 0) {
3396                         try {
3397                             JSAN.use('util.print'); var print = new util.print();
3398                             msg = msg.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\n/g,'<br/>');
3399                             print.simple( msg , { 'no_prompt' : true, 'content_type' : 'text/html' } );
3400                         } catch(E) {
3401                             var err_msg = document.getElementById('commonStrings').getString('common.error');
3402                             err_msg += '\nFIXME: ' + E + '\n';
3403                             dump(err_msg);
3404                             alert(err_msg);
3405                         }
3406                     }
3407                     msg = '';
3408                     if (no_change_label) {
3409                         var m = no_change_label.getAttribute('value');
3410                         var text = document.getElementById('circStrings').getFormattedString('staff.circ.utils.reservation_capture', [params.barcode]);
3411                         m += text + '  ';
3412                         no_change_label.setAttribute('value', m);
3413                         no_change_label.setAttribute('hidden','false');
3414                         no_change_label.setAttribute('onclick','');
3415                         removeCSSClass(no_change_label,'click_link');
3416                         no_change_label.setAttribute('unique_row_counter','');
3417                         if (typeof params.info_blurb == 'function') {
3418                             params.info_blurb( text );
3419                         }
3420                     }
3421                 break;
3422                 default:
3423                     check.what_happened = 'error';
3424                     sound.special('checkin.error');
3425                     msg += document.getElementById('commonStrings').getString('common.error');
3426                     var copy_status = data.hash.ccs[check.copy.status()] ? data.hash.ccs[check.copy.status()].name() : check.copy.status().name();
3427                     msg += '\n';
3428                     var error_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.copy_status.error', [copy_status]);
3429                     print_data.error_msg += error_msg;
3430                     msg += error_msg;
3431                     msg += '\n';
3432                     print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
3433                     msg += print_data.route_to_msg;
3434                 break;
3435             }
3436             if (msg) {
3437                 error.yns_alert(
3438                     msg,
3439                     document.getElementById('circStrings').getString('staff.circ.alert'),
3440                     null,
3441                     document.getElementById('circStrings').getString('staff.circ.utils.msg.ok'),
3442                     null,
3443                     document.getElementById('circStrings').getString('staff.circ.confirm.msg')
3444                 );
3445             }
3446         } else /* ROUTE_ITEM */ if (check.ilsevent == 7000) {
3447
3448             check.what_happened = 'transit';
3449             sound.special('checkin.transit');
3450             var lib = data.hash.aou[ check.org ];
3451             check.route_to = lib.shortname();
3452             print_data.route_to = check.route_to;
3453             print_data.route_to_org = lib;
3454             print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.destination', [check.route_to]);
3455             print_data.route_to_org_fullname = lib.name();
3456             var aous_req = network.simple_request('FM_AOUS_SPECIFIC_RETRIEVE',[ lib.id(), 'lib.courier_code' ]);
3457             if (aous_req) {
3458                 print_data.courier_code = aous_req.value || '';
3459             }
3460             msg += print_data.route_to_msg;
3461             msg += '\n\n';
3462             msg += lib.name();
3463             msg += '\n';
3464             try {
3465                 if (lib.holds_address() ) {
3466                     var a = network.simple_request('FM_AOA_RETRIEVE',[ lib.holds_address() ]);
3467                     if (typeof a.ilsevent != 'undefined') throw(a);
3468                     if (a.street1()) { msg += a.street1() + '\n'; print_data.street1 = a.street1(); }
3469                     if (a.street2()) { msg += a.street2() + '\n'; print_data.street2 = a.street2(); }
3470                     print_data.city_state_zip = (a.city() ? a.city() + ', ' : '') + (a.state() ? a.state() + ' ' : '') + (a.post_code() ? a.post_code() : '');
3471                     print_data.city = a.city();
3472                     print_data.state = a.state();
3473                     print_data.county = a.county();
3474                     print_data.country = a.country();
3475                     print_data.post_code = a.post_code();
3476                     msg += print_data.city_state_zip + '\n';
3477                 } else {
3478                     print_data.street1 = document.getElementById('circStrings').getString('staff.circ.utils.route_to.no_address');
3479                     print_data.no_address = true;
3480                     msg += print_data.street1;
3481                     msg += '\n';
3482                 }
3483             } catch(E) {
3484                 var err_msg = document.getElementById('circStrings').getString('staff.circ.utils.route_to.no_address.error');
3485                 print_data.error_msg += err_msg + '\n';
3486                 msg += err_msg + '\n';
3487                 error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.utils.route_to.no_address.error'), E);
3488             }
3489             msg += '\n';
3490             print_data.item_barcode_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [check.payload.copy.barcode()]);
3491             print_data.item_barcode = check.payload.copy.barcode();
3492             msg += print_data.item_barcode_msg;
3493             msg += '\n';
3494             var payload_title  = (check.payload.record ? check.payload.record.title() : check.payload.copy.dummy_title() );
3495             print_data.item_title_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.title', [payload_title]);
3496             print_data.item_title = payload_title;
3497             msg += print_data.item_title_msg;
3498             msg += '\n';
3499             var payload_author = (check.payload.record ? check.payload.record.author() :check.payload.copy.dummy_author());
3500             print_data.item_author_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.author', [payload_author]);
3501             print_data.item_author = payload_author;
3502             msg += print_data.item_author_msg;
3503             msg += '\n';
3504             if (check.payload.transit) {
3505                 // by adding this here, we make the data available to the
3506                 // receipt printing engine, but since we are not appending it
3507                 // to the 'msg', it will not display in the pre-print dialog.
3508                 print_data.transit_copy_status = 
3509                     data.hash.ccs[check.payload.transit.copy_status()].name();
3510             }
3511             JSAN.use('util.date');
3512             if (check.payload.hold) {
3513                 check.what_happened = 'transit_for_hold';
3514                 sound.special('checkin.transit_for_hold');
3515                 JSAN.use('patron.util');
3516                 var au_obj = patron.util.retrieve_fleshed_au_via_id( session, check.payload.hold.usr() );
3517                 print_data.user = au_obj;
3518                 print_data.user_stat_cat_entries = [];
3519                 var entries = au_obj.stat_cat_entries();
3520                 for (var i = 0; i < entries.length; i++) {
3521                     var stat_cat = data.hash.my_actsc[ entries[i].stat_cat() ];
3522                     if (!stat_cat) {
3523                         stat_cat = data.lookup('actsc', entries[i].stat_cat());
3524                     }
3525                     print_data.user_stat_cat_entries.push( { 
3526                         'id' : entries[i].id(),
3527                         'stat_cat' : {
3528                             'id' : stat_cat.id(),
3529                             'name' : stat_cat.name(),
3530                             'opac_visible' : stat_cat.opac_visible(),
3531                             'owner' : stat_cat.owner(),
3532                             'usr_summary' : stat_cat.usr_summary()
3533                         },
3534                         'stat_cat_entry' : entries[i].stat_cat_entry(),
3535                         'target_usr' : entries[i].target_usr() 
3536                     } );
3537                 }
3538                 msg += '\n';
3539                 if (au_obj.alias()) {
3540                     print_data.hold_for_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.patron_alias',  [au_obj.alias()]);
3541                     print_data.hold_for_alias = au_obj.alias();
3542                     msg += print_data.hold_for_msg;
3543                 } else {
3544                     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() : '']);
3545                     msg += print_data.hold_for_msg;
3546                     print_data.hold_for_family_name = au_obj.family_name() ? au_obj.family_name() : '';
3547                     print_data.hold_for_first_given_name = au_obj.first_given_name() ? au_obj.first_given_name() : '';
3548                     print_data.hold_for_second_given_name = au_obj.second_given_name() ? au_obj.second_given_name() : '';
3549                 }
3550                 msg += '\n';
3551                 print_data.user_barcode_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [au_obj.card().barcode()]);
3552                 print_data.user_barcode = au_obj.card().barcode();
3553                 msg += print_data.user_barcode_msg;
3554                 msg += '\n';
3555                 if (check.payload.hold.phone_notify()) {
3556                     print_data.notify_by_phone_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.phone_notify', [check.payload.hold.phone_notify()]);
3557                     print_data.notify_by_phone = check.payload.hold.phone_notify();
3558                     msg += print_data.notify_by_phone_msg;
3559                     msg += '\n';
3560                 }
3561                 if (check.payload.hold.sms_notify()) {
3562                     print_data.notify_by_text_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.sms_notify', [check.payload.hold.sms_notify()]);
3563                     print_data.notify_by_text = check.payload.hold.sms_notify();
3564                     msg += print_data.notify_by_text_msg;
3565                     msg += '\n';
3566                 }
3567                 if (get_bool(check.payload.hold.email_notify())) {
3568                     var payload_email = au_obj.email() ? au_obj.email() : '';
3569                     print_data.notify_by_email_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.email_notify', [payload_email]);
3570                     print_data.notify_by_email = payload_email;
3571                     msg += print_data.notify_by_email_msg;
3572                     msg += '\n';
3573                 }
3574                 msg += '\n';
3575                 var notes = check.payload.hold.notes();
3576                 print_data.notes_raw = notes;
3577                 for (var i = 0; i < notes.length; i++) {
3578                     if ( get_bool( notes[i].slip() ) ) {
3579                         var temp_msg;
3580                         if ( get_bool( notes[i].staff() ) ) {
3581                             temp_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.notes.staff_note', [ notes[i].title(), notes[i].body() ]);
3582                         } else {
3583                             temp_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.notes.patron_note', [ notes[i].title(), notes[i].body() ]);
3584                         }
3585                         msg += temp_msg + '\n';
3586                         print_list.push(
3587                             {
3588                                 'formatted_note' : temp_msg,
3589                                 'note_title' : notes[i].title(),
3590                                 'note_body' : notes[i].body(),
3591                                 'note_public' : notes[i].pub(),
3592                                 'note_by_staff' : notes[i].staff()
3593                             }
3594                         );
3595                     }
3596                 }
3597                 msg += '\n';
3598                 msg += '\n';
3599                 print_data.request_date = util.date.formatted_date(check.payload.hold.request_time(),'%F');
3600                 print_data.request_date_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.request_date', [print_data.request_date]);
3601                 msg += print_data.request_date_msg;
3602                 msg += '\n';
3603                 var destination_shelf = document.getElementById('circStrings').getString('staff.circ.route_to.hold_shelf');
3604                 print_data.destination_shelf_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [destination_shelf]);
3605                 print_data.destination_shelf = destination_shelf;
3606                 var behind_the_desk_support = String( data.hash.aous['circ.holds.behind_desk_pickup_supported'] ) == 'true';
3607                 if (behind_the_desk_support) {
3608                    var usr_settings = network.simple_request('FM_AUS_RETRIEVE',[ses(),check.payload.hold.usr()]); 
3609                     if (typeof usr_settings['circ.holds_behind_desk'] != 'undefined') {
3610                         if (usr_settings['circ.holds_behind_desk']) {
3611                             print_data.prefer_behind_holds_desk = true;
3612                             destination_shelf = document.getElementById('circStrings').getString('staff.circ.route_to.private_hold_shelf');
3613                             print_data.destination_shelf_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [destination_shelf]);
3614                             print_data.destination_shelf = destination_shelf;
3615                         } else {
3616                             destination_shelf = document.getElementById('circStrings').getString('staff.circ.route_to.public_hold_shelf');
3617                             print_data.destination_shelf_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [destination_shelf]);
3618                             print_data.destination_shelf = destination_shelf;
3619                         }
3620                     } else {
3621                         destination_shelf = document.getElementById('circStrings').getString('staff.circ.route_to.public_hold_shelf');
3622                         print_data.destination_shelf_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [destination_shelf]);
3623                         print_data.destination_shelf = destination_shelf;
3624                     }
3625                 }
3626             }
3627             var rv = 0;
3628             if (suppress_popups) {
3629                 rv = auto_print ? 0 : -1; auto_print = true; // skip dialog and PRINT or DO NOT PRINT based on Auto-Print checkbox
3630             }
3631             var x = data.hash.aous['circ.staff_client.do_not_auto_attempt_print'];
3632             var no_print_prompting = x ? (x.indexOf( check.payload.hold ? "Hold/Transit Slip" : "Transit Slip" ) > -1) : false;
3633             if (no_print_prompting) {
3634                 rv = -1; auto_print = true; // DO NOT PRINT and skip dialog
3635             }
3636             print_data.slip_date = util.date.formatted_date(new Date(),'%F');
3637             print_data.slip_date_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.slip_date', [print_data.slip_date]);
3638             msg += print_data.slip_date_msg;
3639             print_data.payload = check.payload;
3640
3641             if (!auto_print) {
3642                 rv = error.yns_alert_formatted(
3643                     msg,
3644                     document.getElementById('circStrings').getString('staff.circ.utils.transit_slip'),
3645                     document.getElementById('circStrings').getString('staff.circ.utils.transit_slip.print.yes'),
3646                     document.getElementById('circStrings').getString('staff.circ.utils.transit_slip.print.no'),
3647                     null,
3648                     document.getElementById('circStrings').getString('staff.circ.confirm.msg'),
3649                     '/xul/server/skin/media/images/turtle.gif'
3650                 );
3651             } else {
3652                 if (suppress_popups && !no_print_prompting) {
3653                     // FIXME: add SFX and/or GFX
3654                     sound.circ_bad();
3655                 }
3656             }
3657             if (rv == 0) {
3658                 try {
3659                     JSAN.use('util.print'); var print = new util.print();
3660                     var old_template = String( data.hash.aous['ui.circ.old_harcoded_slip_template'] ) == 'true';
3661                     if (old_template) {
3662                         msg = msg.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\n/g,'<br/>');
3663                         print.simple( msg , { 'no_prompt' : true, 'content_type' : 'text/html' } );
3664                     } else {
3665                         var template = check.payload.hold ? 'hold_transit_slip' : 'transit_slip';
3666                         var parms = {
3667                             'patron' : print_data.user,
3668                             'lib' : data.hash.aou[ data.list.au[0].ws_ou() ],
3669                             'staff' : data.list.au[0],
3670                             'header' : data.print_list_templates[ template ].header,
3671                             'line_item' : data.print_list_templates[ template ].line_item,
3672                             'footer' : data.print_list_templates[ template ].footer,
3673                             'type' : data.print_list_templates[ template ].type,
3674                             'list' : print_list,
3675                             'data' : print_data,
3676                             'context' : data.print_list_templates[ template ].context,
3677                         };
3678                         if ($('printer_prompt')) {
3679                             if (! $('printer_prompt').checked) { parms.no_prompt = true; }
3680                         }
3681                         print.tree_list( parms );
3682                     }
3683                 } catch(E) {
3684                     var err_msg = document.getElementById('commonStrings').getString('common.error');
3685                     err_msg += '\nFIXME: ' + E + '\n';
3686                     dump(err_msg);
3687                     alert(err_msg);
3688                 }
3689             }
3690             if (no_change_label) {
3691                 var m = no_change_label.getAttribute('value');
3692                 var trans_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.in_transit', [params.barcode]);
3693                 no_change_label.setAttribute('value', m + trans_msg + '  ');
3694                 no_change_label.setAttribute('hidden','false');
3695                 no_change_label.setAttribute('onclick','');
3696                 removeCSSClass(no_change_label,'click_link');
3697                 no_change_label.setAttribute('unique_row_counter','');
3698                 if (typeof params.info_blurb == 'function') {
3699                     params.info_blurb( trans_msg );
3700                 }
3701             }
3702
3703         } else /* ASSET_COPY_NOT_FOUND */ if (check.ilsevent == 1502) {
3704
3705             check.what_happened = 'not_found';
3706             sound.special('checkin.not_found');
3707             check.route_to = 'CATALOGING';
3708             var mis_scan_msg = document.getElementById('circStrings').getFormattedString('staff.circ.copy_status.status.copy_not_found', [params.barcode]);
3709             if (!suppress_popups) {
3710                 error.yns_alert(
3711                     mis_scan_msg,
3712                     document.getElementById('circStrings').getString('staff.circ.alert'),
3713                     null,
3714                     document.getElementById('circStrings').getString('staff.circ.utils.msg.ok'),
3715                     null,
3716                     document.getElementById('circStrings').getString('staff.circ.confirm.msg')
3717                 );
3718             } else {
3719                 // FIXME: add SFX and/or GFX
3720                 sound.circ_bad();
3721             }
3722             if (no_change_label) {
3723                 var m = no_change_label.getAttribute('value');
3724                 no_change_label.setAttribute('value',m + mis_scan_msg + '  ');
3725                 no_change_label.setAttribute('hidden','false');
3726                 no_change_label.setAttribute('onclick','');
3727                 removeCSSClass(no_change_label,'click_link');
3728                 no_change_label.setAttribute('unique_row_counter','');
3729                 if (typeof params.info_blurb == 'function') {
3730                     params.info_blurb( mis_scan_msg );
3731                 }
3732             }
3733
3734         } else /* HOLD_CAPTURE_DELAYED */ if (check.ilsevent == 7019) {
3735
3736             check.what_happened = 'hold_capture_delayed';
3737             sound.special('checkin.hold_capture_delayed');
3738             var rv = 0;
3739             msg += document.getElementById('circStrings').getString('staff.circ.utils.hold_capture_delayed.description');
3740             if (!suppress_popups) {
3741                 rv = error.yns_alert_formatted(
3742                     msg,
3743                     document.getElementById('circStrings').getString('staff.circ.utils.hold_capture_delayed.titlebar'),
3744                     document.getElementById('circStrings').getString('staff.circ.utils.hold_capture_delayed.prompt_for_nocapture'),
3745                     document.getElementById('circStrings').getString('staff.circ.utils.hold_capture_delayed.prompt_for_capture'),
3746                     null,
3747                     document.getElementById('circStrings').getString('staff.circ.confirm.msg'),
3748                     '/xul/server/skin/media/images/stop_sign.png'
3749                 );
3750             } else {
3751                 // FIXME: add SFX and/or GFX
3752                 sound.circ_bad();
3753             }
3754             params.capture = rv == 0 ? 'nocapture' : 'capture';
3755
3756             return circ.util.checkin_via_barcode(session,params,backdate,auto_print,false);
3757
3758         } else /* NETWORK TIMEOUT */ if (check.ilsevent == -1) {
3759             check.what_happened = 'error';
3760             sound.special('checkin.error');
3761             error.standard_network_error_alert(document.getElementById('circStrings').getString('staff.circ.checkin.suggest_offline'));
3762         } else {
3763
3764             if (check.ilsevent == null) { return null; /* handled */ }
3765             switch (Number(check.ilsevent)) {
3766                 case 1203 /* COPY_BAD_STATUS */ :
3767                 case 1213 /* PATRON_BARRED */ :
3768                 case 1217 /* PATRON_INACTIVE */ :
3769                 case 1224 /* PATRON_ACCOUNT_EXPIRED */ :
3770                 case 1234 /* ITEM_DEPOSIT_PAID */ :
3771                 case 7009 /* CIRC_CLAIMS_RETURNED */ :
3772                 case 7010 /* COPY_ALERT_MESSAGE */ :
3773                 case 7011 /* COPY_STATUS_LOST */ :
3774                 case 7025 /* COPY_STATUS_LONG_OVERDUE */ :
3775                 case 7012 /* COPY_STATUS_MISSING */ :
3776                 case 7013 /* PATRON_EXCEEDS_FINES */ :
3777                     return null; /* handled */
3778                 break;
3779             }
3780
3781             throw(check);
3782
3783         }
3784
3785         return check;
3786     } catch(E) {
3787         JSAN.use('util.error'); var error = new util.error();
3788         error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.error', ['3']), E);
3789         return null;
3790     }
3791 };
3792
3793 circ.util.renew_via_barcode = function ( params, async ) {
3794     try {
3795         var obj = {};
3796         JSAN.use('util.network'); obj.network = new util.network();
3797         JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.stash_retrieve();
3798
3799         function renew_callback(req) {
3800             try {
3801                 JSAN.use('util.error'); var error = new util.error();
3802                 var renew = req.getResultObject();
3803                 if (typeof renew.ilsevent != 'undefined') renew = [ renew ];
3804                 for (var j = 0; j < renew.length; j++) {
3805                     switch(renew[j].ilsevent == null ? null : Number(renew[j].ilsevent)) {
3806                         case 0 /* SUCCESS */ : break;
3807                         case null /* custom event */ : break;
3808                         case 5000 /* PERM_FAILURE */: break;
3809                         case 1212 /* PATRON_EXCEEDS_OVERDUE_COUNT */ : break;
3810                         case 7002 /* PATRON_EXCEEDS_CHECKOUT_COUNT */ : break;
3811                         case 1213 /* PATRON_BARRED */ : break;
3812                         case 1215 /* CIRC_EXCEEDS_COPY_RANGE */ : break;
3813                         case 1224 /* PATRON_ACCOUNT_EXPIRED */ : break;
3814                         case 1232 /* ITEM_DEPOSIT_REQUIRED */ : break;
3815                         case 1233 /* ITEM_RENTAL_FEE_REQUIRED */ : break;
3816                         case 1234 /* ITEM_DEPOSIT_PAID */ : break;
3817                         case 1236 /* PATRON_EXCEEDS_LOST_COUNT */ : break;
3818                         case 1500 /* ACTION_CIRCULATION_NOT_FOUND */ : break;
3819                         case 1502 /* ASSET_COPY_NOT_FOUND */ : 
3820                             var mis_scan_msg = document.getElementById('circStrings').getFormattedString('staff.circ.copy_status.status.copy_not_found', [params.barcode]);
3821                             error.yns_alert(
3822                                 mis_scan_msg,
3823                                 document.getElementById('circStrings').getString('staff.circ.alert'),
3824                                 null,
3825                                 document.getElementById('circStrings').getString('staff.circ.utils.msg.ok'),
3826                                 null,
3827                                 document.getElementById('circStrings').getString('staff.circ.confirm.msg')
3828                             );
3829                             if (no_change_label) {
3830                                 var m = no_change_label.getAttribute('value');
3831                                 no_change_label.setAttribute('value',m + mis_scan_msg + '  ');
3832                                 no_change_label.setAttribute('hidden','false');
3833                                 no_change_label.setAttribute('onclick','');
3834                                 removeCSSClass(no_change_label,'click_link');
3835                                 no_change_label.setAttribute('unique_row_counter','');
3836                                 if (typeof params.info_blurb == 'function') {
3837                                     params.info_blurb( mis_scan_msg );
3838                                 }
3839                             }
3840                         break;
3841                         case 7002 /* PATRON_EXCEEDS_CHECKOUT_COUNT */ : break;
3842                         case 7003 /* COPY_CIRC_NOT_ALLOWED */ : break;
3843                         case 7004 /* COPY_NOT_AVAILABLE */ : break;
3844                         case 7006 /* COPY_IS_REFERENCE */ : break;
3845                         case 7007 /* COPY_NEEDED_FOR_HOLD */ : break;
3846                         case 7008 /* MAX_RENEWALS_REACHED */ : break;
3847                         case 7009 /* CIRC_CLAIMS_RETURNED */ : break;
3848                         case 7010 /* COPY_ALERT_MESSAGE */ : break;
3849                         case 7013 /* PATRON_EXCEEDS_FINES */ : break;
3850                         default:
3851                             throw(renew);
3852                         break;
3853                     }
3854                 }
3855                 try {
3856                     var ibarcode = renew[0].payload.copy ? renew[0].payload.copy.barcode() : params.barcode;
3857                     var p_id = renew[0].payload.patron ? renew[0].payload.patron.id() : renew[0].payload.circ.usr();
3858                     var pname; var pbarcode; 
3859                     if (renew[0].patron) {
3860                         pname = renew[0].payload.patron.family_name();
3861                         pbarcode = typeof renew[0].payload.patron.card() == 'object' ? renew[0].payload.patron.card().barcode() : null;
3862                     } else {
3863                         if (circ.util.renew_via_barcode.last_usr_id == p_id) {
3864                             pname = circ.util.renew_via_barcode.last_pname;
3865                             pbarcode = circ.util.renew_via_barcode.last_pbarcode;
3866                         } else {
3867                             JSAN.use('patron.util'); var p = patron.util.retrieve_fleshed_au_via_id(ses(),p_id);
3868                             pname = p.family_name();
3869                             pbarcode = typeof p.card() == 'object' ? p.card().barcode() : null;
3870                             if (pname) {
3871                                 circ.util.renew_via_barcode.last_usr_id = p_id;
3872                                 circ.util.renew_via_barcode.last_pname = pname;
3873                                 circ.util.renew_via_barcode.last_pbarcode = pbarcode;
3874                             }
3875                         } 
3876                     }
3877                     error.work_log(
3878                         document.getElementById('circStrings').getFormattedString(
3879                             'staff.circ.work_log_renew.message',
3880                             [
3881                                 ses('staff_usrname'),
3882                                 pname ? pname : '???',
3883                                 pbarcode ? pbarcode : '???',
3884                                 ibarcode ? ibarcode : '???'
3885                             ]
3886                         ), {
3887                             'au_id' : p_id,
3888                             'au_family_name' : pname,
3889                             'au_barcode' : pbarcode,
3890                             'acp_barcode' : ibarcode
3891                         }
3892                     );
3893                 } catch(E) {
3894                     error.sdump('D_ERROR','Error with work_logging in server/circ/util.js, renew_via_barcode():' + E);
3895                 }
3896                 if (typeof async == 'function') async(renew);
3897                 return renew;
3898             } catch(E) {
3899                 JSAN.use('util.error'); var error = new util.error();
3900                 error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.renew_failed.error', [params.barcode]), E);
3901                 return null;
3902             }
3903         }
3904
3905         var renew = obj.network.simple_request(
3906             'CHECKOUT_RENEW',
3907             [ ses(), params ],
3908             async ? renew_callback : null,
3909             {
3910                 'title' : document.getElementById('circStrings').getString('staff.circ.checkin.renew_failed.override'),
3911                 'overridable_events' : [
3912                     null /* custom event */,
3913                     1212 /* PATRON_EXCEEDS_OVERDUE_COUNT */,
3914                     1213 /* PATRON_BARRED */,
3915                     1215 /* CIRC_EXCEEDS_COPY_RANGE */,
3916                     1232 /* ITEM_DEPOSIT_REQUIRED */,
3917                     1233 /* ITEM_RENTAL_FEE_REQUIRED */,
3918                     1234 /* ITEM_DEPOSIT_PAID */,
3919                     1236 /* PATRON_EXCEEDS_LOST_COUNT */,
3920                     7002 /* PATRON_EXCEEDS_CHECKOUT_COUNT */,
3921                     7003 /* COPY_CIRC_NOT_ALLOWED */,
3922                     7004 /* COPY_NOT_AVAILABLE */,
3923                     7006 /* COPY_IS_REFERENCE */,
3924                     7007 /* COPY_NEEDED_FOR_HOLD */,
3925                     7008 /* MAX_RENEWALS_REACHED */,
3926                     7009 /* CIRC_CLAIMS_RETURNED */,
3927                     7010 /* COPY_ALERT_MESSAGE */,
3928                     7013 /* PATRON_EXCEEDS_FINES */,
3929                 ],
3930                 'text' : {
3931                     '1212' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
3932                     '1213' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
3933                     '1215' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
3934                     '1232' : function(r) {
3935                         return document.getElementById('circStrings').getFormattedString('staff.circ.renew.override.item_deposit_required.warning.barcode', [params.barcode]);
3936                     },
3937                     '1233' : function(r) {
3938                         return document.getElementById('circStrings').getFormattedString('staff.circ.renew.override.item_rental_fee_required.warning.barcode', [params.barcode]);
3939                     },
3940                     '1234' : function(r) {
3941                         return document.getElementById('circStrings').getFormattedString('staff.circ.utils.checkin.override.item_deposit_paid.warning');
3942                     },
3943                     '1236' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
3944                     '7002' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
3945                     '7003' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
3946                     '7004' : function(r) {
3947                         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()]);
3948                     },
3949                     '7006' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
3950                     '7007' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
3951                     '7008' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
3952                     '7009' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
3953                     '7010' : function(r) {
3954                         return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode.msg', [params.barcode, r.payload]);
3955                     },
3956                     '7013' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); }
3957                 }
3958             }
3959         );
3960         if (! async ) {
3961             return renew_callback( { 'getResultObject' : function() { return renew; } } );
3962         }
3963
3964     } catch(E) {
3965         JSAN.use('util.error'); var error = new util.error();
3966         error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.renew_failed.error', [params.barcode]), E);
3967         return null;
3968     }
3969 };
3970
3971 circ.util.batch_hold_update = function ( hold_ids, field_changes, params ) {
3972     try {
3973         JSAN.use('util.sound'); var sound = new util.sound();
3974         var change_list = []; var idx = -1; var bad_holds = [];
3975         dojo.forEach(
3976             hold_ids,
3977             function(el) {
3978                 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?
3979             }
3980         );
3981         if (params.progressmeter) { params.progressmeter.value = 0; params.progressmeter.hidden = false; }
3982         fieldmapper.standardRequest(
3983             [ api.FM_AHR_UPDATE_BATCH.app, api.FM_AHR_UPDATE_BATCH.method ],
3984             {   async: true,
3985                 params: [ses(), null, change_list],
3986                 onresponse: function(r) {
3987                     idx++; 
3988                     if (params.progressmeter) { params.progressmeter.value = Number( params.progressmeter.value ) + 100/hold_ids.length; }
3989                     var result = r.recv().content();
3990                     if (result != hold_ids[ idx ]) {
3991                         bad_holds.push( { 'hold_id' : hold_ids[ idx ], 'result' : result } );
3992                     }
3993                 },
3994                 oncomplete: function() {
3995                     if (bad_holds.length > 0) {
3996                         sound.circ_bad();
3997                         alert( $('circStrings').getFormattedString('staff.circ.hold_update.hold_ids.failed',[ bad_holds.length ]) );
3998                     } else {
3999                         sound.circ_good();
4000                     }
4001                     if (typeof params.oncomplete == 'function') {
4002                         params.oncomplete( bad_holds );
4003                     }
4004                     if (params.progressmeter) { params.progressmeter.value = 0; params.progressmeter.hidden = true; }
4005                 },
4006                 onerror: function(r) {
4007                     alert('Error in circ/util.js, batch_hold_update(), onerror: ' + r);
4008                 }
4009             }
4010         );
4011     } catch(E) {
4012         alert('Error in circ.util.js, circ.util.batch_hold_update(): ' + E);
4013     }
4014 };
4015
4016 circ.util.find_acq_po = function(session, copy_id) {
4017     dojo.require("openils.Util");
4018     fieldmapper.standardRequest(
4019         ["open-ils.acq", "open-ils.acq.lineitem.retrieve.by_copy_id.authoritative"], {
4020             "params": [session, copy_id, {"clear_marc": true}],
4021             "onresponse": function(r) {
4022                 if (r = openils.Util.readResponse(r)) {
4023                     if (r.purchase_order()) {
4024                         var url = urls.XUL_BROWSER + "?url=" +
4025                             window.escape(
4026                                 xulG.url_prefix('EG_ACQ_PO_VIEW/')
4027                                     + r.purchase_order() + "/" + r.id()
4028                             );
4029                         window.xulG.new_tab(
4030                             url, {"browser": true}, {
4031                                 "no_xulG": false,
4032                                 "show_print_button": false,
4033                                 "show_nav_buttons": true
4034                             }
4035                         );
4036                     } else {
4037                         /* unlikely: got an LI with no PO */
4038                         alert(dojo.byId("circStrings").getFormattedString(
4039                             "staff.circ.utils.find_acq_po.no_po", [r.id()]
4040                         ));
4041                     }
4042                 }
4043             }
4044         }
4045     );
4046 };
4047
4048 dump('exiting circ/util.js\n');