diff --git a/app/Config/Routes.php b/app/Config/Routes.php
index 77cf4c62..f4df6e62 100644
--- a/app/Config/Routes.php
+++ b/app/Config/Routes.php
@@ -271,6 +271,7 @@ $routes->get("processjob", "JobWorker::processJob");
//Employee login api's
$routes->post("/employeeRest/verifyEmployeeNumber", "RestAuthenticationController::verifyEmployeeWithMobileNumber");
$routes->post("/employeeRest/getVerifiedUserData", "RestAuthenticationController::getVerifiedUserData");
+$routes->post("/employeeRest/verifyMpin", "RestAuthenticationController::verifyMpin");
//HR login api's
$routes->post("/employeeRest/verifyHrWithMobileNumber", "RestAuthenticationController::verifyHrWithMobileNumber");
$routes->post("/employeeRest/getVerifiedHrData", "RestAuthenticationController::getVerifiedHrData");
@@ -282,10 +283,11 @@ $routes->group("/api", ["filter" => "authJWT"], function ($routes) {
-$routes->get("getEmployeePolicy", "EmployeeRestController::getEmployeePolicy");
-$routes->get("getAddOnPolicy", "EmployeeRestController::getAddOnPolicy");
+
$routes->get("getChatResponse", "ChatBotController::getChatResponse");
$routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) {
+ $routes->post("saveMpin", "RestAuthenticationController::saveMpin");
+ $routes->post("updateMpin", "RestAuthenticationController::updateMpin");
$routes->get("getChatResponse", "ChatBotController::getChatResponse");
$routes->get("getEmployeeProfile", "EmployeeRestController::getEmployeeProfile");
$routes->post("employeeUpload", "EmployeeRestController::employeeUpload");
diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php
index 7a406e62..464e9a04 100644
--- a/app/Controllers/ClientController.php
+++ b/app/Controllers/ClientController.php
@@ -1288,20 +1288,16 @@ class ClientController extends AdminController
$insurer_id = $client_policy_data['insurer_id'];
$client_id = $client_policy_data['client_id'];
- $base_policy_policy_type_id = 0;
- if($client_policy_data['base_policy'] != null){
- $base_policy_policy_type_id = $this->clientPolicyModel->select('policy_type_id')->where(['id' => $client_policy_data['base_policy'], 'is_active' => 1])->first();
- }
-
$polices = $this->policesModel
->select('policies.*, policy_type.policy_type')
->join('policy_type', 'policy_type.id = policies.policy_type_id')
->where(['policies.insurer_id' => $insurer_id, 'policies.is_active' => 1])
->findAll();
+
$client_policy_list = $this->clientPolicyModel->getpolicyWithPattern( $client_id );
$cd_data = $this->CDMasterModel->where('client_id', $client_id)->where('insurer_id', $insurer_id)->findAll();
- return $this->respond(['status' => true,'code' => 200, 'client_policy_list' => $client_policy_list, 'data' => $client_policy_data, 'cd_data' => $cd_data, "insurer_id" => $client_policy_data['insurer_id'], 'policy' => $polices, 'base_policy_type_id' => $base_policy_policy_type_id['policy_type_id']], 200);
+ return $this->respond(['status' => true,'code' => 200, 'client_policy_list' => $client_policy_list, 'data' => $client_policy_data, 'cd_data' => $cd_data, "insurer_id" => $client_policy_data['insurer_id'], 'policy' => $polices], 200);
}else{
return $this->respond(['status' => false,'code' => 404, 'message' => 'no data found'], 200);
}
diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php
index ec8467e6..db9b306c 100644
--- a/app/Controllers/EmployeeController.php
+++ b/app/Controllers/EmployeeController.php
@@ -674,14 +674,14 @@ class EmployeeController extends AdminController
// client_policy_id pull draft and enrolled status employees and proceed to calculatin and make entry in DB
public function initiateManualEmployeesOnboardProcess($client_policy_id)
{
- $client_data = $this->clientPolicyModel->select('clients.client_name as client_name, policies.name as policy_name')
+ $client_data = $this->clientPolicyModel->select('clients.client_name as client_name, policies.name as policy_name,client_branch_id')
->join('clients', 'clients.id = client_policy.client_id')
->join('policies', 'policies.id = client_policy.policy_id')
->where('client_policy.id', $client_policy_id)
->first();
$empServiceController = new EmployeeServiceController();
- $res = $empServiceController->employeesOnboardPreprocess(['client_policy_id' => $client_policy_id]);
+ $res = $empServiceController->employeesOnboardPreprocess(['client_policy_id' => $client_policy_id,'client_branch_id' => $client_data['client_branch_id']]);
// dd($res);
$count = count($res);
@@ -916,7 +916,7 @@ class EmployeeController extends AdminController
try {
$get_emp_code_and_client_policy_id = $this->employeePolicyModel
- ->select('employee_polices.client_policy_id, employees.emp_code, tpa.short_name')
+ ->select('employee_polices.client_policy_id, employees.emp_code, tpa.short_name,employees.client_id')
->join('client_policy', 'client_policy.id = employee_polices.client_policy_id')
->join('employees', 'employees.id = employee_polices.employee_id')
->join('tpa', 'tpa.id = client_policy.tpa_id')
@@ -940,10 +940,10 @@ class EmployeeController extends AdminController
$emp_code = $get_emp_code_and_client_policy_id['emp_code'];
- $data = $this->employeePolicyModel->getECardDataUsingMd5($client_policy_id, $emp_code);
+ $data = $this->employeePolicyModel->getECardDataUsingMd5($client_policy_id, $emp_code,$client_id);
if($people == 0){
- $data = $this->employeePolicyModel->getECardSingleData($rand_string, $emp_code);
+ $data = $this->employeePolicyModel->getECardSingleData($rand_string, $emp_code,$client_id);
}
// dd($data);
diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php
index 10aac50d..6dcd79c2 100644
--- a/app/Controllers/EmployeeRestController.php
+++ b/app/Controllers/EmployeeRestController.php
@@ -1753,10 +1753,10 @@ public function getAddOnPolicy()
public function iAgreeForAddOn()
{
-
$postData = json_decode($this->request->getBody(), true);
-
$client_policy_id = $postData['client_policy_id'];
+
+ // Alternatively, you can use echo to see the type
$emp_code = $postData['emp_code'];
$client_id = $postData['client_id'];
@@ -1765,7 +1765,7 @@ public function iAgreeForAddOn()
->where('is_active', 1 )
->set(array('emp_status'=>'enrolled'))
->update();
-
+
if (!is_null($client_policy_id) && is_array($client_policy_id))
{
$array_list = [];
@@ -1776,9 +1776,10 @@ public function iAgreeForAddOn()
->set(array('status'=>'enrolled'))
->update();
$find = $this->employeeModel->getEmpFamilybyEmpCode(client_policy_id: $value,emp_code: $emp_code,client_id: $client_id,emp_status:['draft','enrolled'],policy_status:['draft','enrolled']);
- $array_list[] = $find;
+ if(count($find) > 0){
+ $array_list[] = $find;
+ }
}
-
$notification = $this->notificationModel->where('client_id' ,$client_id)->where('template_name', 'member_review_and_summary_mail')->first();
diff --git a/app/Controllers/EmployeeServiceController.php b/app/Controllers/EmployeeServiceController.php
index fdeca4c1..31e23163 100644
--- a/app/Controllers/EmployeeServiceController.php
+++ b/app/Controllers/EmployeeServiceController.php
@@ -1206,7 +1206,7 @@ class EmployeeServiceController extends AdminController
// $file = ['id' => null,'client_id' => $client_id,'policy_id' => $client_policy_id,'action' => 'inception'];
- $file = ['id' => null,'client_id' => $client_id,'policy_id' => $client_policy_id,'action' => 'inception','created_by' => get_session_userid()];
+ $file = ['id' => null,'client_id' => $client_id,'policy_id' => $client_policy_id,'action' => 'inception','created_by' => get_session_userid(),'client_branch_id' => $params['client_branch_id']];
// dd($this->employeeModel->getLastQuery());
// Kint::dump($existing_famility_details);die();
$employee_data_group_by_family = data_group_by_family($existing_famility_details,$data_source = 'db');
diff --git a/app/Controllers/RestAuthenticationController.php b/app/Controllers/RestAuthenticationController.php
index 56fb00c5..4e5cf279 100644
--- a/app/Controllers/RestAuthenticationController.php
+++ b/app/Controllers/RestAuthenticationController.php
@@ -212,5 +212,104 @@ class RestAuthenticationController extends AdminController
}
+ public function saveMpin()
+ {
+ try {
+ $mobile_number = $this->request->getJSON()->mobile_number;
+ $mpin = $this->request->getJSON()->mpin;
+
+
+ $employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first();
+
+ if ($employeeData) {
+ $id= $employeeData["id"];
+ $updateMpin = $this->employeeModel->where('id', $id)->set('mpin', $mpin)->update();
+ if($updateMpin){
+ $result = ['user_verification' => true , 'message' => "Mpin Updated"];
+ return $this->respond(['status' => 'success','code' => 200,'data' => $result],200);
+ }else{
+ $result = ['user_verification' => true , 'message' => "Mpin Not Updated"];
+ return $this->respond(['status' => 'failed','code' => 404,'data' => $result],200);
+ }
+
+
+ } else {
+ $result = ['user_verification' => false , 'message' => "User not found"];
+ return $this->respond(['status' => 'failed','code' => 404,'data' => $result],200);
+
+ }
+ } catch (\Throwable $th) {
+ return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500);
+ }
+ }
+
+ public function updateMpin()
+ {
+ try {
+ $mobile_number = $this->request->getJSON()->mobile_number;
+ $old_mpin = $this->request->getJSON()->old_mpin;
+ $mpin = $this->request->getJSON()->new_mpin;
+
+
+ $employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('mpin', $old_mpin)->where('relationship', 'self')->first();
+
+ if ($employeeData) {
+ $id= $employeeData["id"];
+ $updateMpin = $this->employeeModel->where('id', $id)->set('mpin', $mpin)->update();
+ if($updateMpin){
+ $result = ['mpin_verification' => true , 'message' => "Mpin Updated"];
+ return $this->respond(['status' => 'success','code' => 200,'data' => $result],200);
+ }else{
+ $result = ['mpin_verification' => true , 'message' => "Mpin Not Updated"];
+ return $this->respond(['status' => 'failed','code' => 404,'data' => $result],200);
+ }
+
+
+ } else {
+ $result = ['mpin_verification' => false , 'message' => "Wrong Mpin"];
+ return $this->respond(['status' => 'failed','code' => 404,'data' => $result],200);
+
+ }
+ } catch (\Throwable $th) {
+ return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500);
+ }
+ }
+
+ public function verifyMpin()
+ {
+ try {
+ $mobile_number = $this->request->getJSON()->mobile_number;
+ $mpin = $this->request->getJSON()->mpin;
+
+ $employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first();
+
+ if ($employeeData && $mpin == $employeeData["mpin"]) {
+ $auth = HttpRequestHelper::getRequestInfo();
+ if ($auth) {
+ $data = [
+ 'user_id' => $employeeData['id'],
+ 'user_type' => 'employee',
+ 'ip' => $auth['ip'],
+ 'platform' => $auth['platform'],
+ 'broswer' => $auth['browser'],
+ ];
+
+ $authdata= $this->authHistoryModel->insert($data);
+
+ }
+
+
+
+ $result = JWTToken::encode($employeeData);
+ return $this->respond(['status' => 'success','code' => 200,'data' => $result],200);
+ } else {
+ return $this->respond(['status' => 'failed','code' => 404,'data' => "Invalid OTP"],200);
+ }
+ } catch (\Exception $e) {
+ return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()],500);
+ }
+ }
+
+
}
\ No newline at end of file
diff --git a/app/Helpers/sendMailNotification.php b/app/Helpers/sendMailNotification.php
index 0c8c7067..91bd81d9 100644
--- a/app/Helpers/sendMailNotification.php
+++ b/app/Helpers/sendMailNotification.php
@@ -158,8 +158,11 @@ class sendMailNotification
$addtional_premium = 0;
$gst = 0;
foreach ($array_list as $item) {
- $table_content .= '
Policy Name : ';
+ if(count($item) != 0){
+ $table_content .= 'Policy Name : ';
$temp_data ='';
+ $policy_name ='';
+ $is_addon ='';
foreach ($item as $inner_item) {
$policy_name = $inner_item['policy_name'];
$temp_data .= '| ' . $inner_item['name'] . ' | '.$inner_item['mobile'].' | ₹'.number_format($inner_item['basic_cover_si'], 2, '.', ',').' | '.\DateTime::createFromFormat('Y-m-d', $inner_item['dob'])->format('d-m-Y').' |
';
@@ -175,10 +178,11 @@ class sendMailNotification
$gst = $inner_item['gst'] + $gst;
}
}
+ // echo $policy_name;die;
$table_content .= $policy_name.'
| Name | Mobile Number | Sum Insure | Date Of Birth |
';
$table_content .= $temp_data;
$table_content .= '
';
-
+ $Addon_list = [];
if ($is_addon == 2 || $is_addon == 3) {
$addon_list_array = [
'policy_name'=>$policy_name,
@@ -193,6 +197,8 @@ class sendMailNotification
$temp_data = '';
$addtional_premium = 0;
$gst = 0;
+ }
+
}
$table_content .='
| Policy Name | Additional Premium | GST | Total |
';
@@ -220,11 +226,11 @@ class sendMailNotification
$client_id = $params['client_id'];
$clientModel = new ClientModel();
+ $notificationModel = new NotificationModel();
+ $clientRMModel =new ClientRMModel();
$client_data =$clientModel->where('id', $client_id)->first();
- $notificationModel = new NotificationModel();
$notification_data = $notificationModel->where('client_id' ,$client_id)->where('template_name', $action)->first();
- $clientRMModel =new ClientRMModel();
if ($notification_data['enabled'] == 1) {
$client_rm_data= $clientRMModel->where('client_id', $client_id)->where('is_active',1)->findAll();
@@ -236,6 +242,7 @@ class sendMailNotification
$user_list[]=$user_data;
}
}
+ // print_r($client_rm_data);die;
@@ -262,8 +269,11 @@ class sendMailNotification
$array_list = $params['array_list'];
foreach ($array_list as $item) {
- $table_content .= 'Policy Name : ';
+ if(count($item) != 0){
+ $table_content .= 'Policy Name : ';
$temp_data ='';
+ $policy_name ='';
+ $is_addon ='';
foreach ($item as $inner_item) {
$policy_name = $inner_item['policy_name'];
$temp_data .= '| ' . $inner_item['name'] . ' | '.$inner_item['mobile'].' | ₹'.number_format($inner_item['basic_cover_si'], 2, '.', ',').' | '.\DateTime::createFromFormat('Y-m-d', $inner_item['dob'])->format('d-m-Y').' |
';
@@ -278,7 +288,7 @@ class sendMailNotification
$table_content .= $policy_name.'
| Name | Mobile Number | Sum Insure | Date Of Birth |
';
$table_content .= $temp_data;
$table_content .= '
';
-
+ $Addon_list = [];
if ($is_addon == 2 || $is_addon == 3) {
$addon_list_array = [
'policy_name'=>$policy_name,
@@ -293,6 +303,8 @@ class sendMailNotification
$temp_data = '';
$addtional_premium = 0;
$gst = 0;
+ }
+
}
@@ -308,14 +320,17 @@ class sendMailNotification
$mail_content = str_replace("[[member_summary]]", $table_content , $mail_content);
$account_manager_mail_list = [];
- foreach ($user_list as $key => $value) {
- $full_name = $value['first_name'] .' ' .$value['last_name'];
- $mail_content = str_replace("[[member_name]]", $full_name , $mail_content);
+ // print_r($user_list);die;
+ if(isset($user_list)){
+ foreach ($user_list as $key => $value) {
+ $full_name = $value['first_name'] .' ' .$value['last_name'];
+ $mail_content = str_replace("[[member_name]]", $full_name , $mail_content);
- $wholeData[] = ['mail' => $value['email'], 'subject' => $subject,'message'=> $mail_content];
- // $wholeData[] = ['mail' => $value['email'], 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails']];
+ $wholeData[] = ['mail' => $value['email'], 'subject' => $subject,'message'=> $mail_content];
+ // $wholeData[] = ['mail' => $value['email'], 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails']];
+ }
+ return $wholeData;
}
- return $wholeData;
}
} else if($action == 'client_hr_summary_mail'){
@@ -380,7 +395,7 @@ class sendMailNotification
$table_content .= $policy_name.'
| Name | Mobile Number | Sum Insure | Date Of Birth |
';
$table_content .= $temp_data;
$table_content .= '
';
-
+ $Addon_list = [];
if ($is_addon == 2 || $is_addon == 3) {
$addon_list_array = [
'policy_name'=>$policy_name,
@@ -413,7 +428,7 @@ class sendMailNotification
$hr_mails = $client_data['hr_mails'];
$mail_array = explode(',', $hr_mails);
$mail_array = array_map('trim', $mail_array);
-
+ $wholeData = [];
foreach ($mail_array as $key => $value) {
$wholeData[] = ['mail' => $value, 'subject' => $subject,'message'=> $mail_content];
// $wholeData[] = ['mail' => $value, 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails']];
diff --git a/app/Models/EmployeeModel.php b/app/Models/EmployeeModel.php
index adffe7ff..13a1e5e7 100644
--- a/app/Models/EmployeeModel.php
+++ b/app/Models/EmployeeModel.php
@@ -40,7 +40,8 @@ class EmployeeModel extends Model
"is_createdby_hr",
"client_branch_id",
"token_time_out",
- "emp_type"
+ "emp_type",
+ "mpin"
];
// Callbacks
diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php
index 160eb71e..a94410f5 100644
--- a/app/Models/EmployeePolicyModel.php
+++ b/app/Models/EmployeePolicyModel.php
@@ -814,7 +814,7 @@ class EmployeePolicyModel extends Model
->get()->getResultArray();
}
- public function getECardDataUsingMd5($client_policy_id, $emp_code){
+ public function getECardDataUsingMd5($client_policy_id, $emp_code,$client_id){
$result = $this->db->table('employees e')
->select('e.id,
@@ -829,7 +829,7 @@ class EmployeePolicyModel extends Model
e.doj,
e.band,
TIMESTAMPDIFF(YEAR, e.dob, CURDATE()) AS emp_age,
- (SELECT name FROM employees WHERE relationship = "Self" and emp_code = ' . $this->db->escape($emp_code) . ') AS self,
+ (SELECT name FROM employees WHERE relationship = "Self" and emp_code = ' . $this->db->escape($emp_code) . ' and client_id = '.$client_id.') AS self,
ep.tpa_id,
@@ -881,7 +881,7 @@ class EmployeePolicyModel extends Model
}
- public function getECardSingleData($rand_string, $emp_code){
+ public function getECardSingleData($rand_string, $emp_code,$client_id){
$result = $this->db->table('employees e')
->select('e.id,
@@ -896,7 +896,7 @@ class EmployeePolicyModel extends Model
e.doj,
e.band,
TIMESTAMPDIFF(YEAR, e.dob, CURDATE()) AS emp_age,
- (SELECT name FROM employees WHERE relationship = "Self" and emp_code = ' . $this->db->escape($emp_code) . ') AS self,
+ (SELECT name FROM employees WHERE relationship = "Self" and emp_code = ' . $this->db->escape($emp_code) . ' and client_id = '.$client_id.') AS self,
ep.tpa_id,
diff --git a/app/Models/LevelContactModel.php b/app/Models/LevelContactModel.php
index 79a8f15a..88f52ab2 100644
--- a/app/Models/LevelContactModel.php
+++ b/app/Models/LevelContactModel.php
@@ -22,6 +22,7 @@ class LevelContactModel extends Model
"updated_by",
"otp",
"is_active",
+ "token_time_out"
];
}