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()
161 rungrab : function (id) {
162 //NS.rungrabInventory(id);
163 NS.rungrabAccounts(id);
165 rungrabInventory : function(id)
170 var frameload = function()
177 console.log("document.location" + document.location);
179 if (!(window.location + '').match(/netsuite/)) {
181 window.location = "https://system.netsuite.com/app/reporting/reportrunner.nl?cr=425&customized=T&whence=";
185 // we really just want to send a series of download requests..
186 //https://system.netsuite.com/app/reporting/reportrunner.nl?reporttype=REGISTER&acctid=403
188 document.getElementById('filt1').style = '';
191 crit_4_displayField : '',
193 crit_2_from : '1/1/2007',
194 crit_2_to: '1/1/2014',
195 hddn_crit_32 :getDropdown(document.getElementById('inpt_crit_32')).valueArray[id],
196 inpt_crit_32 :getDropdown(document.getElementById('inpt_crit_32')).valueArray[id],
202 if (!NS.varscheck ) {
205 if (k == 'inpt_crit_32') {
206 continue; // this gets abbreivated..
210 var cur = document.getElementById(k).value;
212 console.log("Can not find " + k);
215 console.log("CUR : " + k + '=' + cur + ' ?= ' + set[k]);
217 console.log("DOE NOT MATCH?");
219 //document.forms.main_form.elements[k].value = set[k];
220 document.getElementById(k).value = set[k];
230 console.log('SUBMIT');
231 document.forms.main_form.submit();
236 console.log('form values - ok - checking if empty');
238 if ( reportTable.oContentProvider.bRequestPending
239 || !reportTable.isInLoadedState()) {
240 console.log('report not ready?');
242 if (NS.timeout < 0) {
243 console.log('SENDING EMTPY..?');
247 method: 'nsdownloadpage',
248 filename : NS.id + '.csv',
258 window.setTimeout( function() { NS.rungrab(id); } ,1000);
263 console.log('no empty - trying download');
267 console.log(reportTable.getTotalRowCount());
269 'https://system.netsuite.com/app/reporting/reportrunner.nl',
271 id: document.forms.main_form.elements.id.value,
272 reportaction: 'exportcsv',
274 visibleranges: '0,' + reportTable.getTotalRowCount()
288 downloadgetdata : function (url,data) {
291 var xmlhttp = new XMLHttpRequest();
293 xmlhttp.open("GET", url,true);
294 xmlhttp.responseType = 'arraybuffer';
295 //xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
297 //for(var i in data) {
298 // kv.push(i +'=' + encodeURIComponent( data[i]));
302 xmlhttp.onload=function() {
306 var r = new Uint8Array(xmlhttp.response);
307 for (i=0;i<r.byteLength;i++) {
311 // location name for location download.
312 var pref = 'HK-Account';
317 method: 'nsdownloadpage',
318 filename : pref+ '-' + NS.id + '.csv',
319 headers : xmlhttp.getAllResponseHeaders(),
320 contentType:xmlhttp.getResponseHeader("Content-Type"),
332 downloaddata : function (url,data) {
335 var xmlhttp = new XMLHttpRequest();
337 xmlhttp.open("POST", url,true);
338 xmlhttp.responseType = 'arraybuffer';
339 xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
342 kv.push(i +'=' + encodeURIComponent( data[i]));
346 xmlhttp.onload=function() {
350 var r = new Uint8Array(xmlhttp.response);
351 for (i=0;i<r.byteLength;i++) {
355 // location name for location download.
357 if (document.getElementById('hddn_crit_32')) {
359 pref = document.getElementById('hddn_crit_32').value ;
362 pref = document.getElementsByClassName('pt_title')[0].innerText.replace(/\s+$/,'').replace(/\//g, '');
368 method: 'nsdownloadpage',
369 filename : pref+ '-' + NS.id + '.csv',
370 headers : xmlhttp.getAllResponseHeaders(),
371 contentType:xmlhttp.getResponseHeader("Content-Type"),
377 xmlhttp.send(kv.join('&'));
380 login : function(u,p,id)
384 document.forms[0].email.value = u;
385 document.forms[0].password.value = p;
389 document.forms[0].elements['jsenabled'].value = 'T';
390 setLoginCookie(document.forms[0].elements['rememberme'].checked);
392 document.forms[0].submit();