|
|
@ -19,7 +19,7 @@ class HumanResourceController extends Controller |
|
|
|
$this->validate($request, [ |
|
|
|
$this->validate($request, [ |
|
|
|
'role_id' => 'required', |
|
|
|
'role_id' => 'required', |
|
|
|
'name' => 'required', |
|
|
|
'name' => 'required', |
|
|
|
'ktp_number' => 'required|numeric|unique:m_users,ktp_number', |
|
|
|
'ktp_number' => 'required|string|unique:m_users,ktp_number', |
|
|
|
'employee_type' => 'required', |
|
|
|
'employee_type' => 'required', |
|
|
|
'company_id' => 'required' |
|
|
|
'company_id' => 'required' |
|
|
|
]); |
|
|
|
]); |
|
|
@ -44,7 +44,7 @@ class HumanResourceController extends Controller |
|
|
|
$this->validate($request, [ |
|
|
|
$this->validate($request, [ |
|
|
|
'role_id' => 'required', |
|
|
|
'role_id' => 'required', |
|
|
|
'name' => 'required', |
|
|
|
'name' => 'required', |
|
|
|
'ktp_number' => 'required|numeric|unique:m_users,ktp_number', |
|
|
|
'ktp_number' => 'required|string|unique:m_users,ktp_number', |
|
|
|
'employee_type' => 'required', |
|
|
|
'employee_type' => 'required', |
|
|
|
'company_id' => 'required', |
|
|
|
'company_id' => 'required', |
|
|
|
'username' => 'required', |
|
|
|
'username' => 'required', |
|
|
@ -60,7 +60,7 @@ class HumanResourceController extends Controller |
|
|
|
$result = HumanResource::create($data); |
|
|
|
$result = HumanResource::create($data); |
|
|
|
|
|
|
|
|
|
|
|
if ($result) { |
|
|
|
if ($result) { |
|
|
|
$this->sendEmail($request->email, $data['password']); |
|
|
|
$this->sendEmail($request->email, $request->password); |
|
|
|
return response()->json(['status' => 'success', 'message' => 'Human Resource Pool successfull created', 'code' => 200]); |
|
|
|
return response()->json(['status' => 'success', 'message' => 'Human Resource Pool successfull created', 'code' => 200]); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
return response()->json(['status' => 'failed', 'message' => 'Human Resource Pool failed created', 'code' => 400]); |
|
|
|
return response()->json(['status' => 'failed', 'message' => 'Human Resource Pool failed created', 'code' => 400]); |
|
|
@ -91,7 +91,7 @@ class HumanResourceController extends Controller |
|
|
|
} |
|
|
|
} |
|
|
|
$humanresource = HumanResource::find($id); |
|
|
|
$humanresource = HumanResource::find($id); |
|
|
|
|
|
|
|
|
|
|
|
$request->ktp_number !== $humanresource['ktp_number'] ? $this->validate($request,['ktp_number'=>'unique:m_users,ktp_number|numeric']) : ''; |
|
|
|
$request->ktp_number !== $humanresource['ktp_number'] ? $this->validate($request,['ktp_number'=>'unique:m_users,ktp_number|string']) : ''; |
|
|
|
$request->email !== $humanresource['email'] ? $this->validate($request,['email'=>'unique:m_users,email|email']) : ''; |
|
|
|
$request->email !== $humanresource['email'] ? $this->validate($request,['email'=>'unique:m_users,email|email']) : ''; |
|
|
|
$request->password ? $this->validate($request,['password'=>'required|min:8']) : ''; |
|
|
|
$request->password ? $this->validate($request,['password'=>'required|min:8']) : ''; |
|
|
|
|
|
|
|
|
|
|
@ -230,32 +230,28 @@ class HumanResourceController extends Controller |
|
|
|
Artisan::call('sync:integration-human-resources'); |
|
|
|
Artisan::call('sync:integration-human-resources'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function sendEmail($email, $hashPassword) |
|
|
|
public function sendEmail($email, $password) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$hashed = $hashPassword; |
|
|
|
$user = User::select('email', 'name', 'username')->where('email', $email)->first(); |
|
|
|
$user = User::select('email', 'name')->where('email', $email)->first(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!$user) { |
|
|
|
if (!$user) { |
|
|
|
return response()->json(['status' => 'error', 'message' => 'e-mail not found '], 400); |
|
|
|
return response()->json(['status' => 'error', 'message' => 'e-mail not found '], 400); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$this->reqHttpCurl($email, $hashed, $user->name); |
|
|
|
$this->reqHttpCurl($email, $password, $user->username, $user->name); |
|
|
|
// if (User::where('email', $email)->update(['password'=> md5($hashed)])) |
|
|
|
|
|
|
|
// return response()->json(['status' => 'success', 'code'=>200, 'message' => 'Password already sent to mail'], 200); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return response()->json(['status' => 'error', 'code'=>400, 'message' => 'e-mail not found '], 400); |
|
|
|
return response()->json(['status' => 'error', 'code'=>400, 'message' => 'e-mail not found '], 400); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private function reqHttpCurl($email, $password, $username) |
|
|
|
private function reqHttpCurl($email, $password, $username, $name) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$postData = [ |
|
|
|
$postData = [ |
|
|
|
"to" => $email, |
|
|
|
"to" => $email, |
|
|
|
"password"=> $password, |
|
|
|
"name" => $name, |
|
|
|
"name" => $username, |
|
|
|
"username" => $username, |
|
|
|
|
|
|
|
"password" => $password, |
|
|
|
"from" => "app.integrasia@integrasiautama.com", |
|
|
|
"from" => "app.integrasia@integrasiautama.com", |
|
|
|
"alias_from" => "ADW", |
|
|
|
"alias_from" => "OSPRO", |
|
|
|
"subject" => "Informasi Akun", |
|
|
|
"subject" => "Registration OSPRO", |
|
|
|
"body" => "informasi-akun-adw" |
|
|
|
"body" => "registration-ospro" |
|
|
|
]; |
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
$curl = curl_init(); |
|
|
|
$curl = curl_init(); |
|
|
|