See some fields in a table for different groups

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
espo
Veteran Member
Posts: 98
Joined: 2013-03-01 12:55

See some fields in a table for different groups

Post by espo » 2014-01-29 08:02

Hello to all,

I would like to know if there is a chance with AppGini to show certain fields in a table (in Details view) for different groups.

Here's an example:

table
ID
name
surname
department
number employed
email
notes

Group 1 must see, insert and modify only the first 4 fields (excluding ID)

ID
name
surname
department
email

Group 2 should be able to see, enter and edit these fields

ID
name
surname
number employed
notes

If there is a method you can kindly point it out to me (in simple'm not a big expert in PHP)

Thank you very much.

espo
Veteran Member
Posts: 98
Joined: 2013-03-01 12:55

Re: See some fields in a table for different groups

Post by espo » 2014-01-30 07:25

Do not answer all at once, otherwise I can not read all the tips you posted ... :lol: :lol: :lol:

User avatar
shasta59
AppGini Super Hero
AppGini Super Hero
Posts: 231
Joined: 2013-01-08 19:40
Location: Calgary, Alberta, Canada

Re: See some fields in a table for different groups

Post by shasta59 » 2014-02-01 01:38

There is one way which would work. But it means creating new templates which are each a bit different than the rest and then calling the correct template (DV) based upon group. In the new template either delete the fields so they do not show or allow them to show. You can choose. This is a cheap and dirty way. Here is the code you need to look for to make it redirect. It is found in the your_table_name_dml.php file. (In this example I needed to have a few unique fields in the users record. These fields were used to verify payment and verify other info. Did not want the user being able to fill these in. So in the user template the fields are not there. In the other template they are. Cheap/dirty method but works well. Only deleting fields not writing code.

In the example below you can see it calls a different template based upon group. Depending upon the group only certain fields show up. I found this method was easier to do. Just duplicate the template, rename it with a slightly different name of your choosing and then put the code in to pick based upon group.

Code: Select all

// open the detail view template
	if(($_POST['dvprint_x']!='' || $_GET['dvprint_x']!='') && $selected_id){
		$templateCode=@implode('', @file('./templates/clinic_reg_templateDVP.html'));
		$dvprint=true;
		}elseif(getLoggedGroupID() == 6 || getLoggedGroupID() == 2){
		$templateCode=@implode('', @file('./templates/clinic_reg_templateDVDUIC.html'));//for district UIC's only to see
		$dvprint=false;
	}else{
		$templateCode=@implode('', @file('./templates/clinic_reg_templateDV.html')); //template for regular users to be shown
		$dvprint=false;
	}
So in the above I check for group and based upon group it decides which template to show. You could also write some code to hide/show the fields based upon group but this method took me minutes to do and very little testing to verify. Plus no regeneration of the app. (Make sure if you do regenerate your app you do not overwrite your changed templates and you also make sure the code is put back in the dml file if you regenerate that also.)

Alan

Hope this helps.
Calgary, Alberta, Canada - Using Appgini 5.50 -

espo
Veteran Member
Posts: 98
Joined: 2013-03-01 12:55

Re: See some fields in a table for different groups

Post by espo » 2014-02-03 09:49

Hi Shasta,

thank you very much for your help!
But I've a question, in the DV page for users, where should I paste the code?

espo
Veteran Member
Posts: 98
Joined: 2013-03-01 12:55

Re: See some fields in a table for different groups

Post by espo » 2014-02-03 14:03

Sorry,

i don't view the your_table_name_dml.php...
I try and let you know...

Thank you very much!!!

espo
Veteran Member
Posts: 98
Joined: 2013-03-01 12:55

Re: See some fields in a table for different groups

Post by espo » 2014-02-03 14:09

Hi Shasta,

it's work....

Thank you...

espo
Veteran Member
Posts: 98
Joined: 2013-03-01 12:55

Re: See some fields in a table for different groups

Post by espo » 2014-02-04 10:02

Hi Shasta,

I've modified the fields with your code, but I've find a problem.
When I save the change into the fileds of the second table, in first table the filed name and surname have been erased.
How can i solve this problem?

First Table has this fields:
- id
- name
- surname
- note
- date

The second table has this fields

- note
- date

Thank you very much.

espo
Veteran Member
Posts: 98
Joined: 2013-03-01 12:55

Re: See some fields in a table for different groups

Post by espo » 2014-06-03 13:18

No one can help me solve?

Thanks a lot in advance.

Post Reply