This topic is locked
[SOLVED]

 how to show user data based on its branch location only

11/24/2014 3:21:32 AM
PHPRunner General questions
G
Getinet author

Hi, all
i am developing a small application(PhpRunner 5.3) that will be accessed via my organizations intranet.

So the thing i want to clarify before i started is how to set up a user registered in a certain branch of my organization can only see, add,edit or do whatever allowed

data only its branch. May be he/she might view other branch data.Could any PHPRUNNER5.3 people help me out on this.I appreciate this community.
Thanks in advance.

admin 11/24/2014

You can use Advanced Security option 'Users can see all data, can edit their own data only' for this purpose.

romaldus 11/25/2014

other scenario to achieve this :

  1. Make a new table in your database, for example BRANCHES_DATA with the following fields : branch_code (char 20, primary key), branch_location (char 30,)
  2. In your user table (which contains username, password,....etc), add a new field : branch_code(char 20). Based on data IN BRANCHES_DATAtable, you can assign any branch_code for each user
  3. In PHPRUNNER events : Login page > After Successful login, add the following code : $_SESSION["CUSTOM_BRANCH"] = $data["branch_code"];



  4. Now you can filter list pages, lookup filter, etc...... using CUSTOM_BRANCH session variable.
    For example to filter list page, In PHPrunner events : Table_Name > List Page > List Page : Before SQL Query add the foolowing code to filter data based on branch_code

$strWhereClause = whereAdd($strWhereClause, "branch_code ='" .$_SESSION["CUSTOM_BRANCH"] ."'");
G
Getinet author 11/27/2014

Thank you very much [b]Rthis solution is more like it.
[color="#008000"]One more question if i am not rude please.
[color="#008000"]But i have also got admin/manager users who can VIEW/ADD/EDIT/DELETE all/any branch data, how to set up such security levels?
" for privileged users only.

romaldus 11/27/2014



Thank you very much [b]Rthis solution is more like it.
[color="#008000"]One more question if i am not rude please.
[color="#008000"]But i have also got admin/manager users who can VIEW/ADD/EDIT/DELETE all/any branch data, how to set up [size="2"]such security levels? [/size]
[size="2"]" for privileged users only.[/size]


Check this:

http://www.asprunner.com/forums/topic/21656-dynamic-query-depending-on-user-groupid/

romaldus 11/27/2014

to make sure admin can see all records, use the following code in Table_Name > List Page > List Page : Before SQL Query

if ($_SESSION["CUSTOM_BRANCH"] != "admin")

{

$strWhereClause = whereAdd($strWhereClause, "branch_code = '" .$_SESSION["CUSTOM_BRANCH"]."'");


Note: in this example i assign username admin to a branch called "admin" in user table

G
Getinet author 11/28/2014

Thanks Brother you are charming.I will use your advice.