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