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