|
|
@ -59,8 +59,8 @@ class UserToProyekController extends Controller |
|
|
|
return response()->json(['status'=>'failed','message'=>'data assign hr to proyek not found!','code'=>400], 400); |
|
|
|
return response()->json(['status'=>'failed','message'=>'data assign hr to proyek not found!','code'=>400], 400); |
|
|
|
die(); |
|
|
|
die(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if($result){ |
|
|
|
if($result){ |
|
|
|
return response()->json(['status'=>'success','message'=>'data assign hr to proyek successfully updated!','code'=>200], 200); |
|
|
|
return response()->json(['status'=>'success','message'=>'data assign hr to proyek successfully updated!','code'=>200], 200); |
|
|
|
}else{ |
|
|
|
}else{ |
|
|
@ -82,7 +82,7 @@ class UserToProyekController extends Controller |
|
|
|
return response()->json(['status'=>'failed','message'=>'data assign hr to proyek not found!','code'=>400], 400); |
|
|
|
return response()->json(['status'=>'failed','message'=>'data assign hr to proyek not found!','code'=>400], 400); |
|
|
|
die(); |
|
|
|
die(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if($delete){ |
|
|
|
if($delete){ |
|
|
|
return response()->json(['status'=>'success','message'=>'data assign hr to proyek successfully deleted!','code'=>200], 200); |
|
|
|
return response()->json(['status'=>'success','message'=>'data assign hr to proyek successfully deleted!','code'=>200], 200); |
|
|
@ -166,4 +166,49 @@ class UserToProyekController extends Controller |
|
|
|
|
|
|
|
|
|
|
|
return response()->json($data); |
|
|
|
return response()->json($data); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private function curlReq($url, $token){ |
|
|
|
|
|
|
|
$ch = curl_init(); |
|
|
|
|
|
|
|
$headers = [ |
|
|
|
|
|
|
|
'Authorization: '.$token |
|
|
|
|
|
|
|
]; |
|
|
|
|
|
|
|
curl_setopt($ch, CURLOPT_URL, $url); |
|
|
|
|
|
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); |
|
|
|
|
|
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$response = curl_exec($ch); |
|
|
|
|
|
|
|
if ($response === false) |
|
|
|
|
|
|
|
$response = curl_error($ch); |
|
|
|
|
|
|
|
curl_close($ch); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return json_decode($response); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getEmployeeIntegration(Request $request) { |
|
|
|
|
|
|
|
$search = urlencode($request->name); |
|
|
|
|
|
|
|
if(empty($search)) |
|
|
|
|
|
|
|
return response()->json(['status'=>'error', 'message'=>'Empty query string!'], 400); |
|
|
|
|
|
|
|
$url = str_replace("SEARCH", $search, config('api.adw').'/employees?emp_name=SEARCH'); |
|
|
|
|
|
|
|
$token = config('api.adw_token'); |
|
|
|
|
|
|
|
$firstResponse = $this->curlReq($url, $token); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if($firstResponse->total == 0) |
|
|
|
|
|
|
|
return response()->json(['status'=>'error', 'message' => 'Data not found!', 'code'=>404], 404); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$data = $firstResponse->data; |
|
|
|
|
|
|
|
return response()->json([$data]); |
|
|
|
|
|
|
|
$currentPage = 1; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if($firstResponse->last_page > 0) { |
|
|
|
|
|
|
|
do { |
|
|
|
|
|
|
|
$currentPage++; |
|
|
|
|
|
|
|
$response = $this->curlReq($url.'&page='.$currentPage, $token); |
|
|
|
|
|
|
|
foreach($response->data as $d){ |
|
|
|
|
|
|
|
array_push($data, $d); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} while ($currentPage < $firstResponse->last_page); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return response()->json(['status'=>'success', 'data'=> $data, 'total' => count($data), 'code'=>200], 200); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|