]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/xul/staff_client/server/circ/util.js
473d97309cd868d3b5ca726729ba3d24229a316f
[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(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('commonStrings').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('commonStrings').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(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(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 (my.status) {
1383                                         case 1:
1384                                         case "1":
1385                                                 return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.1');
1386                                                 break;
1387                                         case 2:
1388                                         case "2":
1389                                                 return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.2');
1390                                                 break;
1391                                         case 3:
1392                                         case "3":
1393                                                 return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.3');
1394                                                 break;
1395                                         case 4:
1396                                         case "4":
1397                                                 return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.4');
1398                                                 break;
1399                                         default:
1400                                                 return my.status;
1401                                                 break;
1402                                 };
1403                         }
1404                 },
1405                 {
1406                         'persist' : 'hidden width ordinal',
1407                         'id' : 'hold_type',
1408                         'label' : document.getElementById('commonStrings').getString('staff.ahr_hold_type_label'),
1409                         'flex' : 0,
1410                         'primary' : false,
1411                         'hidden' : true,
1412                         'render' : function(my) { return my.ahr.hold_type(); },
1413                 },
1414         {
1415                         'persist' : 'hidden width ordinal',
1416                         'id' : 'frozen',
1417                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.frozen'),
1418                         'flex' : 0,
1419                         'primary' : false,
1420                         'hidden' : true,
1421                         'render' : function(my) {
1422                                 if (get_bool( my.ahr.frozen() )) {
1423                                         return document.getElementById('circStrings').getString('staff.circ.utils.yes');
1424                                 } else {
1425                                         return document.getElementById('circStrings').getString('staff.circ.utils.no');
1426                                 }
1427                         }
1428         },
1429         {
1430                         'persist' : 'hidden width ordinal',
1431                         'id' : 'thaw_date',
1432                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.thaw_date'),
1433                         'flex' : 0,
1434                         'primary' : false,
1435                         'hidden' : true,
1436                         'render' : function(my) {
1437                                 if (my.ahr.thaw_date() == null) {
1438                                         return document.getElementById('circStrings').getString('staff.circ.utils.thaw_date.none');
1439                                 } else {
1440                                         return my.ahr.thaw_date().substr(0,10);
1441                                 }
1442                         }
1443         },
1444                 {
1445                         'persist' : 'hidden width ordinal',
1446                         'id' : 'pickup_lib',
1447                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.pickup_lib'),
1448                         'flex' : 1,
1449                         'primary' : false,
1450                         'hidden' : true,
1451                         'render' : function(my) {
1452                                 if (Number(my.ahr.pickup_lib())>=0) {
1453                                         return data.hash.aou[ my.ahr.pickup_lib() ].name();
1454                                 } else {
1455                                         return my.ahr.pickup_lib().name();
1456                                 }
1457                         }
1458                 },
1459                 {
1460                         'persist' : 'hidden width ordinal',
1461                         'id' : 'pickup_lib_shortname',
1462                         'label' : document.getElementById('commonStrings').getString('staff.ahr_pickup_lib_label'),
1463                         'flex' : 0,
1464                         'primary' : false,
1465                         'hidden' : true,
1466                         'render' : function(my) {
1467                                 if (Number(my.ahr.pickup_lib())>=0) {
1468                                         return data.hash.aou[ my.ahr.pickup_lib() ].shortname();
1469                                 } else {
1470                                         return my.ahr.pickup_lib().shortname();
1471                                 }
1472                         }
1473                 },
1474                 {
1475                         'persist' : 'hidden width ordinal',
1476                         'id' : 'current_copy',
1477                         'label' : document.getElementById('commonStrings').getString('staff.ahr_current_copy_label'),
1478                         'flex' : 1,
1479                         'primary' : false,
1480                         'hidden' : true,
1481                         'render' : function(my) {
1482                                 if (my.acp) {
1483                                         return my.acp.barcode();
1484                                 } else {
1485                                         return document.getElementById('circStrings').getString('staff.circ.utils.current_copy.none');
1486                                 }
1487                         }
1488                 },
1489                 {
1490                         'persist' : 'hidden width ordinal',
1491                         'id' : 'email_notify',
1492                         'label' : document.getElementById('commonStrings').getString('staff.ahr_email_notify_label'),
1493                         'flex' : 1,
1494                         'primary' : false,
1495                         'hidden' : true,
1496                         'render' : function(my) {
1497                                 if (get_bool(my.ahr.email_notify())) {
1498                                         return document.getElementById('circStrings').getString('staff.circ.utils.current_copy.yes');
1499                                 } else {
1500                                         return document.getElementById('circStrings').getString('staff.circ.utils.current_copy.no');
1501                                 }
1502                         }
1503                 },
1504                 {
1505                         'persist' : 'hidden width ordinal',
1506                         'id' : 'expire_time',
1507                         'label' : document.getElementById('commonStrings').getString('staff.ahr_expire_time_label'),
1508                         'flex' : 1,
1509                         'primary' : false,
1510                         'hidden' : true,
1511                         'render' : function(my) { return my.ahr.expire_time(); }
1512                 },
1513                 {
1514                         'persist' : 'hidden width ordinal',
1515                         'id' : 'fulfillment_time',
1516                         'label' : document.getElementById('commonStrings').getString('staff.ahr_fulfillment_time_label'),
1517                         'flex' : 1,
1518                         'primary' : false,
1519                         'hidden' : true,
1520                         'render' : function(my) { return my.ahr.fulfillment_time(); }
1521                 },
1522                 {
1523                         'persist' : 'hidden width ordinal',
1524                         'id' : 'holdable_formats',
1525                         'label' : document.getElementById('commonStrings').getString('staff.ahr_holdable_formats_label'),
1526                         'flex' : 1,
1527                         'primary' : false,
1528                         'hidden' : true,
1529                         'render' : function(my) { return my.ahr.holdable_formats(); }
1530                 },
1531                 {
1532                         'persist' : 'hidden width ordinal',
1533                         'id' : 'id',
1534                         'label' : document.getElementById('commonStrings').getString('staff.ahr_id_label'),
1535                         'flex' : 1,
1536                         'primary' : false,
1537                         'hidden' : true,
1538                         'render' : function(my) { return my.ahr.id(); }
1539                 },
1540                 {
1541                         'persist' : 'hidden width ordinal',
1542                         'id' : 'phone_notify',
1543                         'label' : document.getElementById('commonStrings').getString('staff.ahr_phone_notify_label'),
1544                         'flex' : 1,
1545                         'primary' : false,
1546                         'hidden' : true,
1547                         'render' : function(my) { return my.ahr.phone_notify(); }
1548                 },
1549                 {
1550                         'persist' : 'hidden width ordinal',
1551                         'id' : 'prev_check_time',
1552                         'label' : document.getElementById('commonStrings').getString('staff.ahr_prev_check_time_label'),
1553                         'flex' : 1,
1554                         'primary' : false,
1555                         'hidden' : true,
1556                         'render' : function(my) { return my.ahr.prev_check_time(); }
1557                 },
1558                 {
1559                         'persist' : 'hidden width ordinal',
1560                         'id' : 'requestor',
1561                         'label' : document.getElementById('commonStrings').getString('staff.ahr_requestor_label'),
1562                         'flex' : 1,
1563                         'primary' : false,
1564                         'hidden' : true,
1565                         'render' : function(my) { return my.ahr.requestor(); }
1566                 },
1567                 {
1568                         'persist' : 'hidden width ordinal',
1569                         'id' : 'selection_depth',
1570                         'label' : document.getElementById('commonStrings').getString('staff.ahr_selection_depth_label'),
1571                         'flex' : 1,
1572                         'primary' : false,
1573                         'hidden' : true,
1574                         'render' : function(my) { return my.ahr.selection_depth(); }
1575                 },
1576                 {
1577                         'persist' : 'hidden width ordinal',
1578                         'id' : 'target',
1579                         'label' : document.getElementById('commonStrings').getString('staff.ahr_target_label'),
1580                         'flex' : 1,
1581                         'primary' : false,
1582                         'hidden' : true,
1583                         'render' : function(my) { return my.ahr.target(); }
1584                 },
1585                 {
1586                         'persist' : 'hidden width ordinal',
1587                         'id' : 'usr',
1588                         'label' : document.getElementById('commonStrings').getString('staff.ahr_usr_label'),
1589                         'flex' : 1,
1590                         'primary' : false,
1591                         'hidden' : true,
1592                         'render' : function(my) { return my.ahr.usr(); }
1593                 },
1594                 {
1595                         'persist' : 'hidden width ordinal',
1596                         'id' : 'title',
1597                         'label' : document.getElementById('commonStrings').getString('staff.mvr_label_title'),
1598                         'flex' : 1,
1599                         'sort_type' : 'title',
1600                         'primary' : false,
1601                         'hidden' : true,
1602                         'render' : function(my) {
1603                                 if (my.mvr) {
1604                                         return my.mvr.title();
1605                                 } else {
1606                                         return document.getElementById('circStrings').getString('staff.circ.utils.title.none');
1607                                 }
1608                         }
1609                 },
1610                 {
1611                         'persist' : 'hidden width ordinal',
1612                         'id' : 'author',
1613                         'label' : document.getElementById('commonStrings').getString('staff.mvr_label_author'),
1614                         'flex' : 1,
1615                         'primary' : false,
1616                         'hidden' : true,
1617                         'render' : function(my) {
1618                                 if (my.mvr) {
1619                                         return my.mvr.author();
1620                                 } else {
1621                                         return document.getElementById('circStrings').getString('staff.circ.utils.author.none');
1622                                 }
1623                         }
1624                 },
1625                 {
1626                         'persist' : 'hidden width ordinal',
1627                         'id' : 'edition',
1628                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.edition'),
1629                         'flex' : 1,
1630                         'primary' : false,
1631                         'hidden' : true,
1632                         'render' : function(my) { return my.mvr.edition(); }
1633                 },
1634                 {
1635                         'persist' : 'hidden width ordinal',
1636                         'id' : 'isbn',
1637                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.isbn'),
1638                         'flex' : 1,
1639                         'primary' : false,
1640                         'hidden' : true,
1641                         'render' : function(my) { return my.mvr.isbn(); }
1642                 },
1643                 {
1644                         'persist' : 'hidden width ordinal',
1645                         'id' : 'pubdate',
1646                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.pubdate'),
1647                         'flex' : 1,
1648                         'primary' : false,
1649                         'hidden' : true,
1650                         'render' : function(my) { return my.mvr.pubdate(); }
1651                 },
1652                 {
1653                         'persist' : 'hidden width ordinal',
1654                         'id' : 'publisher',
1655                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.publisher'),
1656                         'flex' : 1,
1657                         'primary' : false,
1658                         'hidden' : true,
1659                         'render' : function(my) { return my.mvr.publisher(); }
1660                 },
1661                 {
1662                         'persist' : 'hidden width ordinal',
1663                         'id' : 'tcn',
1664                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.tcn'),
1665                         'flex' : 1,
1666                         'primary' : false,
1667                         'hidden' : true,
1668                         'render' : function(my) { return my.mvr.tcn(); }
1669                 },
1670                 {
1671                         'persist' : 'hidden width ordinal',
1672                         'id' : 'notify_time',
1673                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.notify_time'),
1674                         'flex' : 1,
1675                         'primary' : false,
1676                         'hidden' : true,
1677                         'render' : function(my) { return my.ahr.notify_time(); }
1678                 },
1679                 {
1680                         'persist' : 'hidden width ordinal',
1681                         'id' : 'notify_count',
1682                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.notify_count'),
1683                         'flex' : 1,
1684                         'primary' : false,
1685                         'hidden' : true,
1686                         'render' : function(my) { return my.ahr.notify_count(); }
1687                 },
1688                 {
1689                         'persist' : 'hidden width ordinal',
1690                         'id' : 'transit_source',
1691                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_source'),
1692                         'flex' : 1,
1693                         'primary' : false,
1694                         'hidden' : true,
1695                         'render' : function(my) {
1696                                 if (my.ahr.transit()) {
1697                                         return data.hash.aou[ my.ahr.transit().source() ].shortname();
1698                                 } else {
1699                                         return "";
1700                                 }
1701                         }
1702                 },
1703                 {
1704                         'persist' : 'hidden width ordinal',
1705                         'id' : 'transit_source_send_time',
1706                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_source_send_time'),
1707                         'flex' : 1,
1708                         'primary' : false,
1709                         'hidden' : true,
1710                         'render' : function(my) { return my.ahr.transit() ?  my.ahr.transit().source_send_time() : ""; }
1711                 },
1712                 {
1713                         'persist' : 'hidden width ordinal',
1714                         'id' : 'transit_dest_lib',
1715                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_dest'),
1716                         'flex' : 1,
1717                         'primary' : false,
1718                         'hidden' : true,
1719                         'render' : function(my) { return my.ahr.transit() ?  data.hash.aou[ my.ahr.transit().dest() ].shortname() : ""; }
1720                 },
1721                 {
1722                         'persist' : 'hidden width ordinal',
1723                         'id' : 'transit_dest_recv_time',
1724                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_dest_recv_time'),
1725                         'flex' : 1,
1726                         'primary' : false,
1727                         'hidden' : true,
1728                         'render' : function(my) { return my.ahr.transit() ?  my.ahr.transit().dest_recv_time() : ""; }
1729                 },
1730                 {
1731                         'persist' : 'hidden width ordinal',
1732                         'id' : 'patron_barcode',
1733                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.patron_barcode'),
1734                         'flex' : 1,
1735                         'primary' : false,
1736                         'hidden' : true,
1737                         'render' : function(my) { return my.patron_barcode ? my.patron_barcode : ""; }
1738                 },
1739                 {
1740                         'persist' : 'hidden width ordinal',
1741                         'id' : 'patron_family_name',
1742                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.patron_family_name'),
1743                         'flex' : 1,
1744                         'primary' : false,
1745                         'hidden' : true,
1746                         'render' : function(my) { return my.patron_family_name ? my.patron_family_name : ""; }
1747                 },
1748                 {
1749                         'persist' : 'hidden width ordinal',
1750                         'id' : 'patron_first_given_name',
1751                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.patron_first_given_name'),
1752                         'flex' : 1,
1753                         'primary' : false,
1754                         'hidden' : true,
1755                         'render' : function(my) { return my.patron_first_given_name ? my.patron_first_given_name : ""; }
1756                 },
1757                 {
1758                         'persist' : 'hidden width ordinal',
1759                         'id' : 'callnumber',
1760                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.callnumber'),
1761                         'flex' : 1,
1762                         'primary' : false,
1763                         'hidden' : true,
1764                         'render' : function(my) { return my.acn.label(); }
1765                 },
1766         ];
1767         for (var i = 0; i < c.length; i++) {
1768                 if (modify[ c[i].id ]) {
1769                         for (var j in modify[ c[i].id ]) {
1770                                 c[i][j] = modify[ c[i].id ][j];
1771                         }
1772                 }
1773         }
1774         if (params) {
1775                 if (params.just_these) {
1776                         JSAN.use('util.functional');
1777                         var new_c = [];
1778                         for (var i = 0; i < params.just_these.length; i++) {
1779                                 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
1780                                 new_c.push( function(y){ return y; }( x ) );
1781                         }
1782                         c = new_c;
1783                 }
1784                 if (params.except_these) {
1785                         JSAN.use('util.functional');
1786                         var new_c = [];
1787                         for (var i = 0; i < c.length; i++) {
1788                                 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
1789                                 if (!x) new_c.push(c[i]);
1790                         }
1791                         c = new_c;
1792                 }
1793
1794         }
1795         return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
1796 };
1797 /*
1798 circ.util.std_map_row_to_column = function(error_value) {
1799         return function(row,col) {
1800                 // row contains { 'my' : { 'acp' : {}, 'circ' : {}, 'mvr' : {} } }
1801                 // col contains one of the objects listed above in columns
1802                 
1803                 // mimicking some of the obj in circ.checkin and circ.checkout where map_row_to_column is usually defined
1804                 var obj = {};
1805                 JSAN.use('util.error'); obj.error = new util.error();
1806                 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
1807                 JSAN.use('util.network'); obj.network = new util.network();
1808                 JSAN.use('util.money');
1809
1810                 var my = row.my;
1811                 var value;
1812                 try {
1813                         value = eval( col.render );
1814                 } catch(E) {
1815                         obj.error.sdump('D_WARN','map_row_to_column: ' + E);
1816                         if (error_value) value = error_value; else value = '   ';
1817                 }
1818                 return value;
1819         }
1820 };
1821 */
1822 circ.util.std_map_row_to_columns = function(error_value) {
1823         return function(row,cols) {
1824                 // row contains { 'my' : { 'acp' : {}, 'circ' : {}, 'mvr' : {} } }
1825                 // cols contains all of the objects listed above in columns
1826                 
1827                 var obj = {};
1828                 JSAN.use('util.error'); obj.error = new util.error();
1829                 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
1830                 JSAN.use('util.network'); obj.network = new util.network();
1831                 JSAN.use('util.money');
1832
1833                 var my = row.my;
1834                 var values = [];
1835                 var cmd = '';
1836                 try {
1837                         for (var i = 0; i < cols.length; i++) {
1838                                 switch (typeof cols[i].render) {
1839                                         case 'function': try { values[i] = cols[i].render(my); } catch(E) { values[i] = error_value; dump(E+'\n'); } break;
1840                                         case 'string' : cmd += 'try { ' + cols[i].render + '; values['+i+'] = v; } catch(E) { values['+i+'] = error_value; }'; break;
1841                                         default: cmd += 'values['+i+'] = "??? '+(typeof cols[i].render)+'"; ';
1842                                 }
1843                         }
1844                         if (cmd) eval( cmd );
1845                 } catch(E) {
1846                         obj.error.sdump('D_WARN','map_row_to_column: ' + E);
1847                         if (error_value) { value = error_value; } else { value = '   ' };
1848                 }
1849                 return values;
1850         }
1851 };
1852
1853 circ.util.checkin_via_barcode = function(session,params,backdate,auto_print,async) {
1854         try {
1855                 JSAN.use('util.error'); var error = new util.error();
1856                 JSAN.use('util.network'); var network = new util.network();
1857                 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
1858                 JSAN.use('util.date');
1859
1860                 if (backdate && (backdate == util.date.formatted_date(new Date(),'%Y-%m-%d')) ) backdate = null;
1861
1862                 //var params = { 'barcode' : barcode };
1863                 if (backdate) params.backdate = util.date.formatted_date(backdate + ' 00:00:00','%{iso8601}');
1864
1865                 if (typeof async == 'object') {
1866                         try { async.disable_textbox(); }
1867                         catch(E) { error.sdump('D_ERROR','async.disable_textbox() = ' + E); };
1868                 }
1869                 var check = network.request(
1870                         api.CHECKIN_VIA_BARCODE.app,
1871                         api.CHECKIN_VIA_BARCODE.method,
1872                         [ session, params ],
1873                         async ? function(req) {
1874                                 try {
1875                                         var check = req.getResultObject();
1876                                         var r = circ.util.checkin_via_barcode2(session,params,backdate,auto_print,check);
1877                                         if (typeof async == 'object') {
1878                                                 try { async.checkin_result(r); }
1879                                                 catch(E) { error.sdump('D_ERROR','async.checkin_result() = ' + E); };
1880                                         }
1881                                 } catch(E) {
1882                                         JSAN.use('util.error'); var error = new util.error();
1883                                         error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedMessage('staff.circ.checkin.error', ['1']), E);
1884                                         if (typeof async == 'object') {
1885                                                 try { async.enable_textbox(); }
1886                                                 catch(E) { error.sdump('D_ERROR','async.disable_textbox() = ' + E); };
1887                                         }
1888                                         return null;
1889                                 }
1890                         } : null,
1891                         {
1892                                 'title' : document.getElementById('circStrings').getString('staff.circ.utils.checkin.override'),
1893                                 'overridable_events' : [
1894                                         1203 /* COPY_BAD_STATUS */,
1895                                         1213 /* PATRON_BARRED */,
1896                                         1217 /* PATRON_INACTIVE */,
1897                                         1224 /* PATRON_ACCOUNT_EXPIRED */,
1898                                         7009 /* CIRC_CLAIMS_RETURNED */,
1899                                         7010 /* COPY_ALERT_MESSAGE */,
1900                                         7011 /* COPY_STATUS_LOST */,
1901                                         7012 /* COPY_STATUS_MISSING */,
1902                                         7013 /* PATRON_EXCEEDS_FINES */,
1903                                 ],
1904                                 'text' : {
1905                                         '1203' : function(r) {
1906                                                 //return data.hash.ccs[ r.payload.status() ].name();
1907                                                 return r.payload.status().name();
1908                                         },
1909                                         '7010' : function(r) {
1910                                                 return r.payload;
1911                                         },
1912                                 }
1913                         }
1914                 );
1915                 if (!async) {
1916                         return circ.util.checkin_via_barcode2(session,params,backdate,auto_print,check);
1917                 }
1918
1919
1920         } catch(E) {
1921                 JSAN.use('util.error'); var error = new util.error();
1922                 error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedMessage('staff.circ.checkin.error', ['2']), E);
1923                 if (typeof async == 'object') {
1924                         try { async.enable_textbox(); } catch(E) { error.sdump('D_ERROR','async.disable_textbox() = ' + E); };
1925                 }
1926                 return null;
1927         }
1928 };
1929
1930 circ.util.checkin_via_barcode2 = function(session,params,backdate,auto_print,check) {
1931         try {
1932                 JSAN.use('util.error'); var error = new util.error();
1933                 JSAN.use('util.network'); var network = new util.network();
1934                 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
1935                 JSAN.use('util.date');
1936
1937                 error.sdump('D_DEBUG','check = ' + error.pretty_print( js2JSON( check ) ) );
1938
1939                 check.message = check.textcode;
1940
1941                 if (check.payload && check.payload.copy) { check.copy = check.payload.copy; }
1942                 if (check.payload && check.payload.record) { check.record = check.payload.record; }
1943                 if (check.payload && check.payload.circ) { check.circ = check.payload.circ; }
1944
1945                 if (!check.route_to) { check.route_to = '   '; }
1946
1947                 if (document.getElementById('no_change_label')) {
1948                         document.getElementById('no_change_label').setAttribute('value','');
1949                         document.getElementById('no_change_label').setAttribute('hidden','true');
1950                 }
1951
1952                 if (check.circ) {
1953                         network.simple_request('FM_MBTS_RETRIEVE',[ses(),check.circ.id()], function(req) {
1954                                 JSAN.use('util.money');
1955                                 var bill = req.getResultObject();
1956                                 if (Number(bill.balance_owed()) == 0) { return; }
1957                                 if (document.getElementById('no_change_label')) {
1958                                         var m = document.getElementById('no_change_label').getAttribute('value');
1959                                         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())]) + '  ');
1960                                         document.getElementById('no_change_label').setAttribute('hidden','false');
1961                                 }
1962                         });
1963                 }
1964
1965                 var msg = '';
1966
1967                 if (check.payload && check.payload.cancelled_hold_transit) {
1968                         msg += document.getElementById('circStrings').getString('staff.circ.utils.transit_hold_cancelled');
1969                         msg += '\n\n';
1970                 }
1971
1972                 /* SUCCESS  /  NO_CHANGE  /  ITEM_NOT_CATALOGED */
1973                 if (check.ilsevent == 0 || check.ilsevent == 3 || check.ilsevent == 1202) {
1974                         try { check.route_to = data.lookup('acpl', check.copy.location() ).name(); }
1975                         catch(E) {
1976                                 msg += document.getElementById('commonStrings').getString('common.error');
1977                                 msg += '\nFIXME: ' + E + '\n';
1978                         }
1979                         if (check.ilsevent == 3 /* NO_CHANGE */) {
1980                                 //msg = 'This item is already checked in.\n';
1981                                 if (document.getElementById('no_change_label')) {
1982                                         var m = document.getElementById('no_change_label').getAttribute('value');
1983                                         document.getElementById('no_change_label').setAttribute('value', m + document.getElementById('circStrings').getFormattedString('staff.circ.utils.item_checked_in', [params.barcode]) + '  ');
1984                                         document.getElementById('no_change_label').setAttribute('hidden','false');
1985                                 }
1986                         }
1987                         if (check.ilsevent == 1202 /* ITEM_NOT_CATALOGED */ && check.copy.status() != 11) {
1988                                 var copy_status = (data.hash.ccs[ check.copy.status() ] ? data.hash.ccs[ check.copy.status() ].name() : check.copy.status().name() );
1989                                 msg = document.getElementById('commonStrings').getString('common.error');
1990                                 msg += '\nFIXME --';
1991                                 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.item_not_cataloged', [copy_status]);
1992                                 msg + '\n';
1993                         }
1994                         switch(check.copy.status()) {
1995                                 case 0: /* AVAILABLE */
1996                                 case 7: /* RESHELVING */
1997                                         if (msg) {
1998                                                 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to', [check.route_to]);
1999                                                 msg += '\n';
2000                                         }
2001                                 break;
2002                                 case 8: /* ON HOLDS SHELF */
2003                                         check.route_to = 'HOLDS SHELF';
2004                                         if (check.payload.hold) {
2005                                                 if (check.payload.hold.pickup_lib() != data.list.au[0].ws_ou()) {
2006                                                         msg += document.getElementById('commonStrings').getString('common.error');
2007                                                         msg += '\nFIXME: ';
2008                                                         msg += document.getElementById('circStrings').getString('staff.circ.utils.route_item_error');
2009                                                         msg += '\n';
2010                                                 } else {
2011                                                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to', [check.route_to]);
2012                                                         msg += '.\n';
2013                                                 }
2014                                         } else {
2015                                                 msg += document.getElementById('commonStrings').getString('common.error');
2016                                                 msg += '\nFIXME: ';
2017                                                 msg += document.getElementById('circStrings').getString('staff.circ.utils.route_item_status_error');
2018                                                 msg += '\n';
2019                                         }
2020                                         JSAN.use('util.date');
2021                                         if (check.payload.hold) {
2022                                                 JSAN.use('patron.util');
2023                                                 msg += '\n';
2024                                                 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [check.payload.copy.barcode()]);
2025                                                 msg += '\n';
2026                                                 var payload_title  = (check.payload.record ? check.payload.record.title() : check.payload.copy.dummy_title() );
2027                                                 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.title', [payload_title]);
2028                                                 msg += '\n';
2029                                                 var au_obj = patron.util.retrieve_fleshed_au_via_id( session, check.payload.hold.usr() );
2030                                                 msg += '\n';
2031                                                 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()]);
2032                                                 msg += '\n';
2033                                                 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [au_obj.card().barcode()]);
2034                                                 msg += '\n';
2035                                                 if (check.payload.hold.phone_notify()) {
2036                                                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.phone_notify', [check.payload.hold.phone_notify()]);
2037                                                         msg += '\n';
2038                                                 }
2039                                                 if (check.payload.hold.email_notify()) {
2040                                                         var payload_email = au_obj.email() ? au_obj.email() : '';
2041                                                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.email_notify', [payload_email]);
2042                                                         msg += '\n';
2043                                                 }
2044                                                 msg += '\n';
2045                                                 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.request_date', [util.date.formatted_date(check.payload.hold.request_time(),'%F')]);
2046                                                 msg += '\n';
2047                                         }
2048                                         var rv = 0;
2049                                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.slip_date', [util.date.formatted_date(new Date(),'%F')]);
2050                                         msg += '\n';
2051                                         if (!auto_print) {
2052                                                 rv = error.yns_alert_formatted(
2053                                                         msg,
2054                                                         document.getElementById('circStrings').getString('staff.circ.utils.hold_slip'),
2055                                                         document.getElementById('circStrings').getString('staff.circ.utils.hold_slip.print.yes'),
2056                                                         document.getElementById('circStrings').getString('staff.circ.utils.hold_slip.print.no'),
2057                                                         null,
2058                                                         document.getElementById('circStrings').getString('staff.circ.confirm.msg'),
2059                                                         '/xul/server/skin/media/images/turtle.gif'
2060                                                 );
2061                                         }
2062                                         if (rv == 0) {
2063                                                 try {
2064                                                         JSAN.use('util.print'); var print = new util.print();
2065                                                         msg = msg.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\n/g,'<br/>');
2066                                                         print.simple( msg , { 'no_prompt' : true, 'content_type' : 'text/html' } );
2067                                                 } catch(E) {
2068                                                         var err_msg = document.getElementById('commonStrings').getString('common.error');
2069                                                         err_msg += '\nFIXME: ' + E + '\n';
2070                                                         dump(err_msg);
2071                                                         alert(err_msg);
2072                                                 }
2073                                         }
2074                                         msg = '';
2075                                         if (document.getElementById('no_change_label')) {
2076                                                 var m = document.getElementById('no_change_label').getAttribute('value');
2077                                                 m += document.getElementById('circStrings').getFormattedString('staff.circ.utils.capture', [params.barcode]);
2078                                                 document.getElementById('no_change_label').setAttribute('value', m);
2079                                                 document.getElementById('no_change_label').setAttribute('hidden','false');
2080                                         }
2081                                 break;
2082                                 case 6: /* IN TRANSIT */
2083                                         check.route_to = 'TRANSIT SHELF??';
2084                                         msg += document.getElementById('commonStrings').getString('common.error');
2085                                         msg += "\nFIXME -- I didn't think we could get here.\n";
2086                                 break;
2087                                 case 11: /* CATALOGING */
2088                                         check.route_to = 'CATALOGING';
2089                                         if (document.getElementById('do_not_alert_on_precat')) {
2090                                                 var x = document.getElementById('do_not_alert_on_precat');
2091                                                 if (! x.checked) {
2092                                                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to', [check.route_to]);
2093                                                 }
2094                                         } else {
2095                                                 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to', [check.route_to]);
2096                                         }
2097                                         if (document.getElementById('no_change_label')) {
2098                                                 var m = document.getElementById('no_change_label').getAttribute('value');
2099                                                 var needs_cat = document.getElementById('circStrings').getFormattedString('staff.circ.utils.needs_cataloging', [params.barcode]);
2100                                                 document.getElementById('no_change_label').setAttribute('value', m + needs_cat + '  ');
2101                                                 document.getElementById('no_change_label').setAttribute('hidden','false');
2102                                         }
2103                                 break;
2104                                 default:
2105                                         msg += document.getElementById('commonStrings').getString('common.error');
2106                                         var copy_status = data.hash.ccs[check.copy.status()] ? data.hash.ccs[check.copy.status()].name() : check.copy.status().name();
2107                                         msg += '\n';
2108                                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.copy_status.error', [copy_status]);
2109                                         msg += '\n';
2110                                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to', [check.route_to]);
2111                                 break;
2112                         }
2113                         if (msg) {
2114                                 error.yns_alert(
2115                                         msg,
2116                                         document.getElementById('circStrings').getString('staff.circ.alert'),
2117                                         null,
2118                                         document.getElementById('circStrings').getString('staff.circ.utils.msg.ok'),
2119                                         null,
2120                                         document.getElementById('circStrings').getString('staff.circ.confirm.msg')
2121                                 );
2122                         }
2123                 } else /* ROUTE_ITEM */ if (check.ilsevent == 7000) {
2124
2125                         var lib = data.hash.aou[ check.org ];
2126                         check.route_to = lib.shortname();
2127                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.destination', [check.route_to]);
2128                         msg += '\n\n';
2129                         msg += lib.name();
2130                         msg += '\n';
2131                         try {
2132                                 if (lib.holds_address() ) {
2133                                         var a = network.simple_request('FM_AOA_RETRIEVE',[ lib.holds_address() ]);
2134                                         if (typeof a.ilsevent != 'undefined') throw(a);
2135                                         if (a.street1()) msg += a.street1() + '\n';
2136                                         if (a.street2()) msg += a.street2() + '\n';
2137                                         msg += (a.city() ? a.city() + ', ' : '') + (a.state() ? a.state() + ' ' : '') + (a.post_code() ? a.post_code() : '') + '\n';
2138                                 } else {
2139                                         msg += document.getElementById('circStrings').getString('staff.circ.utils.route_to.no_address');
2140                                         msg += '\n';
2141                                 }
2142                         } catch(E) {
2143                                 msg += document.getElementById('circStrings').getString('staff.circ.utils.route_to.no_address.error');
2144                                 msg += '\n';
2145                                 error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.utils.route_to.no_address.error'), E);
2146                         }
2147                         msg += '\n';
2148                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [check.payload.copy.barcode()]);
2149                         msg += '\n';
2150                         var payload_title  = (check.payload.record ? check.payload.record.title() : check.payload.copy.dummy_title() );
2151                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.title', [payload_title]);
2152                         msg += '\n';
2153                         var payload_author = (check.payload.record ? check.payload.record.author() :check.payload.copy.dummy_author());
2154                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.author', [payload_author]);
2155                         msg += '\n';
2156                         JSAN.use('util.date');
2157                         if (check.payload.hold) {
2158                                 JSAN.use('patron.util');
2159                                 var au_obj = patron.util.retrieve_fleshed_au_via_id( session, check.payload.hold.usr() );
2160                                 msg += '\n';
2161                                 document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.patron', [au_obj.family_name(), au_obj.first_given_name(), au_obj.second_given_name()]);
2162                                 msg += '\n';
2163                                 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [au_obj.card().barcode()]);
2164                                 msg += '\n';
2165                                 if (check.payload.hold.phone_notify()) {
2166                                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.phone_notify', [check.payload.hold.phone_notify()]);
2167                                         msg += '\n';
2168                                 }
2169                                 if (check.payload.hold.email_notify()) {
2170                                         var payload_email = au_obj.email() ? au_obj.email() : '';
2171                                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.email_notify', [payload_email]);
2172                                         msg += '\n';
2173                                 }
2174                                 msg += '\n';
2175                                 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.request_date', [util.date.formatted_date(check.payload.hold.request_time(),'%F')]);
2176                                 msg += '\n';
2177                         }
2178                         var rv = 0;
2179                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.slip_date', [util.date.formatted_date(new Date(),'%F')]);
2180                         if (!auto_print) {
2181                                 rv = error.yns_alert_formatted(
2182                                         msg,
2183                                         document.getElementById('circStrings').getString('staff.circ.utils.hold_slip'),
2184                                         document.getElementById('circStrings').getString('staff.circ.utils.hold_slip.print.yes'),
2185                                         document.getElementById('circStrings').getString('staff.circ.utils.hold_slip.print.no'),
2186                                         null,
2187                                         document.getElementById('circStrings').getString('staff.circ.confirm.msg'),
2188                                         '/xul/server/skin/media/images/turtle.gif'
2189                                 );
2190                         }
2191
2192                         if (rv == 0) {
2193                                 try {
2194                                         JSAN.use('util.print'); var print = new util.print();
2195                                         //print.simple( msg, { 'no_prompt' : true, 'content_type' : 'text/plain' } );
2196                                         msg = msg.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\n/g,'<br/>');
2197                                         print.simple( msg , { 'no_prompt' : true, 'content_type' : 'text/html' } );
2198                                 } catch(E) {
2199                                         var err_msg = document.getElementById('commonStrings').getString('common.error');
2200                                         err_msg += '\nFIXME: ' + E + '\n';
2201                                         dump(err_msg);
2202                                         alert(err_msg);
2203                                 }
2204                         }
2205                         if (document.getElementById('no_change_label')) {
2206                                 var m = document.getElementById('no_change_label').getAttribute('value');
2207                                 var trans_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.in_transit', [params.barcode]);
2208                                 document.getElementById('no_change_label').setAttribute('value', m + trans_msg + '  ');
2209                                 document.getElementById('no_change_label').setAttribute('hidden','false');
2210                         }
2211
2212                 } else /* ASSET_COPY_NOT_FOUND */ if (check.ilsevent == 1502) {
2213
2214                         check.route_to = 'CATALOGING';
2215                         var mis_scan_msg = document.getElementById('circStrings').getFormattedString('staff.circ.copy_status.status.copy_not_found', [params.barcode]);
2216                         error.yns_alert(
2217                                 mis_scan_msg,
2218                                 document.getElementById('circStrings').getString('staff.circ.alert'),
2219                                 null,
2220                                 document.getElementById('circStrings').getString('staff.circ.utils.msg.ok'),
2221                                 null,
2222                                 document.getElementById('circStrings').getString('staff.circ.confirm.msg')
2223                         );
2224                         if (document.getElementById('no_change_label')) {
2225                                 var m = document.getElementById('no_change_label').getAttribute('value');
2226                                 document.getElementById('no_change_label').setAttribute('value',m + mis_scan_msg + '  ');
2227                                 document.getElementById('no_change_label').setAttribute('hidden','false');
2228                         }
2229
2230                 } else /* NETWORK TIMEOUT */ if (check.ilsevent == -1) {
2231                         error.standard_network_error_alert(document.getElementById('circStrings').getString('staff.circ.checkin.suggest_offline'));
2232                 } else {
2233
2234                         switch (check.ilsevent) {
2235                                 case 1203 /* COPY_BAD_STATUS */ :
2236                                 case 1213 /* PATRON_BARRED */ :
2237                                 case 1217 /* PATRON_INACTIVE */ :
2238                                 case 1224 /* PATRON_ACCOUNT_EXPIRED */ :
2239                                 case 7009 /* CIRC_CLAIMS_RETURNED */ :
2240                                 case 7010 /* COPY_ALERT_MESSAGE */ :
2241                                 case 7011 /* COPY_STATUS_LOST */ :
2242                                 case 7012 /* COPY_STATUS_MISSING */ :
2243                                 case 7013 /* PATRON_EXCEEDS_FINES */ :
2244                                         return null; /* handled */
2245                                 break;
2246                         }
2247
2248                         throw(check);
2249
2250                 }
2251
2252                 return check;
2253         } catch(E) {
2254                 JSAN.use('util.error'); var error = new util.error();
2255                 error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedMessage('staff.circ.checkin.error', ['3']), E);
2256                 return null;
2257         }
2258 };
2259
2260 circ.util.renew_via_barcode = function ( barcode, patron_id, async ) {
2261         try {
2262                 var obj = {};
2263                 JSAN.use('util.network'); obj.network = new util.network();
2264                 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.stash_retrieve();
2265
2266                 var params = { barcode: barcode };
2267                 if (patron_id) params.patron = patron_id;
2268
2269                 function renew_callback(req) {
2270                         try {
2271                                 var renew = req.getResultObject();
2272                                 if (typeof renew.ilsevent != 'undefined') renew = [ renew ];
2273                                 for (var j = 0; j < renew.length; j++) {
2274                                         switch(renew[j].ilsevent) {
2275                                                 case 0 /* SUCCESS */ : break;
2276                                                 case 5000 /* PERM_FAILURE */: break;
2277                                                 case 1212 /* PATRON_EXCEEDS_OVERDUE_COUNT */ : break;
2278                                                 case 1213 /* PATRON_BARRED */ : break;
2279                                                 case 1215 /* CIRC_EXCEEDS_COPY_RANGE */ : break;
2280                                                 case 1224 /* PATRON_ACCOUNT_EXPIRED */ : break;
2281                                                 case 1500 /* ACTION_CIRCULATION_NOT_FOUND */ : break;
2282                                                 case 7002 /* PATRON_EXCEEDS_CHECKOUT_COUNT */ : break;
2283                                                 case 7003 /* COPY_CIRC_NOT_ALLOWED */ : break;
2284                                                 case 7004 /* COPY_NOT_AVAILABLE */ : break;
2285                                                 case 7006 /* COPY_IS_REFERENCE */ : break;
2286                                                 case 7007 /* COPY_NEEDED_FOR_HOLD */ : break;
2287                                                 case 7008 /* MAX_RENEWALS_REACHED */ : break;
2288                                                 case 7009 /* CIRC_CLAIMS_RETURNED */ : break;
2289                                                 case 7010 /* COPY_ALERT_MESSAGE */ : break;
2290                                                 case 7013 /* PATRON_EXCEEDS_FINES */ : break;
2291                                                 default:
2292                                                         throw(renew);
2293                                                 break;
2294                                         }
2295                                 }
2296                                 if (typeof async == 'function') async(renew);
2297                                 return renew;
2298                         } catch(E) {
2299                                 JSAN.use('util.error'); var error = new util.error();
2300                                 error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedMessage('staff.circ.checkin.renew_failed.error', [barcode]), E);
2301                                 return null;
2302                         }
2303                 }
2304
2305                 var renew = obj.network.simple_request(
2306                         'CHECKOUT_RENEW',
2307                         [ ses(), params ],
2308                         async ? renew_callback : null,
2309                         {
2310                                 'title' : document.getElementById('circStrings').getMessage('staff.circ.checkin.renew_failed.override'),
2311                                 'overridable_events' : [
2312                                         1212 /* PATRON_EXCEEDS_OVERDUE_COUNT */,
2313                                         1213 /* PATRON_BARRED */,
2314                                         1215 /* CIRC_EXCEEDS_COPY_RANGE */,
2315                                         7002 /* PATRON_EXCEEDS_CHECKOUT_COUNT */,
2316                                         7003 /* COPY_CIRC_NOT_ALLOWED */,
2317                                         7004 /* COPY_NOT_AVAILABLE */,
2318                                         7006 /* COPY_IS_REFERENCE */,
2319                                         7007 /* COPY_NEEDED_FOR_HOLD */,
2320                                         7008 /* MAX_RENEWALS_REACHED */,
2321                                         7009 /* CIRC_CLAIMS_RETURNED */,
2322                                         7010 /* COPY_ALERT_MESSAGE */,
2323                                         7013 /* PATRON_EXCEEDS_FINES */,
2324                                 ],
2325                                 'text' : {
2326                                         '1212' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2327                                         '1213' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2328                                         '1215' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2329                                         '7002' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2330                                         '7003' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2331                                         '7004' : function(r) {
2332                                                 return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode.status', [barcode, r.payload.status().name()]);
2333                                         },
2334                                         '7006' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2335                                         '7007' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2336                                         '7008' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2337                                         '7009' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2338                                         '7010' : function(r) {
2339                                                 return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode.msg', [barcode, r.payload]);
2340                                         },
2341                                         '7013' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); }
2342                                 }
2343                         }
2344                 );
2345                 if (! async ) {
2346                         return renew_callback( { 'getResultObject' : function() { return renew; } } );
2347                 }
2348
2349         } catch(E) {
2350                 JSAN.use('util.error'); var error = new util.error();
2351                 error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.renew_failed.error', [barcode]), E);
2352                 return null;
2353         }
2354 };
2355
2356 dump('exiting circ/util.js\n');