/******************************************************************* Module : /apps/js/index.js Desc. : JS - Halaman Utama Desktop Created By : Siau Pheng (siaupheng@3fonia.com). Created Date : May 24th, 2010. Last Modified : May 14th, 2024. (c) 2010 - 2024, 3FONIA Software; WWW.3FONIA.COM. *******************************************************************/ $(document).ready(function(){ jQuery("#preloader").remove(); loadSidebar(); IndexJS.loading(); }); var IndexJS = { loading: function(){ new Request.JSON({ url: FoniaJS.WEB_PATH+'apps/php/index.php', sendParam: ['data=default'], onSuccess: function(ares){ $('#pageContent').html(ares.content); $('#pageToolbarTop').html(''); $('#pageToolbarBot').html(''); this.loadChart1(); this.loadChart2(); this.periode_info(); }.bind(this) }).send(); }, periode_show: function(reset){ new Request.JSON({ url: FoniaJS.WEB_PATH+'apps/php/index.php', sendParam: ['data=periode-show','reset='+reset], onSuccess: (adata) => { if (!adata.aktif) this.winPeriode = FoniaJS.showWindow('Periode', 'Pilih Periode Data', adata.html, 'md', [{},{i:'butTutup'},{i:'butWSave',v:'Simpan',c:'success'}], () => { $('#winPeriode').find('#butWSave').click(() => IndexJS.periode_simpan()); }); } }).send(); }, periode_simpan: function(){ new Request.JSON({ url: FoniaJS.WEB_PATH+'apps/php/index.php', sendParam: ['data=periode-simpan','OPTION_THN','OPTION_BLN'], onSuccess: (adata) => { if (adata.sukses) FoniaJS.showInfo('Sukses Ganti Periode Data'); FoniaJS.closeWindow(IndexJS.winPeriode); setTimeout(() => {self.location = FoniaJS.WEB_PATH;}, 10); } }).send(); }, periode_info: function(){ new Request.JSON({ url: FoniaJS.WEB_PATH+'apps/php/index.php', sendParam: ['data=periode-info'], onSuccess: (ajson) => $('#liPeriode').html(ajson.html) }).send(); }, loadChart1: function(){ new Request.JSON({ url: FoniaJS.WEB_PATH+'apps/php/index.php', sendParam: ['data=chart1'], onSuccess: function(ares){ $('#divHome1').removeClass('text-center'); if (ares.tipe=='chart') { $('#divHome1').html('
'); var ctx = $('#canvasChart1'); var myChart = new Chart(ctx, { type: ares.chart.type, data: ares.chart.data, options: ares.chart.options }); } else { $('#divHome1').html(ares.html); } } }).send(); }, loadChart2: function(){ new Request.JSON({ url: FoniaJS.WEB_PATH+'apps/php/index.php', sendParam: ['data=chart2'], onSuccess: function(ares){ if (ares.tipe=='chart') { $('#divHome2').html(''); var ctx = $('#canvasChart2'); var myChart = new Chart(ctx, { type: ares.chart.type, data: ares.chart.data, options: ares.chart.options }); } else { $('#divHome2').html(ares.html); } } }).send(); } }; function loadSidebar(){ const mySidebar = document.getElementById('sidebarMain'); mySidebar.addEventListener('shown.bs.modal', () => { document.querySelectorAll('.sidebar .nav-link').forEach((element) => { element.addEventListener('click', (e) => { let nextEl = element.nextElementSibling, parentEl = element.parentElement; if (nextEl){ e.preventDefault(); let mycollapse = new bootstrap.Collapse(nextEl); if (nextEl.classList.contains('show')){ mycollapse.hide(); } else { mycollapse.show(); var opened_submenu = parentEl.parentElement.querySelector('.submenu.show'); if (opened_submenu){ new bootstrap.Collapse(opened_submenu); } } } }); }) }); }