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