// First Load ===================================================== function load_form_woowa_finance_report() { // menghitung woowa total jumlah & nominal ['woowa_jumlah', 'woowa_nominal', 'partner_jumlah', 'partner_nominal', 'real_income_jumlah', 'real_income_nominal'].forEach( el => { let el_input = document.querySelectorAll('#form_woowa_finance_report_input .'+el+'_input'); if (el_input !== null) { el_input.forEach(function(t) { t.addEventListener('change', function() { allvalue = 0; el_input.forEach(function(t) { allvalue += parseFloat((t.value == "") ? 0 : t.value); }); if (document.querySelector('#'+el+'_total') !== null) { document.querySelector('#'+el+'_total').value = allvalue; } }); }); } }); // set number to input document.querySelectorAll('.input_number').forEach(function(el) { el.addEventListener('keyup', function(th) { el.value= el.value.match(/\d+/); }); }); ajax_get_finose(); } // Button Click =================================================== function toggle_form_finose() { toggle_form = document.querySelectorAll('.toggle_form_finose.hide'); if (toggle_form.length > 0) { document.querySelectorAll('.toggle_form_finose')[0].classList.remove('hide'); } else { document.querySelectorAll('.toggle_form_finose')[0].classList.add('hide'); } } // Function ====================================================== function loading3(that){ that.innerHTML = ''; } // Ajax ========================================================== function ajax_get_kas_ditahan(that) { console.log('ajax.js > ajax_get_kas_ditahan'); prev_name = that.innerHTML; loading3(that); const data = JSON.stringify({ nav: 'get_kas_ditahan', tanggal: document.querySelector('#input_filter_kas_ditahan').value, token : localStorage.getItem('token'), }); fetch('route.php', { method: 'POST', headers: { 'Content-Type': 'application/json; charset=UTF-8', }, body: data, }).then(response => { if (response.ok) { response.text().then(response => { // console.log(response); console.log('route.php > class_woowa.php > get_kas_ditahan()'); document.querySelector('#result_area_woowa_kas_ditahan_input').innerHTML = response; that.innerHTML=prev_name; // let res_arr=JSON.parse(response); }); } }); } function ajax_save_finose(that){ console.log('ajax.js > ajax_save_finose'); prev_name = that.innerHTML; loading3(that); let form = document.querySelector('#form_woowa_finance_report_input'); const formEntries = new FormData(form).entries(); const input_data = Object.assign(...Array.from(formEntries, ([x,y]) => ({[x]:y}))); const data = JSON.stringify({ nav: 'save_finose', partner: document.getElementById('partner_header').value, form_data: input_data, token : localStorage.getItem('token'), }); fetch('route.php', { method: 'POST', headers: { 'Content-Type': 'application/json; charset=UTF-8', }, body: data, }).then(response => { if (response.ok) { response.text().then(response => { // let res_arr=JSON.parse(response); console.log(response); that.innerHTML=prev_name; if (response=='success') { document.querySelector('#form_woowa_finance_report_input').reset(); } }); } }); return false; } function ajax_get_finose(that=document.querySelector(`[onclick="ajax_get_finose(this)"]`)) { console.log('gufron.js.php > ajax_get_finose'); prev_name = that.innerHTML; loading3(that); const data = JSON.stringify({ nav: 'get_finose', tanggal: document.querySelector('#input_filter_finose').value, token : localStorage.getItem('token'), }); fetch('route.php', { method: 'POST', headers: { 'Content-Type': 'application/json; charset=UTF-8', }, body: data, }).then(response => { if (response.ok) { response.text().then(response => { // console.log(response); console.log('route_gufron.php > cashflow.php > get_finose()'); document.querySelector('#result_area_woowa_finance_report_input').innerHTML = response; that.innerHTML=prev_name; // let res_arr=JSON.parse(response); }); } }); } function ajax_timeline_product(that){ console.log("gufron.js.php > ajax_timeline_product()"); loading3(that); const data = JSON.stringify({ nav: 'get_timeline_product', product: document.querySelector('#form_timeline .product').value, dari: document.querySelector('#form_timeline .dari').value, sampai: document.querySelector('#form_timeline .sampai').value, partner: document.querySelector('#partner_header').value, token : localStorage.getItem('token'), }); fetch('route.php', { method: 'POST', headers: { 'Content-Type': 'application/json; charset=UTF-8', }, body: data, }).then(response => { if (response.ok) { response.text().then(response => { // console.log(response); console.log('route_gufron.php > timeline_development.php > get_timeline_product()'); document.querySelector('#result_area_timeline').innerHTML=response; that.innerHTML='Go'; }); } }); }