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