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