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