Hi guys!
I want to disable employees from being able to view the complete customer database.
Employees should only be able to view customer data from the region they cover.
In the client data table there is a column: region - this data would be used to show certain employees - depending on the geographical region they cover - data for certain regions only.
For example:
Bob can only view customer data from the region A. Susan can view customer data from regions B and C. Tom can view data from regions A (same as Bob) and the region F, and so on...
Since the number of employees is small (15), the assignment of the region that an employee can view can be coded manually.
If this can be made to be automatic according to the employee's data - even better.
Is it possible to do this and does anyone have a "plug-in" that could serve this purpose?
Thanks in advance for your help!
"Filtering" data for certain employees
Re: "Filtering" data for certain employees
You may have a look here:
viewtopic.php?p=20456#p20457
That article is about filering by date, but you can modify the conditions according to your needs.
Just replace the
I don't know your table names nor column names, but the middle part of the code (see other article) could look something like this:
I think this is good readable. I know it could be coded differently for better code-maintenance but this should just give you a start.
Of course, instead of harcoding the regions, you can fetch that information from a different database table or from somewhere else.
viewtopic.php?p=20456#p20457
That article is about filering by date, but you can modify the conditions according to your needs.
Just replace the
$conditions
-definition (an array holding 1..n SQL statements for your WHERE-part):
Code: Select all
$conditions = [
"datediff(now(), `TABLENAME`.`modified_on`) < 7"
];
Code: Select all
// ... see other article
if (!getLoggedAdmin()) {
switch (getLoggedMemberID()) {
case 'Bob':
$conditions = ["`customers`.`region` IN ('A')"];
break;
case 'Susan':
$conditions = ["`customers`.`region` IN ('B', 'C')"];
break;
case 'Tom':
$conditions = ["`customers`.`region` IN ('A', 'F')"];
break;
default:
$conditions = ["1=2"]; // this will never be true. Other users will not see customers
break;
}
}
// ...rest of the code
Of course, instead of harcoding the regions, you can fetch that information from a different database table or from somewhere else.
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools