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