0xV3NOMx
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 : 18.117.72.24


Current Path : /var/www/html/univadmin/src/
Upload File :
Current File : /var/www/html/univadmin/src/assignUserMenus.php

<?php
function getUserTypeList($aobj_context){
  $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
  $univcode = $aobj_context->mobj_data['univcode'];
  $usertype = $aobj_context->mobj_data['usertype'];

  if($usertype != '100')
    $cond = "and fusertype > '{$usertype}'";

  $query = "select * from usertype where fdeleted='F' $cond
  order by fusertype";
  $result = $aobj_context->mobj_db->getAll($query);
  
  if($result){
    echo $aobj_context->mobj_output->ToJSONEnvelope($result, 0, "success");
  }
  else{
    $arr['msg']="No User Type Found";
    echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
  }
}

function getMenuList($aobj_context){

  $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
  $univcode = $aobj_context->mobj_data['univcode'];
  $fusertype = $aobj_context->mobj_data['fusertype'];

  $query = "select fpermission from usermenu
  where funivcode = '{$univcode}' and fusertype = '{$fusertype}'";

  $result1 = $aobj_context->mobj_db->GetRow($query);

  $permission = $result1['fpermission'];

  $query = "select fmenucode ,fmenuname ,fmainmenu,fismainmenu,fissubmenu,ficonname 
  from masmenu 
  where factive = 'T' and fmodtype='EGOV' order by forder";
  $result = $aobj_context->mobj_db->GetAll($query);

  if($result && count($result)>0){

    foreach ($result as $key => $value) {
      if ($value['fmainmenu'] == 'C') {
        $arr[$value['fmenucode']]['value']=$value['fmenucode'];
        $arr[$value['fmenucode']]['label'] = $value['fmenuname'];
        $icons[$value['fmenucode']]['icon'] = $value['ficonname'];
        $arr[$value['fmenucode']]['children'] = array();
      } else if ($value['fmainmenu'] == 'D') {
        $arr[$value['fmenucode']]['value']=$value['fmenucode'];
        $arr[$value['fmenucode']]['label'] = $value['fmenuname'];
        $icons[$value['fmenucode']]['icon'] = $value['ficonname'];
      } else if ($value['fmainmenu'] == 'S') {
        $arr[$value['fmenucode']]['value']=$value['fmenucode'];
        $arr[$value['fmenucode']]['label'] = $value['fmenuname'];
        $icons[$value['fmenucode']]['icon'] = $value['ficonname'];
      } 
      else {
        $val['value']=$value['fmenucode'];
        $val['label'] = $value['fmenuname'];
        $icons['icon'] = $value['ficonname'];        
        array_push($arr[$value['fmainmenu']]['children'],$val);
      }

    }
  }
  // var_dump($arr);
  // die();
  // var_dump($res);
  if($result){
    //  $res = array();
    //  array_push($res,$arr);
    $res['tree'] = $arr;
    $res['icons'] = $icons;
    if(count($result1) > 0) {
      $res['permission'] = explode('*', $permission);
    } 
    else {
      $res['permission'] = array();
    }
    echo $aobj_context->mobj_output->ToJSONEnvelope($res, 0, "success");
  }
  else{
    $arr['msg']="No User Type Found";
    echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
  }
}

function updateUserMenus($aobj_context){
  $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
  $univcode = $aobj_context->mobj_data['univcode'];
  $req = $aobj_context->req_body['data'];

  $query = "select fpermission from usermenu
  where funivcode = '{$univcode}' and fusertype = '{$req['usertype']}'";
  // var_dump($query);
  $result1 = $aobj_context->mobj_db->GetRow($query);

  if(count($result1) > 0) {
    $query = "update usermenu set fpermission = '{$req['fpermissions']}'
      where fusertype='{$req['usertype']}' and funivcode='{$univcode}' and fdeleted='F'";
  }
  else {
    $query = "insert into usermenu(funivcode, fusertype, fpermission, fdeleted)
    values('{$univcode}', '{$req['usertype']}', '{$req['fpermissions']}', 'F')";
  }
  // var_dump($query);
  // die();
  $result = $aobj_context->mobj_db->Execute($query);

  if($result) 
  {
    $data='Menus was updated successfully.';
    $arr['msg']= $data;
    echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success"); 
    return;
  } else {
    $data='Updation was failed, please try after sometime.';
    $arr['msg']= $data;
    echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failed"); 
    return;
  }
}

?>