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