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