Page 1 of 1

Customers reporting issues to supervisors

Posted: 2021-11-06 15:11
by arcanebits
Hi to all
I have only One table in wich customers will report issues, all good, ultil the supervisors thing came up. The supervisors must only see the issues of customers asigned to them. Ie

Cus1 SupervisorA
Cus2 SupervisorC
Cus3 SupervisorA
Cus4 SupervisorB
Cus5 SupervisorC
Cus6 SupervisorB

Is any way to acomplish this.?

Aldo

Re: Customers reporting issues to supervisors

Posted: 2021-11-06 17:16
by pbottcher
Hi,

you can use the _init hook to adjust the where clause of your query so that you can filter according to your needs.

Re: Customers reporting issues to supervisors

Posted: 2021-11-09 12:03
by arcanebits
Thanks for that. Is there any examplr available?

Re: Customers reporting issues to supervisors

Posted: 2021-11-12 14:05
by arcanebits
Hi again, after some research im quite impressed about the power of the Hooks, I need a little help with convert this example to what i do need
BELOW IS AN EXAMPLE I THINK WILL WORK FOR ME NOT TESTED CAUSE IM NOT SURE HOW TO TIE LOGGED IN USER WITH A FIELD, and if the Filter is well placed

function customers_init(&$options, $memberInfo, &$args){
/* Apply a default filter only if no filter is already applied by the user */
if(!$_POST['FilterField'][1] && !$_GET['FilterField'][1]){
/*
In the call below, we want to display records of the customers
table where the value of the 7th field is equal to 'New'.
*/
addFilter(1, 'and', 7, 'equal-to', 'New'); --->>>> Here, how do i say "Show records only for AsignedField=LoggedInUser <<<<----
}
return TRUE;
}

Thanks for any help!
Aldo

Re: Customers reporting issues to supervisors

Posted: 2021-11-12 14:15
by arcanebits
Just as a comment: I purchased and own: Customizing AppGini web applications Extend what your AppGini web applications can do. Learn the fine details of tailoring the generated code efficiently. On Udemy, I tottally recommend it!
Im on a heavy rush sleeping just 4 hours for a deliver and its a big BIG maybe, im not thinking clearly, Just need to filter all data shown with the username of the logged user ie
addFilter(ALL DATA, logedinuser, 'equal-to', 'Data.Supervisor')
any help is more than welcome.
Aldo

Re: Customers reporting issues to supervisors

Posted: 2021-11-12 19:59
by pbottcher
Hi,
have a look at

https://bigprof.com/appgini/help/advanc ... Info-array

$memberInfo['username'] will be your friend.

Re: Customers reporting issues to supervisors

Posted: 2021-11-14 18:53
by arcanebits
Nice, this is the part I think I need just a little push
function tablename_init(&$options, $memberInfo, &$args){

if($memberInfo['group']=='Admins'){ //Mine--> if($memberInfo['username']=='db.personinchage') <--//
$options->AllowCSV=1;
}else{
$options->AllowCSV=0;
}

return true;
}


Just need that part.
Thanks in advance.
Aldo

Re: Customers reporting issues to supervisors

Posted: 2021-11-14 20:14
by pbottcher
ok, so what is your question now?

Re: Customers reporting issues to supervisors

Posted: 2021-11-17 20:55
by arcanebits
Hi. Using that example I need to verify that logged in user is equal to a database field.
if($memberInfo['username']=='db.personinchage')
So supervisors can see only where ticket is asigned to them.

Thanks

Re: Customers reporting issues to supervisors

Posted: 2021-11-17 22:03
by pbottcher
Hi,

you can put an additional

Code: Select all

 $options->QueryWhere="PLACE YOUR RESTRICTION HERE"
for the db.persnincharge to select only those records asigned to him/her.

Re: Customers reporting issues to supervisors

Posted: 2022-01-10 17:02
by arcanebits
Amazing help! Thanks a LOT

Re: Customers reporting issues to supervisors

Posted: 2022-01-10 18:26
by pbottcher
Just to add to this. If you need to make sure that the person will not have direct access (by knowing the URL for a selectedID, verify if the request contains a selectedID and add a query beforehand and check if the has access to that selectedID, if not redirect the user to the tableview.