Esempio n. 1
0
     echo "Output File not set!\n";
     exit;
 }
 $TIMETREX_URL = $api_url;
 $api_session = new TimeTrexClientAPI();
 $api_session->Login($username, $password);
 if ($TIMETREX_SESSION_ID == FALSE) {
     echo "API Username/Password is incorrect!\n";
     exit(1);
 }
 //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;
     }
Esempio n. 2
0
    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;
    //Show error messages
}
Esempio n. 3
0
        return $return;
    }
    $TIMETREX_URL = $api_url;
    $api_session = new TimeTrexClientAPI();
    $api_session->Login($username, $password);
    if ($TIMETREX_SESSION_ID == FALSE) {
        echo "API Username/Password is incorrect!\n";
        exit;
    }
    echo "Session ID: {$TIMETREX_SESSION_ID}\n";
    if ($object != '') {
        $column_map = parseCSV($column_map_file, TRUE, FALSE, ',', 9216);
        if (is_array($column_map)) {
            foreach ($column_map as $column_map_row) {
                $column_map_arr[$column_map_row['timetrex_column']] = array('map_column_name' => $column_map_row['csv_column'], 'default_value' => $column_map_row['default_value'], 'parse_hint' => $column_map_row['parse_hint']);
            }
        } else {
            echo "Column map is invalid!\n";
        }
        $obj = new TimeTrexClientAPI('Import' . $object);
        $obj->setRawData(file_get_contents($import_csv_file));
        //var_dump( $obj->getOptions('columns') );
        $retval = $obj->Import($column_map_arr, array('fuzzy_match' => TRUE), $dry_run);
        if ($retval->getResult() == TRUE) {
            echo "Import successful!\n";
        } else {
            echo $retval;
            exit(1);
        }
    }
}