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