From d00a2d348332b9c5af795c781dd283d4ed4e9499 Mon Sep 17 00:00:00 2001 From: Cris Date: Tue, 4 Sep 2018 12:27:06 +0200 Subject: [PATCH] Added function to get errors from CastTimeServer --- include/functions.inc.php | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/include/functions.inc.php b/include/functions.inc.php index 6f6c5cc3b..be021b6f5 100644 --- a/include/functions.inc.php +++ b/include/functions.inc.php @@ -1097,4 +1097,42 @@ function PersonLog($person_id, $logtype_kurzbz, $logdata, $taetigkeit_kurzbz, $a $personlog = new personlog(); $personlog->log($person_id, $logtype_kurzbz, $logdata, $taetigkeit_kurzbz, $app, $oe_kurzbz, $user); } + +/** + * Sendet einen Request an den CaseTime Server um die Daten dort zu speichern + */ +function getCaseTimeErrors($uid) +{ + $ch = curl_init(); + + $url = CASETIME_SERVER.'/sync/get_zeitfehler'; + + $params = 'sachb='.$uid; + + curl_setopt($ch, CURLOPT_URL, $url.'?'.$params ); //Url together with parameters + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //Return data instead printing directly in Browser + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT , 7); //Timeout after 7 seconds + curl_setopt($ch, CURLOPT_USERAGENT , "FH-Complete CaseTime Addon"); + curl_setopt($ch, CURLOPT_HEADER, 0); + + $result = curl_exec($ch); + + if(curl_errno($ch)) + { + return 'Curl error: ' . curl_error($ch); + curl_close($ch); + } + else + { + curl_close($ch); + $data = json_decode($result); + + if(isset($data->STATUS) && $data->STATUS=='OK') + { + return $data->RESULT; + } + else + return false; + } +} ?>