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