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