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.
See some fields in a table for different groups
Re: See some fields in a table for different groups
Do not answer all at once, otherwise I can not read all the tips you posted ...
Re: See some fields in a table for different groups
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.
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.
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;
}
Alan
Hope this helps.
Calgary, Alberta, Canada - Using Appgini 5.50 -
Re: See some fields in a table for different groups
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?
thank you very much for your help!
But I've a question, in the DV page for users, where should I paste the code?
Re: See some fields in a table for different groups
Sorry,
i don't view the your_table_name_dml.php...
I try and let you know...
Thank you very much!!!
i don't view the your_table_name_dml.php...
I try and let you know...
Thank you very much!!!
Re: See some fields in a table for different groups
Hi Shasta,
it's work....
Thank you...
it's work....
Thank you...
Re: See some fields in a table for different groups
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.
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.
Re: See some fields in a table for different groups
No one can help me solve?
Thanks a lot in advance.
Thanks a lot in advance.