This topic is locked
[SOLVED]

Hide menus with two conditions

4/18/2021 4:20:49 PM
PHPRunner General questions
A
abhijit2020 author

Hi,

I am trying to hide menu(s) for users who meet the following two conditions. I tried the conditions individually and it seems the second condition is not working.

  1. User security group (e.g. Employee) <---- Working
  2. The user has no record in a custom view (e.g. TS_Delegate_VW) <---- Not Working

I have the following code in the "Menu Item: Modify" event


$rs = DB::Query("select count(DelegateEmpNo) as cnt from TS_Delegate_VW where DelegateEmpNo=".$_SESSION["EmpNo"]." ");
$data = $rs->fetchAssoc();

if (Security::getUserGroup()=="Employee" && $data["cnt"] = 0) {

$title = $menuItem->getTitle();
if ($title=="Leave Approval" || $title=="Timesheet Approval")
return false;

}

return true;

I am using the above SQL query in other page events and it's working for me. Unable to figure out why it's not working here.

Any help/direction is greatly appreciated.

Thank you,

Abhi

admin 4/19/2021

Wrong:
$data["cnt"] = 0

Right:
$data["cnt"] == 0

A
abhijit2020 author 4/20/2021

Thank you. Issue is resolved.