6 rungrabAccounts : function(id)
11 var frameload = function()
18 console.log("document.location" + document.location);
20 if (!(window.location + '').match(/netsuite/)) {
22 window.location = "https://system.netsuite.com/app/reporting/reportrunner.nl?reporttype=REGISTER&acctid=" + id;
26 // we really just want to send a series of download requests..
27 //https://system.netsuite.com/app/reporting/reportrunner.nl?reporttype=REGISTER&acctid=403
31 var chk = document.getElementById('lines');
32 console.log("lines element?");
34 console.log('checking form values');
37 if (chk.value !='T') {
38 console.log('SETTING VALUES:chk');
40 console.log('SETTING VALUES:daterange');
41 document.forms[0].daterange.value = 'CUSTOM';
42 console.log('SETTING VALUES:date1');
43 document.getElementById('date1').value = '1/1/2008';
44 console.log('SETTING VALUES:date2');
45 document.getElementById('date2').value = '1/1/2013';
46 console.log('SUBMIT');
47 document.forms[0].submit();
52 console.log('form values - ok - checking if empty');
54 if ( reportTable.oContentProvider.bRequestPending
55 || !reportTable.isInLoadedState()) {
56 console.log('report not ready?');
59 console.log('SENDING EMTPY..?');
63 method: 'nsdownloadpage',
64 filename : NS.id + '.csv',
74 window.setTimeout( function() { NS.rungrab(id); } ,1000);
79 console.log('no empty - trying download');
81 var ar = document.forms[0].elements;
83 for(var i =0; i < ar.length; i++) {
85 data[e.name] = e.value;
87 console.log(JSON.stringify(data));
88 console.log(reportTable.getTotalRowCount());
90 'https://system.netsuite.com/app/reporting/reportrunner.nl',
93 reportaction: 'exportcsv',
95 visibleranges: '0,' + reportTable.getTotalRowCount()
110 rungrabAccounts : function(id)
116 console.log("document.location= " + document.location);
118 if (!(window.location + '').match(/netsuite/)) {
120 console.log("REDIRECT");
121 window.location = "https://system.netsuite.com/app/reporting/reportrunner.nl?reporttype=REGISTER&acctid=52"; // empty account register..
126 // we really just want to send a series of download requests..
127 //https://system.netsuite.com/app/reporting/reportrunner.nl?reporttype=REGISTER&acctid=403
131 'https://system.netsuite.com/app/common/search/searchresults.csv' +
132 '?searchtype=Transaction' +
133 '&Transaction_ACCOUNT=' + id +
134 '&sortcol=Transaction_TRANDATE_raw' +
146 //reportaction: 'exportcsv',
148 //visibleranges: '0,' + reportTable.getTotalRowCount()
162 rungrab : function (id) {
163 //NS.rungrabInventory(id);
164 NS.rungrabAccounts(id);
166 rungrabInventory : function(id)
171 var frameload = function()
178 console.log("document.location" + document.location);
180 if (!(window.location + '').match(/netsuite/)) {
182 window.location = "https://system.netsuite.com/app/reporting/reportrunner.nl?cr=425&customized=T&whence=";
186 // we really just want to send a series of download requests..
187 //https://system.netsuite.com/app/reporting/reportrunner.nl?reporttype=REGISTER&acctid=403
189 document.getElementById('filt1').style = '';
192 crit_4_displayField : '',
194 crit_2_from : '1/1/2007',
195 crit_2_to: '1/1/2014',
196 hddn_crit_32 :getDropdown(document.getElementById('inpt_crit_32')).valueArray[id],
197 inpt_crit_32 :getDropdown(document.getElementById('inpt_crit_32')).valueArray[id],
203 if (!NS.varscheck ) {
206 if (k == 'inpt_crit_32') {
207 continue; // this gets abbreivated..
211 var cur = document.getElementById(k).value;
213 console.log("Can not find " + k);
216 console.log("CUR : " + k + '=' + cur + ' ?= ' + set[k]);
218 console.log("DOE NOT MATCH?");
220 //document.forms.main_form.elements[k].value = set[k];
221 document.getElementById(k).value = set[k];
231 console.log('SUBMIT');
232 document.forms.main_form.submit();
237 console.log('form values - ok - checking if empty');
239 if ( reportTable.oContentProvider.bRequestPending
240 || !reportTable.isInLoadedState()) {
241 console.log('report not ready?');
243 if (NS.timeout < 0) {
244 console.log('SENDING EMTPY..?');
248 method: 'nsdownloadpage',
249 filename : NS.id + '.csv',
259 window.setTimeout( function() { NS.rungrab(id); } ,1000);
264 console.log('no empty - trying download');
268 console.log(reportTable.getTotalRowCount());
270 'https://system.netsuite.com/app/reporting/reportrunner.nl',
272 id: document.forms.main_form.elements.id.value,
273 reportaction: 'exportcsv',
275 visibleranges: '0,' + reportTable.getTotalRowCount()
289 downloadgetdata : function (url,data) {
292 var xmlhttp = new XMLHttpRequest();
294 xmlhttp.open("GET", url,true);
295 xmlhttp.responseType = 'arraybuffer';
296 //xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
298 //for(var i in data) {
299 // kv.push(i +'=' + encodeURIComponent( data[i]));
303 xmlhttp.onload=function() {
307 var r = new Uint8Array(xmlhttp.response);
308 for (i=0;i<r.byteLength;i++) {
312 // location name for location download.
314 if (document.getElementById('hddn_crit_32')) {
316 pref = document.getElementById('hddn_crit_32').value ;
319 pref = document.getElementsByClassName('pt_title')[0].innerText.replace(/\s+$/,'').replace(/\//g, '');
325 method: 'nsdownloadpage',
326 filename : pref+ '-' + NS.id + '.csv',
327 headers : xmlhttp.getAllResponseHeaders(),
328 contentType:xmlhttp.getResponseHeader("Content-Type"),
340 downloaddata : function (url,data) {
343 var xmlhttp = new XMLHttpRequest();
345 xmlhttp.open("POST", url,true);
346 xmlhttp.responseType = 'arraybuffer';
347 xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
350 kv.push(i +'=' + encodeURIComponent( data[i]));
354 xmlhttp.onload=function() {
358 var r = new Uint8Array(xmlhttp.response);
359 for (i=0;i<r.byteLength;i++) {
363 // location name for location download.
365 if (document.getElementById('hddn_crit_32')) {
367 pref = document.getElementById('hddn_crit_32').value ;
370 pref = document.getElementsByClassName('pt_title')[0].innerText.replace(/\s+$/,'').replace(/\//g, '');
376 method: 'nsdownloadpage',
377 filename : pref+ '-' + NS.id + '.csv',
378 headers : xmlhttp.getAllResponseHeaders(),
379 contentType:xmlhttp.getResponseHeader("Content-Type"),
385 xmlhttp.send(kv.join('&'));
388 login : function(u,p,id)
392 document.forms[0].email.value = u;
393 document.forms[0].password.value = p;
397 document.forms[0].elements['jsenabled'].value = 'T';
398 setLoginCookie(document.forms[0].elements['rememberme'].checked);
400 document.forms[0].submit();