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