$user_data = array('status_id' => 10, 'first_name' => 'Michael', 'last_name' => 'Jackson', 'employee_number' => 239842, 'user_name' => 'mjackson', 'password' => 'whiteglove123', 'hire_date' => '01-Oct-09');
$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";
Beispiel #2
0
 //echo "Session ID: $TIMETREX_SESSION_ID\n";
 if ($report != '') {
     $report_obj = new TimeTrexClientAPI($report);
     $config = array();
     if ($saved_report != '') {
         $saved_report_obj = new TimeTrexClientAPI('UserReportData');
         $saved_report_result = $saved_report_obj->getUserReportData(array('filter_data' => array('name' => trim($saved_report))));
         $saved_report_data = $saved_report_result->getResult();
         if (is_array($saved_report_data) and isset($saved_report_data[0]) and isset($saved_report_data[0]['data'])) {
             $config = $saved_report_data[0]['data']['config'];
         } else {
             echo "ERROR: Saved report not found...\n";
             exit(1);
         }
     } elseif ($template != '') {
         $config_result = $report_obj->getTemplate($template);
         $config = $config_result->getResult();
     }
     if ($time_period != '' and isset($config['-1010-time_period'])) {
         $config['-1010-time_period']['time_period'] = $time_period;
     }
     //var_dump($config);
     $result = $report_obj->getReport($config, strtolower($file_format));
     $retval = $result->getResult();
     if (is_array($retval)) {
         if (isset($retval['file_name']) and $output_file == '') {
             $output_file = $retval['file_name'];
         }
         file_put_contents($output_file, base64_decode($retval['data']));
     } else {
         var_dump($retval);