112 lines
4.0 KiB
JavaScript
112 lines
4.0 KiB
JavaScript
/*******************************************************************
|
|
|
|
Module : /apps/js/index.js
|
|
Desc. : JS - Halaman Utama Desktop
|
|
Created By : Siau Pheng ([email protected]).
|
|
Created Date : May 24th, 2010.
|
|
Last Modified : December 14th, 2025.
|
|
|
|
(c) 2010 - 2025, 3FONIA Software; WWW.3FONIA.COM.
|
|
|
|
*******************************************************************/
|
|
|
|
$(document).ready(function(){
|
|
jQuery("#preloader").remove();
|
|
loadSidebar();
|
|
IndexJS.loading();
|
|
setInterval(() => {
|
|
if ($('#ChartB').length > 0) IndexJS.load_chart();
|
|
}, 600000);
|
|
if ('undefined' !== typeof qz) launchQZ();
|
|
});
|
|
|
|
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.load_chart();
|
|
}.bind(this)
|
|
}).send();
|
|
},
|
|
|
|
load_chart: function(){
|
|
this.data_query('chart-sale');
|
|
this.data_query('chart-omzet');
|
|
this.data_query('tabel-stok');
|
|
},
|
|
|
|
data_query: function(tipe){
|
|
if (tipe=="chart-sale"){
|
|
new Request.JSON({
|
|
url: FoniaJS.WEB_PATH+'apps/php/index.php',
|
|
sendParam: ['data=chart-sale'],
|
|
onSuccess: function(ares){
|
|
if (ares.tipe=='chart') {
|
|
var ctx = Chart.getChart('ChartA');
|
|
if (typeof ctx !== 'undefined') ctx.destroy();
|
|
var myChart = new Chart($('#ChartA'), {
|
|
type: ares.chart.type,
|
|
data: ares.chart.data,
|
|
options: ares.chart.options
|
|
});
|
|
}
|
|
}
|
|
}).send();
|
|
} else if (tipe=="chart-omzet"){
|
|
new Request.JSON({
|
|
url: FoniaJS.WEB_PATH+'apps/php/index.php',
|
|
sendParam: ['data=chart-omzet'],
|
|
onSuccess: function(ares){
|
|
if (ares.tipe=='chart') {
|
|
var ctx = Chart.getChart('ChartB');
|
|
if (typeof ctx !== 'undefined') ctx.destroy();
|
|
var myChart = new Chart($('#ChartB'), {
|
|
type: ares.chart.type,
|
|
data: ares.chart.data,
|
|
options: ares.chart.options
|
|
});
|
|
}
|
|
}
|
|
}).send();
|
|
} else if (tipe=="tabel-stok"){
|
|
new Request.JSON({
|
|
url: FoniaJS.WEB_PATH+'apps/php/index.php',
|
|
sendParam: ['data=tabel-stok'],
|
|
onSuccess: function(ares){
|
|
if (ares.tipe=='tabel') {
|
|
$('#tabelStok').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); }
|
|
}
|
|
}
|
|
});
|
|
})
|
|
});
|
|
}
|