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