]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/xul/staff_client/server/circ/util.js
typos, and working around the fun JSON number/text casting issue
[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', 'renew_via_barcode'
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 } );
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                                         var url = urls.XUL_PATRON_DISPLAY; // + '?id=' + window.escape( patrons[j] );
76                                         window.xulG.new_tab( url, {}, { 'id' : patrons[j] } );
77                                 } catch(E) {
78                                         obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.utils.retrieve_patron.failure'), E);
79                                 }
80                         }
81                 }
82
83         } catch(E) {
84                 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.utils.retrieve_copy.failure'),E);
85         }
86 };
87
88
89 circ.util.show_last_few_circs = function(selection_list,count) {
90         var obj = {};
91         JSAN.use('util.error'); obj.error = new util.error();
92         JSAN.use('util.window'); obj.win = new util.window();
93         JSAN.use('util.network'); obj.network = new util.network();
94         JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
95
96         if (!count) count = 4;
97
98         for (var i = 0; i < selection_list.length; i++) {
99                 try {
100                         if (typeof selection_list[i].copy_id == 'undefined' || selection_list[i].copy_id == null) continue;
101                         var url = xulG.url_prefix( urls.XUL_CIRC_SUMMARY ); // + '?copy_id=' + selection_list[i].copy_id + '&count=' + count;
102                         var my_xulG = obj.win.open( url, 'show_last_few_circs', 'chrome,resizable,modal', { 'copy_id' : selection_list[i].copy_id, 'count' : count } );
103
104                         if (typeof my_xulG.retrieve_these_patrons == 'undefined') continue;
105                         var patrons = my_xulG.retrieve_these_patrons;
106                         for (var j = 0; j < patrons.length; j++) {
107                                 if (typeof window.xulG == 'object' && typeof window.xulG.new_tab == 'function') {
108                                         try {
109                                                 var url = urls.XUL_PATRON_DISPLAY; // + '?id=' + window.escape( patrons[j] );
110                                                 window.xulG.new_tab( url, {}, { 'id' : patrons[j] } );
111                                         } catch(E) {
112                                                 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.utils.retrieve_patron.failure') ,E);
113                                         }
114                                 }
115                         }
116
117                 } catch(E) {
118                         obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.utils.retrieve_circs.failure') ,E);
119                 }
120         }
121 };
122
123 circ.util.offline_checkout_columns = function(modify,params) {
124         
125         var c = [
126                 {
127                         'id' : 'timestamp',
128                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.timestamp'),
129                         'flex' : 1,
130                         'primary' : false,
131                         'hidden' : true,
132                         'render' : function(my) { return my.timestamp; }
133                 },
134                 {
135                         'id' : 'checkout_time',
136                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.checkout_time'),
137                         'flex' : 1,
138                         'primary' : false,
139                         'hidden' : true,
140                         'render' : function(my) { return my.checkout_time; }
141                 },
142                 {
143                         'id' : 'type',
144                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.type'),
145                         'flex' : 1,
146                         'primary' : false,
147                         'hidden' : true,
148                         'render' : function(my) { return my.type; }
149                 },
150                 {
151                         'id' : 'noncat',
152                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.noncat'),
153                         'flex' : 1,
154                         'primary' : false,
155                         'hidden' : true,
156                         'render' : function(my) { return my.noncat; }
157                 },
158                 {
159                         'id' : 'noncat_type',
160                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.noncat_type'),
161                         'flex' : 1,
162                         'primary' : false,
163                         'hidden' : true,
164                         'render' : function(my) { return my.noncat_type; }
165                 },
166                 {
167                         'id' : 'noncat_count',
168                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.count'),
169                         'sort_type' : 'number',
170                         'flex' : 1,
171                         'primary' : false,
172                         'hidden' : false,
173                         'render' : function(my) { return my.noncat_count; }
174                 },
175                 {
176                         'id' : 'patron_barcode',
177                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.patron_barcode'),
178                         'flex' : 1,
179                         'primary' : false,
180                         'hidden' : true,
181                         'render' : function(my) { return my.patron_barcode; }
182                 },
183                 {
184                         'id' : 'barcode',
185                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.item_barcode'),
186                         'flex' : 2,
187                         'primary' : true,
188                         'hidden' : false,
189                         'render' : function(my) { return my.barcode; }
190                 },
191                 {
192                         'id' : 'due_date',
193                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.due_date'),
194                         'flex' : 1,
195                         'primary' : false,
196                         'hidden' : false,
197                         'render' : function(my) { return my.due_date; }
198                 }
199         ];
200         if (modify) for (var i = 0; i < c.length; i++) {
201                 if (modify[ c[i].id ]) {
202                         for (var j in modify[ c[i].id ]) {
203                                 c[i][j] = modify[ c[i].id ][j];
204                         }
205                 }
206         }
207         if (params) {
208                 if (params.just_these) {
209                         JSAN.use('util.functional');
210                         var new_c = [];
211                         for (var i = 0; i < params.just_these.length; i++) {
212                                 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
213                                 new_c.push( function(y){ return y; }( x ) );
214                         }
215                         c = new_c;
216                 }
217                 if (params.except_these) {
218                         JSAN.use('util.functional');
219                         var new_c = [];
220                         for (var i = 0; i < c.length; i++) {
221                                 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
222                                 if (!x) new_c.push(c[i]);
223                         }
224                         c = new_c;
225                 }
226
227         }
228         return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
229 };
230
231 circ.util.offline_checkin_columns = function(modify,params) {
232         
233         var c = [
234                 {
235                         'id' : 'timestamp',
236                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.timestamp'),
237                         'flex' : 1,
238                         'primary' : false,
239                         'hidden' : true,
240                         'render' : function(my) { return my.timestamp; }
241                 },
242                 {
243                         'id' : 'backdate',
244                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.backdate'),
245                         'flex' : 1,
246                         'primary' : false,
247                         'hidden' : true,
248                         'render' : function(my) { return my.backdate; }
249                 },
250                 {
251                         'id' : 'type',
252                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.type'),
253                         'flex' : 1,
254                         'primary' : false,
255                         'hidden' : true,
256                         'render' : function(my) { return my.type; }
257                 },
258                 {
259                         'id' : 'barcode',
260                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.item_barcode'),
261                         'flex' : 2,
262                         'primary' : true,
263                         'hidden' : false,
264                         'render' : function(my) { return my.barcode; }
265                 }
266         ];
267         if (modify) for (var i = 0; i < c.length; i++) {
268                 if (modify[ c[i].id ]) {
269                         for (var j in modify[ c[i].id ]) {
270                                 c[i][j] = modify[ c[i].id ][j];
271                         }
272                 }
273         }
274         if (params) {
275                 if (params.just_these) {
276                         JSAN.use('util.functional');
277                         var new_c = [];
278                         for (var i = 0; i < params.just_these.length; i++) {
279                                 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
280                                 new_c.push( function(y){ return y; }( x ) );
281                         }
282                         c = new_c;
283                 }
284                 if (params.except_these) {
285                         JSAN.use('util.functional');
286                         var new_c = [];
287                         for (var i = 0; i < c.length; i++) {
288                                 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
289                                 if (!x) new_c.push(c[i]);
290                         }
291                         c = new_c;
292                 }
293
294         }
295         return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
296 };
297
298 circ.util.offline_renew_columns = function(modify,params) {
299         
300         var c = [
301                 {
302                         'id' : 'timestamp',
303                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.timestamp'),
304                         'flex' : 1,
305                         'primary' : false,
306                         'hidden' : true,
307                         'render' : function(my) { return my.timestamp; }
308                 },
309                 {
310                         'id' : 'checkout_time',
311                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.checkout_time'),
312                         'flex' : 1,
313                         'primary' : false,
314                         'hidden' : true,
315                         'render' : function(my) { return my.checkout_time; }
316                 },
317                 {
318                         'id' : 'type',
319                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.type'),
320                         'flex' : 1,
321                         'primary' : false,
322                         'hidden' : true,
323                         'render' : function(my) { return my.type; }
324                 },
325                 {
326                         'id' : 'patron_barcode',
327                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.patron_barcode'),
328                         'flex' : 1,
329                         'primary' : false,
330                         'hidden' : true,
331                         'render' : function(my) { return my.patron_barcode; }
332                 },
333                 {
334                         'id' : 'barcode',
335                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.item_barcode'),
336                         'flex' : 2,
337                         'primary' : true,
338                         'hidden' : false,
339                         'render' : function(my) { return my.barcode; }
340                 },
341                 {
342                         'id' : 'due_date',
343                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.due_date'),
344                         'flex' : 1,
345                         'primary' : false,
346                         'hidden' : false,
347                         'render' : function(my) { return my.due_date; }
348                 }
349         ];
350         if (modify) for (var i = 0; i < c.length; i++) {
351                 if (modify[ c[i].id ]) {
352                         for (var j in modify[ c[i].id ]) {
353                                 c[i][j] = modify[ c[i].id ][j];
354                         }
355                 }
356         }
357         if (params) {
358                 if (params.just_these) {
359                         JSAN.use('util.functional');
360                         var new_c = [];
361                         for (var i = 0; i < params.just_these.length; i++) {
362                                 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
363                                 new_c.push( function(y){ return y; }( x ) );
364                         }
365                         c = new_c;
366                 }
367                 if (params.except_these) {
368                         JSAN.use('util.functional');
369                         var new_c = [];
370                         for (var i = 0; i < c.length; i++) {
371                                 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
372                                 if (!x) new_c.push(c[i]);
373                         }
374                         c = new_c;
375                 }
376
377         }
378         return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
379 };
380
381 circ.util.offline_inhouse_use_columns = function(modify,params) {
382         
383         var c = [
384                 {
385                         'id' : 'timestamp',
386                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.timestamp'),
387                         'flex' : 1,
388                         'primary' : false,
389                         'hidden' : true,
390                         'render' : function(my) { return my.timestamp; }
391                 },
392                 {
393                         'id' : 'use_time',
394                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.use_time'),
395                         'flex' : 1,
396                         'primary' : false,
397                         'hidden' : true,
398                         'render' : function(my) { return my.use_time; }
399                 },
400                 {
401                         'id' : 'type',
402                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.type'),
403                         'flex' : 1,
404                         'primary' : false,
405                         'hidden' : true,
406                         'render' : function(my) { return my.type; }
407                 },
408                 {
409                         'id' : 'count',
410                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.count'),
411                         'sort_type' : 'number',
412                         'flex' : 1,
413                         'primary' : false,
414                         'hidden' : false,
415                         'render' : function(my) { return my.count; }
416                 },
417                 {
418                         'id' : 'barcode',
419                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.item_barcode'),
420                         'flex' : 2,
421                         'primary' : true,
422                         'hidden' : false,
423                         'render' : function(my) { return my.barcode; }
424                 }
425         ];
426         if (modify) for (var i = 0; i < c.length; i++) {
427                 if (modify[ c[i].id ]) {
428                         for (var j in modify[ c[i].id ]) {
429                                 c[i][j] = modify[ c[i].id ][j];
430                         }
431                 }
432         }
433         if (params) {
434                 if (params.just_these) {
435                         JSAN.use('util.functional');
436                         var new_c = [];
437                         for (var i = 0; i < params.just_these.length; i++) {
438                                 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
439                                 new_c.push( function(y){ return y; }( x ) );
440                         }
441                         c = new_c;
442                 }
443                 if (params.except_these) {
444                         JSAN.use('util.functional');
445                         var new_c = [];
446                         for (var i = 0; i < c.length; i++) {
447                                 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
448                                 if (!x) new_c.push(c[i]);
449                         }
450                         c = new_c;
451                 }
452
453         }
454         return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
455 };
456
457 circ.util.columns = function(modify,params) {
458         
459         JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
460         JSAN.use('util.network'); var network = new util.network();
461         JSAN.use('util.money');
462
463         var c = [
464                 {
465                         'id' : 'acp_id',
466                         'label' : document.getElementById('commonStrings').getString('staff.acp_label_id'),
467                         'flex' : 1,
468                         'primary' : false,
469                         'hidden' : true,
470                         'render' : function(my) { return my.acp.id(); },
471                         'persist' : 'hidden width ordinal'
472                 },
473                 {
474                         'id' : 'circ_id',
475                         'label' : document.getElementById('commonStrings').getString('staff.circ_label_id'),
476                         'flex' : 1,
477                         'primary' : false,
478                         'hidden' : true,
479                         'render' : function(my) { return my.circ ? my.circ.id() : ( my.acp.circulations() ? my.acp.circulations()[0].id() : ""); },
480                         'persist' : 'hidden width ordinal'
481                 },
482                 {
483                         'id' : 'mvr_doc_id',
484                         'label' : document.getElementById('commonStrings').getString('staff.mvr_label_doc_id'),
485                         'flex' : 1,
486                         'primary' : false,
487                         'hidden' : true,
488                         'render' : function(my) { return my.mvr.doc_id(); },
489                         'persist' : 'hidden width ordinal'
490                 },
491         {
492                         'persist' : 'hidden width ordinal',
493                         'id' : 'service',
494                         'label' : 'Service',
495                         'flex' : 1,
496                         'primary' : false,
497                         'hidden' : true,
498                         'render' : function(my) { return my.service; }
499         },
500                 {
501                         'id' : 'barcode',
502                         'label' : document.getElementById('commonStrings').getString('staff.acp_label_barcode'),
503                         'flex' : 1,
504                         'primary' : false,
505                         'hidden' : true,
506                         'render' : function(my) { return my.acp.barcode(); },
507                         'persist' : 'hidden width ordinal'
508                 },
509                 {
510                         'id' : 'call_number',
511                         'label' : document.getElementById('commonStrings').getString('staff.acp_label_call_number'),
512                         'flex' : 1,
513                         'primary' : false,
514                         'hidden' : true,
515                         'render' : function(my) {
516                                 if (my.acp && my.acp.call_number() == -1) {
517                                         return document.getElementById('circStrings').getString('staff.circ.utils.not_cataloged');
518                                 } else {
519                                         if (!my.acn) {
520                                                 var x = network.simple_request("FM_ACN_RETRIEVE",[ my.acp.call_number() ]);
521                                                 if (x.ilsevent) {
522                                                         return document.getElementById('circStrings').getString('staff.circ.utils.not_cataloged');
523                                                 } else {
524                                                         my.acn = x; return x.label();
525                                                 }
526                                         } else {
527                                                 return my.acn.label();
528                                         }
529                                 }
530                         },
531                         'persist' : 'hidden width ordinal'
532                 },
533                 {
534                         'id' : 'owning_lib',
535                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.owning_lib'),
536                         'flex' : 1,
537                         'primary' : false,
538                         'hidden' : true,
539                         'render' : function(my) {
540                                 if (Number(my.acn.owning_lib())>=0) {
541                                         return data.hash.aou[ my.acn.owning_lib() ].shortname();
542                                 } else {
543                                         return my.acn.owning_lib().shortname();
544                                 }
545                         },
546                         'persist' : 'hidden width ordinal'
547                 },
548                 {
549                         'id' : 'copy_number',
550                         'label' : document.getElementById('commonStrings').getString('staff.acp_label_copy_number'),
551                         'flex' : 1,
552                         'sort_type' : 'number',
553                         'primary' : false,
554                         'hidden' : true,
555                         'render' : function(my) { return my.acp.copy_number(); },
556                         'persist' : 'hidden width ordinal'
557                 },
558                 {
559                         'id' : 'location',
560                         'label' : document.getElementById('commonStrings').getString('staff.acp_label_location'),
561                         'flex' : 1,
562                         'primary' : false,
563                         'hidden' : true,
564                         'render' : function(my) {
565                                 if (Number(my.acp.location())>=0) {
566                                         return data.lookup("acpl", my.acp.location() ).name();
567                                 } else {
568                                         return my.acp.location().name();
569                                 }
570                         },
571                         'persist' : 'hidden width ordinal'
572                 },
573                 {
574                         'id' : 'loan_duration',
575                         'label' : document.getElementById('commonStrings').getString('staff.acp_label_loan_duration'),
576                         'flex' : 1,
577                         'primary' : false,
578                         'hidden' : true,
579                         'render' : function(my) {
580                                 switch(Number(my.acp.loan_duration())) {
581                                         case 1:
582                                                 return document.getElementById('circStrings').getString('staff.circ.utils.loan_duration.short');
583                                                 break;
584                                         case 2:
585                                                 return document.getElementById('circStrings').getString('staff.circ.utils.loan_duration.normal');
586                                                 break;
587                                         case 3:
588                                                 return document.getElementById('circStrings').getString('staff.circ.utils.loan_duration.long');
589                                                 break;
590                                 };
591                         },
592                         'persist' : 'hidden width ordinal'
593                 },
594                 {
595                         'id' : 'circ_lib',
596                         'label' : document.getElementById('commonStrings').getString('staff.acp_label_circ_lib'),
597                         'flex' : 1,
598                         'primary' : false,
599                         'hidden' : true,
600                         'render' : function(my) {
601                                 if (Number(my.acp.circ_lib())>=0) {
602                                         return data.hash.aou[ my.acp.circ_lib() ].shortname();
603                                 } else {
604                                         return my.acp.circ_lib().shortname();
605                                 }
606                         },
607                         'persist' : 'hidden width ordinal'
608                 },
609                 {
610                         'id' : 'fine_level',
611                         'label' : document.getElementById('commonStrings').getString('staff.acp_label_fine_level'),
612                         'flex' : 1,
613                         'primary' : false,
614                         'hidden' : true,
615                         'render' : function(my) {
616                                 switch(Number(my.acp.fine_level())) {
617                                         case 1:
618                                                 return document.getElementById('circStrings').getString('staff.circ.utils.fine_level.low');
619                                                 break;
620                                         case 2:
621                                                 return document.getElementById('circStrings').getString('staff.circ.utils.fine_level.normal');
622                                                 break;
623                                         case 3:
624                                                 return document.getElementById('circStrings').getString('staff.circ.utils.fine_level.high');
625                                                 break;
626                                 };
627                         },
628                         'persist' : 'hidden width ordinal'
629                 },
630                 {
631                         'id' : 'circulate',
632                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.circulate'),
633                         'flex' : 1,
634                         'primary' : false,
635                         'hidden' : true,
636                         'render' : function(my) {
637                                 if (get_bool( my.acp.circulate() )) {
638                                         return document.getElementById('circStrings').getString('staff.circ.utils.yes');
639                                 } else {
640                                         return document.getElementById('circStrings').getString('staff.circ.utils.no');
641                                 }
642                         },
643                         'persist' : 'hidden width ordinal'
644                 },
645                 {
646                         'id' : 'deleted',
647                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.deleted'),
648                         'flex' : 1,
649                         'primary' : false,
650                         'hidden' : true,
651                         'render' : function(my) {
652                                 if (get_bool( my.acp.deleted() )) {
653                                         return document.getElementById('circStrings').getString('staff.circ.utils.yes');
654                                 } else {
655                                         return document.getElementById('circStrings').getString('staff.circ.utils.no');
656                                 }
657                         },
658                         'persist' : 'hidden width ordinal'
659                 },
660                 {
661                         'id' : 'holdable',
662                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.holdable'),
663                         'flex' : 1,
664                         'primary' : false,
665                         'hidden' : true,
666                         'render' : function(my) {
667                                 if (get_bool( my.acp.holdable() )) {
668                                         return document.getElementById('circStrings').getString('staff.circ.utils.yes');
669                                 } else {
670                                         return document.getElementById('circStrings').getString('staff.circ.utils.no');
671                                 }
672                         },
673                         'persist' : 'hidden width ordinal'
674                 },
675                 {
676                         'id' : 'opac_visible',
677                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.opac_visible'),
678                         'flex' : 1,
679                         'primary' : false,
680                         'hidden' : true,
681                         'render' : function(my) {
682                                 if (get_bool( my.acp.opac_visible() )) {
683                                         return document.getElementById('circStrings').getString('staff.circ.utils.yes');
684                                 } else {
685                                         return document.getElementById('circStrings').getString('staff.circ.utils.no');
686                                 }
687                         },
688                         'persist' : 'hidden width ordinal'
689                 },
690                 {
691                         'persist' : 'hidden width ordinal',
692                         'id' : 'ref',
693                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.reference'),
694                         'flex' : 1,
695                         'primary' : false,
696                         'hidden' : true,
697                         'render' : function(my) {
698                                 if (get_bool( my.acp.ref() )) {
699                                         return document.getElementById('circStrings').getString('staff.circ.utils.yes');
700                                 } else {
701                                         return document.getElementById('circStrings').getString('staff.circ.utils.no');
702                                 }
703                         }
704                 },
705                 {
706                         'persist' : 'hidden width ordinal',
707                         'id' : 'deposit',
708                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.deposit'),
709                         'flex' : 1,
710                         'primary' : false,
711                         'hidden' : true,
712                         'render' : function(my) {
713                                 if (get_bool( my.acp.deposit() )) {
714                                         return document.getElementById('circStrings').getString('staff.circ.utils.yes');
715                                 } else {
716                                         return document.getElementById('circStrings').getString('staff.circ.utils.no');
717                                 }
718                         }
719                 },
720                 {
721                         'persist' : 'hidden width ordinal',
722                         'id' : 'deposit_amount',
723                         'label' : document.getElementById('commonStrings').getString('staff.acp_label_deposit_amount'),
724                         'flex' : 1,
725                         'primary' : false,
726                         'hidden' : true,
727                         'render' : function(my) {
728                                 if (my.acp.price() == null) {
729                                         return document.getElementById('circStrings').getString('staff.circ.utils.unset');
730                                 } else {
731                                         return util.money.sanitize(my.acp.deposit_amount());
732                                 }
733                         },
734                         'sort_type' : 'money'
735                 },
736                 {
737                         'persist' : 'hidden width ordinal',
738                         'id' : 'price',
739                         'label' : document.getElementById('commonStrings').getString('staff.acp_label_price'),
740                         'flex' : 1,
741                         'primary' : false,
742                         'hidden' : true,
743                         'render' : function(my) {
744                                 if (my.acp.price() == null) {
745                                         return document.getElementById('circStrings').getString('staff.circ.utils.unset');
746                                 } else {
747                                         return util.money.sanitize(my.acp.price());
748                                 }
749                         },
750                         'sort_type' : 'money'
751                 },
752                 {
753                         'persist' : 'hidden width ordinal',
754                         'id' : 'circ_as_type',
755                         'label' : document.getElementById('commonStrings').getString('staff.acp_label_circ_as_type'),
756                         'flex' : 1,
757                         'primary' : false,
758                         'hidden' : true,
759                         'render' : function(my) { return my.acp.circ_as_type(); }
760                 },
761                 {
762                         'persist' : 'hidden width ordinal',
763                         'id' : 'circ_modifier',
764                         'label' : document.getElementById('commonStrings').getString('staff.acp_label_circ_modifier'),
765                         'flex' : 1,
766                         'primary' : false,
767                         'hidden' : true,
768                         'render' : function(my) { return my.acp.circ_modifier(); }
769                 },
770                 {
771                         'persist' : 'hidden width ordinal',
772                         'id' : 'checkout_lib',
773                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.checkout_lib'),
774                         'flex' : 1,
775                         'primary' : false,
776                         'hidden' : true,
777                         'render' : function(my) {
778                                 if (my.circ) {
779                                         return data.hash.aou[ my.circ.circ_lib() ].shortname();
780                                 } else {
781                                         if (my.acp.circulations()) {
782                                                 return data.hash.aou[ my.acp.circulations()[0].circ_lib() ].shortname();
783                                         } else {
784                                                 return "";
785                                         }
786                                 }
787                         }
788                 },
789                 {
790                         'persist' : 'hidden width ordinal',
791                         'id' : 'xact_start_full',
792                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.checkout_timestamp'),
793                         'flex' : 1,
794                         'primary' : false,
795                         'hidden' : true,
796                         'render' : function(my) {
797                                 if (my.circ) {
798                                         return my.circ.xact_start();
799                                 } else {
800                                         if (my.acp.circulations()) {
801                                                 return my.acp.circulations()[0].xact_start();
802                                         }
803                                         else {
804                                                 return  "";
805                                         }
806                                 }
807                         }
808                 },
809                 {
810                         'persist' : 'hidden width ordinal',
811                         'id' : 'checkin_time_full',
812                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.checkin_timestamp'),
813                         'flex' : 1,
814                         'primary' : false,
815                         'hidden' : true,
816                         'render' : function(my) {
817                                 if (my.circ) {
818                                         return my.circ.checkin_time();
819                                 } else {
820                                         if (my.acp.circulations()) {
821                                                 return my.acp.circulations()[0].checkin_time();
822                                         } else {
823                                                 return "";
824                                         }
825                                 }
826                         }
827                 },
828                 {
829                         'persist' : 'hidden width ordinal',
830                         'id' : 'xact_start',
831                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.xact_start'),
832                         'flex' : 1,
833                         'primary' : false,
834                         'hidden' : true,
835                         'render' : function(my) {
836                                 if (my.circ) {
837                                         return my.circ.xact_start().substr(0,10);
838                                 } else {
839                                         if (my.acp.circulations()) {
840                                                 return my.acp.circulations()[0].xact_start().substr(0,10);
841                                         } else {
842                                                 return "";
843                                         }
844                                 }
845                         }
846                 },
847                 {
848                         'persist' : 'hidden width ordinal',
849                         'id' : 'checkin_time',
850                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.checkin_time'),
851                         'flex' : 1,
852                         'primary' : false,
853                         'hidden' : true,
854                         'render' : function(my) {
855                                 if (my.circ) {
856                                         return my.circ.checkin_time().substr(0,10);
857                                 } else {
858                                         if (my.acp.circulations()) {
859                                                 return my.acp.circulations()[0].checkin_time().substr(0,10);
860                                         } else {
861                                                 return "";
862                                         }
863                                 }
864                         }
865                 },
866                 {
867                         'persist' : 'hidden width ordinal',
868                         'id' : 'xact_finish',
869                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.xact_finish'),
870                         'flex' : 1,
871                         'primary' : false,
872                         'hidden' : true,
873                         'render' : function(my) { return my.circ.xact_finish(); },
874                 },
875                 {
876                         'persist' : 'hidden width ordinal',
877                         'id' : 'due_date',
878                         'label' : document.getElementById('commonStrings').getString('staff.circ_label_due_date'),
879                         'flex' : 1,
880                         'primary' : false,
881                         'hidden' : true,
882                         'render' : function(my) {
883                                 if (my.circ) {
884                                         return my.circ.due_date().substr(0,10);
885                                 } else {
886                                         if (my.acp.circulations()) {
887                                                 return my.acp.circulations()[0].due_date().substr(0,10);
888                                         } else {
889                                                 return "";
890                                         }
891                                 }
892                         }
893                 },
894                 {
895                         'persist' : 'hidden width ordinal',
896                         'id' : 'create_date',
897                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.create_date'),
898                         'flex' : 1,
899                         'primary' : false,
900                         'hidden' : true,
901                         'render' : function(my) { return my.acp.create_date().substr(0,10); }
902                 },
903                 {
904                         'persist' : 'hidden width ordinal',
905                         'id' : 'edit_date',
906                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.edit_date'),
907                         'flex' : 1,
908                         'primary' : false,
909                         'hidden' : true,
910                         'render' : function(my) { return my.acp.edit_date().substr(0,10); }
911                 },
912                 {
913                         'persist' : 'hidden width ordinal',
914                         'id' : 'title',
915                         'label' : document.getElementById('commonStrings').getString('staff.mvr_label_title'),
916                         'flex' : 2,
917                         'sort_type' : 'title',
918                         'primary' : false,
919                         'hidden' : true,
920                         'render' : function(my) {
921                                 try {  return my.mvr.title(); }
922                                 catch(E) { return my.acp.dummy_title(); }
923                         }
924                 },
925                 {
926                         'persist' : 'hidden width ordinal',
927                         'id' : 'author',
928                         'label' : document.getElementById('commonStrings').getString('staff.mvr_label_author'),
929                         'flex' : 1,
930                         'primary' : false,
931                         'hidden' : true,
932                         'render' : function(my) {
933                                 try { return my.mvr.author(); }
934                                 catch(E) { return my.acp.dummy_author(); }
935                         }
936                 },
937                 {
938                         'persist' : 'hidden width ordinal',
939                         'id' : 'edition',
940                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.edition'),
941                         'flex' : 1,
942                         'primary' : false,
943                         'hidden' : true,
944                         'render' : function(my) { return my.mvr.edition(); }
945                 },
946                 {
947                         'persist' : 'hidden width ordinal',
948                         'id' : 'isbn',
949                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.isbn'),
950                         'flex' : 1,
951                         'primary' : false,
952                         'hidden' : true,
953                         'render' : function(my) { return my.mvr.isbn(); }
954                 },
955                 {
956                         'persist' : 'hidden width ordinal',
957                         'id' : 'pubdate',
958                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.pubdate'),
959                         'flex' : 1,
960                         'primary' : false,
961                         'hidden' : true,
962                         'render' : function(my) { return my.mvr.pubdate(); }
963                 },
964                 {
965                         'persist' : 'hidden width ordinal',
966                         'id' : 'publisher',
967                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.publisher'),
968                         'flex' : 1,
969                         'primary' : false,
970                         'hidden' : true,
971                         'render' : function(my) { return my.mvr.publisher(); }
972                 },
973                 {
974                         'persist' : 'hidden width ordinal',
975                         'id' : 'tcn',
976                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.tcn'),
977                         'flex' : 1,
978                         'primary' : false,
979                         'hidden' : true,
980                         'render' : function(my) { return my.mvr.tcn(); }
981                 },
982                 {
983                         'persist' : 'hidden width ordinal',
984                         'id' : 'renewal_remaining',
985                         'label' : document.getElementById('commonStrings').getString('staff.circ_label_renewal_remaining'),
986                         'flex' : 0,
987                         'primary' : false,
988                         'hidden' : true,
989                         'render' : function(my) {
990                                 if (my.circ) {
991                                         return my.circ.renewal_remaining();
992                                 } else {
993                                         if (my.acp.circulations()) {
994                                                 return my.acp.circulations()[0].renewal_remaining();
995                                         } else {
996                                                 return "";
997                                         }
998                                 }
999                         },
1000                         'sort_type' : 'number'
1001                 },
1002                 {
1003                         'persist' : 'hidden width ordinal',
1004                         'id' : 'stop_fines',
1005                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.stop_fines'),
1006                         'flex' : 0,
1007                         'primary' : false,
1008                         'hidden' : true,
1009                         'render' : function(my) {
1010                                 if (my.circ) {
1011                                         return my.circ.stop_fines();
1012                                 } else {
1013                                         if (my.acp.circulations()) {
1014                                                 return my.acp.circulations()[0].stop_fines();
1015                                         } else {
1016                                                 return "";
1017                                         }
1018                                 }
1019                         }
1020                 },
1021                 {
1022                         'persist' : 'hidden width ordinal',
1023                         'id' : 'stop_fines_time',
1024                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.stop_fines_time'),
1025                         'flex' : 0,
1026                         'primary' : false,
1027                         'hidden' : true,
1028                         'render' : function(my) {
1029                                 if (my.circ) {
1030                                         return my.circ.stop_fines_time();
1031                                 } else {
1032                                         if (my.acp.circulations()) {
1033                                                 return my.acp.circulations()[0].stop_fines_time();
1034                                         } else {
1035                                                 return "";
1036                                         }
1037                                 }
1038                         }
1039                 },
1040                 {
1041                         'persist' : 'hidden width ordinal',
1042                         'id' : 'status',
1043                         'label' : document.getElementById('commonStrings').getString('staff.acp_label_status'),
1044                         'flex' : 1,
1045                         'primary' : false,
1046                         'hidden' : true,
1047                         'render' : function(my) {
1048                                 if (Number(my.acp.status())>=0) {
1049                                         return data.hash.ccs[ my.acp.status() ].name();
1050                                 } else {
1051                                         return my.acp.status().name();
1052                                 }
1053                         }
1054                 },
1055                 {
1056                         'persist' : 'hidden width ordinal',
1057                         'id' : 'route_to',
1058                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.route_to'),
1059                         'flex' : 1,
1060                         'primary' : false,
1061                         'hidden' : true,
1062                         'render' : function(my) { return my.route_to.toString(); }
1063                 },
1064                 {
1065                         'persist' : 'hidden width ordinal',
1066                         'id' : 'message',
1067                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.message'),
1068                         'flex' : 1,
1069                         'primary' : false,
1070                         'hidden' : true,
1071                         'render' : function(my) { return my.message.toString(); }
1072                 },
1073                 {
1074                         'persist' : 'hidden width ordinal',
1075                         'id' : 'uses',
1076                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.uses'),
1077                         'flex' : 1,
1078                         'primary' : false,
1079                         'hidden' : true,
1080                         'render' : function(my) { return my.uses; },
1081                         'sort_type' : 'number'
1082                 },
1083                 {
1084                         'persist' : 'hidden width ordinal',
1085                         'id' : 'alert_message',
1086                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.alert_message'),
1087                         'flex' : 1,
1088                         'primary' : false,
1089                         'hidden' : true,
1090                         'render' : function(my) { return my.acp.alert_message(); }
1091                 }
1092         ];
1093         for (var i = 0; i < c.length; i++) {
1094                 if (modify[ c[i].id ]) {
1095                         for (var j in modify[ c[i].id ]) {
1096                                 c[i][j] = modify[ c[i].id ][j];
1097                         }
1098                 }
1099         }
1100         if (params) {
1101                 if (params.just_these) {
1102                         JSAN.use('util.functional');
1103                         var new_c = [];
1104                         for (var i = 0; i < params.just_these.length; i++) {
1105                                 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
1106                                 new_c.push( function(y){ return y; }( x ) );
1107                         }
1108                         c = new_c;
1109                 }
1110                 if (params.except_these) {
1111                         JSAN.use('util.functional');
1112                         var new_c = [];
1113                         for (var i = 0; i < c.length; i++) {
1114                                 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
1115                                 if (!x) new_c.push(c[i]);
1116                         }
1117                         c = new_c;
1118                 }
1119         }
1120         return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
1121 };
1122
1123 circ.util.transit_columns = function(modify,params) {
1124         
1125         JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
1126
1127         var c = [
1128                 {
1129                         'persist' : 'hidden width ordinal',
1130                         'id' : 'transit_item_barcode',
1131                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.barcode'),
1132                         'flex' : 1,
1133                         'primary' : false,
1134                         'hidden' : true,
1135                         'render' : function(my) { return my.acp.barcode(); }
1136                 },
1137                 {
1138                         'persist' : 'hidden width ordinal',
1139                         'id' : 'transit_item_title',
1140                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.title'),
1141                         'flex' : 1,
1142                         'primary' : false,
1143                         'hidden' : true,
1144                         'render' : function(my) {
1145                                 try { return my.mvr.title(); }
1146                                 catch(E) { return my.acp.dummy_title(); }
1147                         }
1148                 },
1149                 {
1150                         'persist' : 'hidden width ordinal',
1151                         'id' : 'transit_item_author',
1152                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.author'),
1153                         'flex' : 1,
1154                         'primary' : false,
1155                         'hidden' : true,
1156                         'render' : function(my) {
1157                                 try { return my.mvr.author(); }
1158                                 catch(E) { return my.acp.dummy_author(); }
1159                         }
1160                 },
1161                 {
1162                         'persist' : 'hidden width ordinal',
1163                         'id' : 'transit_item_callnumber',
1164                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.callnumber'),
1165                         'flex' : 1,
1166                         'primary' : false,
1167                         'hidden' : true,
1168                         'render' : function(my) { return my.acn.label(); }
1169                 },
1170                 {
1171                         'persist' : 'hidden width ordinal',
1172                         'id' : 'transit_id',
1173                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_id'),
1174                         'flex' : 1,
1175                         'primary' : false,
1176                         'hidden' : true,
1177                         'render' : function(my) { return my.atc.id(); }
1178                 },
1179                 {
1180                         'persist' : 'hidden width ordinal',
1181                         'id' : 'transit_source',
1182                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_source'),
1183                         'flex' : 1,
1184                         'primary' : false,
1185                         'hidden' : false,
1186                         'render' : function(my) {
1187                                 if (typeof my.atc.source() == "object") {
1188                                         return my.atc.source().shortname();
1189                                 } else {
1190                                         return data.hash.aou[ my.atc.source() ].shortname();
1191                                 }
1192                         }
1193                 },
1194                 {
1195                         'persist' : 'hidden width ordinal',
1196                         'id' : 'transit_source_send_time',
1197                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_source_send_time'),
1198                         'flex' : 1,
1199                         'primary' : false,
1200                         'hidden' : false,
1201                         'render' : function(my) { return my.atc.source_send_time(); }
1202                 },
1203                 {
1204                         'persist' : 'hidden width ordinal',
1205                         'id' : 'transit_dest_lib',
1206                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_dest'),
1207                         'flex' : 1,
1208                         'primary' : false,
1209                         'hidden' : false,
1210                         'render' : function(my) {
1211                                 if (typeof my.atc.dest() == "object") {
1212                                         return my.atc.dest().shortname();
1213                                 } else {
1214                                         return data.hash.aou[ my.atc.dest() ].shortname();
1215                                 }
1216                         }
1217                 },
1218                 {
1219                         'persist' : 'hidden width ordinal',
1220                         'id' : 'transit_dest_recv_time',
1221                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_dest_recv_time'),
1222                         'flex' : 1,
1223                         'primary' : false,
1224                         'hidden' : false,
1225                         'render' : function(my) { return my.atc.dest_recv_time(); }
1226                 },
1227                 {
1228                         'persist' : 'hidden width ordinal',
1229                         'id' : 'transit_target_copy',
1230                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_target_copy'),
1231                         'flex' : 1,
1232                         'primary' : false,
1233                         'hidden' : true,
1234                         'render' : function(my) { return my.atc.target_copy(); }
1235                 },
1236         ];
1237         for (var i = 0; i < c.length; i++) {
1238                 if (modify[ c[i].id ]) {
1239                         for (var j in modify[ c[i].id ]) {
1240                                 c[i][j] = modify[ c[i].id ][j];
1241                         }
1242                 }
1243         }
1244         if (params) {
1245                 if (params.just_these) {
1246                         JSAN.use('util.functional');
1247                         var new_c = [];
1248                         for (var i = 0; i < params.just_these.length; i++) {
1249                                 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
1250                                 new_c.push( function(y){ return y; }( x ) );
1251                         }
1252                         c = new_c;
1253                 }
1254                 if (params.except_these) {
1255                         JSAN.use('util.functional');
1256                         var new_c = [];
1257                         for (var i = 0; i < c.length; i++) {
1258                                 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
1259                                 if (!x) new_c.push(c[i]);
1260                         }
1261                         c = new_c;
1262                 }
1263
1264         }
1265         return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
1266 };
1267
1268 circ.util.hold_columns = function(modify,params) {
1269         
1270         JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
1271
1272         var c = [
1273                 {
1274                         'persist' : 'hidden width ordinal',
1275                         'id' : 'request_lib',
1276                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.request_lib'),
1277                         'flex' : 1,
1278                         'primary' : false,
1279                         'hidden' : true,
1280                         'render' : function(my) {
1281                                 if (Number(my.ahr.request_lib())>=0) {
1282                                         return data.hash.aou[ my.ahr.request_lib() ].name();
1283                                 } else {
1284                                         return my.ahr.request_lib().name();
1285                                 }
1286                         }
1287                 },
1288                 {
1289                         'persist' : 'hidden width ordinal',
1290                         'id' : 'request_lib_shortname',
1291                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.request_lib_shortname'),
1292                         'flex' : 0,
1293                         'primary' : false,
1294                         'hidden' : true,
1295                         'render' : function(my) {
1296                                 if (Number(my.ahr.request_lib())>=0) {
1297                                         return data.hash.aou[ my.ahr.request_lib() ].shortname();
1298                                 } else {
1299                                         return my.ahr.request_lib().shortname();
1300                                 }
1301                         }
1302                 },
1303
1304                 {
1305                         'persist' : 'hidden width ordinal',
1306                         'id' : 'request_timestamp',
1307                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.request_timestamp'),
1308                         'flex' : 0,
1309                         'primary' : false,
1310                         'hidden' : true,
1311                         'render' : function(my) { return my.ahr.request_time().toString(); }
1312                 },
1313                 {
1314                         'persist' : 'hidden width ordinal',
1315                         'id' : 'request_time',
1316                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.request_time'),
1317                         'flex' : 0,
1318                         'primary' : false,
1319                         'hidden' : true,
1320                         'render' : function(my) { return my.ahr.request_time().toString().substr(0,10); }
1321                 },
1322                 {
1323                         'persist' : 'hidden width ordinal',
1324                         'id' : 'available_timestamp',
1325                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.available_timestamp'),
1326                         'flex' : 1,
1327                         'primary' : false,
1328                         'hidden' : true,
1329                         'render' : function(my) {
1330                                 if (my.ahr.transit() && my.ahr.transit().dest_recv_time()) {
1331                                         return my.ahr.transit().dest_recv_time().toString();
1332                                 }
1333                                 if (my.ahr.capture_time()) {
1334                                         return my.ahr.capture_time().toString();
1335                                 }
1336                                 return "";
1337                         }
1338                 },
1339                 {
1340                         'persist' : 'hidden width ordinal',
1341                         'id' : 'available_time',
1342                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.available_time'),
1343                         'flex' : 1,
1344                         'primary' : false,
1345                         'hidden' : false,
1346                         'render' : function(my) {
1347                                 if (my.ahr.transit() && my.ahr.transit().dest_recv_time()) {
1348                                         return my.ahr.transit().dest_recv_time().toString().substr(0,10);
1349                                 }
1350                                 if (my.ahr.capture_time()) {
1351                                         return my.ahr.capture_time().toString().substr(0,10);
1352                                 }
1353                                 return "";
1354                         }
1355                 },
1356                 {
1357                         'persist' : 'hidden width ordinal',
1358                         'id' : 'capture_timestamp',
1359                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.capture_timestamp'),
1360                         'flex' : 1,
1361                         'primary' : false,
1362                         'hidden' : true,
1363                         'render' : function(my) { return my.ahr.capture_time() ? my.ahr.capture_time().toString() : ""; }
1364                 },
1365                 {
1366                         'persist' : 'hidden width ordinal',
1367                         'id' : 'capture_time',
1368                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.capture_time'),
1369                         'flex' : 1,
1370                         'primary' : false,
1371                         'hidden' : true,
1372                         'render' : function(my) { return my.ahr.capture_time() ? my.ahr.capture_time().toString().substr(0,10) : ""; }
1373                 },
1374                 {
1375                         'persist' : 'hidden width ordinal',
1376                         'id' : 'status',
1377                         'label' : document.getElementById('commonStrings').getString('staff.ahr_status_label'),
1378                         'flex' : 1,
1379                         'primary' : false,
1380                         'hidden' : false,
1381                         'render' : function(my) {
1382                                 switch (Number(my.status)) {
1383                                         case 1:
1384                                                 return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.1');
1385                                                 break;
1386                                         case 2:
1387                                                 return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.2');
1388                                                 break;
1389                                         case 3:
1390                                                 return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.3');
1391                                                 break;
1392                                         case 4:
1393                                                 return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.4');
1394                                                 break;
1395                                         default:
1396                                                 return my.status;
1397                                                 break;
1398                                 };
1399                         }
1400                 },
1401                 {
1402                         'persist' : 'hidden width ordinal',
1403                         'id' : 'hold_type',
1404                         'label' : document.getElementById('commonStrings').getString('staff.ahr_hold_type_label'),
1405                         'flex' : 0,
1406                         'primary' : false,
1407                         'hidden' : true,
1408                         'render' : function(my) { return my.ahr.hold_type(); },
1409                 },
1410         {
1411                         'persist' : 'hidden width ordinal',
1412                         'id' : 'frozen',
1413                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.frozen'),
1414                         'flex' : 0,
1415                         'primary' : false,
1416                         'hidden' : true,
1417                         'render' : function(my) {
1418                                 if (get_bool( my.ahr.frozen() )) {
1419                                         return document.getElementById('circStrings').getString('staff.circ.utils.yes');
1420                                 } else {
1421                                         return document.getElementById('circStrings').getString('staff.circ.utils.no');
1422                                 }
1423                         }
1424         },
1425         {
1426                         'persist' : 'hidden width ordinal',
1427                         'id' : 'thaw_date',
1428                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.thaw_date'),
1429                         'flex' : 0,
1430                         'primary' : false,
1431                         'hidden' : true,
1432                         'render' : function(my) {
1433                                 if (my.ahr.thaw_date() == null) {
1434                                         return document.getElementById('circStrings').getString('staff.circ.utils.thaw_date.none');
1435                                 } else {
1436                                         return my.ahr.thaw_date().substr(0,10);
1437                                 }
1438                         }
1439         },
1440                 {
1441                         'persist' : 'hidden width ordinal',
1442                         'id' : 'pickup_lib',
1443                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.pickup_lib'),
1444                         'flex' : 1,
1445                         'primary' : false,
1446                         'hidden' : true,
1447                         'render' : function(my) {
1448                                 if (Number(my.ahr.pickup_lib())>=0) {
1449                                         return data.hash.aou[ my.ahr.pickup_lib() ].name();
1450                                 } else {
1451                                         return my.ahr.pickup_lib().name();
1452                                 }
1453                         }
1454                 },
1455                 {
1456                         'persist' : 'hidden width ordinal',
1457                         'id' : 'pickup_lib_shortname',
1458                         'label' : document.getElementById('commonStrings').getString('staff.ahr_pickup_lib_label'),
1459                         'flex' : 0,
1460                         'primary' : false,
1461                         'hidden' : true,
1462                         'render' : function(my) {
1463                                 if (Number(my.ahr.pickup_lib())>=0) {
1464                                         return data.hash.aou[ my.ahr.pickup_lib() ].shortname();
1465                                 } else {
1466                                         return my.ahr.pickup_lib().shortname();
1467                                 }
1468                         }
1469                 },
1470                 {
1471                         'persist' : 'hidden width ordinal',
1472                         'id' : 'current_copy',
1473                         'label' : document.getElementById('commonStrings').getString('staff.ahr_current_copy_label'),
1474                         'flex' : 1,
1475                         'primary' : false,
1476                         'hidden' : true,
1477                         'render' : function(my) {
1478                                 if (my.acp) {
1479                                         return my.acp.barcode();
1480                                 } else {
1481                                         return document.getElementById('circStrings').getString('staff.circ.utils.current_copy.none');
1482                                 }
1483                         }
1484                 },
1485                 {
1486                         'persist' : 'hidden width ordinal',
1487                         'id' : 'email_notify',
1488                         'label' : document.getElementById('commonStrings').getString('staff.ahr_email_notify_label'),
1489                         'flex' : 1,
1490                         'primary' : false,
1491                         'hidden' : true,
1492                         'render' : function(my) {
1493                                 if (get_bool(my.ahr.email_notify())) {
1494                                         return document.getElementById('circStrings').getString('staff.circ.utils.current_copy.yes');
1495                                 } else {
1496                                         return document.getElementById('circStrings').getString('staff.circ.utils.current_copy.no');
1497                                 }
1498                         }
1499                 },
1500                 {
1501                         'persist' : 'hidden width ordinal',
1502                         'id' : 'expire_time',
1503                         'label' : document.getElementById('commonStrings').getString('staff.ahr_expire_time_label'),
1504                         'flex' : 1,
1505                         'primary' : false,
1506                         'hidden' : true,
1507                         'render' : function(my) { return my.ahr.expire_time(); }
1508                 },
1509                 {
1510                         'persist' : 'hidden width ordinal',
1511                         'id' : 'fulfillment_time',
1512                         'label' : document.getElementById('commonStrings').getString('staff.ahr_fulfillment_time_label'),
1513                         'flex' : 1,
1514                         'primary' : false,
1515                         'hidden' : true,
1516                         'render' : function(my) { return my.ahr.fulfillment_time(); }
1517                 },
1518                 {
1519                         'persist' : 'hidden width ordinal',
1520                         'id' : 'holdable_formats',
1521                         'label' : document.getElementById('commonStrings').getString('staff.ahr_holdable_formats_label'),
1522                         'flex' : 1,
1523                         'primary' : false,
1524                         'hidden' : true,
1525                         'render' : function(my) { return my.ahr.holdable_formats(); }
1526                 },
1527                 {
1528                         'persist' : 'hidden width ordinal',
1529                         'id' : 'id',
1530                         'label' : document.getElementById('commonStrings').getString('staff.ahr_id_label'),
1531                         'flex' : 1,
1532                         'primary' : false,
1533                         'hidden' : true,
1534                         'render' : function(my) { return my.ahr.id(); }
1535                 },
1536                 {
1537                         'persist' : 'hidden width ordinal',
1538                         'id' : 'phone_notify',
1539                         'label' : document.getElementById('commonStrings').getString('staff.ahr_phone_notify_label'),
1540                         'flex' : 1,
1541                         'primary' : false,
1542                         'hidden' : true,
1543                         'render' : function(my) { return my.ahr.phone_notify(); }
1544                 },
1545                 {
1546                         'persist' : 'hidden width ordinal',
1547                         'id' : 'prev_check_time',
1548                         'label' : document.getElementById('commonStrings').getString('staff.ahr_prev_check_time_label'),
1549                         'flex' : 1,
1550                         'primary' : false,
1551                         'hidden' : true,
1552                         'render' : function(my) { return my.ahr.prev_check_time(); }
1553                 },
1554                 {
1555                         'persist' : 'hidden width ordinal',
1556                         'id' : 'requestor',
1557                         'label' : document.getElementById('commonStrings').getString('staff.ahr_requestor_label'),
1558                         'flex' : 1,
1559                         'primary' : false,
1560                         'hidden' : true,
1561                         'render' : function(my) { return my.ahr.requestor(); }
1562                 },
1563                 {
1564                         'persist' : 'hidden width ordinal',
1565                         'id' : 'selection_depth',
1566                         'label' : document.getElementById('commonStrings').getString('staff.ahr_selection_depth_label'),
1567                         'flex' : 1,
1568                         'primary' : false,
1569                         'hidden' : true,
1570                         'render' : function(my) { return my.ahr.selection_depth(); }
1571                 },
1572                 {
1573                         'persist' : 'hidden width ordinal',
1574                         'id' : 'target',
1575                         'label' : document.getElementById('commonStrings').getString('staff.ahr_target_label'),
1576                         'flex' : 1,
1577                         'primary' : false,
1578                         'hidden' : true,
1579                         'render' : function(my) { return my.ahr.target(); }
1580                 },
1581                 {
1582                         'persist' : 'hidden width ordinal',
1583                         'id' : 'usr',
1584                         'label' : document.getElementById('commonStrings').getString('staff.ahr_usr_label'),
1585                         'flex' : 1,
1586                         'primary' : false,
1587                         'hidden' : true,
1588                         'render' : function(my) { return my.ahr.usr(); }
1589                 },
1590                 {
1591                         'persist' : 'hidden width ordinal',
1592                         'id' : 'title',
1593                         'label' : document.getElementById('commonStrings').getString('staff.mvr_label_title'),
1594                         'flex' : 1,
1595                         'sort_type' : 'title',
1596                         'primary' : false,
1597                         'hidden' : true,
1598                         'render' : function(my) {
1599                                 if (my.mvr) {
1600                                         return my.mvr.title();
1601                                 } else {
1602                                         return document.getElementById('circStrings').getString('staff.circ.utils.title.none');
1603                                 }
1604                         }
1605                 },
1606                 {
1607                         'persist' : 'hidden width ordinal',
1608                         'id' : 'author',
1609                         'label' : document.getElementById('commonStrings').getString('staff.mvr_label_author'),
1610                         'flex' : 1,
1611                         'primary' : false,
1612                         'hidden' : true,
1613                         'render' : function(my) {
1614                                 if (my.mvr) {
1615                                         return my.mvr.author();
1616                                 } else {
1617                                         return document.getElementById('circStrings').getString('staff.circ.utils.author.none');
1618                                 }
1619                         }
1620                 },
1621                 {
1622                         'persist' : 'hidden width ordinal',
1623                         'id' : 'edition',
1624                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.edition'),
1625                         'flex' : 1,
1626                         'primary' : false,
1627                         'hidden' : true,
1628                         'render' : function(my) { return my.mvr.edition(); }
1629                 },
1630                 {
1631                         'persist' : 'hidden width ordinal',
1632                         'id' : 'isbn',
1633                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.isbn'),
1634                         'flex' : 1,
1635                         'primary' : false,
1636                         'hidden' : true,
1637                         'render' : function(my) { return my.mvr.isbn(); }
1638                 },
1639                 {
1640                         'persist' : 'hidden width ordinal',
1641                         'id' : 'pubdate',
1642                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.pubdate'),
1643                         'flex' : 1,
1644                         'primary' : false,
1645                         'hidden' : true,
1646                         'render' : function(my) { return my.mvr.pubdate(); }
1647                 },
1648                 {
1649                         'persist' : 'hidden width ordinal',
1650                         'id' : 'publisher',
1651                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.publisher'),
1652                         'flex' : 1,
1653                         'primary' : false,
1654                         'hidden' : true,
1655                         'render' : function(my) { return my.mvr.publisher(); }
1656                 },
1657                 {
1658                         'persist' : 'hidden width ordinal',
1659                         'id' : 'tcn',
1660                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.tcn'),
1661                         'flex' : 1,
1662                         'primary' : false,
1663                         'hidden' : true,
1664                         'render' : function(my) { return my.mvr.tcn(); }
1665                 },
1666                 {
1667                         'persist' : 'hidden width ordinal',
1668                         'id' : 'notify_time',
1669                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.notify_time'),
1670                         'flex' : 1,
1671                         'primary' : false,
1672                         'hidden' : true,
1673                         'render' : function(my) { return my.ahr.notify_time(); }
1674                 },
1675                 {
1676                         'persist' : 'hidden width ordinal',
1677                         'id' : 'notify_count',
1678                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.notify_count'),
1679                         'flex' : 1,
1680                         'primary' : false,
1681                         'hidden' : true,
1682                         'render' : function(my) { return my.ahr.notify_count(); }
1683                 },
1684                 {
1685                         'persist' : 'hidden width ordinal',
1686                         'id' : 'transit_source',
1687                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_source'),
1688                         'flex' : 1,
1689                         'primary' : false,
1690                         'hidden' : true,
1691                         'render' : function(my) {
1692                                 if (my.ahr.transit()) {
1693                                         return data.hash.aou[ my.ahr.transit().source() ].shortname();
1694                                 } else {
1695                                         return "";
1696                                 }
1697                         }
1698                 },
1699                 {
1700                         'persist' : 'hidden width ordinal',
1701                         'id' : 'transit_source_send_time',
1702                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_source_send_time'),
1703                         'flex' : 1,
1704                         'primary' : false,
1705                         'hidden' : true,
1706                         'render' : function(my) { return my.ahr.transit() ?  my.ahr.transit().source_send_time() : ""; }
1707                 },
1708                 {
1709                         'persist' : 'hidden width ordinal',
1710                         'id' : 'transit_dest_lib',
1711                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_dest'),
1712                         'flex' : 1,
1713                         'primary' : false,
1714                         'hidden' : true,
1715                         'render' : function(my) { return my.ahr.transit() ?  data.hash.aou[ my.ahr.transit().dest() ].shortname() : ""; }
1716                 },
1717                 {
1718                         'persist' : 'hidden width ordinal',
1719                         'id' : 'transit_dest_recv_time',
1720                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_dest_recv_time'),
1721                         'flex' : 1,
1722                         'primary' : false,
1723                         'hidden' : true,
1724                         'render' : function(my) { return my.ahr.transit() ?  my.ahr.transit().dest_recv_time() : ""; }
1725                 },
1726                 {
1727                         'persist' : 'hidden width ordinal',
1728                         'id' : 'patron_barcode',
1729                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.patron_barcode'),
1730                         'flex' : 1,
1731                         'primary' : false,
1732                         'hidden' : true,
1733                         'render' : function(my) { return my.patron_barcode ? my.patron_barcode : ""; }
1734                 },
1735                 {
1736                         'persist' : 'hidden width ordinal',
1737                         'id' : 'patron_family_name',
1738                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.patron_family_name'),
1739                         'flex' : 1,
1740                         'primary' : false,
1741                         'hidden' : true,
1742                         'render' : function(my) { return my.patron_family_name ? my.patron_family_name : ""; }
1743                 },
1744                 {
1745                         'persist' : 'hidden width ordinal',
1746                         'id' : 'patron_first_given_name',
1747                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.patron_first_given_name'),
1748                         'flex' : 1,
1749                         'primary' : false,
1750                         'hidden' : true,
1751                         'render' : function(my) { return my.patron_first_given_name ? my.patron_first_given_name : ""; }
1752                 },
1753                 {
1754                         'persist' : 'hidden width ordinal',
1755                         'id' : 'callnumber',
1756                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.callnumber'),
1757                         'flex' : 1,
1758                         'primary' : false,
1759                         'hidden' : true,
1760                         'render' : function(my) { return my.acn.label(); }
1761                 },
1762         ];
1763         for (var i = 0; i < c.length; i++) {
1764                 if (modify[ c[i].id ]) {
1765                         for (var j in modify[ c[i].id ]) {
1766                                 c[i][j] = modify[ c[i].id ][j];
1767                         }
1768                 }
1769         }
1770         if (params) {
1771                 if (params.just_these) {
1772                         JSAN.use('util.functional');
1773                         var new_c = [];
1774                         for (var i = 0; i < params.just_these.length; i++) {
1775                                 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
1776                                 new_c.push( function(y){ return y; }( x ) );
1777                         }
1778                         c = new_c;
1779                 }
1780                 if (params.except_these) {
1781                         JSAN.use('util.functional');
1782                         var new_c = [];
1783                         for (var i = 0; i < c.length; i++) {
1784                                 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
1785                                 if (!x) new_c.push(c[i]);
1786                         }
1787                         c = new_c;
1788                 }
1789
1790         }
1791         return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
1792 };
1793 /*
1794 circ.util.std_map_row_to_column = function(error_value) {
1795         return function(row,col) {
1796                 // row contains { 'my' : { 'acp' : {}, 'circ' : {}, 'mvr' : {} } }
1797                 // col contains one of the objects listed above in columns
1798                 
1799                 // mimicking some of the obj in circ.checkin and circ.checkout where map_row_to_column is usually defined
1800                 var obj = {};
1801                 JSAN.use('util.error'); obj.error = new util.error();
1802                 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
1803                 JSAN.use('util.network'); obj.network = new util.network();
1804                 JSAN.use('util.money');
1805
1806                 var my = row.my;
1807                 var value;
1808                 try {
1809                         value = eval( col.render );
1810                 } catch(E) {
1811                         obj.error.sdump('D_WARN','map_row_to_column: ' + E);
1812                         if (error_value) value = error_value; else value = '   ';
1813                 }
1814                 return value;
1815         }
1816 };
1817 */
1818 circ.util.std_map_row_to_columns = function(error_value) {
1819         return function(row,cols) {
1820                 // row contains { 'my' : { 'acp' : {}, 'circ' : {}, 'mvr' : {} } }
1821                 // cols contains all of the objects listed above in columns
1822                 
1823                 var obj = {};
1824                 JSAN.use('util.error'); obj.error = new util.error();
1825                 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
1826                 JSAN.use('util.network'); obj.network = new util.network();
1827                 JSAN.use('util.money');
1828
1829                 var my = row.my;
1830                 var values = [];
1831                 var cmd = '';
1832                 try {
1833                         for (var i = 0; i < cols.length; i++) {
1834                                 switch (typeof cols[i].render) {
1835                                         case 'function': try { values[i] = cols[i].render(my); } catch(E) { values[i] = error_value; dump(E+'\n'); } break;
1836                                         case 'string' : cmd += 'try { ' + cols[i].render + '; values['+i+'] = v; } catch(E) { values['+i+'] = error_value; }'; break;
1837                                         default: cmd += 'values['+i+'] = "??? '+(typeof cols[i].render)+'"; ';
1838                                 }
1839                         }
1840                         if (cmd) eval( cmd );
1841                 } catch(E) {
1842                         obj.error.sdump('D_WARN','map_row_to_column: ' + E);
1843                         if (error_value) { value = error_value; } else { value = '   ' };
1844                 }
1845                 return values;
1846         }
1847 };
1848
1849 circ.util.checkin_via_barcode = function(session,params,backdate,auto_print,async) {
1850         try {
1851                 JSAN.use('util.error'); var error = new util.error();
1852                 JSAN.use('util.network'); var network = new util.network();
1853                 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
1854                 JSAN.use('util.date');
1855
1856                 if (backdate && (backdate == util.date.formatted_date(new Date(),'%Y-%m-%d')) ) backdate = null;
1857
1858                 //var params = { 'barcode' : barcode };
1859                 if (backdate) params.backdate = util.date.formatted_date(backdate + ' 00:00:00','%{iso8601}');
1860
1861                 if (typeof async == 'object') {
1862                         try { async.disable_textbox(); }
1863                         catch(E) { error.sdump('D_ERROR','async.disable_textbox() = ' + E); };
1864                 }
1865                 var check = network.request(
1866                         api.CHECKIN_VIA_BARCODE.app,
1867                         api.CHECKIN_VIA_BARCODE.method,
1868                         [ session, params ],
1869                         async ? function(req) {
1870                                 try {
1871                                         var check = req.getResultObject();
1872                                         var r = circ.util.checkin_via_barcode2(session,params,backdate,auto_print,check);
1873                                         if (typeof async == 'object') {
1874                                                 try { async.checkin_result(r); }
1875                                                 catch(E) { error.sdump('D_ERROR','async.checkin_result() = ' + E); };
1876                                         }
1877                                 } catch(E) {
1878                                         JSAN.use('util.error'); var error = new util.error();
1879                                         error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedMessage('staff.circ.checkin.error', ['1']), E);
1880                                         if (typeof async == 'object') {
1881                                                 try { async.enable_textbox(); }
1882                                                 catch(E) { error.sdump('D_ERROR','async.disable_textbox() = ' + E); };
1883                                         }
1884                                         return null;
1885                                 }
1886                         } : null,
1887                         {
1888                                 'title' : document.getElementById('circStrings').getString('staff.circ.utils.checkin.override'),
1889                                 'overridable_events' : [
1890                                         1203 /* COPY_BAD_STATUS */,
1891                                         1213 /* PATRON_BARRED */,
1892                                         1217 /* PATRON_INACTIVE */,
1893                                         1224 /* PATRON_ACCOUNT_EXPIRED */,
1894                                         7009 /* CIRC_CLAIMS_RETURNED */,
1895                                         7010 /* COPY_ALERT_MESSAGE */,
1896                                         7011 /* COPY_STATUS_LOST */,
1897                                         7012 /* COPY_STATUS_MISSING */,
1898                                         7013 /* PATRON_EXCEEDS_FINES */,
1899                                 ],
1900                                 'text' : {
1901                                         '1203' : function(r) {
1902                                                 //return data.hash.ccs[ r.payload.status() ].name();
1903                                                 return r.payload.status().name();
1904                                         },
1905                                         '7010' : function(r) {
1906                                                 return r.payload;
1907                                         },
1908                                 }
1909                         }
1910                 );
1911                 if (!async) {
1912                         return circ.util.checkin_via_barcode2(session,params,backdate,auto_print,check);
1913                 }
1914
1915
1916         } catch(E) {
1917                 JSAN.use('util.error'); var error = new util.error();
1918                 error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedMessage('staff.circ.checkin.error', ['2']), E);
1919                 if (typeof async == 'object') {
1920                         try { async.enable_textbox(); } catch(E) { error.sdump('D_ERROR','async.disable_textbox() = ' + E); };
1921                 }
1922                 return null;
1923         }
1924 };
1925
1926 circ.util.checkin_via_barcode2 = function(session,params,backdate,auto_print,check) {
1927         try {
1928                 JSAN.use('util.error'); var error = new util.error();
1929                 JSAN.use('util.network'); var network = new util.network();
1930                 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
1931                 JSAN.use('util.date');
1932
1933                 error.sdump('D_DEBUG','check = ' + error.pretty_print( js2JSON( check ) ) );
1934
1935                 check.message = check.textcode;
1936
1937                 if (check.payload && check.payload.copy) { check.copy = check.payload.copy; }
1938                 if (check.payload && check.payload.record) { check.record = check.payload.record; }
1939                 if (check.payload && check.payload.circ) { check.circ = check.payload.circ; }
1940
1941                 if (!check.route_to) { check.route_to = '   '; }
1942
1943                 if (document.getElementById('no_change_label')) {
1944                         document.getElementById('no_change_label').setAttribute('value','');
1945                         document.getElementById('no_change_label').setAttribute('hidden','true');
1946                 }
1947
1948                 if (check.circ) {
1949                         network.simple_request('FM_MBTS_RETRIEVE',[ses(),check.circ.id()], function(req) {
1950                                 JSAN.use('util.money');
1951                                 var bill = req.getResultObject();
1952                                 if (Number(bill.balance_owed()) == 0) { return; }
1953                                 if (document.getElementById('no_change_label')) {
1954                                         var m = document.getElementById('no_change_label').getAttribute('value');
1955                                         document.getElementById('no_change_label').setAttribute('value', m + document.getElementById('circStrings').getFormattedString('staff.circ.utils.billable.amount', [params.barcode, util.money.sanitize(bill.balance_owed())]) + '  ');
1956                                         document.getElementById('no_change_label').setAttribute('hidden','false');
1957                                 }
1958                         });
1959                 }
1960
1961                 var msg = '';
1962
1963                 if (check.payload && check.payload.cancelled_hold_transit) {
1964                         msg += document.getElementById('circStrings').getString('staff.circ.utils.transit_hold_cancelled');
1965                         msg += '\n\n';
1966                 }
1967
1968                 /* SUCCESS  /  NO_CHANGE  /  ITEM_NOT_CATALOGED */
1969                 if (check.ilsevent == 0 || check.ilsevent == 3 || check.ilsevent == 1202) {
1970                         try { check.route_to = data.lookup('acpl', check.copy.location() ).name(); }
1971                         catch(E) {
1972                                 msg += document.getElementById('commonStrings').getString('common.error');
1973                                 msg += '\nFIXME: ' + E + '\n';
1974                         }
1975                         if (check.ilsevent == 3 /* NO_CHANGE */) {
1976                                 //msg = 'This item is already checked in.\n';
1977                                 if (document.getElementById('no_change_label')) {
1978                                         var m = document.getElementById('no_change_label').getAttribute('value');
1979                                         document.getElementById('no_change_label').setAttribute('value', m + document.getElementById('circStrings').getFormattedString('staff.circ.utils.item_checked_in', [params.barcode]) + '  ');
1980                                         document.getElementById('no_change_label').setAttribute('hidden','false');
1981                                 }
1982                         }
1983                         if (check.ilsevent == 1202 /* ITEM_NOT_CATALOGED */ && check.copy.status() != 11) {
1984                                 var copy_status = (data.hash.ccs[ check.copy.status() ] ? data.hash.ccs[ check.copy.status() ].name() : check.copy.status().name() );
1985                                 msg = document.getElementById('commonStrings').getString('common.error');
1986                                 msg += '\nFIXME --';
1987                                 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.item_not_cataloged', [copy_status]);
1988                                 msg + '\n';
1989                         }
1990                         switch(Number(check.copy.status())) {
1991                                 case 0: /* AVAILABLE */
1992                                 case 7: /* RESHELVING */
1993                                         if (msg) {
1994                                                 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to', [check.route_to]);
1995                                                 msg += '\n';
1996                                         }
1997                                 break;
1998                                 case 8: /* ON HOLDS SHELF */
1999                                         check.route_to = 'HOLDS SHELF';
2000                                         if (check.payload.hold) {
2001                                                 if (check.payload.hold.pickup_lib() != data.list.au[0].ws_ou()) {
2002                                                         msg += document.getElementById('commonStrings').getString('common.error');
2003                                                         msg += '\nFIXME: ';
2004                                                         msg += document.getElementById('circStrings').getString('staff.circ.utils.route_item_error');
2005                                                         msg += '\n';
2006                                                 } else {
2007                                                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to', [check.route_to]);
2008                                                         msg += '.\n';
2009                                                 }
2010                                         } else {
2011                                                 msg += document.getElementById('commonStrings').getString('common.error');
2012                                                 msg += '\nFIXME: ';
2013                                                 msg += document.getElementById('circStrings').getString('staff.circ.utils.route_item_status_error');
2014                                                 msg += '\n';
2015                                         }
2016                                         JSAN.use('util.date');
2017                                         if (check.payload.hold) {
2018                                                 JSAN.use('patron.util');
2019                                                 msg += '\n';
2020                                                 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [check.payload.copy.barcode()]);
2021                                                 msg += '\n';
2022                                                 var payload_title  = (check.payload.record ? check.payload.record.title() : check.payload.copy.dummy_title() );
2023                                                 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.title', [payload_title]);
2024                                                 msg += '\n';
2025                                                 var au_obj = patron.util.retrieve_fleshed_au_via_id( session, check.payload.hold.usr() );
2026                                                 msg += '\n';
2027                                                 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.patron',  [au_obj.family_name(), au_obj.first_given_name(), au_obj.second_given_name()]);
2028                                                 msg += '\n';
2029                                                 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [au_obj.card().barcode()]);
2030                                                 msg += '\n';
2031                                                 if (check.payload.hold.phone_notify()) {
2032                                                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.phone_notify', [check.payload.hold.phone_notify()]);
2033                                                         msg += '\n';
2034                                                 }
2035                                                 if (check.payload.hold.email_notify()) {
2036                                                         var payload_email = au_obj.email() ? au_obj.email() : '';
2037                                                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.email_notify', [payload_email]);
2038                                                         msg += '\n';
2039                                                 }
2040                                                 msg += '\n';
2041                                                 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.request_date', [util.date.formatted_date(check.payload.hold.request_time(),'%F')]);
2042                                                 msg += '\n';
2043                                         }
2044                                         var rv = 0;
2045                                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.slip_date', [util.date.formatted_date(new Date(),'%F')]);
2046                                         msg += '\n';
2047                                         if (!auto_print) {
2048                                                 rv = error.yns_alert_formatted(
2049                                                         msg,
2050                                                         document.getElementById('circStrings').getString('staff.circ.utils.hold_slip'),
2051                                                         document.getElementById('circStrings').getString('staff.circ.utils.hold_slip.print.yes'),
2052                                                         document.getElementById('circStrings').getString('staff.circ.utils.hold_slip.print.no'),
2053                                                         null,
2054                                                         document.getElementById('circStrings').getString('staff.circ.confirm.msg'),
2055                                                         '/xul/server/skin/media/images/turtle.gif'
2056                                                 );
2057                                         }
2058                                         if (rv == 0) {
2059                                                 try {
2060                                                         JSAN.use('util.print'); var print = new util.print();
2061                                                         msg = msg.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\n/g,'<br/>');
2062                                                         print.simple( msg , { 'no_prompt' : true, 'content_type' : 'text/html' } );
2063                                                 } catch(E) {
2064                                                         var err_msg = document.getElementById('commonStrings').getString('common.error');
2065                                                         err_msg += '\nFIXME: ' + E + '\n';
2066                                                         dump(err_msg);
2067                                                         alert(err_msg);
2068                                                 }
2069                                         }
2070                                         msg = '';
2071                                         if (document.getElementById('no_change_label')) {
2072                                                 var m = document.getElementById('no_change_label').getAttribute('value');
2073                                                 m += document.getElementById('circStrings').getFormattedString('staff.circ.utils.capture', [params.barcode]);
2074                                                 document.getElementById('no_change_label').setAttribute('value', m);
2075                                                 document.getElementById('no_change_label').setAttribute('hidden','false');
2076                                         }
2077                                 break;
2078                                 case 6: /* IN TRANSIT */
2079                                         check.route_to = 'TRANSIT SHELF??';
2080                                         msg += document.getElementById('commonStrings').getString('common.error');
2081                                         msg += "\nFIXME -- I didn't think we could get here.\n";
2082                                 break;
2083                                 case 11: /* CATALOGING */
2084                                         check.route_to = 'CATALOGING';
2085                                         if (document.getElementById('do_not_alert_on_precat')) {
2086                                                 var x = document.getElementById('do_not_alert_on_precat');
2087                                                 if (! x.checked) {
2088                                                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to', [check.route_to]);
2089                                                 }
2090                                         } else {
2091                                                 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to', [check.route_to]);
2092                                         }
2093                                         if (document.getElementById('no_change_label')) {
2094                                                 var m = document.getElementById('no_change_label').getAttribute('value');
2095                                                 var needs_cat = document.getElementById('circStrings').getFormattedString('staff.circ.utils.needs_cataloging', [params.barcode]);
2096                                                 document.getElementById('no_change_label').setAttribute('value', m + needs_cat + '  ');
2097                                                 document.getElementById('no_change_label').setAttribute('hidden','false');
2098                                         }
2099                                 break;
2100                                 default:
2101                                         msg += document.getElementById('commonStrings').getString('common.error');
2102                                         var copy_status = data.hash.ccs[check.copy.status()] ? data.hash.ccs[check.copy.status()].name() : check.copy.status().name();
2103                                         msg += '\n';
2104                                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.copy_status.error', [copy_status]);
2105                                         msg += '\n';
2106                                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to', [check.route_to]);
2107                                 break;
2108                         }
2109                         if (msg) {
2110                                 error.yns_alert(
2111                                         msg,
2112                                         document.getElementById('circStrings').getString('staff.circ.alert'),
2113                                         null,
2114                                         document.getElementById('circStrings').getString('staff.circ.utils.msg.ok'),
2115                                         null,
2116                                         document.getElementById('circStrings').getString('staff.circ.confirm.msg')
2117                                 );
2118                         }
2119                 } else /* ROUTE_ITEM */ if (check.ilsevent == 7000) {
2120
2121                         var lib = data.hash.aou[ check.org ];
2122                         check.route_to = lib.shortname();
2123                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.destination', [check.route_to]);
2124                         msg += '\n\n';
2125                         msg += lib.name();
2126                         msg += '\n';
2127                         try {
2128                                 if (lib.holds_address() ) {
2129                                         var a = network.simple_request('FM_AOA_RETRIEVE',[ lib.holds_address() ]);
2130                                         if (typeof a.ilsevent != 'undefined') throw(a);
2131                                         if (a.street1()) msg += a.street1() + '\n';
2132                                         if (a.street2()) msg += a.street2() + '\n';
2133                                         msg += (a.city() ? a.city() + ', ' : '') + (a.state() ? a.state() + ' ' : '') + (a.post_code() ? a.post_code() : '') + '\n';
2134                                 } else {
2135                                         msg += document.getElementById('circStrings').getString('staff.circ.utils.route_to.no_address');
2136                                         msg += '\n';
2137                                 }
2138                         } catch(E) {
2139                                 msg += document.getElementById('circStrings').getString('staff.circ.utils.route_to.no_address.error');
2140                                 msg += '\n';
2141                                 error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.utils.route_to.no_address.error'), E);
2142                         }
2143                         msg += '\n';
2144                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [check.payload.copy.barcode()]);
2145                         msg += '\n';
2146                         var payload_title  = (check.payload.record ? check.payload.record.title() : check.payload.copy.dummy_title() );
2147                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.title', [payload_title]);
2148                         msg += '\n';
2149                         var payload_author = (check.payload.record ? check.payload.record.author() :check.payload.copy.dummy_author());
2150                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.author', [payload_author]);
2151                         msg += '\n';
2152                         JSAN.use('util.date');
2153                         if (check.payload.hold) {
2154                                 JSAN.use('patron.util');
2155                                 var au_obj = patron.util.retrieve_fleshed_au_via_id( session, check.payload.hold.usr() );
2156                                 msg += '\n';
2157                                 document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.patron', [au_obj.family_name(), au_obj.first_given_name(), au_obj.second_given_name()]);
2158                                 msg += '\n';
2159                                 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [au_obj.card().barcode()]);
2160                                 msg += '\n';
2161                                 if (check.payload.hold.phone_notify()) {
2162                                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.phone_notify', [check.payload.hold.phone_notify()]);
2163                                         msg += '\n';
2164                                 }
2165                                 if (check.payload.hold.email_notify()) {
2166                                         var payload_email = au_obj.email() ? au_obj.email() : '';
2167                                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.email_notify', [payload_email]);
2168                                         msg += '\n';
2169                                 }
2170                                 msg += '\n';
2171                                 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.request_date', [util.date.formatted_date(check.payload.hold.request_time(),'%F')]);
2172                                 msg += '\n';
2173                         }
2174                         var rv = 0;
2175                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.slip_date', [util.date.formatted_date(new Date(),'%F')]);
2176                         if (!auto_print) {
2177                                 rv = error.yns_alert_formatted(
2178                                         msg,
2179                                         document.getElementById('circStrings').getString('staff.circ.utils.hold_slip'),
2180                                         document.getElementById('circStrings').getString('staff.circ.utils.hold_slip.print.yes'),
2181                                         document.getElementById('circStrings').getString('staff.circ.utils.hold_slip.print.no'),
2182                                         null,
2183                                         document.getElementById('circStrings').getString('staff.circ.confirm.msg'),
2184                                         '/xul/server/skin/media/images/turtle.gif'
2185                                 );
2186                         }
2187
2188                         if (rv == 0) {
2189                                 try {
2190                                         JSAN.use('util.print'); var print = new util.print();
2191                                         //print.simple( msg, { 'no_prompt' : true, 'content_type' : 'text/plain' } );
2192                                         msg = msg.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\n/g,'<br/>');
2193                                         print.simple( msg , { 'no_prompt' : true, 'content_type' : 'text/html' } );
2194                                 } catch(E) {
2195                                         var err_msg = document.getElementById('commonStrings').getString('common.error');
2196                                         err_msg += '\nFIXME: ' + E + '\n';
2197                                         dump(err_msg);
2198                                         alert(err_msg);
2199                                 }
2200                         }
2201                         if (document.getElementById('no_change_label')) {
2202                                 var m = document.getElementById('no_change_label').getAttribute('value');
2203                                 var trans_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.in_transit', [params.barcode]);
2204                                 document.getElementById('no_change_label').setAttribute('value', m + trans_msg + '  ');
2205                                 document.getElementById('no_change_label').setAttribute('hidden','false');
2206                         }
2207
2208                 } else /* ASSET_COPY_NOT_FOUND */ if (check.ilsevent == 1502) {
2209
2210                         check.route_to = 'CATALOGING';
2211                         var mis_scan_msg = document.getElementById('circStrings').getFormattedString('staff.circ.copy_status.status.copy_not_found', [params.barcode]);
2212                         error.yns_alert(
2213                                 mis_scan_msg,
2214                                 document.getElementById('circStrings').getString('staff.circ.alert'),
2215                                 null,
2216                                 document.getElementById('circStrings').getString('staff.circ.utils.msg.ok'),
2217                                 null,
2218                                 document.getElementById('circStrings').getString('staff.circ.confirm.msg')
2219                         );
2220                         if (document.getElementById('no_change_label')) {
2221                                 var m = document.getElementById('no_change_label').getAttribute('value');
2222                                 document.getElementById('no_change_label').setAttribute('value',m + mis_scan_msg + '  ');
2223                                 document.getElementById('no_change_label').setAttribute('hidden','false');
2224                         }
2225
2226                 } else /* NETWORK TIMEOUT */ if (check.ilsevent == -1) {
2227                         error.standard_network_error_alert(document.getElementById('circStrings').getString('staff.circ.checkin.suggest_offline'));
2228                 } else {
2229
2230                         switch (Number(check.ilsevent)) {
2231                                 case 1203 /* COPY_BAD_STATUS */ :
2232                                 case 1213 /* PATRON_BARRED */ :
2233                                 case 1217 /* PATRON_INACTIVE */ :
2234                                 case 1224 /* PATRON_ACCOUNT_EXPIRED */ :
2235                                 case 7009 /* CIRC_CLAIMS_RETURNED */ :
2236                                 case 7010 /* COPY_ALERT_MESSAGE */ :
2237                                 case 7011 /* COPY_STATUS_LOST */ :
2238                                 case 7012 /* COPY_STATUS_MISSING */ :
2239                                 case 7013 /* PATRON_EXCEEDS_FINES */ :
2240                                         return null; /* handled */
2241                                 break;
2242                         }
2243
2244                         throw(check);
2245
2246                 }
2247
2248                 return check;
2249         } catch(E) {
2250                 JSAN.use('util.error'); var error = new util.error();
2251                 error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedMessage('staff.circ.checkin.error', ['3']), E);
2252                 return null;
2253         }
2254 };
2255
2256 circ.util.renew_via_barcode = function ( barcode, patron_id, async ) {
2257         try {
2258                 var obj = {};
2259                 JSAN.use('util.network'); obj.network = new util.network();
2260                 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.stash_retrieve();
2261
2262                 var params = { barcode: barcode };
2263                 if (patron_id) params.patron = patron_id;
2264
2265                 function renew_callback(req) {
2266                         try {
2267                                 var renew = req.getResultObject();
2268                                 if (typeof renew.ilsevent != 'undefined') renew = [ renew ];
2269                                 for (var j = 0; j < renew.length; j++) {
2270                                         switch(Number(renew[j].ilsevent)) {
2271                                                 case 0 /* SUCCESS */ : break;
2272                                                 case 5000 /* PERM_FAILURE */: break;
2273                                                 case 1212 /* PATRON_EXCEEDS_OVERDUE_COUNT */ : break;
2274                                                 case 1213 /* PATRON_BARRED */ : break;
2275                                                 case 1215 /* CIRC_EXCEEDS_COPY_RANGE */ : break;
2276                                                 case 1224 /* PATRON_ACCOUNT_EXPIRED */ : break;
2277                                                 case 1500 /* ACTION_CIRCULATION_NOT_FOUND */ : break;
2278                                                 case 7002 /* PATRON_EXCEEDS_CHECKOUT_COUNT */ : break;
2279                                                 case 7003 /* COPY_CIRC_NOT_ALLOWED */ : break;
2280                                                 case 7004 /* COPY_NOT_AVAILABLE */ : break;
2281                                                 case 7006 /* COPY_IS_REFERENCE */ : break;
2282                                                 case 7007 /* COPY_NEEDED_FOR_HOLD */ : break;
2283                                                 case 7008 /* MAX_RENEWALS_REACHED */ : break;
2284                                                 case 7009 /* CIRC_CLAIMS_RETURNED */ : break;
2285                                                 case 7010 /* COPY_ALERT_MESSAGE */ : break;
2286                                                 case 7013 /* PATRON_EXCEEDS_FINES */ : break;
2287                                                 default:
2288                                                         throw(renew);
2289                                                 break;
2290                                         }
2291                                 }
2292                                 if (typeof async == 'function') async(renew);
2293                                 return renew;
2294                         } catch(E) {
2295                                 JSAN.use('util.error'); var error = new util.error();
2296                                 error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedMessage('staff.circ.checkin.renew_failed.error', [barcode]), E);
2297                                 return null;
2298                         }
2299                 }
2300
2301                 var renew = obj.network.simple_request(
2302                         'CHECKOUT_RENEW',
2303                         [ ses(), params ],
2304                         async ? renew_callback : null,
2305                         {
2306                                 'title' : document.getElementById('circStrings').getMessage('staff.circ.checkin.renew_failed.override'),
2307                                 'overridable_events' : [
2308                                         1212 /* PATRON_EXCEEDS_OVERDUE_COUNT */,
2309                                         1213 /* PATRON_BARRED */,
2310                                         1215 /* CIRC_EXCEEDS_COPY_RANGE */,
2311                                         7002 /* PATRON_EXCEEDS_CHECKOUT_COUNT */,
2312                                         7003 /* COPY_CIRC_NOT_ALLOWED */,
2313                                         7004 /* COPY_NOT_AVAILABLE */,
2314                                         7006 /* COPY_IS_REFERENCE */,
2315                                         7007 /* COPY_NEEDED_FOR_HOLD */,
2316                                         7008 /* MAX_RENEWALS_REACHED */,
2317                                         7009 /* CIRC_CLAIMS_RETURNED */,
2318                                         7010 /* COPY_ALERT_MESSAGE */,
2319                                         7013 /* PATRON_EXCEEDS_FINES */,
2320                                 ],
2321                                 'text' : {
2322                                         '1212' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2323                                         '1213' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2324                                         '1215' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2325                                         '7002' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2326                                         '7003' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2327                                         '7004' : function(r) {
2328                                                 return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode.status', [barcode, r.payload.status().name()]);
2329                                         },
2330                                         '7006' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2331                                         '7007' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2332                                         '7008' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2333                                         '7009' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2334                                         '7010' : function(r) {
2335                                                 return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode.msg', [barcode, r.payload]);
2336                                         },
2337                                         '7013' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); }
2338                                 }
2339                         }
2340                 );
2341                 if (! async ) {
2342                         return renew_callback( { 'getResultObject' : function() { return renew; } } );
2343                 }
2344
2345         } catch(E) {
2346                 JSAN.use('util.error'); var error = new util.error();
2347                 error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.renew_failed.error', [barcode]), E);
2348                 return null;
2349         }
2350 };
2351
2352 dump('exiting circ/util.js\n');