]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/xul/staff_client/server/circ/util.js
Added functionality to holds menus to include columns for Total Holds Available,...
[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', '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) { return my.mvr.isbn(); }
988                 },
989                 {
990                         'persist' : 'hidden width ordinal',
991                         'id' : 'pubdate',
992                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.pubdate'),
993                         'flex' : 1,
994                         'primary' : false,
995                         'hidden' : true,
996                         'render' : function(my) { return my.mvr.pubdate(); }
997                 },
998                 {
999                         'persist' : 'hidden width ordinal',
1000                         'id' : 'publisher',
1001                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.publisher'),
1002                         'flex' : 1,
1003                         'primary' : false,
1004                         'hidden' : true,
1005                         'render' : function(my) { return my.mvr.publisher(); }
1006                 },
1007                 {
1008                         'persist' : 'hidden width ordinal',
1009                         'id' : 'tcn',
1010                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.tcn'),
1011                         'flex' : 1,
1012                         'primary' : false,
1013                         'hidden' : true,
1014                         'render' : function(my) { return my.mvr.tcn(); }
1015                 },
1016                 {
1017                         'persist' : 'hidden width ordinal',
1018                         'id' : 'renewal_remaining',
1019                         'label' : document.getElementById('commonStrings').getString('staff.circ_label_renewal_remaining'),
1020                         'flex' : 0,
1021                         'primary' : false,
1022                         'hidden' : true,
1023                         'render' : function(my) {
1024                                 if (my.circ) {
1025                                         return my.circ.renewal_remaining();
1026                                 } else {
1027                                         if (my.acp.circulations()) {
1028                                                 return my.acp.circulations()[0].renewal_remaining();
1029                                         } else {
1030                                                 return "";
1031                                         }
1032                                 }
1033                         },
1034                         'sort_type' : 'number'
1035                 },
1036                 {
1037                         'persist' : 'hidden width ordinal',
1038                         'id' : 'stop_fines',
1039                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.stop_fines'),
1040                         'flex' : 0,
1041                         'primary' : false,
1042                         'hidden' : true,
1043                         'render' : function(my) {
1044                                 if (my.circ) {
1045                                         return my.circ.stop_fines();
1046                                 } else {
1047                                         if (my.acp.circulations()) {
1048                                                 return my.acp.circulations()[0].stop_fines();
1049                                         } else {
1050                                                 return "";
1051                                         }
1052                                 }
1053                         }
1054                 },
1055                 {
1056                         'persist' : 'hidden width ordinal',
1057                         'id' : 'stop_fines_time',
1058                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.stop_fines_time'),
1059                         'flex' : 0,
1060                         'primary' : false,
1061                         'hidden' : true,
1062                         'render' : function(my) {
1063                                 if (my.circ) {
1064                                         return my.circ.stop_fines_time();
1065                                 } else {
1066                                         if (my.acp.circulations()) {
1067                                                 return my.acp.circulations()[0].stop_fines_time();
1068                                         } else {
1069                                                 return "";
1070                                         }
1071                                 }
1072                         }
1073                 },
1074                 {
1075                         'persist' : 'hidden width ordinal',
1076                         'id' : 'status',
1077                         'label' : document.getElementById('commonStrings').getString('staff.acp_label_status'),
1078                         'flex' : 1,
1079                         'primary' : false,
1080                         'hidden' : true,
1081                         'render' : function(my) {
1082                                 if (Number(my.acp.status())>=0) {
1083                                         return data.hash.ccs[ my.acp.status() ].name();
1084                                 } else {
1085                                         return my.acp.status().name();
1086                                 }
1087                         }
1088                 },
1089                 {
1090                         'persist' : 'hidden width ordinal',
1091                         'id' : 'route_to',
1092                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.route_to'),
1093                         'flex' : 1,
1094                         'primary' : false,
1095                         'hidden' : true,
1096                         'render' : function(my) { return my.route_to.toString(); }
1097                 },
1098                 {
1099                         'persist' : 'hidden width ordinal',
1100                         'id' : 'message',
1101                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.message'),
1102                         'flex' : 1,
1103                         'primary' : false,
1104                         'hidden' : true,
1105                         'render' : function(my) { return my.message.toString(); }
1106                 },
1107                 {
1108                         'persist' : 'hidden width ordinal',
1109                         'id' : 'uses',
1110                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.uses'),
1111                         'flex' : 1,
1112                         'primary' : false,
1113                         'hidden' : true,
1114                         'render' : function(my) { return my.uses; },
1115                         'sort_type' : 'number'
1116                 },
1117                 {
1118                         'persist' : 'hidden width ordinal',
1119                         'id' : 'alert_message',
1120                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.alert_message'),
1121                         'flex' : 1,
1122                         'primary' : false,
1123                         'hidden' : true,
1124                         'render' : function(my) { return my.acp.alert_message(); }
1125                 }
1126         ];
1127         for (var i = 0; i < c.length; i++) {
1128                 if (modify[ c[i].id ]) {
1129                         for (var j in modify[ c[i].id ]) {
1130                                 c[i][j] = modify[ c[i].id ][j];
1131                         }
1132                 }
1133         }
1134         if (params) {
1135                 if (params.just_these) {
1136                         JSAN.use('util.functional');
1137                         var new_c = [];
1138                         for (var i = 0; i < params.just_these.length; i++) {
1139                                 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
1140                                 new_c.push( function(y){ return y; }( x ) );
1141                         }
1142                         c = new_c;
1143                 }
1144                 if (params.except_these) {
1145                         JSAN.use('util.functional');
1146                         var new_c = [];
1147                         for (var i = 0; i < c.length; i++) {
1148                                 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
1149                                 if (!x) new_c.push(c[i]);
1150                         }
1151                         c = new_c;
1152                 }
1153         }
1154         return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
1155 };
1156
1157 circ.util.transit_columns = function(modify,params) {
1158         
1159         JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
1160
1161         var c = [
1162                 {
1163                         'persist' : 'hidden width ordinal',
1164                         'id' : 'transit_item_barcode',
1165                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.barcode'),
1166                         'flex' : 1,
1167                         'primary' : false,
1168                         'hidden' : true,
1169                         'render' : function(my) { return my.acp.barcode(); }
1170                 },
1171                 {
1172                         'persist' : 'hidden width ordinal',
1173                         'id' : 'transit_item_title',
1174                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.title'),
1175                         'flex' : 1,
1176                         'primary' : false,
1177                         'hidden' : true,
1178                         'render' : function(my) {
1179                                 try { return my.mvr.title(); }
1180                                 catch(E) { return my.acp.dummy_title(); }
1181                         }
1182                 },
1183                 {
1184                         'persist' : 'hidden width ordinal',
1185                         'id' : 'transit_item_author',
1186                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.author'),
1187                         'flex' : 1,
1188                         'primary' : false,
1189                         'hidden' : true,
1190                         'render' : function(my) {
1191                                 try { return my.mvr.author(); }
1192                                 catch(E) { return my.acp.dummy_author(); }
1193                         }
1194                 },
1195                 {
1196                         'persist' : 'hidden width ordinal',
1197                         'id' : 'transit_item_callnumber',
1198                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.callnumber'),
1199                         'flex' : 1,
1200                         'primary' : false,
1201                         'hidden' : true,
1202                         'render' : function(my) { return my.acn.label(); }
1203                 },
1204                 {
1205                         'persist' : 'hidden width ordinal',
1206                         'id' : 'transit_id',
1207                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_id'),
1208                         'flex' : 1,
1209                         'primary' : false,
1210                         'hidden' : true,
1211                         'render' : function(my) { return my.atc.id(); }
1212                 },
1213                 {
1214                         'persist' : 'hidden width ordinal',
1215                         'id' : 'transit_source',
1216                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_source'),
1217                         'flex' : 1,
1218                         'primary' : false,
1219                         'hidden' : false,
1220                         'render' : function(my) {
1221                                 if (typeof my.atc.source() == "object") {
1222                                         return my.atc.source().shortname();
1223                                 } else {
1224                                         return data.hash.aou[ my.atc.source() ].shortname();
1225                                 }
1226                         }
1227                 },
1228                 {
1229                         'persist' : 'hidden width ordinal',
1230                         'id' : 'transit_source_send_time',
1231                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_source_send_time'),
1232                         'flex' : 1,
1233                         'primary' : false,
1234                         'hidden' : false,
1235                         'render' : function(my) { return my.atc.source_send_time(); }
1236                 },
1237                 {
1238                         'persist' : 'hidden width ordinal',
1239                         'id' : 'transit_dest_lib',
1240                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_dest'),
1241                         'flex' : 1,
1242                         'primary' : false,
1243                         'hidden' : false,
1244                         'render' : function(my) {
1245                                 if (typeof my.atc.dest() == "object") {
1246                                         return my.atc.dest().shortname();
1247                                 } else {
1248                                         return data.hash.aou[ my.atc.dest() ].shortname();
1249                                 }
1250                         }
1251                 },
1252                 {
1253                         'persist' : 'hidden width ordinal',
1254                         'id' : 'transit_dest_recv_time',
1255                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_dest_recv_time'),
1256                         'flex' : 1,
1257                         'primary' : false,
1258                         'hidden' : false,
1259                         'render' : function(my) { return my.atc.dest_recv_time(); }
1260                 },
1261                 {
1262                         'persist' : 'hidden width ordinal',
1263                         'id' : 'transit_target_copy',
1264                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_target_copy'),
1265                         'flex' : 1,
1266                         'primary' : false,
1267                         'hidden' : true,
1268                         'render' : function(my) { return my.atc.target_copy(); }
1269                 },
1270         ];
1271         for (var i = 0; i < c.length; i++) {
1272                 if (modify[ c[i].id ]) {
1273                         for (var j in modify[ c[i].id ]) {
1274                                 c[i][j] = modify[ c[i].id ][j];
1275                         }
1276                 }
1277         }
1278         if (params) {
1279                 if (params.just_these) {
1280                         JSAN.use('util.functional');
1281                         var new_c = [];
1282                         for (var i = 0; i < params.just_these.length; i++) {
1283                                 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
1284                                 new_c.push( function(y){ return y; }( x ) );
1285                         }
1286                         c = new_c;
1287                 }
1288                 if (params.except_these) {
1289                         JSAN.use('util.functional');
1290                         var new_c = [];
1291                         for (var i = 0; i < c.length; i++) {
1292                                 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
1293                                 if (!x) new_c.push(c[i]);
1294                         }
1295                         c = new_c;
1296                 }
1297
1298         }
1299         return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
1300 };
1301
1302 circ.util.hold_columns = function(modify,params) {
1303         
1304         JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
1305
1306         var c = [
1307                 {
1308                         'persist' : 'hidden width ordinal',
1309                         'id' : 'request_lib',
1310                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.request_lib'),
1311                         'flex' : 1,
1312                         'primary' : false,
1313                         'hidden' : true,
1314                         'render' : function(my) {
1315                                 if (Number(my.ahr.request_lib())>=0) {
1316                                         return data.hash.aou[ my.ahr.request_lib() ].name();
1317                                 } else {
1318                                         return my.ahr.request_lib().name();
1319                                 }
1320                         }
1321                 },
1322                 {
1323                         'persist' : 'hidden width ordinal',
1324                         'id' : 'request_lib_shortname',
1325                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.request_lib_shortname'),
1326                         'flex' : 0,
1327                         'primary' : false,
1328                         'hidden' : true,
1329                         'render' : function(my) {
1330                                 if (Number(my.ahr.request_lib())>=0) {
1331                                         return data.hash.aou[ my.ahr.request_lib() ].shortname();
1332                                 } else {
1333                                         return my.ahr.request_lib().shortname();
1334                                 }
1335                         }
1336                 },
1337
1338                 {
1339                         'persist' : 'hidden width ordinal',
1340                         'id' : 'request_timestamp',
1341                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.request_timestamp'),
1342                         'flex' : 0,
1343                         'primary' : false,
1344                         'hidden' : true,
1345                         'render' : function(my) { return my.ahr.request_time().toString(); }
1346                 },
1347                 {
1348                         'persist' : 'hidden width ordinal',
1349                         'id' : 'request_time',
1350                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.request_time'),
1351                         'flex' : 0,
1352                         'primary' : false,
1353                         'hidden' : true,
1354                         'render' : function(my) { return my.ahr.request_time().toString().substr(0,10); }
1355                 },
1356                 {
1357                         'persist' : 'hidden width ordinal',
1358                         'id' : 'available_timestamp',
1359                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.available_timestamp'),
1360                         'flex' : 1,
1361                         'primary' : false,
1362                         'hidden' : true,
1363                         'render' : function(my) {
1364                                 if (my.ahr.transit() && my.ahr.transit().dest_recv_time()) {
1365                                         return my.ahr.transit().dest_recv_time().toString();
1366                                 }
1367                                 if (!my.ahr.transit() && my.ahr.capture_time()) {
1368                                         return my.ahr.capture_time().toString();
1369                                 }
1370                                 return "";
1371                         }
1372                 },
1373                 {
1374                         'persist' : 'hidden width ordinal',
1375                         'id' : 'available_time',
1376                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.available_time'),
1377                         'flex' : 1,
1378                         'primary' : false,
1379                         'hidden' : false,
1380                         'render' : function(my) {
1381                                 if (my.ahr.transit() && my.ahr.transit().dest_recv_time()) {
1382                                         return my.ahr.transit().dest_recv_time().toString().substr(0,10);
1383                                 }
1384                                 if (!my.ahr.transit() && my.ahr.capture_time()) {
1385                                         return my.ahr.capture_time().toString().substr(0,10);
1386                                 }
1387                                 return "";
1388                         }
1389                 },
1390                 {
1391                         'persist' : 'hidden width ordinal',
1392                         'id' : 'capture_timestamp',
1393                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.capture_timestamp'),
1394                         'flex' : 1,
1395                         'primary' : false,
1396                         'hidden' : true,
1397                         'render' : function(my) { return my.ahr.capture_time() ? my.ahr.capture_time().toString() : ""; }
1398                 },
1399                 {
1400                         'persist' : 'hidden width ordinal',
1401                         'id' : 'capture_time',
1402                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.capture_time'),
1403                         'flex' : 1,
1404                         'primary' : false,
1405                         'hidden' : true,
1406                         'render' : function(my) { return my.ahr.capture_time() ? my.ahr.capture_time().toString().substr(0,10) : ""; }
1407                 },
1408                 {
1409                         'persist' : 'hidden width ordinal',
1410                         'id' : 'status',
1411                         'label' : document.getElementById('commonStrings').getString('staff.ahr_status_label'),
1412                         'flex' : 1,
1413                         'primary' : false,
1414                         'hidden' : false,
1415                         'render' : function(my) {
1416                                 switch (Number(my.status)) {
1417                                         case 1:
1418                                                 return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.1');
1419                                                 break;
1420                                         case 2:
1421                                                 return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.2');
1422                                                 break;
1423                                         case 3:
1424                                                 return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.3');
1425                                                 break;
1426                                         case 4:
1427                                                 return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.4');
1428                                                 break;
1429                                         default:
1430                                                 return my.status;
1431                                                 break;
1432                                 };
1433                         }
1434                 },
1435                 {
1436                         'persist' : 'hidden width ordinal',
1437                         'id' : 'hold_type',
1438                         'label' : document.getElementById('commonStrings').getString('staff.ahr_hold_type_label'),
1439                         'flex' : 0,
1440                         'primary' : false,
1441                         'hidden' : true,
1442                         'render' : function(my) { return my.ahr.hold_type(); }
1443                 },
1444         {
1445                         'persist' : 'hidden width ordinal',
1446                         'id' : 'frozen',
1447                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.active'),
1448                         'flex' : 0,
1449                         'primary' : false,
1450                         'hidden' : true,
1451                         'render' : function(my) {
1452                                 if (!get_bool( my.ahr.frozen() )) {
1453                                         return document.getElementById('circStrings').getString('staff.circ.utils.yes');
1454                                 } else {
1455                                         return document.getElementById('circStrings').getString('staff.circ.utils.no');
1456                                 }
1457                         }
1458         },
1459         {
1460                         'persist' : 'hidden width ordinal',
1461                         'id' : 'thaw_date',
1462                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.thaw_date'),
1463                         'flex' : 0,
1464                         'primary' : false,
1465                         'hidden' : true,
1466                         'render' : function(my) {
1467                                 if (my.ahr.thaw_date() == null) {
1468                                         return document.getElementById('circStrings').getString('staff.circ.utils.thaw_date.none');
1469                                 } else {
1470                                         return my.ahr.thaw_date().substr(0,10);
1471                                 }
1472                         }
1473         },
1474                 {
1475                         'persist' : 'hidden width ordinal',
1476                         'id' : 'pickup_lib',
1477                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.pickup_lib'),
1478                         'flex' : 1,
1479                         'primary' : false,
1480                         'hidden' : true,
1481                         'render' : function(my) {
1482                                 if (Number(my.ahr.pickup_lib())>=0) {
1483                                         return data.hash.aou[ my.ahr.pickup_lib() ].name();
1484                                 } else {
1485                                         return my.ahr.pickup_lib().name();
1486                                 }
1487                         }
1488                 },
1489                 {
1490                         'persist' : 'hidden width ordinal',
1491                         'id' : 'pickup_lib_shortname',
1492                         'label' : document.getElementById('commonStrings').getString('staff.ahr_pickup_lib_label'),
1493                         'flex' : 0,
1494                         'primary' : false,
1495                         'hidden' : true,
1496                         'render' : function(my) {
1497                                 if (Number(my.ahr.pickup_lib())>=0) {
1498                                         return data.hash.aou[ my.ahr.pickup_lib() ].shortname();
1499                                 } else {
1500                                         return my.ahr.pickup_lib().shortname();
1501                                 }
1502                         }
1503                 },
1504                 {
1505                         'persist' : 'hidden width ordinal',
1506                         'id' : 'current_copy',
1507                         'label' : document.getElementById('commonStrings').getString('staff.ahr_current_copy_label'),
1508                         'flex' : 1,
1509                         'primary' : false,
1510                         'hidden' : true,
1511                         'render' : function(my) {
1512                                 if (my.acp) {
1513                                         return my.acp.barcode();
1514                                 } else {
1515                                         return document.getElementById('circStrings').getString('staff.circ.utils.current_copy.none');
1516                                 }
1517                         }
1518                 },
1519                 {
1520                         'persist' : 'hidden width ordinal',
1521                         'id' : 'current_copy_location', 
1522                         'label' : document.getElementById('commonStrings').getString('staff.ahr_current_copy_location_label'),
1523             'flex' : 1,
1524                         'primary' : false, 
1525             'hidden' : true, 
1526             'render' : function(my) { 
1527                 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(); } 
1528             }
1529                 },
1530                 {
1531                         'persist' : 'hidden width ordinal',
1532                         'id' : 'email_notify',
1533                         'label' : document.getElementById('commonStrings').getString('staff.ahr_email_notify_label'),
1534                         'flex' : 1,
1535                         'primary' : false,
1536                         'hidden' : true,
1537                         'render' : function(my) {
1538                                 if (get_bool(my.ahr.email_notify())) {
1539                                         return document.getElementById('circStrings').getString('staff.circ.utils.yes');
1540                                 } else {
1541                                         return document.getElementById('circStrings').getString('staff.circ.utils.no');
1542                                 }
1543                         }
1544                 },
1545                 {
1546                         'persist' : 'hidden width ordinal',
1547                         'id' : 'expire_time',
1548                         'label' : document.getElementById('commonStrings').getString('staff.ahr_expire_time_label'),
1549                         'flex' : 1,
1550                         'primary' : false,
1551                         'hidden' : true,
1552                         'render' : function(my) { return my.ahr.expire_time(); }
1553                 },
1554                 {
1555                         'persist' : 'hidden width ordinal',
1556                         'id' : 'expire_date',
1557                         'label' : document.getElementById('commonStrings').getString('staff.ahr_expire_date_label'),
1558                         'flex' : 1,
1559                         'primary' : false,
1560                         'hidden' : true,
1561                         'render' : function(my) { return my.ahr.expire_time() ? my.ahr.expire_time().toString().substr(0,10) : ''; }
1562                 },
1563                 {
1564                         'persist' : 'hidden width ordinal',
1565                         'id' : 'fulfillment_time',
1566                         'label' : document.getElementById('commonStrings').getString('staff.ahr_fulfillment_time_label'),
1567                         'flex' : 1,
1568                         'primary' : false,
1569                         'hidden' : true,
1570                         'render' : function(my) { return my.ahr.fulfillment_time(); }
1571                 },
1572                 {
1573                         'persist' : 'hidden width ordinal',
1574                         'id' : 'holdable_formats',
1575                         'label' : document.getElementById('commonStrings').getString('staff.ahr_holdable_formats_label'),
1576                         'flex' : 1,
1577                         'primary' : false,
1578                         'hidden' : true,
1579                         'render' : function(my) { return my.ahr.holdable_formats(); }
1580                 },
1581                 {
1582                         'persist' : 'hidden width ordinal',
1583                         'id' : 'id',
1584                         'label' : document.getElementById('commonStrings').getString('staff.ahr_id_label'),
1585                         'flex' : 1,
1586                         'primary' : false,
1587                         'hidden' : true,
1588                         'render' : function(my) { return my.ahr.id(); }
1589                 },
1590                 {
1591                         'persist' : 'hidden width ordinal',
1592                         'id' : 'phone_notify',
1593                         'label' : document.getElementById('commonStrings').getString('staff.ahr_phone_notify_label'),
1594                         'flex' : 1,
1595                         'primary' : false,
1596                         'hidden' : true,
1597                         'render' : function(my) { return my.ahr.phone_notify(); }
1598                 },
1599                 {
1600                         'persist' : 'hidden width ordinal',
1601                         'id' : 'prev_check_time',
1602                         'label' : document.getElementById('commonStrings').getString('staff.ahr_prev_check_time_label'),
1603                         'flex' : 1,
1604                         'primary' : false,
1605                         'hidden' : true,
1606                         'render' : function(my) { return my.ahr.prev_check_time(); }
1607                 },
1608                 {
1609                         'persist' : 'hidden width ordinal',
1610                         'id' : 'requestor',
1611                         'label' : document.getElementById('commonStrings').getString('staff.ahr_requestor_label'),
1612                         'flex' : 1,
1613                         'primary' : false,
1614                         'hidden' : true,
1615                         'render' : function(my) { return my.ahr.requestor(); }
1616                 },
1617                 {
1618                         'persist' : 'hidden width ordinal',
1619                         'id' : 'selection_depth',
1620                         'label' : document.getElementById('commonStrings').getString('staff.ahr_selection_depth_label'),
1621                         'flex' : 1,
1622                         'primary' : false,
1623                         'hidden' : true,
1624                         'render' : function(my) { return my.ahr.selection_depth(); }
1625                 },
1626                 {
1627                         'persist' : 'hidden width ordinal',
1628                         'id' : 'target',
1629                         'label' : document.getElementById('commonStrings').getString('staff.ahr_target_label'),
1630                         'flex' : 1,
1631                         'primary' : false,
1632                         'hidden' : true,
1633                         'render' : function(my) { return my.ahr.target(); }
1634                 },
1635                 {
1636                         'persist' : 'hidden width ordinal',
1637                         'id' : 'usr',
1638                         'label' : document.getElementById('commonStrings').getString('staff.ahr_usr_label'),
1639                         'flex' : 1,
1640                         'primary' : false,
1641                         'hidden' : true,
1642                         'render' : function(my) { return my.ahr.usr(); }
1643                 },
1644                 {
1645                         'persist' : 'hidden width ordinal',
1646                         'id' : 'title',
1647                         'label' : document.getElementById('commonStrings').getString('staff.mvr_label_title'),
1648                         'flex' : 1,
1649                         'sort_type' : 'title',
1650                         'primary' : false,
1651                         'hidden' : true,
1652                         'render' : function(my) {
1653                                 if (my.mvr) {
1654                                         return my.mvr.title();
1655                                 } else {
1656                                         return document.getElementById('circStrings').getString('staff.circ.utils.title.none');
1657                                 }
1658                         }
1659                 },
1660                 {
1661                         'persist' : 'hidden width ordinal',
1662                         'id' : 'author',
1663                         'label' : document.getElementById('commonStrings').getString('staff.mvr_label_author'),
1664                         'flex' : 1,
1665                         'primary' : false,
1666                         'hidden' : true,
1667                         'render' : function(my) {
1668                                 if (my.mvr) {
1669                                         return my.mvr.author();
1670                                 } else {
1671                                         return document.getElementById('circStrings').getString('staff.circ.utils.author.none');
1672                                 }
1673                         }
1674                 },
1675                 {
1676                         'persist' : 'hidden width ordinal',
1677                         'id' : 'edition',
1678                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.edition'),
1679                         'flex' : 1,
1680                         'primary' : false,
1681                         'hidden' : true,
1682                         'render' : function(my) { return my.mvr.edition(); }
1683                 },
1684                 {
1685                         'persist' : 'hidden width ordinal',
1686                         'id' : 'isbn',
1687                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.isbn'),
1688                         'flex' : 1,
1689                         'primary' : false,
1690                         'hidden' : true,
1691                         'render' : function(my) { return my.mvr.isbn(); }
1692                 },
1693                 {
1694                         'persist' : 'hidden width ordinal',
1695                         'id' : 'pubdate',
1696                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.pubdate'),
1697                         'flex' : 1,
1698                         'primary' : false,
1699                         'hidden' : true,
1700                         'render' : function(my) { return my.mvr.pubdate(); }
1701                 },
1702                 {
1703                         'persist' : 'hidden width ordinal',
1704                         'id' : 'publisher',
1705                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.publisher'),
1706                         'flex' : 1,
1707                         'primary' : false,
1708                         'hidden' : true,
1709                         'render' : function(my) { return my.mvr.publisher(); }
1710                 },
1711                 {
1712                         'persist' : 'hidden width ordinal',
1713                         'id' : 'tcn',
1714                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.tcn'),
1715                         'flex' : 1,
1716                         'primary' : false,
1717                         'hidden' : true,
1718                         'render' : function(my) { return my.mvr.tcn(); }
1719                 },
1720                 {
1721                         'persist' : 'hidden width ordinal',
1722                         'id' : 'notify_time',
1723                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.notify_time'),
1724                         'flex' : 1,
1725                         'primary' : false,
1726                         'hidden' : true,
1727                         'render' : function(my) { return my.ahr.notify_time(); }
1728                 },
1729                 {
1730                         'persist' : 'hidden width ordinal',
1731                         'id' : 'notify_count',
1732                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.notify_count'),
1733                         'flex' : 1,
1734                         'primary' : false,
1735                         'hidden' : true,
1736                         'render' : function(my) { return my.ahr.notify_count(); }
1737                 },
1738                 {
1739                         'persist' : 'hidden width ordinal',
1740                         'id' : 'transit_source',
1741                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_source'),
1742                         'flex' : 1,
1743                         'primary' : false,
1744                         'hidden' : true,
1745                         'render' : function(my) {
1746                                 if (my.ahr.transit()) {
1747                                         return data.hash.aou[ my.ahr.transit().source() ].shortname();
1748                                 } else {
1749                                         return "";
1750                                 }
1751                         }
1752                 },
1753                 {
1754                         'persist' : 'hidden width ordinal',
1755                         'id' : 'transit_source_send_time',
1756                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_source_send_time'),
1757                         'flex' : 1,
1758                         'primary' : false,
1759                         'hidden' : true,
1760                         'render' : function(my) { return my.ahr.transit() ?  my.ahr.transit().source_send_time() : ""; }
1761                 },
1762                 {
1763                         'persist' : 'hidden width ordinal',
1764                         'id' : 'transit_dest_lib',
1765                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_dest'),
1766                         'flex' : 1,
1767                         'primary' : false,
1768                         'hidden' : true,
1769                         'render' : function(my) { return my.ahr.transit() ?  data.hash.aou[ my.ahr.transit().dest() ].shortname() : ""; }
1770                 },
1771                 {
1772                         'persist' : 'hidden width ordinal',
1773                         'id' : 'transit_dest_recv_time',
1774                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_dest_recv_time'),
1775                         'flex' : 1,
1776                         'primary' : false,
1777                         'hidden' : true,
1778                         'render' : function(my) { return my.ahr.transit() ?  my.ahr.transit().dest_recv_time() : ""; }
1779                 },
1780                 {
1781                         'persist' : 'hidden width ordinal',
1782                         'id' : 'patron_barcode',
1783                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.patron_barcode'),
1784                         'flex' : 1,
1785                         'primary' : false,
1786                         'hidden' : true,
1787                         'render' : function(my) { return my.patron_barcode ? my.patron_barcode : ""; }
1788                 },
1789                 {
1790                         'persist' : 'hidden width ordinal',
1791                         'id' : 'patron_family_name',
1792                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.patron_family_name'),
1793                         'flex' : 1,
1794                         'primary' : false,
1795                         'hidden' : true,
1796                         'render' : function(my) { return my.patron_family_name ? my.patron_family_name : ""; }
1797                 },
1798                 {
1799                         'persist' : 'hidden width ordinal',
1800                         'id' : 'patron_first_given_name',
1801                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.patron_first_given_name'),
1802                         'flex' : 1,
1803                         'primary' : false,
1804                         'hidden' : true,
1805                         'render' : function(my) { return my.patron_first_given_name ? my.patron_first_given_name : ""; }
1806                 },
1807                 {
1808                         'persist' : 'hidden width ordinal',
1809                         'id' : 'callnumber',
1810                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.callnumber'),
1811                         'flex' : 1,
1812                         'primary' : false,
1813                         'hidden' : true,
1814                         'render' : function(my) { return my.acn.label(); }
1815                 },
1816                 {
1817                         'persist' : 'hidden width ordinal',
1818                         'id' : 'total_holds',
1819                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.total_holds'),
1820                         'flex' : 1,
1821                         'primary' : false,
1822                         'hidden' : true,
1823                         'render' : function(my) { return my.total_holds; }
1824                 },
1825                 {
1826                         'persist' : 'hidden width ordinal',
1827                         'id' : 'queue_position',
1828                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.queue_position'),
1829                         'flex' : 1,
1830                         'primary' : false,
1831                         'hidden' : true,
1832                         'render' : function(my) { return my.queue_position; }
1833                 },
1834                 {
1835                         'persist' : 'hidden width ordinal',
1836                         'id' : 'potential_copies',
1837                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.potential_copies'),
1838                         'flex' : 1,
1839                         'primary' : false,
1840                         'hidden' : true,
1841                         'render' : function(my) { return my.potential_copies; }
1842                 },
1843                 {
1844                         'persist' : 'hidden width ordinal',
1845                         'id' : 'estimated_wait',
1846                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.estimated_wait'),
1847                         'flex' : 1,
1848                         'primary' : false,
1849                         'hidden' : true,
1850                         'render' : function(my) { return my.estimated_wait; }
1851                 }
1852         ];
1853         for (var i = 0; i < c.length; i++) {
1854                 if (modify[ c[i].id ]) {
1855                         for (var j in modify[ c[i].id ]) {
1856                                 c[i][j] = modify[ c[i].id ][j];
1857                         }
1858                 }
1859         }
1860         if (params) {
1861                 if (params.just_these) {
1862                         JSAN.use('util.functional');
1863                         var new_c = [];
1864                         for (var i = 0; i < params.just_these.length; i++) {
1865                                 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
1866                                 new_c.push( function(y){ return y; }( x ) );
1867                         }
1868                         c = new_c;
1869                 }
1870                 if (params.except_these) {
1871                         JSAN.use('util.functional');
1872                         var new_c = [];
1873                         for (var i = 0; i < c.length; i++) {
1874                                 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
1875                                 if (!x) new_c.push(c[i]);
1876                         }
1877                         c = new_c;
1878                 }
1879
1880         }
1881         return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
1882 };
1883 /*
1884 circ.util.std_map_row_to_column = function(error_value) {
1885         return function(row,col) {
1886                 // row contains { 'my' : { 'acp' : {}, 'circ' : {}, 'mvr' : {} } }
1887                 // col contains one of the objects listed above in columns
1888                 
1889                 // mimicking some of the obj in circ.checkin and circ.checkout where map_row_to_column is usually defined
1890                 var obj = {};
1891                 JSAN.use('util.error'); obj.error = new util.error();
1892                 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
1893                 JSAN.use('util.network'); obj.network = new util.network();
1894                 JSAN.use('util.money');
1895
1896                 var my = row.my;
1897                 var value;
1898                 try {
1899                         value = eval( col.render );
1900                 } catch(E) {
1901                         obj.error.sdump('D_WARN','map_row_to_column: ' + E);
1902                         if (error_value) value = error_value; else value = '   ';
1903                 }
1904                 return value;
1905         }
1906 };
1907 */
1908 circ.util.std_map_row_to_columns = function(error_value) {
1909         return function(row,cols) {
1910                 // row contains { 'my' : { 'acp' : {}, 'circ' : {}, 'mvr' : {} } }
1911                 // cols contains all of the objects listed above in columns
1912                 
1913                 var obj = {};
1914                 JSAN.use('util.error'); obj.error = new util.error();
1915                 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
1916                 JSAN.use('util.network'); obj.network = new util.network();
1917                 JSAN.use('util.money');
1918
1919                 var my = row.my;
1920                 var values = [];
1921                 var cmd = '';
1922                 try {
1923                         for (var i = 0; i < cols.length; i++) {
1924                                 switch (typeof cols[i].render) {
1925                                         case 'function': try { values[i] = cols[i].render(my); } catch(E) { values[i] = error_value; obj.error.sdump('D_COLUMN_RENDER_ERROR',E); } break;
1926                                         case 'string' : cmd += 'try { ' + cols[i].render + '; values['+i+'] = v; } catch(E) { values['+i+'] = error_value; }'; break;
1927                                         default: cmd += 'values['+i+'] = "??? '+(typeof cols[i].render)+'"; ';
1928                                 }
1929                         }
1930                         if (cmd) eval( cmd );
1931                 } catch(E) {
1932                         obj.error.sdump('D_WARN','map_row_to_column: ' + E);
1933                         if (error_value) { value = error_value; } else { value = '   ' };
1934                 }
1935                 return values;
1936         }
1937 };
1938
1939 circ.util.checkin_via_barcode = function(session,params,backdate,auto_print,async) {
1940         try {
1941                 JSAN.use('util.error'); var error = new util.error();
1942                 JSAN.use('util.network'); var network = new util.network();
1943                 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
1944                 JSAN.use('util.date'); JSAN.use('util.functional');
1945
1946                 if (backdate && (backdate == util.date.formatted_date(new Date(),'%Y-%m-%d')) ) backdate = null;
1947
1948                 //var params = { 'barcode' : barcode };
1949                 if (backdate) params.backdate = util.date.formatted_date(backdate + ' 00:00:00','%{iso8601}');
1950
1951                 if (typeof params.disable_textbox == 'function') {
1952                         try { params.disable_textbox(); }
1953                         catch(E) { error.sdump('D_ERROR','params.disable_textbox() = ' + E); };
1954                 }
1955
1956         function checkin_callback(req) {
1957             try {
1958                 var check = req.getResultObject();
1959                 var r = circ.util.checkin_via_barcode2(session,params,backdate,auto_print,check);
1960                 if (typeof params.checkin_result == 'function') {
1961                     try { params.checkin_result(r); }
1962                     catch(E) { error.sdump('D_ERROR','params.checkin_result() = ' + E); };
1963                 }
1964                                 if (typeof async == 'function') async(check);
1965                                 return check;
1966             } catch(E) {
1967                 JSAN.use('util.error'); var error = new util.error();
1968                 error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.error', ['1']), E);
1969                 if (typeof params.enable_textbox == 'function') {
1970                     try { params.enable_textbox(); }
1971                     catch(E) { error.sdump('D_ERROR','params.disable_textbox() = ' + E); };
1972                 }
1973                 return null;
1974             }
1975         } 
1976
1977                 var check = network.request(
1978                         api.CHECKIN_VIA_BARCODE.app,
1979                         api.CHECKIN_VIA_BARCODE.method,
1980                         [ session, util.functional.filter_object( params, function(i,o) { return typeof o != 'function'; } ) ],
1981                         async ? checkin_callback : null,
1982                         {
1983                                 'title' : document.getElementById('circStrings').getString('staff.circ.utils.checkin.override'),
1984                                 'overridable_events' : [
1985                     null /* custom event */,
1986                                         1203 /* COPY_BAD_STATUS */,
1987                                         1213 /* PATRON_BARRED */,
1988                                         1217 /* PATRON_INACTIVE */,
1989                                         1224 /* PATRON_ACCOUNT_EXPIRED */,
1990                                         1234 /* ITEM_DEPOSIT_PAID */,
1991                                         7009 /* CIRC_CLAIMS_RETURNED */,
1992                                         7010 /* COPY_ALERT_MESSAGE */,
1993                                         7011 /* COPY_STATUS_LOST */,
1994                                         7012 /* COPY_STATUS_MISSING */,
1995                                         7013 /* PATRON_EXCEEDS_FINES */,
1996                                 ],
1997                                 'text' : {
1998                                         '1203' : function(r) {
1999                                                 return typeof r.payload.status() == 'object' ? r.payload.status().name() : data.hash.ccs[ r.payload.status() ].name();
2000                                         },
2001                                         '1234' : function(r) {
2002                                                 return document.getElementById('circStrings').getString('staff.circ.utils.checkin.override.item_deposit_paid.warning');
2003                                         },
2004                                         '7010' : function(r) {
2005                                                 return r.payload;
2006                                         }
2007                                 }
2008                         }
2009                 );
2010                 if (! async ) {
2011                         return checkin_callback( { 'getResultObject' : function() { return check; } } );
2012                 }
2013
2014
2015         } catch(E) {
2016                 JSAN.use('util.error'); var error = new util.error();
2017                 error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.error', ['2']), E);
2018                 if (typeof params.enable_textbox == 'function') {
2019                         try { params.enable_textbox(); } catch(E) { error.sdump('D_ERROR','params.disable_textbox() = ' + E); };
2020                 }
2021                 return null;
2022         }
2023 };
2024
2025 circ.util.checkin_via_barcode2 = function(session,params,backdate,auto_print,check) {
2026         try {
2027                 JSAN.use('util.error'); var error = new util.error();
2028                 JSAN.use('util.network'); var network = new util.network();
2029                 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
2030                 JSAN.use('util.date');
2031
2032                 error.sdump('D_DEBUG','check = ' + error.pretty_print( js2JSON( check ) ) );
2033
2034                 check.message = check.textcode;
2035
2036                 if (check.payload && check.payload.copy) { check.copy = check.payload.copy; }
2037                 if (check.payload && check.payload.record) { check.record = check.payload.record; }
2038                 if (check.payload && check.payload.circ) { check.circ = check.payload.circ; }
2039
2040                 if (!check.route_to) { check.route_to = '   '; }
2041
2042                 if (document.getElementById('no_change_label')) {
2043                         document.getElementById('no_change_label').setAttribute('value','');
2044                         document.getElementById('no_change_label').setAttribute('hidden','true');
2045                 }
2046
2047                 if (check.circ) {
2048                         network.simple_request('FM_MBTS_RETRIEVE.authoritative',[ses(),check.circ.id()], function(req) {
2049                                 JSAN.use('util.money');
2050                                 var bill = req.getResultObject();
2051                                 if (Number(bill.balance_owed()) == 0) { return; }
2052                                 if (document.getElementById('no_change_label')) {
2053                                         var m = document.getElementById('no_change_label').getAttribute('value');
2054                                         document.getElementById('no_change_label').setAttribute('value', m + document.getElementById('circStrings').getFormattedString('staff.circ.utils.billable.amount', [params.barcode, util.money.sanitize(bill.balance_owed())]) + '  ');
2055                                         document.getElementById('no_change_label').setAttribute('hidden','false');
2056                                 }
2057                         });
2058                 }
2059
2060                 var msg = '';
2061
2062                 if (check.payload && check.payload.cancelled_hold_transit) {
2063                         msg += document.getElementById('circStrings').getString('staff.circ.utils.transit_hold_cancelled');
2064                         msg += '\n\n';
2065                 }
2066
2067                 /* SUCCESS  /  NO_CHANGE  /  ITEM_NOT_CATALOGED */
2068                 if (check.ilsevent == 0 || check.ilsevent == 3 || check.ilsevent == 1202) {
2069                         try { check.route_to = data.lookup('acpl', check.copy.location() ).name(); }
2070                         catch(E) {
2071                                 msg += document.getElementById('commonStrings').getString('common.error');
2072                                 msg += '\nFIXME: ' + E + '\n';
2073                         }
2074                         if (check.ilsevent == 3 /* NO_CHANGE */) {
2075                                 //msg = 'This item is already checked in.\n';
2076                                 if (document.getElementById('no_change_label')) {
2077                                         var m = document.getElementById('no_change_label').getAttribute('value');
2078                                         document.getElementById('no_change_label').setAttribute('value', m + document.getElementById('circStrings').getFormattedString('staff.circ.utils.item_checked_in', [params.barcode]) + '  ');
2079                                         document.getElementById('no_change_label').setAttribute('hidden','false');
2080                                 }
2081                         }
2082                         if (check.ilsevent == 1202 /* ITEM_NOT_CATALOGED */ && check.copy.status() != 11) {
2083                                 var copy_status = (data.hash.ccs[ check.copy.status() ] ? data.hash.ccs[ check.copy.status() ].name() : check.copy.status().name() );
2084                                 msg = document.getElementById('commonStrings').getString('common.error');
2085                                 msg += '\nFIXME --';
2086                                 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.item_not_cataloged', [copy_status]);
2087                                 msg + '\n';
2088                         }
2089                         switch(Number(check.copy.status())) {
2090                                 case 0: /* AVAILABLE */
2091                                 case 7: /* RESHELVING */
2092                                         if (msg) {
2093                                                 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2094                                                 msg += '\n';
2095                                         }
2096                                 break;
2097                                 case 8: /* ON HOLDS SHELF */
2098                                         check.route_to = 'HOLDS SHELF';
2099                                         if (check.payload.hold) {
2100                                                 if (check.payload.hold.pickup_lib() != data.list.au[0].ws_ou()) {
2101                                                         msg += document.getElementById('commonStrings').getString('common.error');
2102                                                         msg += '\nFIXME: ';
2103                                                         msg += document.getElementById('circStrings').getString('staff.circ.utils.route_item_error');
2104                                                         msg += '\n';
2105                                                 } else {
2106                                                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2107                                                         msg += '.\n';
2108                                                 }
2109                                         } else {
2110                                                 msg += document.getElementById('commonStrings').getString('common.error');
2111                                                 msg += '\nFIXME: ';
2112                                                 msg += document.getElementById('circStrings').getString('staff.circ.utils.route_item_status_error');
2113                                                 msg += '\n';
2114                                         }
2115                                         JSAN.use('util.date');
2116                                         if (check.payload.hold) {
2117                                                 JSAN.use('patron.util');
2118                                                 msg += '\n';
2119                                                 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [check.payload.copy.barcode()]);
2120                                                 msg += '\n';
2121                                                 var payload_title  = (check.payload.record ? check.payload.record.title() : check.payload.copy.dummy_title() );
2122                                                 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.title', [payload_title]);
2123                                                 msg += '\n';
2124                                                 var au_obj = patron.util.retrieve_fleshed_au_via_id( session, check.payload.hold.usr() );
2125                                                 msg += '\n';
2126                         if (au_obj.alias()) {
2127                                                 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.patron_alias',  [au_obj.alias()]);
2128                         } else {
2129                                                 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.patron',  [au_obj.family_name(), au_obj.first_given_name(), au_obj.second_given_name()]);
2130                         }
2131                                                 msg += '\n';
2132                                                 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [au_obj.card().barcode()]);
2133                                                 msg += '\n';
2134                                                 if (check.payload.hold.phone_notify()) {
2135                                                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.phone_notify', [check.payload.hold.phone_notify()]);
2136                                                         msg += '\n';
2137                                                 }
2138                                                 if (get_bool(check.payload.hold.email_notify())) {
2139                                                         var payload_email = au_obj.email() ? au_obj.email() : '';
2140                                                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.email_notify', [payload_email]);
2141                                                         msg += '\n';
2142                                                 }
2143                                                 msg += '\n';
2144                                                 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.request_date', [util.date.formatted_date(check.payload.hold.request_time(),'%F')]);
2145                                                 msg += '\n';
2146                                         }
2147                                         var rv = 0;
2148                                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.slip_date', [util.date.formatted_date(new Date(),'%F')]);
2149                                         msg += '\n';
2150                                         if (!auto_print) {
2151                                                 rv = error.yns_alert_formatted(
2152                                                         msg,
2153                                                         document.getElementById('circStrings').getString('staff.circ.utils.hold_slip'),
2154                                                         document.getElementById('circStrings').getString('staff.circ.utils.hold_slip.print.yes'),
2155                                                         document.getElementById('circStrings').getString('staff.circ.utils.hold_slip.print.no'),
2156                                                         null,
2157                                                         document.getElementById('circStrings').getString('staff.circ.confirm.msg'),
2158                                                         '/xul/server/skin/media/images/turtle.gif'
2159                                                 );
2160                                         }
2161                                         if (rv == 0) {
2162                                                 try {
2163                                                         JSAN.use('util.print'); var print = new util.print();
2164                                                         msg = msg.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\n/g,'<br/>');
2165                                                         print.simple( msg , { 'no_prompt' : true, 'content_type' : 'text/html' } );
2166                                                 } catch(E) {
2167                                                         var err_msg = document.getElementById('commonStrings').getString('common.error');
2168                                                         err_msg += '\nFIXME: ' + E + '\n';
2169                                                         dump(err_msg);
2170                                                         alert(err_msg);
2171                                                 }
2172                                         }
2173                                         msg = '';
2174                                         if (document.getElementById('no_change_label')) {
2175                                                 var m = document.getElementById('no_change_label').getAttribute('value');
2176                                                 m += document.getElementById('circStrings').getFormattedString('staff.circ.utils.capture', [params.barcode]);
2177                                                 document.getElementById('no_change_label').setAttribute('value', m);
2178                                                 document.getElementById('no_change_label').setAttribute('hidden','false');
2179                                         }
2180                                 break;
2181                                 case 6: /* IN TRANSIT */
2182                                         check.route_to = 'TRANSIT SHELF??';
2183                                         msg += document.getElementById('commonStrings').getString('common.error');
2184                                         msg += "\nFIXME -- I didn't think we could get here.\n";
2185                                 break;
2186                                 case 11: /* CATALOGING */
2187                                         check.route_to = 'CATALOGING';
2188                                         if (document.getElementById('do_not_alert_on_precat')) {
2189                                                 var x = document.getElementById('do_not_alert_on_precat');
2190                                                 if (! x.checked) {
2191                                                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2192                                                 }
2193                                         } else {
2194                                                 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2195                                         }
2196                                         if (document.getElementById('no_change_label')) {
2197                                                 var m = document.getElementById('no_change_label').getAttribute('value');
2198                                                 var needs_cat = document.getElementById('circStrings').getFormattedString('staff.circ.utils.needs_cataloging', [params.barcode]);
2199                                                 document.getElementById('no_change_label').setAttribute('value', m + needs_cat + '  ');
2200                                                 document.getElementById('no_change_label').setAttribute('hidden','false');
2201                                         }
2202                                 break;
2203                                 default:
2204                                         msg += document.getElementById('commonStrings').getString('common.error');
2205                                         var copy_status = data.hash.ccs[check.copy.status()] ? data.hash.ccs[check.copy.status()].name() : check.copy.status().name();
2206                                         msg += '\n';
2207                                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.copy_status.error', [copy_status]);
2208                                         msg += '\n';
2209                                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2210                                 break;
2211                         }
2212                         if (msg) {
2213                                 error.yns_alert(
2214                                         msg,
2215                                         document.getElementById('circStrings').getString('staff.circ.alert'),
2216                                         null,
2217                                         document.getElementById('circStrings').getString('staff.circ.utils.msg.ok'),
2218                                         null,
2219                                         document.getElementById('circStrings').getString('staff.circ.confirm.msg')
2220                                 );
2221                         }
2222                 } else /* ROUTE_ITEM */ if (check.ilsevent == 7000) {
2223
2224                         var lib = data.hash.aou[ check.org ];
2225                         check.route_to = lib.shortname();
2226                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.destination', [check.route_to]);
2227                         msg += '\n\n';
2228                         msg += lib.name();
2229                         msg += '\n';
2230                         try {
2231                                 if (lib.holds_address() ) {
2232                                         var a = network.simple_request('FM_AOA_RETRIEVE',[ lib.holds_address() ]);
2233                                         if (typeof a.ilsevent != 'undefined') throw(a);
2234                                         if (a.street1()) msg += a.street1() + '\n';
2235                                         if (a.street2()) msg += a.street2() + '\n';
2236                                         msg += (a.city() ? a.city() + ', ' : '') + (a.state() ? a.state() + ' ' : '') + (a.post_code() ? a.post_code() : '') + '\n';
2237                                 } else {
2238                                         msg += document.getElementById('circStrings').getString('staff.circ.utils.route_to.no_address');
2239                                         msg += '\n';
2240                                 }
2241                         } catch(E) {
2242                                 msg += document.getElementById('circStrings').getString('staff.circ.utils.route_to.no_address.error');
2243                                 msg += '\n';
2244                                 error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.utils.route_to.no_address.error'), E);
2245                         }
2246                         msg += '\n';
2247                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [check.payload.copy.barcode()]);
2248                         msg += '\n';
2249                         var payload_title  = (check.payload.record ? check.payload.record.title() : check.payload.copy.dummy_title() );
2250                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.title', [payload_title]);
2251                         msg += '\n';
2252                         var payload_author = (check.payload.record ? check.payload.record.author() :check.payload.copy.dummy_author());
2253                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.author', [payload_author]);
2254                         msg += '\n';
2255                         JSAN.use('util.date');
2256                         if (check.payload.hold) {
2257                                 JSAN.use('patron.util');
2258                                 var au_obj = patron.util.retrieve_fleshed_au_via_id( session, check.payload.hold.usr() );
2259                                 msg += '\n';
2260                 if (au_obj.alias()) {
2261                     msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.patron_alias',  [au_obj.alias()]);
2262                 } else {
2263                                 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.patron', [au_obj.family_name(), au_obj.first_given_name(), au_obj.second_given_name()]);
2264                 }
2265                                 msg += '\n';
2266                                 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [au_obj.card().barcode()]);
2267                                 msg += '\n';
2268                                 if (check.payload.hold.phone_notify()) {
2269                                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.phone_notify', [check.payload.hold.phone_notify()]);
2270                                         msg += '\n';
2271                                 }
2272                                 if (get_bool(check.payload.hold.email_notify())) {
2273                                         var payload_email = au_obj.email() ? au_obj.email() : '';
2274                                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.email_notify', [payload_email]);
2275                                         msg += '\n';
2276                                 }
2277                                 msg += '\n';
2278                                 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.request_date', [util.date.formatted_date(check.payload.hold.request_time(),'%F')]);
2279                                 msg += '\n';
2280                         }
2281                         var rv = 0;
2282                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.slip_date', [util.date.formatted_date(new Date(),'%F')]);
2283                         if (!auto_print) {
2284                                 rv = error.yns_alert_formatted(
2285                                         msg,
2286                                         document.getElementById('circStrings').getString('staff.circ.utils.transit_slip'),
2287                                         document.getElementById('circStrings').getString('staff.circ.utils.transit_slip.print.yes'),
2288                                         document.getElementById('circStrings').getString('staff.circ.utils.transit_slip.print.no'),
2289                                         null,
2290                                         document.getElementById('circStrings').getString('staff.circ.confirm.msg'),
2291                                         '/xul/server/skin/media/images/turtle.gif'
2292                                 );
2293                         }
2294
2295                         if (rv == 0) {
2296                                 try {
2297                                         JSAN.use('util.print'); var print = new util.print();
2298                                         //print.simple( msg, { 'no_prompt' : true, 'content_type' : 'text/plain' } );
2299                                         msg = msg.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\n/g,'<br/>');
2300                                         print.simple( msg , { 'no_prompt' : true, 'content_type' : 'text/html' } );
2301                                 } catch(E) {
2302                                         var err_msg = document.getElementById('commonStrings').getString('common.error');
2303                                         err_msg += '\nFIXME: ' + E + '\n';
2304                                         dump(err_msg);
2305                                         alert(err_msg);
2306                                 }
2307                         }
2308                         if (document.getElementById('no_change_label')) {
2309                                 var m = document.getElementById('no_change_label').getAttribute('value');
2310                                 var trans_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.in_transit', [params.barcode]);
2311                                 document.getElementById('no_change_label').setAttribute('value', m + trans_msg + '  ');
2312                                 document.getElementById('no_change_label').setAttribute('hidden','false');
2313                         }
2314
2315                 } else /* ASSET_COPY_NOT_FOUND */ if (check.ilsevent == 1502) {
2316
2317                         check.route_to = 'CATALOGING';
2318                         var mis_scan_msg = document.getElementById('circStrings').getFormattedString('staff.circ.copy_status.status.copy_not_found', [params.barcode]);
2319                         error.yns_alert(
2320                                 mis_scan_msg,
2321                                 document.getElementById('circStrings').getString('staff.circ.alert'),
2322                                 null,
2323                                 document.getElementById('circStrings').getString('staff.circ.utils.msg.ok'),
2324                                 null,
2325                                 document.getElementById('circStrings').getString('staff.circ.confirm.msg')
2326                         );
2327                         if (document.getElementById('no_change_label')) {
2328                                 var m = document.getElementById('no_change_label').getAttribute('value');
2329                                 document.getElementById('no_change_label').setAttribute('value',m + mis_scan_msg + '  ');
2330                                 document.getElementById('no_change_label').setAttribute('hidden','false');
2331                         }
2332
2333                 } else /* HOLD_CAPTURE_DELAYED */ if (check.ilsevent == 7019) {
2334
2335                         var rv = 0;
2336                         msg += document.getElementById('circStrings').getString('staff.circ.utils.hold_capture_delayed.description');
2337                         rv = error.yns_alert_formatted(
2338                                 msg,
2339                                 document.getElementById('circStrings').getString('staff.circ.utils.hold_capture_delayed.titlebar'),
2340                                 document.getElementById('circStrings').getString('staff.circ.utils.hold_capture_delayed.prompt_for_nocapture'),
2341                                 document.getElementById('circStrings').getString('staff.circ.utils.hold_capture_delayed.prompt_for_capture'),
2342                                 null,
2343                                 document.getElementById('circStrings').getString('staff.circ.confirm.msg'),
2344                                 '/xul/server/skin/media/images/stop_sign.png'
2345                         );
2346                         params.capture = rv == 0 ? 'nocapture' : 'capture';
2347
2348                         return circ.util.checkin_via_barcode(session,params,backdate,auto_print,false); 
2349
2350                 } else /* NETWORK TIMEOUT */ if (check.ilsevent == -1) {
2351                         error.standard_network_error_alert(document.getElementById('circStrings').getString('staff.circ.checkin.suggest_offline'));
2352                 } else {
2353
2354             if (check.ilsevent == null) { return null; /* handled */ }
2355                         switch (Number(check.ilsevent)) {
2356                                 case 1203 /* COPY_BAD_STATUS */ :
2357                                 case 1213 /* PATRON_BARRED */ :
2358                                 case 1217 /* PATRON_INACTIVE */ :
2359                                 case 1224 /* PATRON_ACCOUNT_EXPIRED */ :
2360                                 case 1234 /* ITEM_DEPOSIT_PAID */ :
2361                                 case 7009 /* CIRC_CLAIMS_RETURNED */ :
2362                                 case 7010 /* COPY_ALERT_MESSAGE */ :
2363                                 case 7011 /* COPY_STATUS_LOST */ :
2364                                 case 7012 /* COPY_STATUS_MISSING */ :
2365                                 case 7013 /* PATRON_EXCEEDS_FINES */ :
2366                                         return null; /* handled */
2367                                 break;
2368                         }
2369
2370                         throw(check);
2371
2372                 }
2373
2374                 return check;
2375         } catch(E) {
2376                 JSAN.use('util.error'); var error = new util.error();
2377                 error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.error', ['3']), E);
2378                 return null;
2379         }
2380 };
2381
2382 circ.util.renew_via_barcode = function ( barcode, patron_id, async ) {
2383         try {
2384                 var obj = {};
2385                 JSAN.use('util.network'); obj.network = new util.network();
2386                 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.stash_retrieve();
2387
2388                 var params = { barcode: barcode };
2389                 if (patron_id) params.patron = patron_id;
2390
2391                 function renew_callback(req) {
2392                         try {
2393                                 var renew = req.getResultObject();
2394                                 if (typeof renew.ilsevent != 'undefined') renew = [ renew ];
2395                                 for (var j = 0; j < renew.length; j++) {
2396                                         switch(renew[j].ilsevent == null ? null : Number(renew[j].ilsevent)) {
2397                                                 case 0 /* SUCCESS */ : break;
2398                                                 case null /* custom event */ : break;
2399                                                 case 5000 /* PERM_FAILURE */: break;
2400                                                 case 1212 /* PATRON_EXCEEDS_OVERDUE_COUNT */ : break;
2401                                                 case 1213 /* PATRON_BARRED */ : break;
2402                                                 case 1215 /* CIRC_EXCEEDS_COPY_RANGE */ : break;
2403                                                 case 1224 /* PATRON_ACCOUNT_EXPIRED */ : break;
2404                         case 1232 /* ITEM_DEPOSIT_REQUIRED */ : break;
2405                         case 1233 /* ITEM_RENTAL_FEE_REQUIRED */ : break;
2406                                             case 1234 /* ITEM_DEPOSIT_PAID */ : break;
2407                                                 case 1500 /* ACTION_CIRCULATION_NOT_FOUND */ : break;
2408                                                 case 7002 /* PATRON_EXCEEDS_CHECKOUT_COUNT */ : break;
2409                                                 case 7003 /* COPY_CIRC_NOT_ALLOWED */ : break;
2410                                                 case 7004 /* COPY_NOT_AVAILABLE */ : break;
2411                                                 case 7006 /* COPY_IS_REFERENCE */ : break;
2412                                                 case 7007 /* COPY_NEEDED_FOR_HOLD */ : break;
2413                                                 case 7008 /* MAX_RENEWALS_REACHED */ : break;
2414                                                 case 7009 /* CIRC_CLAIMS_RETURNED */ : break;
2415                                                 case 7010 /* COPY_ALERT_MESSAGE */ : break;
2416                                                 case 7013 /* PATRON_EXCEEDS_FINES */ : break;
2417                                                 default:
2418                                                         throw(renew);
2419                                                 break;
2420                                         }
2421                                 }
2422                                 if (typeof async == 'function') async(renew);
2423                                 return renew;
2424                         } catch(E) {
2425                                 JSAN.use('util.error'); var error = new util.error();
2426                                 error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.renew_failed.error', [barcode]), E);
2427                                 return null;
2428                         }
2429                 }
2430
2431                 var renew = obj.network.simple_request(
2432                         'CHECKOUT_RENEW',
2433                         [ ses(), params ],
2434                         async ? renew_callback : null,
2435                         {
2436                                 'title' : document.getElementById('circStrings').getString('staff.circ.checkin.renew_failed.override'),
2437                                 'overridable_events' : [
2438                     null /* custom event */,
2439                                         1212 /* PATRON_EXCEEDS_OVERDUE_COUNT */,
2440                                         1213 /* PATRON_BARRED */,
2441                                         1215 /* CIRC_EXCEEDS_COPY_RANGE */,
2442                     1232 /* ITEM_DEPOSIT_REQUIRED */,
2443                     1233 /* ITEM_RENTAL_FEE_REQUIRED */,
2444                                         1234 /* ITEM_DEPOSIT_PAID */,
2445                                         7002 /* PATRON_EXCEEDS_CHECKOUT_COUNT */,
2446                                         7003 /* COPY_CIRC_NOT_ALLOWED */,
2447                                         7004 /* COPY_NOT_AVAILABLE */,
2448                                         7006 /* COPY_IS_REFERENCE */,
2449                                         7007 /* COPY_NEEDED_FOR_HOLD */,
2450                                         7008 /* MAX_RENEWALS_REACHED */,
2451                                         7009 /* CIRC_CLAIMS_RETURNED */,
2452                                         7010 /* COPY_ALERT_MESSAGE */,
2453                                         7013 /* PATRON_EXCEEDS_FINES */,
2454                                 ],
2455                                 'text' : {
2456                                         '1212' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2457                                         '1213' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2458                                         '1215' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2459                     '1232' : function(r) {
2460                         return document.getElementById('circStrings').getFormattedString('staff.circ.renew.override.item_deposit_required.warning.barcode', [barcode]);
2461                     },
2462                     '1233' : function(r) {
2463                         return document.getElementById('circStrings').getFormattedString('staff.circ.renew.override.item_rental_fee_required.warning.barcode', [barcode]);
2464                     },
2465                                         '1234' : function(r) {
2466                                                 return document.getElementById('circStrings').getFormattedString('staff.circ.utils.checkin.override.item_deposit_paid.warning');
2467                                         },
2468                                         '7002' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2469                                         '7003' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2470                                         '7004' : function(r) {
2471                                                 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()]);
2472                                         },
2473                                         '7006' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2474                                         '7007' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2475                                         '7008' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2476                                         '7009' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2477                                         '7010' : function(r) {
2478                                                 return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode.msg', [barcode, r.payload]);
2479                                         },
2480                                         '7013' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); }
2481                                 }
2482                         }
2483                 );
2484                 if (! async ) {
2485                         return renew_callback( { 'getResultObject' : function() { return renew; } } );
2486                 }
2487
2488         } catch(E) {
2489                 JSAN.use('util.error'); var error = new util.error();
2490                 error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.renew_failed.error', [barcode]), E);
2491                 return null;
2492         }
2493 };
2494
2495 dump('exiting circ/util.js\n');