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