Page 1 of 1

Quick API Questions

Posted: Tue Nov 04, 2014 10:56 am
by Cynjut
Three quick SOAP API questions in the latest (7.4.6) version:

1) When I filter the user API for phone_id (also called punch_id in a couple of things I've read), I get all records. If I do the same search using employee number, I get a single record. Is there something special about filtering on the phone_id? If filtering by phone_id (or one of the other id's in the API) is only available in the commercial version, I'm good with that, I just need to know.

2) I want to implement a system that punches employees in and out based on a "big red button" in an application I wrote and/or allows the employees to clock in from their Asterisk desk phone. (See long note below) In order to do those, I need to find out if an employee is authorized a lunch break in their current scheduled shift. This is so they can "push the button" when they sit down and be "on the clock". When they push the button at lunch time (based on their meal policy for this shift) I want to clock them out to lunch, and then push the button to punch them back in from lunch when they come back. At the end of the day, I want to clock them out for the day. There will be exceptions (people get sick, or leave at lunch and take LWOP for the afternoon) and handling that manually is fine. The question then is "where can I get the employee's current meal policy information for the shift they are currently in?" If someone's feeling magnanimous, you can also mention the short version of the same question for the "Break Policy" object associated with the current shift. That way, if they're authorized a couple of cigarette breaks, we can document that.

3) If I want to run the big-red-button PHP script on a whole slew of remote machines or on the Asterisk phone servers that talk to the SOAP API on the server, do I need anything more from TimeTrex than the ".../TimeTrex/classes/modules/api/client/TimeTrexClientAPI.class.php" file (or perhaps the ".../api/client/" directory) installed on the remote machines? I know there are a lot of dependencies that I'll need to install, but is this PHP class definition the only one I'll need to add to the server update package for the rest of the workstations? I'm in complete control of the workstations and servers but I don't want to have to install the entire TimeTrex distribution on every workstation for a file or two.

Unless you want to read me whining, you should stop here. :-)

Background notes: This business application runs on a few hundred workstations and provides the employees with everything they need to do their job. it already integrates custom code, Asterisk dialer support, SugarCRM, and RT4 to give them everything they need on (basically) a single screen. Having them log out of the app, log into anything else, and log back into the app takes more time than the floor guys are willing to donate. Because of that, if I can't implement the big boss' additional "features" in the app, they don't want me to do it. They are spread out all over campus and a distributed time accounting system has already been discussed and shot down hard (the boss is already tired of paying for the time it takes to get from the existing time clocks to the workstations). The hand-jammed time accounting system is starting to make the bookkeeper a little testy and there are other things that we'd like to start tracking other than meals and breaks (like production quotas and client time codes), so moving to the next level will require SOMETHING, and I think TimeTrex is the answer to the question. The problem is that I need to show her how we're going to do this before she'll break loose any of her kids' future inheritance. So, we're starting with the community version to see if this is going to work. After that, she'll decide on what direction I end up going to support her needs.

Any help you can provide would be greatly appreciated.

Re: Quick API Questions

Posted: Tue Nov 04, 2014 6:12 pm
by shaunw
Cynjut wrote:Three quick SOAP API questions in the latest (7.4.6) version:

1) When I filter the user API for phone_id (also called punch_id in a couple of things I've read), I get all records. If I do the same search using employee number, I get a single record. Is there something special about filtering on the phone_id? If filtering by phone_id (or one of the other id's in the API) is only available in the commercial version, I'm good with that, I just need to know.
This is not currently available from the API.
Cynjut wrote: 2) I want to implement a system that punches employees in and out based on a "big red button" in an application I wrote and/or allows the employees to clock in from their Asterisk desk phone. (See long note below) In order to do those, I need to find out if an employee is authorized a lunch break in their current scheduled shift. This is so they can "push the button" when they sit down and be "on the clock". When they push the button at lunch time (based on their meal policy for this shift) I want to clock them out to lunch, and then push the button to punch them back in from lunch when they come back. At the end of the day, I want to clock them out for the day. There will be exceptions (people get sick, or leave at lunch and take LWOP for the afternoon) and handling that manually is fine. The question then is "where can I get the employee's current meal policy information for the shift they are currently in?" If someone's feeling magnanimous, you can also mention the short version of the same question for the "Break Policy" object associated with the current shift. That way, if they're authorized a couple of cigarette breaks, we can document that.
Handling lunch/breaks like this can actually get extremely complicated if you want to do it yourself. But it depends on how exactly you want to determine if an employee is actually punching for lunch and not out at the end of day for example. Further down in your post you mention the potential to track time to specific clients, that further complicates things too.

You'll need to define the "rules" that determine lunch/break and how that will work (separate from TimeTrex), then once those are well defined it may be easier to find a solution to this.
Cynjut wrote: 3) If I want to run the big-red-button PHP script on a whole slew of remote machines or on the Asterisk phone servers that talk to the SOAP API on the server, do I need anything more from TimeTrex than the ".../TimeTrex/classes/modules/api/client/TimeTrexClientAPI.class.php" file (or perhaps the ".../api/client/" directory) installed on the remote machines? I know there are a lot of dependencies that I'll need to install, but is this PHP class definition the only one I'll need to add to the server update package for the rest of the workstations? I'm in complete control of the workstations and servers but I don't want to have to install the entire TimeTrex distribution on every workstation for a file or two.
Nope, that is all you need to access the SOAP API.
Cynjut wrote: Unless you want to read me whining, you should stop here. :-)

Background notes: This business application runs on a few hundred workstations and provides the employees with everything they need to do their job. it already integrates custom code, Asterisk dialer support, SugarCRM, and RT4 to give them everything they need on (basically) a single screen. Having them log out of the app, log into anything else, and log back into the app takes more time than the floor guys are willing to donate. Because of that, if I can't implement the big boss' additional "features" in the app, they don't want me to do it. They are spread out all over campus and a distributed time accounting system has already been discussed and shot down hard (the boss is already tired of paying for the time it takes to get from the existing time clocks to the workstations). The hand-jammed time accounting system is starting to make the bookkeeper a little testy and there are other things that we'd like to start tracking other than meals and breaks (like production quotas and client time codes), so moving to the next level will require SOMETHING, and I think TimeTrex is the answer to the question. The problem is that I need to show her how we're going to do this before she'll break loose any of her kids' future inheritance. So, we're starting with the community version to see if this is going to work. After that, she'll decide on what direction I end up going to support her needs.

Any help you can provide would be greatly appreciated.
Based on your long-term goals it seems like the "big red button" may be a much too simplistic solution. Quite a few companies using TimeTrex simply use a "big red button" that opens the TimeTrex Punch screen (or in the commercial versions, the Quick Punch screen), then they don't have to reinvent the wheel when dealing with things like meal/breaks and tracking time to clients, and its still fast/easy for the employees to use.

Re: Quick API Questions

Posted: Wed Nov 05, 2014 7:29 am
by Cynjut
Thanks for the info Shaun.

I appreciate your help again and the confirmation of the API information.

Is there a link somewhere that talks to the public data array elements we can filter on by API object and/or the public members of the data objects for each API call? I'm using the database schema now, which may not be accurate all the time? I'm using the document at http://www.timetrex.com/help/developers ... index.html right now.

To partially answer my own question, right now I'm using the Punch API to put in an automatic punch (which returns the new PunchID). From there, I grab the newly inserted punch from the GetPunch API to get the information from the "new" punch. From there I grab the PunchControlID and the information associated with that item (which includes the "default" mail policy ID). From there, I think I can use that data (from the punch and punchcontrol data arrays) to figure out what I need.

This really is an awesome piece of software. I keep plugging away with it and keep finding cool things it can do.

Thanks.

Re: Quick API Questions

Posted: Wed Nov 05, 2014 9:07 am
by shaunw
To find out what you can filter by, check the classes/modules/user/UserListFactory.class.php file, near the bottom is a function getAPISearchByCompanyIdAndArrayCriteria(), in there you will see what columns that can be searched by.

Re: Quick API Questions

Posted: Wed Nov 05, 2014 9:21 am
by Cynjut
Got it. Thanks.