]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/xul/staff_client/server/admin/upload_xacts.js
e4ec6533ca4d011cc80a900edc3f8c1877fa9c55
[Evergreen.git] / Open-ILS / xul / staff_client / server / admin / upload_xacts.js
1 var myPackageDir = 'open_ils_staff_client'; var IAMXUL = true; var g = {};
2
3 function $(id) {
4         return document.getElementById(id);
5 }
6
7 function my_init() {
8         try {
9                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect UniversalFileRead");
10                 if (typeof JSAN == 'undefined') { throw( "The JSAN library object is missing."); }
11                 JSAN.errorLevel = "die"; // none, warn, or die
12                 JSAN.addRepository('..');
13                 JSAN.use('util.error'); g.error = new util.error();
14                 g.error.sdump('D_TRACE','my_init() for offline_checkout.html');
15
16                 if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') {
17                         try { window.xulG.set_tab_name('Upload Offline Transactions'); } catch(E) { alert(E); }
18                 }
19
20                 g.cgi = new CGI();
21
22                 JSAN.use('util.file'); g.file = new util.file( g.cgi.param('filename') );
23
24                 if (g.file._file.exists()) {
25                         $('submit').disabled = false;
26                         $('file').value = g.file._file.path;
27                 } else {
28                         alert('No transactions to upload.');
29                         return;
30                 }
31
32                 $( 'ws' ).setAttribute('value', g.cgi.param('ws'));
33                 $( 'ses' ).setAttribute('value', g.cgi.param('ses'));
34                 $( 'seskey' ).setAttribute('value', g.cgi.param('seskey'));
35                 $( 'delta' ).setAttribute('value', g.cgi.param('delta'));
36
37                 $( 'form' ).setAttribute('action', xulG.url_prefix(urls.XUL_OFFLINE_MANAGE_XACTS_CGI));
38
39                 setTimeout(
40                         function() {
41                                 JSAN.use('util.widgets');
42                                 util.widgets.click('submit');
43                         }, 0
44                 );
45
46         } catch(E) {
47                 var err_msg = "!! This software has encountered an error.  Please tell your friendly " +
48                         "system administrator or software developer the following:\nmain/upload_xacts.xhtml\n" + E + '\n';
49                 try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
50                 alert(err_msg);
51         }
52 }
53
54