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