upgrade first session to flightphp

This commit is contained in:
2026-08-19 17:22:07 +07:00
parent 36395c2b55
commit 27ebdca49b
31 changed files with 1383 additions and 7659 deletions
+142 -103
View File
@@ -17,7 +17,6 @@ var FoniaJS = {
APP_ID: 0,
APP_SID: "",
WEB_HOST: "",
WEB_PATH: "",
WEB_FULLPATH: "",
WEB_MOBILE: 0,
AUTH_LEVEL: 9,
@@ -35,11 +34,10 @@ var FoniaJS = {
this.APP_ID = _adata[0];
this.APP_SID = _adata[1];
this.WEB_HOST = _adata[2];
this.WEB_PATH = _adata[3];
this.WEB_FULLPATH = _adata[4];
this.WEB_MOBILE = _adata[5];
this.AUTH_LEVEL = parseInt(_adata[6]);
this.phpversion = _adata[7];
this.WEB_FULLPATH = _adata[3];
this.WEB_MOBILE = _adata[4];
this.AUTH_LEVEL = parseInt(_adata[5]);
this.phpversion = '';
}
if (typeof(skey) === 'string' && skey !== '') {
_hasil = $.base64.decode(skey);
@@ -62,38 +60,36 @@ var FoniaJS = {
var apar = ["p=" + p];
if (q != null) apar.push("q=" + q);
new Request.JSON({
url: this.WEB_PATH + "auth.php",
url: "auth/menu",
sendParam: apar,
onSuccess: (apop) => {
if (apop.login == false) {
this.showErrorLocale("Fonia.sess_expire");
setTimeout(function(){self.location = FoniaJS.WEB_PATH;}, 1600);
setTimeout(() => { self.location = self.location.href; }, 1600);
return false;
}
if (apop.php == "" || !window[apop.func]) {
this.showErrorLocale("Fonia.page404");
return false;
}
window[apop.func]['PHP'] = this.WEB_PATH + "apps/php/" + apop.php;
window[apop.func]['PHP'] = apop.php;
window[apop.func]['KODE'] = apop.kode;
if (apop.iswindow == true) {
if (IndexJS.loading) IndexJS.loading();
new Request({
url: this.WEB_PATH + "apps/php/" + apop.php,
sendParam: ["data=default"],
onSuccess: (txt) => {
this.showWindow(apop.kode, apop.title, txt, apop.width, apop.button, function(){
new Request.JSON({
url: apop.php + '/index',
onSuccess: (ajson) => {
this.showWindow(apop.kode, apop.title, ajson.html, apop.width, apop.button, () => {
if (typeof window[apop.func]['loading'] === 'function') window[apop.func]['loading'](q);
});
}
}).send();
} else {
$("#pageToolbarBot").html(this.genToolButton(apop.button));
new Request({
url: this.WEB_PATH + "apps/php/" + apop.php,
sendParam: ["data=default"],
onSuccess: (txt) => {
$('#pageContent').html(txt);
new Request.JSON({
url: apop.php + '/index',
onSuccess: (ajson) => {
$('#pageContent').html(ajson.html);
if (typeof window[apop.func]['loading'] === 'function') window[apop.func]['loading'](q);
}
}).send();
@@ -122,13 +118,12 @@ var FoniaJS = {
if ($('#ExitLink').length) {
$('#ExitLink').click(() => {
new Request.JSON({
url: this.WEB_PATH + "apps/php/login.php",
sendParam: ["mode=logout"],
url: "auth/logout",
onFailure: () => {
self.location = (['localhost','127.0.0.1'].indexOf(location.hostname) >= 0) ? this.WEB_PATH : "/";
self.location = self.location.href;
},
onSuccess: (respon) => {
var _nurl = (['localhost','127.0.0.1'].indexOf(location.hostname) >= 0) ? this.WEB_PATH : "/";
var _nurl = self.location.href;
if (typeof respon !== 'undefined' && respon.nexthost !== '/') _nurl = respon.nexthost;
self.location = _nurl;
}
@@ -167,8 +162,8 @@ var FoniaJS = {
$('#butSOK').click(() => {
$('#butSOK').prop('disabled', true);
new Request.JSON({
url: this.WEB_PATH + "auth.php",
sendParam: ["mode=auth", "data=super-check", "UID", "PWD", "SUPER=" + _bsuper, "UOVER=" + _buover],
url: "auth/supervisi",
sendParam: ["data=super-check", "UID", "PWD", "SUPER=" + _bsuper, "UOVER=" + _buover],
onSuccess: (adata) => {
if (adata.status == 1) {
fungcall();
@@ -182,9 +177,9 @@ var FoniaJS = {
$('#butSBatal').click(() => {
if (_ceksuper) {
clearInterval(_ceksuper);
new Request({
url: this.WEB_PATH + "auth.php",
sendParam: ["mode=auth", "data=super-cancel", "KODE=" + ocall.KODE, "REQ_SID=" + this.APP_SID, "REQ=" + _tsid]
new Request.JSON({
url: "auth/supervisi",
sendParam: ["data=super-cancel", "KODE=" + ocall.KODE, "REQ_SID=" + this.APP_SID, "REQ=" + _tsid]
}).send();
}
});
@@ -194,26 +189,26 @@ var FoniaJS = {
$('#Auth_SP2').addClass('d-none');
$('#Auth_SP3').removeClass('d-none');
$('#butSOK').prop('disabled', true);
new Request({
url: this.WEB_PATH + "auth.php",
sendParam: ["mode=auth", "data=super-request", "KODE=" + ocall.KODE, "REQ_SID=" + this.APP_SID, "REQ=" + _tsid, "MSG=" + tmsg]
new Request.JSON({
url: "auth/supervisi",
sendParam: ["data=super-request", "KODE=" + ocall.KODE, "REQ_SID=" + this.APP_SID, "REQ=" + _tsid, "MSG=" + tmsg]
}).send();
var _cobalagi = 5;
_ceksuper = setInterval(() => {
$('#butSBatal').html(this.locale("Fonia.cancel") + " (" + _cobalagi + ")");
if (_cobalagi == 0) {
clearInterval(_ceksuper);
new Request({
url: this.WEB_PATH + "auth.php",
sendParam: ["mode=auth", "data=super-cancel", "KODE=" + ocall.KODE, "REQ_SID=" + this.APP_SID, "REQ=" + _tsid]
new Request.JSON({
url: "auth/supervisi",
sendParam: ["data=super-cancel", "KODE=" + ocall.KODE, "REQ_SID=" + this.APP_SID, "REQ=" + _tsid]
}).send();
this.closeWindow(this.winSAuth);
this.showErrorLocale("Fonia.auth_fail");
return false;
}
new Request.JSON({
url: this.WEB_PATH + "auth.php",
sendParam: ["mode=auth", "data=request-check", "KODE=" + ocall.KODE, "REQ_SID=" + this.APP_SID, "REQ=" + _tsid],
url: "auth/supervisi",
sendParam: ["data=request-check", "KODE=" + ocall.KODE, "REQ_SID=" + this.APP_SID, "REQ=" + _tsid],
onSuccess: (adata) => {
if (adata.status == 1) {
clearInterval(_ceksuper);
@@ -290,48 +285,91 @@ var FoniaJS = {
return smenu;
},
FormDecorated: function() {
$('input').each((i, el) => {
$('input.form-control[class*=integer], input.form-control[class*=angka]').each((i, el) => {
const elm = $(el);
// 16:shift 17:ctrl 18:alt 35:end 36:home 37:left 38:up 39:right 40:down 9:tab 13:enter 27:esc
// 8:backspace 46:delete 45:delete 48-57/96-105:num 110/190:dot 109/189/173:minus 107/187/61:plus
if (elm.hasClass('integer') || elm.hasClass('angka')) {
elm.keydown((e) => {
var key = e.keyCode ?? e.which;
return (jQuery.inArray(key,[8,9,13,46,110,190])!==-1 || (key>=16 && key<=18) || (key>=35 && key<=40) || (key>=48 && key<=57) || (key>=96 && key<=105));
});
} else if (elm.hasClass('number')) {
elm.keydown((e) => {
var key = e.keyCode ?? e.which;
return (jQuery.inArray(key,[8,9,13,46,110,190,109,189,173])!==-1 || (key>=16 && key<=18) || (key>=35 && key<=40) || (key>=48 && key<=57) || (key>=96 && key<=105));
});
elm.focus((e) => {
$(e.currentTarget).val( FoniaJS.StrToFloat($(e.currentTarget).val()) );
});
elm.blur((e) => {
$(e.currentTarget).val( FoniaJS.FloatToStr($(e.currentTarget).val(), 0) );
});
} else if (elm.hasClass('double')) {
elm.keydown((e) => {
var key = e.keyCode ?? e.which;
return (jQuery.inArray(key,[8,9,13,46,110,190,109,189,173])!==-1 || (key>=16 && key<=18) || (key>=35 && key<=40) || (key>=48 && key<=57) || (key>=96 && key<=105));
});
elm.focus((e) => {
$(e.currentTarget).val( FoniaJS.StrToFloat($(e.currentTarget).val()) );
$(e.currentTarget).select();
});
elm.blur((e) => {
$(e.currentTarget).val( FoniaJS.FloatToStr($(e.currentTarget).val(), 2) );
});
} else if (elm.hasClass('phone')) {
elm.keyup((e) => {
var key = e.keyCode ?? e.which;
return (jQuery.inArray(key,[8,9,13,46,110,190,109,189,173,107,187,61])!==-1 || (key>=16 && key<=18) || (key>=35 && key<=40) || (key>=48 && key<=57) || (key>=96 && key<=105));
});
} else if (elm.hasClass('error') && elm.val()) {
var tmp_str = elm.val();
elm.val('');
FoniaJS.showError(tmp_str);
}
elm.on('keypress keyup blur paste', (e) => {
elm.val(elm.val().replace(/[^\d].+/, ""));
if ((e.which < 48 || e.which > 57)) e.preventDefault();
});
});
$('input.form-control[class*=double]').each((i, el) => {
const elm = $(el);
elm.on('keypress keyup blur paste', (e) => {
elm.val(elm.val().replace(/[^0-9\.]/g,''));
if (e.type === 'blur') elm.val( FoniaJS.FloatToStr(elm.val(), 2) );
if ((e.which != 46 || elm.val().indexOf('.') != -1) && (e.which < 48 || e.which > 57)) e.preventDefault();
});
elm.on('focus', (e) => {
elm.val( FoniaJS.StrToFloat(elm.val()) );
elm.select();
e.preventDefault();
});
});
$('input.form-control[type=number]').each((i, el) => {
const elm = $(el);
elm.on('keypress keyup blur paste', (e) => {
elm.val(elm.val().replace(/[^0-9]/g,''));
if ((e.which != 46 || elm.val().indexOf('.') != -1) && (e.which < 48 || e.which > 57)) e.preventDefault();
});
});
$('input.form-control, textarea.form-control, select.form-select').each((i, el) => {
const elm = $(el);
const okyup = elm.attr('okyup') ?? '';
const oblur = elm.attr('oblur') ?? '';
const ochan = elm.attr('ochan') ?? '';
elm.on('keyup blur change', (e) => {
if (e.type === 'keyup' && okyup) {
var fnc = okyup.split('.');
if (typeof window[fnc[0]][fnc[1]] === 'function'){
window[fnc[0]][fnc[1]]();
} else console.warn('fungsi '+okyup+' tidak ada !');
}
if (e.type === 'blur' && oblur) {
var fnc = oblur.split('.');
if (typeof window[fnc[0]][fnc[1]] === 'function'){
window[fnc[0]][fnc[1]]();
} else console.warn('fungsi '+oblur+' tidak ada !');
}
if (e.type === 'change' && ochan) {
var fnc = ochan.split('.');
if (typeof window[fnc[0]][fnc[1]] === 'function'){
window[fnc[0]][fnc[1]]();
} else console.warn('fungsi '+ochan+' tidak ada !');
}
e.preventDefault();
});
});
$('input.form-check-input[type=radio]').each((i, el) => {
const elm = $(el);
elm.on('click', () => {
const oclic = elm.attr('ochan') ?? '';
const elp = $('#'+elm.attr('name'));
if (elm.is(':checked')) elp.val(elm.val());
if (oclic) {
var fnc = oclic.split('.');
if (typeof window[fnc[0]][fnc[1]] === 'function'){
window[fnc[0]][fnc[1]]();
} else console.warn('fungsi '+oclic+' tidak ada !');
}
});
});
$('input.form-check-input[type=checkbox]').each((i, el) => {
const elm = $(el);
elm.on('change', () => {
const odata = JSON.parse(elm.attr('odata') ?? '[]');
const ochan = elm.attr('ochan') ?? '';
elm.val(elm.is(':checked') ? odata[0] : odata[1]);
if (ochan) {
var fnc = ochan.split('.');
if (typeof window[fnc[0]][fnc[1]] === 'function'){
window[fnc[0]][fnc[1]]();
} else console.warn('fungsi '+ochan+' tidak ada !');
}
});
});
$('input[class*=error][type=hidden]').each((i, el) => {
const elm = $(el);
this.showError(elm.val());
});
$('.option-tags').each((i, el) => {
const elm = $(el);
@@ -345,7 +383,7 @@ var FoniaJS = {
});
$('[data-toggle="tooltip"]').tooltip();
if('function' == typeof jQuery.fn.datepicker){
$('.pickdate').datepicker({
$('.input-group.date').datepicker({
format: 'dd-mm-yyyy',
weekStart: 1,
language: 'id',
@@ -360,11 +398,6 @@ var FoniaJS = {
RequestParam: function(aparam) {
var tmp_hasil = [];
var tmp_array = aparam;
/*$('input').each((i, el) => {
if (el.id.indexOf('_db')!==-1){
tmp_array.push(el.id);
}
});*/
var tmp_cblist = {};
$('tbody input[id*="cbox"][type="checkbox"]:checked').map((i, b) => {
const arr = b.id.split('_');
@@ -387,15 +420,6 @@ var FoniaJS = {
} else {
tmp_value = ($('#'+nilai).is('.integer, .number, .double')) ? this.StrToFloat(tmp_value) : encodeURIComponent(tmp_value);
}
/*if ($('#'+nilai).hasClass("cgrpbox")) {//not used !
var _tmp_value = "";
$('input').each((i, el) => {
if (el.id.indexOf(nilai + "_cgrpbox")!==-1 && el.checked) {
_tmp_value += "," + el.value;
}
});
tmp_value = _tmp_value.substr(1);
}*/
}
tmp_value = nilai + "=" + tmp_value;
} else {
@@ -794,7 +818,7 @@ class _Request_JSONF extends _Request {
dataFilter: (data) => {
var json = {}, jsono = {'draw':0,'recordsTotal':0,'recordsFiltered':0,'data':[]};
try {
json = jQuery.parseJSON(data);
json = JSON.parse(data);
if (!jQuery.isEmptyObject(json) && json.length > 0){
$(json).each((i, lini) => {
if (lini.type == 'table-live' && lini.id == ini.id) {
@@ -841,7 +865,7 @@ class _Request_JSONF extends _Request {
}
/** end live db **/
if (ini.option.length > 0) opsi.columnDefs.push({responsivePriority:3,targets:-1}, {orderable:false,targets:-1});
if (ini.navi.func_navi == '') opsi.paging = false;
if (ini.navi.no_navi == true) opsi.paging = false;
if (ini.config.scrollbar == true) {
opsi.scrollY = ini.config.scroll_height;
@@ -858,12 +882,26 @@ class _Request_JSONF extends _Request {
}
_navibar += '<div class="row"><div class="col">';
$(ini.navi.button).map((key, val) => {
_navibar += '<button type="button" class="btn rounded-pill '+_bcss+' me-2"'+_dis+' onclick="'+val.func+'();">'+val.label+'</button>';
_navibar += '<button type="button" class="btn rounded-pill '+_bcss+' me-2 navi-btn-'+key+'"'+_dis+'>'+val.label+'</button>';
});
_navibar += '</div></div>';
}
opsi.initComplete = function(settings,json){
if (ini.navi.button) $('#'+ini.id+'Tabel_wrapper div.toolbar').html(_navibar);
if (ini.navi.button) {
$('#'+ini.id+'Tabel_wrapper div.toolbar').html(_navibar);
// apply navi button
if (ini.navi.button.length > 0){
$(ini.navi.button).map((key, val) => {
$('#'+ini.id+'Tabel_wrapper div.toolbar button[class*=navi-btn-'+key+']').on('click', (e) => {
e.preventDefault();
var fnc = val.func.split('.');
if (typeof window[fnc[0]][fnc[1]] === 'function'){
window[fnc[0]][fnc[1]]();
} else console.warn('fungsi '+val.func+' tidak ada !');
});
});
}
}
}
opsi.drawCallback = function(settings){
// apply rowcss to tr/row
@@ -908,16 +946,16 @@ class _Request_JSONF extends _Request {
$(ini.option).map((key, val) => {
if (val.type == 'checkbox'){
$('#'+ini.id+'Tabel thead input[type=checkbox][id*=_cbhead_]').on('change', (e) => {
var _chek = e.currentTarget.checked;
e.currentTarget.value = (e.currentTarget.checked ? val.avalue[0] : val.avalue[1]);
var _chek = e.currentTarget.is(':checked');
e.currentTarget.val(e.currentTarget.is(':checked') ? val.avalue[0] : val.avalue[1]);
$('#'+ini.id+'Tabel tbody input[type=checkbox][id*='+val.field+'_cbox_]').each((i, el) => {
el.checked = _chek;
el.value = (el.checked ? val.avalue[0] : val.avalue[1]);
el.prop('checked', _chek);
el.val(el.is(':checked') ? val.avalue[0] : val.avalue[1]);
});
});
$('#'+ini.id+'Tabel tbody input[type=checkbox][id*=_cbox_]').on('change', (e) => {
e.currentTarget.value = (e.currentTarget.value == val.avalue[1] ? val.avalue[0] : val.avalue[1]);
e.currentTarget.checked = e.currentTarget.value == val.avalue[0];
e.currentTarget.val(e.currentTarget.val() == val.avalue[1] ? val.avalue[0] : val.avalue[1]);
e.currentTarget.prop('checked', e.currentTarget.val() == val.avalue[0]);
});
} else if (val.type == 'button'){
$('#'+ini.id+'Tabel tbody').on('click', '.'+val.icon, (e) => {
@@ -971,6 +1009,7 @@ class _Request_JSONF extends _Request {
tr.addClass('dt-hasChild parent');
}
});
// disnini
}
var otabel = $('#'+ini.id+'Tabel').DataTable(opsi);
}
@@ -981,7 +1020,7 @@ var Request = function (options) {
};
Request.JSON = function (options) {
const _options = Object.assign({}, options, {'dataType':'json'});
const _options = Object.assign({}, options, { 'dataType': 'json' });
return new _Request(_options);
};