]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js
SHORTNAME macro instead of PINES_CODE for receipt tempaltes
[Evergreen.git] / Open-ILS / xul / staff_client / chrome / content / OpenILS / data.js
1 dump('entering OpenILS/data.js\n');
2
3 if (typeof OpenILS == 'undefined') OpenILS = {};
4 OpenILS.data = function () {
5
6         JSAN.use('util.error'); this.error = new util.error();
7         JSAN.use('util.network'); this.network = new util.network();
8
9         return this;
10 }
11
12 OpenILS.data.prototype = {
13
14         'list' : {},
15         'hash' : {},
16         'tree' : {},
17
18         'temp' : '',
19
20         'data_progress' : function(msg) {
21                 try {
22                         var x = document.getElementById('data_progress');
23                         if (x) {
24                                 x.appendChild( document.createTextNode( msg ) );
25                         }
26                 } catch(E) {
27                         this.error.sdump('D_ERROR',msg + '\n' + E);
28                 }
29         },
30
31         'init' : function (params) {
32
33                 try {
34                         if (params && params.via == 'stash') {  
35                                 this.stash_retrieve();
36                         } else {
37                                 this.network_retrieve();
38                         }
39                 
40                 } catch(E) {
41                         this.error.sdump('D_ERROR','Error in OpenILS.data.init('
42                                 +js2JSON(params)+'): ' + js2JSON(E) );
43                 }
44
45
46         },
47
48         'stash' : function () {
49                 try {
50                         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
51                         const OpenILS=new Components.Constructor("@mozilla.org/openils_data_cache;1", "nsIOpenILS");
52                         var data_cache=new OpenILS( );
53                         for (var i = 0; i < arguments.length; i++) {
54                                 try {
55                                         if (arguments[i] != 'hash' && arguments[i] != 'list') this.error.sdump('D_DATA_STASH','stashing ' + arguments[i] + ' : ' + this[arguments[i]] + (typeof this[arguments[i]] == 'object' ? ' = ' + js2JSON(this[arguments[i]]) : '') + '\n');
56                                 } catch(F) { alert(F); }
57                                 data_cache.wrappedJSObject.OpenILS.prototype.data[arguments[i]] = this[arguments[i]];
58                         }
59                 } catch(E) {
60                         this.error.sdump('D_ERROR','Error in OpenILS.data.stash(): ' + js2JSON(E) );
61                 }
62         },
63
64         'lookup' : function(key,value) {
65                 try {
66                         var obj = this; var found;
67                         if (obj.hash[key] && obj.hash[key][value]) return obj.hash[key][value];
68                         switch(key) {
69                                 case 'acpl': 
70                                         found = obj.network.simple_request('FM_ACPL_RETRIEVE_VIA_ID',[ value ]);
71                                 break;
72                                 default: return undefined; break;
73                         }
74                         if (typeof found.ilsevent != 'undefined') throw(found);
75                         if (!obj.hash[key]) obj.hash[key] = {};
76                         obj.hash[key][value] = found; obj.list[key].push( found ); obj.stash('hash','list');
77                         return found;
78                 } catch(E) {
79                         this.error.sdump('D_ERROR','Error in OpenILS.data.lookup('+key+','+value+'): ' + js2JSON(E) );
80                         return undefined;
81                 }
82         },
83
84         '_debug_stash' : function() {
85                 try {
86                         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
87                         const OpenILS=new Components.Constructor("@mozilla.org/openils_data_cache;1", "nsIOpenILS");
88                         var data_cache=new OpenILS( );
89                         for (var i in data_cache.wrappedJSObject.OpenILS.prototype.data) {
90                                 dump('_debug_stash ' + i + '\n');
91                         }
92                 } catch(E) {
93                         this.error.sdump('D_ERROR','Error in OpenILS.data._debug_stash(): ' + js2JSON(E) );
94                 }
95         },
96
97         '_fm_objects' : {
98
99                 'pgt' : [ api.FM_PGT_RETRIEVE.app, api.FM_PGT_RETRIEVE.method, [], true ],
100                 'cit' : [ api.FM_CIT_RETRIEVE.app, api.FM_CIT_RETRIEVE.method, [], true ],
101                 'citm' : [ api.FM_CITM_RETRIEVE.app, api.FM_CITM_RETRIEVE.method, [], true ],
102                 /*
103                 'cst' : [ api.FM_CST_RETRIEVE.app, api.FM_CST_RETRIEVE.method, [], true ],
104                 */
105                 /*
106                 'acpl' : [ api.FM_ACPL_RETRIEVE.app, api.FM_ACPL_RETRIEVE.method, [], true ],
107                 */
108                 'ccs' : [ api.FM_CCS_RETRIEVE.app, api.FM_CCS_RETRIEVE.method, [], true ],
109                 'aou' : [ api.FM_AOU_RETRIEVE.app, api.FM_AOU_RETRIEVE.method, [], true ],
110                 'aout' : [ api.FM_AOUT_RETRIEVE.app, api.FM_AOUT_RETRIEVE.method, [], true ],
111                 'crahp' : [ api.FM_CRAHP_RETRIEVE.app, api.FM_CRAHP_RETRIEVE.method, [], true ],
112         },
113
114         'stash_retrieve' : function() {
115                 try {
116                         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
117                         const OpenILS=new Components.Constructor("@mozilla.org/openils_data_cache;1", "nsIOpenILS");
118                         var data_cache=new OpenILS( );
119                         var dc = data_cache.wrappedJSObject.OpenILS.prototype.data;
120                         for (var i in dc) {
121                                 this.error.sdump('D_DATA_RETRIEVE','Retrieving ' + i + ' : ' + dc[i] + '\n');
122                                 this[i] = dc[i];
123                         }
124                         if (typeof this.on_complete == 'function') {
125
126                                 this.on_complete();
127                         }
128                 } catch(E) {
129                         this.error.sdump('D_ERROR','Error in OpenILS.data._debug_stash(): ' + js2JSON(E) );
130                 }
131         },
132
133         'print_list_defaults' : function() {
134                 var obj = this;
135                 //if (typeof obj.print_list_templates == 'undefined') {
136                 {
137                         obj.print_list_types = [ 
138                                 'offline_checkout', 
139                                 'offline_checkin', 
140                                 'offline_renew', 
141                                 'offline_inhouse_use', 
142                                 'items', 
143                                 'bills', 
144                                 'payment', 
145                                 'holds', 
146                                 /* 'patrons' */
147                         ];
148                         obj.print_list_templates = { 
149                                 'item_status' : {
150                                         'type' : 'items',
151                                         'header' : 'The following items have been examined:<hr/><ol>',
152                                         'line_item' : '<li>%title%<br/>\r\nBarcode: %barcode%\r\n',
153                                         'footer' : '</ol><hr />%SHORTNAME% %TODAY_TRIM%<br/>\r\n<br/>\r\n',
154                                 }, 
155                                 'transit_list' : {
156                                         'type' : 'transits',
157                                         'header' : 'Transits:<hr/><ol>',
158                                         'line_item' : '<li>From: %transit_source% To: %transit_dest_lib%<br/>\r\nWhen: %transit_source_send_time%<br />\r\nBarcode: %transit_item_barcode% Title: %transit_item_title%<br/>\r\n',
159                                         'footer' : '</ol><hr />%SHORTNAME% %TODAY_TRIM%<br/>\r\n<br/>\r\n',
160                                 }, 
161                                 'items_out' : {
162                                         'type' : 'items',
163                                         'header' : 'Welcome to %LIBRARY%!<br/>\r\nYou have the following items:<hr/><ol>',
164                                         'line_item' : '<li>%title%<br/>\r\nBarcode: %barcode% Due: %due_date%\r\n',
165                                         'footer' : '</ol><hr />%SHORTNAME% %TODAY_TRIM%<br/>\r\nYou were helped by %STAFF_FIRSTNAME%<br/>\r\n<br/>\r\n',
166                                 }, 
167                                 'checkout' : {
168                                         'type' : 'items',
169                                         'header' : 'Welcome to %LIBRARY%!<br/>\r\nYou checked out the following items:<hr/><ol>',
170                                         'line_item' : '<li>%title%<br/>\r\nBarcode: %barcode% Due: %due_date%\r\n',
171                                         'footer' : '</ol><hr />%SHORTNAME% %TODAY_TRIM%<br/>\r\nYou were helped by %STAFF_FIRSTNAME%<br/>\r\n<br/>\r\n',
172                                 }, 
173                                 'offline_checkout' : {
174                                         'type' : 'offline_checkout',
175                                         'header' : 'Patron %patron_barcode%<br/>\r\nYou checked out the following items:<hr/><ol>',
176                                         'line_item' : '<li>Barcode: %barcode%<br/>\r\nDue: %due_date%\r\n',
177                                         'footer' : '</ol><hr />%TODAY_TRIM%<br/>\r\n<br/>\r\n',
178                                 },
179                                 'checkin' : {
180                                         'type' : 'items',
181                                         'header' : 'You checked in the following items:<hr/><ol>',
182                                         'line_item' : '<li>%title%<br/>\r\nBarcode: %barcode%  Call Number: %call_number%\r\n',
183                                         'footer' : '</ol><hr />%SHORTNAME% %TODAY_TRIM%<br/>\r\n<br/>\r\n',
184                                 }, 
185                                 'bill_payment' : {
186                                         'type' : 'payment',
187                                         'header' : 'Welcome to %LIBRARY%!<br/>A receipt of your  transaction:<hr/> <table width="100%"> <tr> <td>Original Balance:</td> <td align="right">$%original_balance%</td> </tr> <tr> <td>Payment Method:</td> <td align="right">%payment_type%</td> </tr> <tr> <td>Payment Received:</td> <td align="right">$%payment_received%</td> </tr> <tr> <td>Payment Applied:</td> <td align="right">$%payment_applied%</td> </tr> <tr> <td>Billings Voided:</td> <td align="right">%voided_balance%</td> </tr> <tr> <td>Change Given:</td> <td align="right">$%change_given%</td> </tr> <tr> <td>New Balance:</td> <td align="right">$%new_balance%</td> </tr> </table> <p> Note: %note% </p> <p> Specific bills: <blockquote>',
188                                         'line_item' : 'Bill #%bill_id%  %last_billing_type% Received: $%payment%<br />%barcode% %title%<br /><br />',
189                                         'footer' : '</blockquote> </p> <hr />%SHORTNAME% %TODAY_TRIM%<br/> <br/> ',
190                                 },
191                                 'bills_historical' : {
192                                         'type' : 'bills',
193                                         'header' : 'Welcome to %LIBRARY%!<br/>You had the following bills:<hr/><ol>',
194                                         'line_item' : '<dt><b>Bill #%id%</b></dt> <dd> <table> <tr valign="top"><td>Date:</td><td>%xact_start%</td></tr> <tr valign="top"><td>Type:</td><td>%xact_type%</td></tr> <tr valign="top"><td>Last Billing:</td><td>%last_billing_type%<br/>%last_billing_note%</td></tr> <tr valign="top"><td>Total Billed:</td><td>$%total_owed%</td></tr> <tr valign="top"><td>Last Payment:</td><td>%last_payment_type%<br/>%last_payment_note%</td></tr> <tr valign="top"><td>Total Paid:</td><td>$%total_paid%</td></tr> <tr valign="top"><td><b>Balance:</b></td><td><b>$%balance_owed%</b></td></tr> </table><br/>',
195                                         'footer' : '</ol><hr />%SHORTNAME% %TODAY_TRIM%<br/>\r\n<br/>\r\n',
196                                 }, 
197                                 'bills_current' : {
198                                         'type' : 'bills',
199                                         'header' : 'Welcome to %LIBRARY%!<br/>You have the following bills:<hr/><ol>',
200                                         'line_item' : '<dt><b>Bill #%id%</b></dt> <dd> <table> <tr valign="top"><td>Date:</td><td>%xact_start%</td></tr> <tr valign="top"><td>Type:</td><td>%xact_type%</td></tr> <tr valign="top"><td>Last Billing:</td><td>%last_billing_type%<br/>%last_billing_note%</td></tr> <tr valign="top"><td>Total Billed:</td><td>$%total_owed%</td></tr> <tr valign="top"><td>Last Payment:</td><td>%last_payment_type%<br/>%last_payment_note%</td></tr> <tr valign="top"><td>Total Paid:</td><td>$%total_paid%</td></tr> <tr valign="top"><td><b>Balance:</b></td><td><b>$%balance_owed%</b></td></tr> </table><br/>',
201                                         'footer' : '</ol><hr />%SHORTNAME% %TODAY_TRIM%<br/>\r\n<br/>\r\n',
202                                 }, 
203                                 'offline_checkin' : {
204                                         'type' : 'offline_checkin',
205                                         'header' : 'You checked in the following items:<hr/><ol>',
206                                         'line_item' : '<li>Barcode: %barcode%\r\n',
207                                         'footer' : '</ol><hr />%TODAY_TRIM%<br/>\r\n<br/>\r\n',
208                                 },
209                                 'offline_renew' : {
210                                         'type' : 'offline_renew',
211                                         'header' : 'You renewed the following items:<hr/><ol>',
212                                         'line_item' : '<li>Barcode: %barcode%\r\n',
213                                         'footer' : '</ol><hr />%TODAY_TRIM%<br/>\r\n<br/>\r\n',
214                                 },
215                                 'offline_inhouse_use' : {
216                                         'type' : 'offline_inhouse_use',
217                                         'header' : 'You marked the following in-house items used:<hr/><ol>',
218                                         'line_item' : '<li>Barcode: %barcode%\r\nUses: %count%',
219                                         'footer' : '</ol><hr />%TODAY_TRIM%<br/>\r\n<br/>\r\n',
220                                 },
221                                 'in_house_use' : {
222                                         'type' : 'items',
223                                         'header' : 'You marked the following in-house items used:<hr/><ol>',
224                                         'line_item' : '<li>Barcode: %barcode%\r\nUses: %uses%\r\n<br />%alert_message%',
225                                         'footer' : '</ol><hr />%TODAY_TRIM%<br/>\r\n<br/>\r\n',
226                                 },
227                                 'holds' : {
228                                         'type' : 'holds',
229                                         'header' : 'Welcome to %LIBRARY%!<br/>\r\nYou have the following titles on hold:<hr/><ol>',
230                                         'line_item' : '<li>%title%\r\n',
231                                         'footer' : '</ol><hr />%SHORTNAME% %TODAY_TRIM%<br/>\r\nYou were helped by %STAFF_FIRSTNAME%<br/>\r\n<br/>\r\n',
232                                 } 
233                         }; 
234
235                         obj.stash( 'print_list_templates', 'print_list_types' );
236                 }
237         },
238
239         'network_retrieve' : function() {
240                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
241                 var obj = this;
242
243
244                 JSAN.use('util.file'); var file = new util.file('print_list_templates');
245                 obj.print_list_defaults();
246                 obj.data_progress('Default print templates set. ');
247                 if (file._file.exists()) {
248                         try {
249                                 var x = file.get_object();
250                                 if (x) {
251                                         for (var i in x) {
252                                                 obj.print_list_templates[i] = x[i];
253                                         }
254                                         obj.stash('print_list_templates');
255                                         obj.data_progress('Saved print templates retrieved from file. ');
256                                 }
257                         } catch(E) {
258                                 alert(E);
259                         }
260                 }
261                 file.close();
262
263                 JSAN.use('util.file'); var file = new util.file('global_font_adjust');
264                 if (file._file.exists()) {
265                         try {
266                                 var x = file.get_object();
267                                 if (x) {
268                                         obj.global_font_adjust = x;
269                                         obj.stash('global_font_adjust');
270                                         obj.data_progress('Saved font settings retrieved from file. ');
271                                 }
272                         } catch(E) {
273                                 alert(E);
274                         }
275                 }
276                 file.close();
277
278                 JSAN.use('util.file'); var file = new util.file('no_sound');
279                 if (file._file.exists()) {
280                         try {
281                                 var x = file.get_content();
282                                 if (x) {
283                                         obj.no_sound = x;
284                                         obj.stash('no_sound');
285                                         obj.data_progress('Saved sound settings retrieved from file. ');
286                                 }
287                         } catch(E) {
288                                 alert(E);
289                         }
290                 }
291                 file.close();
292
293                 JSAN.use('util.file'); var file = new util.file('print_strategy');
294                 if (file._file.exists()) {
295                         try {
296                                 var x = file.get_content();
297                                 if (x) {
298                                         obj.print_strategy = x;
299                                         obj.stash('print_strategy');
300                                         obj.data_progress('Print strategy retrieved from file. ');
301                                 }
302                         } catch(E) {
303                                 alert(E);
304                         }
305                 }
306                 file.close();
307
308                 JSAN.use('util.functional');
309                 JSAN.use('util.fm_utils');
310
311                 function gen_fm_retrieval_func(classname,data) {
312                         var app = data[0]; var method = data[1]; var params = data[2]; var cacheable = data[3];
313                         return function () {
314                                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
315
316                                 function convert() {
317                                         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
318                                         try {
319                                                 if (obj.list[classname].constructor.name == 'Array') {
320                                                         obj.hash[classname] = 
321                                                                 util.functional.convert_object_list_to_hash(
322                                                                         obj.list[classname]
323                                                                 );
324                                                 }
325                                         } catch(E) {
326
327                                                 obj.error.sdump('D_ERROR',E + '\n');
328                                         }
329
330                                 }
331
332                                 try {
333                                         var level = obj.error.sdump_levels.D_SES_RESULT;
334                                         if (classname == 'aou' || classname == 'my_aou')
335                                                 obj.error.sdump_levels.D_SES_RESULT = false;
336                                         var robj = obj.network.request( app, method, params);
337                                         if (!robj || robj.ilsevent) {
338                                                 obj.error.standard_unexpected_error_alert('The staff client failed to retrieve expected data from this call, "' + method + '"',robj);
339                                                 throw(robj);
340                                         }
341                                         obj.list[classname] = robj;
342                                         obj.error.sdump_levels.D_SES_RESULT = level;
343                                         convert();
344                                         obj.data_progress('Retrieved list for ' + classname + ' objects. ');
345                                         // if cacheable, store an offline copy
346                                         /* FIXME -- we're going to revisit caching and do it differently
347                                         if (cacheable) {
348                                                 var file = new util.file( classname );
349                                                 file.set_object( obj.list[classname] );
350                                         }
351                                         */
352
353                                 } catch(E) {
354                                         // if cacheable, try offline
355                                         if (cacheable) {
356                                                 /* FIXME -- we're going to revisit caching and do it differently
357                                                 try {
358                                                         var file = new util.file( classname );
359                                                         obj.list[classname] = file.get_object(); file.close();
360                                                         convert();
361                                                 } catch(E) {
362                                                         throw(E);
363                                                 }
364                                                 */
365                                                 throw(E); // for now
366                                         } else {
367                                                 throw(E); // for now
368                                         }
369                                 }
370                         }
371                 }
372
373                 this.chain = [];
374
375                 this.chain.push(
376                         function() {
377                                 try {
378                                         var robj = obj.network.simple_request('CIRC_MODIFIER_LIST',[]);
379                                         if (typeof robj.ilsevent != 'undefined') throw(robj);
380                                         obj.list.circ_modifier = robj;
381                                         obj.data_progress('Retrieved circ modifier list. ');
382                                 } catch(E) {
383                                         var error = 'Error: ' + js2JSON(E);
384                                         obj.error.sdump('D_ERROR',error);
385                                         throw(E);
386                                 }
387                         }
388                 );
389
390                 this.chain.push(
391                         function() {
392                                 try {
393                                         var robj = obj.network.simple_request('BILLING_TYPE_LIST',[]);
394                                         if (typeof robj.ilsevent != 'undefined') throw(robj);
395                                         obj.list.billing_type = robj;
396                                         obj.data_progress('Retrieved billing type list. ');
397                                 } catch(E) {
398                                         var error = 'Error: ' + js2JSON(E);
399                                         obj.error.sdump('D_ERROR',error);
400                                         throw(E);
401                                 }
402                         }
403                 );
404
405
406                 this.chain.push(
407                         function() {
408                                 var f = gen_fm_retrieval_func(
409                                         'cnal',
410                                         [
411                                                 api.FM_CNAL_RETRIEVE.app,
412                                                 api.FM_CNAL_RETRIEVE.method,
413                                                 [ obj.session.key ],
414                                                 false
415                                         ]
416                                 );
417                                 try {
418                                         f();
419                                 } catch(E) {
420                                         var error = 'Error: ' + js2JSON(E);
421                                         obj.error.sdump('D_ERROR',error);
422                                         throw(E);
423                                 }
424                         }
425                 );
426
427                 this.chain.push(
428                         function() {
429                                 var f = gen_fm_retrieval_func(
430                                         'au',
431                                         [
432                                                 api.FM_AU_RETRIEVE_VIA_SESSION.app,
433                                                 api.FM_AU_RETRIEVE_VIA_SESSION.method,
434                                                 [ obj.session.key ],
435                                                 false
436                                         ]
437                                 );
438                                 try {
439                                         f();
440                                 } catch(E) {
441                                         var error = 'Error: ' + js2JSON(E);
442                                         obj.error.sdump('D_ERROR',error);
443                                         throw(E);
444                                 }
445                                 obj.list.au = [ obj.list.au ];
446                         }
447                 );
448
449                 this.chain.push(
450                         function() {
451                                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
452                                 var f = gen_fm_retrieval_func(
453                                         'my_asv',
454                                         [
455                                                 api.FM_ASV_RETRIEVE_REQUIRED.app,
456                                                 api.FM_ASV_RETRIEVE_REQUIRED.method,
457                                                 [ obj.session.key ],
458                                                 true
459                                         ]
460                                 );
461                                 try {
462                                         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
463                                         f();
464                                 } catch(E) {
465                                         var error = 'Error: ' + js2JSON(E);
466                                         obj.error.sdump('D_ERROR',error);
467                                         throw(E);
468                                 }
469                         }
470                 );
471
472                 this.chain.push(
473                         function() {
474                                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
475                                 var f = gen_fm_retrieval_func(
476                                         'asv',
477                                         [
478                                                 api.FM_ASV_RETRIEVE.app,
479                                                 api.FM_ASV_RETRIEVE.method,
480                                                 [ obj.session.key ],
481                                                 true
482                                         ]
483                                 );
484                                 try {
485                                         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
486                                         f();
487                                 } catch(E) {
488                                         var error = 'Error: ' + js2JSON(E);
489                                         obj.error.sdump('D_ERROR',error);
490                                         throw(E);
491                                 }
492                         }
493                 );
494
495                 obj.error.sdump('D_DEBUG','_fm_objects = ' + js2JSON(this._fm_objects) + '\n');
496
497                 for (var i in this._fm_objects) {
498                         this.chain.push( gen_fm_retrieval_func(i,this._fm_objects[i]) );
499                 }
500
501                 // The previous org_tree call returned a tree, not a list or hash.
502                 this.chain.push(
503                         function () {
504                                 obj.tree.aou = obj.list.aou;
505                                 obj.list.aou = util.fm_utils.flatten_ou_branch( obj.tree.aou );
506                                 obj.hash.aou = util.functional.convert_object_list_to_hash( obj.list.aou );
507                         }
508                 );
509
510                 // The previous pgt call returned a tree, not a list or hash.
511                 this.chain.push(
512                         function () {
513                                 obj.tree.pgt = obj.list.pgt;
514                                 obj.list.pgt = util.fm_utils.flatten_ou_branch( obj.tree.pgt );
515                                 obj.hash.pgt = util.functional.convert_object_list_to_hash( obj.list.pgt );
516                         }
517                 );
518
519                 // Do this after we get the user object
520                 this.chain.push(
521
522                         function() {
523
524                                 gen_fm_retrieval_func('my_aou', 
525                                         [ 
526                                                 api.FM_AOU_RETRIEVE_RELATED_VIA_SESSION.app,
527                                                 api.FM_AOU_RETRIEVE_RELATED_VIA_SESSION.method,
528                                                 [ obj.session.key, obj.list.au[0].ws_ou() ], /* use ws_ou and not home_ou */
529                                                 true
530                                         ]
531                                 )();
532                         }
533                 );
534
535                 this.chain.push(
536
537                         function () {
538
539                                 gen_fm_retrieval_func( 'my_actsc', 
540                                         [ 
541                                                 api.FM_ACTSC_RETRIEVE_VIA_AOU.app,
542                                                 api.FM_ACTSC_RETRIEVE_VIA_AOU.method,
543                                                 [ obj.session.key, obj.list.au[0].ws_ou() ],
544                                                 true
545                                         ]
546                                 )();
547                         }
548                 );
549
550                 this.chain.push(
551
552                         function () {
553
554                                 gen_fm_retrieval_func( 'my_asc', 
555                                         [ 
556                                                 api.FM_ASC_RETRIEVE_VIA_AOU.app,
557                                                 api.FM_ASC_RETRIEVE_VIA_AOU.method,
558                                                 [ obj.session.key, obj.list.au[0].ws_ou() ],
559                                                 true
560                                         ]
561                                 )();
562                         }
563                 );
564
565
566                 this.chain.push(
567                         function() {
568                                 var f = gen_fm_retrieval_func(
569                                         'cnct',
570                                         [
571                                                 api.FM_CNCT_RETRIEVE.app,
572                                                 api.FM_CNCT_RETRIEVE.method,
573                                                 [ obj.list.au[0].ws_ou() ], 
574                                                 false
575                                         ]
576                                 );
577                                 try {
578                                         f();
579                                 } catch(E) {
580                                         var error = 'Error: ' + js2JSON(E);
581                                         obj.error.sdump('D_ERROR',error);
582                                         throw(E);
583                                 }
584                         }
585                 );
586
587                 this.chain.push(
588                         function() {
589                                 var f = gen_fm_retrieval_func(
590                                         'acpl',
591                                         [
592                                                 api.FM_ACPL_RETRIEVE.app,
593                                                 api.FM_ACPL_RETRIEVE.method,
594                                                 [ obj.list.au[0].ws_ou() ],
595                                                 false
596                                         ]
597                                 );
598                                 try {
599                                         f();
600                                 } catch(E) {
601                                         var error = 'Error: ' + js2JSON(E);
602                                         obj.error.sdump('D_ERROR',error);
603                                         throw(E);
604                                 }
605                         }
606                 );
607
608
609
610                 if (typeof this.on_complete == 'function') {
611
612                         this.chain.push( this.on_complete );
613                 }
614                 JSAN.use('util.exec'); this.exec = new util.exec();
615                 this.exec.on_error = function(E) { 
616                 
617                         if (typeof obj.on_error == 'function') {
618                                 obj.on_error();
619                         } else {
620                                 alert('oops: ' + E ); 
621                         }
622
623                         return false; /* break chain */
624                 }
625
626                 this.exec.chain( this.chain );
627
628         }
629 }
630
631 dump('exiting OpenILS/data.js\n');