]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/xul/staff_client/server/circ/util.js
for the Circulate as Type column in xul lists, display the actual citm value instead...
[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                 ],
2667                 'text' : {
2668                     '1203' : function(r) {
2669                         return typeof r.payload.status() == 'object' ? r.payload.status().name() : data.hash.ccs[ r.payload.status() ].name();
2670                     },
2671                     '1234' : function(r) {
2672                         return document.getElementById('circStrings').getString('staff.circ.utils.checkin.override.item_deposit_paid.warning');
2673                     },
2674                     '7010' : function(r) {
2675                         return r.payload;
2676                     }
2677                 }
2678             }
2679         );
2680         if (! async ) {
2681             return checkin_callback( { 'getResultObject' : function() { return check; } } );
2682         }
2683
2684
2685     } catch(E) {
2686         JSAN.use('util.error'); var error = new util.error();
2687         error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.error', ['2']), E);
2688         if (typeof params.enable_textbox == 'function') {
2689             try { params.enable_textbox(); } catch(E) { error.sdump('D_ERROR','params.disable_textbox() = ' + E); };
2690         }
2691         return null;
2692     }
2693 };
2694
2695 circ.util.checkin_via_barcode2 = function(session,params,backdate,auto_print,check) {
2696     try {
2697         JSAN.use('util.error'); var error = new util.error();
2698         JSAN.use('util.network'); var network = new util.network();
2699         JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
2700         JSAN.use('util.date');
2701         JSAN.use('util.sound'); var sound = new util.sound();
2702
2703         dump('check = ' + error.pretty_print( js2JSON( check ) ) + '\n' );
2704
2705         check.message = check.textcode;
2706
2707         if (check.payload && check.payload.copy) { check.copy = check.payload.copy; }
2708         if (check.payload && check.payload.volume) { check.volume = check.payload.volume; }
2709         if (check.payload && check.payload.record) { check.record = check.payload.record; }
2710         if (check.payload && check.payload.circ) { check.circ = check.payload.circ; }
2711         if (check.payload && check.payload.patron) { check.patron = check.payload.patron; }
2712
2713         if (!check.route_to) { check.route_to = '   '; }
2714
2715         var no_change_label = document.getElementById('no_change_label');
2716
2717         if (no_change_label) {
2718             no_change_label.setAttribute('value','');
2719             no_change_label.setAttribute('hidden','true');
2720             no_change_label.setAttribute('onclick','');
2721             removeCSSClass(no_change_label,'click_link');
2722             no_change_label.setAttribute('unique_row_counter','');
2723         }
2724
2725         var msg = '';
2726         var print_list = [];
2727         var print_data = { 
2728             'error' : '',
2729             'error_msg' : '',
2730             'cancelled' : '',
2731             'route_to' : '',
2732             'route_to_msg' : '',
2733             'route_to_org_fullname' : '',
2734             'destination_shelf' : '',
2735             'destination_shelf_msg' : '',
2736             'courier_code' : '',
2737             'street1' : '',
2738             'street2' : '',
2739             'city_state_zip' : '',
2740             'city' : '',
2741             'state' : '',
2742             'county' : '',
2743             'country' : '',
2744             'post_code' : '',
2745             'item_barcode' : '',
2746             'item_barcode_msg' : '',
2747             'item_title' : '',
2748             'item_title_msg' : '',
2749             'item_author' : '',
2750             'item_author_msg' : '',
2751             'hold_for_msg' : '',
2752             'hold_for_alias' : '',
2753             'hold_for_family_name' : '',
2754             'hold_for_first_given_name' : '',
2755             'hold_for_second_given_name' : '',
2756             'user_barcode' : '',
2757             'user_barcode_msg' : '',
2758             'notify_by_phone' : '',
2759             'notify_by_phone_msg' : '',
2760             'notify_by_email' : '',
2761             'notify_by_email_msg' : '',
2762             'request_date' : '',
2763             'request_date_msg' : '',
2764             'shelf_expire_time' : '',
2765             'slip_date' : '',
2766             'slip_date_msg' : '',
2767             'user' : '',
2768             'user_stat_cat_entries' : ''
2769         };
2770
2771         if (check.payload && check.payload.cancelled_hold_transit) {
2772             print_data.cancelled = document.getElementById('circStrings').getString('staff.circ.utils.transit_hold_cancelled');
2773             msg += print_data.cancelled;
2774             msg += '\n\n';
2775         }
2776
2777         /* SUCCESS  /  NO_CHANGE  /  ITEM_NOT_CATALOGED */
2778         if (check.ilsevent == 0 || check.ilsevent == 3 || check.ilsevent == 1202) {
2779             try { check.route_to = data.lookup('acpl', check.copy.location() ).name(); }
2780             catch(E) {
2781                 print_data.error_msg = document.getElementById('commonStrings').getString('common.error');
2782                 print_data.error_msg += '\nFIXME: ' + E + '\n';
2783                 msg += print_data.error_msg;
2784             }
2785             if (check.ilsevent == 3 /* NO_CHANGE */) {
2786                 //msg = 'This item is already checked in.\n';
2787                 check.what_happened = 'no_change';
2788                 if (no_change_label) {
2789                     var m = no_change_label.getAttribute('value');
2790                     var text = document.getElementById('circStrings').getFormattedString('staff.circ.utils.item_checked_in', [params.barcode]);
2791                     no_change_label.setAttribute('value', m + text + '  ');
2792                     no_change_label.setAttribute('hidden','false');
2793                     no_change_label.setAttribute('onclick','');
2794                     removeCSSClass(no_change_label,'click_link');
2795                     no_change_label.setAttribute('unique_row_counter','');
2796                     if (typeof params.info_blurb == 'function') {
2797                         params.info_blurb( text );
2798                     }
2799                 }
2800             }
2801             if (check.ilsevent == 1202 /* ITEM_NOT_CATALOGED */ && check.copy.status() != 11) {
2802                 check.what_happened = 'error';
2803                 var copy_status = (data.hash.ccs[ check.copy.status() ] ? data.hash.ccs[ check.copy.status() ].name() : check.copy.status().name() );
2804                 var err_msg = document.getElementById('commonStrings').getString('common.error');
2805                 err_msg += '\nFIXME --';
2806                 err_msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.item_not_cataloged', [copy_status]);
2807                 err_msg += '\n';
2808                 msg += err_msg;
2809                 print_data.error_msg += err_msg;
2810             }
2811             switch(Number(check.copy.status())) {
2812                 case 0: /* AVAILABLE */
2813                 case 7: /* RESHELVING */
2814                     check.what_happened = 'success';
2815                     if (msg) {
2816                         print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2817                         print_data.route_to = check.route_to;
2818                         msg += print_data.route_to_msg;
2819                         msg += '\n';
2820                     }
2821                 break;
2822                 case 8: /* ON HOLDS SHELF */
2823                     check.what_happened = 'hold_shelf';
2824                     check.route_to = document.getElementById('circStrings').getString('staff.circ.route_to.hold_shelf');
2825                     if (check.payload.hold) {
2826                         if (check.payload.hold.pickup_lib() != data.list.au[0].ws_ou()) {
2827                             check.what_happened = 'error';
2828                             var err_msg = document.getElementById('commonStrings').getString('common.error');
2829                             err_msg += '\nFIXME: ';
2830                             err_msg += document.getElementById('circStrings').getString('staff.circ.utils.route_item_error');
2831                             err_msg += '\n';
2832                             msg += err_msg;
2833                             print_data.error_msg += err_msg;
2834                         } else {
2835                             print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2836                             print_data.route_to = check.route_to;
2837                             var behind_the_desk_support = String( data.hash.aous['circ.holds.behind_desk_pickup_supported'] ) == 'true';
2838                             if (behind_the_desk_support) {
2839                                var usr_settings = network.simple_request('FM_AUS_RETRIEVE',[ses(),check.payload.hold.usr()]); 
2840                                 if (typeof usr_settings['circ.holds_behind_desk'] != 'undefined') {
2841                                     if (usr_settings['circ.holds_behind_desk']) {
2842                                         print_data.prefer_behind_holds_desk = true;
2843                                         check.route_to = document.getElementById('circStrings').getString('staff.circ.route_to.private_hold_shelf');
2844                                         print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2845                                         print_data.route_to = check.route_to;
2846                                     } else {
2847                                         check.route_to = document.getElementById('circStrings').getString('staff.circ.route_to.public_hold_shelf');
2848                                         print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2849                                         print_data.route_to = check.route_to;
2850                                     }
2851                                 } else {
2852                                     check.route_to = document.getElementById('circStrings').getString('staff.circ.route_to.public_hold_shelf');
2853                                     print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2854                                     print_data.route_to = check.route_to;
2855                                 }
2856                             }
2857                             print_data.destination_shelf_msg = print_data.route_to_msg;
2858                             print_data.destination_shelf = print_data.route_to;
2859                             msg += print_data.route_to_msg;
2860                             msg += '\n';
2861                         }
2862                     } else {
2863                         check.what_happened = 'error';
2864                         var err_msg = document.getElementById('commonStrings').getString('common.error');
2865                         err_msg += '\nFIXME: ';
2866                         err_msg += document.getElementById('circStrings').getString('staff.circ.utils.route_item_status_error');
2867                         err_msg += '\n';
2868                         msg += err_msg;
2869                         print_data.error_msg += err_msg;
2870                     }
2871                     JSAN.use('util.date');
2872                     if (check.payload.hold) {
2873                         JSAN.use('patron.util');
2874                         msg += '\n';
2875                         print_data.item_barcode_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [check.payload.copy.barcode()]);
2876                         print_data.item_barcode = check.payload.copy.barcode();
2877                         msg += print_data.item_barcode_msg;
2878                         msg += '\n';
2879                         var payload_title  = (check.payload.record ? check.payload.record.title() : check.payload.copy.dummy_title() );
2880                         print_data.item_title_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.title', [payload_title]);
2881                         print_data.item_title = payload_title;
2882                         msg += print_data.item_title_msg;
2883                         msg += '\n';
2884                         var au_obj = patron.util.retrieve_fleshed_au_via_id( session, check.payload.hold.usr() );
2885                         print_data.user = au_obj;
2886                         print_data.user_stat_cat_entries = [];
2887                         var entries = au_obj.stat_cat_entries();
2888                         for (var i = 0; i < entries.length; i++) {
2889                             var stat_cat = data.hash.my_actsc[ entries[i].stat_cat() ];
2890                             if (!stat_cat) {
2891                                 stat_cat = data.lookup('actsc', entries[i].stat_cat());
2892                             }
2893                             print_data.user_stat_cat_entries.push( { 
2894                                 'id' : entries[i].id(),
2895                                 'stat_cat' : {
2896                                     'id' : stat_cat.id(),
2897                                     'name' : stat_cat.name(),
2898                                     'opac_visible' : stat_cat.opac_visible(),
2899                                     'owner' : stat_cat.owner(),
2900                                     'usr_summary' : stat_cat.usr_summary()
2901                                 },
2902                                 'stat_cat_entry' : entries[i].stat_cat_entry(),
2903                                 'target_usr' : entries[i].target_usr() 
2904                             } );
2905                         }
2906                         msg += '\n';
2907                         if (au_obj.alias()) {
2908                             print_data.hold_for_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.patron_alias',  [au_obj.alias()]);
2909                             print_data.hold_for_alias = au_obj.alias();
2910                             msg += print_data.hold_for_msg;
2911                         } else {
2912                             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() : '']);
2913                             msg += print_data.hold_for_msg;
2914                             print_data.hold_for_family_name = au_obj.family_name() ? au_obj.family_name() : '';
2915                             print_data.hold_for_first_given_name = au_obj.first_given_name() ? au_obj.first_given_name() : '';
2916                             print_data.hold_for_second_given_name = au_obj.second_given_name() ? au_obj.second_given_name() : '';
2917                         }
2918                         msg += '\n';
2919                         print_data.user_barcode_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [au_obj.card().barcode()]);
2920                         print_data.user_barcode = au_obj.card().barcode();
2921                         msg += print_data.user_barcode_msg;
2922                         msg += '\n';
2923                         if (check.payload.hold.phone_notify()) {
2924                             print_data.notify_by_phone_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.phone_notify', [check.payload.hold.phone_notify()]);
2925                             print_data.notify_by_phone = check.payload.hold.phone_notify();
2926                             msg += print_data.notify_by_phone_msg;
2927                             msg += '\n';
2928                         }
2929                         if (get_bool(check.payload.hold.email_notify())) {
2930                             var payload_email = au_obj.email() ? au_obj.email() : '';
2931                             print_data.notify_by_email_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.email_notify', [payload_email]);
2932                             print_data.notify_by_email = payload_email;
2933                             msg += print_data.notify_by_email_msg;
2934                             msg += '\n';
2935                         }
2936                         msg += '\n';
2937                         var notes = check.payload.hold.notes();
2938                         print_data.notes_raw = notes;
2939                         for (var i = 0; i < notes.length; i++) {
2940                             if ( get_bool( notes[i].slip() ) ) {
2941                                 var temp_msg;
2942                                 if ( get_bool( notes[i].staff() ) ) {
2943                                     temp_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.notes.staff_note', [ notes[i].title(), notes[i].body() ]);
2944                                 } else {
2945                                     temp_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.notes.patron_note', [ notes[i].title(), notes[i].body() ]);
2946                                 }
2947                                 msg += temp_msg + '\n';
2948                                 print_list.push(
2949                                     {
2950                                         'formatted_note' : temp_msg,
2951                                         'note_title' : notes[i].title(),
2952                                         'note_body' : notes[i].body(),
2953                                         'note_public' : notes[i].pub(),
2954                                         'note_by_staff' : notes[i].staff()
2955                                     }
2956                                 );
2957                             }
2958                         }
2959                         msg += '\n';
2960                         msg += '\n';
2961                         print_data.request_date = util.date.formatted_date(check.payload.hold.request_time(),'%F');
2962                         print_data.request_date_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.request_date', [print_data.request_date]);
2963                         print_data.shelf_expire_time = check.payload.hold.shelf_expire_time();
2964                         msg += print_data.request_date_msg;
2965                         msg += '\n';
2966                     }
2967                     var rv = 0;
2968                     var suppress_popups = data.hash.aous['ui.circ.suppress_checkin_popups'];
2969                     if (suppress_popups) {
2970                         rv = auto_print ? 0 : -1; auto_print = true; // skip dialog and PRINT or DO NOT PRINT based on Auto-Print checkbox
2971                     }
2972                     var x = data.hash.aous['circ.staff_client.do_not_auto_attempt_print'];
2973                     var no_print_prompting = x ? ( x.indexOf( "Hold Slip" ) > -1) : false;
2974                     if (no_print_prompting) {
2975                         rv = -1; auto_print = true; // DO NOT PRINT and skip dialog
2976                     }
2977                     print_data.slip_date = util.date.formatted_date(new Date(),'%F');
2978                     print_data.slip_date_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.slip_date', [print_data.slip_date]);
2979                     msg += print_data.slip_date_msg;
2980                     msg += '\n';
2981                     print_data.payload = check.payload;
2982
2983                     if (!auto_print) {
2984                         rv = error.yns_alert_formatted(
2985                             msg,
2986                             document.getElementById('circStrings').getString('staff.circ.utils.hold_slip'),
2987                             document.getElementById('circStrings').getString('staff.circ.utils.hold_slip.print.yes'),
2988                             document.getElementById('circStrings').getString('staff.circ.utils.hold_slip.print.no'),
2989                             null,
2990                             document.getElementById('circStrings').getString('staff.circ.confirm.msg'),
2991                             '/xul/server/skin/media/images/turtle.gif'
2992                         );
2993                     } else {
2994                         if (suppress_popups && !no_print_prompting) {
2995                             // FIXME: Add SFX and/or GFX
2996                             sound.circ_bad();
2997                         }
2998                     }
2999                     if (rv == 0) {
3000                         try {
3001                             JSAN.use('util.print'); var print = new util.print();
3002                             var old_template = String( data.hash.aous['ui.circ.old_harcoded_slip_template'] ) == 'true';
3003                             if (old_template) {
3004                                 msg = msg.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\n/g,'<br/>');
3005                                 print.simple( msg , { 'no_prompt' : true, 'content_type' : 'text/html' } );
3006                             } else {
3007                                 var template = 'hold_slip';
3008                                 var parms = {
3009                                     'patron' : print_data.user,
3010                                     'lib' : data.hash.aou[ check.payload.hold.pickup_lib() ],
3011                                     'staff' : data.list.au[0],
3012                                     'header' : data.print_list_templates[ template ].header,
3013                                     'line_item' : data.print_list_templates[ template ].line_item,
3014                                     'footer' : data.print_list_templates[ template ].footer,
3015                                     'type' : data.print_list_templates[ template ].type,
3016                                     'list' : print_list,
3017                                     'data' : print_data
3018                                 };
3019                                 if ($('printer_prompt')) {
3020                                     if (! $('printer_prompt').checked) { parms.no_prompt = true; }
3021                                 }
3022                                 print.tree_list( parms );
3023                             }
3024                         } catch(E) {
3025                             var err_msg = document.getElementById('commonStrings').getString('common.error');
3026                             err_msg += '\nFIXME: ' + E + '\n';
3027                             dump(err_msg);
3028                             alert(err_msg);
3029                         }
3030                     }
3031                     msg = '';
3032                     if (no_change_label) {
3033                         var m = no_change_label.getAttribute('value');
3034                         var text = document.getElementById('circStrings').getFormattedString('staff.circ.utils.capture', [params.barcode]);
3035                         m += text + '  ';
3036                         no_change_label.setAttribute('value', m);
3037                         no_change_label.setAttribute('hidden','false');
3038                         no_change_label.setAttribute('onclick','');
3039                         removeCSSClass(no_change_label,'click_link');
3040                         no_change_label.setAttribute('unique_row_counter','');
3041                         if (typeof params.info_blurb == 'function') {
3042                             params.info_blurb( text );
3043                         }
3044                     }
3045                 break;
3046                 case 6: /* IN TRANSIT */
3047                     check.what_happened = 'error';
3048                     check.route_to = 'TRANSIT SHELF??';
3049                     print_data.route_to;
3050                     var err_msg = document.getElementById('commonStrings').getString('common.error');
3051                     err_msg += "\nFIXME -- I didn't think we could get here.\n";
3052                     print_data.error_msg += err_msg;
3053                     msg += err_msg;
3054                 break;
3055                 case 11: /* CATALOGING */
3056                     check.what_happened = 'cataloging';
3057                     check.route_to = 'CATALOGING';
3058                     print_data.route_to;
3059                     var suppress_popups = data.hash.aous['ui.circ.suppress_checkin_popups'];
3060                     var x = document.getElementById('do_not_alert_on_precat');
3061                     var do_not_alert_on_precats = x ? ( x.getAttribute('checked') == 'true' ) : false;
3062                     if ( !suppress_popups && !do_not_alert_on_precats ) {
3063                         print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
3064                         msg += print_data.route_to_msg;
3065                     } else {
3066                         if (suppress_popups && !do_not_alert_on_precats) {
3067                             // FIXME: add SFX and/or GFX
3068                             sound.circ_bad();
3069                         }
3070                     }
3071                     if (no_change_label) {
3072                         var m = no_change_label.getAttribute('value');
3073                         var needs_cat = document.getElementById('circStrings').getFormattedString('staff.circ.utils.needs_cataloging', [params.barcode]);
3074                         no_change_label.setAttribute('value', m + needs_cat + '  ');
3075                         no_change_label.setAttribute('hidden','false');
3076                         no_change_label.setAttribute('onclick','');
3077                         removeCSSClass(no_change_label,'click_link');
3078                         no_change_label.setAttribute('unique_row_counter','');
3079                         if (typeof params.info_blurb == 'function') {
3080                             params.info_blurb( needs_cat );
3081                         }
3082                     }
3083                 break;
3084                 case 15: // ON_RESERVATION_SHELF
3085                     check.route_to = 'RESERVATION SHELF';
3086                     check.what_happened = "reservation_shelf";
3087                     if (check.payload.reservation) {
3088                         if (check.payload.reservation.pickup_lib() != data.list.au[0].ws_ou()) {
3089                             msg += document.getElementById('commonStrings').getString('common.error');
3090                             msg += '\nFIXME: ';
3091                             msg += document.getElementById('circStrings').getString('staff.circ.utils.route_item_error');
3092                             msg += '\n';
3093                         } else {
3094                             msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
3095                             msg += '.\n';
3096                         }
3097                     } else {
3098                         msg += document.getElementById('commonStrings').getString('common.error');
3099                         msg += '\nFIXME: ';
3100                         msg += document.getElementById('circStrings').getString('staff.circ.utils.reservation_status_error');
3101                         msg += '\n';
3102                     }
3103                     JSAN.use('util.date');
3104                     if (check.payload.reservation) {
3105                         JSAN.use('patron.util');
3106                         msg += '\n';
3107                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.reservation.barcode', [check.payload.copy.barcode()]);
3108                         msg += '\n';
3109                         var payload_title  = (check.payload.record ? check.payload.record.title() : check.payload.copy.dummy_title() );
3110                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.reservation.title', [payload_title]);
3111                         msg += '\n';
3112                         var au_obj =
3113                             typeof(check.payload.reservation.usr().card) == "function" ?
3114                                 check.payload.reservation.usr() :
3115                                 patron.util.retrieve_fleshed_au_via_id(session, check.payload.reservation.usr());
3116                         msg += '\n';
3117                         if (au_obj.alias()) {
3118                             msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.reservation.patron_alias',  [au_obj.alias()]);
3119                         } else {
3120                             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() || ""]);
3121                         }
3122                         msg += '\n';
3123                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.reservation.barcode', [au_obj.card().barcode()]);
3124                         msg += '\n';
3125                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.reservation.request_date', [util.date.formatted_date(check.payload.reservation.request_time(),'%F %H:%M')]);
3126                         msg += '\n';
3127
3128                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.reservation.start_date', [util.date.formatted_date(check.payload.reservation.start_time(),'%F %H:%M')]);
3129                         msg += '\n';
3130                     }
3131                     var rv = 0;
3132                     msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.reservation.slip_date', [util.date.formatted_date(new Date(),'%F')]);
3133                     msg += '\n';
3134                     if (!auto_print) {
3135                         rv = error.yns_alert_formatted(
3136                             msg,
3137                             document.getElementById('circStrings').getString('staff.circ.utils.reservation_slip'),
3138                             document.getElementById('circStrings').getString('staff.circ.utils.reservation_slip.print.yes'),
3139                             document.getElementById('circStrings').getString('staff.circ.utils.reservation_slip.print.no'),
3140                             null,
3141                             document.getElementById('circStrings').getString('staff.circ.confirm.msg'),
3142                             '/xul/server/skin/media/images/turtle.gif'
3143                         );
3144                     }
3145                     if (rv == 0) {
3146                         try {
3147                             JSAN.use('util.print'); var print = new util.print();
3148                             msg = msg.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\n/g,'<br/>');
3149                             print.simple( msg , { 'no_prompt' : true, 'content_type' : 'text/html' } );
3150                         } catch(E) {
3151                             var err_msg = document.getElementById('commonStrings').getString('common.error');
3152                             err_msg += '\nFIXME: ' + E + '\n';
3153                             dump(err_msg);
3154                             alert(err_msg);
3155                         }
3156                     }
3157                     msg = '';
3158                     if (no_change_label) {
3159                         var m = no_change_label.getAttribute('value');
3160                         var text = document.getElementById('circStrings').getFormattedString('staff.circ.utils.reservation_capture', [params.barcode]);
3161                         m += text + '  ';
3162                         no_change_label.setAttribute('value', m);
3163                         no_change_label.setAttribute('hidden','false');
3164                         no_change_label.setAttribute('onclick','');
3165                         removeCSSClass(no_change_label,'click_link');
3166                         no_change_label.setAttribute('unique_row_counter','');
3167                         if (typeof params.info_blurb == 'function') {
3168                             params.info_blurb( text );
3169                         }
3170                     }
3171                 break;
3172                 default:
3173                     check.what_happened = 'error';
3174                     msg += document.getElementById('commonStrings').getString('common.error');
3175                     var copy_status = data.hash.ccs[check.copy.status()] ? data.hash.ccs[check.copy.status()].name() : check.copy.status().name();
3176                     msg += '\n';
3177                     var error_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.copy_status.error', [copy_status]);
3178                     print_data.error_msg += error_msg;
3179                     msg += error_msg;
3180                     msg += '\n';
3181                     print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
3182                     msg += print_data.route_to_msg;
3183                 break;
3184             }
3185             if (msg) {
3186                 error.yns_alert(
3187                     msg,
3188                     document.getElementById('circStrings').getString('staff.circ.alert'),
3189                     null,
3190                     document.getElementById('circStrings').getString('staff.circ.utils.msg.ok'),
3191                     null,
3192                     document.getElementById('circStrings').getString('staff.circ.confirm.msg')
3193                 );
3194             }
3195         } else /* ROUTE_ITEM */ if (check.ilsevent == 7000) {
3196
3197             check.what_happened = 'transit';
3198             var lib = data.hash.aou[ check.org ];
3199             check.route_to = lib.shortname();
3200             print_data.route_to = check.route_to;
3201             print_data.route_to_org = lib;
3202             print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.destination', [check.route_to]);
3203             print_data.route_to_org_fullname = lib.name();
3204             var aous_req = network.simple_request('FM_AOUS_SPECIFIC_RETRIEVE',[ lib.id(), 'lib.courier_code' ]);
3205             if (aous_req) {
3206                 print_data.courier_code = aous_req.value || '';
3207             }
3208             msg += print_data.route_to_msg;
3209             msg += '\n\n';
3210             msg += lib.name();
3211             msg += '\n';
3212             try {
3213                 if (lib.holds_address() ) {
3214                     var a = network.simple_request('FM_AOA_RETRIEVE',[ lib.holds_address() ]);
3215                     if (typeof a.ilsevent != 'undefined') throw(a);
3216                     if (a.street1()) { msg += a.street1() + '\n'; print_data.street1 = a.street1(); }
3217                     if (a.street2()) { msg += a.street2() + '\n'; print_data.street2 = a.street2(); }
3218                     print_data.city_state_zip = (a.city() ? a.city() + ', ' : '') + (a.state() ? a.state() + ' ' : '') + (a.post_code() ? a.post_code() : '');
3219                     print_data.city = a.city();
3220                     print_data.state = a.state();
3221                     print_data.county = a.county();
3222                     print_data.country = a.country();
3223                     print_data.post_code = a.post_code();
3224                     msg += print_data.city_state_zip + '\n';
3225                 } else {
3226                     print_data.street1 = document.getElementById('circStrings').getString('staff.circ.utils.route_to.no_address');
3227                     print_data.no_address = true;
3228                     msg += print_data.street1;
3229                     msg += '\n';
3230                 }
3231             } catch(E) {
3232                 var err_msg = document.getElementById('circStrings').getString('staff.circ.utils.route_to.no_address.error');
3233                 print_data.error_msg += err_msg + '\n';
3234                 msg += err_msg + '\n';
3235                 error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.utils.route_to.no_address.error'), E);
3236             }
3237             msg += '\n';
3238             print_data.item_barcode_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [check.payload.copy.barcode()]);
3239             print_data.item_barcode = check.payload.copy.barcode();
3240             msg += print_data.item_barcode_msg;
3241             msg += '\n';
3242             var payload_title  = (check.payload.record ? check.payload.record.title() : check.payload.copy.dummy_title() );
3243             print_data.item_title_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.title', [payload_title]);
3244             print_data.item_title = payload_title;
3245             msg += print_data.item_title_msg;
3246             msg += '\n';
3247             var payload_author = (check.payload.record ? check.payload.record.author() :check.payload.copy.dummy_author());
3248             print_data.item_author_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.author', [payload_author]);
3249             print_data.item_author = payload_author;
3250             msg += print_data.item_author_msg;
3251             msg += '\n';
3252             JSAN.use('util.date');
3253             if (check.payload.hold) {
3254                 check.what_happened = 'transit_for_hold';
3255                 JSAN.use('patron.util');
3256                 var au_obj = patron.util.retrieve_fleshed_au_via_id( session, check.payload.hold.usr() );
3257                 print_data.user = au_obj;
3258                 print_data.user_stat_cat_entries = [];
3259                 var entries = au_obj.stat_cat_entries();
3260                 for (var i = 0; i < entries.length; i++) {
3261                     var stat_cat = data.hash.my_actsc[ entries[i].stat_cat() ];
3262                     if (!stat_cat) {
3263                         stat_cat = data.lookup('actsc', entries[i].stat_cat());
3264                     }
3265                     print_data.user_stat_cat_entries.push( { 
3266                         'id' : entries[i].id(),
3267                         'stat_cat' : {
3268                             'id' : stat_cat.id(),
3269                             'name' : stat_cat.name(),
3270                             'opac_visible' : stat_cat.opac_visible(),
3271                             'owner' : stat_cat.owner(),
3272                             'usr_summary' : stat_cat.usr_summary()
3273                         },
3274                         'stat_cat_entry' : entries[i].stat_cat_entry(),
3275                         'target_usr' : entries[i].target_usr() 
3276                     } );
3277                 }
3278                 msg += '\n';
3279                 if (au_obj.alias()) {
3280                     print_data.hold_for_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.patron_alias',  [au_obj.alias()]);
3281                     print_data.hold_for_alias = au_obj.alias();
3282                     msg += print_data.hold_for_msg;
3283                 } else {
3284                     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() : '']);
3285                     msg += print_data.hold_for_msg;
3286                     print_data.hold_for_family_name = au_obj.family_name() ? au_obj.family_name() : '';
3287                     print_data.hold_for_first_given_name = au_obj.first_given_name() ? au_obj.first_given_name() : '';
3288                     print_data.hold_for_second_given_name = au_obj.second_given_name() ? au_obj.second_given_name() : '';
3289                 }
3290                 msg += '\n';
3291                 print_data.user_barcode_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [au_obj.card().barcode()]);
3292                 print_data.user_barcode = au_obj.card().barcode();
3293                 msg += print_data.user_barcode_msg;
3294                 msg += '\n';
3295                 if (check.payload.hold.phone_notify()) {
3296                     print_data.notify_by_phone_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.phone_notify', [check.payload.hold.phone_notify()]);
3297                     print_data.notify_by_phone = check.payload.hold.phone_notify();
3298                     msg += print_data.notify_by_phone_msg;
3299                     msg += '\n';
3300                 }
3301                 if (get_bool(check.payload.hold.email_notify())) {
3302                     var payload_email = au_obj.email() ? au_obj.email() : '';
3303                     print_data.notify_by_email_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.email_notify', [payload_email]);
3304                     print_data.notify_by_email = payload_email;
3305                     msg += print_data.notify_by_email_msg;
3306                     msg += '\n';
3307                 }
3308                 msg += '\n';
3309                 var notes = check.payload.hold.notes();
3310                 print_data.notes_raw = notes;
3311                 for (var i = 0; i < notes.length; i++) {
3312                     if ( get_bool( notes[i].slip() ) ) {
3313                         var temp_msg;
3314                         if ( get_bool( notes[i].staff() ) ) {
3315                             temp_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.notes.staff_note', [ notes[i].title(), notes[i].body() ]);
3316                         } else {
3317                             temp_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.notes.patron_note', [ notes[i].title(), notes[i].body() ]);
3318                         }
3319                         msg += temp_msg + '\n';
3320                         print_list.push(
3321                             {
3322                                 'formatted_note' : temp_msg,
3323                                 'note_title' : notes[i].title(),
3324                                 'note_body' : notes[i].body(),
3325                                 'note_public' : notes[i].pub(),
3326                                 'note_by_staff' : notes[i].staff()
3327                             }
3328                         );
3329                     }
3330                 }
3331                 msg += '\n';
3332                 msg += '\n';
3333                 print_data.request_date = util.date.formatted_date(check.payload.hold.request_time(),'%F');
3334                 print_data.request_date_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.request_date', [print_data.request_date]);
3335                 msg += print_data.request_date_msg;
3336                 msg += '\n';
3337                 var destination_shelf = document.getElementById('circStrings').getString('staff.circ.route_to.hold_shelf');
3338                 print_data.destination_shelf_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [destination_shelf]);
3339                 print_data.destination_shelf = destination_shelf;
3340                 var behind_the_desk_support = String( data.hash.aous['circ.holds.behind_desk_pickup_supported'] ) == 'true';
3341                 if (behind_the_desk_support) {
3342                    var usr_settings = network.simple_request('FM_AUS_RETRIEVE',[ses(),check.payload.hold.usr()]); 
3343                     if (typeof usr_settings['circ.holds_behind_desk'] != 'undefined') {
3344                         if (usr_settings['circ.holds_behind_desk']) {
3345                             print_data.prefer_behind_holds_desk = true;
3346                             destination_shelf = document.getElementById('circStrings').getString('staff.circ.route_to.private_hold_shelf');
3347                             print_data.destination_shelf_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [destination_shelf]);
3348                             print_data.destination_shelf = destination_shelf;
3349                         } else {
3350                             destination_shelf = document.getElementById('circStrings').getString('staff.circ.route_to.public_hold_shelf');
3351                             print_data.destination_shelf_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [destination_shelf]);
3352                             print_data.destination_shelf = destination_shelf;
3353                         }
3354                     } else {
3355                         destination_shelf = document.getElementById('circStrings').getString('staff.circ.route_to.public_hold_shelf');
3356                         print_data.destination_shelf_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [destination_shelf]);
3357                         print_data.destination_shelf = destination_shelf;
3358                     }
3359                 }
3360             }
3361             var rv = 0;
3362             var suppress_popups = data.hash.aous['ui.circ.suppress_checkin_popups'];
3363             if (suppress_popups) {
3364                 rv = auto_print ? 0 : -1; auto_print = true; // skip dialog and PRINT or DO NOT PRINT based on Auto-Print checkbox
3365             }
3366             var x = data.hash.aous['circ.staff_client.do_not_auto_attempt_print'];
3367             var no_print_prompting = x ? (x.indexOf( check.payload.hold ? "Hold/Transit Slip" : "Transit Slip" ) > -1) : false;
3368             if (no_print_prompting) {
3369                 rv = -1; auto_print = true; // DO NOT PRINT and skip dialog
3370             }
3371             print_data.slip_date = util.date.formatted_date(new Date(),'%F');
3372             print_data.slip_date_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.slip_date', [print_data.slip_date]);
3373             msg += print_data.slip_date_msg;
3374             print_data.payload = check.payload;
3375
3376             if (!auto_print) {
3377                 rv = error.yns_alert_formatted(
3378                     msg,
3379                     document.getElementById('circStrings').getString('staff.circ.utils.transit_slip'),
3380                     document.getElementById('circStrings').getString('staff.circ.utils.transit_slip.print.yes'),
3381                     document.getElementById('circStrings').getString('staff.circ.utils.transit_slip.print.no'),
3382                     null,
3383                     document.getElementById('circStrings').getString('staff.circ.confirm.msg'),
3384                     '/xul/server/skin/media/images/turtle.gif'
3385                 );
3386             } else {
3387                 if (suppress_popups && !no_print_prompting) {
3388                     // FIXME: add SFX and/or GFX
3389                     sound.circ_bad();
3390                 }
3391             }
3392             if (rv == 0) {
3393                 try {
3394                     JSAN.use('util.print'); var print = new util.print();
3395                     var old_template = String( data.hash.aous['ui.circ.old_harcoded_slip_template'] ) == 'true';
3396                     if (old_template) {
3397                         msg = msg.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\n/g,'<br/>');
3398                         print.simple( msg , { 'no_prompt' : true, 'content_type' : 'text/html' } );
3399                     } else {
3400                         var template = check.payload.hold ? 'hold_transit_slip' : 'transit_slip';
3401                         var parms = {
3402                             'patron' : print_data.user,
3403                             'lib' : data.hash.aou[ data.list.au[0].ws_ou() ],
3404                             'staff' : data.list.au[0],
3405                             'header' : data.print_list_templates[ template ].header,
3406                             'line_item' : data.print_list_templates[ template ].line_item,
3407                             'footer' : data.print_list_templates[ template ].footer,
3408                             'type' : data.print_list_templates[ template ].type,
3409                             'list' : print_list,
3410                             'data' : print_data 
3411                         };
3412                         if ($('printer_prompt')) {
3413                             if (! $('printer_prompt').checked) { parms.no_prompt = true; }
3414                         }
3415                         print.tree_list( parms );
3416                     }
3417                 } catch(E) {
3418                     var err_msg = document.getElementById('commonStrings').getString('common.error');
3419                     err_msg += '\nFIXME: ' + E + '\n';
3420                     dump(err_msg);
3421                     alert(err_msg);
3422                 }
3423             }
3424             if (no_change_label) {
3425                 var m = no_change_label.getAttribute('value');
3426                 var trans_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.in_transit', [params.barcode]);
3427                 no_change_label.setAttribute('value', m + trans_msg + '  ');
3428                 no_change_label.setAttribute('hidden','false');
3429                 no_change_label.setAttribute('onclick','');
3430                 removeCSSClass(no_change_label,'click_link');
3431                 no_change_label.setAttribute('unique_row_counter','');
3432                 if (typeof params.info_blurb == 'function') {
3433                     params.info_blurb( trans_msg );
3434                 }
3435             }
3436
3437         } else /* ASSET_COPY_NOT_FOUND */ if (check.ilsevent == 1502) {
3438
3439             check.what_happened = 'not_found';
3440             check.route_to = 'CATALOGING';
3441             var mis_scan_msg = document.getElementById('circStrings').getFormattedString('staff.circ.copy_status.status.copy_not_found', [params.barcode]);
3442             var suppress_popups = data.hash.aous['ui.circ.suppress_checkin_popups'];
3443             if (!suppress_popups) {
3444                 error.yns_alert(
3445                     mis_scan_msg,
3446                     document.getElementById('circStrings').getString('staff.circ.alert'),
3447                     null,
3448                     document.getElementById('circStrings').getString('staff.circ.utils.msg.ok'),
3449                     null,
3450                     document.getElementById('circStrings').getString('staff.circ.confirm.msg')
3451                 );
3452             } else {
3453                 // FIXME: add SFX and/or GFX
3454                 sound.circ_bad();
3455             }
3456             if (no_change_label) {
3457                 var m = no_change_label.getAttribute('value');
3458                 no_change_label.setAttribute('value',m + mis_scan_msg + '  ');
3459                 no_change_label.setAttribute('hidden','false');
3460                 no_change_label.setAttribute('onclick','');
3461                 removeCSSClass(no_change_label,'click_link');
3462                 no_change_label.setAttribute('unique_row_counter','');
3463                 if (typeof params.info_blurb == 'function') {
3464                     params.info_blurb( mis_scan_msg );
3465                 }
3466             }
3467
3468         } else /* HOLD_CAPTURE_DELAYED */ if (check.ilsevent == 7019) {
3469
3470             check.what_happened = 'hold_capture_delayed';
3471             var rv = 0;
3472             msg += document.getElementById('circStrings').getString('staff.circ.utils.hold_capture_delayed.description');
3473             var suppress_popups = data.hash.aous['ui.circ.suppress_checkin_popupst'];
3474             if (!suppress_popups) {
3475                 rv = error.yns_alert_formatted(
3476                     msg,
3477                     document.getElementById('circStrings').getString('staff.circ.utils.hold_capture_delayed.titlebar'),
3478                     document.getElementById('circStrings').getString('staff.circ.utils.hold_capture_delayed.prompt_for_nocapture'),
3479                     document.getElementById('circStrings').getString('staff.circ.utils.hold_capture_delayed.prompt_for_capture'),
3480                     null,
3481                     document.getElementById('circStrings').getString('staff.circ.confirm.msg'),
3482                     '/xul/server/skin/media/images/stop_sign.png'
3483                 );
3484             } else {
3485                 // FIXME: add SFX and/or GFX
3486                 sound.circ_bad();
3487             }
3488             params.capture = rv == 0 ? 'nocapture' : 'capture';
3489
3490             return circ.util.checkin_via_barcode(session,params,backdate,auto_print,false);
3491
3492         } else /* NETWORK TIMEOUT */ if (check.ilsevent == -1) {
3493             check.what_happened = 'error';
3494             error.standard_network_error_alert(document.getElementById('circStrings').getString('staff.circ.checkin.suggest_offline'));
3495         } else {
3496
3497             if (check.ilsevent == null) { return null; /* handled */ }
3498             switch (Number(check.ilsevent)) {
3499                 case 1203 /* COPY_BAD_STATUS */ :
3500                 case 1213 /* PATRON_BARRED */ :
3501                 case 1217 /* PATRON_INACTIVE */ :
3502                 case 1224 /* PATRON_ACCOUNT_EXPIRED */ :
3503                 case 1234 /* ITEM_DEPOSIT_PAID */ :
3504                 case 7009 /* CIRC_CLAIMS_RETURNED */ :
3505                 case 7010 /* COPY_ALERT_MESSAGE */ :
3506                 case 7011 /* COPY_STATUS_LOST */ :
3507                 case 7012 /* COPY_STATUS_MISSING */ :
3508                 case 7013 /* PATRON_EXCEEDS_FINES */ :
3509                     return null; /* handled */
3510                 break;
3511             }
3512
3513             throw(check);
3514
3515         }
3516
3517         return check;
3518     } catch(E) {
3519         JSAN.use('util.error'); var error = new util.error();
3520         error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.error', ['3']), E);
3521         return null;
3522     }
3523 };
3524
3525 circ.util.renew_via_barcode = function ( params, async ) {
3526     try {
3527         var obj = {};
3528         JSAN.use('util.network'); obj.network = new util.network();
3529         JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.stash_retrieve();
3530
3531         function renew_callback(req) {
3532             try {
3533                 JSAN.use('util.error'); var error = new util.error();
3534                 var renew = req.getResultObject();
3535                 if (typeof renew.ilsevent != 'undefined') renew = [ renew ];
3536                 for (var j = 0; j < renew.length; j++) {
3537                     switch(renew[j].ilsevent == null ? null : Number(renew[j].ilsevent)) {
3538                         case 0 /* SUCCESS */ : break;
3539                         case null /* custom event */ : break;
3540                         case 5000 /* PERM_FAILURE */: break;
3541                         case 1212 /* PATRON_EXCEEDS_OVERDUE_COUNT */ : break;
3542                         case 1213 /* PATRON_BARRED */ : break;
3543                         case 1215 /* CIRC_EXCEEDS_COPY_RANGE */ : break;
3544                         case 1224 /* PATRON_ACCOUNT_EXPIRED */ : break;
3545                         case 1232 /* ITEM_DEPOSIT_REQUIRED */ : break;
3546                         case 1233 /* ITEM_RENTAL_FEE_REQUIRED */ : break;
3547                         case 1234 /* ITEM_DEPOSIT_PAID */ : break;
3548                         case 1500 /* ACTION_CIRCULATION_NOT_FOUND */ : break;
3549                         case 1502 /* ASSET_COPY_NOT_FOUND */ : 
3550                             var mis_scan_msg = document.getElementById('circStrings').getFormattedString('staff.circ.copy_status.status.copy_not_found', [params.barcode]);
3551                             error.yns_alert(
3552                                 mis_scan_msg,
3553                                 document.getElementById('circStrings').getString('staff.circ.alert'),
3554                                 null,
3555                                 document.getElementById('circStrings').getString('staff.circ.utils.msg.ok'),
3556                                 null,
3557                                 document.getElementById('circStrings').getString('staff.circ.confirm.msg')
3558                             );
3559                             if (no_change_label) {
3560                                 var m = no_change_label.getAttribute('value');
3561                                 no_change_label.setAttribute('value',m + mis_scan_msg + '  ');
3562                                 no_change_label.setAttribute('hidden','false');
3563                                 no_change_label.setAttribute('onclick','');
3564                                 removeCSSClass(no_change_label,'click_link');
3565                                 no_change_label.setAttribute('unique_row_counter','');
3566                                 if (typeof params.info_blurb == 'function') {
3567                                     params.info_blurb( mis_scan_msg );
3568                                 }
3569                             }
3570                         break;
3571                         case 7002 /* PATRON_EXCEEDS_CHECKOUT_COUNT */ : break;
3572                         case 7003 /* COPY_CIRC_NOT_ALLOWED */ : break;
3573                         case 7004 /* COPY_NOT_AVAILABLE */ : break;
3574                         case 7006 /* COPY_IS_REFERENCE */ : break;
3575                         case 7007 /* COPY_NEEDED_FOR_HOLD */ : break;
3576                         case 7008 /* MAX_RENEWALS_REACHED */ : break;
3577                         case 7009 /* CIRC_CLAIMS_RETURNED */ : break;
3578                         case 7010 /* COPY_ALERT_MESSAGE */ : break;
3579                         case 7013 /* PATRON_EXCEEDS_FINES */ : break;
3580                         default:
3581                             throw(renew);
3582                         break;
3583                     }
3584                 }
3585                 try {
3586                     var ibarcode = renew[0].payload.copy ? renew[0].payload.copy.barcode() : params.barcode;
3587                     var p_id = renew[0].payload.patron ? renew[0].payload.patron.id() : renew[0].payload.circ.usr();
3588                     var pname; var pbarcode; 
3589                     if (renew[0].patron) {
3590                         pname = renew[0].payload.patron.family_name();
3591                         pbarcode = typeof renew[0].payload.patron.card() == 'object' ? renew[0].payload.patron.card().barcode() : null;
3592                     } else {
3593                         if (circ.util.renew_via_barcode.last_usr_id == p_id) {
3594                             pname = circ.util.renew_via_barcode.last_pname;
3595                             pbarcode = circ.util.renew_via_barcode.last_pbarcode;
3596                         } else {
3597                             JSAN.use('patron.util'); var p = patron.util.retrieve_fleshed_au_via_id(ses(),p_id);
3598                             pname = p.family_name();
3599                             pbarcode = typeof p.card() == 'object' ? p.card().barcode() : null;
3600                             if (pname) {
3601                                 circ.util.renew_via_barcode.last_usr_id = p_id;
3602                                 circ.util.renew_via_barcode.last_pname = pname;
3603                                 circ.util.renew_via_barcode.last_pbarcode = pbarcode;
3604                             }
3605                         } 
3606                     }
3607                     error.work_log(
3608                         document.getElementById('circStrings').getFormattedString(
3609                             'staff.circ.work_log_renew.message',
3610                             [
3611                                 ses('staff_usrname'),
3612                                 pname ? pname : '???',
3613                                 pbarcode ? pbarcode : '???',
3614                                 ibarcode ? ibarcode : '???'
3615                             ]
3616                         ), {
3617                             'au_id' : p_id,
3618                             'au_family_name' : pname,
3619                             'au_barcode' : pbarcode,
3620                             'acp_barcode' : ibarcode
3621                         }
3622                     );
3623                 } catch(E) {
3624                     error.sdump('D_ERROR','Error with work_logging in server/circ/util.js, renew_via_barcode():' + E);
3625                 }
3626                 if (typeof async == 'function') async(renew);
3627                 return renew;
3628             } catch(E) {
3629                 JSAN.use('util.error'); var error = new util.error();
3630                 error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.renew_failed.error', [params.barcode]), E);
3631                 return null;
3632             }
3633         }
3634
3635         var renew = obj.network.simple_request(
3636             'CHECKOUT_RENEW',
3637             [ ses(), params ],
3638             async ? renew_callback : null,
3639             {
3640                 'title' : document.getElementById('circStrings').getString('staff.circ.checkin.renew_failed.override'),
3641                 'overridable_events' : [
3642                     null /* custom event */,
3643                     1212 /* PATRON_EXCEEDS_OVERDUE_COUNT */,
3644                     1213 /* PATRON_BARRED */,
3645                     1215 /* CIRC_EXCEEDS_COPY_RANGE */,
3646                     1232 /* ITEM_DEPOSIT_REQUIRED */,
3647                     1233 /* ITEM_RENTAL_FEE_REQUIRED */,
3648                     1234 /* ITEM_DEPOSIT_PAID */,
3649                     7002 /* PATRON_EXCEEDS_CHECKOUT_COUNT */,
3650                     7003 /* COPY_CIRC_NOT_ALLOWED */,
3651                     7004 /* COPY_NOT_AVAILABLE */,
3652                     7006 /* COPY_IS_REFERENCE */,
3653                     7007 /* COPY_NEEDED_FOR_HOLD */,
3654                     7008 /* MAX_RENEWALS_REACHED */,
3655                     7009 /* CIRC_CLAIMS_RETURNED */,
3656                     7010 /* COPY_ALERT_MESSAGE */,
3657                     7013 /* PATRON_EXCEEDS_FINES */,
3658                 ],
3659                 'text' : {
3660                     '1212' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
3661                     '1213' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
3662                     '1215' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
3663                     '1232' : function(r) {
3664                         return document.getElementById('circStrings').getFormattedString('staff.circ.renew.override.item_deposit_required.warning.barcode', [params.barcode]);
3665                     },
3666                     '1233' : function(r) {
3667                         return document.getElementById('circStrings').getFormattedString('staff.circ.renew.override.item_rental_fee_required.warning.barcode', [params.barcode]);
3668                     },
3669                     '1234' : function(r) {
3670                         return document.getElementById('circStrings').getFormattedString('staff.circ.utils.checkin.override.item_deposit_paid.warning');
3671                     },
3672                     '7002' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
3673                     '7003' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
3674                     '7004' : function(r) {
3675                         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()]);
3676                     },
3677                     '7006' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
3678                     '7007' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
3679                     '7008' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
3680                     '7009' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
3681                     '7010' : function(r) {
3682                         return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode.msg', [params.barcode, r.payload]);
3683                     },
3684                     '7013' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); }
3685                 }
3686             }
3687         );
3688         if (! async ) {
3689             return renew_callback( { 'getResultObject' : function() { return renew; } } );
3690         }
3691
3692     } catch(E) {
3693         JSAN.use('util.error'); var error = new util.error();
3694         error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.renew_failed.error', [params.barcode]), E);
3695         return null;
3696     }
3697 };
3698
3699 circ.util.batch_hold_update = function ( hold_ids, field_changes, params ) {
3700     try {
3701         JSAN.use('util.sound'); var sound = new util.sound();
3702         var change_list = []; var idx = -1; var bad_holds = [];
3703         dojo.forEach(
3704             hold_ids,
3705             function(el) {
3706                 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?
3707             }
3708         );
3709         if (params.progressmeter) { params.progressmeter.value = 0; params.progressmeter.hidden = false; }
3710         fieldmapper.standardRequest(
3711             [ api.FM_AHR_UPDATE_BATCH.app, api.FM_AHR_UPDATE_BATCH.method ],
3712             {   async: true,
3713                 params: [ses(), null, change_list],
3714                 onresponse: function(r) {
3715                     idx++; 
3716                     if (params.progressmeter) { params.progressmeter.value = Number( params.progressmeter.value ) + 100/hold_ids.length; }
3717                     var result = r.recv().content();
3718                     if (result != hold_ids[ idx ]) {
3719                         bad_holds.push( { 'hold_id' : hold_ids[ idx ], 'result' : result } );
3720                     }
3721                 },
3722                 oncomplete: function() {
3723                     if (bad_holds.length > 0) {
3724                         sound.circ_bad();
3725                         alert( $('circStrings').getFormattedString('staff.circ.hold_update.hold_ids.failed',[ bad_holds.length ]) );
3726                     } else {
3727                         sound.circ_good();
3728                     }
3729                     if (typeof params.oncomplete == 'function') {
3730                         params.oncomplete( bad_holds );
3731                     }
3732                     if (params.progressmeter) { params.progressmeter.value = 0; params.progressmeter.hidden = true; }
3733                 },
3734                 onerror: function(r) {
3735                     alert('Error in circ/util.js, batch_hold_update(), onerror: ' + r);
3736                 }
3737             }
3738         );
3739     } catch(E) {
3740         alert('Error in circ.util.js, circ.util.batch_hold_update(): ' + E);
3741     }
3742 };
3743
3744 circ.util.find_acq_po = function(session, copy_id) {
3745     dojo.require("openils.Util");
3746     fieldmapper.standardRequest(
3747         ["open-ils.acq", "open-ils.acq.lineitem.retrieve.by_copy_id.authoritative"], {
3748             "params": [session, copy_id, {"clear_marc": true}],
3749             "onresponse": function(r) {
3750                 if (r = openils.Util.readResponse(r)) {
3751                     if (r.purchase_order()) {
3752                         var url = urls.XUL_BROWSER + "?url=" +
3753                             xulG.url_prefix(
3754                                 escape(urls.EG_ACQ_PO_VIEW +
3755                                     "/" + r.purchase_order() + "/" + r.id())
3756                             );
3757                         window.xulG.new_tab(
3758                             url, {"browser": true}, {
3759                                 "no_xulG": false,
3760                                 "show_print_button": false,
3761                                 "show_nav_buttons": true
3762                             }
3763                         );
3764                     } else {
3765                         /* unlikely: got an LI with no PO */
3766                         alert(dojo.byId("circStrings").getFormattedString(
3767                             "staff.circ.utils.find_acq_po.no_po", [r.id()]
3768                         ));
3769                     }
3770                 }
3771             }
3772         }
3773     );
3774 };
3775
3776 dump('exiting circ/util.js\n');