]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/xul/staff_client/server/circ/util.js
Action for Backdating Already-Checked In Circs
[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.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         for (var i = 0; i < c.length; i++) {
1172                 if (modify[ c[i].id ]) {
1173                         for (var j in modify[ c[i].id ]) {
1174                                 c[i][j] = modify[ c[i].id ][j];
1175                         }
1176                 }
1177         }
1178         if (params) {
1179                 if (params.just_these) {
1180                         JSAN.use('util.functional');
1181                         var new_c = [];
1182                         for (var i = 0; i < params.just_these.length; i++) {
1183                                 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
1184                                 new_c.push( function(y){ return y; }( x ) );
1185                         }
1186                         c = new_c;
1187                 }
1188                 if (params.except_these) {
1189                         JSAN.use('util.functional');
1190                         var new_c = [];
1191                         for (var i = 0; i < c.length; i++) {
1192                                 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
1193                                 if (!x) new_c.push(c[i]);
1194                         }
1195                         c = new_c;
1196                 }
1197         }
1198         return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
1199 };
1200
1201 circ.util.work_log_columns = function(modify,params) {
1202
1203         JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
1204
1205         var c = [
1206                 {
1207                         'persist' : 'hidden width ordinal',
1208                         'id' : 'message',
1209                         'label' : document.getElementById('circStrings').getString('staff.circ.work_log_column.message'),
1210                         'flex' : 3,
1211                         'primary' : true,
1212                         'hidden' : false,
1213                         'render' : function(my) { return my.message; }
1214                 },
1215                 {
1216                         'persist' : 'hidden width ordinal',
1217                         'id' : 'when',
1218                         'label' : document.getElementById('circStrings').getString('staff.circ.work_log_column.when'),
1219                         'flex' : 1,
1220                         'primary' : false,
1221                         'hidden' : false,
1222                         'render' : function(my) { return String( my.when ); }
1223                 }
1224
1225         ];
1226         for (var i = 0; i < c.length; i++) {
1227                 if (modify[ c[i].id ]) {
1228                         for (var j in modify[ c[i].id ]) {
1229                                 c[i][j] = modify[ c[i].id ][j];
1230                         }
1231                 }
1232         }
1233         if (params) {
1234                 if (params.just_these) {
1235                         JSAN.use('util.functional');
1236                         var new_c = [];
1237                         for (var i = 0; i < params.just_these.length; i++) {
1238                                 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
1239                                 new_c.push( function(y){ return y; }( x ) );
1240                         }
1241                         c = new_c;
1242                 }
1243                 if (params.except_these) {
1244                         JSAN.use('util.functional');
1245                         var new_c = [];
1246                         for (var i = 0; i < c.length; i++) {
1247                                 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
1248                                 if (!x) new_c.push(c[i]);
1249                         }
1250                         c = new_c;
1251                 }
1252
1253         }
1254         return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
1255 };
1256
1257 circ.util.transit_columns = function(modify,params) {
1258
1259         JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
1260
1261         var c = [
1262                 {
1263                         'persist' : 'hidden width ordinal',
1264                         'id' : 'transit_item_barcode',
1265                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.barcode'),
1266                         'flex' : 1,
1267                         'primary' : false,
1268                         'hidden' : true,
1269                         'render' : function(my) { return my.acp.barcode(); }
1270                 },
1271                 {
1272                         'persist' : 'hidden width ordinal',
1273                         'id' : 'transit_item_title',
1274                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.title'),
1275                         'flex' : 1,
1276                         'primary' : false,
1277                         'hidden' : true,
1278                         'render' : function(my) {
1279                                 try { return my.mvr.title(); }
1280                                 catch(E) { return my.acp.dummy_title(); }
1281                         }
1282                 },
1283                 {
1284                         'persist' : 'hidden width ordinal',
1285                         'id' : 'transit_item_author',
1286                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.author'),
1287                         'flex' : 1,
1288                         'primary' : false,
1289                         'hidden' : true,
1290                         'render' : function(my) {
1291                                 try { return my.mvr.author(); }
1292                                 catch(E) { return my.acp.dummy_author(); }
1293                         }
1294                 },
1295                 {
1296                         'persist' : 'hidden width ordinal',
1297                         'id' : 'transit_item_callnumber',
1298                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.callnumber'),
1299                         'flex' : 1,
1300                         'primary' : false,
1301                         'hidden' : true,
1302                         'render' : function(my) { return my.acn.label(); }
1303                 },
1304                 {
1305                         'persist' : 'hidden width ordinal',
1306                         'id' : 'transit_id',
1307                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_id'),
1308                         'flex' : 1,
1309                         'primary' : false,
1310                         'hidden' : true,
1311                         'render' : function(my) { return my.atc.id(); }
1312                 },
1313                 {
1314                         'persist' : 'hidden width ordinal',
1315                         'id' : 'transit_source',
1316                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_source'),
1317                         'flex' : 1,
1318                         'primary' : false,
1319                         'hidden' : false,
1320                         'render' : function(my) {
1321                                 if (typeof my.atc.source() == "object") {
1322                                         return my.atc.source().shortname();
1323                                 } else {
1324                                         return data.hash.aou[ my.atc.source() ].shortname();
1325                                 }
1326                         }
1327                 },
1328                 {
1329                         'persist' : 'hidden width ordinal',
1330                         'id' : 'transit_source_send_time',
1331                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_source_send_time'),
1332                         'flex' : 1,
1333                         'primary' : false,
1334                         'hidden' : false,
1335                         'render' : function(my) { return my.atc.source_send_time(); }
1336                 },
1337                 {
1338                         'persist' : 'hidden width ordinal',
1339                         'id' : 'transit_dest_lib',
1340                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_dest'),
1341                         'flex' : 1,
1342                         'primary' : false,
1343                         'hidden' : false,
1344                         'render' : function(my) {
1345                                 if (typeof my.atc.dest() == "object") {
1346                                         return my.atc.dest().shortname();
1347                                 } else {
1348                                         return data.hash.aou[ my.atc.dest() ].shortname();
1349                                 }
1350                         }
1351                 },
1352                 {
1353                         'persist' : 'hidden width ordinal',
1354                         'id' : 'transit_dest_recv_time',
1355                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_dest_recv_time'),
1356                         'flex' : 1,
1357                         'primary' : false,
1358                         'hidden' : false,
1359                         'render' : function(my) { return my.atc.dest_recv_time(); }
1360                 },
1361                 {
1362                         'persist' : 'hidden width ordinal',
1363                         'id' : 'transit_target_copy',
1364                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_target_copy'),
1365                         'flex' : 1,
1366                         'primary' : false,
1367                         'hidden' : true,
1368                         'render' : function(my) { return my.atc.target_copy(); }
1369                 },
1370         ];
1371         for (var i = 0; i < c.length; i++) {
1372                 if (modify[ c[i].id ]) {
1373                         for (var j in modify[ c[i].id ]) {
1374                                 c[i][j] = modify[ c[i].id ][j];
1375                         }
1376                 }
1377         }
1378         if (params) {
1379                 if (params.just_these) {
1380                         JSAN.use('util.functional');
1381                         var new_c = [];
1382                         for (var i = 0; i < params.just_these.length; i++) {
1383                                 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
1384                                 new_c.push( function(y){ return y; }( x ) );
1385                         }
1386                         c = new_c;
1387                 }
1388                 if (params.except_these) {
1389                         JSAN.use('util.functional');
1390                         var new_c = [];
1391                         for (var i = 0; i < c.length; i++) {
1392                                 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
1393                                 if (!x) new_c.push(c[i]);
1394                         }
1395                         c = new_c;
1396                 }
1397
1398         }
1399         return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
1400 };
1401
1402 circ.util.hold_columns = function(modify,params) {
1403
1404         JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
1405
1406         var c = [
1407                 {
1408                         'persist' : 'hidden width ordinal',
1409                         'id' : 'request_lib',
1410                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.request_lib'),
1411                         'flex' : 1,
1412                         'primary' : false,
1413                         'hidden' : true,
1414                         'render' : function(my) {
1415                                 if (Number(my.ahr.request_lib())>=0) {
1416                                         return data.hash.aou[ my.ahr.request_lib() ].name();
1417                                 } else {
1418                                         return my.ahr.request_lib().name();
1419                                 }
1420                         }
1421                 },
1422                 {
1423                         'persist' : 'hidden width ordinal',
1424                         'id' : 'request_lib_shortname',
1425                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.request_lib_shortname'),
1426                         'flex' : 0,
1427                         'primary' : false,
1428                         'hidden' : true,
1429                         'render' : function(my) {
1430                                 if (Number(my.ahr.request_lib())>=0) {
1431                                         return data.hash.aou[ my.ahr.request_lib() ].shortname();
1432                                 } else {
1433                                         return my.ahr.request_lib().shortname();
1434                                 }
1435                         }
1436                 },
1437
1438                 {
1439                         'persist' : 'hidden width ordinal',
1440                         'id' : 'request_timestamp',
1441                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.request_timestamp'),
1442                         'flex' : 0,
1443                         'primary' : false,
1444                         'hidden' : true,
1445                         'render' : function(my) { return my.ahr.request_time().toString(); }
1446                 },
1447                 {
1448                         'persist' : 'hidden width ordinal',
1449                         'id' : 'request_time',
1450                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.request_time'),
1451                         'flex' : 0,
1452                         'primary' : false,
1453                         'hidden' : true,
1454                         'render' : function(my) { return my.ahr.request_time().toString().substr(0,10); }
1455                 },
1456                 {
1457                         'persist' : 'hidden width ordinal',
1458                         'id' : 'available_timestamp',
1459                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.available_timestamp'),
1460                         'flex' : 1,
1461                         'primary' : false,
1462                         'hidden' : true,
1463                         'render' : function(my) {
1464                                 if (my.ahr.transit() && my.ahr.transit().dest_recv_time()) {
1465                                         return my.ahr.transit().dest_recv_time().toString();
1466                                 }
1467                                 if (!my.ahr.transit() && my.ahr.capture_time()) {
1468                                         return my.ahr.capture_time().toString();
1469                                 }
1470                                 return "";
1471                         }
1472                 },
1473                 {
1474                         'persist' : 'hidden width ordinal',
1475                         'id' : 'available_time',
1476                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.available_time'),
1477                         'flex' : 1,
1478                         'primary' : false,
1479                         'hidden' : false,
1480                         'render' : function(my) {
1481                                 if (my.ahr.transit() && my.ahr.transit().dest_recv_time()) {
1482                                         return my.ahr.transit().dest_recv_time().toString().substr(0,10);
1483                                 }
1484                                 if (!my.ahr.transit() && my.ahr.capture_time()) {
1485                                         return my.ahr.capture_time().toString().substr(0,10);
1486                                 }
1487                                 return "";
1488                         }
1489                 },
1490                 {
1491                         'persist' : 'hidden width ordinal',
1492                         'id' : 'capture_timestamp',
1493                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.capture_timestamp'),
1494                         'flex' : 1,
1495                         'primary' : false,
1496                         'hidden' : true,
1497                         'render' : function(my) { return my.ahr.capture_time() ? my.ahr.capture_time().toString() : ""; }
1498                 },
1499                 {
1500                         'persist' : 'hidden width ordinal',
1501                         'id' : 'capture_time',
1502                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.capture_time'),
1503                         'flex' : 1,
1504                         'primary' : false,
1505                         'hidden' : true,
1506                         'render' : function(my) { return my.ahr.capture_time() ? my.ahr.capture_time().toString().substr(0,10) : ""; }
1507                 },
1508                 {
1509                         'persist' : 'hidden width ordinal',
1510                         'id' : 'status',
1511                         'label' : document.getElementById('commonStrings').getString('staff.ahr_status_label'),
1512                         'flex' : 1,
1513                         'primary' : false,
1514                         'hidden' : false,
1515                         'render' : function(my) {
1516                                 switch (Number(my.status)) {
1517                                         case 1:
1518                                                 return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.1');
1519                                                 break;
1520                                         case 2:
1521                                                 return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.2');
1522                                                 break;
1523                                         case 3:
1524                                                 return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.3');
1525                                                 break;
1526                                         case 4:
1527                                                 return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.4');
1528                                                 break;
1529                                         case 5:
1530                                                 return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.5');
1531                                                 break;
1532                                         default:
1533                                                 return my.status;
1534                                                 break;
1535                                 };
1536                         }
1537                 },
1538                 {
1539                         'persist' : 'hidden width ordinal',
1540                         'id' : 'hold_type',
1541                         'label' : document.getElementById('commonStrings').getString('staff.ahr_hold_type_label'),
1542                         'flex' : 0,
1543                         'primary' : false,
1544                         'hidden' : true,
1545                         'render' : function(my) { return my.ahr.hold_type(); }
1546                 },
1547         {
1548                         'persist' : 'hidden width ordinal',
1549                         'id' : 'frozen',
1550                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.active'),
1551                         'flex' : 0,
1552                         'primary' : false,
1553                         'hidden' : true,
1554                         'render' : function(my) {
1555                                 if (!get_bool( my.ahr.frozen() )) {
1556                                         return document.getElementById('circStrings').getString('staff.circ.utils.yes');
1557                                 } else {
1558                                         return document.getElementById('circStrings').getString('staff.circ.utils.no');
1559                                 }
1560                         }
1561         },
1562         {
1563                         'persist' : 'hidden width ordinal',
1564                         'id' : 'thaw_date',
1565                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.thaw_date'),
1566                         'flex' : 0,
1567                         'primary' : false,
1568                         'hidden' : true,
1569                         'render' : function(my) {
1570                                 if (my.ahr.thaw_date() == null) {
1571                                         return document.getElementById('circStrings').getString('staff.circ.utils.thaw_date.none');
1572                                 } else {
1573                                         return my.ahr.thaw_date().substr(0,10);
1574                                 }
1575                         }
1576         },
1577                 {
1578                         'persist' : 'hidden width ordinal',
1579                         'id' : 'pickup_lib',
1580                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.pickup_lib'),
1581                         'flex' : 1,
1582                         'primary' : false,
1583                         'hidden' : true,
1584                         'render' : function(my) {
1585                                 if (Number(my.ahr.pickup_lib())>=0) {
1586                                         return data.hash.aou[ my.ahr.pickup_lib() ].name();
1587                                 } else {
1588                                         return my.ahr.pickup_lib().name();
1589                                 }
1590                         }
1591                 },
1592                 {
1593                         'persist' : 'hidden width ordinal',
1594                         'id' : 'pickup_lib_shortname',
1595                         'label' : document.getElementById('commonStrings').getString('staff.ahr_pickup_lib_label'),
1596                         'flex' : 0,
1597                         'primary' : false,
1598                         'hidden' : true,
1599                         'render' : function(my) {
1600                                 if (Number(my.ahr.pickup_lib())>=0) {
1601                                         return data.hash.aou[ my.ahr.pickup_lib() ].shortname();
1602                                 } else {
1603                                         return my.ahr.pickup_lib().shortname();
1604                                 }
1605                         }
1606                 },
1607                 {
1608                         'persist' : 'hidden width ordinal',
1609                         'id' : 'current_copy',
1610                         'label' : document.getElementById('commonStrings').getString('staff.ahr_current_copy_label'),
1611                         'flex' : 1,
1612                         'primary' : false,
1613                         'hidden' : true,
1614                         'render' : function(my) {
1615                                 if (my.acp) {
1616                                         return my.acp.barcode();
1617                                 } else {
1618                                         return document.getElementById('circStrings').getString('staff.circ.utils.current_copy.none');
1619                                 }
1620                         }
1621                 },
1622                 {
1623                         'persist' : 'hidden width ordinal',
1624                         'id' : 'current_copy_location',
1625                         'label' : document.getElementById('commonStrings').getString('staff.ahr_current_copy_location_label'),
1626             'flex' : 1,
1627                         'primary' : false,
1628             'hidden' : true,
1629             'render' : function(my) {
1630                 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(); }
1631             }
1632                 },
1633                 {
1634                         'persist' : 'hidden width ordinal',
1635                         'id' : 'email_notify',
1636                         'label' : document.getElementById('commonStrings').getString('staff.ahr_email_notify_label'),
1637                         'flex' : 1,
1638                         'primary' : false,
1639                         'hidden' : true,
1640                         'render' : function(my) {
1641                                 if (get_bool(my.ahr.email_notify())) {
1642                                         return document.getElementById('circStrings').getString('staff.circ.utils.yes');
1643                                 } else {
1644                                         return document.getElementById('circStrings').getString('staff.circ.utils.no');
1645                                 }
1646                         }
1647                 },
1648                 {
1649                         'persist' : 'hidden width ordinal',
1650                         'id' : 'expire_time',
1651                         'label' : document.getElementById('commonStrings').getString('staff.ahr_expire_time_label'),
1652                         'flex' : 1,
1653                         'primary' : false,
1654                         'hidden' : true,
1655                         'render' : function(my) { return my.ahr.expire_time(); }
1656                 },
1657                 {
1658                         'persist' : 'hidden width ordinal',
1659                         'id' : 'expire_date',
1660                         'label' : document.getElementById('commonStrings').getString('staff.ahr_expire_date_label'),
1661                         'flex' : 1,
1662                         'primary' : false,
1663                         'hidden' : true,
1664                         'render' : function(my) { return my.ahr.expire_time() ? my.ahr.expire_time().toString().substr(0,10) : ''; }
1665                 },
1666                 {
1667                         'persist' : 'hidden width ordinal',
1668                         'id' : 'fulfillment_time',
1669                         'label' : document.getElementById('commonStrings').getString('staff.ahr_fulfillment_time_label'),
1670                         'flex' : 1,
1671                         'primary' : false,
1672                         'hidden' : true,
1673                         'render' : function(my) { return my.ahr.fulfillment_time(); }
1674                 },
1675                 {
1676                         'persist' : 'hidden width ordinal',
1677                         'id' : 'holdable_formats',
1678                         'label' : document.getElementById('commonStrings').getString('staff.ahr_holdable_formats_label'),
1679                         'flex' : 1,
1680                         'primary' : false,
1681                         'hidden' : true,
1682                         'render' : function(my) { return my.ahr.holdable_formats(); }
1683                 },
1684                 {
1685                         'persist' : 'hidden width ordinal',
1686                         'id' : 'id',
1687                         'label' : document.getElementById('commonStrings').getString('staff.ahr_id_label'),
1688                         'flex' : 1,
1689                         'primary' : false,
1690                         'hidden' : true,
1691                         'render' : function(my) { return my.ahr.id(); }
1692                 },
1693                 {
1694                         'persist' : 'hidden width ordinal',
1695                         'id' : 'phone_notify',
1696                         'label' : document.getElementById('commonStrings').getString('staff.ahr_phone_notify_label'),
1697                         'flex' : 1,
1698                         'primary' : false,
1699                         'hidden' : true,
1700                         'render' : function(my) { return my.ahr.phone_notify(); }
1701                 },
1702                 {
1703                         'persist' : 'hidden width ordinal',
1704                         'id' : 'prev_check_time',
1705                         'label' : document.getElementById('commonStrings').getString('staff.ahr_prev_check_time_label'),
1706                         'flex' : 1,
1707                         'primary' : false,
1708                         'hidden' : true,
1709                         'render' : function(my) { return my.ahr.prev_check_time(); }
1710                 },
1711                 {
1712                         'persist' : 'hidden width ordinal',
1713                         'id' : 'requestor',
1714                         'label' : document.getElementById('commonStrings').getString('staff.ahr_requestor_label'),
1715                         'flex' : 1,
1716                         'primary' : false,
1717                         'hidden' : true,
1718                         'render' : function(my) { return my.ahr.requestor(); }
1719                 },
1720                 {
1721                         'persist' : 'hidden width ordinal',
1722                         'id' : 'selection_depth',
1723                         'label' : document.getElementById('commonStrings').getString('staff.ahr_selection_depth_label'),
1724                         'flex' : 1,
1725                         'primary' : false,
1726                         'hidden' : true,
1727                         'render' : function(my) { return my.ahr.selection_depth(); }
1728                 },
1729                 {
1730                         'persist' : 'hidden width ordinal',
1731                         'id' : 'target',
1732                         'label' : document.getElementById('commonStrings').getString('staff.ahr_target_label'),
1733                         'flex' : 1,
1734                         'primary' : false,
1735                         'hidden' : true,
1736                         'render' : function(my) { return my.ahr.target(); }
1737                 },
1738                 {
1739                         'persist' : 'hidden width ordinal',
1740                         'id' : 'usr',
1741                         'label' : document.getElementById('commonStrings').getString('staff.ahr_usr_label'),
1742                         'flex' : 1,
1743                         'primary' : false,
1744                         'hidden' : true,
1745                         'render' : function(my) { return my.ahr.usr(); }
1746                 },
1747                 {
1748                         'persist' : 'hidden width ordinal',
1749                         'id' : 'title',
1750                         'label' : document.getElementById('commonStrings').getString('staff.mvr_label_title'),
1751                         'flex' : 1,
1752                         'sort_type' : 'title',
1753                         'primary' : false,
1754                         'hidden' : true,
1755                         'render' : function(my) {
1756                                 if (my.mvr) {
1757                                         return my.mvr.title();
1758                                 } else {
1759                                         return document.getElementById('circStrings').getString('staff.circ.utils.title.none');
1760                                 }
1761                         }
1762                 },
1763                 {
1764                         'persist' : 'hidden width ordinal',
1765                         'id' : 'author',
1766                         'label' : document.getElementById('commonStrings').getString('staff.mvr_label_author'),
1767                         'flex' : 1,
1768                         'primary' : false,
1769                         'hidden' : true,
1770                         'render' : function(my) {
1771                                 if (my.mvr) {
1772                                         return my.mvr.author();
1773                                 } else {
1774                                         return document.getElementById('circStrings').getString('staff.circ.utils.author.none');
1775                                 }
1776                         }
1777                 },
1778                 {
1779                         'persist' : 'hidden width ordinal',
1780                         'id' : 'edition',
1781                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.edition'),
1782                         'flex' : 1,
1783                         'primary' : false,
1784                         'hidden' : true,
1785                         'render' : function(my) { return my.mvr.edition(); }
1786                 },
1787                 {
1788                         'persist' : 'hidden width ordinal',
1789                         'id' : 'isbn',
1790                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.isbn'),
1791                         'flex' : 1,
1792                         'primary' : false,
1793                         'hidden' : true,
1794                         'render' : function(my) { return my.mvr.isbn(); }
1795                 },
1796                 {
1797                         'persist' : 'hidden width ordinal',
1798                         'id' : 'pubdate',
1799                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.pubdate'),
1800                         'flex' : 1,
1801                         'primary' : false,
1802                         'hidden' : true,
1803                         'render' : function(my) { return my.mvr.pubdate(); }
1804                 },
1805                 {
1806                         'persist' : 'hidden width ordinal',
1807                         'id' : 'publisher',
1808                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.publisher'),
1809                         'flex' : 1,
1810                         'primary' : false,
1811                         'hidden' : true,
1812                         'render' : function(my) { return my.mvr.publisher(); }
1813                 },
1814                 {
1815                         'persist' : 'hidden width ordinal',
1816                         'id' : 'tcn',
1817                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.tcn'),
1818                         'flex' : 1,
1819                         'primary' : false,
1820                         'hidden' : true,
1821                         'render' : function(my) { return my.mvr.tcn(); }
1822                 },
1823                 {
1824                         'persist' : 'hidden width ordinal',
1825                         'id' : 'notify_time',
1826                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.notify_time'),
1827                         'flex' : 1,
1828                         'primary' : false,
1829                         'hidden' : true,
1830                         'render' : function(my) { return my.ahr.notify_time(); }
1831                 },
1832                 {
1833                         'persist' : 'hidden width ordinal',
1834                         'id' : 'notify_count',
1835                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.notify_count'),
1836                         'flex' : 1,
1837                         'primary' : false,
1838                         'hidden' : true,
1839                         'render' : function(my) { return my.ahr.notify_count(); }
1840                 },
1841                 {
1842                         'persist' : 'hidden width ordinal',
1843                         'id' : 'transit_source',
1844                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_source'),
1845                         'flex' : 1,
1846                         'primary' : false,
1847                         'hidden' : true,
1848                         'render' : function(my) {
1849                                 if (my.ahr.transit()) {
1850                                         return data.hash.aou[ my.ahr.transit().source() ].shortname();
1851                                 } else {
1852                                         return "";
1853                                 }
1854                         }
1855                 },
1856                 {
1857                         'persist' : 'hidden width ordinal',
1858                         'id' : 'transit_source_send_time',
1859                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_source_send_time'),
1860                         'flex' : 1,
1861                         'primary' : false,
1862                         'hidden' : true,
1863                         'render' : function(my) { return my.ahr.transit() ?  my.ahr.transit().source_send_time() : ""; }
1864                 },
1865                 {
1866                         'persist' : 'hidden width ordinal',
1867                         'id' : 'transit_dest_lib',
1868                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_dest'),
1869                         'flex' : 1,
1870                         'primary' : false,
1871                         'hidden' : true,
1872                         'render' : function(my) { return my.ahr.transit() ?  data.hash.aou[ my.ahr.transit().dest() ].shortname() : ""; }
1873                 },
1874                 {
1875                         'persist' : 'hidden width ordinal',
1876                         'id' : 'transit_dest_recv_time',
1877                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_dest_recv_time'),
1878                         'flex' : 1,
1879                         'primary' : false,
1880                         'hidden' : true,
1881                         'render' : function(my) { return my.ahr.transit() ?  my.ahr.transit().dest_recv_time() : ""; }
1882                 },
1883                 {
1884                         'persist' : 'hidden width ordinal',
1885                         'id' : 'patron_barcode',
1886                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.patron_barcode'),
1887                         'flex' : 1,
1888                         'primary' : false,
1889                         'hidden' : true,
1890                         'render' : function(my) { return my.patron_barcode ? my.patron_barcode : ""; }
1891                 },
1892                 {
1893                         'persist' : 'hidden width ordinal',
1894                         'id' : 'patron_family_name',
1895                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.patron_family_name'),
1896                         'flex' : 1,
1897                         'primary' : false,
1898                         'hidden' : true,
1899                         'render' : function(my) { return my.patron_family_name ? my.patron_family_name : ""; }
1900                 },
1901                 {
1902                         'persist' : 'hidden width ordinal',
1903                         'id' : 'patron_first_given_name',
1904                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.patron_first_given_name'),
1905                         'flex' : 1,
1906                         'primary' : false,
1907                         'hidden' : true,
1908                         'render' : function(my) { return my.patron_first_given_name ? my.patron_first_given_name : ""; }
1909                 },
1910                 {
1911                         'persist' : 'hidden width ordinal',
1912                         'id' : 'callnumber',
1913                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.callnumber'),
1914                         'flex' : 1,
1915                         'primary' : false,
1916                         'hidden' : true,
1917                         'render' : function(my) { return my.acn.label(); }
1918                 },
1919                 {
1920                         'persist' : 'hidden width ordinal',
1921                         'id' : 'total_holds',
1922                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.total_holds'),
1923                         'flex' : 1,
1924                         'primary' : false,
1925                         'hidden' : true,
1926                         'render' : function(my) { return my.total_holds; }
1927                 },
1928                 {
1929                         'persist' : 'hidden width ordinal',
1930                         'id' : 'queue_position',
1931                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.queue_position'),
1932                         'flex' : 1,
1933                         'primary' : false,
1934                         'hidden' : true,
1935                         'render' : function(my) { return my.queue_position; }
1936                 },
1937                 {
1938                         'persist' : 'hidden width ordinal',
1939                         'id' : 'potential_copies',
1940                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.potential_copies'),
1941                         'flex' : 1,
1942                         'primary' : false,
1943                         'hidden' : true,
1944                         'render' : function(my) { return my.potential_copies; }
1945                 },
1946                 {
1947                         'persist' : 'hidden width ordinal',
1948                         'id' : 'estimated_wait',
1949                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.estimated_wait'),
1950                         'flex' : 1,
1951                         'primary' : false,
1952                         'hidden' : true,
1953                         'render' : function(my) { return my.estimated_wait; }
1954                 },
1955 {
1956                         'persist' : 'hidden width ordinal',
1957                         'id' : 'hold_note',
1958                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.hold_note'),
1959                         'flex' : 1,
1960                         'primary' : false,
1961                         'hidden' : true,
1962                         'render' : function(my) { return my.ahrn_count; }
1963               },
1964               {
1965                         'persist' : 'hidden width ordinal',
1966                         'id' : 'staff_hold',
1967                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.staff_hold'),
1968                         'flex' : 1,
1969                         'primary' : false,
1970                         'hidden' : true,
1971                         'render' : function(my) {
1972
1973                         if (my.ahr.usr() != my.ahr.requestor()){
1974                             return document.getElementById('circStrings').getString('staff.circ.utils.yes');
1975                         }else {
1976                             return document.getElementById('circStrings').getString('staff.circ.utils.no');
1977                             }
1978                         }
1979                   }
1980               ];
1981         for (var i = 0; i < c.length; i++) {
1982                 if (modify[ c[i].id ]) {
1983                         for (var j in modify[ c[i].id ]) {
1984                                 c[i][j] = modify[ c[i].id ][j];
1985                         }
1986                 }
1987         }
1988         if (params) {
1989                 if (params.just_these) {
1990                         JSAN.use('util.functional');
1991                         var new_c = [];
1992                         for (var i = 0; i < params.just_these.length; i++) {
1993                                 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
1994                                 new_c.push( function(y){ return y; }( x ) );
1995                         }
1996                         c = new_c;
1997                 }
1998                 if (params.except_these) {
1999                         JSAN.use('util.functional');
2000                         var new_c = [];
2001                         for (var i = 0; i < c.length; i++) {
2002                                 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
2003                                 if (!x) new_c.push(c[i]);
2004                         }
2005                         c = new_c;
2006                 }
2007
2008         }
2009         return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
2010 };
2011 /*
2012 circ.util.std_map_row_to_column = function(error_value) {
2013         return function(row,col) {
2014                 // row contains { 'my' : { 'acp' : {}, 'circ' : {}, 'mvr' : {} } }
2015                 // col contains one of the objects listed above in columns
2016
2017                 // mimicking some of the obj in circ.checkin and circ.checkout where map_row_to_column is usually defined
2018                 var obj = {};
2019                 JSAN.use('util.error'); obj.error = new util.error();
2020                 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
2021                 JSAN.use('util.network'); obj.network = new util.network();
2022                 JSAN.use('util.money');
2023
2024                 var my = row.my;
2025                 var value;
2026                 try {
2027                         value = eval( col.render );
2028                 } catch(E) {
2029                         obj.error.sdump('D_WARN','map_row_to_column: ' + E);
2030                         if (error_value) value = error_value; else value = '   ';
2031                 }
2032                 return value;
2033         }
2034 };
2035 */
2036 circ.util.std_map_row_to_columns = function(error_value) {
2037         return function(row,cols) {
2038                 // row contains { 'my' : { 'acp' : {}, 'circ' : {}, 'mvr' : {} } }
2039                 // cols contains all of the objects listed above in columns
2040
2041                 var obj = {};
2042                 JSAN.use('util.error'); obj.error = new util.error();
2043                 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
2044                 JSAN.use('util.network'); obj.network = new util.network();
2045                 JSAN.use('util.money');
2046
2047                 var my = row.my;
2048                 var values = [];
2049                 var cmd = '';
2050                 try {
2051                         for (var i = 0; i < cols.length; i++) {
2052                                 switch (typeof cols[i].render) {
2053                                         case 'function': try { values[i] = cols[i].render(my); } catch(E) { values[i] = error_value; obj.error.sdump('D_COLUMN_RENDER_ERROR',E); } break;
2054                                         case 'string' : cmd += 'try { ' + cols[i].render + '; values['+i+'] = v; } catch(E) { values['+i+'] = error_value; }'; break;
2055                                         default: cmd += 'values['+i+'] = "??? '+(typeof cols[i].render)+'"; ';
2056                                 }
2057                         }
2058                         if (cmd) eval( cmd );
2059                 } catch(E) {
2060                         obj.error.sdump('D_WARN','map_row_to_column: ' + E);
2061                         if (error_value) { value = error_value; } else { value = '   ' };
2062                 }
2063                 return values;
2064         }
2065 };
2066
2067 circ.util.checkin_via_barcode = function(session,params,backdate,auto_print,async) {
2068         try {
2069                 JSAN.use('util.error'); var error = new util.error();
2070                 JSAN.use('util.network'); var network = new util.network();
2071                 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
2072                 JSAN.use('util.date'); JSAN.use('util.functional');
2073
2074                 if (backdate && (backdate == util.date.formatted_date(new Date(),'%Y-%m-%d')) ) backdate = null;
2075
2076                 //var params = { 'barcode' : barcode };
2077                 if (backdate) params.backdate = util.date.formatted_date(backdate + ' 00:00:00','%{iso8601}');
2078
2079                 if (typeof params.disable_textbox == 'function') {
2080                         try { params.disable_textbox(); }
2081                         catch(E) { error.sdump('D_ERROR','params.disable_textbox() = ' + E); };
2082                 }
2083
2084         function checkin_callback(req) {
2085             try {
2086                 var check = req.getResultObject();
2087                 var r = circ.util.checkin_via_barcode2(session,params,backdate,auto_print,check);
2088                 if (typeof params.checkin_result == 'function') {
2089                     try { params.checkin_result(r); }
2090                     catch(E) { error.sdump('D_ERROR','params.checkin_result() = ' + E); };
2091                 }
2092                                 if (typeof async == 'function') async(check);
2093                                 return check;
2094             } catch(E) {
2095                 JSAN.use('util.error'); var error = new util.error();
2096                 error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.error', ['1']), E);
2097                 if (typeof params.enable_textbox == 'function') {
2098                     try { params.enable_textbox(); }
2099                     catch(E) { error.sdump('D_ERROR','params.disable_textbox() = ' + E); };
2100                 }
2101                 return null;
2102             }
2103         }
2104
2105                 var check = network.request(
2106                         api.CHECKIN_VIA_BARCODE.app,
2107                         api.CHECKIN_VIA_BARCODE.method,
2108                         [ session, util.functional.filter_object( params, function(i,o) { return typeof o != 'function'; } ) ],
2109                         async ? checkin_callback : null,
2110                         {
2111                                 'title' : document.getElementById('circStrings').getString('staff.circ.utils.checkin.override'),
2112                                 'overridable_events' : [
2113                     null /* custom event */,
2114                                         1203 /* COPY_BAD_STATUS */,
2115                                         1213 /* PATRON_BARRED */,
2116                                         1217 /* PATRON_INACTIVE */,
2117                                         1224 /* PATRON_ACCOUNT_EXPIRED */,
2118                                         1234 /* ITEM_DEPOSIT_PAID */,
2119                                         7009 /* CIRC_CLAIMS_RETURNED */,
2120                                         7010 /* COPY_ALERT_MESSAGE */,
2121                                         7011 /* COPY_STATUS_LOST */,
2122                                         7012 /* COPY_STATUS_MISSING */,
2123                                         7013 /* PATRON_EXCEEDS_FINES */,
2124                                 ],
2125                                 'text' : {
2126                                         '1203' : function(r) {
2127                                                 return typeof r.payload.status() == 'object' ? r.payload.status().name() : data.hash.ccs[ r.payload.status() ].name();
2128                                         },
2129                                         '1234' : function(r) {
2130                                                 return document.getElementById('circStrings').getString('staff.circ.utils.checkin.override.item_deposit_paid.warning');
2131                                         },
2132                                         '7010' : function(r) {
2133                                                 return r.payload;
2134                                         }
2135                                 }
2136                         }
2137                 );
2138                 if (! async ) {
2139                         return checkin_callback( { 'getResultObject' : function() { return check; } } );
2140                 }
2141
2142
2143         } catch(E) {
2144                 JSAN.use('util.error'); var error = new util.error();
2145                 error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.error', ['2']), E);
2146                 if (typeof params.enable_textbox == 'function') {
2147                         try { params.enable_textbox(); } catch(E) { error.sdump('D_ERROR','params.disable_textbox() = ' + E); };
2148                 }
2149                 return null;
2150         }
2151 };
2152
2153 circ.util.checkin_via_barcode2 = function(session,params,backdate,auto_print,check) {
2154         try {
2155                 JSAN.use('util.error'); var error = new util.error();
2156                 JSAN.use('util.network'); var network = new util.network();
2157                 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
2158                 JSAN.use('util.date');
2159
2160                 error.sdump('D_DEBUG','check = ' + error.pretty_print( js2JSON( check ) ) );
2161
2162                 check.message = check.textcode;
2163
2164                 if (check.payload && check.payload.copy) { check.copy = check.payload.copy; }
2165                 if (check.payload && check.payload.record) { check.record = check.payload.record; }
2166                 if (check.payload && check.payload.circ) { check.circ = check.payload.circ; }
2167
2168                 if (!check.route_to) { check.route_to = '   '; }
2169
2170                 if (document.getElementById('no_change_label')) {
2171                         document.getElementById('no_change_label').setAttribute('value','');
2172                         document.getElementById('no_change_label').setAttribute('hidden','true');
2173                 }
2174
2175                 if (check.circ) {
2176                         network.simple_request('FM_MBTS_RETRIEVE.authoritative',[ses(),check.circ.id()], function(req) {
2177                                 JSAN.use('util.money');
2178                                 var bill = req.getResultObject();
2179                                 if (Number(bill.balance_owed()) == 0) { return; }
2180                                 if (document.getElementById('no_change_label')) {
2181                                         var m = document.getElementById('no_change_label').getAttribute('value');
2182                                         document.getElementById('no_change_label').setAttribute(
2183                         'value', 
2184                         m + document.getElementById('circStrings').getFormattedString('staff.circ.utils.billable.amount', [params.barcode, util.money.sanitize(bill.balance_owed())]) + '  '
2185                     );
2186                                         document.getElementById('no_change_label').setAttribute('hidden','false');
2187                                 }
2188                                 if (document.getElementById('fine_tally')) {
2189                                         var amount = Number( document.getElementById('fine_tally').getAttribute('amount') ) + Number( bill.balance_owed() );
2190                     document.getElementById('fine_tally').setAttribute('amount',amount);
2191                     document.getElementById('fine_tally').setAttribute(
2192                         'value',
2193                         document.getElementById('circStrings').getFormattedString('staff.circ.utils.fine_tally_text', [ util.money.sanitize( amount ) ])
2194                     );
2195                                         document.getElementById('fine_tally').setAttribute('hidden','false');
2196                 }
2197                         });
2198                 }
2199
2200                 var msg = '';
2201         var print_list = [];
2202         var print_data = { 
2203             'error' : '',
2204             'error_msg' : '',
2205             'cancelled' : '',
2206             'route_to' : '',
2207             'route_to_msg' : '',
2208             'route_to_org_fullname' : '',
2209             'street1' : '',
2210             'street2' : '',
2211             'city_state_zip' : '',
2212             'city' : '',
2213             'state' : '',
2214             'county' : '',
2215             'country' : '',
2216             'post_code' : '',
2217             'item_barcode' : '',
2218             'item_barcode_msg' : '',
2219             'item_title' : '',
2220             'item_title_msg' : '',
2221             'item_author' : '',
2222             'item_author_msg' : '',
2223             'hold_for_msg' : '',
2224             'hold_for_alias' : '',
2225             'hold_for_family_name' : '',
2226             'hold_for_first_given_name' : '',
2227             'hold_for_second_given_name' : '',
2228             'user_barcode' : '',
2229             'user_barcode_msg' : '',
2230             'notify_by_phone' : '',
2231             'notify_by_phone_msg' : '',
2232             'notify_by_email' : '',
2233             'notify_by_email_msg' : '',
2234             'request_date' : '',
2235             'request_date_msg' : '',
2236             'slip_date' : '',
2237             'slip_date_msg' : ''
2238         };
2239
2240                 if (check.payload && check.payload.cancelled_hold_transit) {
2241                         print_data.cancelled = document.getElementById('circStrings').getString('staff.circ.utils.transit_hold_cancelled');
2242             msg += print_data.cancelled;
2243                         msg += '\n\n';
2244                 }
2245
2246                 /* SUCCESS  /  NO_CHANGE  /  ITEM_NOT_CATALOGED */
2247                 if (check.ilsevent == 0 || check.ilsevent == 3 || check.ilsevent == 1202) {
2248                         try { check.route_to = data.lookup('acpl', check.copy.location() ).name(); }
2249                         catch(E) {
2250                                 print_data.error_msg = document.getElementById('commonStrings').getString('common.error');
2251                                 print_data.error_msg += '\nFIXME: ' + E + '\n';
2252                 msg += print_data.error_msg;
2253                         }
2254                         if (check.ilsevent == 3 /* NO_CHANGE */) {
2255                                 //msg = 'This item is already checked in.\n';
2256                                 if (document.getElementById('no_change_label')) {
2257                                         var m = document.getElementById('no_change_label').getAttribute('value');
2258                                         document.getElementById('no_change_label').setAttribute('value', m + document.getElementById('circStrings').getFormattedString('staff.circ.utils.item_checked_in', [params.barcode]) + '  ');
2259                                         document.getElementById('no_change_label').setAttribute('hidden','false');
2260                                 }
2261                         }
2262                         if (check.ilsevent == 1202 /* ITEM_NOT_CATALOGED */ && check.copy.status() != 11) {
2263                                 var copy_status = (data.hash.ccs[ check.copy.status() ] ? data.hash.ccs[ check.copy.status() ].name() : check.copy.status().name() );
2264                                 var err_msg = document.getElementById('commonStrings').getString('common.error');
2265                                 err_msg += '\nFIXME --';
2266                                 err_msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.item_not_cataloged', [copy_status]);
2267                                 err_msg += '\n';
2268                 msg += err_msg;
2269                 print_data.error_msg += err_msg;
2270                         }
2271                         switch(Number(check.copy.status())) {
2272                                 case 0: /* AVAILABLE */
2273                                 case 7: /* RESHELVING */
2274                                         if (msg) {
2275                                                 print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2276                         print_data.route_to = check.route_to;
2277                         msg += print_data.route_to_msg;
2278                                                 msg += '\n';
2279                                         }
2280                                 break;
2281                                 case 8: /* ON HOLDS SHELF */
2282                     check.route_to = document.getElementById('circStrings').getString('staff.circ.route_to.hold_shelf');
2283                                         if (check.payload.hold) {
2284                                                 if (check.payload.hold.pickup_lib() != data.list.au[0].ws_ou()) {
2285                                                         var err_msg = document.getElementById('commonStrings').getString('common.error');
2286                                                         err_msg += '\nFIXME: ';
2287                                                         err_msg += document.getElementById('circStrings').getString('staff.circ.utils.route_item_error');
2288                                                         err_msg += '\n';
2289                             msg += err_msg;
2290                             print_data.error_msg += err_msg;
2291                                                 } else {
2292                                                         print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2293                             print_data.route_to = check.route_to;
2294                             var behind_the_desk_support = String( data.hash.aous['circ.holds.behind_desk_pickup_supported'] ) == 'true';
2295                             if (behind_the_desk_support) {
2296                                var usr_settings = network.simple_request('FM_AUS_RETRIEVE',[ses(),check.payload.hold.usr()]); 
2297                                 if (typeof usr_settings['circ.holds_behind_desk'] != 'undefined') {
2298                                     print_data.prefer_behind_holds_desk = true;
2299                                     check.route_to = document.getElementById('circStrings').getString('staff.circ.route_to.private_hold_shelf');
2300                                     print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2301                                     print_data.route_to = check.route_to;
2302                                 } else {
2303                                     check.route_to = document.getElementById('circStrings').getString('staff.circ.route_to.public_hold_shelf');
2304                                     print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2305                                     print_data.route_to = check.route_to;
2306                                 }
2307                             }
2308                             msg += print_data.route_to_msg;
2309                                                         msg += '\n';
2310                                                 }
2311                                         } else {
2312                                                 var err_msg = document.getElementById('commonStrings').getString('common.error');
2313                                                 err_msg += '\nFIXME: ';
2314                                                 err_msg += document.getElementById('circStrings').getString('staff.circ.utils.route_item_status_error');
2315                                                 err_msg += '\n';
2316                         msg += err_msg;
2317                         print_data.error_msg += err_msg;
2318                                         }
2319                                         JSAN.use('util.date');
2320                                         if (check.payload.hold) {
2321                                                 JSAN.use('patron.util');
2322                                                 msg += '\n';
2323                                                 print_data.item_barcode_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [check.payload.copy.barcode()]);
2324                         print_data.item_barcode = check.payload.copy.barcode();
2325                         msg += print_data.item_barcode_msg;
2326                                                 msg += '\n';
2327                                                 var payload_title  = (check.payload.record ? check.payload.record.title() : check.payload.copy.dummy_title() );
2328                                                 print_data.item_title_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.title', [payload_title]);
2329                         print_data.item_title = payload_title;
2330                         msg += print_data.item_title_msg;
2331                                                 msg += '\n';
2332                                                 var au_obj = patron.util.retrieve_fleshed_au_via_id( session, check.payload.hold.usr() );
2333                         print_data.user = au_obj;
2334                                                 msg += '\n';
2335                         if (au_obj.alias()) {
2336                                                 print_data.hold_for_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.patron_alias',  [au_obj.alias()]);
2337                             print_data.hold_for_alias = au_obj.alias();
2338                             msg += print_data.hold_for_msg;
2339                         } else {
2340                                                 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() : '']);
2341                             msg += print_data.hold_for_msg;
2342                             print_data.hold_for_family_name = au_obj.family_name() ? au_obj.family_name() : '';
2343                             print_data.hold_for_first_given_name = au_obj.first_given_name() ? au_obj.first_given_name() : '';
2344                             print_data.hold_for_second_given_name = au_obj.second_given_name() ? au_obj.second_given_name() : '';
2345                         }
2346                                                 msg += '\n';
2347                                                 print_data.user_barcode_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [au_obj.card().barcode()]);
2348                         print_data.user_barcode = au_obj.card().barcode();
2349                         msg += print_data.user_barcode_msg;
2350                                                 msg += '\n';
2351                                                 if (check.payload.hold.phone_notify()) {
2352                                                         print_data.notify_by_phone_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.phone_notify', [check.payload.hold.phone_notify()]);
2353                             print_data.notify_by_phone = check.payload.hold.phone_notify();
2354                             msg += print_data.notify_by_phone_msg;
2355                                                         msg += '\n';
2356                                                 }
2357                                                 if (get_bool(check.payload.hold.email_notify())) {
2358                                                         var payload_email = au_obj.email() ? au_obj.email() : '';
2359                                                         print_data.notify_by_email_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.email_notify', [payload_email]);
2360                             print_data.notify_by_email = payload_email;
2361                             msg += print_data.notify_by_email_msg;
2362                                                         msg += '\n';
2363                                                 }
2364                                                 msg += '\n';
2365                         var notes = check.payload.hold.notes();
2366                         print_data.notes_raw = notes;
2367                         for (var i = 0; i < notes.length; i++) {
2368                             if ( get_bool( notes[i].slip() ) ) {
2369                                 var temp_msg;
2370                                 if ( get_bool( notes[i].staff() ) ) {
2371                                     temp_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.notes.staff_note', [ notes[i].title(), notes[i].body() ]);
2372                                 } else {
2373                                     temp_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.notes.patron_note', [ notes[i].title(), notes[i].body() ]);
2374                                 }
2375                                 msg += temp_msg + '\n';
2376                                 print_list.push(
2377                                     {
2378                                         'formatted_note' : temp_msg,
2379                                         'note_title' : notes[i].title(),
2380                                         'note_body' : notes[i].body(),
2381                                         'note_public' : notes[i].pub(),
2382                                         'note_by_staff' : notes[i].staff()
2383                                     }
2384                                 );
2385                             }
2386                         }
2387                                                 msg += '\n';
2388                                                 msg += '\n';
2389                         print_data.request_date = util.date.formatted_date(check.payload.hold.request_time(),'%F');
2390                                                 print_data.request_date_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.request_date', [print_data.request_date]);
2391                         msg += print_data.request_date_msg;
2392                                                 msg += '\n';
2393                                         }
2394                                         var rv = 0;
2395                     var no_print_prompting = data.hash.aous['circ.staff_client.do_not_auto_attempt_print'];
2396                     if (no_print_prompting) {
2397                         if (no_print_prompting.indexOf( "Hold Slip" ) > -1) {
2398                             rv = -1; auto_print = true; // DO NOT PRINT and skip dialog
2399                         }
2400                     }
2401                     print_data.slip_date = util.date.formatted_date(new Date(),'%F');
2402                                         print_data.slip_date_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.slip_date', [print_data.slip_date]);
2403                     msg += print_data.slip_date_msg;
2404                                         msg += '\n';
2405                     print_data.payload = check.payload;
2406
2407                                         if (!auto_print) {
2408                                                 rv = error.yns_alert_formatted(
2409                                                         msg,
2410                                                         document.getElementById('circStrings').getString('staff.circ.utils.hold_slip'),
2411                                                         document.getElementById('circStrings').getString('staff.circ.utils.hold_slip.print.yes'),
2412                                                         document.getElementById('circStrings').getString('staff.circ.utils.hold_slip.print.no'),
2413                                                         null,
2414                                                         document.getElementById('circStrings').getString('staff.circ.confirm.msg'),
2415                                                         '/xul/server/skin/media/images/turtle.gif'
2416                                                 );
2417                                         }
2418                                         if (rv == 0) {
2419                                                 try {
2420                                                         JSAN.use('util.print'); var print = new util.print();
2421                             var old_template = String( data.hash.aous['ui.circ.old_harcoded_slip_template'] ) == 'true';
2422                             if (old_template) {
2423                                 msg = msg.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\n/g,'<br/>');
2424                                 print.simple( msg , { 'no_prompt' : true, 'content_type' : 'text/html' } );
2425                             } else {
2426                                 var template = 'hold_slip';
2427                                 var params = {
2428                                     'patron' : print_data.user,
2429                                     'lib' : data.hash.aou[ check.payload.hold.pickup_lib() ],
2430                                     'staff' : data.list.au[0],
2431                                     'header' : data.print_list_templates[ template ].header,
2432                                     'line_item' : data.print_list_templates[ template ].line_item,
2433                                     'footer' : data.print_list_templates[ template ].footer,
2434                                     'type' : data.print_list_templates[ template ].type,
2435                                     'list' : print_list,
2436                                     'data' : print_data
2437                                 };
2438                                 print.tree_list( params );
2439                             }
2440                                                 } catch(E) {
2441                                                         var err_msg = document.getElementById('commonStrings').getString('common.error');
2442                                                         err_msg += '\nFIXME: ' + E + '\n';
2443                                                         dump(err_msg);
2444                                                         alert(err_msg);
2445                                                 }
2446                                         }
2447                                         msg = '';
2448                                         if (document.getElementById('no_change_label')) {
2449                                                 var m = document.getElementById('no_change_label').getAttribute('value');
2450                                                 m += document.getElementById('circStrings').getFormattedString('staff.circ.utils.capture', [params.barcode]);
2451                                                 document.getElementById('no_change_label').setAttribute('value', m);
2452                                                 document.getElementById('no_change_label').setAttribute('hidden','false');
2453                                         }
2454                                 break;
2455                                 case 6: /* IN TRANSIT */
2456                                         check.route_to = 'TRANSIT SHELF??';
2457                     print_data.route_to;
2458                                         var err_msg = document.getElementById('commonStrings').getString('common.error');
2459                                         err_msg += "\nFIXME -- I didn't think we could get here.\n";
2460                     print_data.error_msg += err_msg;
2461                     msg += err_msg;
2462                                 break;
2463                                 case 11: /* CATALOGING */
2464                                         check.route_to = 'CATALOGING';
2465                     print_data.route_to;
2466                                         if (document.getElementById('do_not_alert_on_precat')) {
2467                                                 var x = document.getElementById('do_not_alert_on_precat');
2468                                                 if (! x.checked) {
2469                                                         print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2470                             msg += print_data.route_to_msg;
2471                                                 }
2472                                         } else {
2473                                                 print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2474                         msg += print_data.route_to_msg;
2475                                         }
2476                                         if (document.getElementById('no_change_label')) {
2477                                                 var m = document.getElementById('no_change_label').getAttribute('value');
2478                                                 var needs_cat = document.getElementById('circStrings').getFormattedString('staff.circ.utils.needs_cataloging', [params.barcode]);
2479                                                 document.getElementById('no_change_label').setAttribute('value', m + needs_cat + '  ');
2480                                                 document.getElementById('no_change_label').setAttribute('hidden','false');
2481                                         }
2482                                 break;
2483                                 default:
2484                                         msg += document.getElementById('commonStrings').getString('common.error');
2485                                         var copy_status = data.hash.ccs[check.copy.status()] ? data.hash.ccs[check.copy.status()].name() : check.copy.status().name();
2486                                         msg += '\n';
2487                                         var error_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.copy_status.error', [copy_status]);
2488                     print_data.error_msg += error_msg;
2489                     msg += error_msg;
2490                                         msg += '\n';
2491                                         print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2492                     msg += print_data.route_to_msg;
2493                                 break;
2494                         }
2495                         if (msg) {
2496                                 error.yns_alert(
2497                                         msg,
2498                                         document.getElementById('circStrings').getString('staff.circ.alert'),
2499                                         null,
2500                                         document.getElementById('circStrings').getString('staff.circ.utils.msg.ok'),
2501                                         null,
2502                                         document.getElementById('circStrings').getString('staff.circ.confirm.msg')
2503                                 );
2504                         }
2505                 } else /* ROUTE_ITEM */ if (check.ilsevent == 7000) {
2506
2507                         var lib = data.hash.aou[ check.org ];
2508                         check.route_to = lib.shortname();
2509             print_data.route_to = check.route_to;
2510             print_data.route_to_org = lib;
2511                         print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.destination', [check.route_to]);
2512             print_data.route_to_org_fullname = lib.name();
2513             msg += print_data.route_to_msg;
2514                         msg += '\n\n';
2515                         msg += lib.name();
2516                         msg += '\n';
2517                         try {
2518                                 if (lib.holds_address() ) {
2519                                         var a = network.simple_request('FM_AOA_RETRIEVE',[ lib.holds_address() ]);
2520                                         if (typeof a.ilsevent != 'undefined') throw(a);
2521                                         if (a.street1()) { msg += a.street1() + '\n'; print_data.street1 = a.street1(); }
2522                                         if (a.street2()) { msg += a.street2() + '\n'; print_data.street2 = a.street2(); }
2523                                         print_data.city_state_zip = (a.city() ? a.city() + ', ' : '') + (a.state() ? a.state() + ' ' : '') + (a.post_code() ? a.post_code() : '');
2524                     print_data.city = a.city();
2525                     print_data.state = a.state();
2526                     print_data.county = a.county();
2527                     print_data.country = a.country();
2528                     print_data.post_code = a.post_code();
2529                     msg += print_data.city_state_zip + '\n';
2530                                 } else {
2531                                         print_data.street1 = document.getElementById('circStrings').getString('staff.circ.utils.route_to.no_address');
2532                     print_data.no_address = true;
2533                     msg += print_data.street1;
2534                                         msg += '\n';
2535                                 }
2536                         } catch(E) {
2537                                 var err_msg = document.getElementById('circStrings').getString('staff.circ.utils.route_to.no_address.error');
2538                 print_data.error_msg += err_msg + '\n';
2539                                 msg += err_msg + '\n';
2540                                 error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.utils.route_to.no_address.error'), E);
2541                         }
2542                         msg += '\n';
2543                         print_data.item_barcode_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [check.payload.copy.barcode()]);
2544             print_data.item_barcode = check.payload.copy.barcode();
2545             msg += print_data.item_barcode_msg;
2546                         msg += '\n';
2547                         var payload_title  = (check.payload.record ? check.payload.record.title() : check.payload.copy.dummy_title() );
2548                         print_data.item_title_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.title', [payload_title]);
2549             print_data.item_title = payload_title;
2550             msg += print_data.item_title_msg;
2551                         msg += '\n';
2552                         var payload_author = (check.payload.record ? check.payload.record.author() :check.payload.copy.dummy_author());
2553                         print_data.item_author_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.author', [payload_author]);
2554             print_data.item_author = payload_author;
2555             msg += print_data.item_author_msg;
2556                         msg += '\n';
2557                         JSAN.use('util.date');
2558                         if (check.payload.hold) {
2559                                 JSAN.use('patron.util');
2560                                 var au_obj = patron.util.retrieve_fleshed_au_via_id( session, check.payload.hold.usr() );
2561                 print_data.user = au_obj;
2562                                 msg += '\n';
2563                 if (au_obj.alias()) {
2564                     print_data.hold_for_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.patron_alias',  [au_obj.alias()]);
2565                     print_data.hold_for_alias = au_obj.alias();
2566                     msg += print_data.hold_for_msg;
2567                 } else {
2568                     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() : '']);
2569                     msg += print_data.hold_for_msg;
2570                     print_data.hold_for_family_name = au_obj.family_name() ? au_obj.family_name() : '';
2571                     print_data.hold_for_first_given_name = au_obj.first_given_name() ? au_obj.first_given_name() : '';
2572                     print_data.hold_for_second_given_name = au_obj.second_given_name() ? au_obj.second_given_name() : '';
2573                 }
2574                                 msg += '\n';
2575                 print_data.user_barcode_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [au_obj.card().barcode()]);
2576                 print_data.user_barcode = au_obj.card().barcode();
2577                 msg += print_data.user_barcode_msg;
2578                                 msg += '\n';
2579                                 if (check.payload.hold.phone_notify()) {
2580                     print_data.notify_by_phone_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.phone_notify', [check.payload.hold.phone_notify()]);
2581                     print_data.notify_by_phone = check.payload.hold.phone_notify();
2582                     msg += print_data.notify_by_phone_msg;
2583                                         msg += '\n';
2584                                 }
2585                                 if (get_bool(check.payload.hold.email_notify())) {
2586                                         var payload_email = au_obj.email() ? au_obj.email() : '';
2587                     print_data.notify_by_email_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.email_notify', [payload_email]);
2588                     print_data.notify_by_email = payload_email;
2589                     msg += print_data.notify_by_email_msg;
2590                                         msg += '\n';
2591                                 }
2592                                 msg += '\n';
2593                 var notes = check.payload.hold.notes();
2594                 print_data.notes_raw = notes;
2595                 for (var i = 0; i < notes.length; i++) {
2596                     if ( get_bool( notes[i].slip() ) ) {
2597                         var temp_msg;
2598                         if ( get_bool( notes[i].staff() ) ) {
2599                             temp_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.notes.staff_note', [ notes[i].title(), notes[i].body() ]);
2600                         } else {
2601                             temp_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.notes.patron_note', [ notes[i].title(), notes[i].body() ]);
2602                         }
2603                         msg += temp_msg + '\n';
2604                         print_list.push(
2605                             {
2606                                 'formatted_note' : temp_msg,
2607                                 'note_title' : notes[i].title(),
2608                                 'note_body' : notes[i].body(),
2609                                 'note_public' : notes[i].pub(),
2610                                 'note_by_staff' : notes[i].staff()
2611                             }
2612                         );
2613                     }
2614                 }
2615                 msg += '\n';
2616                 msg += '\n';
2617                 print_data.request_date = util.date.formatted_date(check.payload.hold.request_time(),'%F');
2618                 print_data.request_date_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.request_date', [print_data.request_date]);
2619                 msg += print_data.request_date_msg;
2620                                 msg += '\n';
2621                         }
2622                         var rv = 0;
2623             var no_print_prompting = data.hash.aous['circ.staff_client.do_not_auto_attempt_print'];
2624             if (no_print_prompting) {
2625                 if (no_print_prompting.indexOf( check.payload.hold ? "Hold/Transit Slip" : "Transit Slip" ) > -1) {
2626                     rv = -1; auto_print = true; // DO NOT PRINT and skip dialog
2627                 }
2628             }
2629             print_data.slip_date = util.date.formatted_date(new Date(),'%F');
2630             print_data.slip_date_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.slip_date', [print_data.slip_date]);
2631             msg += print_data.slip_date_msg;
2632             print_data.payload = check.payload;
2633
2634                         if (!auto_print) {
2635                                 rv = error.yns_alert_formatted(
2636                                         msg,
2637                                         document.getElementById('circStrings').getString('staff.circ.utils.transit_slip'),
2638                                         document.getElementById('circStrings').getString('staff.circ.utils.transit_slip.print.yes'),
2639                                         document.getElementById('circStrings').getString('staff.circ.utils.transit_slip.print.no'),
2640                                         null,
2641                                         document.getElementById('circStrings').getString('staff.circ.confirm.msg'),
2642                                         '/xul/server/skin/media/images/turtle.gif'
2643                                 );
2644                         }
2645                         if (rv == 0) {
2646                                 try {
2647                                         JSAN.use('util.print'); var print = new util.print();
2648                     var old_template = String( data.hash.aous['ui.circ.old_harcoded_slip_template'] ) == 'true';
2649                     if (old_template) {
2650                         msg = msg.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\n/g,'<br/>');
2651                         print.simple( msg , { 'no_prompt' : true, 'content_type' : 'text/html' } );
2652                     } else {
2653                         var template = check.payload.hold ? 'hold_transit_slip' : 'transit_slip';
2654                         var params = {
2655                             'patron' : print_data.user,
2656                             'lib' : data.hash.aou[ check.payload.hold ? check.payload.hold.pickup_lib() : check.payload.transit.source() ],
2657                             'staff' : data.list.au[0],
2658                             'header' : data.print_list_templates[ template ].header,
2659                             'line_item' : data.print_list_templates[ template ].line_item,
2660                             'footer' : data.print_list_templates[ template ].footer,
2661                             'type' : data.print_list_templates[ template ].type,
2662                             'list' : print_list,
2663                             'data' : print_data 
2664                         };
2665                         print.tree_list( params );
2666                     }
2667                                 } catch(E) {
2668                                         var err_msg = document.getElementById('commonStrings').getString('common.error');
2669                                         err_msg += '\nFIXME: ' + E + '\n';
2670                                         dump(err_msg);
2671                                         alert(err_msg);
2672                                 }
2673                         }
2674                         if (document.getElementById('no_change_label')) {
2675                                 var m = document.getElementById('no_change_label').getAttribute('value');
2676                                 var trans_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.in_transit', [params.barcode]);
2677                                 document.getElementById('no_change_label').setAttribute('value', m + trans_msg + '  ');
2678                                 document.getElementById('no_change_label').setAttribute('hidden','false');
2679                         }
2680
2681                 } else /* ASSET_COPY_NOT_FOUND */ if (check.ilsevent == 1502) {
2682
2683                         check.route_to = 'CATALOGING';
2684                         var mis_scan_msg = document.getElementById('circStrings').getFormattedString('staff.circ.copy_status.status.copy_not_found', [params.barcode]);
2685                         error.yns_alert(
2686                                 mis_scan_msg,
2687                                 document.getElementById('circStrings').getString('staff.circ.alert'),
2688                                 null,
2689                                 document.getElementById('circStrings').getString('staff.circ.utils.msg.ok'),
2690                                 null,
2691                                 document.getElementById('circStrings').getString('staff.circ.confirm.msg')
2692                         );
2693                         if (document.getElementById('no_change_label')) {
2694                                 var m = document.getElementById('no_change_label').getAttribute('value');
2695                                 document.getElementById('no_change_label').setAttribute('value',m + mis_scan_msg + '  ');
2696                                 document.getElementById('no_change_label').setAttribute('hidden','false');
2697                         }
2698
2699                 } else /* HOLD_CAPTURE_DELAYED */ if (check.ilsevent == 7019) {
2700
2701                         var rv = 0;
2702                         msg += document.getElementById('circStrings').getString('staff.circ.utils.hold_capture_delayed.description');
2703                         rv = error.yns_alert_formatted(
2704                                 msg,
2705                                 document.getElementById('circStrings').getString('staff.circ.utils.hold_capture_delayed.titlebar'),
2706                                 document.getElementById('circStrings').getString('staff.circ.utils.hold_capture_delayed.prompt_for_nocapture'),
2707                                 document.getElementById('circStrings').getString('staff.circ.utils.hold_capture_delayed.prompt_for_capture'),
2708                                 null,
2709                                 document.getElementById('circStrings').getString('staff.circ.confirm.msg'),
2710                                 '/xul/server/skin/media/images/stop_sign.png'
2711                         );
2712                         params.capture = rv == 0 ? 'nocapture' : 'capture';
2713
2714                         return circ.util.checkin_via_barcode(session,params,backdate,auto_print,false);
2715
2716                 } else /* NETWORK TIMEOUT */ if (check.ilsevent == -1) {
2717                         error.standard_network_error_alert(document.getElementById('circStrings').getString('staff.circ.checkin.suggest_offline'));
2718                 } else {
2719
2720             if (check.ilsevent == null) { return null; /* handled */ }
2721                         switch (Number(check.ilsevent)) {
2722                                 case 1203 /* COPY_BAD_STATUS */ :
2723                                 case 1213 /* PATRON_BARRED */ :
2724                                 case 1217 /* PATRON_INACTIVE */ :
2725                                 case 1224 /* PATRON_ACCOUNT_EXPIRED */ :
2726                                 case 1234 /* ITEM_DEPOSIT_PAID */ :
2727                                 case 7009 /* CIRC_CLAIMS_RETURNED */ :
2728                                 case 7010 /* COPY_ALERT_MESSAGE */ :
2729                                 case 7011 /* COPY_STATUS_LOST */ :
2730                                 case 7012 /* COPY_STATUS_MISSING */ :
2731                                 case 7013 /* PATRON_EXCEEDS_FINES */ :
2732                                         return null; /* handled */
2733                                 break;
2734                         }
2735
2736                         throw(check);
2737
2738                 }
2739
2740                 return check;
2741         } catch(E) {
2742                 JSAN.use('util.error'); var error = new util.error();
2743                 error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.error', ['3']), E);
2744                 return null;
2745         }
2746 };
2747
2748 circ.util.renew_via_barcode = function ( barcode, patron_id, async ) {
2749         try {
2750                 var obj = {};
2751                 JSAN.use('util.network'); obj.network = new util.network();
2752                 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.stash_retrieve();
2753
2754                 var params = { barcode: barcode };
2755                 if (patron_id) params.patron = patron_id;
2756
2757                 function renew_callback(req) {
2758                         try {
2759                                 var renew = req.getResultObject();
2760                                 if (typeof renew.ilsevent != 'undefined') renew = [ renew ];
2761                                 for (var j = 0; j < renew.length; j++) {
2762                                         switch(renew[j].ilsevent == null ? null : Number(renew[j].ilsevent)) {
2763                                                 case 0 /* SUCCESS */ : break;
2764                                                 case null /* custom event */ : break;
2765                                                 case 5000 /* PERM_FAILURE */: break;
2766                                                 case 1212 /* PATRON_EXCEEDS_OVERDUE_COUNT */ : break;
2767                                                 case 1213 /* PATRON_BARRED */ : break;
2768                                                 case 1215 /* CIRC_EXCEEDS_COPY_RANGE */ : break;
2769                                                 case 1224 /* PATRON_ACCOUNT_EXPIRED */ : break;
2770                         case 1232 /* ITEM_DEPOSIT_REQUIRED */ : break;
2771                         case 1233 /* ITEM_RENTAL_FEE_REQUIRED */ : break;
2772                                             case 1234 /* ITEM_DEPOSIT_PAID */ : break;
2773                                                 case 1500 /* ACTION_CIRCULATION_NOT_FOUND */ : break;
2774                                                 case 7002 /* PATRON_EXCEEDS_CHECKOUT_COUNT */ : break;
2775                                                 case 7003 /* COPY_CIRC_NOT_ALLOWED */ : break;
2776                                                 case 7004 /* COPY_NOT_AVAILABLE */ : break;
2777                                                 case 7006 /* COPY_IS_REFERENCE */ : break;
2778                                                 case 7007 /* COPY_NEEDED_FOR_HOLD */ : break;
2779                                                 case 7008 /* MAX_RENEWALS_REACHED */ : break;
2780                                                 case 7009 /* CIRC_CLAIMS_RETURNED */ : break;
2781                                                 case 7010 /* COPY_ALERT_MESSAGE */ : break;
2782                                                 case 7013 /* PATRON_EXCEEDS_FINES */ : break;
2783                                                 default:
2784                                                         throw(renew);
2785                                                 break;
2786                                         }
2787                                 }
2788                                 if (typeof async == 'function') async(renew);
2789                                 return renew;
2790                         } catch(E) {
2791                                 JSAN.use('util.error'); var error = new util.error();
2792                                 error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.renew_failed.error', [barcode]), E);
2793                                 return null;
2794                         }
2795                 }
2796
2797                 var renew = obj.network.simple_request(
2798                         'CHECKOUT_RENEW',
2799                         [ ses(), params ],
2800                         async ? renew_callback : null,
2801                         {
2802                                 'title' : document.getElementById('circStrings').getString('staff.circ.checkin.renew_failed.override'),
2803                                 'overridable_events' : [
2804                     null /* custom event */,
2805                                         1212 /* PATRON_EXCEEDS_OVERDUE_COUNT */,
2806                                         1213 /* PATRON_BARRED */,
2807                                         1215 /* CIRC_EXCEEDS_COPY_RANGE */,
2808                     1232 /* ITEM_DEPOSIT_REQUIRED */,
2809                     1233 /* ITEM_RENTAL_FEE_REQUIRED */,
2810                                         1234 /* ITEM_DEPOSIT_PAID */,
2811                                         7002 /* PATRON_EXCEEDS_CHECKOUT_COUNT */,
2812                                         7003 /* COPY_CIRC_NOT_ALLOWED */,
2813                                         7004 /* COPY_NOT_AVAILABLE */,
2814                                         7006 /* COPY_IS_REFERENCE */,
2815                                         7007 /* COPY_NEEDED_FOR_HOLD */,
2816                                         7008 /* MAX_RENEWALS_REACHED */,
2817                                         7009 /* CIRC_CLAIMS_RETURNED */,
2818                                         7010 /* COPY_ALERT_MESSAGE */,
2819                                         7013 /* PATRON_EXCEEDS_FINES */,
2820                                 ],
2821                                 'text' : {
2822                                         '1212' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2823                                         '1213' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2824                                         '1215' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2825                     '1232' : function(r) {
2826                         return document.getElementById('circStrings').getFormattedString('staff.circ.renew.override.item_deposit_required.warning.barcode', [barcode]);
2827                     },
2828                     '1233' : function(r) {
2829                         return document.getElementById('circStrings').getFormattedString('staff.circ.renew.override.item_rental_fee_required.warning.barcode', [barcode]);
2830                     },
2831                                         '1234' : function(r) {
2832                                                 return document.getElementById('circStrings').getFormattedString('staff.circ.utils.checkin.override.item_deposit_paid.warning');
2833                                         },
2834                                         '7002' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2835                                         '7003' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2836                                         '7004' : function(r) {
2837                                                 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()]);
2838                                         },
2839                                         '7006' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2840                                         '7007' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2841                                         '7008' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2842                                         '7009' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2843                                         '7010' : function(r) {
2844                                                 return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode.msg', [barcode, r.payload]);
2845                                         },
2846                                         '7013' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); }
2847                                 }
2848                         }
2849                 );
2850                 if (! async ) {
2851                         return renew_callback( { 'getResultObject' : function() { return renew; } } );
2852                 }
2853
2854         } catch(E) {
2855                 JSAN.use('util.error'); var error = new util.error();
2856                 error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.renew_failed.error', [barcode]), E);
2857                 return null;
2858         }
2859 };
2860
2861 dump('exiting circ/util.js\n');