From 894f1357a97b254292724121208a6a37037340bc Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Thu, 28 Nov 2024 09:20:02 +0530 Subject: [PATCH 01/78] CHANGE_in emp login api added additional where condition : GWM --- app/Controllers/EmployeeRestController.php | 64 +++++++++---------- .../RestAuthenticationController.php | 4 +- 2 files changed, 35 insertions(+), 33 deletions(-) diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 0684f727..f0f1925e 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -2502,7 +2502,7 @@ class EmployeeRestController extends AdminController public function storeFireBase() { - // try { + try { $json = $this->request->getJSON(); $firebase_token = $json->firebase_token; $mobile = $json->mobile; @@ -2548,39 +2548,39 @@ 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); - // } - } - - - - - - public function sendPushNotification() - { - $deviceToken = 'cMVKESh8QzqIl8nh_yqbcl:APA91bHKm87Sh1goVJNKZtctV4etgLMQboI0eyDVn3MH1yf9cO-2RtQRlFnKLdataOxosoxm7a4JvATKjfI1_Bids46mGw5m8zesp90mR4odCbD_cJtGmBeMYt4hssSY0YtAht1emK_H'; - $title = 'Nhance'; - $body = 'All your policy enrolled successfully ..!'; - - // Initialize Firebase with the service account - $firebase = (new Factory) - ->withServiceAccount(APPPATH . 'Config/google-services.json') - ->createMessaging(); - - $notification = Notification::create($title, $body); - $message = CloudMessage::withTarget('token', $deviceToken) - ->withNotification($notification); - - try { - $firebase->send($message); - return $this->response->setJSON(['status' => 'success']); - } catch (MessagingException $e) { - //return $this->response->setJSON(['status' => 'error', 'message' => $e->getMessage()]); - log_message('error', $e->getMessage()); + } 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); } } + + + + + + // public function sendPushNotification() + // { + // $deviceToken = 'cMVKESh8QzqIl8nh_yqbcl:APA91bHKm87Sh1goVJNKZtctV4etgLMQboI0eyDVn3MH1yf9cO-2RtQRlFnKLdataOxosoxm7a4JvATKjfI1_Bids46mGw5m8zesp90mR4odCbD_cJtGmBeMYt4hssSY0YtAht1emK_H'; + // $title = 'Nhance'; + // $body = 'All your policy enrolled successfully ..!'; + + // // Initialize Firebase with the service account + // $firebase = (new Factory) + // ->withServiceAccount(APPPATH . 'Config/google-services.json') + // ->createMessaging(); + + // $notification = Notification::create($title, $body); + // $message = CloudMessage::withTarget('token', $deviceToken) + // ->withNotification($notification); + + // try { + // $firebase->send($message); + // return $this->response->setJSON(['status' => 'success']); + // } catch (MessagingException $e) { + // //return $this->response->setJSON(['status' => 'error', 'message' => $e->getMessage()]); + // log_message('error', $e->getMessage()); + // } + // } diff --git a/app/Controllers/RestAuthenticationController.php b/app/Controllers/RestAuthenticationController.php index bed2e473..737265cf 100755 --- a/app/Controllers/RestAuthenticationController.php +++ b/app/Controllers/RestAuthenticationController.php @@ -73,6 +73,7 @@ class RestAuthenticationController extends AdminController $employeeData = $this->employeeModel->where('mobile', $mobile_number) ->where('relationship', 'self') + ->where('emp_status !=', 'truncated') ->where('is_active', 1)->first(); if ($employeeData) { @@ -137,7 +138,8 @@ class RestAuthenticationController extends AdminController $HrData = $this->hrModel->where('mobile', $mobile_number) ->where('contact_type', 'client') - ->where('is_active', 1)->first(); + ->where('is_active', 1) + ->first(); if ($HrData) { From bb033fa8be97bc54cd896d5a9fb876363c307544 Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Thu, 28 Nov 2024 09:24:13 +0530 Subject: [PATCH 02/78] CHANGE_in emp login api added additional where condition : GWM --- app/Controllers/RestAuthenticationController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Controllers/RestAuthenticationController.php b/app/Controllers/RestAuthenticationController.php index 737265cf..14b61d7d 100755 --- a/app/Controllers/RestAuthenticationController.php +++ b/app/Controllers/RestAuthenticationController.php @@ -74,7 +74,8 @@ class RestAuthenticationController extends AdminController $employeeData = $this->employeeModel->where('mobile', $mobile_number) ->where('relationship', 'self') ->where('emp_status !=', 'truncated') - ->where('is_active', 1)->first(); + ->where('is_active', 1) + ->first(); if ($employeeData) { From 8128a95c66468eaf46264e3bb2db19a93ef1dac0 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Thu, 28 Nov 2024 10:10:26 +0530 Subject: [PATCH 03/78] FIX_BULK_MAIL_ISSUE : RV --- app/Controllers/EmployeeRestController.php | 35 ++++++++++++++----- app/Controllers/EmployeeServiceController.php | 28 +++++++++++---- 2 files changed, 48 insertions(+), 15 deletions(-) diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 0684f727..058e1ed5 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -695,6 +695,7 @@ class EmployeeRestController extends AdminController $decodedPayload = json_decode(base64_decode(explode('.', $token)[1]), true); // get the employee id from token $employee_id = $decodedPayload['id']; + // $employee_id = 1; $client_policy = $this->clientPolicyModel->where('id', $policy_id)->where('client_id', $client_id)->where('client_branch_id', $client_branch_id)->first(); if ($client_policy) { $policy = $this->policesModel->where('id', $client_policy['policy_id'])->first(); @@ -875,7 +876,10 @@ class EmployeeRestController extends AdminController $basic_cover_si[]= $basic_cover_si_value; } } + $count = 0; + $wholeData=[];// Initialize an empty array to store employee email. + for ($a=0; $a 0) { - $job_details = new Jobs(); - $r = Jobs::addJob(['job_name' => 'bulk_mail','payload' => $wholeData]); - $wholeData = []; - $count = 0; - } - } + + // if($count == 20 || $a == count($dataToInsert)-1){ + // if (count($wholeData) > 0) { + // $job_details = new Jobs(); + // $r = Jobs::addJob(['job_name' => 'bulk_mail','payload' => $wholeData]); + // $wholeData = []; + // $count = 0; + // } + // } // if ($dataToInsert[$a]['email_corporate'] != null || $dataToInsert[$a]['email_corporate'] != '' && $dataToInsert[$a]['relationship'] == 'Self') { } } + + // for bulk mail queue job push + if (!empty($wholeData) && count($wholeData) > 0) { + + $wholeData = array_chunk($wholeData, 20); + + foreach ($wholeData as $key => $value) { + $job_details = new Jobs(); + $r = Jobs::addJob(['job_name' => 'bulk_mail', 'payload' => $value]); + } + } + $this->fileModel->where('id', $file_id)->set(['status' => 'success','reason' => '','error_data' => ''])->update(); return $this->respond(['status' => 'success', 'code' => 200, 'message' => "Success" ], 200); }else{ diff --git a/app/Controllers/EmployeeServiceController.php b/app/Controllers/EmployeeServiceController.php index 6756e470..e48dbc76 100755 --- a/app/Controllers/EmployeeServiceController.php +++ b/app/Controllers/EmployeeServiceController.php @@ -1979,6 +1979,9 @@ public function employeesEnrollmentInsert($params) // dd($notification); $client_details = $this->clientModel->where('id', $file['client_id'])->first(); + + $emp_emails = []; // Initialize an empty array to store employee email. + foreach ($excel_data as $key => $row) { // dd($key.'-'.count($excel_data)); @@ -2095,17 +2098,30 @@ public function employeesEnrollmentInsert($params) // Kint::dump($emp_emails); // Kint::dump($key.'-'.count($excel_data)); // if mail count is 20 send bulk mail and reset emp_emails variable - if (count($emp_emails) == 20 || $key == count($excel_data) ) { - $job_details = new Jobs(); - $r = Jobs::addJob(['job_name' => 'bulk_mail','payload' => $emp_emails]); - // echo 'Mail triggered'; - $emp_emails = []; - } + // if (count($emp_emails) == 20 || $key == count($excel_data) ) { + // $job_details = new Jobs(); + // $r = Jobs::addJob(['job_name' => 'bulk_mail','payload' => $emp_emails]); + // // echo 'Mail triggered'; + // $emp_emails = []; + // } } } } //end of for loop + + // for bulk mail queue job push + if (!empty($emp_emails) && count($emp_emails) > 0) { + + $emp_emails = array_chunk($emp_emails, 20); + + foreach ($emp_emails as $key => $value) { + $job_details = new Jobs(); + $r = Jobs::addJob(['job_name' => 'bulk_mail', 'payload' => $value]); + } + } + + $this->fileModel->where('id', $file_id)->set(['status' => 'success','reason' => ''])->update(); $this->myLogger->logme("error",'{file_id} uploaded success',['file_id' => $file_id]); From 038475ae0f49debe50856e12eb805abeb9356f9d Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Thu, 28 Nov 2024 15:31:48 +0530 Subject: [PATCH 04/78] CHANGE_VIEW_ENROLLMENT_FAMILY_FILTER_AND_POLICY_TERMS_SCRIPT : RV --- app/Controllers/ClientController.php | 107 +++++++++++-------------- app/Controllers/EmployeeController.php | 8 +- app/Views/enrollment_list.php | 2 + 3 files changed, 54 insertions(+), 63 deletions(-) diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 06f29c30..7b8e9cf8 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -3583,10 +3583,10 @@ class ClientController extends AdminController { $data = $this->clientPolicyModel - ->where("policy_terms IS NOT NULL AND policy_terms <> ''") - ->where('policy_type_id', 2) - ->where('is_active', 1) - ->findAll(); + ->where("policy_terms IS NOT NULL AND policy_terms <> ''") + ->where('policy_type_id', 2) + ->where('is_active', 1) + ->findAll(); for ($i = 0; $i < count($data); $i++) { @@ -3599,80 +3599,63 @@ class ClientController extends AdminController // Set default value of copayzonewisecopay to "empty" $ans = isset($policyTerms['copayzonewisecopay']) ? $policyTerms['copayzonewisecopay'] : 'empty'; - // Initialize an empty array for the ordered policy terms $orderedPolicyTerms = []; // Add copayzonewisecopay and copayzonewisecopaydata if they exist_ if (isset($policyTerms['copayzonewisecopay'])) { - - $orderedPolicyTerms['copayzonewisecopay'] = $policyTerms['copayzonewisecopay']; - $orderedPolicyTerms['co_pay_details'] = isset($policyTerms['co_pay_details']) ? $policyTerms['co_pay_details'] : ''; - } + if(!isset($policyTerms['co_pay_details'])){ + + $co_pay_details_value = ""; + if (strtolower($ans) == "nil" || $ans == 0) { + $policyTerms['copayzonewisecopay'] = 0; + $co_pay_details_value = ""; + } elseif ($ans != 'empty' && $ans !== 'Nil' && $ans !== null && $ans != '' && $ans != 0) { + $policyTerms['copayzonewisecopay'] = 1; + $co_pay_details_value = $ans; + } + + $co_pay_index = array_search('copayzonewisecopay', array_keys($policyTerms)); + $orderedPolicyTerms[] = [ + "key" => "co_pay_details", + "value" => $co_pay_details_value, + "position" => $co_pay_index + 1, + ]; + + unset($policyTerms['optionalparentalcopay']); + + } + } // Add ailmentcapping and ailmentcappingdata if they exist_ if (isset($policyTerms['ailmentcapping'])) { - $orderedPolicyTerms['ailmentcapping'] = $policyTerms['ailmentcapping']; - $orderedPolicyTerms['ailment_capping_details'] = isset($policyTerms['ailment_capping_details']) ? $policyTerms['ailment_capping_details'] : ''; - } - - - // Now add the rest of the policy terms that are not copayzonewisecopay, copayzonewisecopaydata, ailmentcapping, or ailmentcapping_data_ - foreach ($policyTerms as $key => $value) { - if (!in_array($key, ['copayzonewisecopay', 'co_pay_details', 'ailmentcapping', 'ailment_capping_details'])) { - $orderedPolicyTerms[$key] = $value; + if(!isset($policyTerms['ailment_capping_details'])){ + $aliment_index = array_search('ailmentcapping', array_keys($policyTerms)); + $orderedPolicyTerms[] = [ + "key" => "ailment_capping_details", + "value" => "", + "position" => $aliment_index + 2, + ]; } } + foreach ($orderedPolicyTerms as $term) { + $position = $term['position']; + $key = $term['key']; + $value = $term['value']; // Insert the key-value pair at the specified index + $policyTerms = array_merge( + array_slice($policyTerms, 0, $position, true), + [$key => $value], + array_slice($policyTerms, $position, null, true) + ); + } // Re-encode the ordered policy terms - $updatedPolicyTerms = json_encode($orderedPolicyTerms); + $updatedPolicyTerms = json_encode($policyTerms); - - // Update the policyterms in the database_ + // dd($orderedPolicyTerms, $updatedPolicyTerms); $this->clientPolicyModel->update($data[$i]['id'], ['policy_terms' => $updatedPolicyTerms]); - - - // Handle different conditions for copayzonewisecopay - if (strtolower($ans) == "nil" || $ans == 0) { - // If copayzonewisecopay is "nil" or 0, reset it to 0 and add copayzonewisecopaydata as empty_ - if (isset($orderedPolicyTerms['copayzonewisecopay'])) { - $orderedPolicyTerms['copayzonewisecopay'] = 0; - $orderedPolicyTerms['co_pay_details'] = ""; - } - - - // Rebuild the array after modification - foreach ($policyTerms as $key => $value) { - if (!in_array($key, ['copayzonewisecopay', 'co_pay_details'])) { - $orderedPolicyTerms[$key] = $value; - } - } - - - $updatedPolicyTerms = json_encode($orderedPolicyTerms); - $this->clientPolicyModel->update($data[$i]['id'], ['policy_terms' => $updatedPolicyTerms]); - continue; - } elseif ($ans != 'empty' && $ans !== 'Nil' && $ans !== null && $ans != '' && $ans != 0) { - // If copayzonewisecopay has a valid value, update it - if (isset($orderedPolicyTerms['copayzonewisecopay'])) { - $orderedPolicyTerms['copayzonewisecopay'] = 1; - $orderedPolicyTerms['co_pay_details'] = $ans; - } - - - // Rebuild the array after modification - foreach ($policyTerms as $key => $value) { - if (!in_array($key, ['copayzonewisecopay', 'co_pay_details'])) { - $orderedPolicyTerms[$key] = $value; - } - } - - - $updatedPolicyTerms = json_encode($orderedPolicyTerms); - $this->clientPolicyModel->update($data[$i]['id'], ['policy_terms' => $updatedPolicyTerms]); - } } } diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index c308d65f..9afb44b2 100755 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -734,11 +734,16 @@ class EmployeeController extends AdminController employees.emp_status, auth_history.user_type') ->join('employees', $client_id .'= employees.client_id AND ' . $branch_id . '= employees.client_branch_id', 'left') ->join('auth_history', 'employees.id = auth_history.user_id AND "employee" = auth_history.user_type', 'left') + ->where('employees.is_active', 1) + ->where('employees.emp_status !=', 'truncated') + ->groupBy('employees.id') ->findAll(); $groupedData = []; $employeeId = ''; + foreach ($results as $row) { + if($employeeId != $row['employee_id']){ $employeeId = $row['employee_id']; }else{ @@ -751,7 +756,8 @@ class EmployeeController extends AdminController $employeeUserType = $row['user_type']; - if ($employeeId !== null && $employeeRelationship == 'Self') { + // if ($employeeId !== null && $employeeRelationship == 'Self') { + if ($employeeId !== null) { // Append employee info to the branch's employees list $groupedData[] = [ 'employee_id' => $employeeId, diff --git a/app/Views/enrollment_list.php b/app/Views/enrollment_list.php index 3d37096a..edbdd473 100755 --- a/app/Views/enrollment_list.php +++ b/app/Views/enrollment_list.php @@ -180,6 +180,7 @@ SNO Name Emp Code + Relationship Enroled Logged-In @@ -336,6 +337,7 @@ index + 1, employee.employee_name, employee.emp_code, + employee.relationship, enrolled, loggedIn ]); From 4fa7537a636a232fc1b99a1bcac6b07763a56a55 Mon Sep 17 00:00:00 2001 From: velz Date: Thu, 28 Nov 2024 18:04:02 +0530 Subject: [PATCH 05/78] FIX_ENROL_INSERT_EMPTY_ROW&INS_STMT_NULL_HANDLING --- app/Controllers/EmployeeServiceController.php | 245 +++++++++--------- .../PolicyTransactionController.php | 13 +- 2 files changed, 135 insertions(+), 123 deletions(-) diff --git a/app/Controllers/EmployeeServiceController.php b/app/Controllers/EmployeeServiceController.php index 6756e470..577232c2 100755 --- a/app/Controllers/EmployeeServiceController.php +++ b/app/Controllers/EmployeeServiceController.php @@ -1981,131 +1981,136 @@ public function employeesEnrollmentInsert($params) foreach ($excel_data as $key => $row) { - // dd($key.'-'.count($excel_data)); - $value = []; - $policy_data = []; - $temp_unit = ''; - if(empty($row[12])) + $is_row_empty = check_row_is_empty_or_null($row); + if(!$is_row_empty) { - $temp_unit = $existing_units[0]; - } - - $value['emp_code'] = $row[1]; - $value['name'] = $row[2]; - $value['doj'] = (!empty($row[3]) ? convert_string_to_date($row[3],'Y-m-d'): null); - $value['gender'] = $row[4]; - $value['relationship'] = ucfirst(trim($row[5])); - $value['dob'] = convert_string_to_date($row[6],'Y-m-d'); - $value['email_corporate'] = $row[7]; - $value['mobile'] = $row[8]; - $value['band'] = $row[10]; - $value['basic_pay'] = $row[11]; - $value['unit'] = $temp_unit; - $value['family_floater_key'] = null; - $value['client_id'] = $file['client_id']; - $value['client_branch_id'] = $file['client_branch_id']; - $value['file_id'] = $file_id; + $value = []; + $policy_data = []; + $temp_unit = ''; + if(empty($row[12])) + { + $temp_unit = $existing_units[0]; + } + + $value['emp_code'] = $row[1]; + $value['name'] = $row[2]; + $value['doj'] = (!empty($row[3]) ? convert_string_to_date($row[3],'Y-m-d'): null); + $value['gender'] = $row[4]; + $value['relationship'] = ucfirst(trim($row[5])); + $value['dob'] = convert_string_to_date($row[6],'Y-m-d'); + $value['email_corporate'] = $row[7]; + $value['mobile'] = $row[8]; + $value['band'] = $row[10]; + $value['basic_pay'] = $row[11]; + $value['unit'] = $temp_unit; + $value['family_floater_key'] = null; + $value['client_id'] = $file['client_id']; + $value['client_branch_id'] = $file['client_branch_id']; + $value['file_id'] = $file_id; - $value['temp']['emp_id'] = null; // dummy value for using exisitng funciton in model - if (strtolower(trim($value['relationship'])) === 'mother' || strtolower(trim($value['relationship'])) === 'father') { - $relation = 'parent'; - } else if(strtolower(trim($value['relationship'])) === 'son' || strtolower(trim($value['relationship'])) === 'daughter'){ - $relation = 'child'; - }else if(strtolower(trim($value['relationship'])) === 'father in law' || strtolower(trim($value['relationship'])) === 'mother in law'){ - $relation = 'parent_in_law'; - }else if(strtolower(trim($value['relationship'])) === 'spouse'){ - $relation = 'spouse'; - }else{ - $relation = 'self'; - } - $value['family_floater_key'] = $relation; - - $policy_data['basic_cover_si'] = $row[9]; - $policy_data['date_coverage'] = $row[13]; - $policy_data['client_policy_id'] = $file['policy_id']; - - $employee = $this->employeeModel->checkExistingEmployee($value,$file['client_branch_id']); - unset($value['temp']); - //save employee table - // dd($employee['id']); - if($employee !== null) - { - $value['updated_by'] = $file['created_by']; - $value['id'] = $employee['id']; - $value['emp_status'] = 'draft'; - - $log_message = 'Enrollment Update Employee - '.$employee['name'].'('.$employee['emp_code'].') with PK '.$employee['id']; - } - else - { - $value['emp_status'] = 'draft'; - $value['created_by'] = $file['created_by']; - $log_message = 'Enrollment Insert Employee- '.$value['name'] .'('.$value['emp_code'] .') with PK '; - } - - $this->employeeModel->save($value); - if (isset($value['id'])) - { $emp_id = $value['id']; } - else { $emp_id = $this->employeeModel->getInsertID(); - $log_message .= $emp_id; - } - - // $emp_id = $this->employeeModel->getInsertID(); - // if($emp_id != 0){ $log_message .= $emp_id; } - // else{ $emp_id = $employee['id']; } - - $this->myLogger->logme('error',$log_message); - - //save policy table - $employee_policy = $this->employeePolicyModel->checkExistingEmpPolicy(['employee_id' => $emp_id,'client_policy_id' => $file['policy_id']]); - if(count($employee_policy)) - { - $policy_data['updated_by'] = $file['created_by']; - $policy_data['id'] = $employee_policy[0]['id']; - $policy_data['status'] = 'draft'; - - $log_message = 'Update Employee Policy for '. $value['name'].'('. $value['emp_code'].') with PK- ' . $employee_policy[0]['id'] .' client policy ID '.$employee_policy[0]['client_policy_id'].' with SI '.$policy_data['basic_cover_si']; - // echo 'insert policy'; - } - else - { - $policy_data['employee_id'] = $emp_id; - $policy_data['client_policy_id'] = $file['policy_id']; - $policy_data['created_by'] = $file['created_by']; - $policy_data['status'] = 'draft'; - $log_message = 'Insert Employee Policy for '. $value['name'].'('. $value['emp_code'].') - client policy id -'. $file['policy_id'].' - with SI '.$policy_data['basic_cover_si']; - // echo 'update policy'; - } - - $this->employeePolicyModel->save($policy_data); - $emp_policy_id = $this->employeePolicyModel->getInsertID(); - $this->myLogger->logme('error',$log_message); - - //save email of self for send mail later - if (isset($notification) && $notification['enabled'] == 1 && $notification['mail_content'] != '') - { - if(strtolower($value['relationship']) == 'self' && $value['email_corporate'] != "") - { - $params['dataToInsert'] = $value; //holds employee master data - $params['notification'] = $notification; - $params['client_data'] = $client_details; - - //store email and mail content via helper to send notification - $emp_emails[] = sendMailNotification::sendMailNotification('member_welcome_mail', $params); - // Kint::dump($emp_emails); - // Kint::dump($key.'-'.count($excel_data)); - // if mail count is 20 send bulk mail and reset emp_emails variable - if (count($emp_emails) == 20 || $key == count($excel_data) ) { - $job_details = new Jobs(); - $r = Jobs::addJob(['job_name' => 'bulk_mail','payload' => $emp_emails]); - // echo 'Mail triggered'; - $emp_emails = []; - } - + $value['temp']['emp_id'] = null; // dummy value for using exisitng funciton in model + if (strtolower(trim($value['relationship'])) === 'mother' || strtolower(trim($value['relationship'])) === 'father') { + $relation = 'parent'; + } else if(strtolower(trim($value['relationship'])) === 'son' || strtolower(trim($value['relationship'])) === 'daughter'){ + $relation = 'child'; + }else if(strtolower(trim($value['relationship'])) === 'father in law' || strtolower(trim($value['relationship'])) === 'mother in law'){ + $relation = 'parent_in_law'; + }else if(strtolower(trim($value['relationship'])) === 'spouse'){ + $relation = 'spouse'; + }else{ + $relation = 'self'; } - } + $value['family_floater_key'] = $relation; + + $policy_data['basic_cover_si'] = $row[9]; + $policy_data['date_coverage'] = $row[13]; + $policy_data['client_policy_id'] = $file['policy_id']; + + $employee = $this->employeeModel->checkExistingEmployee($value,$file['client_branch_id']); + unset($value['temp']); + //save employee table + // dd($employee['id']); + if($employee !== null) + { + $value['updated_by'] = $file['created_by']; + $value['id'] = $employee['id']; + $value['emp_status'] = 'draft'; + + $log_message = 'Enrollment Update Employee - '.$employee['name'].'('.$employee['emp_code'].') with PK '.$employee['id']; + } + else + { + $value['emp_status'] = 'draft'; + $value['created_by'] = $file['created_by']; + $log_message = 'Enrollment Insert Employee- '.$value['name'] .'('.$value['emp_code'] .') with PK '; + } + + $this->employeeModel->save($value); + if (isset($value['id'])) + { $emp_id = $value['id']; } + else { $emp_id = $this->employeeModel->getInsertID(); + $log_message .= $emp_id; + } + + // $emp_id = $this->employeeModel->getInsertID(); + // if($emp_id != 0){ $log_message .= $emp_id; } + // else{ $emp_id = $employee['id']; } + + $this->myLogger->logme('error',$log_message); + + //save policy table + $employee_policy = $this->employeePolicyModel->checkExistingEmpPolicy(['employee_id' => $emp_id,'client_policy_id' => $file['policy_id']]); + if(count($employee_policy)) + { + $policy_data['updated_by'] = $file['created_by']; + $policy_data['id'] = $employee_policy[0]['id']; + $policy_data['status'] = 'draft'; + + $log_message = 'Update Employee Policy for '. $value['name'].'('. $value['emp_code'].') with PK- ' . $employee_policy[0]['id'] .' client policy ID '.$employee_policy[0]['client_policy_id'].' with SI '.$policy_data['basic_cover_si']; + // echo 'insert policy'; + } + else + { + $policy_data['employee_id'] = $emp_id; + $policy_data['client_policy_id'] = $file['policy_id']; + $policy_data['created_by'] = $file['created_by']; + $policy_data['status'] = 'draft'; + $log_message = 'Insert Employee Policy for '. $value['name'].'('. $value['emp_code'].') - client policy id -'. $file['policy_id'].' - with SI '.$policy_data['basic_cover_si']; + // echo 'update policy'; + } + + $this->employeePolicyModel->save($policy_data); + $emp_policy_id = $this->employeePolicyModel->getInsertID(); + $this->myLogger->logme('error',$log_message); + + //save email of self for send mail later + if (isset($notification) && $notification['enabled'] == 1 && $notification['mail_content'] != '') + { + if(strtolower($value['relationship']) == 'self' && $value['email_corporate'] != "") + { + $params['dataToInsert'] = $value; //holds employee master data + $params['notification'] = $notification; + $params['client_data'] = $client_details; + + //store email and mail content via helper to send notification + $emp_emails[] = sendMailNotification::sendMailNotification('member_welcome_mail', $params); + // Kint::dump($emp_emails); + // Kint::dump($key.'-'.count($excel_data)); + // if mail count is 20 send bulk mail and reset emp_emails variable + if (count($emp_emails) == 20 || $key == count($excel_data) ) { + $job_details = new Jobs(); + $r = Jobs::addJob(['job_name' => 'bulk_mail','payload' => $emp_emails]); + // echo 'Mail triggered'; + $emp_emails = []; + } + + } + } + }// endof if row is empty check } //end of for loop + + $this->fileModel->where('id', $file_id)->set(['status' => 'success','reason' => ''])->update(); $this->myLogger->logme("error",'{file_id} uploaded success',['file_id' => $file_id]); diff --git a/app/Controllers/PolicyTransactionController.php b/app/Controllers/PolicyTransactionController.php index 1c5526c6..f5f1a5b5 100644 --- a/app/Controllers/PolicyTransactionController.php +++ b/app/Controllers/PolicyTransactionController.php @@ -1730,11 +1730,11 @@ class PolicyTransactionController extends BaseController foreach ($excel_data as $excel_key => $excel_row) { $is_row_empty = check_row_is_empty_or_null($excel_row); - if($is_row_empty) + if(!$is_row_empty) { - continue; + break; } - + $is_source_found = 0; $policy_start_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[4]);//policy_start_date from excel $policy_end_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[5]);//policy_end_date from excel @@ -1773,6 +1773,7 @@ class PolicyTransactionController extends BaseController public function updateInsurerStatement($params) { + helper('excel_util_helper'); //get file info $file_id = $params['file_id']; $file = $this->insurerStatements->find($file_id); @@ -1826,6 +1827,12 @@ class PolicyTransactionController extends BaseController $data_to_update = []; foreach ($excel_data as $excel_key => $excel_row) { + $is_row_empty = check_row_is_empty_or_null($excel_row); + if(!$is_row_empty) + { + break; + } + $is_source_found = 0; $policy_start_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[4]);//policy_start_date from excel $policy_end_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[5]);//policy_end_date from excel From e74837bdb60fa6d7d4bd2d6bceedbe8f0a89c869 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Fri, 29 Nov 2024 13:33:56 +0530 Subject: [PATCH 06/78] CHANGES_DELETION_CLAIM_STATUS_QUERY_CHANGES : RV --- app/Controllers/EmployeeController.php | 6 ++--- app/Models/EmployeePolicyModel.php | 36 +++++++++++++++++++++++--- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index 9afb44b2..02c01d34 100755 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -1798,9 +1798,9 @@ class EmployeeController extends AdminController public function checkDeletionGetDataFunction() { // $batch_data = [ - // 'client_id' => 77, - // 'client_policy_id' => 203, - // 'client_branch_id' => 53, + // 'client_id' => 159, + // 'client_policy_id' => 336, + // 'client_branch_id' => 126, // ]; // $batch_data['insurer_or_tpa'] = 'insurer'; diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php index abbba1e4..2d285bb6 100755 --- a/app/Models/EmployeePolicyModel.php +++ b/app/Models/EmployeePolicyModel.php @@ -32,6 +32,7 @@ class EmployeePolicyModel extends Model "updated_at", "rand_string", "is_active", + "claim_status", ]; // Callbacks @@ -617,6 +618,7 @@ class EmployeePolicyModel extends Model employee_polices.policy_end_date, employee_polices.premium, employee_polices.rata_premimum as pro_rata_premium, + employee_polices.claim_status, batch_data.emp_policy_id AS emp_policy_id, batch_data.bl AS batch_list_batch_code, @@ -629,9 +631,37 @@ class EmployeePolicyModel extends Model deletiondata.status, DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + '$add_one_day' AS no_of_days, - ROUND((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365, 2) AS pro_rata_premium, - ROUND(((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365) * 0.18, 2) AS gst, - ROUND(((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365) + (((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365) * 0.18), 2) AS total + + + CASE + WHEN employee_polices.claim_status = 0 THEN + ROUND((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365, 2) + ELSE + 0 + END AS pro_rata_premium, + + CASE + WHEN employee_polices.claim_status = 0 THEN + ROUND(((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365) * 0.18, 2) + ELSE + 0 + END AS gst, + + CASE + WHEN employee_polices.claim_status = 0 THEN + ROUND(((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365) + + (((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365) * 0.18), 2) + ELSE + 0 + END AS total, + + CASE + WHEN employee_polices.claim_status = 0 THEN + 'No claim' + ELSE + 'Claim' + END AS claim_status + FROM emp_endorsement a LEFT JOIN From fb4b24cc79c030119748eac1bbaf61f2e6ae025d Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Mon, 2 Dec 2024 09:37:06 +0530 Subject: [PATCH 07/78] CHANGE_HANDLE_MULTIPLE_REMAINDER_DATE_AND_OTHERS : RV --- app/Config/Routes.php | 2 + app/Controllers/ClientController.php | 36 ++++- app/Controllers/DashboardController.php | 160 ++++++++----------- app/Controllers/EmpDataServiceController.php | 2 +- app/Helpers/sendMailNotification.php | 149 ++++++++++------- app/Models/ClientPolicyModel.php | 1 + app/Views/client_policy.php | 53 ++++-- app/Views/notification.php | 8 +- 8 files changed, 235 insertions(+), 176 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index a6472417..62155a0f 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -22,6 +22,8 @@ $routes->get("view", "EmployeeController::viewECard/$1"); $routes->get("smapletest", "ClientController::smapletest"); $routes->get("testMailAttachments", "ClientController::testMailAttachments"); $routes->get("updatePolicyTermsKey", "ClientController::updatePolicyTermsKey"); +$routes->get("updateRemainderDate", "ClientController::updateRemainderDate"); +$routes->get("sendCroneRemainderMail", "DashboardController::sendCroneRemainderMail"); $routes->post("add_advertise_image", "AppContentManagementController::add_advertise_image"); $routes->get("add_image_index", "AppContentManagementController::add_image_index"); diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 7b8e9cf8..447c293a 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -584,7 +584,7 @@ class ClientController extends AdminController $editData['client_policy'] = $clientPoliceData; $editData['client_policy']['role'] = get_role_id(); $editData['notification'] = $this->notificationModel->select('template_name,enabled')->where('client_id', $id)->findAll(); - $editData['placeHolders'] = ['member_name', 'nhance_logo', 'tpa_id', 'ecard_download_link', 'client_logo', 'policy_no', 'member_summary', 'app_link', 'post_enrollment_app_link', 'client_name']; + $editData['placeHolders'] = ['member_name', 'member_mobile', 'nhance_logo', 'tpa_id', 'ecard_download_link', 'client_logo', 'policy_no', 'member_summary', 'app_link', 'post_enrollment_app_link', 'client_name']; // dd($editData); echo view('layout/header', $headerData); @@ -1033,6 +1033,9 @@ class ClientController extends AdminController $data['cd_ac_no'] = $this->request->getPost('cd_ac_no'); $data['gst'] = $this->request->getPost('gst'); $data['disclaimer'] = $this->request->getPost('disclaimer'); + $data['is_member_modify_allowed'] = $this->request->getPost('is_member_modify_allowed') ? 1 : 0; + $data['enrolment_visibility'] = $this->request->getPost('enrolment_visibility') ? 1 : 0; + if ($policy_type_id == 1 || $policy_type_id == 2 || $policy_type_id == 6 || $policy_type_id == 7) { @@ -1059,7 +1062,8 @@ class ClientController extends AdminController if ($data['inception_type'] == 2) { $data['open_date'] = change_date_format($this->request->getPost('open_date'), 'd-m-Y', 'Y-m-d'); $data['close_date'] = change_date_format($this->request->getPost('close_date'), 'd-m-Y', 'Y-m-d'); - $data['reminder_date'] = change_date_format($this->request->getPost('reminder_date'), 'd-m-Y', 'Y-m-d'); + // $data['reminder_date'] = change_date_format($this->request->getPost('reminder_date'), 'd-m-Y', 'Y-m-d'); + $data['reminder_date'] = $this->request->getPost('reminder_date'); } else { $data['open_date'] = null; $data['closedate'] = null; @@ -1162,11 +1166,13 @@ class ClientController extends AdminController $data['disclaimer'] = $this->request->getPost('disclaimer'); $data['policy_start_date'] = change_date_format($this->request->getPost('policy_start_date'), 'd-m-Y', 'Y-m-d'); $data['policy_end_date'] = change_date_format($this->request->getPost('policy_end_date'), 'd-m-Y', 'Y-m-d'); + $data['is_member_modify_allowed'] = $this->request->getPost('is_member_modify_allowed') ? 1 : 0; if ($data['inception_type'] == 2) { $data['open_date'] = change_date_format($this->request->getPost('open_date'), 'd-m-Y', 'Y-m-d'); $data['close_date'] = change_date_format($this->request->getPost('close_date'), 'd-m-Y', 'Y-m-d'); - $data['reminder_date'] = change_date_format($this->request->getPost('reminder_date'), 'd-m-Y', 'Y-m-d'); + // $data['reminder_date'] = change_date_format($this->request->getPost('reminder_date'), 'd-m-Y', 'Y-m-d'); + $data['reminder_date'] = $this->request->getPost('reminder_date'); } else { $data['open_date'] = null; $data['close_date'] = null; @@ -3659,4 +3665,28 @@ class ClientController extends AdminController } } + public function updateRemainderDate() + { + // Connect to the database and fetch the data + $data = db_connect()->table('client_policy') + ->where("reminder_date IS NOT NULL AND reminder_date <> ''") + ->where('is_active', 1) + ->get() + ->getResultArray(); + + $days = []; + foreach ($data as $value) { + + $reminderDate = strtotime($value['reminder_date']); + if ($reminderDate) { + $date_of_date = date('d', $reminderDate); + $days[] = $date_of_date; + $days[] = $value['reminder_date']; + db_connect()->table('client_policy')->where('id', $value['id'])->set('reminder_date', $date_of_date)->update(); + } + } + + dd($days); + } + } diff --git a/app/Controllers/DashboardController.php b/app/Controllers/DashboardController.php index dfa0841a..b1bc3200 100755 --- a/app/Controllers/DashboardController.php +++ b/app/Controllers/DashboardController.php @@ -362,16 +362,14 @@ class DashboardController extends AdminController // dd($client_policy_data, $send_mail_for_manual_or_crone); $reminder_whole_mail = []; - + foreach ($client_policy_data as $client_policy) { - if(empty($send_mail_for_manual_or_crone)){ - - // echo '1'; + if (empty($send_mail_for_manual_or_crone)) { // Fetch client data $client_data = $this->clientModel->find($client_policy['client_id']); - + // Fetch notification settings $notification_data = $this->notificationModel ->where('client_id', $client_policy['client_id']) @@ -379,11 +377,11 @@ class DashboardController extends AdminController ->first(); // $this->myLogger->logme('error', 'Notification data fetched: ' . json_encode($notification_data)); - + // Check if notification should be sent if ($notification_data && $notification_data['enabled'] == 1 && !empty($notification_data['mail_content'])) { $this->myLogger->logme('error', 'Notification should be sent for client policy ID: ' . $client_policy['id']); - + // Fetch all employees related to the client policy $employees = $this->employeePolicyModel ->select('employees.*') @@ -395,18 +393,18 @@ class DashboardController extends AdminController ->where('employee_polices.is_active', 1) ->where('employees.relationship', 'Self') ->findAll(); - + // Process each employee foreach ($employees as $employee) { - + if ($employee['emp_status'] == 'draft' && $employee['relationship'] == 'Self') { $this->myLogger->logme('error', 'Employee status and relationship check passed for employee ID: ' . $employee['id']); - + // Mail params $params['emp_data'] = $employee; $params['client_data'] = $client_data; $params['notification_data'] = $notification_data; - + // Send the mail notification $mail_result = sendMailNotification::sendMailNotification('member_reminder_mail', $params); // $this->myLogger->logme('error', 'Mail sent result: ' . json_encode($mail_result)); @@ -414,66 +412,66 @@ class DashboardController extends AdminController } } } else { - $this->myLogger->logme('error', 'Notification not sent for client policy ID: ' . $client_policy['id']); + $this->myLogger->logme('error', 'Notification was not sent for Client Policy ID: ' . $client_policy['id']); + $this->myLogger->logme('error', 'Notification setup not found or not enabled'); } - } else { - // echo '2'; + $currentDate = date('d'); + $remainder_dates = explode(",", $client_policy['reminder_date']); - $currentDate = date('d-m-Y'); + foreach ($remainder_dates as $date) { - if($currentDate == date('d-m-Y', strtotime($client_policy['reminder_date']))){ + if ($currentDate == $date) { - // echo '3'; + $client_data = $this->clientModel->find($client_policy['client_id']); - $client_data = $this->clientModel->find($client_policy['client_id']); + // Fetch notification settings + $notification_data = $this->notificationModel + ->where('client_id', $client_policy['client_id']) + ->where('template_name', 'member_reminder_mail') + ->first(); - // Fetch notification settings - $notification_data = $this->notificationModel - ->where('client_id', $client_policy['client_id']) - ->where('template_name', 'member_reminder_mail') - ->first(); - - // Check if notification should be sent - if ($notification_data && $notification_data['enabled'] == 1 && !empty($notification_data['mail_content'])) { + // Check if notification should be sent + if ($notification_data && $notification_data['enabled'] == 1 && !empty($notification_data['mail_content'])) { - // echo '4'; + // echo '4'; - $this->myLogger->logme('error', 'Notification should be sent for client policy ID: ' . $client_policy['id']); - - // Fetch all employees related to the client policy - $employees = $this->employeePolicyModel - ->select('employees.*') - ->join('employees', 'employee_polices.employee_id = employees.id', 'left') - ->where('employee_polices.client_policy_id', $client_policy['id']) - ->where('employees.emp_status', 'draft') - ->where('employees.is_active', 1) - ->where('employee_polices.status', 'draft') - ->where('employee_polices.is_active', 1) - ->where('employees.relationship', 'Self') - ->findAll(); - - // Process each employee - foreach ($employees as $employee) { - - if ($employee['emp_status'] == 'draft' && $employee['relationship'] == 'Self') { - $this->myLogger->logme('error', 'Employee status and relationship check passed for employee ID: ' . $employee['id']); - - // Mail params - $params['emp_data'] = $employee; - $params['client_data'] = $client_data; - $params['notification_data'] = $notification_data; - - // Send the mail notification - $mail_result = sendMailNotification::sendMailNotification('member_reminder_mail', $params); - // $this->myLogger->logme('error', 'Mail sent result: ' . json_encode($mail_result)); - $reminder_whole_mail[] = $mail_result; + $this->myLogger->logme('error', 'Notification should be sent for client policy ID: ' . $client_policy['id']); + + // Fetch all employees related to the client policy + $employees = $this->employeePolicyModel + ->select('employees.*') + ->join('employees', 'employee_polices.employee_id = employees.id', 'left') + ->where('employee_polices.client_policy_id', $client_policy['id']) + ->where('employees.emp_status', 'draft') + ->where('employees.is_active', 1) + ->where('employee_polices.status', 'draft') + ->where('employee_polices.is_active', 1) + ->where('employees.relationship', 'Self') + ->findAll(); + + // Process each employee + foreach ($employees as $employee) { + + if ($employee['emp_status'] == 'draft' && $employee['relationship'] == 'Self') { + $this->myLogger->logme('error', 'Employee status and relationship check passed for employee ID: ' . $employee['id']); + + // Mail params + $params['emp_data'] = $employee; + $params['client_data'] = $client_data; + $params['notification_data'] = $notification_data; + + // Send the mail notification + $mail_result = sendMailNotification::sendMailNotification('member_reminder_mail', $params); + // $this->myLogger->logme('error', 'Mail sent result: ' . json_encode($mail_result)); + $reminder_whole_mail[] = $mail_result; + } } + } else { + // echo '5'; + $this->myLogger->logme('error', 'Notification not sent for client policy ID: ' . $client_policy['id']); } - } else { - // echo '5'; - $this->myLogger->logme('error', 'Notification not sent for client policy ID: ' . $client_policy['id']); } } } @@ -481,41 +479,22 @@ class DashboardController extends AdminController // dd($reminder_whole_mail); - // $this->myLogger->logme('error', 'Whole email, count: ' . $reminder_whole_mail); - // Process and queue bulk emails - $temp_whole_data = []; - $count = 0; - - foreach ($reminder_whole_mail as $whole_index => $values) { - foreach ($values as $index => $value) { - $temp_whole_data[] = $value; - $count++; - $this->myLogger->logme('error', 'Queueing email, count: ' . $count); - - if ($count == 20 || ($whole_index == count($reminder_whole_mail) - 1 && $index == count($values) - 1)) { - if (!empty($temp_whole_data)) { - Jobs::addJob(['job_name' => 'bulk_mail', 'payload' => $temp_whole_data]); - $this->myLogger->logme('error', 'Added bulk mail job: ' . json_encode($temp_whole_data)); - $temp_whole_data = []; - $count = 0; - } - } + if (!empty($reminder_whole_mail) && count($reminder_whole_mail) > 0) { + + $reminder_whole_mail = array_chunk($reminder_whole_mail, 20); + + foreach ($reminder_whole_mail as $key => $value) { + $job_details = new Jobs(); + $r = Jobs::addJob(['job_name' => 'bulk_mail', 'payload' => $value]); } } - - if (count($temp_whole_data) > 0) { - Jobs::addJob(['job_name' => 'bulk_mail', 'payload' => $temp_whole_data]); - $this->myLogger->logme('error', 'Added final bulk mail job: ' . json_encode($temp_whole_data)); + + if (count($reminder_whole_mail) > 0) { return true; - } - - if(count($reminder_whole_mail) > 0){ - return true; - }else{ + } else { return false; } - } public function sendManualReminder($client_id, $client_branch_id) @@ -545,7 +524,7 @@ class DashboardController extends AdminController } } - public function sendManualEcard($client_id, $client_branch_id, $policy_id) + public function sendManualEcard($client_id, $client_branch_id, $policy_id) { $this->myLogger->logme('error', "sendManualEcard called with client_id: {$client_id}, client_branch_id: {$client_branch_id}, policy id : {$policy_id}"); @@ -574,7 +553,8 @@ class DashboardController extends AdminController } - public function data_construct_for_bds($data){ + public function data_construct_for_bds($data) + { $groupedData = [ 'under_process' => [], diff --git a/app/Controllers/EmpDataServiceController.php b/app/Controllers/EmpDataServiceController.php index 9ae9e2d1..4330dd4b 100755 --- a/app/Controllers/EmpDataServiceController.php +++ b/app/Controllers/EmpDataServiceController.php @@ -4353,7 +4353,7 @@ class EmpDataServiceController extends BaseController foreach ($ids as $id) { $emp_details = $this->employeePolicyModel - ->select('employee_polices.client_policy_id, employees.relationship, employees.emp_code, employees.email_corporate, employees.client_id, employees.name, employee_polices.rand_string, employee_polices.tpa_id') + ->select('employee_polices.client_policy_id, employees.relationship, employees.emp_code, employees.email_corporate, employees.client_id, employees.name, employees.mobile, employee_polices.rand_string, employee_polices.tpa_id') ->join('employees', 'employees.id = employee_polices.employee_id') ->where('employees.emp_status', 'active') ->where('employees.is_active', '1') diff --git a/app/Helpers/sendMailNotification.php b/app/Helpers/sendMailNotification.php index fbc374a8..df94db40 100755 --- a/app/Helpers/sendMailNotification.php +++ b/app/Helpers/sendMailNotification.php @@ -17,6 +17,7 @@ class sendMailNotification public static function sendMailNotification($action, $params) { $wholeData =[]; + if ($action == 'member_welcome_mail') { $dataToInsert = $params['dataToInsert']; @@ -42,6 +43,7 @@ class sendMailNotification $subject = $notification['subject']; $app_link = $_ENV['App_Url']; $employee_name =$dataToInsert['name']; + $employee_mobile_no =$dataToInsert['mobile']; $mail_content = $notification['mail_content']; $nhance_logo = $_ENV['NHANCE_LOGO']; $client_logo = base_url() . "public/uploads/logo/" . $client_data['client_logo']; @@ -49,6 +51,7 @@ class sendMailNotification $mail_content = str_replace("[[client_logo]]", "Client Logo", $mail_content); $mail_content = str_replace("[[nhance_logo]]", "Nhance Logo", $mail_content); $mail_content = str_replace("[[member_name]]", $employee_name, $mail_content); + $mail_content = str_replace("[[member_mobile]]", $employee_mobile_no, $mail_content); $mail_content = str_replace("[[client_name]]", $client_data['client_name'], $mail_content); $mail_content = str_replace("[[app_link]]", "Review Details", $mail_content); @@ -83,7 +86,9 @@ class sendMailNotification $mail =''; if ($emp_data['relationship'] == 'Self') { $employee_name =$emp_data['name']; + $employee_mobile_no =$emp_data['mobile']; $mail_content = str_replace("[[member_name]]", $employee_name, $mail_content); + $mail_content = str_replace("[[member_mobile]]", $employee_mobile_no, $mail_content); $mail = $emp_data['email_corporate']; } } @@ -93,7 +98,9 @@ class sendMailNotification }else{ $employee_name =$emp_data['name']; + $employee_mobile_no =$emp_data['mobile']; $mail_content = str_replace("[[member_name]]", $employee_name, $mail_content); + $mail_content = str_replace("[[member_mobile]]", $employee_mobile_no, $mail_content); $mail = $emp_data['email_corporate']; } @@ -111,7 +118,9 @@ class sendMailNotification foreach ($emp_data as $key => $values) { if ($value['relationship'] == 'Self') { $employee_name =$values['name']; + $employee_mobile_no =$values['mobile']; $mail_content = str_replace("[[member_name]]", $employee_name, $mail_content); + $mail_content = str_replace("[[member_mobile]]", $employee_mobile_no, $mail_content); $mail = $values['email_corporate']; } } @@ -120,7 +129,9 @@ class sendMailNotification } }else{ $employee_name =$value['name']; + $employee_mobile_no =$value['mobile']; $mail_content = str_replace("[[member_name]]", $employee_name, $mail_content); + $mail_content = str_replace("[[member_mobile]]", $employee_mobile_no, $mail_content); $mail = $value['email_corporate']; } if (isset($mail) && !empty($mail)) { @@ -161,6 +172,7 @@ class sendMailNotification $app_link = $_ENV['App_Url']; $name = $get_emp_email_and_other_details['name']; + $employee_mobile_no = $get_emp_email_and_other_details['mobile']; $mail_content = $notification['mail_content']; $nhance_logo = $_ENV['NHANCE_LOGO']; @@ -175,6 +187,7 @@ class sendMailNotification $mail_content = str_replace("[[client_logo]]", "Client Logo", $mail_content); $mail_content = str_replace("[[member_name]]", $name, $mail_content); + $mail_content = str_replace("[[member_mobile]]", $employee_mobile_no, $mail_content); $mail_content = str_replace("[[app_link]]", "Review Details", $mail_content); $mail_content = str_replace("[[post_enrollment_app_link]]", "Review Details", $mail_content); // $mail_content = str_replace("[[tpa_id]]", $tpa_id, $mail_content); @@ -226,6 +239,7 @@ class sendMailNotification $gst = 0; $Addon_list = []; $name = ''; + $employee_mobile_no = ''; $emp_code = ''; // echo '
';
@@ -258,6 +272,7 @@ class sendMailNotification
                                 $emp_code = '(' . $inner_item['emp_code'] . ')';
                                 $mail = $inner_item['email_corporate'];
                                 $name = $inner_item['name'];
+                                $employee_mobile_no = $inner_item['mobile'];
                             } 
 
                             $si = '';
@@ -378,6 +393,7 @@ class sendMailNotification
                 // print_r($table_content); die;
 
                 $mail_content = str_replace("[[member_name]]", $name . ' (' . $emp_code . ')' , $mail_content);
+                $mail_content = str_replace("[[member_mobile]]", $employee_mobile_no, $mail_content);
                 $mail_content = str_replace("[[member_summary]]", $table_content , $mail_content);
 
                 // print_r($mail_content); die;
@@ -841,6 +857,7 @@ class sendMailNotification
             // print_r($attachments); die;
 
             $employee_name = 'John Doe';
+            $mobile = 9080706050;
 
             $app_link = $_ENV['App_Url'];
             $nhance_logo = $_ENV['NHANCE_LOGO'];
@@ -850,6 +867,7 @@ class sendMailNotification
             $mail_content = str_replace("[[client_logo]]", "Client Logo", $mail_content);
             $mail_content = str_replace("[[nhance_logo]]", "Nhance Logo", $mail_content);
             $mail_content = str_replace("[[member_name]]", $employee_name, $mail_content);
+            $mail_content = str_replace("[[member_mobile]]", $mobile, $mail_content);
             $mail_content = str_replace("[[client_name]]", $client_data['client_name'], $mail_content);
 
             $mail_content = str_replace("[[app_link]]", "Review Details", $mail_content);
@@ -873,6 +891,7 @@ class sendMailNotification
             $app_link = $_ENV['App_Url'];
 
             $employee_name = 'John Doe';
+            $mobile = 9080706050;
 
             $client_logo = base_url() . "public/uploads/logo/" . $client_data['client_logo'];
 
@@ -880,6 +899,7 @@ class sendMailNotification
             $mail_content = str_replace("[[nhance_logo]]", "Nhance Logo", $mail_content);
             $mail_content = str_replace("[[client_logo]]", "Client Logo", $mail_content);
             $mail_content = str_replace("[[app_link]]", "Review Details", $mail_content);
+            $mail_content = str_replace("[[member_mobile]]", $mobile, $mail_content);
 
             if ((isset($notification_data) && $notification_data['enabled'] == 1)) {
 
@@ -905,6 +925,7 @@ class sendMailNotification
             $link = generate_download_link($rand_string);
 
             $name = 'John Doe';
+            $mobile = 9080706050;
 
             $nhance_logo = $_ENV['NHANCE_LOGO'];
             $app_link = $_ENV['App_Url'];
@@ -916,6 +937,7 @@ class sendMailNotification
             $mail_content = str_replace("[[client_logo]]", "Client Logo", $mail_content);
 
             $mail_content = str_replace("[[member_name]]", $name, $mail_content);
+            $mail_content = str_replace("[[member_mobile]]", $mobile, $mail_content);
             $mail_content = str_replace("[[app_link]]", "Review Details", $mail_content);
             $mail_content = str_replace("[[post_enrollment_app_link]]", "Review Details", $mail_content);
             $mail_content = str_replace("[[ecard_download_link]]", "Download Insurance Card", $mail_content);
@@ -937,7 +959,8 @@ class sendMailNotification
                     'premium' => 12000,
                     'gst' => 2160,
                     'rata_premimum' => 12000,
-                    'is_addon' => 2
+                    'is_addon' => 2,
+                    'mobile' => 9080706050
             ];
             
 
@@ -967,6 +990,7 @@ class sendMailNotification
                 $gst = 0;
                 $Addon_list = [];
                 $name =  $array_list['name'];
+                $mobile =  $array_list['mobile'];
                 $emp_code = '';
                 
                 if (!empty($array_list)) {
@@ -987,9 +1011,9 @@ class sendMailNotification
                     $table_content .= '';
                     $table_content .= '';
                     $table_content .= 'Name';
-                    $table_content .= 'Relation';
-                    $table_content .= 'Date Of Birth';
-                    $table_content .= 'Sum Insured';
+                    $table_content .= 'Relation';
+                    $table_content .= 'Date Of Birth';
+                    $table_content .= 'Sum Insured';
                 
                     // Only Display SI Topup and Dependent Addon 
                     if ($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) {
@@ -1003,14 +1027,14 @@ class sendMailNotification
                     // Table body with details
                     $table_content .= '';
                     $table_content .= '';
-                    $table_content .= '' . $array_list['name'] . $emp_code . '';
-                    $table_content .= '' . $array_list['relationship'] . '';
-                    $table_content .= '' . \DateTime::createFromFormat('Y-m-d', $array_list['dob'])->format('d-m-Y') . '';
-                    $table_content .= '₹' . format_indian_number($array_list['basic_cover_si']) . '';
+                    $table_content .= '' . nl2br(wordwrap($array_list['name'] . $emp_code, 11, "\n", true)) . '';
+                    $table_content .= '' . $array_list['relationship'] . '';
+                    $table_content .= '' . \DateTime::createFromFormat('Y-m-d', $array_list['dob'])->format('d-m-Y') . '';
+                    $table_content .= '₹' . format_indian_number($array_list['basic_cover_si']) . '';
                 
                     if ($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) {
-                        $table_content .= '₹' . format_indian_number(round($array_list['premium'])) . '';
-                        $table_content .= '₹' . format_indian_number(round($array_list['gst'])) . '';
+                        $table_content .= '₹' . format_indian_number(round($array_list['premium'])) . '';
+                        $table_content .= '₹' . format_indian_number(round($array_list['gst'])) . '';
                     }
                 
                     $table_content .= '';
@@ -1039,10 +1063,10 @@ class sendMailNotification
                         
                         $table_content .= '';
                         $table_content .= '';
-                        $table_content .= 'Policy Name';
-                        $table_content .= 'Additional Premium';
-                        $table_content .= 'GST';
-                        $table_content .= 'Total';
+                        $table_content .= 'Policy Name';
+                        $table_content .= 'Additional Premium';
+                        $table_content .= 'GST';
+                        $table_content .= 'Total';
                         $table_content .= '';
                         $table_content .= '';
                         
@@ -1050,16 +1074,16 @@ class sendMailNotification
                         
                         $total_addon = $Addon_list[0]['gst'] + $Addon_list[0]['addtional_premium'];
                         $table_content .= '';
-                        $table_content .= '' . $Addon_list[0]['policy_name'] . '';
-                        $table_content .= '₹' . format_indian_number($Addon_list[0]['addtional_premium']) . '';
-                        $table_content .= '₹' . format_indian_number($Addon_list[0]['gst']) . '';
-                        $table_content .= '₹' . format_indian_number($total_addon) . '';
+                        $table_content .= '' . $Addon_list[0]['policy_name'] . '';
+                        $table_content .= '₹' . format_indian_number($Addon_list[0]['addtional_premium']) . '';
+                        $table_content .= '₹' . format_indian_number($Addon_list[0]['gst']) . '';
+                        $table_content .= '₹' . format_indian_number($total_addon) . '';
                         $table_content .= '';
                 
                         $sum_total_words = numberToWords($total_addon);
                         $table_content .= '';
                         $table_content .= 'Total';
-                        $table_content .= '₹' . format_indian_number($total_addon) . '';
+                        $table_content .= '₹' . format_indian_number($total_addon) . '';
                         $table_content .= '';
                         $table_content .= '';
                         $table_content .= '';
@@ -1067,6 +1091,7 @@ class sendMailNotification
                 }            
                 
                 $mail_content = str_replace("[[member_name]]", $name . ' (' . $emp_code . ')' , $mail_content);
+                $mail_content = str_replace("[[member_mobile]]", $mobile, $mail_content);
                 $mail_content = str_replace("[[member_summary]]", $table_content , $mail_content);
 
 
@@ -1136,14 +1161,14 @@ class sendMailNotification
                     $table_content .= '';
                     $table_content .= '';
                     $table_content .= 'Name';
-                    $table_content .= 'Relation';
-                    $table_content .= 'Date Of Birth';
-                    $table_content .= 'Sum Insured';
+                    $table_content .= 'Relation';
+                    $table_content .= 'Date Of Birth';
+                    $table_content .= 'Sum Insured';
                 
                     // Only Display SI Topup and Dependent Addon 
                     if ($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) {
-                        $table_content .= 'Premium';
-                        $table_content .= 'GST';
+                        $table_content .= 'Premium';
+                        $table_content .= 'GST';
                     }
                 
                     $table_content .= '';
@@ -1152,14 +1177,14 @@ class sendMailNotification
                     // Table body with details
                     $table_content .= '';
                     $table_content .= '';
-                    $table_content .= '' . $array_list['name'] . $emp_code . '';
-                    $table_content .= '' . $array_list['relationship'] . '';
-                    $table_content .= '' . \DateTime::createFromFormat('Y-m-d', $array_list['dob'])->format('d-m-Y') . '';
-                    $table_content .= '₹' . format_indian_number($array_list['basic_cover_si']) . '';
+                    $table_content .= '' . nl2br(wordwrap($array_list['name'] . $emp_code, 11, "\n", true)) . '';
+                    $table_content .= '' . $array_list['relationship'] . '';
+                    $table_content .= '' . \DateTime::createFromFormat('Y-m-d', $array_list['dob'])->format('d-m-Y') . '';
+                    $table_content .= '₹' . format_indian_number($array_list['basic_cover_si']) . '';
                 
                     if ($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) {
-                        $table_content .= '₹' . format_indian_number(round($array_list['premium'])) . '';
-                        $table_content .= '₹' . format_indian_number(round($array_list['gst'])) . '';
+                        $table_content .= '₹' . format_indian_number(round($array_list['premium'])) . '';
+                        $table_content .= '₹' . format_indian_number(round($array_list['gst'])) . '';
                     }
                 
                     $table_content .= '';
@@ -1188,10 +1213,10 @@ class sendMailNotification
                         
                         $table_content .= '';
                         $table_content .= '';
-                        $table_content .= 'Policy Name';
-                        $table_content .= 'Additional Premium';
-                        $table_content .= 'GST';
-                        $table_content .= 'Total';
+                        $table_content .= 'Policy Name';
+                        $table_content .= 'Additional Premium';
+                        $table_content .= 'GST';
+                        $table_content .= 'Total';
                         $table_content .= '';
                         $table_content .= '';
                         
@@ -1199,17 +1224,17 @@ class sendMailNotification
                         
                         $total_addon = $Addon_list[0]['gst'] + $Addon_list[0]['addtional_premium'];
                         $table_content .= '';
-                        $table_content .= '' . $Addon_list[0]['policy_name'] . '';
-                        $table_content .= '₹' . format_indian_number($Addon_list[0]['addtional_premium']) . '';
-                        $table_content .= '₹' . format_indian_number($Addon_list[0]['gst']) . '';
-                        $table_content .= '₹' . format_indian_number($total_addon) . '';
+                        $table_content .= '' . $Addon_list[0]['policy_name'] . '';
+                        $table_content .= '₹' . format_indian_number($Addon_list[0]['addtional_premium']) . '';
+                        $table_content .= '₹' . format_indian_number($Addon_list[0]['gst']) . '';
+                        $table_content .= '₹' . format_indian_number($total_addon) . '';
                         $table_content .= '';
                 
                         $sum_total_words = numberToWords($total_addon);
                         $table_content .= '';
                         $table_content .= 'Total';
-                        $table_content .= '₹' . format_indian_number($total_addon) . '';
-                        $table_content .= '';
+                        $table_content .= '₹' . format_indian_number($total_addon) . '';
+                        $table_content .= '';
                         $table_content .= '';
                         $table_content .= '';
                     }
@@ -1228,7 +1253,7 @@ class sendMailNotification
             $array_list = [
                 'policy_name' => 'Health Insurance Plan',
                 'emp_code' => 'E12345',
-                'name' => 'John Doe',
+                'name' => 'Ramakrishnaparamahamsar',
                 'relationship' => 'Self',
                 'dob' => '1985-05-15',
                 'basic_cover_si' => 500000,
@@ -1284,14 +1309,14 @@ class sendMailNotification
                     $table_content .= '';
                     $table_content .= '';
                     $table_content .= 'Name';
-                    $table_content .= 'Relation';
-                    $table_content .= 'Date Of Birth';
-                    $table_content .= 'Sum Insured';
+                    $table_content .= 'Relation';
+                    $table_content .= 'Date Of Birth';
+                    $table_content .= 'Sum Insured';
                 
                     // Only Display SI Topup and Dependent Addon 
                     if ($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) {
-                        $table_content .= 'Premium';
-                        $table_content .= 'GST';
+                        $table_content .= 'Premium';
+                        $table_content .= 'GST';
                     }
                 
                     $table_content .= '';
@@ -1300,14 +1325,14 @@ class sendMailNotification
                     // Table body with details
                     $table_content .= '';
                     $table_content .= '';
-                    $table_content .= '' . $array_list['name'] . $emp_code . '';
-                    $table_content .= '' . $array_list['relationship'] . '';
-                    $table_content .= '' . \DateTime::createFromFormat('Y-m-d', $array_list['dob'])->format('d-m-Y') . '';
-                    $table_content .= '₹' . format_indian_number($array_list['basic_cover_si']) . '';
+                    $table_content .= '' . nl2br(wordwrap($array_list['name'] . $emp_code, 11, "\n", true)) . '';
+                    $table_content .= '' . $array_list['relationship'] . '';
+                    $table_content .= '' . \DateTime::createFromFormat('Y-m-d', $array_list['dob'])->format('d-m-Y') . '';
+                    $table_content .= '₹' . format_indian_number($array_list['basic_cover_si']) . '';
                 
                     if ($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) {
-                        $table_content .= '₹' . format_indian_number(round($array_list['premium'])) . '';
-                        $table_content .= '₹' . format_indian_number(round($array_list['gst'])) . '';
+                        $table_content .= '₹' . format_indian_number(round($array_list['premium'])) . '';
+                        $table_content .= '₹' . format_indian_number(round($array_list['gst'])) . '';
                     }
                 
                     $table_content .= '';
@@ -1337,10 +1362,10 @@ class sendMailNotification
                         
                         $table_content .= '';
                         $table_content .= '';
-                        $table_content .= 'Policy Name';
-                        $table_content .= 'Additional Premium';
-                        $table_content .= 'GST';
-                        $table_content .= 'Total';
+                        $table_content .= 'Policy Name';
+                        $table_content .= 'Additional Premium';
+                        $table_content .= 'GST';
+                        $table_content .= 'Total';
                         $table_content .= '';
                         $table_content .= '';
                         
@@ -1348,16 +1373,16 @@ class sendMailNotification
                         
                         $total_addon = $Addon_list[0]['gst'] + $Addon_list[0]['addtional_premium'];
                         $table_content .= '';
-                        $table_content .= '' . $Addon_list[0]['policy_name'] . '';
-                        $table_content .= '₹' . format_indian_number($Addon_list[0]['addtional_premium']) . '';
-                        $table_content .= '₹' . format_indian_number($Addon_list[0]['gst']) . '';
-                        $table_content .= '₹' . format_indian_number($total_addon) . '';
+                        $table_content .= '' . $Addon_list[0]['policy_name'] . '';
+                        $table_content .= '₹' . format_indian_number($Addon_list[0]['addtional_premium']) . '';
+                        $table_content .= '₹' . format_indian_number($Addon_list[0]['gst']) . '';
+                        $table_content .= '₹' . format_indian_number($total_addon) . '';
                         $table_content .= '';
                 
                         $sum_total_words = numberToWords($total_addon);
                         $table_content .= '';
-                        $table_content .= 'Total';
-                        $table_content .= '₹' . format_indian_number($total_addon) . '';
+                        $table_content .= 'Total';
+                        $table_content .= '₹' . format_indian_number($total_addon) . '';
                         $table_content .= '';
                         $table_content .= '';
                         $table_content .= '';
diff --git a/app/Models/ClientPolicyModel.php b/app/Models/ClientPolicyModel.php
index 1aa5bf2d..aac8cd01 100755
--- a/app/Models/ClientPolicyModel.php
+++ b/app/Models/ClientPolicyModel.php
@@ -51,6 +51,7 @@ class ClientPolicyModel extends Model
         "enrolment_visibility",
         "disclaimer",
         "is_active",
+        "is_member_modify_allowed",
     ];
 
     public function getClientPolicyById($id){
diff --git a/app/Views/client_policy.php b/app/Views/client_policy.php
index a0bb84b5..fd4a01a5 100755
--- a/app/Views/client_policy.php
+++ b/app/Views/client_policy.php
@@ -37,12 +37,14 @@
                 
+ +
@@ -56,7 +58,7 @@
- + @@ -77,7 +79,7 @@
@@ -301,11 +314,11 @@ allowInput: false }); - var reminderDatePicker = flatpickr("#reminder_date", { - dateFormat: "d-m-Y", - defaultDate: today, - allowInput: false - }); + // var reminderDatePicker = flatpickr("#reminder_date", { + // dateFormat: "d-m-Y", + // defaultDate: today, + // allowInput: false + // }); $('#add_form').hide(); @@ -784,13 +797,14 @@ $('#open_date').val(rearrangeDateFormat(res.data.open_date)); $('#end_date').val(rearrangeDateFormat(res.data.policy_end_date)); $('#close_date').val(rearrangeDateFormat(res.data.close_date)); - $('#reminder_date').val(rearrangeDateFormat(res.data.reminder_date)); + $('#reminder_date').val(res.data.reminder_date); $('#disclaimer').val(res.data.disclaimer); $('#gst_no').val(gst); $('#policy_status').val(checkDateStatus(res.data.policy_end_date)); $('#policy_status_field').show(); + //Open for enrollment yes or no if (res.data.inception_type == 2) { $('#inception_type').prop('checked', true); $('#open_date').parent().show(); @@ -805,13 +819,20 @@ $('.dateofdata').attr('required', false); } - + //Policy Visibility in Web App if (res.data.enrolment_visibility == 1) { $('#policy_visibility').prop('checked', true); } else { $('#policy_visibility').prop('checked', false); } + // Member Modify Data Enable or Disable + if (res.data.is_member_modify_allowed == 1) { + $('#is_member_modify_allowed').prop('checked', true); + } else { + $('#is_member_modify_allowed').prop('checked', false); + } + // if (res.data.is_addon != '1' && res.data.is_addon != '0') { // $('#base_policy_id').show(); diff --git a/app/Views/notification.php b/app/Views/notification.php index 543253b4..77aaf3c2 100755 --- a/app/Views/notification.php +++ b/app/Views/notification.php @@ -237,7 +237,7 @@ - + @@ -405,7 +405,7 @@ - + @@ -492,7 +492,7 @@ +
+
+
+ +
+
- +
-
+ -
+
- +
@@ -84,7 +91,7 @@
-
@@ -234,6 +241,7 @@
\ No newline at end of file diff --git a/app/Views/policy_gmc_terms.php b/app/Views/policy_gmc_terms.php index b7e6c9a8..ff2b1925 100755 --- a/app/Views/policy_gmc_terms.php +++ b/app/Views/policy_gmc_terms.php @@ -107,7 +107,7 @@
-
+
@@ -116,9 +116,9 @@
-
+
-
+
@@ -126,16 +126,16 @@
-
+
Yes No
-
+
-
+
@@ -143,12 +143,16 @@ + + + + @@ -162,6 +166,8 @@ + +
Min Age:
Max Age:
Is Payable by employee:
Spouse:
Min Age:
Max Age:
Is Payable by employee:
Children:
Min Age:
Max Age:
Is Payable by employee:
@@ -192,6 +198,8 @@
Elders Count:
Min Age:
Max Age:
+ Is Payable by employee: + @@ -202,7 +210,7 @@
-
+
@@ -406,7 +414,7 @@