]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/xul/staff_client/server/circ/util.js
Eliminate lang.js (old i18n approach).
[Evergreen.git] / Open-ILS / xul / staff_client / server / circ / util.js
1 dump('entering circ/util.js\n');
2
3 if (typeof circ == 'undefined') var circ = {};
4 circ.util = {};
5
6 circ.util.EXPORT_OK     = [ 
7         'offline_checkout_columns', 'offline_checkin_columns', 'offline_renew_columns', 'offline_inhouse_use_columns', 
8         'columns', 'hold_columns', 'checkin_via_barcode', 'std_map_row_to_columns', 
9         'show_last_few_circs', 'abort_transits', 'transit_columns', 'renew_via_barcode',
10 ];
11 circ.util.EXPORT_TAGS   = { ':all' : circ.util.EXPORT_OK };
12
13 circ.util.abort_transits = function(selection_list) {
14         var obj = {};
15         JSAN.use('util.error'); obj.error = new util.error();
16         JSAN.use('util.network'); obj.network = new util.network();
17         JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
18         JSAN.use('util.functional');
19         var msg = 'Are you sure you would like to abort transits for copies:' + util.functional.map_list( selection_list, function(o){return o.copy_id;}).join(', ') + '?';
20         var r = obj.error.yns_alert(msg,'Aborting Transits','Yes','No',null,'Check here to confirm this action');
21         if (r == 0) {
22                 try {
23                         for (var i = 0; i < selection_list.length; i++) {
24                                 var copy_id = selection_list[i].copy_id;
25                                 var robj = obj.network.simple_request('FM_ATC_VOID',[ ses(), { 'copyid' : copy_id } ]);
26                                 if (typeof robj.ilsevent != 'undefined') {
27                                         switch(robj.ilsevent) {
28                                                 case 1225 /* TRANSIT_ABORT_NOT_ALLOWED */ :
29                                                         alert('Copy Id = ' + copy_id + '\n' + robj.desc);
30                                                 break;
31                                                 case 1504 /* ACTION_TRANSIT_COPY_NOT_FOUND */ :
32                                                         alert('This item was no longer in transit at the time of the abort.  Perhaps this happened from a stale display?');
33                                                 break;
34                                                 case 5000 /* PERM_FAILURE */ :
35                                                 break;
36                                                 default:
37                                                         throw(robj);
38                                                 break;
39                                         }
40                                 }
41                         }
42                 } catch(E) {
43                         obj.error.standard_unexpected_error_alert('Transit not likely aborted.',E);
44                 }
45         }
46 }
47
48 circ.util.show_copy_details = function(copy_id) {
49         var obj = {};
50         JSAN.use('util.error'); obj.error = new util.error();
51         JSAN.use('util.window'); obj.win = new util.window();
52         JSAN.use('util.network'); obj.network = new util.network();
53         JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
54
55         if (typeof copy_id == 'object' && copy_id != null) copy_id = copy_id.id();
56
57         try {
58                 var url = xulG.url_prefix( urls.XUL_COPY_DETAILS ); // + '?copy_id=' + copy_id;
59                 var my_xulG = obj.win.open( url, 'show_copy_details', 'chrome,resizable,modal', { 'copy_id' : copy_id } );
60
61                 if (typeof my_xulG.retrieve_these_patrons == 'undefined') return;
62                 var patrons = my_xulG.retrieve_these_patrons;
63                 for (var j = 0; j < patrons.length; j++) {
64                         if (typeof window.xulG == 'object' && typeof window.xulG.new_tab == 'function') {
65                                 try {
66                                         var url = urls.XUL_PATRON_DISPLAY; // + '?id=' + window.escape( patrons[j] );
67                                         window.xulG.new_tab( url, {}, { 'id' : patrons[j] } );
68                                 } catch(E) {
69                                         obj.error.standard_unexpected_error_alert('Problem retrieving patron.',E);
70                                 }
71                         }
72                 }
73
74         } catch(E) {
75                 obj.error.standard_unexpected_error_alert('Problem retrieving copy details.',E);
76         }
77 }
78
79
80 circ.util.show_last_few_circs = function(selection_list,count) {
81         var obj = {};
82         JSAN.use('util.error'); obj.error = new util.error();
83         JSAN.use('util.window'); obj.win = new util.window();
84         JSAN.use('util.network'); obj.network = new util.network();
85         JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
86
87         if (!count) count = 4;
88
89         for (var i = 0; i < selection_list.length; i++) {
90                 try {
91                         if (typeof selection_list[i].copy_id == 'undefined' || selection_list[i].copy_id == null) continue;
92                         var url = xulG.url_prefix( urls.XUL_CIRC_SUMMARY ); // + '?copy_id=' + selection_list[i].copy_id + '&count=' + count;
93                         var my_xulG = obj.win.open( url, 'show_last_few_circs', 'chrome,resizable,modal', { 'copy_id' : selection_list[i].copy_id, 'count' : count } );
94
95                         if (typeof my_xulG.retrieve_these_patrons == 'undefined') continue;
96                         var patrons = my_xulG.retrieve_these_patrons;
97                         for (var j = 0; j < patrons.length; j++) {
98                                 if (typeof window.xulG == 'object' && typeof window.xulG.new_tab == 'function') {
99                                         try {
100                                                 var url = urls.XUL_PATRON_DISPLAY; // + '?id=' + window.escape( patrons[j] );
101                                                 window.xulG.new_tab( url, {}, { 'id' : patrons[j] } );
102                                         } catch(E) {
103                                                 obj.error.standard_unexpected_error_alert('Problem retrieving patron.',E);
104                                         }
105                                 }
106                         }
107
108                 } catch(E) {
109                         obj.error.standard_unexpected_error_alert('Problem retrieving circulations.',E);
110                 }
111         }
112 }
113
114 circ.util.offline_checkout_columns = function(modify,params) {
115         
116         var c = [
117                 { 
118                         'id' : 'timestamp', 
119                         'label' : 'Timestamp', 
120                         'flex' : 1, 'primary' : false, 'hidden' : true, 
121                         'render' : function(my) { return my.timestamp; },
122                 },
123                 { 
124                         'id' : 'checkout_time', 
125                         'label' : 'Check Out Time', 
126                         'flex' : 1, 'primary' : false, 'hidden' : true, 
127                         'render' : function(my) { return my.checkout_time; },
128                 },
129                 { 
130                         'id' : 'type', 
131                         'label' : 'Transaction Type', 
132                         'flex' : 1, 'primary' : false, 'hidden' : true, 
133                         'render' : function(my) { return my.type; }, 
134                 },
135                 {
136                         'id' : 'noncat',
137                         'label' : 'Non-Cataloged?',
138                         'flex' : 1, 'primary' : false, 'hidden' : true, 
139                         'render' : function(my) { return my.noncat; },
140                 },
141                 {
142                         'id' : 'noncat_type',
143                         'label' : 'Non-Cat Type ID',
144                         'flex' : 1, 'primary' : false, 'hidden' : true,
145                         'render' : function(my) { return my.noncat_type; },
146                 },
147                 {
148                         'id' : 'noncat_count',
149                         'label' : 'Count', 'sort_type' : 'number',
150                         'flex' : 1, 'primary' : false, 'hidden' : false,
151                         'render' : function(my) { return my.noncat_count; },
152                 },
153                 { 
154                         'id' : 'patron_barcode', 
155                         'label' : 'Patron Barcode', 
156                         'flex' : 1, 'primary' : false, 'hidden' : true, 
157                         'render' : function(my) { return my.patron_barcode; },
158                 },
159                 { 
160                         'id' : 'barcode', 
161                         'label' : 'Item Barcode', 
162                         'flex' : 2, 'primary' : true, 'hidden' : false, 
163                         'render' : function(my) { return my.barcode; },
164                 },
165                 { 
166                         'id' : 'due_date', 
167                         'label' : 'Due Date', 
168                         'flex' : 1, 'primary' : false, 'hidden' : false, 
169                         'render' : function(my) { return my.due_date; },
170                 },
171         ];
172         if (modify) for (var i = 0; i < c.length; i++) {
173                 if (modify[ c[i].id ]) {
174                         for (var j in modify[ c[i].id ]) {
175                                 c[i][j] = modify[ c[i].id ][j];
176                         }
177                 }
178         }
179         if (params) {
180                 if (params.just_these) {
181                         JSAN.use('util.functional');
182                         var new_c = [];
183                         for (var i = 0; i < params.just_these.length; i++) {
184                                 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
185                                 new_c.push( function(y){ return y; }( x ) );
186                         }
187                         c = new_c;
188                 }
189                 if (params.except_these) {
190                         JSAN.use('util.functional');
191                         var new_c = [];
192                         for (var i = 0; i < c.length; i++) {
193                                 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
194                                 if (!x) new_c.push(c[i]);
195                         }
196                         c = new_c;
197                 }
198
199         }
200         return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
201 }
202
203 circ.util.offline_checkin_columns = function(modify,params) {
204         
205         var c = [
206                 { 
207                         'id' : 'timestamp', 
208                         'label' : 'Timestamp', 
209                         'flex' : 1, 'primary' : false, 'hidden' : true, 
210                         'render' : function(my) { return my.timestamp; },
211                 },
212                 { 
213                         'id' : 'backdate', 
214                         'label' : 'Back Date', 
215                         'flex' : 1, 'primary' : false, 'hidden' : true, 
216                         'render' : function(my) { return my.backdate; },
217                 },
218                 { 
219                         'id' : 'type', 
220                         'label' : 'Transaction Type', 
221                         'flex' : 1, 'primary' : false, 'hidden' : true, 
222                         'render' : function(my) { return my.type; },
223                 },
224                 { 
225                         'id' : 'barcode', 
226                         'label' : 'Item Barcode', 
227                         'flex' : 2, 'primary' : true, 'hidden' : false, 
228                         'render' : function(my) { return my.barcode; },
229                 },
230         ];
231         if (modify) for (var i = 0; i < c.length; i++) {
232                 if (modify[ c[i].id ]) {
233                         for (var j in modify[ c[i].id ]) {
234                                 c[i][j] = modify[ c[i].id ][j];
235                         }
236                 }
237         }
238         if (params) {
239                 if (params.just_these) {
240                         JSAN.use('util.functional');
241                         var new_c = [];
242                         for (var i = 0; i < params.just_these.length; i++) {
243                                 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
244                                 new_c.push( function(y){ return y; }( x ) );
245                         }
246                         c = new_c;
247                 }
248                 if (params.except_these) {
249                         JSAN.use('util.functional');
250                         var new_c = [];
251                         for (var i = 0; i < c.length; i++) {
252                                 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
253                                 if (!x) new_c.push(c[i]);
254                         }
255                         c = new_c;
256                 }
257
258         }
259         return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
260 }
261
262 circ.util.offline_renew_columns = function(modify,params) {
263         
264         var c = [
265                 { 
266                         'id' : 'timestamp', 
267                         'label' : 'Timestamp', 
268                         'flex' : 1, 'primary' : false, 'hidden' : true, 
269                         'render' : function(my) { return my.timestamp; },
270                 },
271                 { 
272                         'id' : 'checkout_time', 
273                         'label' : 'Check Out Time', 
274                         'flex' : 1, 'primary' : false, 'hidden' : true, 
275                         'render' : function(my) { return my.checkout_time; },
276                 },
277                 { 
278                         'id' : 'type', 
279                         'label' : 'Transaction Type', 
280                         'flex' : 1, 'primary' : false, 'hidden' : true, 
281                         'render' : function(my) { return my.type; },
282                 },
283                 { 
284                         'id' : 'patron_barcode', 
285                         'label' : 'Patron Barcode', 
286                         'flex' : 1, 'primary' : false, 'hidden' : true, 
287                         'render' : function(my) { return my.patron_barcode; },
288                 },
289                 { 
290                         'id' : 'barcode', 
291                         'label' : 'Item Barcode', 
292                         'flex' : 2, 'primary' : true, 'hidden' : false, 
293                         'render' : function(my) { return my.barcode; },
294                 },
295                 { 
296                         'id' : 'due_date', 
297                         'label' : 'Due Date', 
298                         'flex' : 1, 'primary' : false, 'hidden' : false, 
299                         'render' : function(my) { return my.due_date; },
300                 },
301         ];
302         if (modify) for (var i = 0; i < c.length; i++) {
303                 if (modify[ c[i].id ]) {
304                         for (var j in modify[ c[i].id ]) {
305                                 c[i][j] = modify[ c[i].id ][j];
306                         }
307                 }
308         }
309         if (params) {
310                 if (params.just_these) {
311                         JSAN.use('util.functional');
312                         var new_c = [];
313                         for (var i = 0; i < params.just_these.length; i++) {
314                                 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
315                                 new_c.push( function(y){ return y; }( x ) );
316                         }
317                         c = new_c;
318                 }
319                 if (params.except_these) {
320                         JSAN.use('util.functional');
321                         var new_c = [];
322                         for (var i = 0; i < c.length; i++) {
323                                 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
324                                 if (!x) new_c.push(c[i]);
325                         }
326                         c = new_c;
327                 }
328
329         }
330         return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
331 }
332
333 circ.util.offline_inhouse_use_columns = function(modify,params) {
334         
335         var c = [
336                 { 
337                         'id' : 'timestamp', 
338                         'label' : 'Timestamp', 
339                         'flex' : 1, 'primary' : false, 'hidden' : true, 
340                         'render' : function(my) { return my.timestamp; },
341                 },
342                 { 
343                         'id' : 'use_time', 
344                         'label' : 'Use Time', 
345                         'flex' : 1, 'primary' : false, 'hidden' : true, 
346                         'render' : function(my) { return my.use_time; },
347                 },
348                 { 
349                         'id' : 'type', 
350                         'label' : 'Transaction Type', 
351                         'flex' : 1, 'primary' : false, 'hidden' : true, 
352                         'render' : function(my) { return my.type; },
353                 },
354                 {
355                         'id' : 'count',
356                         'label' : 'Count', 'sort_type' : 'number',
357                         'flex' : 1, 'primary' : false, 'hidden' : false,
358                         'render' : function(my) { return my.count; },
359                 },
360                 { 
361                         'id' : 'barcode', 
362                         'label' : 'Item Barcode', 
363                         'flex' : 2, 'primary' : true, 'hidden' : false, 
364                         'render' : function(my) { return my.barcode; },
365                 },
366         ];
367         if (modify) for (var i = 0; i < c.length; i++) {
368                 if (modify[ c[i].id ]) {
369                         for (var j in modify[ c[i].id ]) {
370                                 c[i][j] = modify[ c[i].id ][j];
371                         }
372                 }
373         }
374         if (params) {
375                 if (params.just_these) {
376                         JSAN.use('util.functional');
377                         var new_c = [];
378                         for (var i = 0; i < params.just_these.length; i++) {
379                                 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
380                                 new_c.push( function(y){ return y; }( x ) );
381                         }
382                         c = new_c;
383                 }
384                 if (params.except_these) {
385                         JSAN.use('util.functional');
386                         var new_c = [];
387                         for (var i = 0; i < c.length; i++) {
388                                 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
389                                 if (!x) new_c.push(c[i]);
390                         }
391                         c = new_c;
392                 }
393
394         }
395         return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
396 }
397
398
399
400 circ.util.columns = function(modify,params) {
401         
402         JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
403         JSAN.use('util.network'); var network = new util.network();
404         JSAN.use('util.money');
405
406         var c = [
407                 {
408                         'id' : 'acp_id', 'label' : document.getElementById('commonStrings').getString('staff.acp_label_id'), 'flex' : 1,
409                         'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acp.id(); }, 'persist' : 'hidden width ordinal',
410                 },
411                 {
412                         'id' : 'circ_id', 'label' : document.getElementById('commonStrings').getString('staff.circ_label_id'), 'flex' : 1,
413                         'primary' : false, 'hidden' : true, 'render' : function(my) { return my.circ ? my.circ.id() : ( my.acp.circulations() ? my.acp.circulations()[0].id() : ""); },
414                         'persist' : 'hidden width ordinal',
415                 },
416                 {
417                         'id' : 'mvr_doc_id', 'label' : document.getElementById('commonStrings').getString('staff.mvr_label_doc_id'), 'flex' : 1,
418                         'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr.doc_id(); },
419                         'persist' : 'hidden width ordinal',
420                 },
421         {
422                         'persist' : 'hidden width ordinal', 'id' : 'service', 'label' : 'Service', 'flex' : 1,
423                         'primary' : false, 'hidden' : true, 'render' : function(my) { return my.service; },
424         },
425                 {
426                         'id' : 'barcode', 'label' : document.getElementById('commonStrings').getString('staff.acp_label_barcode'), 'flex' : 1,
427                         'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acp.barcode(); },
428                         'persist' : 'hidden width ordinal',
429                 },
430                 {
431                         'id' : 'call_number', 'label' : document.getElementById('commonStrings').getString('staff.acp_label_call_number'), 'flex' : 1,
432                         'primary' : false, 'hidden' : true, 'render' : function(my) { if (my.acp && my.acp.call_number() == -1) { return "Not Cataloged"; } else { if (!my.acn) { var x = network.simple_request("FM_ACN_RETRIEVE",[ my.acp.call_number() ]); if (x.ilsevent) { return "Not Cataloged"; } else { my.acn = x; return x.label(); } } else { return my.acn.label(); } } },
433                         'persist' : 'hidden width ordinal',
434                 },
435                 {
436                         'id' : 'owning_lib', 'label' : 'Owning Lib', 'flex' : 1,
437                         'primary' : false, 'hidden' : true,
438                         'render' : function(my) { if (Number(my.acn.owning_lib())>=0) { return data.hash.aou[ my.acn.owning_lib() ].shortname(); } else { return my.acn.owning_lib().shortname(); } }, 
439                         'persist' : 'hidden width ordinal',
440                 },
441                 {
442                         'id' : 'copy_number', 'label' : document.getElementById('commonStrings').getString('staff.acp_label_copy_number'), 'flex' : 1, 'sort_type' : 'number',
443                         'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acp.copy_number(); },
444                         'persist' : 'hidden width ordinal',
445                 },
446                 {
447                         'id' : 'location', 'label' : document.getElementById('commonStrings').getString('staff.acp_label_location'), 'flex' : 1,
448                         'primary' : false, 'hidden' : true, 'render' : function(my) { if (Number(my.acp.location())>=0) return data.lookup("acpl", my.acp.location() ).name(); else return my.acp.location().name(); },
449                         'persist' : 'hidden width ordinal',
450                 },
451                 {
452                         'id' : 'loan_duration', 'label' : document.getElementById('commonStrings').getString('staff.acp_label_loan_duration'), 'flex' : 1,
453                         'primary' : false, 'hidden' : true, 
454                         'render' : function(my) { switch(my.acp.loan_duration()){ case 1: return "Short"; break; case 2: return "Normal"; break; case 3: return "Long"; break; }; },
455                         'persist' : 'hidden width ordinal',
456                 },
457                 {
458                         'id' : 'circ_lib', 'label' : document.getElementById('commonStrings').getString('staff.acp_label_circ_lib'), 'flex' : 1,
459                         'primary' : false, 'hidden' : true, 'render' : function(my) { if (Number(my.acp.circ_lib())>=0) return data.hash.aou[ my.acp.circ_lib() ].shortname(); else return my.acp.circ_lib().shortname(); },
460                         'persist' : 'hidden width ordinal',
461                 },
462                 {
463                         'id' : 'fine_level', 'label' : document.getElementById('commonStrings').getString('staff.acp_label_fine_level'), 'flex' : 1,
464                         'primary' : false, 'hidden' : true,
465                         'render' : function(my) { switch(my.acp.fine_level()){ case 1: return "Low"; break; case 2: return "Normal"; break; case 3: return "High"; break; }; },
466                         'persist' : 'hidden width ordinal',
467                 },
468                 {
469                         'id' : 'circulate', 'label' : 'Circulate?', 'flex' : 1,
470                         'primary' : false, 'hidden' : true, 'render' : function(my) { return get_bool( my.acp.circulate() ) ? "Yes" : "No"; },
471                         'persist' : 'hidden width ordinal',
472                 },
473                 {
474                         'id' : 'deleted', 'label' : 'Deleted?', 'flex' : 1,
475                         'primary' : false, 'hidden' : true, 'render' : function(my) { return get_bool( my.acp.deleted() ) ? "Yes" : "No"; },
476                         'persist' : 'hidden width ordinal',
477                 },
478                 {
479                         'id' : 'holdable', 'label' : 'Holdable?', 'flex' : 1,
480                         'primary' : false, 'hidden' : true, 'render' : function(my) { return get_bool( my.acp.holdable() ) ? "Yes" : "No"; },
481                         'persist' : 'hidden width ordinal',
482                 },
483                 {
484                         'id' : 'opac_visible', 'label' : 'OPAC Visible?', 'flex' : 1,
485                         'primary' : false, 'hidden' : true, 'render' : function(my) { return get_bool( my.acp.opac_visible() ) ? "Yes" : "No"; },
486                         'persist' : 'hidden width ordinal',
487                 },
488                 {
489                         'persist' : 'hidden width ordinal', 'id' : 'ref', 'label' : 'Reference?', 'flex' : 1,
490                         'primary' : false, 'hidden' : true, 'render' : function(my) { return get_bool( my.acp.ref() ) ? "Yes" : "No"; },
491                 },
492                 {
493                         'persist' : 'hidden width ordinal', 'id' : 'deposit', 'label' : 'Deposit?', 'flex' : 1,
494                         'primary' : false, 'hidden' : true, 'render' : function(my) { return get_bool( my.acp.deposit() ) ? "Yes" : "No"; },
495                 },
496                 {
497                         'persist' : 'hidden width ordinal', 'id' : 'deposit_amount', 'label' : document.getElementById('commonStrings').getString('staff.acp_label_deposit_amount'), 'flex' : 1,
498                         'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acp.price() == null ? "<Unset>" : util.money.sanitize(my.acp.deposit_amount()); }, 'sort_type' : 'money',
499                 },
500                 {
501                         'persist' : 'hidden width ordinal', 'id' : 'price', 'label' : document.getElementById('commonStrings').getString('staff.acp_label_price'), 'flex' : 1,
502                         'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acp.price() == null ? "<Unset>" : util.money.sanitize(my.acp.price()); }, 'sort_type' : 'money',
503                 },
504                 {
505                         'persist' : 'hidden width ordinal', 'id' : 'circ_as_type', 'label' : document.getElementById('commonStrings').getString('staff.acp_label_circ_as_type'), 'flex' : 1,
506                         'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acp.circ_as_type(); },
507                 },
508                 {
509                         'persist' : 'hidden width ordinal', 'id' : 'circ_modifier', 'label' : document.getElementById('commonStrings').getString('staff.acp_label_circ_modifier'), 'flex' : 1,
510                         'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acp.circ_modifier(); },
511                 },
512                 {
513                         'persist' : 'hidden width ordinal', 'id' : 'checkout_lib', 'label' : 'Checkout Lib', 'flex' : 1,
514                         'primary' : false, 'hidden' : true, 'render' : function(my) { return my.circ ? data.hash.aou[ my.circ.circ_lib() ].shortname() : ( my.acp.circulations() ? data.hash.aou[ my.acp.circulations()[0].circ_lib() ].shortname() : ""); },
515                 },
516                 {
517                         'persist' : 'hidden width ordinal', 'id' : 'xact_start_full', 'label' : 'Checkout Timestamp', 'flex' : 1,
518                         'primary' : false, 'hidden' : true, 'render' : function(my) { return my.circ ? my.circ.xact_start() : (my.acp.circulations() ? my.acp.circulations()[0].xact_start() : ""); },
519                 },
520                 {
521                         'persist' : 'hidden width ordinal', 'id' : 'checkin_time_full', 'label' : 'Checkin Timestamp', 'flex' : 1,
522                         'primary' : false, 'hidden' : true, 'render' : function(my) { return my.circ ? my.circ.checkin_time() : (my.acp.circulations() ? my.acp.circulations()[0].checkin_time() : ""); },
523                 },
524                 {
525                         'persist' : 'hidden width ordinal', 'id' : 'xact_start', 'label' : 'Checkout Date', 'flex' : 1,
526                         'primary' : false, 'hidden' : true, 'render' : function(my) { return my.circ ? my.circ.xact_start().substr(0,10) : (my.acp.circulations() ? my.acp.circulations()[0].xact_start().substr(0,10) : ""); },
527                 },
528                 {
529                         'persist' : 'hidden width ordinal', 'id' : 'checkin_time', 'label' : 'Checkin Date', 'flex' : 1,
530                         'primary' : false, 'hidden' : true, 'render' : function(my) { return my.circ ? my.circ.checkin_time().substr(0,10) : (my.acp.circulations() ? my.acp.circulations()[0].checkin_time().substr(0,10) : ""); },
531                 },
532
533                 {
534                         'persist' : 'hidden width ordinal', 'id' : 'xact_finish', 'label' : 'Transaction Finished', 'flex' : 1,
535                         'primary' : false, 'hidden' : true, 'render' : function(my) { return my.circ.xact_finish(); },
536                 },
537                 {
538                         'persist' : 'hidden width ordinal', 'id' : 'due_date', 'label' : document.getElementById('commonStrings').getString('staff.circ_label_due_date'), 'flex' : 1,
539                         'primary' : false, 'hidden' : true, 'render' : function(my) { return my.circ ? my.circ.due_date().substr(0,10) : (my.acp.circulations() ? my.acp.circulations()[0].due_date().substr(0,10) : ""); },
540                 },
541                 {
542                         'persist' : 'hidden width ordinal', 'id' : 'create_date', 'label' : 'Date Created', 'flex' : 1,
543                         'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acp.create_date().substr(0,10); },
544                 },
545                 {
546                         'persist' : 'hidden width ordinal', 'id' : 'edit_date', 'label' : 'Date Last Edited', 'flex' : 1,
547                         'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acp.edit_date().substr(0,10); },
548                 },
549                 {
550                         'persist' : 'hidden width ordinal', 'id' : 'title', 'label' : document.getElementById('commonStrings').getString('staff.mvr_label_title'), 'flex' : 2, 'sort_type' : 'title',
551                         'primary' : false, 'hidden' : true, 'render' : function(my) { try {  return my.mvr.title(); } catch(E) { return my.acp.dummy_title(); } }
552                 },
553                 {
554                         'persist' : 'hidden width ordinal', 'id' : 'author', 'label' : document.getElementById('commonStrings').getString('staff.mvr_label_author'), 'flex' : 1,
555                         'primary' : false, 'hidden' : true, 'render' : function(my) { try { return my.mvr.author(); } catch(E) { return my.acp.dummy_author(); } }
556                 },
557                 {
558                         'persist' : 'hidden width ordinal', 'id' : 'edition', 'label' : 'Edition', 'flex' : 1,
559                         'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr.edition(); },
560                 },
561                 {
562                         'persist' : 'hidden width ordinal', 'id' : 'isbn', 'label' : 'ISBN', 'flex' : 1,
563                         'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr.isbn(); },
564                 },
565                 {
566                         'persist' : 'hidden width ordinal', 'id' : 'pubdate', 'label' : 'PubDate', 'flex' : 1,
567                         'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr.pubdate(); },
568                 },
569                 {
570                         'persist' : 'hidden width ordinal', 'id' : 'publisher', 'label' : 'Publisher', 'flex' : 1,
571                         'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr.publisher(); },
572                 },
573                 {
574                         'persist' : 'hidden width ordinal', 'id' : 'tcn', 'label' : 'TCN', 'flex' : 1,
575                         'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr.tcn(); },
576                 },
577                 {
578                         'persist' : 'hidden width ordinal', 'id' : 'renewal_remaining', 'label' : document.getElementById('commonStrings').getString('staff.circ_label_renewal_remaining'), 'flex' : 0,
579                         'primary' : false, 'hidden' : true, 'render' : function(my) { return my.circ ? my.circ.renewal_remaining() : (my.acp.circulations() ? my.acp.circulations()[0].renewal_remaining() : ""); }, 'sort_type' : 'number',
580                 },
581                 {
582                         'persist' : 'hidden width ordinal', 'id' : 'stop_fines', 'label' : 'Fines Stopped', 'flex' : 0,
583                         'primary' : false, 'hidden' : true, 'render' : function(my) { return my.circ ? my.circ.stop_fines() : (my.acp.circulations() ? my.acp.circulations()[0].stop_fines() : ""); },
584                 },
585                 {
586                         'persist' : 'hidden width ordinal', 'id' : 'stop_fines_time', 'label' : 'Fines Stopped Time', 'flex' : 0,
587                         'primary' : false, 'hidden' : true, 'render' : function(my) { return my.circ ? my.circ.stop_fines_time() : (my.acp.circulations() ? my.acp.circulations()[0].stop_fines_time() : ""); },
588                 },
589                 {
590                         'persist' : 'hidden width ordinal', 'id' : 'status', 'label' : document.getElementById('commonStrings').getString('staff.acp_label_status'), 'flex' : 1,
591                         'primary' : false, 'hidden' : true, 'render' : function(my) { if (Number(my.acp.status())>=0) return data.hash.ccs[ my.acp.status() ].name(); else return my.acp.status().name(); },
592                 },
593                 {
594                         'persist' : 'hidden width ordinal', 'id' : 'route_to', 'label' : 'Route To', 'flex' : 1,
595                         'primary' : false, 'hidden' : true, 'render' : function(my) { return my.route_to.toString(); },
596                 },
597                 {
598                         'persist' : 'hidden width ordinal', 'id' : 'message', 'label' : 'Message', 'flex' : 1,
599                         'primary' : false, 'hidden' : true, 'render' : function(my) { return my.message.toString(); },
600                 },
601                 {
602                         'persist' : 'hidden width ordinal', 'id' : 'uses', 'label' : '# of Uses', 'flex' : 1,
603                         'primary' : false, 'hidden' : true, 'render' : function(my) { return my.uses; }, 'sort_type' : 'number',
604                 },
605                 {
606                         'persist' : 'hidden width ordinal', 'id' : 'alert_message', 'label' : 'Alert Message', 'flex' : 1,
607                         'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acp.alert_message(); },
608                 }
609         ];
610         for (var i = 0; i < c.length; i++) {
611                 if (modify[ c[i].id ]) {
612                         for (var j in modify[ c[i].id ]) {
613                                 c[i][j] = modify[ c[i].id ][j];
614                         }
615                 }
616         }
617         if (params) {
618                 if (params.just_these) {
619                         JSAN.use('util.functional');
620                         var new_c = [];
621                         for (var i = 0; i < params.just_these.length; i++) {
622                                 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
623                                 new_c.push( function(y){ return y; }( x ) );
624                         }
625                         c = new_c;
626                 }
627                 if (params.except_these) {
628                         JSAN.use('util.functional');
629                         var new_c = [];
630                         for (var i = 0; i < c.length; i++) {
631                                 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
632                                 if (!x) new_c.push(c[i]);
633                         }
634                         c = new_c;
635                 }
636         }
637         return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
638 }
639
640 circ.util.transit_columns = function(modify,params) {
641         
642         JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
643
644         var c = [
645                 {
646                         'persist' : 'hidden width ordinal', 'id' : 'transit_item_barcode', 'label' : 'Barcode', 'flex' : 1,
647                         'primary' : false, 'hidden' : true,  'render' : function(my) { return my.acp.barcode(); },
648                 },
649                 {
650                         'persist' : 'hidden width ordinal', 'id' : 'transit_item_title', 'label' : 'Title', 'flex' : 1,
651                         'primary' : false, 'hidden' : true,  'render' : function(my) { try { return my.mvr.title(); } catch(E) { return my.acp.dummy_title(); } },
652                 },
653                 {
654                         'persist' : 'hidden width ordinal', 'id' : 'transit_item_author', 'label' : 'Author', 'flex' : 1,
655                         'primary' : false, 'hidden' : true,  'render' : function(my) { try { return my.mvr.author(); } catch(E) { return my.acp.dummy_author(); } },
656                 },
657                 {
658                         'persist' : 'hidden width ordinal', 'id' : 'transit_item_callnumber', 'label' : 'Call Number', 'flex' : 1,
659                         'primary' : false, 'hidden' : true,  'render' : function(my) { return my.acn.label(); },
660                 },
661                 {
662                         'persist' : 'hidden width ordinal', 'id' : 'transit_id', 'label' : 'Transit ID', 'flex' : 1,
663                         'primary' : false, 'hidden' : true,  'render' : function(my) { return my.atc.id(); },
664                 },
665                 {
666                         'persist' : 'hidden width ordinal', 'id' : 'transit_source', 'label' : 'Transit Source', 'flex' : 1,
667                         'primary' : false, 'hidden' : false, 'render' : function(my) { return typeof my.atc.source() == "object" ? my.atc.source().shortname() : data.hash.aou[ my.atc.source() ].shortname(); },
668                 },
669                 {
670                         'persist' : 'hidden width ordinal', 'id' : 'transit_source_send_time', 'label' : 'Transitted On', 'flex' : 1,
671                         'primary' : false, 'hidden' : false, 'render' : function(my) { return my.atc.source_send_time(); },
672                 },
673                 {
674                         'persist' : 'hidden width ordinal', 'id' : 'transit_dest_lib', 'label' : 'Transit Destination', 'flex' : 1,
675                         'primary' : false, 'hidden' : false, 'render' : function(my) { return typeof my.atc.dest() == "object" ? my.atc.dest().shortname() : data.hash.aou[ my.atc.dest() ].shortname(); },
676                 },
677                 {
678                         'persist' : 'hidden width ordinal', 'id' : 'transit_dest_recv_time', 'label' : 'Transit Completed On', 'flex' : 1,
679                         'primary' : false, 'hidden' : false, 'render' : function(my) { return my.atc.dest_recv_time(); },
680                 },
681                 {
682                         'persist' : 'hidden width ordinal', 'id' : 'transit_target_copy', 'label' : 'Transit Copy ID', 'flex' : 1,
683                         'primary' : false, 'hidden' : true, 'render' : function(my) { return my.atc.target_copy(); },
684                 },
685         ];
686         for (var i = 0; i < c.length; i++) {
687                 if (modify[ c[i].id ]) {
688                         for (var j in modify[ c[i].id ]) {
689                                 c[i][j] = modify[ c[i].id ][j];
690                         }
691                 }
692         }
693         if (params) {
694                 if (params.just_these) {
695                         JSAN.use('util.functional');
696                         var new_c = [];
697                         for (var i = 0; i < params.just_these.length; i++) {
698                                 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
699                                 new_c.push( function(y){ return y; }( x ) );
700                         }
701                         c = new_c;
702                 }
703                 if (params.except_these) {
704                         JSAN.use('util.functional');
705                         var new_c = [];
706                         for (var i = 0; i < c.length; i++) {
707                                 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
708                                 if (!x) new_c.push(c[i]);
709                         }
710                         c = new_c;
711                 }
712
713         }
714         return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
715 }
716
717
718 circ.util.hold_columns = function(modify,params) {
719         
720         JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
721
722         var c = [
723                 {
724                         'persist' : 'hidden width ordinal', 'id' : 'request_lib', 'label' : 'Request Lib (Full Name)', 'flex' : 1,
725                         'primary' : false, 'hidden' : true,  
726                         'render' : function(my) { if (Number(my.ahr.request_lib())>=0) return data.hash.aou[ my.ahr.request_lib() ].name(); else return my.ahr.request_lib().name(); },
727                 },
728                 {
729                         'persist' : 'hidden width ordinal', 'id' : 'request_lib_shortname', 'label' : 'Request Lib', 'flex' : 0,
730                         'primary' : false, 'hidden' : true,  
731                         'render' : function(my) { if (Number(my.ahr.request_lib())>=0) return data.hash.aou[ my.ahr.request_lib() ].shortname(); else return my.ahr.request_lib().shortname(); },
732                 },
733
734                 {
735                         'persist' : 'hidden width ordinal', 'id' : 'request_timestamp', 'label' : 'Request Timestamp', 'flex' : 0,
736                         'primary' : false, 'hidden' : true,  
737                         'render' : function(my) { return my.ahr.request_time().toString(); },
738                 },
739                 {
740                         'persist' : 'hidden width ordinal', 'id' : 'request_time', 'label' : 'Request Date', 'flex' : 0,
741                         'primary' : false, 'hidden' : true,  
742                         'render' : function(my) { return my.ahr.request_time().toString().substr(0,10); },
743                 },
744                 {
745                         'persist' : 'hidden width ordinal', 'id' : 'available_timestamp', 'label' : 'Available On (Timestamp)', 'flex' : 1,
746                         'primary' : false, 'hidden' : true,  'render' : function(my) { return my.ahr.transit() ? ( my.ahr.transit().dest_recv_time() ? my.ahr.transit().dest_recv_time().toString() : "") : ( my.ahr.capture_time() ? my.ahr.capture_time().toString() : "" ); },
747                 },
748                 {
749                         'persist' : 'hidden width ordinal', 'id' : 'available_time', 'label' : 'Available On', 'flex' : 1,
750                         'primary' : false, 'hidden' : false,  'render' : function(my) { return my.ahr.transit() ? ( my.ahr.transit().dest_recv_time() ? my.ahr.transit().dest_recv_time().toString().substr(0,10) : "") : ( my.ahr.capture_time() ? my.ahr.capture_time().toString().substr(0,10) : "" ); },
751                 },
752                 {
753                         'persist' : 'hidden width ordinal', 'id' : 'capture_timestamp', 'label' : 'Capture Timestamp', 'flex' : 1,
754                         'primary' : false, 'hidden' : true,  'render' : function(my) { return my.ahr.capture_time() ? my.ahr.capture_time().toString() : ""; },
755                 },
756                 {
757                         'persist' : 'hidden width ordinal', 'id' : 'capture_time', 'label' : 'Capture Date', 'flex' : 1,
758                         'primary' : false, 'hidden' : true,  'render' : function(my) { return my.ahr.capture_time() ? my.ahr.capture_time().toString().substr(0,10) : ""; },
759                 },
760                 {
761                         'persist' : 'hidden width ordinal', 'id' : 'status', 'label' : document.getElementById('commonStrings').getString('staff.ahr_status_label'), 'flex' : 1,
762                         'primary' : false, 'hidden' : false,  'render' : function(my) { switch(my.status) { case 1: case "1": return "Waiting for copy"; break; case 2: case "2": return "Waiting for capture"; break; case 3: case "3": return "In-Transit"; break; case 4: case "4" : return "Ready for pickup"; break; default: return my.status; break;}; },
763                 },
764                 {
765                         'persist' : 'hidden width ordinal', 'id' : 'hold_type', 'label' : document.getElementById('commonStrings').getString('staff.ahr_hold_type_label'), 'flex' : 0,
766                         'primary' : false, 'hidden' : true,  'render' : function(my) { return my.ahr.hold_type(); },
767                 },
768         {
769                         'persist' : 'hidden width ordinal', 'id' : 'frozen', 'label' : 'Frozen?', 'flex' : 0,
770                         'primary' : false, 'hidden' : true,  'render' : function(my) { return get_bool( my.ahr.frozen() ) ? 'Yes' : 'No'; },
771         },
772         {
773                         'persist' : 'hidden width ordinal', 'id' : 'thaw_date', 'label' : 'Thaw Date', 'flex' : 0,
774                         'primary' : false, 'hidden' : true,  'render' : function(my) { return my.ahr.thaw_date() == null ? 'No Date' : my.ahr.thaw_date().substr(0,10); },
775         },
776                 {
777                         'persist' : 'hidden width ordinal', 'id' : 'pickup_lib', 'label' : 'Pickup Lib (Full Name)', 'flex' : 1,
778                         'primary' : false, 'hidden' : true,  
779                         'render' : function(my) { if (Number(my.ahr.pickup_lib())>=0) return data.hash.aou[ my.ahr.pickup_lib() ].name(); else return my.ahr.pickup_lib().name(); },
780                 },
781                 {
782                         'persist' : 'hidden width ordinal', 'id' : 'pickup_lib_shortname', 'label' : document.getElementById('commonStrings').getString('staff.ahr_pickup_lib_label'), 'flex' : 0,
783                         'primary' : false, 'hidden' : true,  
784                         'render' : function(my) { if (Number(my.ahr.pickup_lib())>=0) return data.hash.aou[ my.ahr.pickup_lib() ].shortname(); else return my.ahr.pickup_lib().shortname(); },
785                 },
786                 {
787                         'persist' : 'hidden width ordinal', 'id' : 'current_copy', 'label' : document.getElementById('commonStrings').getString('staff.ahr_current_copy_label'), 'flex' : 1,
788                         'primary' : false, 'hidden' : true,  'render' : function(my) { return my.acp ? my.acp.barcode() : "No Copy"; },
789                 },
790                 {
791                         'persist' : 'hidden width ordinal', 'id' : 'email_notify', 'label' : document.getElementById('commonStrings').getString('staff.ahr_email_notify_label'), 'flex' : 1,
792                         'primary' : false, 'hidden' : true,  'render' : function(my) { return get_bool(my.ahr.email_notify()) ? "Yes" : "No"; },
793                 },
794                 {
795                         'persist' : 'hidden width ordinal', 'id' : 'expire_time', 'label' : document.getElementById('commonStrings').getString('staff.ahr_expire_time_label'), 'flex' : 1,
796                         'primary' : false, 'hidden' : true,  'render' : function(my) { return my.ahr.expire_time(); },
797                 },
798                 {
799                         'persist' : 'hidden width ordinal', 'id' : 'fulfillment_time', 'label' : document.getElementById('commonStrings').getString('staff.ahr_fulfillment_time_label'), 'flex' : 1,
800                         'primary' : false, 'hidden' : true,  'render' : function(my) { return my.ahr.fulfillment_time(); },
801                 },
802                 {
803                         'persist' : 'hidden width ordinal', 'id' : 'holdable_formats', 'label' : document.getElementById('commonStrings').getString('staff.ahr_holdable_formats_label'), 'flex' : 1,
804                         'primary' : false, 'hidden' : true,  'render' : function(my) { return my.ahr.holdable_formats(); },
805                 },
806                 {
807                         'persist' : 'hidden width ordinal', 'id' : 'id', 'label' : document.getElementById('commonStrings').getString('staff.ahr_id_label'), 'flex' : 1,
808                         'primary' : false, 'hidden' : true,  'render' : function(my) { return my.ahr.id(); },
809                 },
810                 {
811                         'persist' : 'hidden width ordinal', 'id' : 'phone_notify', 'label' : document.getElementById('commonStrings').getString('staff.ahr_phone_notify_label'), 'flex' : 1,
812                         'primary' : false, 'hidden' : true,  'render' : function(my) { return my.ahr.phone_notify(); },
813                 },
814                 {
815                         'persist' : 'hidden width ordinal', 'id' : 'prev_check_time', 'label' : document.getElementById('commonStrings').getString('staff.ahr_prev_check_time_label'), 'flex' : 1,
816                         'primary' : false, 'hidden' : true,  'render' : function(my) { return my.ahr.prev_check_time(); },
817                 },
818                 {
819                         'persist' : 'hidden width ordinal', 'id' : 'requestor', 'label' : document.getElementById('commonStrings').getString('staff.ahr_requestor_label'), 'flex' : 1,
820                         'primary' : false, 'hidden' : true,  'render' : function(my) { return my.ahr.requestor(); },
821                 },
822                 {
823                         'persist' : 'hidden width ordinal', 'id' : 'selection_depth', 'label' : document.getElementById('commonStrings').getString('staff.ahr_selection_depth_label'), 'flex' : 1,
824                         'primary' : false, 'hidden' : true,  'render' : function(my) { return my.ahr.selection_depth(); },
825                 },
826                 {
827                         'persist' : 'hidden width ordinal', 'id' : 'target', 'label' : document.getElementById('commonStrings').getString('staff.ahr_target_label'), 'flex' : 1,
828                         'primary' : false, 'hidden' : true,  'render' : function(my) { return my.ahr.target(); },
829                 },
830                 {
831                         'persist' : 'hidden width ordinal', 'id' : 'usr', 'label' : document.getElementById('commonStrings').getString('staff.ahr_usr_label'), 'flex' : 1,
832                         'primary' : false, 'hidden' : true,  'render' : function(my) { return my.ahr.usr(); },
833                 },
834                 {
835                         'persist' : 'hidden width ordinal', 'id' : 'title', 'label' : document.getElementById('commonStrings').getString('staff.mvr_label_title'), 'flex' : 1, 'sort_type' : 'title',
836                         'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr ? my.mvr.title() : "No Title?"; },
837                 },
838                 {
839                         'persist' : 'hidden width ordinal', 'id' : 'author', 'label' : document.getElementById('commonStrings').getString('staff.mvr_label_author'), 'flex' : 1,
840                         'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr ? my.mvr.author() : "No Author?"; },
841                 },
842                 {
843                         'persist' : 'hidden width ordinal', 'id' : 'edition', 'label' : 'Edition', 'flex' : 1,
844                         'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr.edition(); },
845                 },
846                 {
847                         'persist' : 'hidden width ordinal', 'id' : 'isbn', 'label' : 'ISBN', 'flex' : 1,
848                         'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr.isbn(); },
849                 },
850                 {
851                         'persist' : 'hidden width ordinal', 'id' : 'pubdate', 'label' : 'PubDate', 'flex' : 1,
852                         'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr.pubdate(); },
853                 },
854                 {
855                         'persist' : 'hidden width ordinal', 'id' : 'publisher', 'label' : 'Publisher', 'flex' : 1,
856                         'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr.publisher(); },
857                 },
858                 {
859                         'persist' : 'hidden width ordinal', 'id' : 'tcn', 'label' : 'TCN', 'flex' : 1,
860                         'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr.tcn(); },
861                 },
862                 {
863                         'persist' : 'hidden width ordinal', 'id' : 'notify_time', 'label' : 'Last Notify Time', 'flex' : 1,
864                         'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.notify_time(); },
865                 },
866                 {
867                         'persist' : 'hidden width ordinal', 'id' : 'notify_count', 'label' : 'Notices', 'flex' : 1,
868                         'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.notify_count(); },
869                 },
870                 {
871                         'persist' : 'hidden width ordinal', 'id' : 'transit_source', 'label' : 'Transit Source', 'flex' : 1,
872                         'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.transit() ?  data.hash.aou[ my.ahr.transit().source() ].shortname() : ""; },
873                 },
874                 {
875                         'persist' : 'hidden width ordinal', 'id' : 'transit_source_send_time', 'label' : 'Transitted On', 'flex' : 1,
876                         'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.transit() ?  my.ahr.transit().source_send_time() : ""; },
877                 },
878                 {
879                         'persist' : 'hidden width ordinal', 'id' : 'transit_dest_lib', 'label' : 'Transit Destination', 'flex' : 1,
880                         'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.transit() ?  data.hash.aou[ my.ahr.transit().dest() ].shortname() : ""; },
881                 },
882                 {
883                         'persist' : 'hidden width ordinal', 'id' : 'transit_dest_recv_time', 'label' : 'Transit Completed On', 'flex' : 1,
884                         'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.transit() ?  my.ahr.transit().dest_recv_time() : ""; },
885                 },
886                 {
887                         'persist' : 'hidden width ordinal', 'id' : 'patron_barcode', 'label' : 'Patron Barcode', 'flex' : 1,
888                         'primary' : false, 'hidden' : true, 'render' : function(my) { return my.patron_barcode ? my.patron_barcode : ""; },
889                 },
890                 {
891                         'persist' : 'hidden width ordinal', 'id' : 'patron_family_name', 'label' : 'Patron Last Name', 'flex' : 1,
892                         'primary' : false, 'hidden' : true, 'render' : function(my) { return my.patron_family_name ? my.patron_family_name : ""; },
893                 },
894                 {
895                         'persist' : 'hidden width ordinal', 'id' : 'patron_first_given_name', 'label' : 'Patron First Name', 'flex' : 1,
896                         'primary' : false, 'hidden' : true, 'render' : function(my) { return my.patron_first_given_name ? my.patron_first_given_name : ""; },
897                 },
898                 {
899                         'persist' : 'hidden width ordinal', 'id' : 'callnumber', 'label' : 'Call Number', 'flex' : 1,
900                         'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acn.label(); },
901                 },
902         ];
903         for (var i = 0; i < c.length; i++) {
904                 if (modify[ c[i].id ]) {
905                         for (var j in modify[ c[i].id ]) {
906                                 c[i][j] = modify[ c[i].id ][j];
907                         }
908                 }
909         }
910         if (params) {
911                 if (params.just_these) {
912                         JSAN.use('util.functional');
913                         var new_c = [];
914                         for (var i = 0; i < params.just_these.length; i++) {
915                                 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
916                                 new_c.push( function(y){ return y; }( x ) );
917                         }
918                         c = new_c;
919                 }
920                 if (params.except_these) {
921                         JSAN.use('util.functional');
922                         var new_c = [];
923                         for (var i = 0; i < c.length; i++) {
924                                 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
925                                 if (!x) new_c.push(c[i]);
926                         }
927                         c = new_c;
928                 }
929
930         }
931         return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
932 }
933 /*
934 circ.util.std_map_row_to_column = function(error_value) {
935         return function(row,col) {
936                 // row contains { 'my' : { 'acp' : {}, 'circ' : {}, 'mvr' : {} } }
937                 // col contains one of the objects listed above in columns
938                 
939                 // mimicking some of the obj in circ.checkin and circ.checkout where map_row_to_column is usually defined
940                 var obj = {}; 
941                 JSAN.use('util.error'); obj.error = new util.error();
942                 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
943                 JSAN.use('util.network'); obj.network = new util.network();
944                 JSAN.use('util.money');
945
946                 var my = row.my;
947                 var value;
948                 try { 
949                         value = eval( col.render );
950                 } catch(E) {
951                         obj.error.sdump('D_WARN','map_row_to_column: ' + E);
952                         if (error_value) value = error_value; else value = '   ';
953                 }
954                 return value;
955         }
956 }
957 */
958 circ.util.std_map_row_to_columns = function(error_value) {
959         return function(row,cols) {
960                 // row contains { 'my' : { 'acp' : {}, 'circ' : {}, 'mvr' : {} } }
961                 // cols contains all of the objects listed above in columns
962                 
963                 var obj = {}; 
964                 JSAN.use('util.error'); obj.error = new util.error();
965                 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
966                 JSAN.use('util.network'); obj.network = new util.network();
967                 JSAN.use('util.money');
968
969                 var my = row.my;
970                 var values = [];
971                 var cmd = '';
972                 try { 
973                         for (var i = 0; i < cols.length; i++) {
974                                 switch (typeof cols[i].render) {
975                                         case 'function': try { values[i] = cols[i].render(my); } catch(E) { values[i] = error_value; dump(E+'\n'); } break;
976                                         case 'string' : cmd += 'try { ' + cols[i].render + '; values['+i+'] = v; } catch(E) { values['+i+'] = error_value; }'; break;
977                                         default: cmd += 'values['+i+'] = "??? '+(typeof cols[i].render)+'"; ';
978                                 }
979                         }
980                         if (cmd) eval( cmd );
981                 } catch(E) {
982                         obj.error.sdump('D_WARN','map_row_to_column: ' + E);
983                         if (error_value) { value = error_value; } else { value = '   ' };
984                 }
985                 return values;
986         }
987 }
988
989 circ.util.checkin_via_barcode = function(session,params,backdate,auto_print,async) {
990         try {
991                 JSAN.use('util.error'); var error = new util.error();
992                 JSAN.use('util.network'); var network = new util.network();
993                 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
994                 JSAN.use('util.date');
995
996                 if (backdate && (backdate == util.date.formatted_date(new Date(),'%Y-%m-%d')) ) backdate = null;
997
998                 //var params = { 'barcode' : barcode };
999                 if (backdate) params.backdate = util.date.formatted_date(backdate + ' 00:00:00','%{iso8601}');
1000
1001                 if (typeof async == 'object') {
1002                         try { async.disable_textbox(); } catch(E) { error.sdump('D_ERROR','async.disable_textbox() = ' + E); };
1003                 }
1004                 var check = network.request(
1005                         api.CHECKIN_VIA_BARCODE.app,
1006                         api.CHECKIN_VIA_BARCODE.method,
1007                         [ session, params ],
1008                         async ? function(req) { 
1009                                 try {
1010                                         var check = req.getResultObject();
1011                                         var r = circ.util.checkin_via_barcode2(session,params,backdate,auto_print,check); 
1012                                         if (typeof async == 'object') {
1013                                                 try { async.checkin_result(r); } catch(E) { error.sdump('D_ERROR','async.checkin_result() = ' + E); };
1014                                         }
1015                                 } catch(E) {
1016                                         JSAN.use('util.error'); var error = new util.error();
1017                                         error.standard_unexpected_error_alert('Check In Failed (in circ.util.checkin): ',E);
1018                                         if (typeof async == 'object') {
1019                                                 try { async.enable_textbox(); } catch(E) { error.sdump('D_ERROR','async.disable_textbox() = ' + E); };
1020                                         }
1021                                         return null;
1022                                 }
1023                         } : null,
1024                         {
1025                                 'title' : 'Override Checkin Failure?',
1026                                 'overridable_events' : [ 
1027                                         1203 /* COPY_BAD_STATUS */, 
1028                                         1213 /* PATRON_BARRED */,
1029                                         1217 /* PATRON_INACTIVE */,
1030                                         1224 /* PATRON_ACCOUNT_EXPIRED */,
1031                                         7009 /* CIRC_CLAIMS_RETURNED */,
1032                                         7010 /* COPY_ALERT_MESSAGE */, 
1033                                         7011 /* COPY_STATUS_LOST */, 
1034                                         7012 /* COPY_STATUS_MISSING */, 
1035                                         7013 /* PATRON_EXCEEDS_FINES */,
1036                                 ],
1037                                 'text' : {
1038                                         '1203' : function(r) {
1039                                                 //return data.hash.ccs[ r.payload.status() ].name();
1040                                                 return r.payload.status().name();
1041                                         },
1042                                         '7010' : function(r) {
1043                                                 return r.payload;
1044                                         },
1045                                 }
1046                         }
1047                 );
1048                 if (!async) {
1049                         return circ.util.checkin_via_barcode2(session,params,backdate,auto_print,check); 
1050                 }
1051
1052
1053         } catch(E) {
1054                 JSAN.use('util.error'); var error = new util.error();
1055                 error.standard_unexpected_error_alert('Check In Failed (in circ.util.checkin): ',E);
1056                 if (typeof async == 'object') {
1057                         try { async.enable_textbox(); } catch(E) { error.sdump('D_ERROR','async.disable_textbox() = ' + E); };
1058                 }
1059                 return null;
1060         }
1061 }
1062
1063 circ.util.checkin_via_barcode2 = function(session,params,backdate,auto_print,check) {
1064         try {
1065                 JSAN.use('util.error'); var error = new util.error();
1066                 JSAN.use('util.network'); var network = new util.network();
1067                 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
1068                 JSAN.use('util.date');
1069
1070                 error.sdump('D_DEBUG','check = ' + error.pretty_print( js2JSON( check ) ) );
1071
1072                 check.message = check.textcode;
1073
1074                 if (check.payload && check.payload.copy) check.copy = check.payload.copy;
1075                 if (check.payload && check.payload.record) check.record = check.payload.record;
1076                 if (check.payload && check.payload.circ) check.circ = check.payload.circ;
1077
1078                 if (!check.route_to) check.route_to = '   ';
1079
1080                 if (document.getElementById('no_change_label')) {
1081                         document.getElementById('no_change_label').setAttribute('value','');
1082                         document.getElementById('no_change_label').setAttribute('hidden','true');
1083                 }
1084
1085                 if (check.circ) {
1086                         network.simple_request('FM_MBTS_RETRIEVE',[ses(),check.circ.id()], function(req) {
1087                                 JSAN.use('util.money');
1088                                 var bill = req.getResultObject();
1089                                 if (Number(bill.balance_owed()) == 0) return;
1090                                 if (document.getElementById('no_change_label')) {
1091                                         var m = document.getElementById('no_change_label').getAttribute('value');
1092                                         document.getElementById('no_change_label').setAttribute('value', m + 'Transaction for ' + params.barcode + ' billable $' + util.money.sanitize(bill.balance_owed()) + '  ');
1093                                         document.getElementById('no_change_label').setAttribute('hidden','false');
1094                                 }
1095                         });
1096                 }
1097
1098                 var msg = '';
1099
1100                 if (check.payload && check.payload.cancelled_hold_transit) {
1101                         msg += 'Original hold for transit cancelled.\n\n';
1102                 }
1103
1104                 /* SUCCESS  /  NO_CHANGE  /  ITEM_NOT_CATALOGED */
1105                 if (check.ilsevent == 0 || check.ilsevent == 3 || check.ilsevent == 1202) {
1106                         try { check.route_to = data.lookup('acpl', check.copy.location() ).name(); } catch(E) { msg += 'Please inform your helpdesk/developers of this error:\nFIXME: ' + E + '\n'; }
1107                         if (check.ilsevent == 3 /* NO_CHANGE */) {
1108                                 //msg = 'This item is already checked in.\n';
1109                                 if (document.getElementById('no_change_label')) {
1110                                         var m = document.getElementById('no_change_label').getAttribute('value');
1111                                         document.getElementById('no_change_label').setAttribute('value',m + params.barcode + ' was already checked in.  ');
1112                                         document.getElementById('no_change_label').setAttribute('hidden','false');
1113                                 }
1114                         }
1115                         if (check.ilsevent == 1202 /* ITEM_NOT_CATALOGED */ && check.copy.status() != 11) {
1116                                 msg = 'Please inform your helpdesk/developers of this error:\nFIXME -- ITEM_NOT_CATALOGED event but copy status is '
1117                                         + (data.hash.ccs[ check.copy.status() ] ? data.hash.ccs[ check.copy.status() ].name() : check.copy.status().name() ) + '\n';
1118                         }
1119                         switch(check.copy.status()) {
1120                                 case 0: /* AVAILABLE */
1121                                 case 7: /* RESHELVING */
1122                                         if (msg) msg += 'This item needs to be routed to ' + check.route_to + '.\n';
1123                                 break;
1124                                 case 8: /* ON HOLDS SHELF */
1125                                         check.route_to = 'HOLDS SHELF';
1126                                         if (check.payload.hold) {
1127                                                 if (check.payload.hold.pickup_lib() != data.list.au[0].ws_ou()) {
1128                                                         msg += 'Please inform your helpdesk/developers of this error:\nFIXME:  We should have received a ROUTE_ITEM\n';
1129                                                 } else {
1130                                                         msg += 'This item needs to be routed to ' + check.route_to + '.\n';
1131                                                 }
1132                                         } else { 
1133                                                 msg += 'Please inform your helpdesk/developers of this error:\nFIXME: status of Holds Shelf, but no actual hold found.\n';
1134                                         }
1135                                         JSAN.use('util.date'); 
1136                                         if (check.payload.hold) {
1137                                                 JSAN.use('patron.util');
1138                                                 msg += '\nBarcode: ' + check.payload.copy.barcode() + '\n';
1139                                                 msg += 'Title: ' + (check.payload.record ? check.payload.record.title() : check.payload.copy.dummy_title() ) + '\n';
1140                                                 var au_obj = patron.util.retrieve_fleshed_au_via_id( session, check.payload.hold.usr() );
1141                                                 msg += '\nHold for patron ' + au_obj.family_name() + ', ' + au_obj.first_given_name() + ' ' + au_obj.second_given_name() + '\n';
1142                                                 msg += 'Barcode: ' + au_obj.card().barcode() + '\n';
1143                                                 if (check.payload.hold.phone_notify()) msg += 'Notify by phone: ' + check.payload.hold.phone_notify() + '\n';
1144                                                 if (check.payload.hold.email_notify()) msg += 'Notify by email: ' + (au_obj.email() ? au_obj.email() : '') + '\n';
1145                                                 msg += '\nRequest Date: ' + util.date.formatted_date(check.payload.hold.request_time(),'%F') + '\n';
1146                                         }
1147                                         var rv = 0;
1148                                         msg += 'Slip Date: ' + util.date.formatted_date(new Date(),'%F') + '\n';
1149                                         if (!auto_print) rv = error.yns_alert_formatted(
1150                                                 msg,
1151                                                 'Hold Slip',
1152                                                 "Print",
1153                                                 "Don't Print",
1154                                                 null,
1155                                                 "Check here to confirm this message",
1156                                                 '/xul/server/skin/media/images/turtle.gif'
1157                                         );
1158                                         if (rv == 0) {
1159                                                 try {
1160                                                         JSAN.use('util.print'); var print = new util.print();
1161                                                         msg = msg.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\n/g,'<br/>');
1162                                                         print.simple( msg , { 'no_prompt' : true, 'content_type' : 'text/html' } );
1163                                                 } catch(E) {
1164                                                         dump('Please inform your helpdesk/developers of this error:\nFIXME: ' + E + '\n');
1165                                                         alert('Please inform your helpdesk/developers of this error:\nFIXME: ' + E + '\n');
1166                                                 }
1167                                         }
1168                                         msg = '';
1169                                         if (document.getElementById('no_change_label')) {
1170                                                 var m = document.getElementById('no_change_label').getAttribute('value');
1171                                                 document.getElementById('no_change_label').setAttribute('value',m + params.barcode + ' has been captured for a hold.  ');
1172                                                 document.getElementById('no_change_label').setAttribute('hidden','false');
1173                                         }
1174                                 break;
1175                                 case 6: /* IN TRANSIT */
1176                                         check.route_to = 'TRANSIT SHELF??';
1177                                         msg += ("Please inform your helpdesk/developers of this error:\nFIXME -- I didn't think we could get here.\n");
1178                                 break;
1179                                 case 11: /* CATALOGING */
1180                                         check.route_to = 'CATALOGING';
1181                                         if (document.getElementById('do_not_alert_on_precat')) {
1182                                                 var x = document.getElementById('do_not_alert_on_precat');
1183                                                 if (! x.checked) msg += 'This item needs to be routed to ' + check.route_to + '.';
1184                                         } else {
1185                                                 msg += 'This item needs to be routed to ' + check.route_to + '.';
1186                                         }
1187                                         if (document.getElementById('no_change_label')) {
1188                                                 var m = document.getElementById('no_change_label').getAttribute('value');
1189                                                 document.getElementById('no_change_label').setAttribute('value',m + params.barcode + ' needs to be cataloged.  ');
1190                                                 document.getElementById('no_change_label').setAttribute('hidden','false');
1191                                         }
1192                                 break;
1193                                 default:
1194                                         msg += ('Please inform your helpdesk/developers of this error:\nFIXME -- this case "' + (data.hash.ccs[check.copy.status()] ? data.hash.ccs[check.copy.status()].name() : check.copy.status().name()) + '" is unhandled.\n');
1195                                         msg += 'This item needs to be routed to ' + check.route_to + '.';
1196                                 break;
1197                         }
1198                         if (msg) error.yns_alert(msg,'Alert',null,'OK',null,"Check here to confirm this message");
1199
1200                 } else /* ROUTE_ITEM */ if (check.ilsevent == 7000) {
1201
1202                         var lib = data.hash.aou[ check.org ];
1203                         check.route_to = lib.shortname();
1204                         msg += 'Destination: ' + check.route_to + '.\n';
1205                         msg += '\n' + lib.name() + '\n';
1206                         try {
1207                                 if (lib.holds_address() ) {
1208                                         var a = network.simple_request('FM_AOA_RETRIEVE',[ lib.holds_address() ]);
1209                                         if (typeof a.ilsevent != 'undefined') throw(a);
1210                                         if (a.street1()) msg += a.street1() + '\n';
1211                                         if (a.street2()) msg += a.street2() + '\n';
1212                                         msg += (a.city() ? a.city() + ', ' : '') + (a.state() ? a.state() + ' ' : '') + (a.post_code() ? a.post_code() : '') + '\n';
1213                                 } else {
1214                                         msg += "We do not have a holds address for this library.\n";
1215                                 }
1216                         } catch(E) {
1217                                 msg += 'Unable to retrieve mailing address.\n';
1218                                 error.standard_unexpected_error_alert('Unable to retrieve mailing address.',E);
1219                         }
1220                         msg += '\nBarcode: ' + check.payload.copy.barcode() + '\n';
1221                         msg += 'Title: ' + (check.payload.record ? check.payload.record.title() : check.payload.copy.dummy_title() ) + '\n';
1222                         msg += 'Author: ' + (check.payload.record ? check.payload.record.author() :check.payload.copy.dummy_author()  ) + '\n';
1223                         JSAN.use('util.date');
1224                         if (check.payload.hold) {
1225                                 JSAN.use('patron.util');
1226                                 var au_obj = patron.util.retrieve_fleshed_au_via_id( session, check.payload.hold.usr() );
1227                                 msg += '\nHold for patron ' + au_obj.family_name() + ', ' + au_obj.first_given_name() + ' ' + au_obj.second_given_name() + '\n';
1228                                 msg += 'Barcode: ' + au_obj.card().barcode() + '\n';
1229                                 if (check.payload.hold.phone_notify()) msg += 'Notify by phone: ' + check.payload.hold.phone_notify() + '\n';
1230                                 if (check.payload.hold.email_notify()) msg += 'Notify by email: ' + (au_obj.email() ? au_obj.email() : '') + '\n';
1231                                 msg += '\nRequest Date: ' + util.date.formatted_date(check.payload.hold.request_time(),'%F');
1232                         }
1233                         var rv = 0;
1234                         msg += '\nSlip Date: ' + util.date.formatted_date(new Date(),'%F') + '\n';
1235                         if (!auto_print) rv = error.yns_alert_formatted(
1236                                 msg,
1237                                 'Transit Slip',
1238                                 "Print",
1239                                 "Don't Print",
1240                                 null,
1241                                 "Check here to confirm this message",
1242                                 '/xul/server/skin/media/images/turtle.gif'
1243                         );
1244                         if (rv == 0) {
1245                                 try {
1246                                         JSAN.use('util.print'); var print = new util.print();
1247                                         //print.simple( msg, { 'no_prompt' : true, 'content_type' : 'text/plain' } );
1248                                         msg = msg.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\n/g,'<br/>');
1249                                         print.simple( msg , { 'no_prompt' : true, 'content_type' : 'text/html' } );
1250                                 } catch(E) {
1251                                         dump('Please inform your helpdesk/developers of this error:\nFIXME: ' + E + '\n');
1252                                         alert('Please inform your helpdesk/developers of this error:\nFIXME: ' + E + '\n');
1253                                 }
1254                         }
1255                         if (document.getElementById('no_change_label')) {
1256                                 var m = document.getElementById('no_change_label').getAttribute('value');
1257                                 document.getElementById('no_change_label').setAttribute('value',m + params.barcode + ' is in transit.  ');
1258                                 document.getElementById('no_change_label').setAttribute('hidden','false');
1259                         }
1260
1261                 } else /* ASSET_COPY_NOT_FOUND */ if (check.ilsevent == 1502) {
1262
1263                         check.route_to = 'CATALOGING';
1264                         error.yns_alert(
1265                                 'The barcode was either mis-scanned or the item needs to be cataloged.',
1266                                 'Alert',
1267                                 null,
1268                                 'OK',
1269                                 null,
1270                                 "Check here to confirm this message"
1271                         );
1272                         if (document.getElementById('no_change_label')) {
1273                                 var m = document.getElementById('no_change_label').getAttribute('value');
1274                                 document.getElementById('no_change_label').setAttribute('value',m + params.barcode + ' is mis-scanned or not cataloged.  ');
1275                                 document.getElementById('no_change_label').setAttribute('hidden','false');
1276                         }
1277
1278                 } else /* NETWORK TIMEOUT */ if (check.ilsevent == -1) {
1279                         error.standard_network_error_alert('Check In Failed.  If you wish to use the offline interface, in the top menubar select Circulation -> Offline Interface');
1280                 } else {
1281
1282                         switch (check.ilsevent) {
1283                                 case 1203 /* COPY_BAD_STATUS */ : 
1284                                 case 1213 /* PATRON_BARRED */ :
1285                                 case 1217 /* PATRON_INACTIVE */ :
1286                                 case 1224 /* PATRON_ACCOUNT_EXPIRED */ :
1287                                 case 7009 /* CIRC_CLAIMS_RETURNED */ :
1288                                 case 7010 /* COPY_ALERT_MESSAGE */ : 
1289                                 case 7011 /* COPY_STATUS_LOST */ : 
1290                                 case 7012 /* COPY_STATUS_MISSING */ : 
1291                                 case 7013 /* PATRON_EXCEEDS_FINES */ :
1292                                         return null; /* handled */
1293                                 break;
1294                         }
1295
1296                         throw(check);
1297
1298                 }
1299
1300                 return check;
1301         } catch(E) {
1302                 JSAN.use('util.error'); var error = new util.error();
1303                 error.standard_unexpected_error_alert('Check In Failed (in circ.util.checkin): ',E);
1304                 return null;
1305         }
1306 }
1307
1308 circ.util.renew_via_barcode = function ( barcode, patron_id, async ) {
1309         try {
1310                 var obj = {};
1311                 JSAN.use('util.network'); obj.network = new util.network();
1312                 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.stash_retrieve();
1313
1314                 var params = { barcode: barcode };
1315                 if (patron_id) params.patron = patron_id;
1316
1317                 function renew_callback(req) {
1318                         try {
1319                                 var renew = req.getResultObject();
1320                                 if (typeof renew.ilsevent != 'undefined') renew = [ renew ];
1321                                 for (var j = 0; j < renew.length; j++) { 
1322                                         switch(renew[j].ilsevent) {
1323                                                 case 0 /* SUCCESS */ : break;
1324                                                 case 5000 /* PERM_FAILURE */: break;
1325                                                 case 1212 /* PATRON_EXCEEDS_OVERDUE_COUNT */ : break;
1326                                                 case 1213 /* PATRON_BARRED */ : break;
1327                                                 case 1215 /* CIRC_EXCEEDS_COPY_RANGE */ : break;
1328                                                 case 1224 /* PATRON_ACCOUNT_EXPIRED */ : break;
1329                                                 case 1500 /* ACTION_CIRCULATION_NOT_FOUND */ : break;
1330                                                 case 7002 /* PATRON_EXCEEDS_CHECKOUT_COUNT */ : break;
1331                                                 case 7003 /* COPY_CIRC_NOT_ALLOWED */ : break;
1332                                                 case 7004 /* COPY_NOT_AVAILABLE */ : break;
1333                                                 case 7006 /* COPY_IS_REFERENCE */ : break;
1334                                                 case 7007 /* COPY_NEEDED_FOR_HOLD */ : break;
1335                                                 case 7008 /* MAX_RENEWALS_REACHED */ : break; 
1336                                                 case 7009 /* CIRC_CLAIMS_RETURNED */ : break; 
1337                                                 case 7010 /* COPY_ALERT_MESSAGE */ : break;
1338                                                 case 7013 /* PATRON_EXCEEDS_FINES */ : break;
1339                                                 default:
1340                                                         throw(renew);
1341                                                 break;
1342                                         }
1343                                 }
1344                                 if (typeof async == 'function') async(renew);
1345                                 return renew;
1346                         } catch(E) {
1347                                 JSAN.use('util.error'); var error = new util.error();
1348                                 error.standard_unexpected_error_alert('Renew Failed for ' + barcode,E);
1349                                 return null;
1350                         }
1351                 }
1352
1353                 var renew = obj.network.simple_request(
1354                         'CHECKOUT_RENEW', 
1355                         [ ses(), params ],
1356                         async ? renew_callback : null,
1357                         {
1358                                 'title' : 'Override Renew Failure?',
1359                                 'overridable_events' : [ 
1360                                         1212 /* PATRON_EXCEEDS_OVERDUE_COUNT */,
1361                                         1213 /* PATRON_BARRED */,
1362                                         1215 /* CIRC_EXCEEDS_COPY_RANGE */,
1363                                         7002 /* PATRON_EXCEEDS_CHECKOUT_COUNT */,
1364                                         7003 /* COPY_CIRC_NOT_ALLOWED */,
1365                                         7004 /* COPY_NOT_AVAILABLE */,
1366                                         7006 /* COPY_IS_REFERENCE */,
1367                                         7007 /* COPY_NEEDED_FOR_HOLD */,
1368                                         7008 /* MAX_RENEWALS_REACHED */, 
1369                                         7009 /* CIRC_CLAIMS_RETURNED */, 
1370                                         7010 /* COPY_ALERT_MESSAGE */,
1371                                         7013 /* PATRON_EXCEEDS_FINES */,
1372                                 ],
1373                                 'text' : {
1374                                         '1212' : function(r) { return 'Barcode: ' + barcode; },
1375                                         '1213' : function(r) { return 'Barcode: ' + barcode; },
1376                                         '1215' : function(r) { return 'Barcode: ' + barcode; },
1377                                         '7002' : function(r) { return 'Barcode: ' + barcode; },
1378                                         '7003' : function(r) { return 'Barcode: ' + barcode; },
1379                                         '7004' : function(r) {
1380                                                 return 'Barcode: ' + barcode + ' Status: ' + r.payload.status().name();
1381                                         },
1382                                         '7006' : function(r) { return 'Barcode: ' + barcode; },
1383                                         '7007' : function(r) { return 'Barcode: ' + barcode; },
1384                                         '7008' : function(r) { return 'Barcode: ' + barcode; },
1385                                         '7009' : function(r) { return 'Barcode: ' + barcode; },
1386                                         '7010' : function(r) {
1387                                                 return 'Barcode: ' + barcode + ' Message: ' + r.payload;
1388                                         },
1389                                         '7013' : function(r) { return 'Barcode: ' + barcode; },
1390                                 }
1391                         }
1392                 );
1393                 if (! async ) return renew_callback( { 'getResultObject' : function() { return renew; } } );
1394
1395         } catch(E) {
1396                 JSAN.use('util.error'); var error = new util.error();
1397                 error.standard_unexpected_error_alert('Renew Failed for ' + barcode,E);
1398                 return null;
1399         }
1400 }
1401
1402
1403
1404 dump('exiting circ/util.js\n');