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