I think I've got it mostly figured out.
First, a small SQL patch like so:
ALTER TABLE group_pricing ADD admin_id integer(1) NULL default NULL after group_percentage;
Then a function (whereever you put functions, still haven't figured that one out yet):
Code:
function customer_allowed($cust_id){
global $db;
$profile = $db_>Execute("select profile_name from ".TABLE_ADMIN_PROFILES." where profile_id=(select admin_profile from ".TABLE_ADMIN." where admin_id = '".$_SESSION['admin_id']."')")
if($profile->fields['profile_name']=="Master Dealer") {
$who_allow = $db->Execute("select admin_id from ".TABLE_GROUP_PRICING." where group_id =(select customers_group_pricing from ".TABLE_CUSTOMERS." where customers_id='".$cust_id."')");
if ($who_allow->fields['admin_id']==$_SESSION['admin_id'])
{
return 'true';
}
else{
return 'false';
}
}
else {
return 'true';
}
}
I would then call that function on each row of the report or what have you.
What I'm not sure about yet is how to create a dropdown in the group pricing page with all the admins by name, which would set the admin id in the group_pricing table.
Any thoughts, comments or questions would be appreciated, thanks! If I get this working I will post it as a plugin, so others can benefit.
Bookmarks