There is a main user_info table called user that holds all users info
UID, name, owner_id, etc
Then there is a table call tm2apptuser that holds user ids with
telemarketers ids for the telemarketers.
uid, tm_id
There is also a table that keeps up with sub users . I need to pull
the person above so that would be level of '1'
uid, par_id, level
Here is the function that I have
Code: Select all
function getSelLeadOwner(){
$data['selOwner']=array();
if(db_value("select TYPE from user where
uid=".q(getFromSession('uid')))=='TELEMARKETER'){
$uid=q(getFromSession('uid'));
$data['selOwner']=db_simple_hash("select tm2apptuser.uid,
user_info.NAME
from tm2apptuser
inner join user_info on user_info.UID=tm2apptuser.uid
where tm_id='$uid'
UNION select u2u.uid, user_info.NAME
from u2u
inner join user_info on user_info.UID=u2u.par_id
where uid='$uid' and level='1'");
$r=db_record("select UID, NAME from user_info where UID=$uid");
$data['selOwner'][$r['UID']]=$r['NAME'];
}else{
$rootAgent=permitted('ADMIN-RIGHTS')?'':getFromSession('uid');
$data['selOwner']=getAgentNetworkList($rootAgent/
*(,nvl($data['bankbranch_id'])*/);//getSelOwner();
};
return $data['selOwner'];
}