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 : 13.58.245.32
<?php
function eGovGetMenus($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$univcode = $aobj_context->mobj_data['univcode'];
$usertype = $aobj_context->mobj_data['usertype'];
if ($univcode == '') {
$arr['msg'] = 'Invalid Params';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 1, "failure");
return;
}
$menu_query = "select fmenucode, fmenuname, ficonname, ffunction,
ifnull(fmainmenu,'') as fmainmenu,
fismainmenu, fissubmenu from masmenu
where fmodtype = 'EGOV' and ifnull(factive,'') = 'T'
and instr((select fpermission from usermenu where funivcode = '{$univcode}'
and fusertype = '{$usertype}'), fmenucode)
order by forder";
// var_dump($menu_query);
$result = $aobj_context->mobj_db->GetAll($menu_query);
$arr = array();
if (count($result) > 0) {
foreach ($result as $value) {
if ($value['fmainmenu'] == 'C') {
$arr[$value['fmenucode']]['children'] = array();
$arr[$value['fmenucode']]['icon'] = $value['ficonname'];
$arr[$value['fmenucode']]['name'] = $value['fmenuname'];
$arr[$value['fmenucode']]['url'] = $value['ffunction'];
} else if ($value['fmainmenu'] == 'D') {
$arr[$value['fmenucode']]['icon'] = $value['ficonname'];
$arr[$value['fmenucode']]['name'] = $value['fmenuname'];
$arr[$value['fmenucode']]['url'] = $value['ffunction'];
} else if ($value['fmainmenu'] == 'S') {
$arr[$value['fmenucode']]['title'] = true;
$arr[$value['fmenucode']]['name'] = $value['fmenuname'];
} else {
$val['icon'] = $value['ficonname'];
$val['url'] = $value['ffunction'];
$val['name'] = $value['fmenuname'];
array_push($arr[$value['fmainmenu']]['children'], $val);
}
}
$res = array();
$i = 0;
foreach ($arr as $value) {
$res[$i] = $value;
$i++;
}
echo $aobj_context->mobj_output->ToJSONEnvelope($res, 0, "success");
} else {
$arr['msg'] = 'Error while fetching menus';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
}
}
|