This topic is locked

How to setup a Hierarchy View?

7/20/2015 2:08:27 AM
PHPRunner General questions
need2sleep authorDevClub member

What would be the best way to create a filter so that the user logged in can access only certain "Sales Orders" in a hierarchy environment?
Example Hierarchy



Homer

/ \

Bart Lisa

/ / \

Ralph Nelson Milhouse


A user would be able to view all sales records associated below them but not above.
I figure I would need to setup a USERS table with a Field: "Report To"
Bart 'reports to' Homer

Lisa 'reports to' Homer

Ralph 'reports to' Bart

Nelson 'reports to' Lisa

Milhouse 'reports to' Lisa
The SALES table would have a Field for "Sales Rep"
There is no real limit but realistically this hierarchy can't surpass more than 10 levels.
Has anyone achieved this with PHPRunner?

Where could I take it from here? Trying to look for inspiration.
Thank you,

D
DealerModulesDevClub member 7/20/2015



What would be the best way to create a filter so that the user logged in can access only certain "Sales Orders" in a hierarchy environment?
Example Hierarchy



Homer

/ \

Bart Lisa

/ / \

Ralph Nelson Milhouse


A user would be able to view all sales records associated below them but not above.
I figure I would need to setup a USERS table with a Field: "Report To"
Bart 'reports to' Homer

Lisa 'reports to' Homer

Ralph 'reports to' Bart

Nelson 'reports to' Lisa

Milhouse 'reports to' Lisa
The SALES table would have a Field for "Sales Rep"
There is no real limit but realistically this hierarchy can't surpass more than 10 levels.
Has anyone achieved this with PHPRunner?

Where could I take it from here? Trying to look for inspiration.
Thank you,


Have you seen the xlinesoft article - http://xlinesoft.com/articles/alumni.htm

Maybe a good example. I would sub the alumni year for your "reports to"
Paul

Sergey Kornilov admin 7/20/2015

The basic idea is to keep the current level of hierarchy is some session variable i.e. $_SESSION["ParentID"]="Homer". Then in AfterTableInit event you can modify query on the fly to only select employees that report directly to Homer:

$query->addWhere("ParentID='".$_SESSION["ParentID"]."'");


More info:

http://xlinesoft.com/phprunner/docs/modify_sql_query_on_the_fly.htm
We use similar approach in DocManager template when you browse files and folders so if you own one you can take a look there. Just make sure you update $_SESSION["ParentID"] variable when you go up or down the tree.