API how to get is user is clocked in or clocked out - getUserPunch
Posted: Mon Aug 19, 2019 2:34 am
Hello,
I am trying to get if a user has clocked in or clocked out.
From reading forums I understood that the api function getUserPunch should tell me this.
But I can't make it work.
I can add punches for a user. And because punches are set for automatic type (status_id=0) need to find out if the punch was clock in or clock out.
echo "user ID is: $id\n";
echo "username is: $username\n";
$punch_data2 = array(
#'id' => $id,
'user_name' => "$username",
#'user_id' => "NULL",
#'epoch' => "NULL",
'station_id' => "NULL",
#'company_id' => "NULL",
#'station_id' => '(ANY, ANY)',
);
$result = postToURL( buildURL( 'APIPunch', 'getUserPunch' ), array( $punch_data2 ) );
print $result;
=============================================================================================
user ID is: 11e9bcd7-65dd-12c0-9e76-6506ec593a72
username is: test
==============================================================
Posting data to URL: http://localhost/timetrex/api/json/api. ... 370553740f
POST Data: json=%5B%7B%22user_name%22%3A%22test%22%2C%22station_id%22%3A%22NULL%22%7D%5D
--------------------------------------------------------------
Returned:
IsValid: NO
Code: VALIDATION
Description: INVALID DATA
Details:
Row: 0
--Field: user_name
----Message: You are not authorized to punch in or out from this station!
===============================================================================================
Any help appretiated!
I am trying to get if a user has clocked in or clocked out.
From reading forums I understood that the api function getUserPunch should tell me this.
But I can't make it work.
I can add punches for a user. And because punches are set for automatic type (status_id=0) need to find out if the punch was clock in or clock out.
echo "user ID is: $id\n";
echo "username is: $username\n";
$punch_data2 = array(
#'id' => $id,
'user_name' => "$username",
#'user_id' => "NULL",
#'epoch' => "NULL",
'station_id' => "NULL",
#'company_id' => "NULL",
#'station_id' => '(ANY, ANY)',
);
$result = postToURL( buildURL( 'APIPunch', 'getUserPunch' ), array( $punch_data2 ) );
print $result;
=============================================================================================
user ID is: 11e9bcd7-65dd-12c0-9e76-6506ec593a72
username is: test
==============================================================
Posting data to URL: http://localhost/timetrex/api/json/api. ... 370553740f
POST Data: json=%5B%7B%22user_name%22%3A%22test%22%2C%22station_id%22%3A%22NULL%22%7D%5D
--------------------------------------------------------------
Returned:
IsValid: NO
Code: VALIDATION
Description: INVALID DATA
Details:
Row: 0
--Field: user_name
----Message: You are not authorized to punch in or out from this station!
===============================================================================================
Any help appretiated!