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