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