Discussion for TimeTrex open source community developers.
Yajasi
Posts: 108 Joined: Wed Oct 17, 2012 4:48 pm
Post
by Yajasi » Sun Apr 19, 2015 4:20 pm
Running 8.0.5 CE on Ubuntu 14.04.
I'm trying to use the API to find which users have a Meal Policy. There doesn't seem to be a report which identifies this. Which API class do I use to do that?
I tried the following, but got an error.
Code: Select all
$ttAPI_group = new TimeTrexClientAPI( 'PolicyGroup' );
$group_factory = $ttAPI_group->getMainClassObject();
$meals = $group_factory->getMealPolicy();
var_dump($meals);
PHP Notice: SOAP Fault: (Code: SOAP-ENV:Server, String: Function 'getMealPolicy' doesn't exist) - Request: Response: in /var/www/html/run/classes/modules/api/client/TimeTrexClientAPI.class.php on line 197
shaunw
Posts: 7839 Joined: Tue Sep 19, 2006 2:22 pm
Post
by shaunw » Mon Apr 20, 2015 7:48 am
You need to get the PolicyGroup data, then pull the user and meal policy data from that, something along these lines:
Code: Select all
$ttAPI_group = new TimeTrexClientAPI( 'PolicyGroup' );
$retval = $ttAPI_group->getPolicyGroup();
$retval will now contain the result of all your policy groups in an array, which will have 'user' and 'meal_policy' array elements.
Yajasi
Posts: 108 Joined: Wed Oct 17, 2012 4:48 pm
Post
by Yajasi » Tue Apr 21, 2015 10:46 pm
$retval will now contain the result of all your policy groups in an array, which will have 'user' and 'meal_policy' array elements.
Here is an excerpt of the return value. It does not have a 'user' or 'meal_policy' array element.
Code: Select all
array {
...
[10]=>
array(6) {
["id"]=>
int(44)
["name"]=>
string(20) "Staff - Mechanic"
["description"]=>
bool(false)
["total_users"]=>
int(11)
["updated_by"]=>
string(22) "TimeTrex Administrator"
["updated_date"]=>
string(14) "02-Apr-15 4:06"
}
[11]=>
array(6) {
["id"]=>
int(3)
["name"]=>
string(17) "Staff - Pilot"
["description"]=>
bool(false)
["total_users"]=>
int(11)
["updated_by"]=>
string(22) "TimeTrex Administrator"
["updated_date"]=>
string(14) "02-Apr-15 4:06"
}
}
Is there anything else I can try?
shaunw
Posts: 7839 Joined: Tue Sep 19, 2006 2:22 pm
Post
by shaunw » Wed Apr 22, 2015 8:08 am
It seems as though you may not be logging into the API as a full administrator that has permissions to view the data you are looking for.
Yajasi
Posts: 108 Joined: Wed Oct 17, 2012 4:48 pm
Post
by Yajasi » Wed Apr 22, 2015 5:14 pm
Thank you! We adjusted our permissions for the API user and were able to retrieve the desired information.