Compare commits
2
Commits
a2978ae927
...
bc95edbc0f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bc95edbc0f | ||
|
|
bd93cca382 |
+36
-30
@@ -4,7 +4,7 @@
|
|||||||
Desc. : JS - Fonia Custom Class v3
|
Desc. : JS - Fonia Custom Class v3
|
||||||
Created By : Siau Pheng ([email protected]).
|
Created By : Siau Pheng ([email protected]).
|
||||||
Created Date : June 19th, 2009.
|
Created Date : June 19th, 2009.
|
||||||
Last Modified : February 10th, 2026.
|
Last Modified : September 4th, 2026.
|
||||||
|
|
||||||
(c) 3FONIA Software; WWW.3FONIA.COM.
|
(c) 3FONIA Software; WWW.3FONIA.COM.
|
||||||
|
|
||||||
@@ -58,8 +58,8 @@ var FoniaJS = {
|
|||||||
},
|
},
|
||||||
callMenu: function(p, q) {
|
callMenu: function(p, q) {
|
||||||
var apar = ["p=" + p];
|
var apar = ["p=" + p];
|
||||||
if (q != null) apar.push("q=" + q);
|
if (q !== null) apar.push("q=" + q);
|
||||||
new Request.JSON({
|
new Request({
|
||||||
url: "auth/menu",
|
url: "auth/menu",
|
||||||
sendParam: apar,
|
sendParam: apar,
|
||||||
onSuccess: (apop) => {
|
onSuccess: (apop) => {
|
||||||
@@ -68,29 +68,29 @@ var FoniaJS = {
|
|||||||
setTimeout(() => { self.location = self.location.href; }, 1600);
|
setTimeout(() => { self.location = self.location.href; }, 1600);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (apop.php == "" || !window[apop.func]) {
|
if (apop.php === "" || !window[apop.func]) {
|
||||||
this.showErrorLocale("Fonia.page404");
|
this.showErrorLocale("Fonia.page404");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
window[apop.func]['PHP'] = apop.php;
|
window[apop.func]['PHP'] = apop.php;
|
||||||
window[apop.func]['KODE'] = apop.kode;
|
window[apop.func]['KODE'] = apop.kode;
|
||||||
if (apop.iswindow == true) {
|
if (apop.iswindow === true) {
|
||||||
if (IndexJS.loading) IndexJS.loading();
|
if (IndexJS.index) IndexJS.index();
|
||||||
new Request.JSON({
|
new Request({
|
||||||
url: apop.php + '/index',
|
url: apop.php + '/index',
|
||||||
onSuccess: (ajson) => {
|
onSuccess: (ajson) => {
|
||||||
this.showWindow(apop.kode, apop.title, ajson.html, apop.width, apop.button, () => {
|
this.showWindow(apop.kode, apop.title, ajson.html, apop.width, apop.button, () => {
|
||||||
if (typeof window[apop.func]['loading'] === 'function') window[apop.func]['loading'](q);
|
if (typeof window[apop.func]['index'] === 'function') window[apop.func]['index'](q);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}).send();
|
}).send();
|
||||||
} else {
|
} else {
|
||||||
$("#pageToolbarBot").html(this.genToolButton(apop.button));
|
$("#pageToolbarBot").html(this.genToolButton(apop.button));
|
||||||
new Request.JSON({
|
new Request({
|
||||||
url: apop.php + '/index',
|
url: apop.php + '/index',
|
||||||
onSuccess: (ajson) => {
|
onSuccess: (ajson) => {
|
||||||
$('#pageContent').html(ajson.html);
|
$('#pageContent').html(ajson.html);
|
||||||
if (typeof window[apop.func]['loading'] === 'function') window[apop.func]['loading'](q);
|
if (typeof window[apop.func]['index'] === 'function') window[apop.func]['index'](q);
|
||||||
}
|
}
|
||||||
}).send();
|
}).send();
|
||||||
}
|
}
|
||||||
@@ -112,12 +112,12 @@ var FoniaJS = {
|
|||||||
if ($('#HomeLink').length){
|
if ($('#HomeLink').length){
|
||||||
$('#HomeLink').click(() => {
|
$('#HomeLink').click(() => {
|
||||||
this.closeAllWindows();
|
this.closeAllWindows();
|
||||||
if (IndexJS.loading) IndexJS.loading();
|
if (IndexJS.index) IndexJS.index();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if ($('#ExitLink').length) {
|
if ($('#ExitLink').length) {
|
||||||
$('#ExitLink').click(() => {
|
$('#ExitLink').click(() => {
|
||||||
new Request.JSON({
|
new Request({
|
||||||
url: "auth/logout",
|
url: "auth/logout",
|
||||||
onFailure: () => {
|
onFailure: () => {
|
||||||
self.location = self.location.href;
|
self.location = self.location.href;
|
||||||
@@ -157,11 +157,11 @@ var FoniaJS = {
|
|||||||
var _buover = (buserover == null) ? false : buserover;
|
var _buover = (buserover == null) ? false : buserover;
|
||||||
var _tsid = parseInt(Math.random() * 99999999);
|
var _tsid = parseInt(Math.random() * 99999999);
|
||||||
var _ceksuper = null;
|
var _ceksuper = null;
|
||||||
var _isi = new String('<div class="row mb-1" id="Auth_SP1"><div class="col-sm-6 col-lg-5">Username</div><div class="col-sm-6 col-lg-7"><input type="text" class="form-control" id="UID" name="UID" value="'+((_bsuper==false)?this.User.ID:'')+'" required="true"></div></div><div class="row mb-1" id="Auth_SP2"><div class="col-sm-6 col-lg-5">Password</div><div class="col-sm-6 col-lg-7"><input type="password" class="form-control" id="PWD" name="PWD" value="" required="true"></div></div><div class="row mb-1 d-none" id="Auth_SP3"><div class="col-12 text-center"><p>'+this.locale("Fonia.auth_wait_msg")+'</p></div></div><hr class="my-2"><div class="row mt-1"><div class="col-4"><button type="button" class="btn btn-outline-primary shadow-none" id="butSReq">Request</button></div><div class="col-8 text-end"><button type="button" class="btn btn-danger me-2" id="butSBatal" data-bs-dismiss="modal">Batal</button><button type="button" class="btn btn-success" id="butSOK">OK</button></div></div>');
|
var _isi = new String('<div class="row mb-1" id="Auth_SP1"><div class="col-sm-6 col-lg-5">Username</div><div class="col-sm-6 col-lg-7"><input type="text" class="form-control" id="UID" name="UID" value="'+((_bsuper===false)?this.User.ID:'')+'" required="true"></div></div><div class="row mb-1" id="Auth_SP2"><div class="col-sm-6 col-lg-5">Password</div><div class="col-sm-6 col-lg-7"><input type="password" class="form-control" id="PWD" name="PWD" value="" required="true"></div></div><div class="row mb-1 d-none" id="Auth_SP3"><div class="col-12 text-center"><p>'+this.locale("Fonia.auth_wait_msg")+'</p></div></div><hr class="my-2"><div class="row mt-1"><div class="col-4"><button type="button" class="btn btn-outline-primary shadow-none" id="butSReq">Request</button></div><div class="col-8 text-end"><button type="button" class="btn btn-danger me-2" id="butSBatal" data-bs-dismiss="modal">Batal</button><button type="button" class="btn btn-success" id="butSOK">OK</button></div></div>');
|
||||||
this.winSAuth = this.showWindow('SAuth', ((this.AUTH_LEVEL < 9 && _bsuper == true) ? this.locale("Fonia.auth_super") : this.locale("Fonia.auth_user")), _isi, 200, '', () => {
|
this.winSAuth = this.showWindow('SAuth', ((this.AUTH_LEVEL < 9 && _bsuper == true) ? this.locale("Fonia.auth_super") : this.locale("Fonia.auth_user")), _isi, 200, '', () => {
|
||||||
$('#butSOK').click(() => {
|
$('#butSOK').click(() => {
|
||||||
$('#butSOK').prop('disabled', true);
|
$('#butSOK').prop('disabled', true);
|
||||||
new Request.JSON({
|
new Request({
|
||||||
url: "auth/supervisi",
|
url: "auth/supervisi",
|
||||||
sendParam: ["data=super-check", "UID", "PWD", "SUPER=" + _bsuper, "UOVER=" + _buover],
|
sendParam: ["data=super-check", "UID", "PWD", "SUPER=" + _bsuper, "UOVER=" + _buover],
|
||||||
onSuccess: (adata) => {
|
onSuccess: (adata) => {
|
||||||
@@ -177,7 +177,7 @@ var FoniaJS = {
|
|||||||
$('#butSBatal').click(() => {
|
$('#butSBatal').click(() => {
|
||||||
if (_ceksuper) {
|
if (_ceksuper) {
|
||||||
clearInterval(_ceksuper);
|
clearInterval(_ceksuper);
|
||||||
new Request.JSON({
|
new Request({
|
||||||
url: "auth/supervisi",
|
url: "auth/supervisi",
|
||||||
sendParam: ["data=super-cancel", "KODE=" + ocall.KODE, "REQ_SID=" + this.APP_SID, "REQ=" + _tsid]
|
sendParam: ["data=super-cancel", "KODE=" + ocall.KODE, "REQ_SID=" + this.APP_SID, "REQ=" + _tsid]
|
||||||
}).send();
|
}).send();
|
||||||
@@ -189,16 +189,16 @@ var FoniaJS = {
|
|||||||
$('#Auth_SP2').addClass('d-none');
|
$('#Auth_SP2').addClass('d-none');
|
||||||
$('#Auth_SP3').removeClass('d-none');
|
$('#Auth_SP3').removeClass('d-none');
|
||||||
$('#butSOK').prop('disabled', true);
|
$('#butSOK').prop('disabled', true);
|
||||||
new Request.JSON({
|
new Request({
|
||||||
url: "auth/supervisi",
|
url: "auth/supervisi",
|
||||||
sendParam: ["data=super-request", "KODE=" + ocall.KODE, "REQ_SID=" + this.APP_SID, "REQ=" + _tsid, "MSG=" + tmsg]
|
sendParam: ["data=super-request", "KODE=" + ocall.KODE, "REQ_SID=" + this.APP_SID, "REQ=" + _tsid, "MSG=" + tmsg]
|
||||||
}).send();
|
}).send();
|
||||||
var _cobalagi = 5;
|
var _cobalagi = 5;
|
||||||
_ceksuper = setInterval(() => {
|
_ceksuper = setInterval(() => {
|
||||||
$('#butSBatal').html(this.locale("Fonia.cancel") + " (" + _cobalagi + ")");
|
$('#butSBatal').html(this.locale("Fonia.cancel") + " (" + _cobalagi + ")");
|
||||||
if (_cobalagi == 0) {
|
if (_cobalagi === 0) {
|
||||||
clearInterval(_ceksuper);
|
clearInterval(_ceksuper);
|
||||||
new Request.JSON({
|
new Request({
|
||||||
url: "auth/supervisi",
|
url: "auth/supervisi",
|
||||||
sendParam: ["data=super-cancel", "KODE=" + ocall.KODE, "REQ_SID=" + this.APP_SID, "REQ=" + _tsid]
|
sendParam: ["data=super-cancel", "KODE=" + ocall.KODE, "REQ_SID=" + this.APP_SID, "REQ=" + _tsid]
|
||||||
}).send();
|
}).send();
|
||||||
@@ -206,11 +206,11 @@ var FoniaJS = {
|
|||||||
this.showErrorLocale("Fonia.auth_fail");
|
this.showErrorLocale("Fonia.auth_fail");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
new Request.JSON({
|
new Request({
|
||||||
url: "auth/supervisi",
|
url: "auth/supervisi",
|
||||||
sendParam: ["data=request-check", "KODE=" + ocall.KODE, "REQ_SID=" + this.APP_SID, "REQ=" + _tsid],
|
sendParam: ["data=request-check", "KODE=" + ocall.KODE, "REQ_SID=" + this.APP_SID, "REQ=" + _tsid],
|
||||||
onSuccess: (adata) => {
|
onSuccess: (adata) => {
|
||||||
if (adata.status == 1) {
|
if (adata.status === 1) {
|
||||||
clearInterval(_ceksuper);
|
clearInterval(_ceksuper);
|
||||||
this.showInfoLocale("Fonia.auth_success");
|
this.showInfoLocale("Fonia.auth_success");
|
||||||
fungcall();
|
fungcall();
|
||||||
@@ -224,14 +224,14 @@ var FoniaJS = {
|
|||||||
});
|
});
|
||||||
$('#UID').keyup((e) => {
|
$('#UID').keyup((e) => {
|
||||||
if (-1!==$.inArray(e.which, [13,9])) {
|
if (-1!==$.inArray(e.which, [13,9])) {
|
||||||
if (e.currentTarget.value != '') $('#PWD').focus();
|
if (e.currentTarget.value !== '') $('#PWD').focus();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$('#PWD').keyup((e) => {
|
$('#PWD').keyup((e) => {
|
||||||
if (e.currentTarget.value == '') return false;
|
if (e.currentTarget.value === '') return false;
|
||||||
if (13 == e.which) $('#butSOK').trigger('click');
|
if (13 == e.which) $('#butSOK').trigger('click');
|
||||||
});
|
});
|
||||||
if (_bsuper == false) {
|
if (_bsuper === false) {
|
||||||
FoniaJS.setFocus("#PWD");
|
FoniaJS.setFocus("#PWD");
|
||||||
} else {
|
} else {
|
||||||
FoniaJS.setFocus("#UID");
|
FoniaJS.setFocus("#UID");
|
||||||
@@ -273,8 +273,7 @@ var FoniaJS = {
|
|||||||
} else {
|
} else {
|
||||||
if (atom.i == 'butTutup') { atom.v='Tutup', atom.c='danger', atom.d='' };
|
if (atom.i == 'butTutup') { atom.v='Tutup', atom.c='danger', atom.d='' };
|
||||||
if (atom.i == 'butBatal') { atom.v='Batal', atom.c='danger', atom.d='' };
|
if (atom.i == 'butBatal') { atom.v='Batal', atom.c='danger', atom.d='' };
|
||||||
var _xt = "";//(typeof atom?.d !== 'undefined') ? ' data-bs-dismiss="modal"' : '';
|
smenu += '<button type="button" class="btn btn-'+(atom?.c ?? 'info')+' mb-2 mb-sm-0'+ma+' col-10 col-sm-3" id="'+atom.i+'">' + atom.v + '</button>';
|
||||||
smenu += '<button type="button" class="btn btn-'+(atom?.c ?? 'info')+' mb-2 mb-sm-0'+ma+' col-10 col-sm-3" id="'+atom.i+'"'+_xt+'>' + atom.v + '</button>';
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
smenu += '</div></div>';
|
smenu += '</div></div>';
|
||||||
@@ -344,7 +343,7 @@ var FoniaJS = {
|
|||||||
elm.on('click', () => {
|
elm.on('click', () => {
|
||||||
const oclic = elm.attr('ochan') ?? '';
|
const oclic = elm.attr('ochan') ?? '';
|
||||||
const elp = $('#'+elm.attr('name'));
|
const elp = $('#'+elm.attr('name'));
|
||||||
if (elm.is(':checked')) elp.val(elm.val());
|
if (elp && elm.is(':checked')) elp.val(elm.val());
|
||||||
if (oclic) {
|
if (oclic) {
|
||||||
var fnc = oclic.split('.');
|
var fnc = oclic.split('.');
|
||||||
if (typeof window[fnc[0]][fnc[1]] === 'function'){
|
if (typeof window[fnc[0]][fnc[1]] === 'function'){
|
||||||
@@ -358,7 +357,7 @@ var FoniaJS = {
|
|||||||
elm.on('change', () => {
|
elm.on('change', () => {
|
||||||
const odata = JSON.parse(elm.attr('odata') ?? '[]');
|
const odata = JSON.parse(elm.attr('odata') ?? '[]');
|
||||||
const ochan = elm.attr('ochan') ?? '';
|
const ochan = elm.attr('ochan') ?? '';
|
||||||
elm.val(elm.is(':checked') ? odata[0] : odata[1]);
|
if (odata.length > 0) elm.val(elm.is(':checked') ? odata[0] : odata[1]);
|
||||||
if (ochan) {
|
if (ochan) {
|
||||||
var fnc = ochan.split('.');
|
var fnc = ochan.split('.');
|
||||||
if (typeof window[fnc[0]][fnc[1]] === 'function'){
|
if (typeof window[fnc[0]][fnc[1]] === 'function'){
|
||||||
@@ -505,7 +504,7 @@ var FoniaJS = {
|
|||||||
'<div class="modal-dialog modal-dialog-centered '+_ctipe+' modal-400" role="document">'+
|
'<div class="modal-dialog modal-dialog-centered '+_ctipe+' modal-400" role="document">'+
|
||||||
'<div class="modal-content">'+
|
'<div class="modal-content">'+
|
||||||
'<div class="modal-header"><h5 class="modal-title" id="winAPPConfLabel">'+str_judul+'</h5><button class="btn-close" type="button" data-bs-dismiss="modal" aria-label="Close"></button></div>'+
|
'<div class="modal-header"><h5 class="modal-title" id="winAPPConfLabel">'+str_judul+'</h5><button class="btn-close" type="button" data-bs-dismiss="modal" aria-label="Close"></button></div>'+
|
||||||
'<div class="modal-body text-center mh-100">'+str_isi+'</div>'+
|
'<div class="modal-body text-center text-break mh-100">'+str_isi+'</div>'+
|
||||||
'<div class="modal-footer"><button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Tidak</button><button type="button" class="btn '+_btipe+' ms-2" id="winConfirmY">Ya</button></div>'+
|
'<div class="modal-footer"><button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Tidak</button><button type="button" class="btn '+_btipe+' ms-2" id="winConfirmY">Ya</button></div>'+
|
||||||
'</div></div></div>';
|
'</div></div></div>';
|
||||||
if ($('#winAPPConf').length) $('#winAPPConf').modal('dispose').remove();
|
if ($('#winAPPConf').length) $('#winAPPConf').modal('dispose').remove();
|
||||||
@@ -641,7 +640,7 @@ class _Request {
|
|||||||
onSuccess: () => {},
|
onSuccess: () => {},
|
||||||
onFailure: () => {},
|
onFailure: () => {},
|
||||||
data: null,
|
data: null,
|
||||||
dataType: 'text'
|
dataType: 'json'
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(options) {
|
constructor(options) {
|
||||||
@@ -669,7 +668,7 @@ class _Request {
|
|||||||
|
|
||||||
class _Request_JSONF extends _Request {
|
class _Request_JSONF extends _Request {
|
||||||
constructor(options) {
|
constructor(options) {
|
||||||
const _options = Object.assign({}, options, {'dataType':'json'});
|
const _options = Object.assign({}, options);
|
||||||
_options.onSuccess = (data) => {
|
_options.onSuccess = (data) => {
|
||||||
if (data.length > 0) {
|
if (data.length > 0) {
|
||||||
$(data).each((i, ini) => {
|
$(data).each((i, ini) => {
|
||||||
@@ -1018,11 +1017,18 @@ var Request = function (options) {
|
|||||||
return new _Request(options);
|
return new _Request(options);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
Request.JSON = function (options) {
|
Request.JSON = function (options) {
|
||||||
const _options = Object.assign({}, options, { 'dataType': 'json' });
|
const _options = Object.assign({}, options, { 'dataType': 'json' });
|
||||||
return new _Request(_options);
|
return new _Request(_options);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Request.TEXT = function (options) {
|
||||||
|
const _options = Object.assign({}, options, { 'dataType': 'text' });
|
||||||
|
return new _Request(_options);
|
||||||
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
Request.JSONF = function(options){
|
Request.JSONF = function(options){
|
||||||
return new _Request_JSONF(options);
|
return new _Request_JSONF(options);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,6 @@
|
|||||||
"Webapp\\": "src/"
|
"Webapp\\": "src/"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"src/Function/Auth.php",
|
|
||||||
"src/Function/Misc.php"
|
"src/Function/Misc.php"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -2,10 +2,10 @@
|
|||||||
|
|
||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
|
|
||||||
Module : /Web/Auth.php
|
Module : /App/Auth.php
|
||||||
Created By : Siau Pheng (siaupheng@3fonia.com).
|
Created By : Siau Pheng (siaupheng@3fonia.com).
|
||||||
Created Date : March 16th, 2008.
|
Created Date : March 16th, 2008.
|
||||||
Last Modified : August 22nd, 2026.
|
Last Modified : September 10th, 2026.
|
||||||
|
|
||||||
(c) 3FONIA Software; WWW.3FONIA.COM.
|
(c) 3FONIA Software; WWW.3FONIA.COM.
|
||||||
|
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Webapp\Web;
|
namespace Webapp\App;
|
||||||
|
|
||||||
use \flight\Engine;
|
use \flight\Engine;
|
||||||
use \flight\Session;
|
use \flight\Session;
|
||||||
@@ -27,11 +27,11 @@ use \flight\database\SimplePdo;
|
|||||||
* @license MIT, https://www.3fonia.com
|
* @license MIT, https://www.3fonia.com
|
||||||
* @copyright Copyright (c) 2008-2026, Siau Pheng <siaupheng@3fonia.com>
|
* @copyright Copyright (c) 2008-2026, Siau Pheng <siaupheng@3fonia.com>
|
||||||
*
|
*
|
||||||
* @package Webapp\Web
|
* @package Webapp\App
|
||||||
*/
|
*/
|
||||||
|
|
||||||
final class Auth {
|
final class Auth {
|
||||||
private int $__id_reg = 0;
|
private int $id_reg = 0;
|
||||||
protected Engine $app;
|
protected Engine $app;
|
||||||
protected SimplePdo $db;
|
protected SimplePdo $db;
|
||||||
protected Session $session;
|
protected Session $session;
|
||||||
@@ -43,56 +43,60 @@ final class Auth {
|
|||||||
$this->app = $app;
|
$this->app = $app;
|
||||||
$this->db = $app->db();
|
$this->db = $app->db();
|
||||||
$this->session = $app->session();
|
$this->session = $app->session();
|
||||||
$this->__id_reg = (int)$this->session->get('__WEB_APP', ['REG_ID'=>0])['REG_ID'];
|
$this->id_reg = (int) $this->session->get('WEB_APP', ['REG_ID'=>0])['REG_ID'];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function set_id_reg(int|string $id = 0): void {
|
public function set_id_reg(int|string $id = 0): void {
|
||||||
if ($id > 0) $this->__id_reg = (int)$id;
|
if ((int) $id > 0) $this->id_reg = (int) $id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function user_check(string $user, string $pass): bool {
|
public function user_check(string $user, string $pass): bool {
|
||||||
$i_hasil = (int)$this->db->fetchField('SELECT COUNT(*) FROM app_operator WHERE Username=? AND Password=MD5(?) AND Aktif=1', [$user, $pass]);
|
$i_hasil = (int) $this->db->fetchField('SELECT COUNT(*) FROM app_operator WHERE Username=? AND Password=MD5(?) AND Aktif=1', [$user, $pass]);
|
||||||
return ($i_hasil > 0 ? true : false);
|
return ($i_hasil > 0 ? true : false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function user_data(string $user): array {
|
public function user_data(string $user): array {
|
||||||
$adata = $this->db->fetchRow('SELECT *,DECODE(Menu,?) Menu2 FROM app_operator WHERE Username=?', [$this->__id_reg, $user])->getData();
|
$adata = [ 'Grup_MenuID' => 0 ];
|
||||||
$adata['Menu'] = $adata['Menu2'];
|
$xdata = $this->db->fetchRow('SELECT *,DECODE(Menu,?) Menu2 FROM app_operator WHERE Username=?', [$this->id_reg, $user]);
|
||||||
unset($adata['Menu2']);
|
if ($xdata) {
|
||||||
|
$adata = $xdata->getData();
|
||||||
|
$adata['Menu'] = $adata['Menu2'];
|
||||||
|
unset($adata['Menu2'], $adata['Password']);
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($this->session->get('APP_TOKEN'))) {
|
if (empty($this->session->get('APP_TOKEN'))) {
|
||||||
$_token = $this->genToken(60);
|
$_token = $this->genToken(60);
|
||||||
$this->session->set('APP_TOKEN', $_token);
|
$this->session->set('APP_TOKEN', $_token);
|
||||||
$this->db->insert('app_token', [ 'Token' => $_token, 'UserID' => $adata['UserID'], 'IP' => $this->app->request()->ip ]);
|
$this->db->insert('app_token', [ 'Token' => $_token, 'UserID' => $adata['UserID'], 'IP' => $this->app->request()->ip ]);
|
||||||
}
|
}
|
||||||
if ((int)$adata['Grup_MenuID'] > 0) $adata['Menu_Grup'] = $this->user_allmenu((int)$adata['Grup_MenuID']);
|
if ((int) $adata['Grup_MenuID'] > 0) $adata['Menu_Grup'] = $this->user_allmenu((int) $adata['Grup_MenuID']);
|
||||||
$adata['UNIX'] = time();
|
$adata['UNIX'] = time();
|
||||||
$adata['LOCALE'] = $this->session->get('__WEB_APP', ['DEF_LOCALE'=>'id'])['DEF_LOCALE'];
|
$adata['LOCALE'] = $this->session->get('WEB_APP', ['DEF_LOCALE'=>'id'])['DEF_LOCALE'];
|
||||||
$adata['MENU_MODUL'] = [];
|
$adata['MENU_MODUL'] = [];
|
||||||
return $adata;
|
return $adata;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function gen_module_menu(): void {
|
public function gen_module_menu(): void {
|
||||||
$amodul = []; $aallow = []; $tallow = '';
|
$amodul = []; $aallow = []; $tallow = '';
|
||||||
if ($this->session->get('__WEB_APP', ['APP_MODULE'=>0])['APP_MODULE']) {
|
if ($this->session->get('WEB_APP', ['APP_MODULE'=>0])['APP_MODULE']) {
|
||||||
$tallow = $this->db->fetchField('SELECT Modul_Akses FROM app_menu_grup WHERE Grup_MenuID=?', [$this->session->get('__WEB_USER', ['Grup_MenuID'=>0])['Grup_MenuID']]);
|
$tallow = $this->db->fetchField('SELECT Modul_Akses FROM app_menu_grup WHERE Grup_MenuID=?', [$this->session->get('WEB_USER', ['Grup_MenuID'=>0])['Grup_MenuID']]);
|
||||||
$aallow = explode(",", $tallow);
|
$aallow = explode(",", $tallow);
|
||||||
|
|
||||||
if (count($aallow) > 0) {
|
if (count($aallow) > 0) {
|
||||||
$stat = $this->db->runQuery('SELECT * FROM (SELECT APP_MODULE,APP_PATH FROM app_config) A LEFT JOIN (SELECT Modul,Urut,Judul,Icon FROM app_menu WHERE Level=0) B ON (A.APP_MODULE=B.Modul) ORDER BY B.Urut');
|
$stat = $this->db->runQuery('SELECT * FROM (SELECT APP_MODULE,APP_PATH FROM app_config) A LEFT JOIN (SELECT Modul,Urut,Judul,Icon FROM app_menu WHERE Level=0) B ON (A.APP_MODULE=B.Modul) ORDER BY B.Urut');
|
||||||
while ($row = $stat->fetch()) {
|
while ($row = $stat->fetch()) {
|
||||||
if (!in_array($row['Modul'], $aallow) || $row['Modul']==$this->session->get('__WEB_APP')['APP_MODULE']) continue;
|
if (!in_array($row['Modul'], $aallow) || $row['Modul']==$this->session->get('WEB_APP')['APP_MODULE']) continue;
|
||||||
$amodul[] = $row;
|
$amodul[] = $row;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$auser = $this->session->get('__WEB_USER', []);
|
$auser = $this->session->get('WEB_USER', []);
|
||||||
$auser['MENU_MODUL'] = $amodul;
|
$auser['MENU_MODUL'] = $amodul;
|
||||||
$this->session->set('__WEB_USER', $auser);
|
$this->session->set('WEB_USER', $auser);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function user_allmenu(int $id_grup = 0): string {
|
public function user_allmenu(int $id_grup = 0): string {
|
||||||
$allmenu = $this->db->fetchField('SELECT DECODE(Menu,?) MenuX FROM app_menu_grup WHERE Grup_MenuID=?', [$this->__id_reg, $id_grup]);
|
$allmenu = $this->db->fetchField('SELECT DECODE(Menu,?) MenuX FROM app_menu_grup WHERE Grup_MenuID=?', [$this->id_reg, $id_grup]);
|
||||||
return $allmenu;
|
return $allmenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,7 +106,7 @@ final class Auth {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function user_log(): void {
|
public function user_log(): void {
|
||||||
$_user_id = $this->session->get('__WEB_USER')['UserID'] ?? 0;
|
$_user_id = $this->session->get('WEB_USER')['UserID'] ?? 0;
|
||||||
if ($_user_id === 0) return;
|
if ($_user_id === 0) return;
|
||||||
$a_hasil = $this->db->fetchRow('SELECT * FROM app_logs WHERE UserID=? ORDER BY Last_Date DESC LIMIT 1', [$_user_id])->getData();
|
$a_hasil = $this->db->fetchRow('SELECT * FROM app_logs WHERE UserID=? ORDER BY Last_Date DESC LIMIT 1', [$_user_id])->getData();
|
||||||
if (count($a_hasil) > 0) {
|
if (count($a_hasil) > 0) {
|
||||||
@@ -116,13 +120,13 @@ final class Auth {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function token_check(string $token): bool {
|
public function token_check(string $token): bool {
|
||||||
$hasil = (bool)$this->db->fetchField('SELECT 1 FROM app_token WHERE Token=?', [$token ?? $this->session->get('APP_TOKEN')]);
|
$hasil = (bool) $this->db->fetchField('SELECT 1 FROM app_token WHERE Token=?', [$token ?? $this->session->get('APP_TOKEN')]);
|
||||||
if ($hasil === true) $this->db->update('app_token', ['DateStamp' => 'NOW()'], 'Token=?', [$token ?? $this->session->get('APP_TOKEN')]);
|
if ($hasil === true) $this->db->runQuery('UPDATE app_token SET DateStamp=NOW() WHERE Token=?', [$token ?? $this->session->get('APP_TOKEN')]);
|
||||||
return $hasil;
|
return $hasil;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function token_update(): void {
|
public function token_update(): void {
|
||||||
$this->db->update('app_token', ['DateStamp' => 'NOW()'], 'Token=?', [$this->session->get('APP_TOKEN')]);
|
$this->db->runQuery('UPDATE app_token SET DateStamp=NOW() WHERE Token=?', [$this->session->get('APP_TOKEN')]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function redirect(string $appUrl): string {
|
public function redirect(string $appUrl): string {
|
||||||
@@ -2,10 +2,10 @@
|
|||||||
|
|
||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
|
|
||||||
Module : /Web/Register.php
|
Module : /App/Register.php
|
||||||
Created By : Siau Pheng (siaupheng@3fonia.com).
|
Created By : Siau Pheng (siaupheng@3fonia.com).
|
||||||
Created Date : November 23th, 2011.
|
Created Date : November 23th, 2011.
|
||||||
Last Modified : August 22nd, 2026.
|
Last Modified : September 10th, 2026.
|
||||||
|
|
||||||
(c) 3FONIA Software; WWW.3FONIA.COM.
|
(c) 3FONIA Software; WWW.3FONIA.COM.
|
||||||
|
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Webapp\Web;
|
namespace Webapp\App;
|
||||||
|
|
||||||
use \flight\Engine;
|
use \flight\Engine;
|
||||||
use \flight\Session;
|
use \flight\Session;
|
||||||
@@ -27,30 +27,30 @@ use \flight\database\SimplePdo;
|
|||||||
* @license MIT, https://www.3fonia.com
|
* @license MIT, https://www.3fonia.com
|
||||||
* @copyright Copyright (c) 2008-2026, Siau Pheng <siaupheng@3fonia.com>
|
* @copyright Copyright (c) 2008-2026, Siau Pheng <siaupheng@3fonia.com>
|
||||||
*
|
*
|
||||||
* @package Webapp\Web
|
* @package Webapp\App
|
||||||
*/
|
*/
|
||||||
|
|
||||||
final class Register {
|
final class Register {
|
||||||
public function __construct(){
|
public function __construct(){
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function reg_id(Session $session) {
|
public static function reg_id(Session $session): string {
|
||||||
$id = (string)$session->get('__WEB_APP', ['REG_ID'=>''])['REG_ID'];
|
$id = (string) $session->get('WEB_APP', ['REG_ID'=>''])['REG_ID'];
|
||||||
return (substr($id,0,3).".".substr($id,3,3).".".substr($id,6));
|
return (substr($id,0,3).".".substr($id,3,3).".".substr($id,6));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function reg_code(Session $session) {
|
public static function reg_code(Session $session): string {
|
||||||
$id = (string)$session->get('__WEB_APP', ['REG_CODE'=>''])['REG_CODE'];
|
$id = (string) $session->get('WEB_APP', ['REG_CODE'=>''])['REG_CODE'];
|
||||||
return (substr($id,0,6)."-".substr($id,6,5)."-".substr($id,11,5)."-".substr($id,16,5)."-".substr($id,21,5)."-".substr($id,26,6));
|
return (substr($id,0,6)."-".substr($id,6,5)."-".substr($id,11,5)."-".substr($id,16,5)."-".substr($id,21,5)."-".substr($id,26,6));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function reg_check(Session $session) {
|
public static function reg_check(Session $session): bool {
|
||||||
$webapp = $session->get('__WEB_APP');
|
$webapp = $session->get('WEB_APP');
|
||||||
return (bool)(isset($webapp['REG_STATUS']) && $webapp['REG_STATUS']) ?? false;
|
return (bool) (isset($webapp['REG_STATUS']) && $webapp['REG_STATUS']) ?? false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function reg_status(SimplePdo $db, array $apps) {
|
public static function reg_status(SimplePdo $db, array $apps): array {
|
||||||
$kode_db = (bool)$db->fetchField('SELECT UPPER(CONVERT(MD5(CONCAT(REG_YEAR,CONVERT(MD5(CONCAT(REG_ID,REG_NAME)) using latin1),REG_ID,REG_NAME)) using latin1))=REG_CODE FROM app_config WHERE REG_ID=?', [$apps['APP_CODE'] ?? '']);
|
$kode_db = (bool) $db->fetchField('SELECT UPPER(CONVERT(MD5(CONCAT(REG_YEAR,CONVERT(MD5(CONCAT(REG_ID,REG_NAME)) using latin1),REG_ID,REG_NAME)) using latin1))=REG_CODE FROM app_config WHERE REG_ID=?', [$apps['APP_CODE'] ?? '']);
|
||||||
return [ 'REG_STATUS' => $kode_db === true ];
|
return [ 'REG_STATUS' => $kode_db === true ];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
|
|
||||||
Module : /Web/Update.php
|
Module : /App/Update.php
|
||||||
Created By : Siau Pheng (siaupheng@3fonia.com).
|
Created By : Siau Pheng (siaupheng@3fonia.com).
|
||||||
Created Date : June 14th, 2013.
|
Created Date : June 14th, 2013.
|
||||||
Last Modified : August 22nd, 2026.
|
Last Modified : August 22nd, 2026.
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Webapp\Web;
|
namespace Webapp\App;
|
||||||
|
|
||||||
use \flight\Engine;
|
use \flight\Engine;
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ use \flight\Engine;
|
|||||||
* @license MIT, https://www.3fonia.com
|
* @license MIT, https://www.3fonia.com
|
||||||
* @copyright Copyright (c) 2008-2026, Siau Pheng <siaupheng@3fonia.com>
|
* @copyright Copyright (c) 2008-2026, Siau Pheng <siaupheng@3fonia.com>
|
||||||
*
|
*
|
||||||
* @package Webapp\Web
|
* @package Webapp\App
|
||||||
*/
|
*/
|
||||||
|
|
||||||
final class Update {
|
final class Update {
|
||||||
@@ -38,7 +38,7 @@ final class Update {
|
|||||||
*/
|
*/
|
||||||
public function __construct(Engine $app){
|
public function __construct(Engine $app){
|
||||||
$this->app = $app;
|
$this->app = $app;
|
||||||
$this->__conf = $app->session()->get('__WEB_APP');
|
$this->__conf = $app->session()->get('WEB_APP');
|
||||||
$this->current();
|
$this->current();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*******************************************************************
|
||||||
|
|
||||||
|
Module : /App/User.php
|
||||||
|
Created By : Siau Pheng (siaupheng@3fonia.com).
|
||||||
|
Created Date : September 10th, 2026.
|
||||||
|
Last Modified : September 10th, 2026.
|
||||||
|
|
||||||
|
(c) 3FONIA Software; WWW.3FONIA.COM.
|
||||||
|
|
||||||
|
*******************************************************************/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Webapp\App;
|
||||||
|
|
||||||
|
use \flight\Engine;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class User
|
||||||
|
*
|
||||||
|
* User & Role Class.
|
||||||
|
*
|
||||||
|
* @license MIT, https://www.3fonia.com
|
||||||
|
* @copyright Copyright (c) 2008-2026, Siau Pheng <siaupheng@3fonia.com>
|
||||||
|
*
|
||||||
|
* @package Webapp\App
|
||||||
|
*/
|
||||||
|
|
||||||
|
final class User {
|
||||||
|
private array $web_user;
|
||||||
|
protected Engine $app;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Engine $app
|
||||||
|
*/
|
||||||
|
public function __construct(Engine $app) {
|
||||||
|
$this->app = $app;
|
||||||
|
$this->web_user = (array) $app->session()->get('WEB_USER');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function logged(): bool {
|
||||||
|
return !empty($this->web_user);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function is_level(int $level = 9): bool {
|
||||||
|
if (($this->web_user['Level'] ?? 9) <= $level) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function not_level(int $level = 9): bool {
|
||||||
|
if (($this->web_user['Level'] ?? 9) !== $level) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function id(int $digit = 0): string|int {
|
||||||
|
$id_user = (int) $this->web_user['UserID'] ?? 0;
|
||||||
|
if ($digit > 0) return isi_nol($id_user, $digit);
|
||||||
|
return $id_user;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function username(): string {
|
||||||
|
return (string) $this->web_user['Username'] ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function level(): int {
|
||||||
|
return (int) $this->web_user['Level'] ?? 9;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function unix(): string {
|
||||||
|
return (string) $this->web_user['UNIX'] ?? '0';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function nama(): string {
|
||||||
|
return (string) $this->web_user['Nama'] ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+7
-10
@@ -37,7 +37,7 @@ final class SQL {
|
|||||||
private array $_awhere = [];
|
private array $_awhere = [];
|
||||||
protected Engine $app;
|
protected Engine $app;
|
||||||
protected SimplePdo $db;
|
protected SimplePdo $db;
|
||||||
protected array webuser;
|
protected array $webuser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Engine $app
|
* @param Engine $app
|
||||||
@@ -45,7 +45,7 @@ final class SQL {
|
|||||||
public function __construct(Engine $app){
|
public function __construct(Engine $app){
|
||||||
$this->app = $app;
|
$this->app = $app;
|
||||||
$this->db = $app->db();
|
$this->db = $app->db();
|
||||||
$this->webuser = $app->session()->get('__WEB_USER', ['UserID'=>0, 'UNIX'=>0]);
|
$this->webuser = $app->session()->get('WEB_USER', ['UserID'=>0, 'UNIX'=>0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//todo: deprecated
|
//todo: deprecated
|
||||||
@@ -57,20 +57,18 @@ final class SQL {
|
|||||||
$this->_ttable = $table;
|
$this->_ttable = $table;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function add_param(string $param = "", string|int|null $value = null, bool $nomor = false): void {
|
public function add_param(string $param = "", mixed $value = null, bool $nomor = false): void {
|
||||||
$req = Param::Get($param);
|
|
||||||
$this->_afield[] = [
|
$this->_afield[] = [
|
||||||
'field' => $param,
|
'field' => $param,
|
||||||
'value' => (is_null($value) && !empty($req)) ? $req : $value,
|
'value' => is_null($value) ? Param::Get($param) : $value,
|
||||||
'numbe' => $nomor,
|
'numbe' => $nomor,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function add_param_date(string $param = "", string|null $value = null): void {
|
public function add_param_date(string $param = "", string|null $value = null): void {
|
||||||
$req = Param::Get($param);
|
|
||||||
$this->_afield[] = [
|
$this->_afield[] = [
|
||||||
'field' => $param,
|
'field' => $param,
|
||||||
'value' => tgl_sql2str((is_null($value) && !empty($req)) ? $req : $value),
|
'value' => tgl_sql2str(is_null($value) ? Param::Get($param) : $value),
|
||||||
'numbe' => false,
|
'numbe' => false,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -115,11 +113,10 @@ final class SQL {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function add_where(string $field = "", string|int|null $value = null, bool $nomor = false): void {
|
public function add_where(string $field = "", mixed $value = null, bool $nomor = false): void {
|
||||||
$req = Param::Get($param);
|
|
||||||
$this->_awhere[] = [
|
$this->_awhere[] = [
|
||||||
'field' => $field,
|
'field' => $field,
|
||||||
'value' => (is_null($value) && !empty($req)) ? $req : $value,
|
'value' => is_null($value) ? Param::Get($field) : $value,
|
||||||
'numbe' => $nomor,
|
'numbe' => $nomor,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
+133
-75
@@ -5,7 +5,7 @@
|
|||||||
Module : /Data/Cache.php
|
Module : /Data/Cache.php
|
||||||
Created By : Siau Pheng (siaupheng@3fonia.com).
|
Created By : Siau Pheng (siaupheng@3fonia.com).
|
||||||
Created Date : March 16th, 2008.
|
Created Date : March 16th, 2008.
|
||||||
Last Modified : August 21st, 2026.
|
Last Modified : September 3rd, 2026.
|
||||||
|
|
||||||
(c) 3FONIA Software; WWW.3FONIA.COM.
|
(c) 3FONIA Software; WWW.3FONIA.COM.
|
||||||
|
|
||||||
@@ -17,6 +17,7 @@ namespace Webapp\Data;
|
|||||||
|
|
||||||
use \flight\Engine;
|
use \flight\Engine;
|
||||||
use \flight\Session;
|
use \flight\Session;
|
||||||
|
use \flight\database\SimplePdo;
|
||||||
use \FilesystemIterator;
|
use \FilesystemIterator;
|
||||||
use \MatthiasMullie\Minify;
|
use \MatthiasMullie\Minify;
|
||||||
use \SplFileInfo;
|
use \SplFileInfo;
|
||||||
@@ -33,16 +34,20 @@ use \SplFileInfo;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
final class Cache {
|
final class Cache {
|
||||||
private $__cachedir = "";
|
private string $cachedir;
|
||||||
private $__cssdir = "";
|
private string $cssdir;
|
||||||
private $__localedir = "";
|
private string $localedir;
|
||||||
private $__jsdir = "";
|
private string $jsdir;
|
||||||
private $__jsapp = "";
|
private string $jsapp;
|
||||||
private $__rootdir = "";
|
private string $rootdir;
|
||||||
private $__ini = [];
|
private array $ini;
|
||||||
|
private array $web_app;
|
||||||
|
private array $web_user;
|
||||||
|
private bool $is_login;
|
||||||
|
private bool $IS_DEV = false;
|
||||||
protected Engine $app;
|
protected Engine $app;
|
||||||
protected Session $session;
|
protected SimplePdo $db;
|
||||||
protected array $__asset = [];
|
protected array $asset = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Engine $app
|
* @param Engine $app
|
||||||
@@ -50,42 +55,50 @@ final class Cache {
|
|||||||
|
|
||||||
public function __construct(Engine $app) {
|
public function __construct(Engine $app) {
|
||||||
$this->app = $app;
|
$this->app = $app;
|
||||||
$this->session = $app->session();
|
$this->db = $app->db();
|
||||||
$rootdir = (defined('PROJECT_ROOT')) ? PROJECT_ROOT : $this->app->get('app.project_root');
|
$this->web_app = $app->session()->get('WEB_APP') ?? [];
|
||||||
$this->__cachedir = $rootdir . '/public/chunks/';
|
$this->web_user = $app->session()->get('WEB_USER') ?? [];
|
||||||
$this->__localedir = $rootdir . '/app/Scripts/locale/';
|
$this->is_login = (count($this->web_user) > 0);
|
||||||
$this->__jsapp = $rootdir . '/app/Scripts/';
|
|
||||||
$this->__cssdir = __DIR__ . '/../../assets/css/';
|
$rootdir = (defined('PROJECT_ROOT')) ? PROJECT_ROOT : $app->get('app.project_root');
|
||||||
$this->__jsdir = __DIR__ . '/../../assets/js/';
|
$this->cachedir = $rootdir . '/temp/cache/';
|
||||||
$this->__rootdir = $rootdir . '/';
|
$this->localedir = $rootdir . '/app/Scripts/locale/';
|
||||||
if (!is_dir($this->__cachedir)) mkdir($this->__cachedir, 0755, true);
|
$this->jsapp = $rootdir . '/app/Scripts/';
|
||||||
if (!file_exists($this->__cachedir . "cache.ini")) {
|
$this->cssdir = realpath(__DIR__ . '/../../assets/css') . '/';
|
||||||
$this->__ini = [
|
$this->jsdir = realpath(__DIR__ . '/../../assets/js') . '/';
|
||||||
'login' => [ 'stamp' => 0, 'css' => "", 'js' => "", 'app' => "", ],
|
$this->rootdir = $rootdir . '/';
|
||||||
'index' => [ 'stamp' => 0, 'css' => "", 'js' => "", 'app' => "", ],
|
if (!is_dir($this->cachedir)) mkdir($this->cachedir, 0755, true);
|
||||||
'display' => [ 'stamp' => 0, 'css' => "", 'js' => "", 'app' => "", ],
|
if (!file_exists($this->cachedir . "cache.ini")) {
|
||||||
|
$this->ini = [
|
||||||
|
'login' => [ 'css' => "", 'js' => "", 'app' => "", ],
|
||||||
|
'index' => [ 'css' => "", 'js' => "", 'app' => "", ],
|
||||||
|
'display' => [ 'css' => "", 'js' => "", 'app' => "", ],
|
||||||
];
|
];
|
||||||
$this->save_ini();
|
$this->save_ini();
|
||||||
} else $this->__ini = parse_ini_file($this->__cachedir . "cache.ini", true);
|
} else $this->ini = parse_ini_file($this->cachedir . "cache.ini", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function set_dev(bool $is_dev = false): void {
|
||||||
|
$this->IS_DEV = $is_dev;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function set_asset(array $asset = []): void {
|
public function set_asset(array $asset = []): void {
|
||||||
$this->__asset = $asset;
|
$this->asset = $asset;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function gen_file(string $mode = "index", string $type = "css"): array {
|
private function gen_file(string $mode = "index", string $type = "css"): array {
|
||||||
$itime = 0;
|
$itime = 0;
|
||||||
$afile = [];
|
$afile = [];
|
||||||
if ($type == "css") {
|
if ($type === "css") {
|
||||||
$_afile = array_unique($this->__asset['css'][$mode] ?? []);
|
$_afile = array_unique($this->asset['css'][$mode] ?? []);
|
||||||
foreach ($_afile as $__key => $val) {
|
foreach ($_afile as $__key => $val) {
|
||||||
if (!file_exists($this->__cssdir . $val)) continue;
|
if (!file_exists($this->cssdir . $val)) continue;
|
||||||
$_file = new SplFileInfo($this->__cssdir . $val);
|
$_file = new SplFileInfo($this->cssdir . $val);
|
||||||
$afile[] = $_file->getRealPath();
|
$afile[] = $_file->getRealPath();
|
||||||
$itime += $_file->getMTime();
|
$itime += $_file->getMTime();
|
||||||
}
|
}
|
||||||
if (is_dir($this->__rootdir . 'app/Styles/')) {
|
if (is_dir($this->rootdir . 'app/Styles/')) {
|
||||||
$iterator = new FilesystemIterator($this->__rootdir . 'app/Styles/', FilesystemIterator::SKIP_DOTS);
|
$iterator = new FilesystemIterator($this->rootdir . 'app/Styles/', FilesystemIterator::SKIP_DOTS);
|
||||||
foreach ($iterator as $_file) {
|
foreach ($iterator as $_file) {
|
||||||
if ($_file->isFile()) {
|
if ($_file->isFile()) {
|
||||||
$afile[] = $_file->getRealPath();
|
$afile[] = $_file->getRealPath();
|
||||||
@@ -93,18 +106,18 @@ final class Cache {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if ($type == "js") {
|
} else if ($type === "js") {
|
||||||
$_afile = array_unique($this->__asset['js'][$mode] ?? []);
|
$_afile = array_unique($this->asset['js'][$mode] ?? []);
|
||||||
foreach ($_afile as $__key => $val) {
|
foreach ($_afile as $__key => $val) {
|
||||||
if (!file_exists($this->__jsdir . $val)) continue;
|
if (!file_exists($this->jsdir . $val)) continue;
|
||||||
$_file = new SplFileInfo($this->__jsdir . $val);
|
$_file = new SplFileInfo($this->jsdir . $val);
|
||||||
$afile[] = $_file->getRealPath();
|
$afile[] = $_file->getRealPath();
|
||||||
$itime += $_file->getMTime();
|
$itime += $_file->getMTime();
|
||||||
}
|
}
|
||||||
// add locale file
|
// add locale file
|
||||||
$ljs = ($this->session->get('__WEB_USER')['LOCALE'] ?? $this->session->get('__WEB_APP')['DEF_LOCALE']).'.js';
|
$ljs = ($this->web_user['LOCALE'] ?? $this->web_app['DEF_LOCALE']).'.js';
|
||||||
if (is_dir($this->__localedir)) {
|
if (is_dir($this->localedir)) {
|
||||||
$iterator = new \FilesystemIterator($this->__localedir, \FilesystemIterator::SKIP_DOTS);
|
$iterator = new \FilesystemIterator($this->localedir, \FilesystemIterator::SKIP_DOTS);
|
||||||
foreach ($iterator as $_file) {
|
foreach ($iterator as $_file) {
|
||||||
if ($_file->isFile() && str_ends_with($_file->getFilename(), $ljs)) {
|
if ($_file->isFile() && str_ends_with($_file->getFilename(), $ljs)) {
|
||||||
$afile[] = $_file->getRealPath();
|
$afile[] = $_file->getRealPath();
|
||||||
@@ -112,25 +125,31 @@ final class Cache {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if ($type == "app") {
|
} else if ($type === "app") {
|
||||||
if ($mode === 'index') {
|
if (is_dir($this->jsapp)) {
|
||||||
if (is_dir($this->__jsapp)) {
|
if (file_exists($this->jsapp . $mode . '.js')) {
|
||||||
$dirIterator = new \RecursiveDirectoryIterator($this->__jsapp, \RecursiveDirectoryIterator::SKIP_DOTS);
|
$_file = new SplFileInfo($this->jsapp . $mode . '.js');
|
||||||
|
$afile[] = $_file->getRealPath();
|
||||||
|
$itime += $_file->getMTime();
|
||||||
|
}
|
||||||
|
if ($mode === 'index') {
|
||||||
|
$_ajs = ['system/profile', 'system/chpasswd'];
|
||||||
|
$amenu = array_values($this->web_user['Merge_Menu'] ?? []);
|
||||||
|
$_ops = $this->db->fetchColumn("SELECT Link FROM app_menu WHERE Kode IN (?) AND Link<>'' ORDER BY Kode", [$amenu]);
|
||||||
|
if ($_ops) $_ajs += $_ops;
|
||||||
|
|
||||||
|
$dirIterator = new \RecursiveDirectoryIterator($this->jsapp, \RecursiveDirectoryIterator::SKIP_DOTS);
|
||||||
$dirFilter = new \RecursiveCallbackFilterIterator($dirIterator, fn($curr, $key, $iter) => !($curr->isDir() && in_array($curr->getFilename(), ['locale'])));
|
$dirFilter = new \RecursiveCallbackFilterIterator($dirIterator, fn($curr, $key, $iter) => !($curr->isDir() && in_array($curr->getFilename(), ['locale'])));
|
||||||
$iterator = new \RecursiveIteratorIterator($dirFilter);
|
$iterator = new \RecursiveIteratorIterator($dirFilter);
|
||||||
foreach ($iterator as $_file) {
|
foreach ($iterator as $_file) {
|
||||||
if ($_file->isFile() && !in_array($_file->getFilename(), ['login.js','display.js'])) {
|
if ($_file->isFile() &&
|
||||||
|
!in_array($_file->getFilename(), ['login.js','index.js','display.js']) &&
|
||||||
|
array_any($_ajs, fn($js) => str_ends_with(str_replace(['_','\\'],['','/'],$_file->getRealPath()), $js.'.js'))) {
|
||||||
$afile[] = $_file->getRealPath();
|
$afile[] = $_file->getRealPath();
|
||||||
$itime += $_file->getMTime();
|
$itime += $_file->getMTime();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if (file_exists($this->__jsapp . $mode . '.js')) {
|
|
||||||
$_file = new SplFileInfo($this->__jsapp . $mode . '.js');
|
|
||||||
$afile[] = $_file->getRealPath();
|
|
||||||
$itime += $_file->getMTime();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return [ $afile, $itime ];
|
return [ $afile, $itime ];
|
||||||
@@ -139,8 +158,8 @@ final class Cache {
|
|||||||
private function create_cache(string $type = "css", array $afile = [], string $cachefile = ""): void {
|
private function create_cache(string $type = "css", array $afile = [], string $cachefile = ""): void {
|
||||||
$contents = ''; $smini = null;
|
$contents = ''; $smini = null;
|
||||||
$bpublic = ($this->app->request()->ip === '127.0.0.1') ? false : true;
|
$bpublic = ($this->app->request()->ip === '127.0.0.1') ? false : true;
|
||||||
if ($bpublic == true) {
|
if ($bpublic === true) {
|
||||||
if ($type=="css") {
|
if ($type === "css") {
|
||||||
$smini = new Minify\CSS;
|
$smini = new Minify\CSS;
|
||||||
} else {
|
} else {
|
||||||
$smini = new Minify\JS;
|
$smini = new Minify\JS;
|
||||||
@@ -148,7 +167,7 @@ final class Cache {
|
|||||||
}
|
}
|
||||||
foreach ($afile as $nfile) {
|
foreach ($afile as $nfile) {
|
||||||
if (file_exists($nfile)) {
|
if (file_exists($nfile)) {
|
||||||
if ($bpublic == true) {
|
if ($bpublic === true) {
|
||||||
$smini->add($nfile);
|
$smini->add($nfile);
|
||||||
} else {
|
} else {
|
||||||
$contents .= "\n". file_get_contents($nfile);
|
$contents .= "\n". file_get_contents($nfile);
|
||||||
@@ -156,61 +175,100 @@ final class Cache {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($bpublic) $contents = $smini->minify();
|
if ($bpublic) $contents = $smini->minify();
|
||||||
file_put_contents($this->__cachedir . $cachefile, $contents);
|
file_put_contents($this->cachedir . $cachefile, $contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function save_ini(): void {
|
private function save_ini(): void {
|
||||||
$content = "";
|
$content = "";
|
||||||
foreach ($this->__ini as $key => $elem) {
|
unset ($this->ini['index']['app']);
|
||||||
$content .= ($content==""?"":"\n"). "[".$key."]\n";
|
foreach ($this->ini as $key => $elem) {
|
||||||
|
$content .= ($content === ""?"" : "\n"). "[".$key."]\n";
|
||||||
foreach ($elem as $key2 => $elem2) {
|
foreach ($elem as $key2 => $elem2) {
|
||||||
if ($elem2=="") $content .= $key2." = \n";
|
if ($key)
|
||||||
|
if ($elem2 === "") $content .= $key2." = \n";
|
||||||
else $content .= $key2." = \"".$elem2."\"\n";
|
else $content .= $key2." = \"".$elem2."\"\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
file_put_contents($this->__cachedir . "cache.ini", $content);
|
file_put_contents($this->cachedir . "cache.ini", $content);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function Cache(string $mode = "index"): array {
|
public function Cache(string $mode = "index"): array {
|
||||||
|
if ($mode === 'index') {
|
||||||
|
$this->ini['index']['app'] = (string) $this->db->fetchField("SELECT JS FROM app_operator_profile WHERE UserID=?", [$this->web_user['UserID']]) ?? '';
|
||||||
|
$this->web_user['Merge_Menu'] = array_filter(array_unique(explode(",", $this->web_user['Menu_Grup'] .",". $this->web_user['Menu'])));
|
||||||
|
}
|
||||||
|
|
||||||
$is_modif = false;
|
$is_modif = false;
|
||||||
foreach (['css','js','app'] as $type) {
|
foreach (['css','js','app'] as $type) {
|
||||||
[ $afile, $lastmod ] = $this->gen_file($mode, $type);
|
$is_index_app = ($mode === 'index' && $type === 'app');
|
||||||
$cachefile = md5($mode . $type . $lastmod) . ($type=='css'?'.css':'.js');
|
if (empty($this->ini[$mode][$type]) || !file_exists($this->cachedir . $this->ini[$mode][$type]) || ($this->IS_DEV)) {
|
||||||
if (!file_exists($this->__cachedir . $cachefile) || ((time()-(int)$this->__ini[$mode]['stamp']) > (86400*14))) {
|
[ $afile, $lastmod ] = $this->gen_file($mode, $type);
|
||||||
|
$cachefile = md5($mode . '-' . $type . '-' . $lastmod) . ($type === 'css' ? '.css' : '.js');
|
||||||
|
if ($is_index_app) $cachefile = md5('index-app-' . (string) $this->web_user['UserID'] . $lastmod) . '.js';
|
||||||
$this->create_cache($type, $afile, $cachefile);
|
$this->create_cache($type, $afile, $cachefile);
|
||||||
$this->__ini[$mode][$type] = $cachefile;
|
$this->ini[$mode][$type] = $cachefile;
|
||||||
$this->__ini[$mode]['stamp'] = time();
|
if ($is_index_app) $this->db->runQuery("INSERT INTO app_operator_profile (UserID,JS) VALUES (?, ?) ON DUPLICATE KEY UPDATE JS=VALUES(JS)", [$this->web_user['UserID'], $cachefile]);
|
||||||
$is_modif = true;
|
$is_modif = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($is_modif === true) $this->save_ini();
|
|
||||||
$acache = [ 'CSS' => [], 'JS' => [], 'JSX' => [] ];
|
$acache = [ 'CSS' => [], 'JS' => [], 'JSX' => [] ];
|
||||||
foreach ($this->__ini[$mode] as $_type => $_file) {
|
foreach ($this->ini[$mode] as $_type => $_file) {
|
||||||
if ($_type == 'stamp') continue;
|
if (file_exists($this->cachedir . $_file)) {
|
||||||
if (file_exists($this->__cachedir . $_file)) {
|
|
||||||
if ($_type === 'css') {
|
if ($_type === 'css') {
|
||||||
$acache['CSS'][] = 'chunks/' . $_file;
|
$acache['CSS'][] = 'cache/' . $_file;
|
||||||
} else $acache['JS'][] = 'chunks/' . $_file;
|
} else $acache['JS'][] = 'cache/' . $_file;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ($is_modif === true) $this->save_ini();
|
||||||
|
|
||||||
$aoption = $this->session->get('__WEB_APP');
|
|
||||||
$auser = $this->session->get('__WEB_USER');
|
|
||||||
$nonce = $this->app->get('csp_nonce');
|
$nonce = $this->app->get('csp_nonce');
|
||||||
$islog = user_logged($this->session);
|
$_secret = $this->web_app['APP_CODE'] .";". $this->web_app['APP_SID'] .";". $this->app->request()->getVar('HTTP_HOST') .";". "http://".$this->app->request()->getVar('HTTP_HOST') .";". isMobile() .";". ($this->web_app['AUTH_LEVEL']?$this->web_app['AUTH_LEVEL']:0);
|
||||||
$_secret = $aoption['APP_CODE'] .";". $aoption['APP_SID'] .";". $this->app->request()->getVar('HTTP_HOST') .";". "http://".$this->app->request()->getVar('HTTP_HOST') .";". isMobile() .";". ($aoption['AUTH_LEVEL']?$aoption['AUTH_LEVEL']:0);
|
$_suser = ($this->is_login) ? $this->web_user['Username'] .";". $this->web_user['UserID'] .";". $this->web_user['Grup_MenuID'] .";". $this->web_user['Level'] : "nobody;999;999;9";
|
||||||
$_suser = ($islog) ? $auser['Username'] .";". $auser['UserID'] .";". $auser['Grup_MenuID'] .";". $auser['Level'] : "nobody;999;999;9";
|
|
||||||
|
|
||||||
$acache['JSX'][] = '<script nonce="'.$nonce.'" type="text/javascript">';
|
$acache['JSX'][] = '<script nonce="'.$nonce.'" type="text/javascript">';
|
||||||
$acache['JSX'][] = 'FoniaJS.setConfig("'.base64_encode($_secret).'", "'.base64_encode($_suser).'");';
|
$acache['JSX'][] = 'FoniaJS.setConfig("'.base64_encode($_secret).'", "'.base64_encode($_suser).'");';
|
||||||
$acache['JSX'][] = '$(document).ready(function(){';
|
$acache['JSX'][] = '$(document).ready(function(){';
|
||||||
if ($islog) $acache['JSX'][] = 'FoniaJS.loadMenu();';
|
if ($this->is_login) $acache['JSX'][] = 'FoniaJS.loadMenu();';
|
||||||
$acache['JSX'][] = '});';
|
$acache['JSX'][] = '});';
|
||||||
$acache['JSX'][] = '</script>';
|
$acache['JSX'][] = '</script>';
|
||||||
|
|
||||||
return $acache;
|
return $acache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function Make_Cache(array $amode = ['login', 'index', 'display']): array {
|
||||||
|
$is_modif = false;
|
||||||
|
foreach ($amode as $mode) {
|
||||||
|
foreach (['css','js','app'] as $type) {
|
||||||
|
if ($mode === 'index' && $type === 'app') continue;
|
||||||
|
if (empty($this->ini[$mode][$type]) || !file_exists($this->cachedir . $this->ini[$mode][$type])) {
|
||||||
|
[ $afile, $lastmod ] = $this->gen_file($mode, $type);
|
||||||
|
$cachefile = md5($mode . '-' . $type . '-' . $lastmod) . ($type === 'css' ? '.css' : '.js');
|
||||||
|
$this->create_cache($type, $afile, $cachefile);
|
||||||
|
$this->ini[$mode][$type] = $cachefile;
|
||||||
|
$is_modif = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($is_modif === true) $this->save_ini();
|
||||||
|
|
||||||
|
if (in_array('index', $amode)) {
|
||||||
|
$agrup = $this->db->fetchAll('SELECT Grup_MenuID,DECODE(Menu,?) Menu FROM app_menu_grup', [$this->web_app['PARENT_CODE']]);
|
||||||
|
$auser = $this->db->fetchAll("SELECT A.*,IFNULL(B.JS,'') JS FROM (SELECT UserID,Grup_MenuID,DECODE(Menu,?) Menu FROM app_operator) A LEFT JOIN app_operator_profile B ON (A.UserID=B.UserID)", [$this->web_app['PARENT_CODE']]);
|
||||||
|
foreach ($auser as $user) {
|
||||||
|
if (empty($user['JS']) || !file_exists($this->cachedir . $user['JS'])) {
|
||||||
|
$this->web_user['Merge_Menu'] = array_filter(array_unique(explode(",", $user['Menu'] .",". ($agrup[$user['Grup_MenuID']]['Menu'] ?? ''))));
|
||||||
|
|
||||||
|
[ $afile, $lastmod ] = $this->gen_file('index', 'app');
|
||||||
|
$cachefile = md5('index-app-' . (string) $user['UserID'] . $lastmod) . '.js';
|
||||||
|
$this->create_cache('app', $afile, $cachefile);
|
||||||
|
$this->db->runQuery("INSERT INTO app_operator_profile (UserID,JS) VALUES (?, ?) ON DUPLICATE KEY UPDATE JS=VALUES(JS)", [$user['UserID'], $cachefile]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return [ 'status' => 1, 'user_count' => count($auser) ];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
+2
-2
@@ -42,8 +42,8 @@ final class PDF {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public function __construct(Engine $app) {
|
public function __construct(Engine $app) {
|
||||||
$this->webapp = $app->session()->get('__WEB_APP', ['REG_NAME'=>'', 'APP_NAME'=>'', 'APP_VER'=>'']);
|
$this->webapp = $app->session()->get('WEB_APP', ['REG_NAME'=>'', 'APP_NAME'=>'', 'APP_VER'=>'']);
|
||||||
$this->webuser = $app->session()->get('__WEB_USER', ['UserID'=>0, 'Username'=>'']);
|
$this->webuser = $app->session()->get('WEB_USER', ['UserID'=>0, 'Username'=>'']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function add_field(string $nama, string|int $lebar=0, string $align="L", string $func="", int $kol=1): void {
|
public function add_field(string $nama, string|int $lebar=0, string $align="L", string $func="", int $kol=1): void {
|
||||||
|
|||||||
@@ -29,12 +29,12 @@ final class SimpleXLS {
|
|||||||
public function __construct($oprop=[]) {
|
public function __construct($oprop=[]) {
|
||||||
$this->__wbook = new \Shuchkin\SimpleXLSXGen();
|
$this->__wbook = new \Shuchkin\SimpleXLSXGen();
|
||||||
$this->__wbook
|
$this->__wbook
|
||||||
->setAuthor($_SESSION['__WEB_APP']['APP_NAME']." v".$_SESSION['__WEB_APP']['APP_VER'])
|
->setAuthor($_SESSION['WEB_APP']['APP_NAME']." v".$_SESSION['WEB_APP']['APP_VER'])
|
||||||
->setLastModifiedBy($_SESSION['__WEB_APP']['APP_NAME']." v".$_SESSION['__WEB_APP']['APP_VER'])
|
->setLastModifiedBy($_SESSION['WEB_APP']['APP_NAME']." v".$_SESSION['WEB_APP']['APP_VER'])
|
||||||
->setTitle($oprop['title'] ?? "")
|
->setTitle($oprop['title'] ?? "")
|
||||||
->setSubject($oprop['subject'] ?? $_SESSION['__WEB_APP']['REG_NAME'])
|
->setSubject($oprop['subject'] ?? $_SESSION['WEB_APP']['REG_NAME'])
|
||||||
->setDescription($oprop['desc'] ?? "")
|
->setDescription($oprop['desc'] ?? "")
|
||||||
->setCompany($_SESSION['__WEB_APP']['REG_NAME'])
|
->setCompany($_SESSION['WEB_APP']['REG_NAME'])
|
||||||
->setDefaultFont("Calibri")
|
->setDefaultFont("Calibri")
|
||||||
->setDefaultFontSize(11);
|
->setDefaultFontSize(11);
|
||||||
}
|
}
|
||||||
@@ -133,11 +133,11 @@ final class SimpleXLS {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function add_stamp($ctk_ke=1, $bnama=false) {
|
public function add_stamp($ctk_ke=1, $bnama=false) {
|
||||||
$this->__avalue[] = ["<i>".$_SESSION['__WEB_APP']['APP_NAME']."v".$_SESSION['__WEB_APP']['APP_VER'].date("\@ymd.His")."-".user_id(3).(($bnama==true)?"/".strtoupper(user_user()):"").(($ctk_ke>0)?"#".isi_nol($ctk_ke,2):"")."</i>"];
|
$this->__avalue[] = ["<i>".$_SESSION['WEB_APP']['APP_NAME']."v".$_SESSION['WEB_APP']['APP_VER'].date("\@ymd.His")."-".user_id(3).(($bnama==true)?"/".strtoupper(user_user()):"").(($ctk_ke>0)?"#".isi_nol($ctk_ke,2):"")."</i>"];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_stamp($ctk_ke=1, $bnama=false) {
|
public function get_stamp($ctk_ke=1, $bnama=false) {
|
||||||
return $_SESSION['__WEB_APP']['APP_NAME']."v".$_SESSION['__WEB_APP']['APP_VER'].date("\@ymd.His")."-".user_id(3).(($bnama==true)?"/".strtoupper(user_user()):"").(($ctk_ke>0)?"#".isi_nol($ctk_ke,2):"");
|
return $_SESSION['WEB_APP']['APP_NAME']."v".$_SESSION['WEB_APP']['APP_VER'].date("\@ymd.His")."-".user_id(3).(($bnama==true)?"/".strtoupper(user_user()):"").(($ctk_ke>0)?"#".isi_nol($ctk_ke,2):"");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function show_headers() {
|
public function show_headers() {
|
||||||
|
|||||||
+3
-3
@@ -38,12 +38,12 @@ final class XLS {
|
|||||||
$this->__tnamafile = $tnama_file;
|
$this->__tnamafile = $tnama_file;
|
||||||
$this->__wbook = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
$this->__wbook = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||||
$this->__wbook->getProperties()
|
$this->__wbook->getProperties()
|
||||||
->setCreator($_SESSION['__WEB_APP']['APP_NAME']." v".$_SESSION['__WEB_APP']['APP_VER'])
|
->setCreator($_SESSION['WEB_APP']['APP_NAME']." v".$_SESSION['WEB_APP']['APP_VER'])
|
||||||
->setLastModifiedBy($_SESSION['__WEB_APP']['APP_NAME']." v".$_SESSION['__WEB_APP']['APP_VER'])
|
->setLastModifiedBy($_SESSION['WEB_APP']['APP_NAME']." v".$_SESSION['WEB_APP']['APP_VER'])
|
||||||
->setTitle($oprop['title'] ?? "")
|
->setTitle($oprop['title'] ?? "")
|
||||||
->setSubject($oprop['subject'] ?? "")
|
->setSubject($oprop['subject'] ?? "")
|
||||||
->setDescription($oprop['desc'] ?? "")
|
->setDescription($oprop['desc'] ?? "")
|
||||||
->setCompany($_SESSION['__WEB_APP']['REG_NAME']);
|
->setCompany($_SESSION['WEB_APP']['REG_NAME']);
|
||||||
$this->__wsheet = $this->__wbook->getActiveSheet();
|
$this->__wsheet = $this->__wbook->getActiveSheet();
|
||||||
$this->__fhead = [
|
$this->__fhead = [
|
||||||
'font' => ['bold' => true],
|
'font' => ['bold' => true],
|
||||||
|
|||||||
@@ -1,63 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*******************************************************************
|
|
||||||
|
|
||||||
Module : /Function/Auth.php
|
|
||||||
Desc. : Fungsi Custom Auth
|
|
||||||
Created By : Siau Pheng (siaupheng@3fonia.com).
|
|
||||||
Created Date : January 27th, 2008.
|
|
||||||
Last Modified : January 21st, 2024.
|
|
||||||
|
|
||||||
(c) 3FONIA Software; WWW.3FONIA.COM.
|
|
||||||
|
|
||||||
*******************************************************************/
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
use \flight\Session;
|
|
||||||
|
|
||||||
if (!function_exists('user_level')) {
|
|
||||||
function user_level(Session $session, int $level = 9): bool {
|
|
||||||
if ($session->get('__WEB_USER', ['Level'=>9])['Level'] <= $level) return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!function_exists('user_level_not')) {
|
|
||||||
function user_level_not(Session $session, int $level = 9): bool {
|
|
||||||
if ($session->get('__WEB_USER', ['Level'=>9])['Level'] !== $level) return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!function_exists('user_logged')) {
|
|
||||||
function user_logged(Session $session): bool {
|
|
||||||
return !empty($session->get('__WEB_USER'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!function_exists('user_id')) {
|
|
||||||
function user_id(Session $session, int $digit = 0): string|int {
|
|
||||||
$id_user = (int)$session->get('__WEB_USER', ['UserID'=>0])['UserID'];
|
|
||||||
if ($digit > 0) return isi_nol($id_user, $digit);
|
|
||||||
return $id_user;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!function_exists('user_user')) {
|
|
||||||
function user_user(Session $session): string {
|
|
||||||
return (string)$session->get('__WEB_USER', ['Username'=>''])['Username'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!function_exists('user_unix')) {
|
|
||||||
function user_unix(Session $session): string {
|
|
||||||
return (string)$session->get('__WEB_USER', ['UNIX'=>'0'])['UNIX'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!function_exists('user_nama')) {
|
|
||||||
function user_nama(Session $session): string {
|
|
||||||
return (string)$session->get('__WEB_USER', ['Nama'=>''])['Nama'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -40,8 +40,8 @@ final class PrintHTML {
|
|||||||
* @param Engine $app
|
* @param Engine $app
|
||||||
*/
|
*/
|
||||||
public function __construct(Engine $app) {
|
public function __construct(Engine $app) {
|
||||||
$this->webapp = $app->session()->get('__WEB_APP', ['APP_NAME'=>'', 'APP_VER'=>'']);
|
$this->webapp = $app->session()->get('WEB_APP', ['APP_NAME'=>'', 'APP_VER'=>'']);
|
||||||
$this->webuser = $app->session()->get('__WEB_USER', ['UserID'=>0, 'Username'=>'']);
|
$this->webuser = $app->session()->get('WEB_USER', ['UserID'=>0, 'Username'=>'']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function set_css(string $style): void {
|
public function set_css(string $style): void {
|
||||||
|
|||||||
@@ -49,8 +49,8 @@ class PrintPOS {
|
|||||||
*/
|
*/
|
||||||
public function __construct(Engine $app) {
|
public function __construct(Engine $app) {
|
||||||
$this->app = $app;
|
$this->app = $app;
|
||||||
$this->webapp = $app->session()->get('__WEB_APP', ['APP_NAME'=>'', 'APP_VER'=>'']);
|
$this->webapp = $app->session()->get('WEB_APP', ['APP_NAME'=>'', 'APP_VER'=>'']);
|
||||||
$this->webuser = $app->session()->get('__WEB_USER', ['UserID'=>0, 'Username'=>'']);
|
$this->webuser = $app->session()->get('WEB_USER', ['UserID'=>0, 'Username'=>'']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function set_opendrawer(): void {
|
public function set_opendrawer(): void {
|
||||||
|
|||||||
@@ -50,8 +50,8 @@ class PrintRAW {
|
|||||||
*/
|
*/
|
||||||
public function __construct(Engine $app) {
|
public function __construct(Engine $app) {
|
||||||
$this->app = $app;
|
$this->app = $app;
|
||||||
$this->webapp = $app->session()->get('__WEB_APP', ['APP_NAME'=>'', 'APP_VER'=>'']);
|
$this->webapp = $app->session()->get('WEB_APP', ['APP_NAME'=>'', 'APP_VER'=>'']);
|
||||||
$this->webuser = $app->session()->get('__WEB_USER', ['UserID'=>0, 'Username'=>'']);
|
$this->webuser = $app->session()->get('WEB_USER', ['UserID'=>0, 'Username'=>'']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function set_opendrawer(): void {
|
public function set_opendrawer(): void {
|
||||||
|
|||||||
+18
-17
@@ -5,7 +5,7 @@
|
|||||||
Module : /Web/Form.php
|
Module : /Web/Form.php
|
||||||
Created By : Siau Pheng (siaupheng@3fonia.com).
|
Created By : Siau Pheng (siaupheng@3fonia.com).
|
||||||
Created Date : February 27th, 2008.
|
Created Date : February 27th, 2008.
|
||||||
Last Modified : August 22nd, 2026.
|
Last Modified : September 5th, 2026.
|
||||||
|
|
||||||
(c) 3FONIA Software; WWW.3FONIA.COM.
|
(c) 3FONIA Software; WWW.3FONIA.COM.
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ final class Form {
|
|||||||
|
|
||||||
public function option(string $label, string $field, mixed $value=null, bool $enable=true, bool $req=false, array $arr=[], ?string $help=null, ?string $change=null, bool $multi=false, bool $group=false): string {
|
public function option(string $label, string $field, mixed $value=null, bool $enable=true, bool $req=false, array $arr=[], ?string $help=null, ?string $change=null, bool $multi=false, bool $group=false): string {
|
||||||
$_opsi = '';
|
$_opsi = '';
|
||||||
if (!empty($change)) $_opsi .= ' ochan="'.$change.'"';
|
if (!empty($change)) $_opsi .= ' ochan="'.rtrim($change, '();').'"';
|
||||||
if ($enable===false) $_opsi .= ' disabled=true';
|
if ($enable===false) $_opsi .= ' disabled=true';
|
||||||
if ($req===true) $_opsi .= ' required=true';
|
if ($req===true) $_opsi .= ' required=true';
|
||||||
if ($multi===true) $_opsi .= ' multiple';
|
if ($multi===true) $_opsi .= ' multiple';
|
||||||
@@ -118,14 +118,14 @@ final class Form {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function option_ulevel(string $label, string $field, int $value=9, bool $enable=true, bool $req=false, ?string $help=null, ?string $change=null): string {
|
public function option_ulevel(string $label, string $field, int $value=9, bool $enable=true, bool $req=false, ?string $help=null, ?string $change=null): string {
|
||||||
return $this->option($label, $field, $value, $enable, $req, $this->session->get('__WEB_APP')['USER_LEVEL'], $help, $change);
|
return $this->option($label, $field, $value, $enable, $req, $this->session->get('WEB_APP')['USER_LEVEL'], $help, $change);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function radio(string $label, string $field, mixed $value=null, bool $enable=true, bool $req=false, array $arr=[], ?string $help=null, ?string $change=null): string {
|
public function radio(string $label, string $field, mixed $value=null, bool $enable=true, bool $req=false, array $arr=[], ?string $help=null, ?string $change=null): string {
|
||||||
$_val = array_values($arr);
|
$_val = array_keys($arr);
|
||||||
if (empty($value)) $value = $_val[0];
|
if (is_null($value)) $value = $_val[0];
|
||||||
$_opsi = '';
|
$_opsi = '';
|
||||||
if (!empty($change)) $_opsi .= ' ochan="'.$change.'"';
|
if (!empty($change)) $_opsi .= ' ochan="'.rtrim($change, '();').'"';
|
||||||
if ($enable===false) $_opsi .= ' disabled=true';
|
if ($enable===false) $_opsi .= ' disabled=true';
|
||||||
if ($req===true) $_opsi .= ' required=true';
|
if ($req===true) $_opsi .= ' required=true';
|
||||||
$tout = '<input type="hidden" id="'.$field.'" value="'.$value.'" />';
|
$tout = '<input type="hidden" id="'.$field.'" value="'.$value.'" />';
|
||||||
@@ -151,9 +151,9 @@ final class Form {
|
|||||||
|
|
||||||
public function checkbox(string $label, string $field, mixed $value=null, bool $enable=true, bool $req=false, array $arr=[], ?string $help=null, ?string $change=null): string {
|
public function checkbox(string $label, string $field, mixed $value=null, bool $enable=true, bool $req=false, array $arr=[], ?string $help=null, ?string $change=null): string {
|
||||||
$_val = array_values($arr);
|
$_val = array_values($arr);
|
||||||
if (empty($value)) $value = $_val[1];
|
if (is_null($value)) $value = $_val[0];
|
||||||
$_opsi = ' odata="'.htmlspecialchars(json_encode($arr)).'"';
|
$_opsi = ' odata="'.htmlspecialchars(json_encode($arr)).'"';
|
||||||
if (!empty($change)) $_opsi .= ' ochan="'.$change.'"';
|
if (!empty($change)) $_opsi .= ' ochan="'.rtrim($change, '();').'"';
|
||||||
if ($enable===false) $_opsi .= ' disabled=true';
|
if ($enable===false) $_opsi .= ' disabled=true';
|
||||||
if ($req===true) $_opsi .= ' required=true';
|
if ($req===true) $_opsi .= ' required=true';
|
||||||
$tout = '<div class="col-form-label form-check"><input type="checkbox" class="form-check-input" id="'.$field.'" name="'.$field.'" value="'.$value.'"'.$_opsi;
|
$tout = '<div class="col-form-label form-check"><input type="checkbox" class="form-check-input" id="'.$field.'" name="'.$field.'" value="'.$value.'"'.$_opsi;
|
||||||
@@ -165,9 +165,9 @@ final class Form {
|
|||||||
|
|
||||||
public function switch(string $label, string $field, mixed $value=null, bool $enable=true, bool $req=false, array $arr=[], ?string $help=null, ?string $change=null): string {
|
public function switch(string $label, string $field, mixed $value=null, bool $enable=true, bool $req=false, array $arr=[], ?string $help=null, ?string $change=null): string {
|
||||||
$_val = array_values($arr);
|
$_val = array_values($arr);
|
||||||
if (empty($value)) $value = $_val[1];
|
if (is_null($value)) $value = $_val[0];
|
||||||
$_opsi = ' odata="'.htmlspecialchars(json_encode($arr)).'"';
|
$_opsi = ' odata="'.htmlspecialchars(json_encode($arr)).'"';
|
||||||
if (!empty($change)) $_opsi .= ' ochan="'.$change.'"';
|
if (!empty($change)) $_opsi .= ' ochan="'.rtrim($change, '();').'"';
|
||||||
if ($enable===false) $_opsi .= ' disabled=true';
|
if ($enable===false) $_opsi .= ' disabled=true';
|
||||||
if ($req===true) $_opsi .= ' required=true';
|
if ($req===true) $_opsi .= ' required=true';
|
||||||
$tout = '<div class="col-form-label form-check form-switch"><input class="form-check-input" id="'.$field.'" name="'.$field.'" type="checkbox" role="switch" value="'.$value.'"'.$_opsi;
|
$tout = '<div class="col-form-label form-check form-switch"><input class="form-check-input" id="'.$field.'" name="'.$field.'" type="checkbox" role="switch" value="'.$value.'"'.$_opsi;
|
||||||
@@ -179,8 +179,8 @@ final class Form {
|
|||||||
|
|
||||||
public function textbox(string $label, string $field, mixed $value=null, bool $enable=true, bool $req=false, string $type="text", ?string $holdtxt=null, ?int $maxsize=null, ?string $help=null, ?string $keyup=null, ?string $blur=null): string {
|
public function textbox(string $label, string $field, mixed $value=null, bool $enable=true, bool $req=false, string $type="text", ?string $holdtxt=null, ?int $maxsize=null, ?string $help=null, ?string $keyup=null, ?string $blur=null): string {
|
||||||
$_opsi = '';
|
$_opsi = '';
|
||||||
if (!empty($keyup)) $_opsi .= ' okyup="'.$keyup.'"';
|
if (!empty($keyup)) $_opsi .= ' okyup="'.rtrim($keyup, '();').'"';
|
||||||
if (!empty($blur)) $_opsi .= ' oblur="'.$blur.'"';
|
if (!empty($blur)) $_opsi .= ' oblur="'.rtrim($blur, '();').'"';
|
||||||
if (!empty($holdtxt)) $_opsi .= ' placeholder="'.$holdtxt.'"';
|
if (!empty($holdtxt)) $_opsi .= ' placeholder="'.$holdtxt.'"';
|
||||||
if (!empty($maxsize)) $_opsi .= ' maxlength="'.$maxsize.'"';
|
if (!empty($maxsize)) $_opsi .= ' maxlength="'.$maxsize.'"';
|
||||||
if ($enable===false) $_opsi .= ' readonly';
|
if ($enable===false) $_opsi .= ' readonly';
|
||||||
@@ -196,8 +196,9 @@ final class Form {
|
|||||||
return $tout;
|
return $tout;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function textauto(string $label, string $field, array $avalue=['value'=>0,'text'=>""], bool $enable=true, bool $req=false, ?string $holdtxt=null, ?int $maxsize=null, ?string $help=null): string {
|
public function textauto(string $label, string $field, array $avalue, bool $enable=true, bool $req=false, ?string $holdtxt=null, ?int $maxsize=null, ?string $help=null): string {
|
||||||
$_opsi = '';
|
$_opsi = '';
|
||||||
|
if (count($avalue) === 0) $avalue = [ 'value' => 0, 'text' => "" ];
|
||||||
if (!empty($holdtxt)) $_opsi .= ' placeholder="'.$holdtxt.'"';
|
if (!empty($holdtxt)) $_opsi .= ' placeholder="'.$holdtxt.'"';
|
||||||
if (!empty($maxsize)) $_opsi .= ' maxlength="'.$maxsize.'"';
|
if (!empty($maxsize)) $_opsi .= ' maxlength="'.$maxsize.'"';
|
||||||
if ($enable===false) $_opsi .= ' disabled=true';
|
if ($enable===false) $_opsi .= ' disabled=true';
|
||||||
@@ -222,8 +223,8 @@ final class Form {
|
|||||||
|
|
||||||
public function textarea(string $label, string $field, ?string $value=null, bool $enable=true, bool $req=false, int $rows=1, ?string $holdtxt=null, ?string $help=null, ?string $keyup=null, ?string $blur=null): string {
|
public function textarea(string $label, string $field, ?string $value=null, bool $enable=true, bool $req=false, int $rows=1, ?string $holdtxt=null, ?string $help=null, ?string $keyup=null, ?string $blur=null): string {
|
||||||
$_opsi = '';
|
$_opsi = '';
|
||||||
if (!empty($keyup)) $_opsi .= ' okyup="'.$keyup.'"';
|
if (!empty($keyup)) $_opsi .= ' okyup="'.rtrim($keyup, '();').'"';
|
||||||
if (!empty($blur)) $_opsi .= ' oblur="'.$blur.'"';
|
if (!empty($blur)) $_opsi .= ' oblur="'.rtrim($blur, '();').'"';
|
||||||
if (!empty($holdtxt)) $_opsi .= ' placeholder="'.$holdtxt.'"';
|
if (!empty($holdtxt)) $_opsi .= ' placeholder="'.$holdtxt.'"';
|
||||||
if ($enable===false) $_opsi .= ' disabled=true';
|
if ($enable===false) $_opsi .= ' disabled=true';
|
||||||
if ($req===true) $_opsi .= ' required=true';
|
if ($req===true) $_opsi .= ' required=true';
|
||||||
@@ -244,7 +245,7 @@ final class Form {
|
|||||||
|
|
||||||
public function color(string $label, string $field, ?string $value=null, bool $enable=true, bool $req=false, ?string $help=null, ?string $change=null): string {
|
public function color(string $label, string $field, ?string $value=null, bool $enable=true, bool $req=false, ?string $help=null, ?string $change=null): string {
|
||||||
$_opsi = '';
|
$_opsi = '';
|
||||||
if (!empty($change)) $_opsi .= ' ochan="'.$change.'"';
|
if (!empty($change)) $_opsi .= ' ochan="'.rtrim($change, '();').'"';
|
||||||
if ($enable===false) $_opsi .= ' disabled=true';
|
if ($enable===false) $_opsi .= ' disabled=true';
|
||||||
if ($req===true) $_opsi .= ' required=true';
|
if ($req===true) $_opsi .= ' required=true';
|
||||||
$tout = '<input type="color" class="form-control form-control-color" id="'.$field.'" name="'.$field.'" value="'.$value.'"'.$_opsi.' />';
|
$tout = '<input type="color" class="form-control form-control-color" id="'.$field.'" name="'.$field.'" value="'.$value.'"'.$_opsi.' />';
|
||||||
@@ -267,7 +268,7 @@ final class Form {
|
|||||||
$col_right = 'col-sm-' . (10-$lebar_kolom) . ' col-lg-' . (12-$lebar_kolom);
|
$col_right = 'col-sm-' . (10-$lebar_kolom) . ' col-lg-' . (12-$lebar_kolom);
|
||||||
$tres = '';
|
$tres = '';
|
||||||
foreach ($this->__aform as $_key => $_val) {
|
foreach ($this->__aform as $_key => $_val) {
|
||||||
$tres .= sprintf('<div class="row mb-1"><label class="%s col-form-label" for="%s">%s</label><div class="%s">%s %s</div></div>', $col_left, $_key, $_val['label'], $col_right, $_val['form'], (empty($_val['help'])?'':'<span class="help-block"><small>'.$_val['help'].'</small></span>'));
|
$tres .= sprintf('<div class="row mb-1"><label class="%s col-form-label" for="%s">%s</label><div class="%s">%s %s</div></div>', $col_left, $_key, $_val['label'], $col_right.(str_contains($_val['form'],'type="radio"')?' d-flex gap-2':''), $_val['form'], (empty($_val['help'])?'':'<span class="help-block"><small>'.$_val['help'].'</small></span>'));
|
||||||
}
|
}
|
||||||
foreach ($this->__ahide as $_key => $_val) {
|
foreach ($this->__ahide as $_key => $_val) {
|
||||||
$tres .= $_val;
|
$tres .= $_val;
|
||||||
|
|||||||
+2
-2
@@ -44,8 +44,8 @@ final class Menu {
|
|||||||
$this->app = $app;
|
$this->app = $app;
|
||||||
$this->db = $app->db();
|
$this->db = $app->db();
|
||||||
$this->session = $app->session();
|
$this->session = $app->session();
|
||||||
$this->webapp = $this->session->get('__WEB_APP', ['APP_MODULE'=>'', 'PARENT_SITE'=>'', 'PARENT_SUB'=>false]);
|
$this->webapp = $this->session->get('WEB_APP', ['APP_MODULE'=>'', 'PARENT_SITE'=>'', 'PARENT_SUB'=>false]);
|
||||||
$this->webuser = $this->session->get('__WEB_USER', ['Menu'=>'', 'Menu_Grup'=>'', 'MENU_MODUL'=>[]]);
|
$this->webuser = $this->session->get('WEB_USER', ['Menu'=>'', 'Menu_Grup'=>'', 'MENU_MODUL'=>[]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function Sidebar(): string {
|
public function Sidebar(): string {
|
||||||
|
|||||||
+2
-1
@@ -38,7 +38,8 @@ final class Param {
|
|||||||
private static function __data(): void {
|
private static function __data(): void {
|
||||||
global $app;
|
global $app;
|
||||||
if (empty($app)) $app = \Flight::app();
|
if (empty($app)) $app = \Flight::app();
|
||||||
$_asumber = array_merge($app->request()->query->getData(), $app->request()->data->getData());
|
//$_asumber = array_merge($app->request()->query->getData(), $app->request()->data->getData());
|
||||||
|
$_asumber = $app->request()->query->getData() + $app->request()->data->getData();
|
||||||
foreach ($_asumber as $__key => $__val) {
|
foreach ($_asumber as $__key => $__val) {
|
||||||
self::$__ahasil[$__key] = is_string($__val) ? self::safeSQL($__val) : $__val;
|
self::$__ahasil[$__key] = is_string($__val) ? self::safeSQL($__val) : $__val;
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-7
@@ -5,7 +5,7 @@
|
|||||||
Module : /Web/Table.php
|
Module : /Web/Table.php
|
||||||
Created By : Siau Pheng (siaupheng@3fonia.com).
|
Created By : Siau Pheng (siaupheng@3fonia.com).
|
||||||
Created Date : January 16th, 2008.
|
Created Date : January 16th, 2008.
|
||||||
Last Modified : August 22nd, 2026.
|
Last Modified : August 27th, 2026.
|
||||||
|
|
||||||
(c) 3FONIA Software; WWW.3FONIA.COM.
|
(c) 3FONIA Software; WWW.3FONIA.COM.
|
||||||
|
|
||||||
@@ -144,7 +144,7 @@ final class Table {
|
|||||||
$this->__bnobutton = true;
|
$this->__bnobutton = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function add_field(string $field = "", string $header = "", string $style = "l", string $format = "", string $footer = "", string $otype = ""): void {
|
public function add_field(string $field = "", string $header = "", string $style = "l", mixed $format = "", string $footer = "", string $otype = ""): void {
|
||||||
$this->__afield[] = [ 'a' => $field, 'h' => $header, 's' => $style, 'f' => $format, 't' => $footer, 'o' => $otype ];
|
$this->__afield[] = [ 'a' => $field, 'h' => $header, 's' => $style, 'f' => $format, 't' => $footer, 'o' => $otype ];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,7 +162,7 @@ final class Table {
|
|||||||
$row = $this->db->fetchRow("SELECT ".$this->__tfooter." FROM ".$this->__ttable.$this->__twhere, $this->__aparam);
|
$row = $this->db->fetchRow("SELECT ".$this->__tfooter." FROM ".$this->__ttable.$this->__twhere, $this->__aparam);
|
||||||
foreach ($this->__afield as $col) {
|
foreach ($this->__afield as $col) {
|
||||||
$tval = $row[$col['a']] ?? '';
|
$tval = $row[$col['a']] ?? '';
|
||||||
if (is_set($col['t']) && !empty($col['t'])) {
|
if (isset($col['t']) && !empty($col['t'])) {
|
||||||
if (is_array($col['t'])) {
|
if (is_array($col['t'])) {
|
||||||
$tval2 = $col['t'][$tval] ?? '';
|
$tval2 = $col['t'][$tval] ?? '';
|
||||||
} else if (function_exists($col['t'])) {
|
} else if (function_exists($col['t'])) {
|
||||||
@@ -186,8 +186,7 @@ final class Table {
|
|||||||
// adding all option
|
// adding all option
|
||||||
foreach ($this->__aoption as $opsi) {
|
foreach ($this->__aoption as $opsi) {
|
||||||
if (in_array($opsi['type'], ["button","button-dt"])) {
|
if (in_array($opsi['type'], ["button","button-dt"])) {
|
||||||
if (!isset($opsi['field'])) continue;
|
if (!empty($opsi['field']) && ((string) $row[$opsi['field']] !== (string) $opsi['value'])) {} else {
|
||||||
if (!empty($opsi['field']) && ($row[$opsi['field']] !== (!empty($opsi['value']) ? $opsi['value'] : (string)$this->app->session()->get('__WEB_USER')['UNIX']))) {} else {
|
|
||||||
$aoption['button'][] = [ $opsi['icon'], (empty($opsi['field_css'])?'':$opsi['avalue_css'][$row[$opsi['field_css']]]??'') ];
|
$aoption['button'][] = [ $opsi['icon'], (empty($opsi['field_css'])?'':$opsi['avalue_css'][$row[$opsi['field_css']]]??'') ];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -270,8 +269,7 @@ final class Table {
|
|||||||
// adding all option
|
// adding all option
|
||||||
foreach ($this->__aoption as $opsi) {
|
foreach ($this->__aoption as $opsi) {
|
||||||
if (in_array($opsi['type'], ["button","button-dt"])) {
|
if (in_array($opsi['type'], ["button","button-dt"])) {
|
||||||
if (!isset($opsi['field'])) continue;
|
if (!empty($opsi['field']) && ((string) $row[$opsi['field']] !== (string) $opsi['value'])) {} else {
|
||||||
if (!empty($opsi['field']) && ($row[$opsi['field']] !== (!empty($opsi['value']) ? $opsi['value'] : $this->app->session()->get('__WEB_USER')['UNIX']))) {} else {
|
|
||||||
$aoption['button'][] = [ $opsi['icon'], (empty($opsi['field_css'])?'':$opsi['avalue_css'][$row[$opsi['field_css']]]??'') ];
|
$aoption['button'][] = [ $opsi['icon'], (empty($opsi['field_css'])?'':$opsi['avalue_css'][$row[$opsi['field_css']]]??'') ];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user