nsinject.js
authorAlan Knowles <alan@roojs.com>
Mon, 24 Sep 2012 04:59:45 +0000 (12:59 +0800)
committerAlan Knowles <alan@roojs.com>
Mon, 24 Sep 2012 04:59:45 +0000 (12:59 +0800)
nsinject.js

index 9f9b80b..d201dc0 100644 (file)
@@ -112,101 +112,28 @@ NS = {
         //id = 282;
         this.id = id;
         var timeout = 10;
-        var frameload = function()
-        {
-             
-            
-            
-            
-        }
+        
         console.log("document.location" + document.location);
         
-        if (!(window.location + '').match(/netsuite/)) {
-            // try
-            
-            window.location = 'https://system.netsuite.com/app/common/search/searchresults.nl' +
-                '?searchtype=Transaction' +
-                '&Transaction_ACCOUNT=' + id +
-                'sortcol=Transaction_TRANDATE_raw' +
-                '&sortdir=ASC'+
-                '&csv=HTML'+
-                '&OfficeXML=F'+
-                '&pdf='+
-                '&style=NORMAL'+
-                '&report='+
-                '&grid='+
-                '&searchid=118'+
-                '&dle=F';
-            
-            //window.location = "https://system.netsuite.com/app/reporting/reportrunner.nl?reporttype=REGISTER&acctid=" + id;
-            return;
-        }
-        // do stuff..
+        
         // we really just want to send a series of download requests..
         //https://system.netsuite.com/app/reporting/reportrunner.nl?reporttype=REGISTER&acctid=403
         
-        
-        
-        var chk = document.getElementById('lines');
-        console.log("lines element?");
-        console.log(chk)
-        console.log('checking form values');
-        
-        
-        if (chk.value !='T') {
-            console.log('SETTING VALUES:chk');
-            chk.value= 'T';
-            console.log('SETTING VALUES:daterange');
-            document.forms[0].daterange.value = 'CUSTOM';
-            console.log('SETTING VALUES:date1');
-            document.getElementById('date1').value = '1/1/2008';
-            console.log('SETTING VALUES:date2');
-            document.getElementById('date2').value = '1/1/2013';
-            console.log('SUBMIT');
-            document.forms[0].submit();
-            
-            return;
-        }
-        
-        console.log('form values - ok - checking if empty');
-        
-         if (   reportTable.oContentProvider.bRequestPending
-                || !reportTable.isInLoadedState()) {
-                console.log('report not ready?');
-                NS.timeout--;
-                if (NS.timeout < 0) {
-                    console.log('SENDING EMTPY..?');
-                    console.log(
-                         JSON.stringify ({
-                            requesturl : '',
-                            method: 'nsdownloadpage',
-                            filename : NS.id + '.csv',
-                            headers : '',
-                            contentType: '',
-                            data: []
-                        }));
-                    return;
-                    
-                    
-                }
-                
-                 window.setTimeout( function() {  NS.rungrab(id); } ,1000);
-                
-                return;
-                
-            }
-        console.log('no empty - trying download');
-            
-        var ar = document.forms[0].elements;
-        var data= {};
-        for(var i =0; i < ar.length; i++) {
-            var e = ar[i];
-            data[e.name] = e.value;
-        }
-        console.log(JSON.stringify(data));
-        console.log(reportTable.getTotalRowCount());
-         NS.downloaddata(
-            'https://system.netsuite.com/app/reporting/reportrunner.nl',
+         
+        NS.downloaddata(
+            'https://system.netsuite.com/app/common/search/searchresults.csv' +
+            '?searchtype=Transaction' + 
+            '&Transaction_ACCOUNT=' + id +
+            '&sortcol=Transaction_TRANDATE_raw' +
+            '&sortdir=ASC'+
+            '&csv=Export'+
+            '&OfficeXML=F'+
+            '&pdf='+
+            '&style=NORMAL'+
+            '&report='+
+            '&grid='+
+            '&searchid=118'+
+            '&dle=F',
             {
                 id: data.id,
                 reportaction: 'exportcsv',