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