Example #1
0
$result = $user_obj->setUser($user_data);
if ($result->isValid() === TRUE) {
    echo "Employee added successfully.<br>\n";
    $insert_id = $result->getResult();
    //Get employees new ID on success.
} else {
    echo "Employee save failed.<br>\n";
    print $result;
    //Show error messages
}
//
//Get TimeSheet Summary report data in raw PHP native array format. 'csv' and 'pdf' are also valid formats.
//
$report_obj = new TimeTrexClientAPI('TimesheetSummaryReport');
$config = $report_obj->getTemplate('by_employee+regular+overtime+premium+absence')->getResult();
$result = $report_obj->getTimesheetSummaryReport($config, 'raw');
echo "Report Data: <br>\n";
print $result;
//
//Add punch for employee
//
$punch_obj = new TimeTrexClientAPI('Punch');
$punch_data = array('user_id' => 1023, 'type_id' => 10, 'status_id' => 20, 'time_stamp' => strtotime('19-Aug-2013 5:50PM'), 'branch_id' => 296, 'department_id' => 896, 'job_id' => 610, 'job_item_id' => 9);
$result = $punch_obj->setPunch($punch_data);
if ($result->isValid() === TRUE) {
    echo "Punch added successfully.<br>\n";
    $insert_id = $result->getResult();
    //Get employees new ID on success.
} else {
    echo "Punch save failed.<br>\n";
    print $result;