CHANGE_EMP_REST_EMP_UPLOAD_FIREBASE_JSON : AADHAVAN

This commit is contained in:
aadhavan valli 2024-07-20 16:40:29 +05:30
parent 3d03a6f063
commit 8d3f31413c

View File

@ -632,6 +632,7 @@ class EmployeeRestController extends AdminController
$policy_id = $this->request->getPost('policy_id');
$client_data = $this->clientModel->where('id', $client_id)->first();
$notification = $this->notificationModel->where('client_id',$client_id)->where('template_name','member_welcome_mail')->first();
$jwt = $this->request->getHeader('Authorization');
@ -742,13 +743,13 @@ class EmployeeRestController extends AdminController
$basic_cover_si= [];
foreach ($extra['0'] as $index => $id) {
$relation ='';
if ($extra['5'][$index] === 'Mother' || $extra['5'][$index] === 'Father') {
if (strtolower(trim($extra['5'][$index])) === 'mother' || strtolower(trim($extra['5'][$index])) === 'father') {
$relation = 'parent';
} else if($extra['5'][$index] === 'Son' || $extra['5'][$index] === 'Daughter'){
} else if(strtolower(trim($extra['5'][$index])) === 'son' || strtolower(trim($extra['5'][$index])) === 'daughter'){
$relation = 'child';
}else if($extra['5'][$index] === 'Father in Law' || $extra['5'][$index] === 'Mother in Law'){
}else if(strtolower(trim($extra['5'][$index])) === 'father in law' || strtolower(trim($extra['5'][$index])) === 'mother in law'){
$relation = 'parent_in_law';
}else if($extra['5'][$index] === 'Spouse'){
}else if(strtolower(trim($extra['5'][$index])) === 'spouse'){
$relation = 'spouse';
}else{
$relation = 'self';
@ -777,7 +778,7 @@ class EmployeeRestController extends AdminController
// Check if the 'doj' key exists before accessing it
'doj' => $doj_new_format,
'gender' => $extra['4'][$index],
'relationship' => ucfirst($extra['5'][$index]),
'relationship' => ucfirst(trim($extra['5'][$index])),
'family_floater_key' => $relation,
'dob' => $dob_new_format,
'email_corporate' => $extra['7'][$index],
@ -888,10 +889,10 @@ class EmployeeRestController extends AdminController
$emp_policy = $this->employeePolicyModel->insert($emp_policy_data);
}
$notification = $this->notificationModel->where('client_id',$client_id)->where('template_name','member_welcome_mail')->first();
if (isset($notification) && $notification['enabled'] == 1 && !empty($notification['mail_content'])) {
if (isset($notification) && $notification['enabled'] == 1) {
//trigger
$wholeData=[];
if ($dataToInsert[$a]['relationship'] == 'Self' && isset($dataToInsert[$a]['email_corporate']) && !empty($dataToInsert[$a]['email_corporate'])) {
$params['dataToInsert'] = $dataToInsert[$a];
@ -2323,9 +2324,10 @@ class EmployeeRestController extends AdminController
public function storeFireBase()
{
try {
$firebase_token = $this->request->getPost('firebase_token');
$mobile = $this->request->getPost('mobile');
// try {
$json = $this->request->getJSON();
$firebase_token = $json->firebase_token;
$mobile = $json->mobile;
// Ensure the mobile number is provided
if (empty($mobile)) {
@ -2368,10 +2370,10 @@ class EmployeeRestController extends AdminController
} else {
return $this->respond(['status' => 'failed', 'code' => 404, 'message' => 'Employee not found'], 404);
}
} catch (\Throwable $th) {
log_message('error', 'An error occurred: ' . $th->getMessage());
return $this->respond(['status' => 'failed', 'code' => 500, 'message' => 'An error occurred', 'error' => $th->getMessage()], 500);
}
// } catch (\Throwable $th) {
// log_message('error', 'An error occurred: ' . $th->getMessage());
// return $this->respond(['status' => 'failed', 'code' => 500, 'message' => 'An error occurred', 'error' => $th->getMessage()], 500);
// }
}