Walter
|
| Posted: 01/15/2003, 9:06 AM |
|
Hi all,
I have a client that wants to track several layers of sales people. . .you know the typical pyramid idea, i.e John works for bill who works for Ed who works for Cathy who works for Phill and so on and so on. The commissions trickle down. I'm trying to find a way to track this in the database with an unlimmited amount of levels. I thought of using fields named Rep_id and Parent_id so that each salesman would have a rep_id and if there was a salesman above him he would also be given a parent_id (which is the same as the salesman above him's rep_id. I feel there has to be a better way to do this because it would make it difficult to track all salesmen under a particular salesman because the list might be several levels deep. Does anyone have an idea or an example that might help? I'm using CCS, apache, mySQL, and PHP.
Thanks,
Walter
|
|
|
 |
RonB
|
| Posted: 01/15/2003, 12:51 PM |
|
I think the way you proposed it looks fine. The trick seems to be to translate this into a smart way of showing it on the page. Maybe something like this?
lets's say the table is called:
emps
-------
rep_id
Parent_id
rep_name
two grids:
-> grid one(boss -> label1 source: Parent_id label2 source:emps1_rep_name ) holds all the people that have people under them(bosses):
( SELECT distinct emps.Parent_id, emps1.rep_name AS emps1_rep_name
FROM emps INNER JOIN emps emps1 ON emps.Parent_id = emps1.rep_id)
I selected the emps table twice in the query builder and made a join.
Make the label Parent_id a link and in the proppertiesbox make sure it sends it's own value via the url lets say as a variable named meet_the_boss 
->grid two(emps) holds all the people in emps and you could build that one with the query builder and add a parameter for Parent_id -> meet_the_boss(URL)
Make rep_id show as a link and make sure that the value of the field is transmitted via url has the same variable name as the one transmitted via the boss->Parant_id link ie meet_the_boss.
This grid wil now react to a link clicked in the boss grid and to the link from the rep_id label.
Now this will allow you to "cycle" thrue the levels. start with a rep in the boss grid and keep clicking on the rep in emps grid to get one level lower in the hierarchy.
Just a thought 
|
|
|
 |
Walter
|
| Posted: 01/17/2003, 12:17 PM |
|
Thanks RonB, That sounds like a great idea!
Thanks again,
Walter
|
|
|
 |
|