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