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