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