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 '&Transaction_DEPARTMENT=2' + // hk
135 '&sortcol=Transaction_TRANDATE_raw' +
149 //reportaction: 'exportcsv',
151 //visibleranges: '0,' + reportTable.getTotalRowCount()
164 rungrab : function (id) {
165 //NS.rungrabInventory(id);
166 NS.rungrabAccounts(id);
168 rungrabInventory : function(id)
173 var frameload = function()
180 console.log("document.location" + document.location);
182 if (!(window.location + '').match(/netsuite/)) {
184 window.location = "https://system.netsuite.com/app/reporting/reportrunner.nl?cr=425&customized=T&whence=";
188 // we really just want to send a series of download requests..
189 //https://system.netsuite.com/app/reporting/reportrunner.nl?reporttype=REGISTER&acctid=403
191 document.getElementById('filt1').style = '';
194 crit_4_displayField : '',
196 crit_2_from : '1/1/2007',
197 crit_2_to: '1/1/2014',
198 hddn_crit_32 :getDropdown(document.getElementById('inpt_crit_32')).valueArray[id],
199 inpt_crit_32 :getDropdown(document.getElementById('inpt_crit_32')).valueArray[id],
205 if (!NS.varscheck ) {
208 if (k == 'inpt_crit_32') {
209 continue; // this gets abbreivated..
213 var cur = document.getElementById(k).value;
215 console.log("Can not find " + k);
218 console.log("CUR : " + k + '=' + cur + ' ?= ' + set[k]);
220 console.log("DOE NOT MATCH?");
222 //document.forms.main_form.elements[k].value = set[k];
223 document.getElementById(k).value = set[k];
233 console.log('SUBMIT');
234 document.forms.main_form.submit();
239 console.log('form values - ok - checking if empty');
241 if ( reportTable.oContentProvider.bRequestPending
242 || !reportTable.isInLoadedState()) {
243 console.log('report not ready?');
245 if (NS.timeout < 0) {
246 console.log('SENDING EMTPY..?');
250 method: 'nsdownloadpage',
251 filename : NS.id + '.csv',
261 window.setTimeout( function() { NS.rungrab(id); } ,1000);
266 console.log('no empty - trying download');
270 console.log(reportTable.getTotalRowCount());
272 'https://system.netsuite.com/app/reporting/reportrunner.nl',
274 id: document.forms.main_form.elements.id.value,
275 reportaction: 'exportcsv',
277 visibleranges: '0,' + reportTable.getTotalRowCount()
291 downloadgetdata : function (url,data) {
294 var xmlhttp = new XMLHttpRequest();
296 xmlhttp.open("GET", url,true);
297 xmlhttp.responseType = 'arraybuffer';
298 //xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
300 //for(var i in data) {
301 // kv.push(i +'=' + encodeURIComponent( data[i]));
305 xmlhttp.onload=function() {
309 var r = new Uint8Array(xmlhttp.response);
310 for (i=0;i<r.byteLength;i++) {
314 // location name for location download.
315 var pref = data.pref;
320 method: 'nsdownloadpage',
321 filename : pref+ '-' + NS.id + '.csv',
322 headers : xmlhttp.getAllResponseHeaders(),
323 contentType:xmlhttp.getResponseHeader("Content-Type"),
327 if (data.pref == 'SG-Account') {
336 'https://system.netsuite.com/app/common/search/searchresults.csv' +
337 '?searchtype=Transaction' +
338 '&Transaction_ACCOUNT=' + data.id +
339 '&Transaction_DEPARTMENT=1' + // sg
340 '&sortcol=Transaction_TRANDATE_raw' +
354 //reportaction: 'exportcsv',
356 //visibleranges: '0,' + reportTable.getTotalRowCount()
371 downloaddata : function (url,data) {
374 var xmlhttp = new XMLHttpRequest();
376 xmlhttp.open("POST", url,true);
377 xmlhttp.responseType = 'arraybuffer';
378 xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
381 kv.push(i +'=' + encodeURIComponent( data[i]));
385 xmlhttp.onload=function() {
389 var r = new Uint8Array(xmlhttp.response);
390 for (i=0;i<r.byteLength;i++) {
394 // location name for location download.
396 if (document.getElementById('hddn_crit_32')) {
398 pref = document.getElementById('hddn_crit_32').value ;
401 pref = document.getElementsByClassName('pt_title')[0].innerText.replace(/\s+$/,'').replace(/\//g, '');
407 method: 'nsdownloadpage',
408 filename : pref+ '-' + NS.id + '.csv',
409 headers : xmlhttp.getAllResponseHeaders(),
410 contentType:xmlhttp.getResponseHeader("Content-Type"),
416 xmlhttp.send(kv.join('&'));
419 login : function(u,p,id)
423 document.forms[0].email.value = u;
424 document.forms[0].password.value = p;
428 document.forms[0].elements['jsenabled'].value = 'T';
429 setLoginCookie(document.forms[0].elements['rememberme'].checked);
431 document.forms[0].submit();