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