Getting all types of absences through the API

Discussion for TimeTrex open source community developers.
Post Reply
bdrayer
Posts: 6
Joined: Fri Feb 13, 2015 1:36 am

Getting all types of absences through the API

Post by bdrayer »

Hi,

I actually use a really old version of Timetrex and I am doing all my external request using SQL command (it work well). I am actually trying to migrate to a newer version of timetrex and want to use the API (with PHP) to do my requests but I am facing a problem.

I can get punches using postToURL(buildURL('APIPunch', 'getPunch'), array($arguments)) and I can also get Holidays using postToURL(buildURL('APIAccrual', 'getAccrual'), array($arguments)) but can't get other type of absences like, for example, Sick (Paid).

All the informations are stored on the table user_date_total but when I try to get the informations using postToURL(buildURL('APIUserDateTotal', 'getUserDateTotal()'), array($arguments)) it says me it's a private function (but it's public in the documentation).

I must say that the API documentation is really complicated to understand, ...

Anyone have an Idea how I can get such informations?

Thanks in advance for your help :-)
mikeb
Posts: 709
Joined: Thu Jul 27, 2006 11:58 am

Re: Getting all types of absences through the API

Post by mikeb »

What is that you are trying to achieve exactly? If you are wanting to retrieve time worked and absence time, often its easiest to use a report like TimeSheetDetail instead.

APIUserDateTotal->getUserDateTotal() is definitely an API call you can make assuming you are logged in with the proper permissions. If you post the full and exact error message, we would be able to assist you much better.
TimeTrex Community Edition is developed and supported by volunteers.
Help motivate us to continue by showing your appreciation!
bdrayer
Posts: 6
Joined: Fri Feb 13, 2015 1:36 am

Re: Getting all types of absences through the API

Post by bdrayer »

I actually have developped an application, based on the data from Timetrex, managing Holidays, overtime and also management of absences as well as some data that are not stored in Timetrex (but are mixed with timetrex data).

It work pretty well (but slow) using SQL request and my really old version of timetrex but I want, if possible, use the API to get the data (I actually have a lot of views inside the Timetrex database) due to the fact I will need to rewrite a part of it due to the changes between my version of timetrex and the new one.

If not possible, I will juste continue to use SQL to get the data, but to be more compatible with other persons installation and be able to share my work when it work correctly, I think it's better if I can create an API based version of my work.
Attachments
TMS2.png
TMS1.png
mikeb
Posts: 709
Joined: Thu Jul 27, 2006 11:58 am

Re: Getting all types of absences through the API

Post by mikeb »

API approach is definitely the one to take. If you provide us with the exact error message you are receiving, it would be helpful.
TimeTrex Community Edition is developed and supported by volunteers.
Help motivate us to continue by showing your appreciation!
bdrayer
Posts: 6
Joined: Fri Feb 13, 2015 1:36 am

Re: Getting all types of absences through the API

Post by bdrayer »

OK, I get it working. But what kind of parameters can use to filter APIUserDateTotal->getUserDateTotal()? user_id, start_date and end_date seems to work well but status_id not for example.
mikeb
Posts: 709
Joined: Thu Jul 27, 2006 11:58 am

Re: Getting all types of absences through the API

Post by mikeb »

You can search by almost any field that it returns.

You can find the specific filter criteria in the code itself: UserDateTotalListFactory->getAPISearchByCompanyIdAndArrayCriteria()
TimeTrex Community Edition is developed and supported by volunteers.
Help motivate us to continue by showing your appreciation!
Post Reply