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