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