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