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