corrected same function

This commit is contained in:
2026-10-21 16:13:30 +07:00
parent 17188f6134
commit 0a47ddc422
5 changed files with 64 additions and 78 deletions
+24 -23
View File
@@ -5,7 +5,7 @@
Module : /Web/Menu.php
Created By : Siau Pheng ([email protected]).
Created Date : January 16th, 2008.
Last Modified : August 22nd, 2026.
Last Modified : October 21st, 2026.
(c) 3FONIA Software; WWW.3FONIA.COM.
@@ -31,8 +31,9 @@ use \flight\database\SimplePdo;
*/
final class Menu {
private array $webapp;
private array $webuser;
private array $web_app;
private array $web_user;
private array $my_menu;
protected Engine $app;
protected SimplePdo $db;
protected Session $session;
@@ -44,27 +45,28 @@ final class Menu {
$this->app = $app;
$this->db = $app->db();
$this->session = $app->session();
$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->web_app = $this->session->get('WEB_APP', ['APP_MODULE'=>'', 'PARENT_SITE'=>'', 'PARENT_SUB'=>false]);
$this->web_user = $this->session->get('WEB_USER', ['Menu'=>'', 'Menu_Grup'=>'', 'MENU_MODUL'=>[]]);
$_gmenu = '';
$_umenu = $this->db->fetchField("SELECT CONVERT(DECODE(Menu,?) USING UTF8MB4) Menu FROM app_operator WHERE UserID=?", [$this->web_app['PARENT_CODE'], $this->web_user['UserID']]) ?? '';
if ($this->web_user['Grup_MenuID'] > 0) $_gmenu = $this->db->fetchField('SELECT CONVERT(DECODE(Menu,?) USING UTF8MB4) Menu FROM app_menu_grup WHERE Grup_MenuID=?', [$this->web_app['PARENT_CODE'], $this->web_user['Grup_MenuID']]) ?? '';
$this->my_menu = array_unique(array_filter(explode(",", $_gmenu.",".$_umenu)));
}
public function Sidebar(): string {
$a_modul = [];
$is_modul = ($this->webapp['APP_MODULE'] !== '') ? true : false;
if ($is_modul == true) {
$a_modul[] = $this->webapp['APP_MODULE'];
$is_modul = !empty($this->web_app['APP_MODULE']);
if ($is_modul === true) {
$a_modul[] = $this->web_app['APP_MODULE'];
} else {
$atmp = $this->db->fetchAll('SELECT * FROM app_menu WHERE Level=0 AND Aktif=1 AND Modul<>"IND" ORDER BY Urut');
foreach ($atmp as $tmp) {
$a_modul[] = $tmp['Modul'];
}
foreach ($atmp as $tmp) $a_modul[] = $tmp['Modul'];
}
$my_menu = array_unique(array_filter(explode(",", $this->webuser['Menu_Grup'].",".$this->webuser['Menu'])));
$tsql = 'SELECT * FROM app_menu WHERE Aktif=1 AND Modul IN (?) AND Kode IN (?)';
if ($is_modul == true) $tsql .= ' AND Level>0';
$amodul = $this->db->fetchAll($tsql . ' ORDER BY Kode', [$a_modul, $my_menu]);
$amodul = $this->db->fetchAll($tsql . ' ORDER BY Kode', [$a_modul, $this->my_menu]);
$thasil = '';
$last_level = 0;
@@ -88,10 +90,10 @@ final class Menu {
public function Header(): string {
$a_modul = [];
$is_modul = ($this->webapp['APP_MODULE'] !== '') ? true : false;
$is_modul = !empty($this->web_app['APP_MODULE']);
$mulai_level = 0;
if ($is_modul == true) {
$a_modul[] = $this->webapp['APP_MODULE'];
if ($is_modul === true) {
$a_modul[] = $this->web_app['APP_MODULE'];
$mulai_level = 1;
} else {
$atmp = $this->db->fetchAll('SELECT * FROM app_menu WHERE Level=0 AND Aktif=1 AND Modul<>"IND" ORDER BY Urut');
@@ -100,11 +102,10 @@ final class Menu {
}
}
$my_menu = array_unique(array_filter(explode(",", $this->webuser['Menu_Grup'].",".$this->webuser['Menu'])));
$tsql = 'SELECT * FROM app_menu WHERE Aktif=1 AND Modul IN (?) AND Kode IN (?)';
if ($is_modul == true) $tsql .= ' AND Level>0';
$amodul = $this->db->fetchAll($tsql . ' ORDER BY Kode', [$a_modul, $my_menu]);
$amodul = $this->db->fetchAll($tsql . ' ORDER BY Kode', [$a_modul, $this->my_menu]);
$thasil = '';
$last_level = 0;
@@ -134,15 +135,15 @@ final class Menu {
public function Modul(): string {
$t_modul = '';
if (is_array($this->webuser['MENU_MODUL']) && count($this->webuser['MENU_MODUL'])>0) {
if (is_array($this->web_user['MENU_MODUL']) && count($this->web_user['MENU_MODUL'])>0) {
$t_modul = '<div class="dropdown-divider"></div>';
if ($this->app->request()->getVar('SERVER_ADDR') === '127.0.0.1') {
$href1 = '//127.0.0.1/';
$href2 = "";
} else {
$_host = $this->app->request()->getVar('HTTP_ORIGIN') ?? $this->app->request()->getVar('HTTP_HOST') ?? $this->webapp['PARENT_SITE'];
$_host = $this->app->request()->getVar('HTTP_ORIGIN') ?? $this->app->request()->getVar('HTTP_HOST') ?? $this->web_app['PARENT_SITE'];
$_host = str_replace(['http://','https://'], "", $_host);
if ($this->webapp['PARENT_SUB'] === true) {
if ($this->web_app['PARENT_SUB'] === true) {
$_subs = explode('.', $_host);
if (count($_subs) > 2) array_shift($_subs);
$href1 = "//";
@@ -152,7 +153,7 @@ final class Menu {
$href2 = "";
}
}
foreach ($this->webuser['MENU_MODUL'] as $modul) {
foreach ($this->web_user['MENU_MODUL'] as $modul) {
$href = $href1 . $modul['APP_PATH'] . $href2 . '/' . $this->session->get('APP_TOKEN');
$t_modul .= '<a class="dropdown-item slink" href="'.$href.'"><i class="'.$modul['Icon'].' me-2"></i> '.$modul['Judul'].'</a>';
}
@@ -173,7 +174,7 @@ final class Menu {
$apage = $acus_page[$page];
} else if ($page <> "") {
$apage = $db->fetchRow('SELECT * FROM app_menu WHERE Kode=?', [$page]);
$apage['Width'] = (int)$apage['Width'];
$apage['Width'] = (int) $apage['Width'];
}
$ajson['iswindow'] = ($apage['Width'] > 0) ? true : false;
+1 -10
View File
@@ -5,7 +5,7 @@
Module : /Web/Param.php
Created By : Siau Pheng ([email protected]).
Created Date : November 14th, 2013.
Last Modified : September 16th, 2026.
Last Modified : October 16th, 2026.
(c) 3FONIA Software; WWW.3FONIA.COM.
@@ -75,15 +75,6 @@ final class Param {
return self::$__ahasil;
}
//delete
public static function Get_Text(string $key, mixed $def = null): mixed {
return self::Get($key, $def);
}
//delete
public static function Get_ArrayCBOX() {
return [];
}
}
?>