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