first commit

This commit is contained in:
2026-10-29 13:34:31 +07:00
commit 45e4595c57
255 changed files with 35457 additions and 0 deletions
+148
View File
@@ -0,0 +1,148 @@
/*******************************************************************
PHP Class : /Controller/IndexController
Description : Halaman Utama Aplikasi / Index
Created By : Siau Pheng ([email protected]).
Created Date : May 24th, 2010.
Last Modified : August 29th, 2026.
(c) 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/
$(document).ready(() => {
$("#preloader").remove();
loadSidebar();
IndexJS.index();
if (window.Desktop_Chart) clearInterval(window.Desktop_Chart);
window.Desktop_Chart = setInterval(() => {
if ($('#ChartB').length == 0) return false;
IndexJS.load_chart();
}, 600000);
// QZ Printer
$('#qzLaunch').click(() => launchQZ());
$('#qzStart').click(() => startConnection());
$('#qzStop').click(() => endConnection());
if ('undefined' !== typeof qz) startConnection();
});
var socket = io(window.location.host, { 'path': '/io' });
// PPOB
socket.on('ppob-data', (adata) => {
//console.log('reply ppob-data', adata);
if (Array.isArray(adata.prabayar) && adata.prabayar.length > 0){
$.each(adata.prabayar, (i, v) => {
if (v.Status == 4) PrabayarJS.proses_print(0, v.No_TX);
});
socket.emit('ppob-update', { 'UserID': FoniaJS.User.UID, 'CabID': FoniaJS.User.CabID });
} else socket.emit('ppob-done');
});
// SUPERVISI
socket.on('super-data', (adata) => {
//console.log('reply super-data', adata);
if ($('#divSuper').length === 0) socket.emit('super-done');
if (Array.isArray(adata.data)) {
var table = $('#divSuperTabel').DataTable();
table.clear();
table.rows.add(adata.data).draw();
}
});
var IndexJS = {
index: function(){
new Request({
url: 'index/index',
sendParam: [],
onSuccess: (ares) => {
$('#pageContent').html(ares.html);
$('#pageToolbarTop').html('');
$('#pageToolbarBot').html('');
FoniaJS.User.CabID = +ares.CabID || 0;
if (socket.active) socket.emit('ppob-check', { 'UserID': FoniaJS.User.UID, 'CabID': FoniaJS.User.CabID });
this.get_picture();
this.load_chart();
}
}).send();
},
get_picture: function(){
new Request({
url: 'system/profile/get_picture',
onSuccess: (ajson) => {
$('img.get-picture').attr('src', ajson.src);
}
}).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({
url: 'index/chart_sale',
onSuccess: (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({
url: 'index/chart_omzet',
onSuccess: (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({
url: 'index/table_stok',
onSuccess: (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); }
}
}
});
})
});
}