]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/xul/staff_client/server/circ/util.js
Wrap interface results from "find originating purchase order" in browser
[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) {
575                 if (my.acp && my.acp.call_number() == -1) {
576                     return document.getElementById('circStrings').getString('staff.circ.utils.not_cataloged');
577                 } else if (my.acp && my.acp.call_number() == -2) {
578                     return document.getElementById('circStrings').getString('staff.circ.utils.retrieving');
579                 } else {
580                     if (!my.acn) {
581                         var x = network.simple_request("FM_ACN_RETRIEVE.authoritative",[ my.acp.call_number() ]);
582                         if (x.ilsevent) {
583                             return document.getElementById('circStrings').getString('staff.circ.utils.not_cataloged');
584                         } else {
585                             my.acn = x; return x.label();
586                         }
587                     } else {
588                         return my.acn.label();
589                     }
590                 }
591             },
592             'persist' : 'hidden width ordinal'
593         },
594         {
595             'id' : 'owning_lib',
596             'fm_class' : 'acn',
597             'label' : document.getElementById('circStrings').getString('staff.circ.utils.owning_lib'),
598             'flex' : 1,
599             'primary' : false,
600             'hidden' : true,
601             'editable' : false, 'render' : function(my) {
602                 if (Number(my.acn.owning_lib())>=0) {
603                     return data.hash.aou[ my.acn.owning_lib() ].shortname();
604                 } else {
605                     return my.acn.owning_lib().shortname();
606                 }
607             },
608             'persist' : 'hidden width ordinal'
609         },
610         {
611             'id' : 'copy_number',
612             'fm_class' : 'acp',
613             'label' : document.getElementById('commonStrings').getString('staff.acp_label_copy_number'),
614             'flex' : 1,
615             'sort_type' : 'number',
616             'primary' : false,
617             'hidden' : true,
618             'editable' : false, 'render' : function(my) { return my.acp.copy_number(); },
619             'persist' : 'hidden width ordinal'
620         },
621         {
622             'id' : 'location',
623             'fm_class' : 'acp',
624             'label' : document.getElementById('commonStrings').getString('staff.acp_label_location'),
625             'flex' : 1,
626             'primary' : false,
627             'hidden' : true,
628             'editable' : false, 'render' : function(my) {
629                 if (Number(my.acp.location())>=0) {
630                     return data.lookup("acpl", my.acp.location() ).name();
631                 } else {
632                     return my.acp.location().name();
633                 }
634             },
635             'persist' : 'hidden width ordinal'
636         },
637         {
638             'id' : 'loan_duration',
639             'fm_class' : 'acp',
640             'label' : document.getElementById('commonStrings').getString('staff.acp_label_loan_duration'),
641             'flex' : 1,
642             'primary' : false,
643             'hidden' : true,
644             'editable' : false, 'render' : function(my) {
645                 switch(Number(my.acp.loan_duration())) {
646                     case 1:
647                         return document.getElementById('circStrings').getString('staff.circ.utils.loan_duration.short');
648                         break;
649                     case 2:
650                         return document.getElementById('circStrings').getString('staff.circ.utils.loan_duration.normal');
651                         break;
652                     case 3:
653                         return document.getElementById('circStrings').getString('staff.circ.utils.loan_duration.long');
654                         break;
655                 };
656             },
657             'persist' : 'hidden width ordinal'
658         },
659         {
660             'id' : 'circ_lib',
661             'fm_class' : 'acp',
662             'label' : document.getElementById('commonStrings').getString('staff.acp_label_circ_lib'),
663             'flex' : 1,
664             'primary' : false,
665             'hidden' : true,
666             'editable' : false, 'render' : function(my) {
667                 if (Number(my.acp.circ_lib())>=0) {
668                     return data.hash.aou[ my.acp.circ_lib() ].shortname();
669                 } else {
670                     return my.acp.circ_lib().shortname();
671                 }
672             },
673             'persist' : 'hidden width ordinal'
674         },
675         {
676             'id' : 'fine_level',
677             'fm_class' : 'acp',
678             'label' : document.getElementById('commonStrings').getString('staff.acp_label_fine_level'),
679             'flex' : 1,
680             'primary' : false,
681             'hidden' : true,
682             'editable' : false, 'render' : function(my) {
683                 switch(Number(my.acp.fine_level())) {
684                     case 1:
685                         return document.getElementById('circStrings').getString('staff.circ.utils.fine_level.low');
686                         break;
687                     case 2:
688                         return document.getElementById('circStrings').getString('staff.circ.utils.fine_level.normal');
689                         break;
690                     case 3:
691                         return document.getElementById('circStrings').getString('staff.circ.utils.fine_level.high');
692                         break;
693                 };
694             },
695             'persist' : 'hidden width ordinal'
696         },
697         {
698             'id' : 'circulate',
699             'fm_class' : 'acp',
700             'label' : document.getElementById('circStrings').getString('staff.circ.utils.circulate'),
701             'flex' : 1,
702             'primary' : false,
703             'hidden' : true,
704             'editable' : false, 'render' : function(my) {
705                 if (get_bool( my.acp.circulate() )) {
706                     return document.getElementById('circStrings').getString('staff.circ.utils.yes');
707                 } else {
708                     return document.getElementById('circStrings').getString('staff.circ.utils.no');
709                 }
710             },
711             'persist' : 'hidden width ordinal'
712         },
713         {
714             'id' : 'deleted',
715             'fm_class' : 'acp',
716             'label' : document.getElementById('circStrings').getString('staff.circ.utils.deleted'),
717             'flex' : 1,
718             'primary' : false,
719             'hidden' : true,
720             'editable' : false, 'render' : function(my) {
721                 if (get_bool( my.acp.deleted() )) {
722                     return document.getElementById('circStrings').getString('staff.circ.utils.yes');
723                 } else {
724                     return document.getElementById('circStrings').getString('staff.circ.utils.no');
725                 }
726             },
727             'persist' : 'hidden width ordinal'
728         },
729         {
730             'id' : 'holdable',
731             'fm_class' : 'acp',
732             'label' : document.getElementById('circStrings').getString('staff.circ.utils.holdable'),
733             'flex' : 1,
734             'primary' : false,
735             'hidden' : true,
736             'editable' : false, 'render' : function(my) {
737                 if (get_bool( my.acp.holdable() )) {
738                     return document.getElementById('circStrings').getString('staff.circ.utils.yes');
739                 } else {
740                     return document.getElementById('circStrings').getString('staff.circ.utils.no');
741                 }
742             },
743             'persist' : 'hidden width ordinal'
744         },
745         {
746             'id' : 'floating',
747             'fm_class' : 'acp',
748             'label' : document.getElementById('circStrings').getString('staff.circ.utils.floating'),
749             'flex' : 1,
750             'primary' : false,
751             'hidden' : true,
752             'editable' : false, 'render' : function(my) {
753                 if (get_bool( my.acp.floating() )) {
754                     return document.getElementById('circStrings').getString('staff.circ.utils.yes');
755                 } else {
756                     return document.getElementById('circStrings').getString('staff.circ.utils.no');
757                 }
758             },
759             'persist' : 'hidden width ordinal'
760         },
761
762         {
763             'id' : 'opac_visible',
764             'fm_class' : 'acp',
765             'label' : document.getElementById('circStrings').getString('staff.circ.utils.opac_visible'),
766             'flex' : 1,
767             'primary' : false,
768             'hidden' : true,
769             'editable' : false, 'render' : function(my) {
770                 if (get_bool( my.acp.opac_visible() )) {
771                     return document.getElementById('circStrings').getString('staff.circ.utils.yes');
772                 } else {
773                     return document.getElementById('circStrings').getString('staff.circ.utils.no');
774                 }
775             },
776             'persist' : 'hidden width ordinal'
777         },
778         {
779             'persist' : 'hidden width ordinal',
780             'id' : 'acp_mint_condition',
781             'fm_class' : 'acp',
782             'label' : document.getElementById('circStrings').getString('staff.circ.utils.acp_mint_condition'),
783             'flex' : 0,
784             'primary' : false,
785             'hidden' : true,
786             'editable' : false, 'render' : function(my) {
787                 if (get_bool( my.acp.mint_condition() )) {
788                     return document.getElementById('circStrings').getString('staff.circ.utils.acp_mint_condition.true');
789                 } else {
790                     return document.getElementById('circStrings').getString('staff.circ.utils.acp_mint_condition.false');
791                 }
792             }
793         },
794         {
795             'persist' : 'hidden width ordinal',
796             'fm_class' : 'acp',
797             'id' : 'ref',
798             'label' : document.getElementById('circStrings').getString('staff.circ.utils.reference'),
799             'flex' : 1,
800             'primary' : false,
801             'hidden' : true,
802             'editable' : false, 'render' : function(my) {
803                 if (get_bool( my.acp.ref() )) {
804                     return document.getElementById('circStrings').getString('staff.circ.utils.yes');
805                 } else {
806                     return document.getElementById('circStrings').getString('staff.circ.utils.no');
807                 }
808             }
809         },
810         {
811             'persist' : 'hidden width ordinal',
812             'fm_class' : 'acp',
813             'id' : 'deposit',
814             'label' : document.getElementById('circStrings').getString('staff.circ.utils.deposit'),
815             'flex' : 1,
816             'primary' : false,
817             'hidden' : true,
818             'editable' : false, 'render' : function(my) {
819                 if (get_bool( my.acp.deposit() )) {
820                     return document.getElementById('circStrings').getString('staff.circ.utils.yes');
821                 } else {
822                     return document.getElementById('circStrings').getString('staff.circ.utils.no');
823                 }
824             }
825         },
826         {
827             'persist' : 'hidden width ordinal',
828             'fm_class' : 'acp',
829             'id' : 'deposit_amount',
830             'label' : document.getElementById('commonStrings').getString('staff.acp_label_deposit_amount'),
831             'flex' : 1,
832             'primary' : false,
833             'hidden' : true,
834             'editable' : false, 'render' : function(my) {
835                 if (my.acp.price() == null) {
836                     return document.getElementById('circStrings').getString('staff.circ.utils.unset');
837                 } else {
838                     return util.money.sanitize(my.acp.deposit_amount());
839                 }
840             },
841             'sort_type' : 'money'
842         },
843         {
844             'persist' : 'hidden width ordinal',
845             'fm_class' : 'acp',
846             'id' : 'price',
847             'label' : document.getElementById('commonStrings').getString('staff.acp_label_price'),
848             'flex' : 1,
849             'primary' : false,
850             'hidden' : true,
851             'editable' : false, 'render' : function(my) {
852                 if (my.acp.price() == null) {
853                     return document.getElementById('circStrings').getString('staff.circ.utils.unset');
854                 } else {
855                     return util.money.sanitize(my.acp.price());
856                 }
857             },
858             'sort_type' : 'money'
859         },
860         {
861             'persist' : 'hidden width ordinal',
862             'fm_class' : 'acp',
863             'id' : 'circ_as_type',
864             'label' : document.getElementById('commonStrings').getString('staff.acp_label_circ_as_type'),
865             'flex' : 1,
866             'primary' : false,
867             'hidden' : true,
868             'editable' : false, 'render' : function(my) { return my.acp.circ_as_type(); }
869         },
870         {
871             'persist' : 'hidden width ordinal',
872             'fm_class' : 'acp',
873             'id' : 'circ_modifier',
874             'label' : document.getElementById('commonStrings').getString('staff.acp_label_circ_modifier'),
875             'flex' : 1,
876             'primary' : false,
877             'hidden' : true,
878             'editable' : false, 'render' : function(my) { return my.acp.circ_modifier(); }
879         },
880         {
881             'id' : 'status_changed_time',
882             'fm_class' : 'acp',
883             'label' : document.getElementById('circStrings').getString('staff.circ.utils.status_changed_time'),
884             'flex' : 1,
885             'primary' : false,
886             'hidden' : true,
887             'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.acp.status_changed_time(), '%{localized}' ); },
888             'persist' : 'hidden width ordinal'
889         },
890         {
891             'persist' : 'hidden width ordinal',
892             'fm_class' : 'circ',
893             'id' : 'checkout_lib',
894             'label' : document.getElementById('circStrings').getString('staff.circ.utils.checkout_lib'),
895             'flex' : 1,
896             'primary' : false,
897             'hidden' : true,
898             'editable' : false, 'render' : function(my) {
899                 if (my.circ) {
900                     return data.hash.aou[ my.circ.circ_lib() ].shortname();
901                 } else {
902                     return "";
903                 }
904             }
905         },
906         {
907             'persist' : 'hidden width ordinal',
908             'fm_class' : 'circ',
909             'id' : 'xact_start',
910             'label' : document.getElementById('circStrings').getString('staff.circ.utils.xact_start'),
911             'flex' : 1,
912             'primary' : false,
913             'hidden' : true,
914             'editable' : false, 'render' : function(my) {
915                 if (my.circ) {
916                     return util.date.formatted_date( my.circ.xact_start(), '%{localized}' );
917                 } else {
918                     return "";
919                 }
920             }
921         },
922         {
923             'persist' : 'hidden width ordinal',
924             'fm_class' : 'circ',
925             'id' : 'checkin_time',
926             'label' : document.getElementById('circStrings').getString('staff.circ.utils.checkin_time'),
927             'flex' : 1,
928             'primary' : false,
929             'hidden' : true,
930             'editable' : false, 'render' : function(my) {
931                 if (my.circ) {
932                     return util.date.formatted_date( my.circ.checkin_time(), '%{localized}' );
933                 } else {
934                     return "";
935                 }
936             }
937         },
938         {
939             'persist' : 'hidden width ordinal',
940             'fm_class' : 'circ',
941             'id' : 'xact_finish',
942             'label' : document.getElementById('circStrings').getString('staff.circ.utils.xact_finish'),
943             'flex' : 1,
944             'primary' : false,
945             'hidden' : true,
946             'editable' : false, 'render' : function(my) { return my.circ ? util.date.formatted_date( my.circ.xact_finish(), '%{localized}' ) : ""; },
947         },
948         {
949             'persist' : 'hidden width ordinal',
950             'fm_class' : 'circ',
951             'id' : 'due_date',
952             'label' : document.getElementById('commonStrings').getString('staff.circ_label_due_date'),
953             'flex' : 1,
954             'primary' : false,
955             'hidden' : true,
956             'editable' : false, 'render' : function(my) {
957                 if (my.circ) {
958                     return util.date.formatted_date( my.circ.due_date(), '%{localized}' );
959                 } else {
960                     return "";
961                 }
962             }
963         },
964         {
965             'persist' : 'hidden width ordinal',
966             'fm_class' : 'acp',
967             'id' : 'create_date',
968             'label' : document.getElementById('circStrings').getString('staff.circ.utils.create_date'),
969             'flex' : 1,
970             'primary' : false,
971             'hidden' : true,
972             'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.acp.create_date(), '%{localized}' ); }
973         },
974         {
975             'persist' : 'hidden width ordinal',
976             'fm_class' : 'acp',
977             'id' : 'edit_date',
978             'label' : document.getElementById('circStrings').getString('staff.circ.utils.edit_date'),
979             'flex' : 1,
980             'primary' : false,
981             'hidden' : true,
982             'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.acp.edit_date(), '%{localized}' ); }
983         },
984         {
985             'persist' : 'hidden width ordinal',
986             'fm_class' : 'mvr',
987             'id' : 'title',
988             'label' : document.getElementById('commonStrings').getString('staff.mvr_label_title'),
989             'flex' : 2,
990             'sort_type' : 'title',
991             'primary' : false,
992             'hidden' : true,
993             'editable' : false, 'render' : function(my) {
994                 try {  return my.mvr.title(); }
995                 catch(E) { return my.acp.dummy_title(); }
996             }
997         },
998         {
999             'persist' : 'hidden width ordinal',
1000             'fm_class' : 'mvr',
1001             'id' : 'author',
1002             'label' : document.getElementById('commonStrings').getString('staff.mvr_label_author'),
1003             'flex' : 1,
1004             'primary' : false,
1005             'hidden' : true,
1006             'editable' : false, 'render' : function(my) {
1007                 try { return my.mvr.author(); }
1008                 catch(E) { return my.acp.dummy_author(); }
1009             }
1010         },
1011         {
1012             'persist' : 'hidden width ordinal',
1013             'fm_class' : 'mvr',
1014             'id' : 'edition',
1015             'label' : document.getElementById('circStrings').getString('staff.circ.utils.edition'),
1016             'flex' : 1,
1017             'primary' : false,
1018             'hidden' : true,
1019             'editable' : false, 'render' : function(my) { return my.mvr.edition(); }
1020         },
1021         {
1022             'persist' : 'hidden width ordinal',
1023             'fm_class' : 'mvr',
1024             'id' : 'isbn',
1025             'label' : document.getElementById('circStrings').getString('staff.circ.utils.isbn'),
1026             'flex' : 1,
1027             'primary' : false,
1028             'hidden' : true,
1029             'editable' : false, 'render' : function(my) { 
1030                 try { return my.mvr.isbn(); }
1031                 catch(E) { return my.acp.dummy_isbn(); }
1032             }
1033         },
1034         {
1035             'persist' : 'hidden width ordinal',
1036             'fm_class' : 'mvr',
1037             'id' : 'pubdate',
1038             'label' : document.getElementById('circStrings').getString('staff.circ.utils.pubdate'),
1039             'flex' : 1,
1040             'primary' : false,
1041             'hidden' : true,
1042             'editable' : false, 'render' : function(my) { return my.mvr.pubdate(); }
1043         },
1044         {
1045             'persist' : 'hidden width ordinal',
1046             'fm_class' : 'mvr',
1047             'id' : 'publisher',
1048             'label' : document.getElementById('circStrings').getString('staff.circ.utils.publisher'),
1049             'flex' : 1,
1050             'primary' : false,
1051             'hidden' : true,
1052             'editable' : false, 'render' : function(my) { return my.mvr.publisher(); }
1053         },
1054         {
1055             'persist' : 'hidden width ordinal',
1056             'fm_class' : 'mvr',
1057             'id' : 'tcn',
1058             'label' : document.getElementById('circStrings').getString('staff.circ.utils.tcn'),
1059             'flex' : 1,
1060             'primary' : false,
1061             'hidden' : true,
1062             'editable' : false, 'render' : function(my) { return my.mvr.tcn(); }
1063         },
1064         {
1065             'persist' : 'hidden width ordinal',
1066             'fm_class' : 'circ',
1067             'id' : 'renewal_remaining',
1068             'label' : document.getElementById('commonStrings').getString('staff.circ_label_renewal_remaining'),
1069             'flex' : 0,
1070             'primary' : false,
1071             'hidden' : true,
1072             'editable' : false, 'render' : function(my) {
1073                 if (my.circ) {
1074                     return my.circ.renewal_remaining();
1075                 } else {
1076                     return "";
1077                 }
1078             },
1079             'sort_type' : 'number'
1080         },
1081         {
1082             'persist' : 'hidden width ordinal',
1083             'fm_class' : 'circ',
1084             'id' : 'stop_fines',
1085             'label' : document.getElementById('circStrings').getString('staff.circ.utils.stop_fines'),
1086             'flex' : 0,
1087             'primary' : false,
1088             'hidden' : true,
1089             'editable' : false, 'render' : function(my) {
1090                 if (my.circ) {
1091                     return my.circ.stop_fines();
1092                 } else {
1093                     return "";
1094                 }
1095             }
1096         },
1097         {
1098             'persist' : 'hidden width ordinal',
1099             'fm_class' : 'circ',
1100             'id' : 'stop_fines_time',
1101             'label' : document.getElementById('circStrings').getString('staff.circ.utils.stop_fines_time'),
1102             'flex' : 0,
1103             'primary' : false,
1104             'hidden' : true,
1105             'editable' : false, 'render' : function(my) {
1106                 if (my.circ) {
1107                     return util.date.formatted_date( my.circ.stop_fines_time(), '%{localized}' );
1108                 } else {
1109                     return "";
1110                 }
1111             }
1112         },
1113         {
1114             'persist' : 'hidden width ordinal',
1115             'fm_class' : 'acp',
1116             'id' : 'acp_status',
1117             'label' : document.getElementById('commonStrings').getString('staff.acp_label_status'),
1118             'flex' : 1,
1119             'primary' : false,
1120             'hidden' : true,
1121             'editable' : false, 'render' : function(my) {
1122                 if (Number(my.acp.status())>=0) {
1123                     return data.hash.ccs[ my.acp.status() ].name();
1124                 } else {
1125                     return my.acp.status().name();
1126                 }
1127             }
1128         },
1129         {
1130             'persist' : 'hidden width ordinal',
1131             'id' : 'route_to',
1132             'label' : document.getElementById('circStrings').getString('staff.circ.utils.route_to'),
1133             'flex' : 1,
1134             'primary' : false,
1135             'hidden' : true,
1136             'editable' : false, 'render' : function(my) { return my.route_to.toString(); }
1137         },
1138         {
1139             'persist' : 'hidden width ordinal',
1140             'id' : 'message',
1141             'label' : document.getElementById('circStrings').getString('staff.circ.utils.message'),
1142             'flex' : 1,
1143             'primary' : false,
1144             'hidden' : true,
1145             'editable' : false, 'render' : function(my) { return my.message.toString(); }
1146         },
1147         {
1148             'persist' : 'hidden width ordinal',
1149             'id' : 'uses',
1150             'label' : document.getElementById('circStrings').getString('staff.circ.utils.uses'),
1151             'flex' : 1,
1152             'primary' : false,
1153             'hidden' : true,
1154             'editable' : false, 'render' : function(my) { return my.uses; },
1155             'sort_type' : 'number'
1156         },
1157         {
1158             'persist' : 'hidden width ordinal',
1159             'fm_class' : 'acp',
1160             'id' : 'alert_message',
1161             'label' : document.getElementById('circStrings').getString('staff.circ.utils.alert_message'),
1162             'flex' : 1,
1163             'primary' : false,
1164             'hidden' : true,
1165             'editable' : false, 'render' : function(my) { return my.acp.alert_message(); }
1166         },
1167         {
1168             'persist' : 'hidden width ordinal',
1169             'fm_class' : 'circ',
1170             'id' : 'checkin_workstation',
1171             'label' : document.getElementById('circStrings').getString('staff.circ.utils.checkin_workstation'),
1172             'flex' : 1,
1173             'primary' : false,
1174             'hidden' : true,
1175             'editable' : false, 'render' : function(my) { return my.circ ? ( typeof my.circ.checkin_workstation() == 'object' ? my.circ.checkin_workstation().name() : my.circ.checkin_workstation() ) : ""; },
1176         },
1177         {
1178             'persist' : 'hidden width ordinal',
1179             'fm_class' : 'circ',
1180             'id' : 'checkout_workstation',
1181             'label' : document.getElementById('circStrings').getString('staff.circ.utils.checkout_workstation'),
1182             'flex' : 1,
1183             'primary' : false,
1184             'hidden' : true,
1185             'editable' : false, 'render' : function(my) { return my.circ ? ( typeof my.circ.workstation() == 'object' ? my.circ.workstation().name() : my.circ.workstation() ) : ""; },
1186         },
1187         {
1188             'persist' : 'hidden width ordinal',
1189             'fm_class' : 'circ',
1190             'id' : 'checkout_workstation_top_of_chain',
1191             'label' : document.getElementById('circStrings').getString('staff.circ.utils.checkout_workstation_top_of_chain'),
1192             'flex' : 1,
1193             'primary' : false,
1194             'hidden' : true,
1195             '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() ) : ""; },
1196         },
1197         {
1198             'persist' : 'hidden width ordinal',
1199             'fm_class' : 'circ',
1200             'id' : 'checkin_scan_time',
1201             'label' : document.getElementById('circStrings').getString('staff.circ.utils.checkin_scan_time'),
1202             'flex' : 1,
1203             'primary' : false,
1204             'hidden' : true,
1205             'editable' : false, 'render' : function(my) { return my.circ ? util.date.formatted_date( my.circ.checkin_scan_time(), '%{localized}' ) : ""; },
1206         },
1207         {
1208             'persist' : 'hidden width ordinal',
1209             'fm_class' : 'bre',
1210             'id' : 'creator',
1211             'label' : document.getElementById('circStrings').getString('staff.circ.utils.creator'),
1212             'flex' : 1,
1213             'primary' : false,
1214             'hidden' : true,
1215             'editable' : false, 'render' : function(my) { return my.bre ? (typeof my.bre.creator() == 'object' ? my.bre.creator().usrname() : '#' + my.bre.creator() ) : ''; }
1216         },
1217         {
1218             'persist' : 'hidden width ordinal',
1219             'fm_class' : 'bre',
1220             'id' : 'editor',
1221             'label' : document.getElementById('circStrings').getString('staff.circ.utils.editor'),
1222             'flex' : 1,
1223             'primary' : false,
1224             'hidden' : true,
1225             'editable' : false, 'render' : function(my) { return my.bre ? (typeof my.bre.editor() == 'object' ? my.bre.editor().usrname() : '#' + my.bre.editor() ) : ''; }
1226         },
1227         {
1228             'persist' : 'hidden width ordinal',
1229             'fm_class' : 'bre',
1230             'id' : 'create_date',
1231             'label' : document.getElementById('circStrings').getString('staff.circ.utils.bre.create_date'),
1232             'flex' : 1,
1233             'primary' : false,
1234             'hidden' : true,
1235             'editable' : false, 'render' : function(my) { return my.bre ? util.date.formatted_date( my.bre.create_date(), '%{localized}' ) : ''; }
1236         },
1237         {
1238             'persist' : 'hidden width ordinal',
1239             'fm_class' : 'bre',
1240             'id' : 'edit_date',
1241             'label' : document.getElementById('circStrings').getString('staff.circ.utils.bre.edit_date'),
1242             'flex' : 1,
1243             'primary' : false,
1244             'hidden' : true,
1245             'editable' : false, 'render' : function(my) { return my.bre ? util.date.formatted_date( my.bre.edit_date(), '%{localized}' ) : ''; }
1246         },
1247         {
1248             'persist' : 'hidden width ordinal',
1249             'fm_class' : 'bre',
1250             'id' : 'tcn_value',
1251             'label' : document.getElementById('circStrings').getString('staff.circ.utils.tcn'),
1252             'flex' : 1,
1253             'primary' : false,
1254             'hidden' : true,
1255             'editable' : false, 'render' : function(my) { return my.bre ? my.bre.tcn_value() : ''; }
1256         },
1257         {
1258             'persist' : 'hidden width ordinal',
1259             'fm_class' : 'bre',
1260             'id' : 'tcn_source',
1261             'label' : document.getElementById('circStrings').getString('staff.circ.utils.tcn_source'),
1262             'flex' : 1,
1263             'primary' : false,
1264             'hidden' : true,
1265             'editable' : false, 'render' : function(my) { return my.bre ? my.bre.tcn_source() : ''; }
1266         }
1267
1268     ];
1269     for (var i = 0; i < c.length; i++) {
1270         if (modify[ c[i].id ]) {
1271             for (var j in modify[ c[i].id ]) {
1272                 c[i][j] = modify[ c[i].id ][j];
1273             }
1274         }
1275     }
1276     if (params) {
1277         if (params.just_these) {
1278             JSAN.use('util.functional');
1279             var new_c = [];
1280             for (var i = 0; i < params.just_these.length; i++) {
1281                 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
1282                 new_c.push( function(y){ return y; }( x ) );
1283             }
1284             c = new_c;
1285         }
1286         if (params.except_these) {
1287             JSAN.use('util.functional');
1288             var new_c = [];
1289             for (var i = 0; i < c.length; i++) {
1290                 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
1291                 if (!x) new_c.push(c[i]);
1292             }
1293             c = new_c;
1294         }
1295     }
1296     return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
1297 };
1298
1299 circ.util.work_log_columns = function(modify,params) {
1300
1301     JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
1302
1303     var c = [
1304         {
1305             'persist' : 'hidden width ordinal',
1306             'id' : 'message',
1307             'label' : document.getElementById('circStrings').getString('staff.circ.work_log_column.message'),
1308             'flex' : 3,
1309             'primary' : true,
1310             'hidden' : false,
1311             'editable' : false, 'render' : function(my) { return my.message; }
1312         },
1313         {
1314             'persist' : 'hidden width ordinal',
1315             'id' : 'when',
1316             'label' : document.getElementById('circStrings').getString('staff.circ.work_log_column.when'),
1317             'flex' : 1,
1318             'primary' : false,
1319             'hidden' : false,
1320             'editable' : false, 'render' : function(my) { return String( my.when ); }
1321         }
1322
1323     ];
1324     for (var i = 0; i < c.length; i++) {
1325         if (modify[ c[i].id ]) {
1326             for (var j in modify[ c[i].id ]) {
1327                 c[i][j] = modify[ c[i].id ][j];
1328             }
1329         }
1330     }
1331     if (params) {
1332         if (params.just_these) {
1333             JSAN.use('util.functional');
1334             var new_c = [];
1335             for (var i = 0; i < params.just_these.length; i++) {
1336                 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
1337                 new_c.push( function(y){ return y; }( x ) );
1338             }
1339             c = new_c;
1340         }
1341         if (params.except_these) {
1342             JSAN.use('util.functional');
1343             var new_c = [];
1344             for (var i = 0; i < c.length; i++) {
1345                 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
1346                 if (!x) new_c.push(c[i]);
1347             }
1348             c = new_c;
1349         }
1350
1351     }
1352     return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
1353 };
1354
1355 circ.util.transit_columns = function(modify,params) {
1356
1357     JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
1358
1359     var c = [
1360         {
1361             'persist' : 'hidden width ordinal',
1362             'id' : 'transit_item_barcode',
1363             'label' : document.getElementById('circStrings').getString('staff.circ.utils.barcode'),
1364             'flex' : 1,
1365             'primary' : false,
1366             'hidden' : true,
1367             'editable' : false, 'render' : function(my) { return my.acp.barcode(); }
1368         },
1369         {
1370             'persist' : 'hidden width ordinal',
1371             'id' : 'transit_item_title',
1372             'label' : document.getElementById('circStrings').getString('staff.circ.utils.title'),
1373             'flex' : 1,
1374             'primary' : false,
1375             'hidden' : true,
1376             'editable' : false, 'render' : function(my) {
1377                 try { return my.mvr.title(); }
1378                 catch(E) { return my.acp.dummy_title(); }
1379             }
1380         },
1381         {
1382             'persist' : 'hidden width ordinal',
1383             'id' : 'transit_item_author',
1384             'label' : document.getElementById('circStrings').getString('staff.circ.utils.author'),
1385             'flex' : 1,
1386             'primary' : false,
1387             'hidden' : true,
1388             'editable' : false, 'render' : function(my) {
1389                 try { return my.mvr.author(); }
1390                 catch(E) { return my.acp.dummy_author(); }
1391             }
1392         },
1393         {
1394             'persist' : 'hidden width ordinal',
1395             'id' : 'transit_item_callnumber',
1396             'label' : document.getElementById('circStrings').getString('staff.circ.utils.callnumber'),
1397             'flex' : 1,
1398             'primary' : false,
1399             'hidden' : true,
1400             'editable' : false, 'render' : function(my) { return my.acn.label(); }
1401         },
1402         {
1403             'persist' : 'hidden width ordinal',
1404             'id' : 'transit_id',
1405             'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_id'),
1406             'flex' : 1,
1407             'primary' : false,
1408             'hidden' : true,
1409             'editable' : false, 'render' : function(my) { return my.atc.id(); }
1410         },
1411         {
1412             'persist' : 'hidden width ordinal',
1413             'id' : 'transit_source',
1414             'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_source'),
1415             'flex' : 1,
1416             'primary' : false,
1417             'hidden' : false,
1418             'editable' : false, 'render' : function(my) {
1419                 if (typeof my.atc.source() == "object") {
1420                     return my.atc.source().shortname();
1421                 } else {
1422                     return data.hash.aou[ my.atc.source() ].shortname();
1423                 }
1424             }
1425         },
1426         {
1427             'persist' : 'hidden width ordinal',
1428             'id' : 'transit_source_send_time',
1429             'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_source_send_time'),
1430             'flex' : 1,
1431             'primary' : false,
1432             'hidden' : false,
1433             'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.atc.source_send_time(), '%{localized}' ); }
1434         },
1435         {
1436             'persist' : 'hidden width ordinal',
1437             'id' : 'transit_dest_lib',
1438             'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_dest'),
1439             'flex' : 1,
1440             'primary' : false,
1441             'hidden' : false,
1442             'editable' : false, 'render' : function(my) {
1443                 if (typeof my.atc.dest() == "object") {
1444                     return my.atc.dest().shortname();
1445                 } else {
1446                     return data.hash.aou[ my.atc.dest() ].shortname();
1447                 }
1448             }
1449         },
1450         {
1451             'persist' : 'hidden width ordinal',
1452             'id' : 'transit_dest_recv_time',
1453             'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_dest_recv_time'),
1454             'flex' : 1,
1455             'primary' : false,
1456             'hidden' : false,
1457             'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.atc.dest_recv_time(), '%{localized}' ); }
1458         },
1459         {
1460             'persist' : 'hidden width ordinal',
1461             'id' : 'transit_target_copy',
1462             'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_target_copy'),
1463             'flex' : 1,
1464             'primary' : false,
1465             'hidden' : true,
1466             'editable' : false, 'render' : function(my) { return my.atc.target_copy(); }
1467         },
1468     ];
1469     for (var i = 0; i < c.length; i++) {
1470         if (modify[ c[i].id ]) {
1471             for (var j in modify[ c[i].id ]) {
1472                 c[i][j] = modify[ c[i].id ][j];
1473             }
1474         }
1475     }
1476     if (params) {
1477         if (params.just_these) {
1478             JSAN.use('util.functional');
1479             var new_c = [];
1480             for (var i = 0; i < params.just_these.length; i++) {
1481                 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
1482                 new_c.push( function(y){ return y; }( x ) );
1483             }
1484             c = new_c;
1485         }
1486         if (params.except_these) {
1487             JSAN.use('util.functional');
1488             var new_c = [];
1489             for (var i = 0; i < c.length; i++) {
1490                 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
1491                 if (!x) new_c.push(c[i]);
1492             }
1493             c = new_c;
1494         }
1495
1496     }
1497     return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
1498 };
1499
1500 circ.util.hold_columns = function(modify,params) {
1501
1502     JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
1503
1504     var c = [
1505         {
1506             'id' : 'post_clear_shelf_action',
1507             'flex' : 1, 'primary' : false, 'hidden' : true, 'editable' : false, 
1508             'label' : document.getElementById('circStrings').getString('staff.circ.utils.hold_post_clear_shelf_action.label'),
1509             'render' : function(my) { 
1510                 return my.post_clear_shelf_action ? document.getElementById('circStrings').getString('staff.circ.utils.hold_post_clear_shelf_action.' + my.post_clear_shelf_action) : '';
1511             }
1512         },
1513         {
1514             'persist' : 'hidden width ordinal',
1515             'id' : 'cancel_time',
1516             'label' : document.getElementById('circStrings').getString('staff.circ.utils.hold_cancel_time'),
1517             'flex' : 1,
1518             'primary' : false,
1519             'hidden' : true,
1520             'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.ahr.cancel_time(), '%{localized}' ); }
1521         },
1522         {
1523             'persist' : 'hidden width ordinal',
1524             'id' : 'cancel_cause',
1525             'label' : document.getElementById('circStrings').getString('staff.circ.utils.hold_cancel_cause'),
1526             'flex' : 1,
1527             'primary' : false,
1528             'hidden' : true,
1529             '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(); }
1530         },
1531         {
1532             'persist' : 'hidden width ordinal',
1533             'id' : 'cancel_note',
1534             'label' : document.getElementById('circStrings').getString('staff.circ.utils.hold_cancel_note'),
1535             'flex' : 1,
1536             'primary' : false,
1537             'hidden' : true,
1538             'editable' : false, 'render' : function(my) { return my.ahr.cancel_note(); }
1539         },
1540         {
1541             'persist' : 'hidden width ordinal',
1542             'id' : 'request_lib',
1543             'label' : document.getElementById('circStrings').getString('staff.circ.utils.request_lib'),
1544             'flex' : 1,
1545             'primary' : false,
1546             'hidden' : true,
1547             'editable' : false, 'render' : function(my) {
1548                 if (Number(my.ahr.request_lib())>=0) {
1549                     return data.hash.aou[ my.ahr.request_lib() ].name();
1550                 } else {
1551                     return my.ahr.request_lib().name();
1552                 }
1553             }
1554         },
1555         {
1556             'persist' : 'hidden width ordinal',
1557             'id' : 'request_lib_shortname',
1558             'label' : document.getElementById('circStrings').getString('staff.circ.utils.request_lib_shortname'),
1559             'flex' : 0,
1560             'primary' : false,
1561             'hidden' : true,
1562             'editable' : false, 'render' : function(my) {
1563                 if (Number(my.ahr.request_lib())>=0) {
1564                     return data.hash.aou[ my.ahr.request_lib() ].shortname();
1565                 } else {
1566                     return my.ahr.request_lib().shortname();
1567                 }
1568             }
1569         },
1570         {
1571             'persist' : 'hidden width ordinal',
1572             'id' : 'request_time',
1573             'label' : document.getElementById('circStrings').getString('staff.circ.utils.request_time'),
1574             'flex' : 0,
1575             'primary' : false,
1576             'hidden' : true,
1577             'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.ahr.request_time(), '%{localized}' ); }
1578         },
1579         {
1580             'persist' : 'hidden width ordinal',
1581             'id' : 'shelf_time',
1582             'label' : document.getElementById('circStrings').getString('staff.circ.utils.holds.shelf_time'),
1583             'flex' : 0,
1584             'primary' : false,
1585             'hidden' : true,
1586             'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.ahr.shelf_time(), '%{localized}' ); }
1587         },
1588         {
1589             'persist' : 'hidden width ordinal',
1590             'id' : 'shelf_expire_time',
1591             'label' : document.getElementById('circStrings').getString('staff.circ.utils.holds.shelf_expire_time'),
1592             'flex' : 0,
1593             'primary' : false,
1594             'hidden' : true,
1595             'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.ahr.shelf_expire_time(), '%{localized}' ); }
1596         },
1597         {
1598             'persist' : 'hidden width ordinal',
1599             'id' : 'available_time',
1600             'label' : document.getElementById('circStrings').getString('staff.circ.utils.available_time'),
1601             'flex' : 1,
1602             'primary' : false,
1603             'hidden' : false,
1604             'editable' : false, 'render' : function(my) {
1605                 if (my.ahr.transit() && my.ahr.transit().dest_recv_time()) {
1606                     return util.date.formatted_date( my.ahr.transit().dest_recv_time(), '%{localized}' );
1607                 }
1608                 if (!my.ahr.transit() && my.ahr.capture_time()) {
1609                     return util.date.formatted_date( my.ahr.capture_time(), '%{localized}' );
1610                 }
1611                 return "";
1612             }
1613         },
1614         {
1615             'persist' : 'hidden width ordinal',
1616             'id' : 'capture_time',
1617             'label' : document.getElementById('circStrings').getString('staff.circ.utils.capture_time'),
1618             'flex' : 1,
1619             'primary' : false,
1620             'hidden' : true,
1621             'editable' : false, 'render' : function(my) { return my.ahr.capture_time() ? util.date.formatted_date( my.ahr.capture_time(), '%{localized}' ) : ""; }
1622         },
1623         {
1624             'persist' : 'hidden width ordinal',
1625             'id' : 'ahr_status',
1626             'label' : document.getElementById('commonStrings').getString('staff.ahr_status_label'),
1627             'flex' : 1,
1628             'primary' : false,
1629             'hidden' : false,
1630             'editable' : false, 'render' : function(my) {
1631                 switch (Number(my.status)) {
1632                     case 1:
1633                         return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.1');
1634                         break;
1635                     case 2:
1636                         return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.2');
1637                         break;
1638                     case 3:
1639                         return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.3');
1640                         break;
1641                     case 4:
1642                         return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.4');
1643                         break;
1644                                         case 5:
1645                         return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.5');
1646                         break;
1647                     default:
1648                         return my.status;
1649                         break;
1650                 };
1651             }
1652         },
1653         {
1654             'persist' : 'hidden width ordinal',
1655             'id' : 'hold_type',
1656             'label' : document.getElementById('commonStrings').getString('staff.ahr_hold_type_label'),
1657             'flex' : 0,
1658             'primary' : false,
1659             'hidden' : true,
1660             'editable' : false, 'render' : function(my) { return my.ahr.hold_type(); }
1661         },
1662         {
1663             'persist' : 'hidden width ordinal',
1664             'id' : 'ahr_mint_condition',
1665             'label' : document.getElementById('circStrings').getString('staff.circ.utils.ahr_mint_condition'),
1666             'flex' : 0,
1667             'primary' : false,
1668             'hidden' : true,
1669             'editable' : false, 'render' : function(my) {
1670                 if (get_bool( my.ahr.mint_condition() )) {
1671                     return document.getElementById('circStrings').getString('staff.circ.utils.ahr_mint_condition.true');
1672                 } else {
1673                     return document.getElementById('circStrings').getString('staff.circ.utils.ahr_mint_condition.false');
1674                 }
1675             }
1676         },
1677         {
1678             'persist' : 'hidden width ordinal',
1679             'id' : 'frozen',
1680             'label' : document.getElementById('circStrings').getString('staff.circ.utils.active'),
1681             'flex' : 0,
1682             'primary' : false,
1683             'hidden' : true,
1684             'editable' : false, 'render' : function(my) {
1685                 if (!get_bool( my.ahr.frozen() )) {
1686                     return document.getElementById('circStrings').getString('staff.circ.utils.yes');
1687                 } else {
1688                     return document.getElementById('circStrings').getString('staff.circ.utils.no');
1689                 }
1690             }
1691         },
1692         {
1693             'persist' : 'hidden width ordinal',
1694             'id' : 'thaw_date',
1695             'label' : document.getElementById('circStrings').getString('staff.circ.utils.thaw_date'),
1696             'flex' : 0,
1697             'primary' : false,
1698             'hidden' : true,
1699             'editable' : false, 'render' : function(my) {
1700                 if (my.ahr.thaw_date() == null) {
1701                     return document.getElementById('circStrings').getString('staff.circ.utils.thaw_date.none');
1702                 } else {
1703                     return util.date.formatted_date( my.ahr.thaw_date(), '%{localized}' );
1704                 }
1705             }
1706         },
1707         {
1708             'persist' : 'hidden width ordinal',
1709             'id' : 'pickup_lib',
1710             'label' : document.getElementById('circStrings').getString('staff.circ.utils.pickup_lib'),
1711             'flex' : 1,
1712             'primary' : false,
1713             'hidden' : true,
1714             'editable' : false, 'render' : function(my) {
1715                 if (Number(my.ahr.pickup_lib())>=0) {
1716                     return data.hash.aou[ my.ahr.pickup_lib() ].name();
1717                 } else {
1718                     return my.ahr.pickup_lib().name();
1719                 }
1720             }
1721         },
1722         {
1723             'persist' : 'hidden width ordinal',
1724             'id' : 'pickup_lib_shortname',
1725             'label' : document.getElementById('commonStrings').getString('staff.ahr_pickup_lib_label'),
1726             'flex' : 0,
1727             'primary' : false,
1728             'hidden' : true,
1729             'editable' : false, 'render' : function(my) {
1730                 if (Number(my.ahr.pickup_lib())>=0) {
1731                     return data.hash.aou[ my.ahr.pickup_lib() ].shortname();
1732                 } else {
1733                     return my.ahr.pickup_lib().shortname();
1734                 }
1735             }
1736         },
1737         {
1738             'persist' : 'hidden width ordinal',
1739             'id' : 'current_copy',
1740             'label' : document.getElementById('commonStrings').getString('staff.ahr_current_copy_label'),
1741             'flex' : 1,
1742             'primary' : false,
1743             'hidden' : true,
1744             'editable' : false, 'render' : function(my) {
1745                 if (my.acp) {
1746                     return my.acp.barcode();
1747                 } else {
1748                     return document.getElementById('circStrings').getString('staff.circ.utils.current_copy.none');
1749                 }
1750             }
1751         },
1752         {
1753             'persist' : 'hidden width ordinal',
1754             'id' : 'current_copy_location',
1755             'label' : document.getElementById('commonStrings').getString('staff.ahr_current_copy_location_label'),
1756             'flex' : 1,
1757             'primary' : false,
1758             'hidden' : true,
1759             'editable' : false, 'render' : function(my) {
1760                 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(); }
1761             }
1762         },
1763         {
1764             'persist' : 'hidden width ordinal',
1765             'id' : 'email_notify',
1766             'label' : document.getElementById('commonStrings').getString('staff.ahr_email_notify_label'),
1767             'flex' : 1,
1768             'primary' : false,
1769             'hidden' : true,
1770             'editable' : false, 'render' : function(my) {
1771                 if (get_bool(my.ahr.email_notify())) {
1772                     return document.getElementById('circStrings').getString('staff.circ.utils.yes');
1773                 } else {
1774                     return document.getElementById('circStrings').getString('staff.circ.utils.no');
1775                 }
1776             }
1777         },
1778         {
1779             'persist' : 'hidden width ordinal',
1780             'id' : 'expire_date',
1781             'label' : document.getElementById('commonStrings').getString('staff.ahr_expire_date_label'),
1782             'flex' : 1,
1783             'primary' : false,
1784             'hidden' : true,
1785             'editable' : false, 'render' : function(my) { return my.ahr.expire_time() ? util.date.formatted_date( my.ahr.expire_time(), '%{localized}' ) : ''; }
1786         },
1787         {
1788             'persist' : 'hidden width ordinal',
1789             'id' : 'fulfillment_time',
1790             'label' : document.getElementById('commonStrings').getString('staff.ahr_fulfillment_time_label'),
1791             'flex' : 1,
1792             'primary' : false,
1793             'hidden' : true,
1794             'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.ahr.fulfillment_time(), '%{localized}' ); }
1795         },
1796         {
1797             'persist' : 'hidden width ordinal',
1798             'id' : 'holdable_formats',
1799             'label' : document.getElementById('commonStrings').getString('staff.ahr_holdable_formats_label'),
1800             'flex' : 1,
1801             'primary' : false,
1802             'hidden' : true,
1803             'editable' : false, 'render' : function(my) { return my.ahr.holdable_formats(); }
1804         },
1805         {
1806             'persist' : 'hidden width ordinal',
1807             'id' : 'ahr_id',
1808             'label' : document.getElementById('commonStrings').getString('staff.ahr_id_label'),
1809             'flex' : 1,
1810             'primary' : false,
1811             'hidden' : true,
1812             'editable' : false, 'render' : function(my) { return my.ahr.id(); }
1813         },
1814         {
1815             'persist' : 'hidden width ordinal',
1816             'id' : 'phone_notify',
1817             'label' : document.getElementById('commonStrings').getString('staff.ahr_phone_notify_label'),
1818             'flex' : 1,
1819             'primary' : false,
1820             'hidden' : true,
1821             'editable' : false, 'render' : function(my) { return my.ahr.phone_notify(); }
1822         },
1823         {
1824             'persist' : 'hidden width ordinal',
1825             'id' : 'prev_check_time',
1826             'label' : document.getElementById('commonStrings').getString('staff.ahr_prev_check_time_label'),
1827             'flex' : 1,
1828             'primary' : false,
1829             'hidden' : true,
1830             'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.ahr.prev_check_time(), '%{localized}' ); }
1831         },
1832         {
1833             'persist' : 'hidden width ordinal',
1834             'id' : 'requestor',
1835             'label' : document.getElementById('commonStrings').getString('staff.ahr_requestor_label'),
1836             'flex' : 1,
1837             'primary' : false,
1838             'hidden' : true,
1839             'editable' : false, 'render' : function(my) { return my.ahr.requestor(); }
1840         },
1841         {
1842             'persist' : 'hidden width ordinal',
1843             'id' : 'selection_depth',
1844             'label' : document.getElementById('commonStrings').getString('staff.ahr_selection_depth_label'),
1845             'flex' : 1,
1846             'primary' : false,
1847             'hidden' : true,
1848             'editable' : false, 'render' : function(my) { return my.ahr.selection_depth(); }
1849         },
1850         {
1851             'persist' : 'hidden width ordinal',
1852             'id' : 'top_of_queue',
1853             'label' : document.getElementById('commonStrings').getString('staff.ahr_top_of_queue_label'),
1854             'flex' : 1,
1855             'primary' : false,
1856             'hidden' : true,
1857             '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') ; }
1858         },
1859         {
1860             'persist' : 'hidden width ordinal',
1861             'id' : 'target',
1862             'label' : document.getElementById('commonStrings').getString('staff.ahr_target_label'),
1863             'flex' : 1,
1864             'primary' : false,
1865             'hidden' : true,
1866             'editable' : false, 'render' : function(my) { return my.ahr.target(); }
1867         },
1868         {
1869             'persist' : 'hidden width ordinal',
1870             'id' : 'usr',
1871             'label' : document.getElementById('commonStrings').getString('staff.ahr_usr_label'),
1872             'flex' : 1,
1873             'primary' : false,
1874             'hidden' : true,
1875             'editable' : false, 'render' : function(my) { return my.ahr.usr(); }
1876         },
1877         {
1878             'persist' : 'hidden width ordinal',
1879             'id' : 'title',
1880             'label' : document.getElementById('commonStrings').getString('staff.mvr_label_title'),
1881             'flex' : 1,
1882             'sort_type' : 'title',
1883             'primary' : false,
1884             'hidden' : true,
1885             'editable' : false, 'render' : function(my) {
1886                 if (my.mvr) {
1887                     return my.mvr.title();
1888                 } else {
1889                     return document.getElementById('circStrings').getString('staff.circ.utils.title.none');
1890                 }
1891             }
1892         },
1893         {
1894             'persist' : 'hidden width ordinal',
1895             'id' : 'author',
1896             'label' : document.getElementById('commonStrings').getString('staff.mvr_label_author'),
1897             'flex' : 1,
1898             'primary' : false,
1899             'hidden' : true,
1900             'editable' : false, 'render' : function(my) {
1901                 if (my.mvr) {
1902                     return my.mvr.author();
1903                 } else {
1904                     return document.getElementById('circStrings').getString('staff.circ.utils.author.none');
1905                 }
1906             }
1907         },
1908         {
1909             'persist' : 'hidden width ordinal',
1910             'id' : 'edition',
1911             'label' : document.getElementById('circStrings').getString('staff.circ.utils.edition'),
1912             'flex' : 1,
1913             'primary' : false,
1914             'hidden' : true,
1915             'editable' : false, 'render' : function(my) { return my.mvr.edition(); }
1916         },
1917         {
1918             'persist' : 'hidden width ordinal',
1919             'id' : 'isbn',
1920             'label' : document.getElementById('circStrings').getString('staff.circ.utils.isbn'),
1921             'flex' : 1,
1922             'primary' : false,
1923             'hidden' : true,
1924             'editable' : false, 'render' : function(my) { return my.mvr.isbn(); }
1925         },
1926         {
1927             'persist' : 'hidden width ordinal',
1928             'id' : 'pubdate',
1929             'label' : document.getElementById('circStrings').getString('staff.circ.utils.pubdate'),
1930             'flex' : 1,
1931             'primary' : false,
1932             'hidden' : true,
1933             'editable' : false, 'render' : function(my) { return my.mvr.pubdate(); }
1934         },
1935         {
1936             'persist' : 'hidden width ordinal',
1937             'id' : 'publisher',
1938             'label' : document.getElementById('circStrings').getString('staff.circ.utils.publisher'),
1939             'flex' : 1,
1940             'primary' : false,
1941             'hidden' : true,
1942             'editable' : false, 'render' : function(my) { return my.mvr.publisher(); }
1943         },
1944         {
1945             'persist' : 'hidden width ordinal',
1946             'id' : 'tcn',
1947             'label' : document.getElementById('circStrings').getString('staff.circ.utils.tcn'),
1948             'flex' : 1,
1949             'primary' : false,
1950             'hidden' : true,
1951             'editable' : false, 'render' : function(my) { return my.mvr.tcn(); }
1952         },
1953         {
1954             'persist' : 'hidden width ordinal',
1955             'id' : 'notify_time',
1956             'label' : document.getElementById('circStrings').getString('staff.circ.utils.notify_time'),
1957             'flex' : 1,
1958             'primary' : false,
1959             'hidden' : true,
1960             'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.ahr.notify_time(), '%{localized}' ); }
1961         },
1962         {
1963             'persist' : 'hidden width ordinal',
1964             'id' : 'notify_count',
1965             'label' : document.getElementById('circStrings').getString('staff.circ.utils.notify_count'),
1966             'flex' : 1,
1967             'primary' : false,
1968             'hidden' : true,
1969             'editable' : false, 'render' : function(my) { return my.ahr.notify_count(); }
1970         },
1971         {
1972             'persist' : 'hidden width ordinal',
1973             'id' : 'transit_source',
1974             'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_source'),
1975             'flex' : 1,
1976             'primary' : false,
1977             'hidden' : true,
1978             'editable' : false, 'render' : function(my) {
1979                 if (my.ahr.transit()) {
1980                     return data.hash.aou[ my.ahr.transit().source() ].shortname();
1981                 } else {
1982                     return "";
1983                 }
1984             }
1985         },
1986         {
1987             'persist' : 'hidden width ordinal',
1988             'id' : 'transit_source_send_time',
1989             'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_source_send_time'),
1990             'flex' : 1,
1991             'primary' : false,
1992             'hidden' : true,
1993             'editable' : false, 'render' : function(my) { return my.ahr.transit() ?  util.date.formatted_date( my.ahr.transit().source_send_time(), '%{localized}' ) : ""; }
1994         },
1995         {
1996             'persist' : 'hidden width ordinal',
1997             'id' : 'transit_dest_lib',
1998             'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_dest'),
1999             'flex' : 1,
2000             'primary' : false,
2001             'hidden' : true,
2002             'editable' : false, 'render' : function(my) { return my.ahr.transit() ?  data.hash.aou[ my.ahr.transit().dest() ].shortname() : ""; }
2003         },
2004         {
2005             'persist' : 'hidden width ordinal',
2006             'id' : 'transit_dest_recv_time',
2007             'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_dest_recv_time'),
2008             'flex' : 1,
2009             'primary' : false,
2010             'hidden' : true,
2011             'editable' : false, 'render' : function(my) { return my.ahr.transit() ?  util.date.formatted_date( my.ahr.transit().dest_recv_time(), '%{localized}' ) : ""; }
2012         },
2013         {
2014             'persist' : 'hidden width ordinal',
2015             'id' : 'patron_barcode',
2016             'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.patron_barcode'),
2017             'flex' : 1,
2018             'primary' : false,
2019             'hidden' : true,
2020             'editable' : false, 'render' : function(my) { return my.patron_barcode ? my.patron_barcode : ""; }
2021         },
2022         {
2023             'persist' : 'hidden width ordinal',
2024             'id' : 'patron_family_name',
2025             'label' : document.getElementById('circStrings').getString('staff.circ.utils.patron_family_name'),
2026             'flex' : 1,
2027             'primary' : false,
2028             'hidden' : true,
2029             'editable' : false, 'render' : function(my) { return my.patron_family_name ? my.patron_family_name : ""; }
2030         },
2031         {
2032             'persist' : 'hidden width ordinal',
2033             'id' : 'patron_first_given_name',
2034             'label' : document.getElementById('circStrings').getString('staff.circ.utils.patron_first_given_name'),
2035             'flex' : 1,
2036             'primary' : false,
2037             'hidden' : true,
2038             'editable' : false, 'render' : function(my) { return my.patron_first_given_name ? my.patron_first_given_name : ""; }
2039         },
2040         {
2041             'persist' : 'hidden width ordinal',
2042             'id' : 'callnumber',
2043             'label' : document.getElementById('circStrings').getString('staff.circ.utils.callnumber'),
2044             'flex' : 1,
2045             'primary' : false,
2046             'hidden' : true,
2047             'editable' : false, 'render' : function(my) { return my.acn.label(); }
2048         },
2049                 {
2050             'persist' : 'hidden width ordinal',
2051             'id' : 'total_holds',
2052             'label' : document.getElementById('circStrings').getString('staff.circ.utils.total_holds'),
2053             'flex' : 1,
2054             'primary' : false,
2055             'hidden' : true,
2056             'editable' : false, 'render' : function(my) { return my.total_holds; }
2057         },
2058                 {
2059             'persist' : 'hidden width ordinal',
2060             'id' : 'queue_position',
2061             'label' : document.getElementById('circStrings').getString('staff.circ.utils.queue_position'),
2062             'flex' : 1,
2063             'primary' : false,
2064             'hidden' : true,
2065             'editable' : false, 'render' : function(my) { return my.queue_position; }
2066         },
2067                 {
2068             'persist' : 'hidden width ordinal',
2069             'id' : 'potential_copies',
2070             'label' : document.getElementById('circStrings').getString('staff.circ.utils.potential_copies'),
2071             'flex' : 1,
2072             'primary' : false,
2073             'hidden' : true,
2074             'editable' : false, 'render' : function(my) { return my.potential_copies; }
2075         },
2076                 {
2077             'persist' : 'hidden width ordinal',
2078             'id' : 'estimated_wait',
2079             'label' : document.getElementById('circStrings').getString('staff.circ.utils.estimated_wait'),
2080             'flex' : 1,
2081             'primary' : false,
2082             'hidden' : true,
2083             'editable' : false, 'render' : function(my) { return my.estimated_wait; }
2084         },
2085         {
2086             'persist' : 'hidden width ordinal',
2087             'id' : 'hold_note',
2088             'label' : document.getElementById('circStrings').getString('staff.circ.utils.hold_note'),
2089             'flex' : 1,
2090             'primary' : false,
2091             'hidden' : true,
2092             'editable' : false, 'render' : function(my) { return my.ahrn_count; }
2093         },
2094         {
2095             'persist' : 'hidden width ordinal',
2096             'id' : 'staff_hold',
2097             'label' : document.getElementById('circStrings').getString('staff.circ.utils.staff_hold'),
2098             'flex' : 1,
2099             'primary' : false,
2100             'hidden' : true,
2101             'editable' : false, 
2102             'render' : function(my) {
2103                 if (my.ahr.usr() != my.ahr.requestor()){
2104                     return document.getElementById('circStrings').getString('staff.circ.utils.yes');
2105                 } else {
2106                     return document.getElementById('circStrings').getString('staff.circ.utils.no');
2107                 }
2108             }
2109         }
2110     ];
2111     for (var i = 0; i < c.length; i++) {
2112         if (modify[ c[i].id ]) {
2113             for (var j in modify[ c[i].id ]) {
2114                 c[i][j] = modify[ c[i].id ][j];
2115             }
2116         }
2117     }
2118     if (params) {
2119         if (params.just_these) {
2120             JSAN.use('util.functional');
2121             var new_c = [];
2122             for (var i = 0; i < params.just_these.length; i++) {
2123                 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
2124                 new_c.push( function(y){ return y; }( x ) );
2125             }
2126             c = new_c;
2127         }
2128         if (params.except_these) {
2129             JSAN.use('util.functional');
2130             var new_c = [];
2131             for (var i = 0; i < c.length; i++) {
2132                 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
2133                 if (!x) new_c.push(c[i]);
2134             }
2135             c = new_c;
2136         }
2137
2138     }
2139     return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
2140 };
2141 /*
2142 circ.util.std_map_row_to_column = function(error_value) {
2143     return function(row,col) {
2144         // row contains { 'my' : { 'acp' : {}, 'circ' : {}, 'mvr' : {} } }
2145         // col contains one of the objects listed above in columns
2146
2147         // mimicking some of the obj in circ.checkin and circ.checkout where map_row_to_column is usually defined
2148         var obj = {};
2149         JSAN.use('util.error'); obj.error = new util.error();
2150         JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
2151         JSAN.use('util.network'); obj.network = new util.network();
2152         JSAN.use('util.money');
2153
2154         var my = row.my;
2155         var value;
2156         try {
2157             value = eval( col.render );
2158         } catch(E) {
2159             obj.error.sdump('D_WARN','map_row_to_column: ' + E);
2160             if (error_value) value = error_value; else value = '   ';
2161         }
2162         return value;
2163     }
2164 };
2165 */
2166 circ.util.std_map_row_to_columns = function(error_value) {
2167     return function(row,cols) {
2168         // row contains { 'my' : { 'acp' : {}, 'circ' : {}, 'mvr' : {} } }
2169         // cols contains all of the objects listed above in columns
2170
2171         var obj = {};
2172         JSAN.use('util.error'); obj.error = new util.error();
2173         JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
2174         JSAN.use('util.network'); obj.network = new util.network();
2175         JSAN.use('util.money');
2176
2177         var my = row.my;
2178         var values = [];
2179         var cmd = '';
2180         try {
2181             for (var i = 0; i < cols.length; i++) {
2182                 switch (typeof cols[i].render) {
2183                     case 'function': try { values[i] = cols[i].render(my); } catch(E) { values[i] = error_value; obj.error.sdump('D_COLUMN_RENDER_ERROR',E); } break;
2184                     case 'string' : cmd += 'try { ' + cols[i].render + '; values['+i+'] = v; } catch(E) { values['+i+'] = error_value; }'; break;
2185                     default: cmd += 'values['+i+'] = "??? '+(typeof cols[i].render)+'"; ';
2186                 }
2187             }
2188             if (cmd) eval( cmd );
2189         } catch(E) {
2190             obj.error.sdump('D_WARN','map_row_to_column: ' + E);
2191             if (error_value) { value = error_value; } else { value = '   ' };
2192         }
2193         return values;
2194     }
2195 };
2196
2197 circ.util.checkin_via_barcode = function(session,params,backdate,auto_print,async) {
2198     try {
2199         JSAN.use('util.error'); var error = new util.error();
2200         JSAN.use('util.network'); var network = new util.network();
2201         JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
2202         JSAN.use('util.date'); JSAN.use('util.functional');
2203
2204         if (backdate && (backdate == util.date.formatted_date(new Date(),'%Y-%m-%d')) ) backdate = null;
2205
2206         //var params = { 'barcode' : barcode };
2207         if (backdate) params.backdate = util.date.formatted_date(backdate + ' 00:00:00','%{iso8601}');
2208
2209         if (typeof params.disable_textbox == 'function') {
2210             try { params.disable_textbox(); }
2211             catch(E) { error.sdump('D_ERROR','params.disable_textbox() = ' + E); };
2212         }
2213
2214         function checkin_callback(req) {
2215             JSAN.use('util.error'); var error = new util.error();
2216             try {
2217                 var check = req.getResultObject();
2218                 var r = circ.util.checkin_via_barcode2(session,params,backdate,auto_print,check);
2219                 try {
2220                     error.work_log(
2221                         document.getElementById('circStrings').getFormattedString(
2222                             'staff.circ.work_log_checkin_attempt.' + r.what_happened + '.message',
2223                             [
2224                                 ses('staff_usrname'),
2225                                 r.payload.patron ? r.payload.patron.family_name() : '',
2226                                 r.payload.patron ? r.payload.patron.card().barcode() : '',
2227                                 r.payload.copy ? r.payload.copy.barcode() : '',
2228                                 r.route_to ? r.route_to : ''
2229                             ]
2230                         ), {
2231                             'au_id' : r.payload.patron ? r.payload.patron.id() : '',
2232                             'au_family_name' : r.payload.patron ? r.payload.patron.family_name() : '',
2233                             'au_barcode' : r.payload.patron ? r.payload.patron.card().barcode() : '',
2234                             'acp_barcode' : r.payload.copy ? r.payload.copy.barcode() : ''
2235                         }
2236                     );
2237                 } catch(E) {
2238                     error.sdump('D_ERROR','Error with work_logging in server/circ/checkout.js, _checkout:' + E);
2239                 }
2240
2241                 if (typeof params.checkin_result == 'function') {
2242                     try { params.checkin_result(r); } catch(E) { error.sdump('D_ERROR','params.checkin_result() = ' + E); };
2243                 }
2244                 if (typeof async == 'function') async(check);
2245                 return check;
2246             } catch(E) {
2247                 error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.error', ['1']), E);
2248                 if (typeof params.enable_textbox == 'function') {
2249                     try { params.enable_textbox(); }
2250                     catch(E) { error.sdump('D_ERROR','params.disable_textbox() = ' + E); };
2251                 }
2252                 return null;
2253             }
2254         }
2255
2256         var suppress_popups = data.hash.aous['ui.circ.suppress_checkin_popups'];
2257
2258         var check = network.request(
2259             api.CHECKIN_VIA_BARCODE.app,
2260             api.CHECKIN_VIA_BARCODE.method,
2261             [ session, util.functional.filter_object( params, function(i,o) { return typeof o != 'function'; } ) ],
2262             async ? checkin_callback : null,
2263             {
2264                 'title' : document.getElementById('circStrings').getString('staff.circ.utils.checkin.override'),
2265                 'auto_override_these_events' : suppress_popups ? [
2266                     null /* custom event */,
2267                     1203 /* COPY_BAD_STATUS */,
2268                     1213 /* PATRON_BARRED */,
2269                     1217 /* PATRON_INACTIVE */,
2270                     1224 /* PATRON_ACCOUNT_EXPIRED */,
2271                     1234 /* ITEM_DEPOSIT_PAID */,
2272                     7009 /* CIRC_CLAIMS_RETURNED */,
2273                     7010 /* COPY_ALERT_MESSAGE */,
2274                     7011 /* COPY_STATUS_LOST */,
2275                     7012 /* COPY_STATUS_MISSING */,
2276                     7013 /* PATRON_EXCEEDS_FINES */
2277                 ] : [],
2278                 'overridable_events' : [
2279                     null /* custom event */,
2280                     1203 /* COPY_BAD_STATUS */,
2281                     1213 /* PATRON_BARRED */,
2282                     1217 /* PATRON_INACTIVE */,
2283                     1224 /* PATRON_ACCOUNT_EXPIRED */,
2284                     1234 /* ITEM_DEPOSIT_PAID */,
2285                     7009 /* CIRC_CLAIMS_RETURNED */,
2286                     7010 /* COPY_ALERT_MESSAGE */,
2287                     7011 /* COPY_STATUS_LOST */,
2288                     7012 /* COPY_STATUS_MISSING */,
2289                     7013 /* PATRON_EXCEEDS_FINES */
2290                 ],
2291                 'text' : {
2292                     '1203' : function(r) {
2293                         return typeof r.payload.status() == 'object' ? r.payload.status().name() : data.hash.ccs[ r.payload.status() ].name();
2294                     },
2295                     '1234' : function(r) {
2296                         return document.getElementById('circStrings').getString('staff.circ.utils.checkin.override.item_deposit_paid.warning');
2297                     },
2298                     '7010' : function(r) {
2299                         return r.payload;
2300                     }
2301                 }
2302             }
2303         );
2304         if (! async ) {
2305             return checkin_callback( { 'getResultObject' : function() { return check; } } );
2306         }
2307
2308
2309     } catch(E) {
2310         JSAN.use('util.error'); var error = new util.error();
2311         error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.error', ['2']), E);
2312         if (typeof params.enable_textbox == 'function') {
2313             try { params.enable_textbox(); } catch(E) { error.sdump('D_ERROR','params.disable_textbox() = ' + E); };
2314         }
2315         return null;
2316     }
2317 };
2318
2319 circ.util.checkin_via_barcode2 = function(session,params,backdate,auto_print,check) {
2320     try {
2321         JSAN.use('util.error'); var error = new util.error();
2322         JSAN.use('util.network'); var network = new util.network();
2323         JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
2324         JSAN.use('util.date');
2325         JSAN.use('util.sound'); var sound = new util.sound();
2326
2327         error.sdump('D_DEBUG','check = ' + error.pretty_print( js2JSON( check ) ) );
2328
2329         check.message = check.textcode;
2330
2331         if (check.payload && check.payload.copy) { check.copy = check.payload.copy; }
2332         if (check.payload && check.payload.record) { check.record = check.payload.record; }
2333         if (check.payload && check.payload.circ) { check.circ = check.payload.circ; }
2334         if (check.payload && check.payload.patron) { check.patron = check.payload.patron; }
2335
2336         if (!check.route_to) { check.route_to = '   '; }
2337
2338         if (document.getElementById('no_change_label')) {
2339             document.getElementById('no_change_label').setAttribute('value','');
2340             document.getElementById('no_change_label').setAttribute('hidden','true');
2341         }
2342
2343         var msg = '';
2344         var print_list = [];
2345         var print_data = { 
2346             'error' : '',
2347             'error_msg' : '',
2348             'cancelled' : '',
2349             'route_to' : '',
2350             'route_to_msg' : '',
2351             'route_to_org_fullname' : '',
2352             'courier_code' : '',
2353             'street1' : '',
2354             'street2' : '',
2355             'city_state_zip' : '',
2356             'city' : '',
2357             'state' : '',
2358             'county' : '',
2359             'country' : '',
2360             'post_code' : '',
2361             'item_barcode' : '',
2362             'item_barcode_msg' : '',
2363             'item_title' : '',
2364             'item_title_msg' : '',
2365             'item_author' : '',
2366             'item_author_msg' : '',
2367             'hold_for_msg' : '',
2368             'hold_for_alias' : '',
2369             'hold_for_family_name' : '',
2370             'hold_for_first_given_name' : '',
2371             'hold_for_second_given_name' : '',
2372             'user_barcode' : '',
2373             'user_barcode_msg' : '',
2374             'notify_by_phone' : '',
2375             'notify_by_phone_msg' : '',
2376             'notify_by_email' : '',
2377             'notify_by_email_msg' : '',
2378             'request_date' : '',
2379             'request_date_msg' : '',
2380             'slip_date' : '',
2381             'slip_date_msg' : ''
2382         };
2383
2384         if (check.payload && check.payload.cancelled_hold_transit) {
2385             print_data.cancelled = document.getElementById('circStrings').getString('staff.circ.utils.transit_hold_cancelled');
2386             msg += print_data.cancelled;
2387             msg += '\n\n';
2388         }
2389
2390         /* SUCCESS  /  NO_CHANGE  /  ITEM_NOT_CATALOGED */
2391         if (check.ilsevent == 0 || check.ilsevent == 3 || check.ilsevent == 1202) {
2392             try { check.route_to = data.lookup('acpl', check.copy.location() ).name(); }
2393             catch(E) {
2394                 print_data.error_msg = document.getElementById('commonStrings').getString('common.error');
2395                 print_data.error_msg += '\nFIXME: ' + E + '\n';
2396                 msg += print_data.error_msg;
2397             }
2398             if (check.ilsevent == 3 /* NO_CHANGE */) {
2399                 //msg = 'This item is already checked in.\n';
2400                 check.what_happened = 'no_change';
2401                 if (document.getElementById('no_change_label')) {
2402                     var m = document.getElementById('no_change_label').getAttribute('value');
2403                     document.getElementById('no_change_label').setAttribute('value', m + document.getElementById('circStrings').getFormattedString('staff.circ.utils.item_checked_in', [params.barcode]) + '  ');
2404                     document.getElementById('no_change_label').setAttribute('hidden','false');
2405                 }
2406             }
2407             if (check.ilsevent == 1202 /* ITEM_NOT_CATALOGED */ && check.copy.status() != 11) {
2408                 check.what_happened = 'error';
2409                 var copy_status = (data.hash.ccs[ check.copy.status() ] ? data.hash.ccs[ check.copy.status() ].name() : check.copy.status().name() );
2410                 var err_msg = document.getElementById('commonStrings').getString('common.error');
2411                 err_msg += '\nFIXME --';
2412                 err_msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.item_not_cataloged', [copy_status]);
2413                 err_msg += '\n';
2414                 msg += err_msg;
2415                 print_data.error_msg += err_msg;
2416             }
2417             switch(Number(check.copy.status())) {
2418                 case 0: /* AVAILABLE */
2419                 case 7: /* RESHELVING */
2420                     check.what_happened = 'success';
2421                     if (msg) {
2422                         print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2423                         print_data.route_to = check.route_to;
2424                         msg += print_data.route_to_msg;
2425                         msg += '\n';
2426                     }
2427                 break;
2428                 case 8: /* ON HOLDS SHELF */
2429                     check.what_happened = 'hold_shelf';
2430                     check.route_to = document.getElementById('circStrings').getString('staff.circ.route_to.hold_shelf');
2431                     if (check.payload.hold) {
2432                         if (check.payload.hold.pickup_lib() != data.list.au[0].ws_ou()) {
2433                             check.what_happened = 'error';
2434                             var err_msg = document.getElementById('commonStrings').getString('common.error');
2435                             err_msg += '\nFIXME: ';
2436                             err_msg += document.getElementById('circStrings').getString('staff.circ.utils.route_item_error');
2437                             err_msg += '\n';
2438                             msg += err_msg;
2439                             print_data.error_msg += err_msg;
2440                         } else {
2441                             print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2442                             print_data.route_to = check.route_to;
2443                             var behind_the_desk_support = String( data.hash.aous['circ.holds.behind_desk_pickup_supported'] ) == 'true';
2444                             if (behind_the_desk_support) {
2445                                var usr_settings = network.simple_request('FM_AUS_RETRIEVE',[ses(),check.payload.hold.usr()]); 
2446                                 if (typeof usr_settings['circ.holds_behind_desk'] != 'undefined') {
2447                                     print_data.prefer_behind_holds_desk = true;
2448                                     check.route_to = document.getElementById('circStrings').getString('staff.circ.route_to.private_hold_shelf');
2449                                     print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2450                                     print_data.route_to = check.route_to;
2451                                 } else {
2452                                     check.route_to = document.getElementById('circStrings').getString('staff.circ.route_to.public_hold_shelf');
2453                                     print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2454                                     print_data.route_to = check.route_to;
2455                                 }
2456                             }
2457                             msg += print_data.route_to_msg;
2458                             msg += '\n';
2459                         }
2460                     } else {
2461                         check.what_happened = 'error';
2462                         var err_msg = document.getElementById('commonStrings').getString('common.error');
2463                         err_msg += '\nFIXME: ';
2464                         err_msg += document.getElementById('circStrings').getString('staff.circ.utils.route_item_status_error');
2465                         err_msg += '\n';
2466                         msg += err_msg;
2467                         print_data.error_msg += err_msg;
2468                     }
2469                     JSAN.use('util.date');
2470                     if (check.payload.hold) {
2471                         JSAN.use('patron.util');
2472                         msg += '\n';
2473                         print_data.item_barcode_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [check.payload.copy.barcode()]);
2474                         print_data.item_barcode = check.payload.copy.barcode();
2475                         msg += print_data.item_barcode_msg;
2476                         msg += '\n';
2477                         var payload_title  = (check.payload.record ? check.payload.record.title() : check.payload.copy.dummy_title() );
2478                         print_data.item_title_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.title', [payload_title]);
2479                         print_data.item_title = payload_title;
2480                         msg += print_data.item_title_msg;
2481                         msg += '\n';
2482                         var au_obj = patron.util.retrieve_fleshed_au_via_id( session, check.payload.hold.usr() );
2483                         print_data.user = au_obj;
2484                         msg += '\n';
2485                         if (au_obj.alias()) {
2486                             print_data.hold_for_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.patron_alias',  [au_obj.alias()]);
2487                             print_data.hold_for_alias = au_obj.alias();
2488                             msg += print_data.hold_for_msg;
2489                         } else {
2490                             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() : '']);
2491                             msg += print_data.hold_for_msg;
2492                             print_data.hold_for_family_name = au_obj.family_name() ? au_obj.family_name() : '';
2493                             print_data.hold_for_first_given_name = au_obj.first_given_name() ? au_obj.first_given_name() : '';
2494                             print_data.hold_for_second_given_name = au_obj.second_given_name() ? au_obj.second_given_name() : '';
2495                         }
2496                         msg += '\n';
2497                         print_data.user_barcode_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [au_obj.card().barcode()]);
2498                         print_data.user_barcode = au_obj.card().barcode();
2499                         msg += print_data.user_barcode_msg;
2500                         msg += '\n';
2501                         if (check.payload.hold.phone_notify()) {
2502                             print_data.notify_by_phone_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.phone_notify', [check.payload.hold.phone_notify()]);
2503                             print_data.notify_by_phone = check.payload.hold.phone_notify();
2504                             msg += print_data.notify_by_phone_msg;
2505                             msg += '\n';
2506                         }
2507                         if (get_bool(check.payload.hold.email_notify())) {
2508                             var payload_email = au_obj.email() ? au_obj.email() : '';
2509                             print_data.notify_by_email_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.email_notify', [payload_email]);
2510                             print_data.notify_by_email = payload_email;
2511                             msg += print_data.notify_by_email_msg;
2512                             msg += '\n';
2513                         }
2514                         msg += '\n';
2515                         var notes = check.payload.hold.notes();
2516                         print_data.notes_raw = notes;
2517                         for (var i = 0; i < notes.length; i++) {
2518                             if ( get_bool( notes[i].slip() ) ) {
2519                                 var temp_msg;
2520                                 if ( get_bool( notes[i].staff() ) ) {
2521                                     temp_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.notes.staff_note', [ notes[i].title(), notes[i].body() ]);
2522                                 } else {
2523                                     temp_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.notes.patron_note', [ notes[i].title(), notes[i].body() ]);
2524                                 }
2525                                 msg += temp_msg + '\n';
2526                                 print_list.push(
2527                                     {
2528                                         'formatted_note' : temp_msg,
2529                                         'note_title' : notes[i].title(),
2530                                         'note_body' : notes[i].body(),
2531                                         'note_public' : notes[i].pub(),
2532                                         'note_by_staff' : notes[i].staff()
2533                                     }
2534                                 );
2535                             }
2536                         }
2537                         msg += '\n';
2538                         msg += '\n';
2539                         print_data.request_date = util.date.formatted_date(check.payload.hold.request_time(),'%F');
2540                         print_data.request_date_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.request_date', [print_data.request_date]);
2541                         msg += print_data.request_date_msg;
2542                         msg += '\n';
2543                     }
2544                     var rv = 0;
2545                     var suppress_popups = data.hash.aous['ui.circ.suppress_checkin_popups'];
2546                     if (suppress_popups) {
2547                         rv = auto_print ? 0 : -1; auto_print = true; // skip dialog and PRINT or DO NOT PRINT based on Auto-Print checkbox
2548                     }
2549                     var x = data.hash.aous['circ.staff_client.do_not_auto_attempt_print'];
2550                     var no_print_prompting = x ? ( x.indexOf( "Hold Slip" ) > -1) : false;
2551                     if (no_print_prompting) {
2552                         rv = -1; auto_print = true; // DO NOT PRINT and skip dialog
2553                     }
2554                     print_data.slip_date = util.date.formatted_date(new Date(),'%F');
2555                     print_data.slip_date_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.slip_date', [print_data.slip_date]);
2556                     msg += print_data.slip_date_msg;
2557                     msg += '\n';
2558                     print_data.payload = check.payload;
2559
2560                     if (!auto_print) {
2561                         rv = error.yns_alert_formatted(
2562                             msg,
2563                             document.getElementById('circStrings').getString('staff.circ.utils.hold_slip'),
2564                             document.getElementById('circStrings').getString('staff.circ.utils.hold_slip.print.yes'),
2565                             document.getElementById('circStrings').getString('staff.circ.utils.hold_slip.print.no'),
2566                             null,
2567                             document.getElementById('circStrings').getString('staff.circ.confirm.msg'),
2568                             '/xul/server/skin/media/images/turtle.gif'
2569                         );
2570                     } else {
2571                         if (suppress_popups && !no_print_prompting) {
2572                             // FIXME: Add SFX and/or GFX
2573                             sound.circ_bad();
2574                         }
2575                     }
2576                     if (rv == 0) {
2577                         try {
2578                             JSAN.use('util.print'); var print = new util.print();
2579                             var old_template = String( data.hash.aous['ui.circ.old_harcoded_slip_template'] ) == 'true';
2580                             if (old_template) {
2581                                 msg = msg.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\n/g,'<br/>');
2582                                 print.simple( msg , { 'no_prompt' : true, 'content_type' : 'text/html' } );
2583                             } else {
2584                                 var template = 'hold_slip';
2585                                 var params = {
2586                                     'patron' : print_data.user,
2587                                     'lib' : data.hash.aou[ check.payload.hold.pickup_lib() ],
2588                                     'staff' : data.list.au[0],
2589                                     'header' : data.print_list_templates[ template ].header,
2590                                     'line_item' : data.print_list_templates[ template ].line_item,
2591                                     'footer' : data.print_list_templates[ template ].footer,
2592                                     'type' : data.print_list_templates[ template ].type,
2593                                     'list' : print_list,
2594                                     'data' : print_data
2595                                 };
2596                                 print.tree_list( params );
2597                             }
2598                         } catch(E) {
2599                             var err_msg = document.getElementById('commonStrings').getString('common.error');
2600                             err_msg += '\nFIXME: ' + E + '\n';
2601                             dump(err_msg);
2602                             alert(err_msg);
2603                         }
2604                     }
2605                     msg = '';
2606                     if (document.getElementById('no_change_label')) {
2607                         var m = document.getElementById('no_change_label').getAttribute('value');
2608                         m += document.getElementById('circStrings').getFormattedString('staff.circ.utils.capture', [params.barcode]);
2609                         document.getElementById('no_change_label').setAttribute('value', m);
2610                         document.getElementById('no_change_label').setAttribute('hidden','false');
2611                     }
2612                 break;
2613                 case 6: /* IN TRANSIT */
2614                     check.what_happened = 'error';
2615                     check.route_to = 'TRANSIT SHELF??';
2616                     print_data.route_to;
2617                     var err_msg = document.getElementById('commonStrings').getString('common.error');
2618                     err_msg += "\nFIXME -- I didn't think we could get here.\n";
2619                     print_data.error_msg += err_msg;
2620                     msg += err_msg;
2621                 break;
2622                 case 11: /* CATALOGING */
2623                     check.what_happened = 'cataloging';
2624                     check.route_to = 'CATALOGING';
2625                     print_data.route_to;
2626                     var suppress_popups = data.hash.aous['ui.circ.suppress_checkin_popups'];
2627                     var x = document.getElementById('do_not_alert_on_precat');
2628                     var do_not_alert_on_precats = x ? ( x.getAttribute('checked') == 'true' ) : false;
2629                     if ( !suppress_popups && !do_not_alert_on_precats ) {
2630                         print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2631                         msg += print_data.route_to_msg;
2632                     } else {
2633                         if (suppress_popups && !do_not_alert_on_precats) {
2634                             // FIXME: add SFX and/or GFX
2635                             sound.circ_bad();
2636                         }
2637                     }
2638                     if (document.getElementById('no_change_label')) {
2639                         var m = document.getElementById('no_change_label').getAttribute('value');
2640                         var needs_cat = document.getElementById('circStrings').getFormattedString('staff.circ.utils.needs_cataloging', [params.barcode]);
2641                         document.getElementById('no_change_label').setAttribute('value', m + needs_cat + '  ');
2642                         document.getElementById('no_change_label').setAttribute('hidden','false');
2643                     }
2644                 break;
2645                 default:
2646                     check.what_happened = 'error';
2647                     msg += document.getElementById('commonStrings').getString('common.error');
2648                     var copy_status = data.hash.ccs[check.copy.status()] ? data.hash.ccs[check.copy.status()].name() : check.copy.status().name();
2649                     msg += '\n';
2650                     var error_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.copy_status.error', [copy_status]);
2651                     print_data.error_msg += error_msg;
2652                     msg += error_msg;
2653                     msg += '\n';
2654                     print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2655                     msg += print_data.route_to_msg;
2656                 break;
2657             }
2658             if (msg) {
2659                 error.yns_alert(
2660                     msg,
2661                     document.getElementById('circStrings').getString('staff.circ.alert'),
2662                     null,
2663                     document.getElementById('circStrings').getString('staff.circ.utils.msg.ok'),
2664                     null,
2665                     document.getElementById('circStrings').getString('staff.circ.confirm.msg')
2666                 );
2667             }
2668         } else /* ROUTE_ITEM */ if (check.ilsevent == 7000) {
2669
2670             check.what_happened = 'transit';
2671             var lib = data.hash.aou[ check.org ];
2672             check.route_to = lib.shortname();
2673             print_data.route_to = check.route_to;
2674             print_data.route_to_org = lib;
2675             print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.destination', [check.route_to]);
2676             print_data.route_to_org_fullname = lib.name();
2677             var aous_req = network.simple_request('FM_AOUS_SPECIFIC_RETRIEVE',[ lib.id(), 'lib.courier_code', ses() ]);
2678             if (aous_req) {
2679                 print_data.courier_code = aous_req.value || '';
2680             }
2681             msg += print_data.route_to_msg;
2682             msg += '\n\n';
2683             msg += lib.name();
2684             msg += '\n';
2685             try {
2686                 if (lib.holds_address() ) {
2687                     var a = network.simple_request('FM_AOA_RETRIEVE',[ lib.holds_address() ]);
2688                     if (typeof a.ilsevent != 'undefined') throw(a);
2689                     if (a.street1()) { msg += a.street1() + '\n'; print_data.street1 = a.street1(); }
2690                     if (a.street2()) { msg += a.street2() + '\n'; print_data.street2 = a.street2(); }
2691                     print_data.city_state_zip = (a.city() ? a.city() + ', ' : '') + (a.state() ? a.state() + ' ' : '') + (a.post_code() ? a.post_code() : '');
2692                     print_data.city = a.city();
2693                     print_data.state = a.state();
2694                     print_data.county = a.county();
2695                     print_data.country = a.country();
2696                     print_data.post_code = a.post_code();
2697                     msg += print_data.city_state_zip + '\n';
2698                 } else {
2699                     print_data.street1 = document.getElementById('circStrings').getString('staff.circ.utils.route_to.no_address');
2700                     print_data.no_address = true;
2701                     msg += print_data.street1;
2702                     msg += '\n';
2703                 }
2704             } catch(E) {
2705                 var err_msg = document.getElementById('circStrings').getString('staff.circ.utils.route_to.no_address.error');
2706                 print_data.error_msg += err_msg + '\n';
2707                 msg += err_msg + '\n';
2708                 error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.utils.route_to.no_address.error'), E);
2709             }
2710             msg += '\n';
2711             print_data.item_barcode_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [check.payload.copy.barcode()]);
2712             print_data.item_barcode = check.payload.copy.barcode();
2713             msg += print_data.item_barcode_msg;
2714             msg += '\n';
2715             var payload_title  = (check.payload.record ? check.payload.record.title() : check.payload.copy.dummy_title() );
2716             print_data.item_title_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.title', [payload_title]);
2717             print_data.item_title = payload_title;
2718             msg += print_data.item_title_msg;
2719             msg += '\n';
2720             var payload_author = (check.payload.record ? check.payload.record.author() :check.payload.copy.dummy_author());
2721             print_data.item_author_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.author', [payload_author]);
2722             print_data.item_author = payload_author;
2723             msg += print_data.item_author_msg;
2724             msg += '\n';
2725             JSAN.use('util.date');
2726             if (check.payload.hold) {
2727                 check.what_happened = 'transit_for_hold';
2728                 JSAN.use('patron.util');
2729                 var au_obj = patron.util.retrieve_fleshed_au_via_id( session, check.payload.hold.usr() );
2730                 print_data.user = au_obj;
2731                 msg += '\n';
2732                 if (au_obj.alias()) {
2733                     print_data.hold_for_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.patron_alias',  [au_obj.alias()]);
2734                     print_data.hold_for_alias = au_obj.alias();
2735                     msg += print_data.hold_for_msg;
2736                 } else {
2737                     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() : '']);
2738                     msg += print_data.hold_for_msg;
2739                     print_data.hold_for_family_name = au_obj.family_name() ? au_obj.family_name() : '';
2740                     print_data.hold_for_first_given_name = au_obj.first_given_name() ? au_obj.first_given_name() : '';
2741                     print_data.hold_for_second_given_name = au_obj.second_given_name() ? au_obj.second_given_name() : '';
2742                 }
2743                 msg += '\n';
2744                 print_data.user_barcode_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [au_obj.card().barcode()]);
2745                 print_data.user_barcode = au_obj.card().barcode();
2746                 msg += print_data.user_barcode_msg;
2747                 msg += '\n';
2748                 if (check.payload.hold.phone_notify()) {
2749                     print_data.notify_by_phone_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.phone_notify', [check.payload.hold.phone_notify()]);
2750                     print_data.notify_by_phone = check.payload.hold.phone_notify();
2751                     msg += print_data.notify_by_phone_msg;
2752                     msg += '\n';
2753                 }
2754                 if (get_bool(check.payload.hold.email_notify())) {
2755                     var payload_email = au_obj.email() ? au_obj.email() : '';
2756                     print_data.notify_by_email_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.email_notify', [payload_email]);
2757                     print_data.notify_by_email = payload_email;
2758                     msg += print_data.notify_by_email_msg;
2759                     msg += '\n';
2760                 }
2761                 msg += '\n';
2762                 var notes = check.payload.hold.notes();
2763                 print_data.notes_raw = notes;
2764                 for (var i = 0; i < notes.length; i++) {
2765                     if ( get_bool( notes[i].slip() ) ) {
2766                         var temp_msg;
2767                         if ( get_bool( notes[i].staff() ) ) {
2768                             temp_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.notes.staff_note', [ notes[i].title(), notes[i].body() ]);
2769                         } else {
2770                             temp_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.notes.patron_note', [ notes[i].title(), notes[i].body() ]);
2771                         }
2772                         msg += temp_msg + '\n';
2773                         print_list.push(
2774                             {
2775                                 'formatted_note' : temp_msg,
2776                                 'note_title' : notes[i].title(),
2777                                 'note_body' : notes[i].body(),
2778                                 'note_public' : notes[i].pub(),
2779                                 'note_by_staff' : notes[i].staff()
2780                             }
2781                         );
2782                     }
2783                 }
2784                 msg += '\n';
2785                 msg += '\n';
2786                 print_data.request_date = util.date.formatted_date(check.payload.hold.request_time(),'%F');
2787                 print_data.request_date_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.request_date', [print_data.request_date]);
2788                 msg += print_data.request_date_msg;
2789                 msg += '\n';
2790             }
2791             var rv = 0;
2792             var suppress_popups = data.hash.aous['ui.circ.suppress_checkin_popups'];
2793             if (suppress_popups) {
2794                 rv = auto_print ? 0 : -1; auto_print = true; // skip dialog and PRINT or DO NOT PRINT based on Auto-Print checkbox
2795             }
2796             var x = data.hash.aous['circ.staff_client.do_not_auto_attempt_print'];
2797             var no_print_prompting = x ? (x.indexOf( check.payload.hold ? "Hold/Transit Slip" : "Transit Slip" ) > -1) : false;
2798             if (no_print_prompting) {
2799                 rv = -1; auto_print = true; // DO NOT PRINT and skip dialog
2800             }
2801             print_data.slip_date = util.date.formatted_date(new Date(),'%F');
2802             print_data.slip_date_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.slip_date', [print_data.slip_date]);
2803             msg += print_data.slip_date_msg;
2804             print_data.payload = check.payload;
2805
2806             if (!auto_print) {
2807                 rv = error.yns_alert_formatted(
2808                     msg,
2809                     document.getElementById('circStrings').getString('staff.circ.utils.transit_slip'),
2810                     document.getElementById('circStrings').getString('staff.circ.utils.transit_slip.print.yes'),
2811                     document.getElementById('circStrings').getString('staff.circ.utils.transit_slip.print.no'),
2812                     null,
2813                     document.getElementById('circStrings').getString('staff.circ.confirm.msg'),
2814                     '/xul/server/skin/media/images/turtle.gif'
2815                 );
2816             } else {
2817                 if (suppress_popups && !no_print_prompting) {
2818                     // FIXME: add SFX and/or GFX
2819                     sound.circ_bad();
2820                 }
2821             }
2822             if (rv == 0) {
2823                 try {
2824                     JSAN.use('util.print'); var print = new util.print();
2825                     var old_template = String( data.hash.aous['ui.circ.old_harcoded_slip_template'] ) == 'true';
2826                     if (old_template) {
2827                         msg = msg.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\n/g,'<br/>');
2828                         print.simple( msg , { 'no_prompt' : true, 'content_type' : 'text/html' } );
2829                     } else {
2830                         var template = check.payload.hold ? 'hold_transit_slip' : 'transit_slip';
2831                         var params = {
2832                             'patron' : print_data.user,
2833                             'lib' : data.hash.aou[ check.payload.hold ? check.payload.hold.pickup_lib() : check.payload.transit.source() ],
2834                             'staff' : data.list.au[0],
2835                             'header' : data.print_list_templates[ template ].header,
2836                             'line_item' : data.print_list_templates[ template ].line_item,
2837                             'footer' : data.print_list_templates[ template ].footer,
2838                             'type' : data.print_list_templates[ template ].type,
2839                             'list' : print_list,
2840                             'data' : print_data 
2841                         };
2842                         print.tree_list( params );
2843                     }
2844                 } catch(E) {
2845                     var err_msg = document.getElementById('commonStrings').getString('common.error');
2846                     err_msg += '\nFIXME: ' + E + '\n';
2847                     dump(err_msg);
2848                     alert(err_msg);
2849                 }
2850             }
2851             if (document.getElementById('no_change_label')) {
2852                 var m = document.getElementById('no_change_label').getAttribute('value');
2853                 var trans_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.in_transit', [params.barcode]);
2854                 document.getElementById('no_change_label').setAttribute('value', m + trans_msg + '  ');
2855                 document.getElementById('no_change_label').setAttribute('hidden','false');
2856             }
2857
2858         } else /* ASSET_COPY_NOT_FOUND */ if (check.ilsevent == 1502) {
2859
2860             check.what_happened = 'not_found';
2861             check.route_to = 'CATALOGING';
2862             var mis_scan_msg = document.getElementById('circStrings').getFormattedString('staff.circ.copy_status.status.copy_not_found', [params.barcode]);
2863             var suppress_popups = data.hash.aous['ui.circ.suppress_checkin_popups'];
2864             if (!suppress_popups) {
2865                 error.yns_alert(
2866                     mis_scan_msg,
2867                     document.getElementById('circStrings').getString('staff.circ.alert'),
2868                     null,
2869                     document.getElementById('circStrings').getString('staff.circ.utils.msg.ok'),
2870                     null,
2871                     document.getElementById('circStrings').getString('staff.circ.confirm.msg')
2872                 );
2873             } else {
2874                 // FIXME: add SFX and/or GFX
2875                 sound.circ_bad();
2876             }
2877             if (document.getElementById('no_change_label')) {
2878                 var m = document.getElementById('no_change_label').getAttribute('value');
2879                 document.getElementById('no_change_label').setAttribute('value',m + mis_scan_msg + '  ');
2880                 document.getElementById('no_change_label').setAttribute('hidden','false');
2881             }
2882
2883         } else /* HOLD_CAPTURE_DELAYED */ if (check.ilsevent == 7019) {
2884
2885             check.what_happened = 'hold_capture_delayed';
2886             var rv = 0;
2887             msg += document.getElementById('circStrings').getString('staff.circ.utils.hold_capture_delayed.description');
2888             var suppress_popups = data.hash.aous['ui.circ.suppress_checkin_popupst'];
2889             if (!suppress_popups) {
2890                 rv = error.yns_alert_formatted(
2891                     msg,
2892                     document.getElementById('circStrings').getString('staff.circ.utils.hold_capture_delayed.titlebar'),
2893                     document.getElementById('circStrings').getString('staff.circ.utils.hold_capture_delayed.prompt_for_nocapture'),
2894                     document.getElementById('circStrings').getString('staff.circ.utils.hold_capture_delayed.prompt_for_capture'),
2895                     null,
2896                     document.getElementById('circStrings').getString('staff.circ.confirm.msg'),
2897                     '/xul/server/skin/media/images/stop_sign.png'
2898                 );
2899             } else {
2900                 // FIXME: add SFX and/or GFX
2901                 sound.circ_bad();
2902             }
2903             params.capture = rv == 0 ? 'nocapture' : 'capture';
2904
2905             return circ.util.checkin_via_barcode(session,params,backdate,auto_print,false);
2906
2907         } else /* NETWORK TIMEOUT */ if (check.ilsevent == -1) {
2908             check.what_happened = 'error';
2909             error.standard_network_error_alert(document.getElementById('circStrings').getString('staff.circ.checkin.suggest_offline'));
2910         } else {
2911
2912             if (check.ilsevent == null) { return null; /* handled */ }
2913             switch (Number(check.ilsevent)) {
2914                 case 1203 /* COPY_BAD_STATUS */ :
2915                 case 1213 /* PATRON_BARRED */ :
2916                 case 1217 /* PATRON_INACTIVE */ :
2917                 case 1224 /* PATRON_ACCOUNT_EXPIRED */ :
2918                 case 1234 /* ITEM_DEPOSIT_PAID */ :
2919                 case 7009 /* CIRC_CLAIMS_RETURNED */ :
2920                 case 7010 /* COPY_ALERT_MESSAGE */ :
2921                 case 7011 /* COPY_STATUS_LOST */ :
2922                 case 7012 /* COPY_STATUS_MISSING */ :
2923                 case 7013 /* PATRON_EXCEEDS_FINES */ :
2924                     return null; /* handled */
2925                 break;
2926             }
2927
2928             throw(check);
2929
2930         }
2931
2932         return check;
2933     } catch(E) {
2934         JSAN.use('util.error'); var error = new util.error();
2935         error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.error', ['3']), E);
2936         return null;
2937     }
2938 };
2939
2940 circ.util.renew_via_barcode = function ( params, async ) {
2941     try {
2942         var obj = {};
2943         JSAN.use('util.network'); obj.network = new util.network();
2944         JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.stash_retrieve();
2945
2946         function renew_callback(req) {
2947             try {
2948                 JSAN.use('util.error'); var error = new util.error();
2949                 var renew = req.getResultObject();
2950                 if (typeof renew.ilsevent != 'undefined') renew = [ renew ];
2951                 for (var j = 0; j < renew.length; j++) {
2952                     switch(renew[j].ilsevent == null ? null : Number(renew[j].ilsevent)) {
2953                         case 0 /* SUCCESS */ : break;
2954                         case null /* custom event */ : break;
2955                         case 5000 /* PERM_FAILURE */: break;
2956                         case 1212 /* PATRON_EXCEEDS_OVERDUE_COUNT */ : break;
2957                         case 1213 /* PATRON_BARRED */ : break;
2958                         case 1215 /* CIRC_EXCEEDS_COPY_RANGE */ : break;
2959                         case 1224 /* PATRON_ACCOUNT_EXPIRED */ : break;
2960                         case 1232 /* ITEM_DEPOSIT_REQUIRED */ : break;
2961                         case 1233 /* ITEM_RENTAL_FEE_REQUIRED */ : break;
2962                         case 1234 /* ITEM_DEPOSIT_PAID */ : break;
2963                         case 1500 /* ACTION_CIRCULATION_NOT_FOUND */ : break;
2964                         case 1502 /* ASSET_COPY_NOT_FOUND */ : 
2965                             var mis_scan_msg = document.getElementById('circStrings').getFormattedString('staff.circ.copy_status.status.copy_not_found', [params.barcode]);
2966                             error.yns_alert(
2967                                 mis_scan_msg,
2968                                 document.getElementById('circStrings').getString('staff.circ.alert'),
2969                                 null,
2970                                 document.getElementById('circStrings').getString('staff.circ.utils.msg.ok'),
2971                                 null,
2972                                 document.getElementById('circStrings').getString('staff.circ.confirm.msg')
2973                             );
2974                             if (document.getElementById('no_change_label')) {
2975                                 var m = document.getElementById('no_change_label').getAttribute('value');
2976                                 document.getElementById('no_change_label').setAttribute('value',m + mis_scan_msg + '  ');
2977                                 document.getElementById('no_change_label').setAttribute('hidden','false');
2978                             }
2979                         break;
2980                         case 7002 /* PATRON_EXCEEDS_CHECKOUT_COUNT */ : break;
2981                         case 7003 /* COPY_CIRC_NOT_ALLOWED */ : break;
2982                         case 7004 /* COPY_NOT_AVAILABLE */ : break;
2983                         case 7006 /* COPY_IS_REFERENCE */ : break;
2984                         case 7007 /* COPY_NEEDED_FOR_HOLD */ : break;
2985                         case 7008 /* MAX_RENEWALS_REACHED */ : break;
2986                         case 7009 /* CIRC_CLAIMS_RETURNED */ : break;
2987                         case 7010 /* COPY_ALERT_MESSAGE */ : break;
2988                         case 7013 /* PATRON_EXCEEDS_FINES */ : break;
2989                         default:
2990                             throw(renew);
2991                         break;
2992                     }
2993                 }
2994                 try {
2995                     var ibarcode = renew[0].payload.copy ? renew[0].payload.copy.barcode() : params.barcode;
2996                     var p_id = renew[0].payload.patron ? renew[0].payload.patron.id() : renew[0].payload.circ.usr();
2997                     var pname; var pbarcode; 
2998                     if (renew[0].patron) {
2999                         pname = renew[0].payload.patron.family_name();
3000                         pbarcode = typeof renew[0].payload.patron.card() == 'object' ? renew[0].payload.patron.card().barcode() : null;
3001                     } else {
3002                         if (circ.util.renew_via_barcode.last_usr_id == p_id) {
3003                             pname = circ.util.renew_via_barcode.last_pname;
3004                             pbarcode = circ.util.renew_via_barcode.last_pbarcode;
3005                         } else {
3006                             JSAN.use('patron.util'); var p = patron.util.retrieve_fleshed_au_via_id(ses(),p_id);
3007                             pname = p.family_name();
3008                             pbarcode = typeof p.card() == 'object' ? p.card().barcode() : null;
3009                             if (pname) {
3010                                 circ.util.renew_via_barcode.last_usr_id = p_id;
3011                                 circ.util.renew_via_barcode.last_pname = pname;
3012                                 circ.util.renew_via_barcode.last_pbarcode = pbarcode;
3013                             }
3014                         } 
3015                     }
3016                     error.work_log(
3017                         document.getElementById('circStrings').getFormattedString(
3018                             'staff.circ.work_log_renew.message',
3019                             [
3020                                 ses('staff_usrname'),
3021                                 pname ? pname : '???',
3022                                 pbarcode ? pbarcode : '???',
3023                                 ibarcode ? ibarcode : '???'
3024                             ]
3025                         ), {
3026                             'au_id' : p_id,
3027                             'au_family_name' : pname,
3028                             'au_barcode' : pbarcode,
3029                             'acp_barcode' : ibarcode
3030                         }
3031                     );
3032                 } catch(E) {
3033                     error.sdump('D_ERROR','Error with work_logging in server/circ/util.js, renew_via_barcode():' + E);
3034                 }
3035                 if (typeof async == 'function') async(renew);
3036                 return renew;
3037             } catch(E) {
3038                 JSAN.use('util.error'); var error = new util.error();
3039                 error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.renew_failed.error', [params.barcode]), E);
3040                 return null;
3041             }
3042         }
3043
3044         var renew = obj.network.simple_request(
3045             'CHECKOUT_RENEW',
3046             [ ses(), params ],
3047             async ? renew_callback : null,
3048             {
3049                 'title' : document.getElementById('circStrings').getString('staff.circ.checkin.renew_failed.override'),
3050                 'overridable_events' : [
3051                     null /* custom event */,
3052                     1212 /* PATRON_EXCEEDS_OVERDUE_COUNT */,
3053                     1213 /* PATRON_BARRED */,
3054                     1215 /* CIRC_EXCEEDS_COPY_RANGE */,
3055                     1232 /* ITEM_DEPOSIT_REQUIRED */,
3056                     1233 /* ITEM_RENTAL_FEE_REQUIRED */,
3057                     1234 /* ITEM_DEPOSIT_PAID */,
3058                     7002 /* PATRON_EXCEEDS_CHECKOUT_COUNT */,
3059                     7003 /* COPY_CIRC_NOT_ALLOWED */,
3060                     7004 /* COPY_NOT_AVAILABLE */,
3061                     7006 /* COPY_IS_REFERENCE */,
3062                     7007 /* COPY_NEEDED_FOR_HOLD */,
3063                     7008 /* MAX_RENEWALS_REACHED */,
3064                     7009 /* CIRC_CLAIMS_RETURNED */,
3065                     7010 /* COPY_ALERT_MESSAGE */,
3066                     7013 /* PATRON_EXCEEDS_FINES */,
3067                 ],
3068                 'text' : {
3069                     '1212' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
3070                     '1213' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
3071                     '1215' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
3072                     '1232' : function(r) {
3073                         return document.getElementById('circStrings').getFormattedString('staff.circ.renew.override.item_deposit_required.warning.barcode', [params.barcode]);
3074                     },
3075                     '1233' : function(r) {
3076                         return document.getElementById('circStrings').getFormattedString('staff.circ.renew.override.item_rental_fee_required.warning.barcode', [params.barcode]);
3077                     },
3078                     '1234' : function(r) {
3079                         return document.getElementById('circStrings').getFormattedString('staff.circ.utils.checkin.override.item_deposit_paid.warning');
3080                     },
3081                     '7002' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
3082                     '7003' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
3083                     '7004' : function(r) {
3084                         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()]);
3085                     },
3086                     '7006' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
3087                     '7007' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
3088                     '7008' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
3089                     '7009' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
3090                     '7010' : function(r) {
3091                         return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode.msg', [params.barcode, r.payload]);
3092                     },
3093                     '7013' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); }
3094                 }
3095             }
3096         );
3097         if (! async ) {
3098             return renew_callback( { 'getResultObject' : function() { return renew; } } );
3099         }
3100
3101     } catch(E) {
3102         JSAN.use('util.error'); var error = new util.error();
3103         error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.renew_failed.error', [params.barcode]), E);
3104         return null;
3105     }
3106 };
3107
3108 circ.util.batch_hold_update = function ( hold_ids, field_changes, params ) {
3109     try {
3110         JSAN.use('util.sound'); var sound = new util.sound();
3111         var change_list = []; var idx = -1; var bad_holds = [];
3112         dojo.forEach(
3113             hold_ids,
3114             function(el) {
3115                 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?
3116             }
3117         );
3118         if (params.progressmeter) { params.progressmeter.value = 0; params.progressmeter.hidden = false; }
3119         fieldmapper.standardRequest(
3120             [ api.FM_AHR_UPDATE_BATCH.app, api.FM_AHR_UPDATE_BATCH.method ],
3121             {   async: true,
3122                 params: [ses(), null, change_list],
3123                 onresponse: function(r) {
3124                     idx++; 
3125                     if (params.progressmeter) { params.progressmeter.value = Number( params.progressmeter.value ) + 100/hold_ids.length; }
3126                     var result = r.recv().content();
3127                     if (result != hold_ids[ idx ]) {
3128                         bad_holds.push( { 'hold_id' : hold_ids[ idx ], 'result' : result } );
3129                     }
3130                 },
3131                 oncomplete: function() {
3132                     if (bad_holds.length > 0) {
3133                         sound.circ_bad();
3134                         alert( $('circStrings').getFormattedString('staff.circ.hold_update.hold_ids.failed',[ bad_holds.length ]) );
3135                     } else {
3136                         sound.circ_good();
3137                     }
3138                     if (typeof params.oncomplete == 'function') {
3139                         params.oncomplete( bad_holds );
3140                     }
3141                     if (params.progressmeter) { params.progressmeter.value = 0; params.progressmeter.hidden = true; }
3142                 },
3143                 onerror: function(r) {
3144                     alert('Error in circ/util.js, batch_hold_update(), onerror: ' + r);
3145                 }
3146             }
3147         );
3148     } catch(E) {
3149         alert('Error in circ.util.js, circ.util.batch_hold_update(): ' + E);
3150     }
3151 };
3152
3153 circ.util.find_acq_po = function(session, copy_id) {
3154     dojo.require("openils.Util");
3155     fieldmapper.standardRequest(
3156         ["open-ils.acq", "open-ils.acq.lineitem.retrieve.by_copy_id"], {
3157             "params": [session, copy_id, {"clear_marc": true}],
3158             "onresponse": function(r) {
3159                 if (r = openils.Util.readResponse(r)) {
3160                     if (r.purchase_order()) {
3161                         var url = urls.XUL_BROWSER + "?url=" +
3162                             xulG.url_prefix(
3163                                 escape(urls.EG_ACQ_PO_VIEW +
3164                                     "/" + r.purchase_order() + "/" + r.id())
3165                             );
3166                         window.xulG.new_tab(
3167                             url, {"browser": true}, {
3168                                 "no_xulG": false,
3169                                 "show_print_button": false,
3170                                 "show_nav_buttons": true
3171                             }
3172                         );
3173                     } else {
3174                         /* unlikely: got an LI with no PO */
3175                         alert(dojo.byId("circStrings").getFormattedString(
3176                             "staff.circ.utils.find_acq_po.no_po", [r.id()]
3177                         ));
3178                     }
3179                 }
3180             }
3181         }
3182     );
3183 };
3184
3185 dump('exiting circ/util.js\n');