Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64
Your IP : 3.146.255.135
<?php
function getCmenus($aobj_context){
$univcode = $aobj_context->mobj_data["univcode"];
$usertype = $aobj_context->mobj_data["usertype"];
$query="select fmenucode, fmenuname as title, ifnull(ffunction, '') as url,
fmainmenu from col_masmenu where factive ='T' and fismainmenu='T'
and instr(ftype, '{$usertype}') > 0";
$result = $aobj_context->mobj_db->GetAll($query);
$arr=[];
foreach($result as $val){
$menuItems=[];
$menucode = $val['fmenucode'];
$obj['title'] = $val['title'];
$obj['url'] = $val['url'];
$submenu = array();
$qry = "select fmenucode, fmenuname as title, ifnull(ffunction, '') as url, factive, fmainmenu from col_masmenu
where factive ='T' and fissubmenu='T' and fmainmenu='{$menucode}'
and instr(ftype, '{$usertype}') > 0";
$res = $aobj_context->mobj_db->GetAll($qry);
foreach($res as $value){
$innerSubmenu = array();
if($menucode == $value['fmainmenu']){
$sub['title']=$value['title'];
$sub['url']=$value['url'];
}
$query1 = "select fmenucode, fmenuname as title, ifnull(ffunction, '') as url, factive, fmainmenu from col_masmenu
where factive ='T' and fissubmenu='T' and fmainmenu='{$value['fmenucode']}'
and instr(ftype, '{$usertype}') > 0";
$result1 = $aobj_context->mobj_db->GetAll($query1);
foreach($result1 as $v){
if($v['fmainmenu'] === $value['fmenucode']){
$subm['title']=$v['title'];
$subm['url']=$v['url'];
array_push($innerSubmenu, $subm);
}
}
$sub['submenu'] = $innerSubmenu;
array_push($submenu, $sub);
}
$obj['submenu'] = $submenu;
array_push($arr, $obj);
}
// var_dump($arr);die();
if($result){
$menu['menu'] = $arr;
echo $aobj_context->mobj_output->ToJSONEnvelope($menu,0,"success");
}else{
$arr['msg'] = 'Failed to load';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
}
}
?>
|