diff --git a/app/Config/Routes.php b/app/Config/Routes.php
index f4942153..6ad4f058 100755
--- a/app/Config/Routes.php
+++ b/app/Config/Routes.php
@@ -26,6 +26,8 @@ $routes->get("updateRemainderDate", "ClientController::updateRemainderDate");
$routes->get("sendCroneRemainderMail", "DashboardController::sendCroneRemainderMail");
$routes->get("sendextraparam", "ClientController::sendextraparam");
// $routes->post("iAgreeForAddOn", "EmployeeRestController::iAgreeForAddOn");
+// $routes->get("sendCroneRemainderMail", "DashboardController::sendCroneRemainderMail");
+// $routes->post("employeeUpload", "EmployeeRestController::employeeUpload");
$routes->post("add_advertise_image", "AppContentManagementController::add_advertise_image");
$routes->get("add_image_index", "AppContentManagementController::add_image_index");
@@ -134,6 +136,11 @@ $routes->group("/client", ["filter" => "authMVC"], function ($routes) {
$routes->get("list/(:any)", "ClientController::listVehicleFiles/$1");
$routes->get("delete/(:any)", "ClientController::deleteVehicleFiles/$1");
});
+
+
+ $routes->group("others", ["filter" => "authMVC"], function ($routes) {
+ $routes->post("create", "ClientController::createOtherTabContent");
+ });
});
$routes->group("/employee", ["filter" => "authMVC"], function ($routes) {
@@ -448,11 +455,11 @@ $routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) {
$routes->get("getFEContent", "EmployeeRestController::getFEContent");
$routes->get("getAdvertisementImage", "EmployeeRestController::getAdvertisementImage");
});
-
+$routes->get("getEmployeeActiveOrInactivePolicy", "EmployeeRestController::getEmployeeActiveOrInactivePolicy");
$routes->get("sendPushNotification", "EmployeeRestController::sendPushNotification");
$routes->post("sendEmail", "EmployeeRestController::send_email");
-$routes->get("getFamilyPolicyDetails", "EmployeeRestController::getFamilyPolicyDetails");
+$routes->get("getBackToEnrolledDetails", "EmployeeRestController::getBackToEnrolledDetails");
// Ticketing System
diff --git a/app/Controllers/ChatBotController.php b/app/Controllers/ChatBotController.php
index afc79b5e..d2ecad96 100755
--- a/app/Controllers/ChatBotController.php
+++ b/app/Controllers/ChatBotController.php
@@ -73,7 +73,7 @@ class ChatBotController extends AdminController
public function getChatResponse()
{
- // try {
+ try {
$emp_code = $this->request->getVar('emp_code');
$client_id = $this->request->getVar('client_id');
$client_branch_id = $this->request->getVar('client_branch_id');
@@ -236,9 +236,9 @@ class ChatBotController extends AdminController
return $this->respond(['status' => 'failed','code' => 404,'data' => 'No Data'],404);
}
- // } catch (\Throwable $th) {
- // return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500);
- // }
+ } catch (\Throwable $th) {
+ return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500);
+ }
}
diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php
index 6191c995..fcdd14e4 100755
--- a/app/Controllers/ClientController.php
+++ b/app/Controllers/ClientController.php
@@ -118,6 +118,8 @@ class ClientController extends AdminController
$this->leadsModel = new LeadsModel();
}
+ //--------------------------------------------------------------------------------------------------------
+
public function checkDuplicateTableFieldValue()
{
$table = $this->request->getPost('table');
@@ -181,7 +183,7 @@ class ClientController extends AdminController
print_rr($attachments);
}
- public function testingForReviewMail($client_id = 77, $emp_code = 'EMP001-K1', $mail_active = 1) //this function for only tsesting some logics not use for business logic
+ public function testingForReviewMail($client_id = 77, $emp_code = 'EMP001-K1', $mail_active = 0) //this function for only tsesting some logics not use for business logic
{
$client_policy_ids = $this->employeeModel
@@ -315,6 +317,8 @@ class ClientController extends AdminController
// return $this->respond(['status' => 'success','code' => 200,'data' => [] ], 200);
}
+ //--------------------------------------------------------------------------------------------------------
+
public function index()
{
$this->myLogger->logme('error', 'Client list function called');
@@ -2079,6 +2083,11 @@ class ClientController extends AdminController
$data['age_ratio']['elders']['min'] = $this->request->getPost("other_member_min_age") ? $this->request->getPost("other_member_min_age") : 0;
$data['age_ratio']['elders']['max'] = $this->request->getPost("other_member_max_age") ? $this->request->getPost("other_member_max_age") : 0;
+ $data['is_payable_employee']['self'] = $this->request->getPost("is_payable_employee_for_self") ? 1 : 0;
+ $data['is_payable_employee']['spouse'] = $this->request->getPost("is_payable_employee_for_spouse") ? 1 : 0;
+ $data['is_payable_employee']['childern'] = $this->request->getPost("is_payable_employee_for_child") ? 1 : 0;
+ $data['is_payable_employee']['elders'] = $this->request->getPost("is_payable_employee_for_elders") ? 1 : 0;
+
// if (!in_array("self", $data['family_floaters'])) {
@@ -2169,6 +2178,7 @@ class ClientController extends AdminController
$data['preandpostnatal'] = "";
$data['babyday1cover'] = "";
}
+
$data['9monthwaitingperiodwaived'] = str_replace(',', '', $this->request->getPost("9monthwaitingperiodwaived"));
$data['coverfromthedateofjoining'] = str_replace(',', '', $this->request->getPost("coverfromthedateofjoining"));
$data['waiverof1,2,3&4thyearexclusions'] = $this->request->getPost("waiverof1,2,3&4thyearexclusions");
@@ -2309,6 +2319,8 @@ class ClientController extends AdminController
$data['totalSumInsured'] = str_replace(',', '', $this->request->getPost("totalSumInsured"));
$data['age_ratio']['self']['min'] = $this->request->getPost("self_min_age");
$data['age_ratio']['self']['max'] = $this->request->getPost("self_max_age");
+ $data['is_payable_employee']['self'] = 0;
+
$data['accidentalDeathBenefit'] = str_replace(',', '', $this->request->getPost("accidentalDeathBenefit"));
$data['permanentTotalDisablement'] = str_replace(',', '', $this->request->getPost("permanentTotalDisablement"));
$data['permanentPartialDisablement'] = $this->request->getPost("permanentPartialDisablement");
@@ -2442,11 +2454,11 @@ class ClientController extends AdminController
$termsData = json_decode($termsData['policy_terms']);
- if (isset($termsData->sum_insured) && empty($termsData->sum_insured)) {
+ if (isset($termsData->sum_insured) && $termsData->sum_insured == "" && $termsData->sum_insured == null) {
return $this->respond(['status' => false, 'code' => 200, 'message' => 'The Policy terms Sum Insured field is empty', 'data' => $record], 200);
}
- if (isset($termsData->SumInsured) && empty($termsData->sum_insured)) {
+ if (isset($termsData->sumInsured2) && $termsData->sumInsured2 == "" && $termsData->sumInsured2 == null) {
return $this->respond(['status' => false, 'code' => 200, 'message' => 'The Policy terms Sum Insured field is empty'], 200);
}
@@ -2892,6 +2904,13 @@ class ClientController extends AdminController
$client_policy_id = $this->request->getPost("client_policy_id");
$policy_terms = $this->request->getPost("policy_terms");
+ if (!empty($policy_terms)) {
+ $policy_terms = json_decode($policy_terms, true);
+ $policy_terms['is_payable_employee']['self'] = 0;
+ $policy_terms = json_encode($policy_terms);
+ }
+
+
$record = $this->clientPolicyModel->where('id', $client_policy_id)->first();
if ($record) {
@@ -3602,15 +3621,22 @@ class ClientController extends AdminController
dd($result);
}
+ // ---------------------------------------------------------------------------------------------------------
+
public function updatePolicyTermsKey()
{
+ $client_id = $this->request->getGet('client_id');
- $data = $this->clientPolicyModel
+ $query = $this->clientPolicyModel
->where("policy_terms IS NOT NULL AND policy_terms <> ''")
- ->where('policy_type_id', 2)
- ->where('is_active', 1)
- ->findAll();
-
+ ->where('is_active', 1);
+
+ if (!empty($client_id)) {
+ $query->where('client_id', $client_id);
+ }
+
+ $data = $query->findAll();
+
for ($i = 0; $i < count($data); $i++) {
if (isset($data[$i]['policy_terms']) && !empty($data[$i]['policy_terms'])) {
@@ -3619,49 +3645,110 @@ class ClientController extends AdminController
continue;
}
- // Set default value of copayzonewisecopay to "empty"
- $ans = isset($policyTerms['copayzonewisecopay']) ? $policyTerms['copayzonewisecopay'] : 'empty';
+ $is_addon = $data[$i]['is_addon'];
+
+ $payable_arr = [];
+ if (in_array($data[$i]['policy_type_id'], [2,3]) && $is_addon == 1) {
+
+ $payable_arr = [ "self" => 0, "spouse" => 0, "childern" => 0, "elders" => 0, ];
+
+ } else if ($data[$i]['policy_type_id'] == 3 && $is_addon == 3) {
+
+ $payable_arr = ["self" => 1,"spouse" => 1,"childern" => 1,"elders" => 1,];
+
+ } else if (in_array($data[$i]['policy_type_id'], [4, 5])) {
+
+ $payable_arr = ["self" => 1,"spouse" => 1,"childern" => 1,"elders" => 1,];
+ }
// Initialize an empty array for the ordered policy terms
$orderedPolicyTerms = [];
- // Add copayzonewisecopay and copayzonewisecopaydata if they exist_
- if (isset($policyTerms['copayzonewisecopay'])) {
+ if(in_array($data[$i]['policy_type_id'], [2,3,4,5])){
- if(!isset($policyTerms['co_pay_details'])){
+ // Set default value of copayzonewisecopay to "empty"
+ $ans = isset($policyTerms['copayzonewisecopay']) ? $policyTerms['copayzonewisecopay'] : 'empty';
- $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;
+ // add is_payable_employee for the GMC Policy
+ if (isset($policyTerms['age_ratio'])) {
+ if(!isset($policyTerms['is_payable_employee'])){
+ $aliment_index = array_search('age_ratio', array_keys($policyTerms));
+ $orderedPolicyTerms[] = [
+ "key" => "is_payable_employee",
+ "value" => $payable_arr,
+ "position" => $aliment_index + 1,
+ ];
}
-
- $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 copayzonewisecopay and copayzonewisecopaydata if they exist_
+ if (isset($policyTerms['copayzonewisecopay'])) {
+
+ 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 + 2,
+ ];
+
+ unset($policyTerms['optionalparentalcopay']);
+
+ }
+ }
+
+ // Add ailmentcapping and ailmentcappingdata if they exist
+ if (isset($policyTerms['ailmentcapping'])) {
+ if(!isset($policyTerms['ailment_capping_details'])){
+ $aliment_index = array_search('ailmentcapping', array_keys($policyTerms));
+ $orderedPolicyTerms[] = [
+ "key" => "ailment_capping_details",
+ "value" => "",
+ "position" => $aliment_index + 3,
+ ];
+ }
+ }
+
+ }else {
+
+ // add is_payable_employee for the GMC Policy
+ if (isset($policyTerms['age_ratio'])) {
+ if(!isset($policyTerms['is_payable_employee'])){
+ $aliment_index = array_search('age_ratio', array_keys($policyTerms));
+ $orderedPolicyTerms[] = [
+ "key" => "is_payable_employee",
+ "value" => [
+ "self" => 0,
+ ],
+ "position" => $aliment_index + 1,
+ ];
+ }
+ }else{
+
+ if(!isset($policyTerms['is_payable_employee'])){
+ $orderedPolicyTerms[] = [
+ "key" => "is_payable_employee",
+ "value" => [
+ "self" => 0,
+ ],
+ "position" => 2,
+ ];
+ }
+ }
+
}
- // Add ailmentcapping and ailmentcappingdata if they exist_
- if (isset($policyTerms['ailmentcapping'])) {
- 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'];
@@ -3706,10 +3793,24 @@ class ClientController extends AdminController
dd($days);
}
- public function sendextraparam(){
+ public function sendextraparam()
+ {
+ // $batch_data = [
+ // 'client_id' => 17,
+ // 'client_policy_id' => 30,
+ // 'client_branch_id' => 18,
+ // ];
+ // $batch_data['insurer_or_tpa'] = 'insurer';
+ // $batch_data['insurer_or_tpa'] = 'tpa';
+
+
+ // dd($this->request);
// $employeeRestController = new EmployeeServiceController();
- // $employeeRestController->employeesEnrollmentInsert(['file_id' => 715]);
+ // $employeeRestController->employeesEnrollmentInsert(['file_id' => 721]);
+
+ // $r = Jobs::addJob(['job_name' => 'employeesEnrollmentInsert','payload' => ['file_id' => 721]]);
+
// $dashBoardController = new DashboardController();
// $client_policy_data = $this->clientPolicyModel->getPolicyDetailsForRemainder($client_id=159, $client_branch_id=126);
@@ -3719,6 +3820,60 @@ class ClientController extends AdminController
// $emp_data = $this->employeePolicyModel->getEmployeePolicyForEcard(12);
// $ids = array_column($emp_data, 'id');
// $EmpDataServiceController->sendMailForDownloadingECard($ids);
+
+ // $EmpDataServiceController = new EmpDataServiceController();
+ // $EmpDataServiceController->importDeletionValidation(['file_id' => 304]); //for live
+
+ // $result = $this->employeePolicyModel->getDeletionEmployeeDataForExportExcel($batch_data);
+ // print_rr($result); die;
+
+ // $empServiceController = new EmployeeServiceController();
+ // $res = $empServiceController->employeesOnboardPreprocess(['file_id' => '741']);
+
+ // $PolicyTransactionController = new PolicyTransactionController();
+ // $res = $PolicyTransactionController->validateInsurerStatement(['file_id' => '36']);
}
+
+ // -------------------------------------------------------------------------------------------------------
+
+ public function createOtherTabContent()
+ {
+ $this->myLogger->logme('error', 'Client Others function called');
+ $data = $this->request->getPost();
+ $data['created_by'] = get_session_userid();
+ $client_id = $data['client_id'];
+ unset($data['client_id']);
+
+ $insert = $this->clientModel->where('id', $client_id)->set($data)->update();
+
+ if ($insert) {
+ return $this->respond(['status' => true, 'code' => 200, 'message' => 'Client others data updated', 'data' => $data], 200);
+ } else {
+ return $this->respond(['status' => false, 'code' => 404, 'message' => 'No data to update'], 200);
+ }
+ }
+
+
+ // -------------------------------------------------------------------------------------------------------
+
+ public function enrollmentAddonSIAmountDropdown($client_policy_id)
+ {
+ if(!empty($client_policy_id)){
+ $client_policy_details = $this->clientPolicyModel->where('id', $client_policy_id)->where('policy_status', 1)->where('is_active', 1)->first();
+
+ if(!empty($client_policy_details) && $client_policy_details['policy_type_id'] == 3 && $client_policy_details['is_addon'] == 3){
+
+ $base_policy_id = $client_policy_details['base_policy'] ?? 0;
+
+ if(!empty($base_policy_id)){
+
+
+
+ }
+
+ }
+ }
+ }
+
}
diff --git a/app/Controllers/DashboardController.php b/app/Controllers/DashboardController.php
index b4843a59..7c0ef32b 100755
--- a/app/Controllers/DashboardController.php
+++ b/app/Controllers/DashboardController.php
@@ -365,41 +365,81 @@ class DashboardController extends AdminController
foreach ($client_policy_data as $client_policy) {
- if (empty($send_mail_for_manual_or_crone)) {
+ // Fetch client data
+ $client_data = $this->clientModel->find($client_policy['client_id']);
- // 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'])
+ ->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();
+ if ($notification_data && $notification_data['enabled'] == 1 && !empty($notification_data['mail_content'])) {
- // $this->myLogger->logme('error', 'Notification data fetched: ' . json_encode($notification_data));
+ //manaual
+ if (empty($send_mail_for_manual_or_crone)) {
- // Check if notification should be sent
- if ($notification_data && $notification_data['enabled'] == 1 && !empty($notification_data['mail_content'])) {
+ // Check if notification should be sent
$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.*, employee_polices.id as emp_policy_id')
- ->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();
+ $employees = [];
+ if (in_array($client_policy['policy_type_id'], [2, 4]) || ($client_policy['policy_type_id'] == 3 && $client_policy['is_addon'] == 1)) {
- // dd($employees);
+ // Fetch all employees related to the client policy
+ $employees = $this->employeePolicyModel
+ ->select('employees.*, employee_polices.id as emp_policy_id')
+ ->join('employees', 'employee_polices.employee_id = employees.id', 'left')
+ ->where('employee_polices.client_policy_id', $client_policy['id'])
+ ->where('employees.is_active', 1)
+ ->where('employee_polices.is_active', 1)
+ ->where('employees.emp_status', 'draft')
+ ->where('employee_polices.status', 'draft')
+ ->where('employees.relationship', 'Self')
+ ->where("employees.email_corporate IS NOT NULL AND employees.email_corporate != ''")
+ ->findAll();
+
+ // dd($employees, 'first');
+
+ } else if (($client_policy['policy_type_id'] == 3 && $client_policy['is_addon'] == 3) || $client_policy['policy_type_id'] == 5) {
+
+ $empDependentData = $this->employeePolicyModel
+ ->select('employees.*, employee_polices.id as emp_policy_id')
+ ->join('employees', 'employee_polices.employee_id = employees.id', 'left')
+ ->where('employee_polices.client_policy_id', $client_policy['id'])
+ ->where('employees.is_active', 1)
+ ->where('employee_polices.is_active', 1)
+ ->where('employees.emp_status', 'draft')
+ ->where('employee_polices.status', 'draft')
+ ->where('employees.relationship !=', 'Self')
+ ->findAll();
+
+ $empCodes = array_column($empDependentData, 'emp_code');
+
+ // dd($empDependentData, $empCodes,'second');
+
+ if (!empty($empCodes)) {
+
+ $empSelfData = $this->employeePolicyModel
+ ->select('employees.*, employee_polices.id as emp_policy_id')
+ ->join('employees', 'employee_polices.employee_id = employees.id', 'left')
+ ->whereIn('employees.emp_code', $empCodes)
+ ->where('employees.is_active', 1)
+ ->where('employee_polices.is_active', 1)
+ ->where('employees.relationship', 'Self')
+ ->where("employees.email_corporate IS NOT NULL AND employees.email_corporate != ''")
+ ->findAll();
+
+ $employees = array_merge($employees, $empSelfData);
+ }
+ }
+
+ // dd($employees);
// Process each employee
- foreach ($employees as $employee) {
+ if (!empty($employees) && count($employees) > 0) {
+
+ 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
@@ -407,8 +447,8 @@ class DashboardController extends AdminController
$params['client_data'] = $client_data;
$params['notification_data'] = $notification_data;
$params['common'] = [
- 'client_id' => $client_policy['client_id'],
- 'client_branch_id' => $client_policy['client_branch_id'],
+ 'client_id' => $client_policy['client_id'],
+ 'client_branch_id' => $client_policy['client_branch_id'],
'client_policy_id' => $client_policy['id'],
'employee_policy_id' => $employee['emp_policy_id'],
'employee_id' => $employee['id'],
@@ -422,50 +462,76 @@ class DashboardController extends AdminController
$reminder_whole_mail[] = $mail_result[0];
}
}
- } else {
- $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 {
- $currentDate = date('d');
- $remainder_dates = explode(",", $client_policy['reminder_date']);
+ } else { // crone
- foreach ($remainder_dates as $date) {
+ if (!empty($client_policy['reminder_date'])) {
- if ($currentDate == $date) {
+ $currentDate = date('d');
+ $remainder_dates = explode(",", $client_policy['reminder_date']);
- $client_data = $this->clientModel->find($client_policy['client_id']);
+ foreach ($remainder_dates as $date) {
- // Fetch notification settings
- $notification_data = $this->notificationModel
- ->where('client_id', $client_policy['client_id'])
- ->where('template_name', 'member_reminder_mail')
- ->first();
+ if ($currentDate == $date) {
- // 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']);
- // echo '4';
+ // Fetch all employees related to the client policy
+ $employees = [];
+ if (in_array($client_policy['policy_type_id'], [2, 4]) || ($client_policy['policy_type_id'] == 3 && $client_policy['is_addon'] == 1)) {
- $this->myLogger->logme('error', 'Notification should be sent for client policy ID: ' . $client_policy['id']);
+ $employees = $this->employeePolicyModel
+ ->select('employees.*, employee_polices.id as emp_policy_id')
+ ->join('employees', 'employee_polices.employee_id = employees.id', 'left')
+ ->where('employee_polices.client_policy_id', $client_policy['id'])
+ ->where('employees.is_active', 1)
+ ->where('employee_polices.is_active', 1)
+ ->where('employees.emp_status', 'draft')
+ ->where('employee_polices.status', 'draft')
+ ->where('employees.relationship', 'Self')
+ ->where("employees.email_corporate IS NOT NULL AND employees.email_corporate != ''")
+ ->findAll();
- // Fetch all employees related to the client policy
- $employees = $this->employeePolicyModel
- ->select('employees.*, employee_polices.id as emp_policy_id')
- ->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();
+ // dd($employees, 'first');
- // Process each employee
- foreach ($employees as $employee) {
+ } else if (($client_policy['policy_type_id'] == 3 && $client_policy['is_addon'] == 3) || $client_policy['policy_type_id'] == 5) {
+
+ $empDependentData = $this->employeePolicyModel
+ ->select('employees.*, employee_polices.id as emp_policy_id')
+ ->join('employees', 'employee_polices.employee_id = employees.id', 'left')
+ ->where('employee_polices.client_policy_id', $client_policy['id'])
+ ->where('employees.is_active', 1)
+ ->where('employee_polices.is_active', 1)
+ ->where('employees.emp_status', 'draft')
+ ->where('employee_polices.status', 'draft')
+ ->where('employees.relationship !=', 'Self')
+ ->findAll();
+
+ $empCodes = array_column($empDependentData, 'emp_code');
+
+ // dd($empDependentData, $empCodes,'second');
+
+ if (!empty($empCodes)) {
+
+ $empSelfData = $this->employeePolicyModel
+ ->select('employees.*, employee_polices.id as emp_policy_id')
+ ->join('employees', 'employee_polices.employee_id = employees.id', 'left')
+ ->whereIn('employees.emp_code', $empCodes)
+ ->where('employees.is_active', 1)
+ ->where('employee_polices.is_active', 1)
+ ->where('employees.relationship', 'Self')
+ ->where("employees.email_corporate IS NOT NULL AND employees.email_corporate != ''")
+ ->findAll();
+
+ $employees = array_merge($employees, $empSelfData);
+ }
+ }
+
+ // dd($employees);
+
+ // 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
@@ -473,8 +539,8 @@ class DashboardController extends AdminController
$params['client_data'] = $client_data;
$params['notification_data'] = $notification_data;
$params['common'] = [
- 'client_id' => $client_policy['client_id'],
- 'client_branch_id' => $client_policy['client_branch_id'],
+ 'client_id' => $client_policy['client_id'],
+ 'client_branch_id' => $client_policy['client_branch_id'],
'client_policy_id' => $client_policy['id'],
'employee_policy_id' => $employee['emp_policy_id'],
'employee_id' => $employee['id'],
@@ -486,13 +552,19 @@ class DashboardController extends AdminController
// $this->myLogger->logme('error', 'Mail sent result: ' . json_encode($mail_result));
$reminder_whole_mail[] = $mail_result[0];
}
+
}
- } else {
- // echo '5';
- $this->myLogger->logme('error', 'Notification not sent for client policy ID: ' . $client_policy['id']);
}
+
+ } else {
+ $this->myLogger->logme('error', "SEND REMAINDER CRONE --- Remainder date is empty()");
}
}
+
+ } else {
+
+ $this->myLogger->logme('error', 'Notification setup not found or not enabled');
+ $this->myLogger->logme('error', 'Notification was not sent for this Client ID: ' . $client_policy['client_id']);
}
}
@@ -516,13 +588,13 @@ class DashboardController extends AdminController
}
}
- public function sendManualReminder($client_id, $client_branch_id)
+ public function sendManualReminder($client_id, $client_branch_id, $client_policy_id = null)
{
$this->myLogger->logme('error','Log Works');
$this->myLogger->logme('error', "sendManualRemainder called with client_id: {$client_id}, client_branch_id: {$client_branch_id}");
- $client_policy_data = $this->clientPolicyModel->getPolicyDetailsForRemainder($client_id, $client_branch_id);
+ $client_policy_data = $this->clientPolicyModel->getPolicyDetailsForRemainder($client_id, $client_branch_id, $client_policy_id);
// print_r($client_policy_data); die;
// print_r($this->clientPolicyModel->getLastQuery()); die;
// $this->myLogger->logme('error', "Policy details fetched: " . json_encode($client_policy_data));
diff --git a/app/Controllers/EmpDataServiceController.php b/app/Controllers/EmpDataServiceController.php
index 617eeda9..1e4366ca 100755
--- a/app/Controllers/EmpDataServiceController.php
+++ b/app/Controllers/EmpDataServiceController.php
@@ -751,11 +751,15 @@ class EmpDataServiceController extends BaseController
public function generateExcelForDeletion($export_data)
- {
+ {
+ // dd($export_data);
+
$ids = [];
$objects = $this->employeePolicyModel->getDeletionEmployeeDataForExportExcel($export_data);
+ // dd($objects);
+
$totals = 0;
foreach ($objects as $obj) {
$ids[] = $obj->endorsement_primarykey;
@@ -2932,6 +2936,14 @@ class EmpDataServiceController extends BaseController
$batch_code = $file['batch_code'];
$user_id = $file['created_by'];
+ $ref_data = [
+ 'client_id' => $client_id,
+ 'client_policy_id' => $client_policy_id,
+ 'client_branch_id' => $client_branch_id,
+ 'insurer_or_tpa' => $file['insurer_or_tpa'],
+ 'event_type' => $file['event_type'],
+ ];
+
$file_name_with_path = WRITEPATH . "/uploads/import_excel/" . $file['file_name'];
@@ -2963,72 +2975,8 @@ class EmpDataServiceController extends BaseController
}
}
- $db = \Config\Database::connect();
-
- $sql = "
- SELECT DISTINCT
- a.id as endorsement_primarykey,
- a.group_key,
- employee_polices.id as primaryKey,
- employees.name AS emp_name,
- employees.emp_code AS emp_code,
- employees.dob AS emp_dob,
- employees.gender AS emp_gender,
- employees.relationship AS emp_relationship,
- 'Has Define' as emp_type,
-
- employee_polices.basic_cover_si,
- employee_polices.uhid as risk_id,
- employee_polices.policy_end_date,
- employee_polices.rata_premimum as premium,
-
-
- deletiondata.empstatus,
- deletiondata.changeevent,
- deletiondata.dateofexit,
- deletiondata.reasonforexit,
- deletiondata.status,
-
- DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) AS no_of_days,
- ROUND((employee_polices.rata_premimum * DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit)) / 365, 2) AS pro_rata_premium,
- ROUND(((employee_polices.rata_premimum * DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit)) / 365) * 0.18, 2) AS gst,
- ROUND(((employee_polices.rata_premimum * DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit)) / 365) + (((employee_polices.rata_premimum * DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit)) / 365) * 0.18), 2) AS total
- FROM
- emp_endorsement a
- LEFT JOIN
- employees ON a.emp_code = employees.emp_code and a.pk = employees.id
- LEFT JOIN
- employee_polices ON employees.id = employee_polices.employee_id
-
- LEFT JOIN(
-
- select aa.emp_code, aa.new_value as 'empstatus', bb.new_value as 'changeevent', cc.new_value as 'dateofexit', dd.new_value as 'reasonforexit', ee.new_value as 'status' from
-
- ( SELECT a1.emp_code, a1.field_name, a1.new_value from emp_endorsement as a1 where a1.field_name = 'emp_status') aa
- left join
- ( SELECT b1.emp_code, b1.field_name, b1.new_value from emp_endorsement as b1 where b1.field_name = 'change_event') bb on aa.emp_code = bb.emp_code
- left join
- ( SELECT c1.emp_code, c1.field_name, c1.new_value from emp_endorsement as c1 where c1.field_name = 'date_of_exit') cc on aa.emp_code = cc.emp_code
- left join
- ( SELECT d1.emp_code, d1.field_name, d1.new_value from emp_endorsement as d1 where d1.field_name = 'reason_for_exit') dd on aa.emp_code = dd.emp_code
- left JOIN
- ( SELECT e1.emp_code, e1.field_name, e1.new_value from emp_endorsement as e1 where e1.field_name = 'status') ee on aa.emp_code = ee.emp_code
-
- ) as deletiondata on a.emp_code = deletiondata.emp_code
-
- WHERE employee_polices.client_policy_id = '$client_policy_id'
- AND employees.client_branch_id = '$client_branch_id'
- AND a.actions = 'd'
- AND employee_polices.is_active = 1
- AND employee_polices.status = 'active'
- AND employees.is_active = 1
- AND employees.emp_status = 'active'
- AND (a.endorsement_id IS NULL OR a.endorsement_id = '')
- group by group_key
- ";
-
- $query = $db->query($sql);
- $endorsement_data = $query->getResultArray();
+ $objects = $this->employeePolicyModel->getDeletionEmployeeDataForExportExcel($ref_data, 1);
+ $endorsement_data = $objects;
// dd($endorsement_data);
diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php
index 75893afd..7721b203 100755
--- a/app/Controllers/EmployeeController.php
+++ b/app/Controllers/EmployeeController.php
@@ -711,16 +711,25 @@ class EmployeeController extends AdminController
public function enrollmentClientList()
{
$data = [];
- $client_list = $this->clientModel->findAll();
- $branch_list = $this->clientBranchModel->findAll();
+ $client_list = $this->clientModel->where('clients.is_active', 1)->findAll();
+ $branch_list = $this->clientBranchModel->where('client_branch.is_active', 1)->findAll();
+ $policy_list = $this->clientPolicyModel
+ ->select('client_policy.*, policy_type.policy_type')
+ ->join('policy_type', 'client_policy.policy_type_id = policy_type.id')
+ ->where('client_policy.is_active', 1)
+ ->findAll();
+
$data['client_list'] = $client_list;
$data['branch_list'] = $branch_list;
+ $data['policy_list'] = $policy_list;
// Get session data if available
$data['selected_client_id'] = session()->get('client_id');
$data['selected_branch_id'] = session()->get('branch_id');
$data['selected_type'] = session()->get('type');
+ // dd($data);
+
$this->myLogger->logme('error', 'list called');
return $this->loadLayout('enrollment_list', $data);
@@ -1753,9 +1762,11 @@ class EmployeeController extends AdminController
public function update_emp_data()
{
$data = $this->request->getPost();
-
- $data['dob'] = date('Y-m-d', strtotime($data['dob']));
-
+ // print_rr($data);
+ // $data['dob'] = date('Y-m-d', strtotime($data['dob']));
+ $data['dob'] = change_date_format($data['dob'], 'd/m/Y', 'Y-m-d');
+ // print_rr($data); die;
+
// Fetch current employee data
$employee_data = $this->employeeModel->where('id', $data['employee_primary_id'])->first();
@@ -1964,5 +1975,50 @@ class EmployeeController extends AdminController
return redirect()->back()->with('error', 'Log file not found.');
}
+ public function exportToExceltpadata()
+ {
+ // Create a new Spreadsheet
+ $spreadsheet = new Spreadsheet();
+ $sheet = $spreadsheet->getActiveSheet();
+
+ // Header row
+ $headers = [
+ 'TPA_NAME', 'SHORT_NAME', 'TPA_BRANCH_NAME', 'TPA_BRANCH_CODE',
+ 'TPA_CONTACT_PERSON_NAME', 'TPA_CONTACT_PERSON_EMAIL', 'TPA_CONTACT_PERSON_MOBILE',
+ 'TPA_CONTACT_PERSON_DESIGNATION', 'IS_DELETED'
+ ];
+ $sheet->fromArray($headers, NULL, 'A1');
+
+ // Data rows
+ $data = [
+ ["ICICI Lombard Health Care", "IL Health care", "Chennai", "997133", "Heena", "dharanisri@jubiliant.in", "9043955294", "General Manager", "YES"],
+ ["ICICI Lombard Health Care", "IL Health care", "Chennai", "997133", "Mahammad shireen", "mahammad.shireen@icicilombard.com", "8655420732", "Claims head", "NO"],
+ ["Medi Assist Insurance TPA Private Limited", "Medi Assist", "Chennai", "YA0000000348", "Ragavi", "dharanisri@jubiliant.in", "9043955294", "Senior Manager", "YES"],
+ ["Medi Assist Insurance TPA Private Limited", "Medi Assist", "Chennai", "YA0000000348", "Vijayalakshmi", "vijayalakshmi.c@mediassist.in", "7795542162", "Senior Executive | Account Management", "NO"],
+ ["Vidal Health Insurance TPA", "Vidal", "Chennai", "YA0000000349", "vijalakshmi", "vijayalakshmi.c@mediassist.in", "7795542162", "Senior Executive", "NO"],
+ ["Vidal Health Insurance TPA", "Vidal", "Chennai", "YA0000000349", "M.Pushparaj", "pushparaj.moorthy@vidalhealth.com", "8939634456", "Executive", "NO"],
+ ["Digit in-House", "Digit in-House", "Go Digit General Insurance Ltd", "1", "sathish", "sathish.n@vidalhealth.com", "7823913800", "Senior Executive", "NO"],
+ ["Digit in-House", "Digit in-House", "Go Digit General Insurance Ltd", "1", "Mr. Pavan", "TK.Pavankumar@godigit.com", "8754490492", "Strategic Partnerships", "NO"],
+ ["Aditya Birla Health Insurance Co. Limited", "ABHI", "Chennai", "O1", "sathish", "sathish.n@vidalhealth.com", "7823913800", "Senior Executive", "NO"],
+ ["Aditya Birla Health Insurance Co. Limited", "ABHI", "Chennai", "O1", "Jhonson Kj", "jhonson.kj@adityabirlacapital.com", "9900729513", "Executive", "NO"],
+ ["Aditya Birla Health Insurance Co. Limited", "ABHI", "Chennai", "01", "Jhonson Kj", "jhonson.kj@adityabirlacapital.com", "9900729513", "Executive", "NO"],
+ ["R Care Health", "R Care", "Chennai", "01", "Jeevanadam", "Jeevanandam.Kumaran@relianceada.com", "8825982053", "Executive", "NO"],
+ ["IFFCO-TOKIO GENERAL INSURANCE CO. LTD", "ITGI", "Chennai", "01", "Anjali", "Anjali.K@ext.iffcotokio.co.in", "6374270165", "Senior Executive", "NO"],
+ ["Star Health and Allied Insurance", "STAR", "Chennai", "110000", "Mr. Vijay Baskar", "vijayabhaskar.m@starhealth.in", "9840905286", "Area Manager", "NO"],
+ ];
+ $sheet->fromArray($data, NULL, 'A2');
+
+ // Save the file
+ $filename = 'TPA_Data.xlsx';
+ $writer = new Xlsx($spreadsheet);
+
+ // Set headers for download
+ header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
+ header('Content-Disposition: attachment; filename="' . $filename . '"');
+ header('Cache-Control: max-age=0');
+
+ $writer->save('php://output');
+ exit;
+ }
}
diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php
index 92bc9d15..5742b0dd 100755
--- a/app/Controllers/EmployeeRestController.php
+++ b/app/Controllers/EmployeeRestController.php
@@ -28,6 +28,7 @@ use App\Models\UserModel;
use App\Models\FEContentModel;
use App\Models\AddImgModel;
use App\Models\ClientBranchModel;
+use App\Models\AuditHistoryModel;
use App\Controllers\Jobs ;
@@ -71,6 +72,7 @@ class EmployeeRestController extends AdminController
protected $feContentModel;
protected $addImgModel;
protected $clientBranchModel;
+ protected $auditHistoryModel;
public function __construct()
@@ -94,6 +96,7 @@ class EmployeeRestController extends AdminController
$this->feContentModel = new FEContentModel();
$this->addImgModel = new AddImgModel();
$this->clientBranchModel = new ClientBranchModel();
+ $this->auditHistoryModel = new AuditHistoryModel();
}
@@ -220,8 +223,6 @@ class EmployeeRestController extends AdminController
{
try {
$data = $this->request->getJSON();
-
-
if ($data) {
$Count = 0;
@@ -245,13 +246,11 @@ class EmployeeRestController extends AdminController
$item->dob = $this->convertDateFormatYMD($item->dob);
$item->emp_status = 'draft';
-
$employee = $this->employeeModel->insert($item);
if ($employee) {
$Count++;
}
-
}
}
@@ -260,21 +259,15 @@ class EmployeeRestController extends AdminController
if(isset($data[0]->id))
{
-
- $this->createEmployeePolicyData($data[0]->id , $data[0]->emp_code , $data[0]->client_id , $data[0]->client_policy_id , $data[0]->basic_cover_si);
-
- }else{
-
- $this->createEmployeePolicyData($employee , $data[0]->emp_code , $data[0]->client_id , $data[0]->client_policy_id , $data[0]->basic_cover_si);
-
+ $this->createEmployeePolicyData($data[0]->id , $data[0]->emp_code , $data[0]->client_id , $data[0]->client_policy_id , $data[0]->basic_cover_si);
+ }else
+ {
+ $payable_employee = $this->getEmployeePayableValue($data[0]->client_policy_id,$data[0]->relationship);
+ $this->createEmployeePolicyData($employee , $data[0]->emp_code , $data[0]->client_id , $data[0]->client_policy_id , $data[0]->basic_cover_si , $payable_employee);
}
-
-
-
$this->updatePremiumAmount($data[0]->client_policy_id , $data[0]->emp_code , $data[0]->client_branch_id);
-
$result = [];
return $this->respond(['status' => 'success','code' => 200,'data' => $result], 200);
} else {
@@ -288,7 +281,37 @@ class EmployeeRestController extends AdminController
}
- public function createEmployeePolicyData($employee_id,$emp_code,$client_id,$client_policy_id,$basic_cover_si = null)
+ public function getEmployeePayableValue($client_policy_id,$relationship)
+ {
+ $terms = $this->clientPolicyModel->where('id',$client_policy_id)->get()->getRow()->policy_terms;
+
+ if(isset(json_decode($terms)->is_payable_employee))
+ {
+ $is_payable_obj = json_decode($terms)->is_payable_employee;
+
+ if ($relationship === 'Mother' || $relationship === 'Father' || $relationship === 'Father in Law' || $relationship === 'Mother in Law')
+ {
+ return $is_payable_obj->elders;
+ }
+ else if($relationship === 'Son' || $relationship === 'Daughter')
+ {
+ return $is_payable_obj->childern;
+ }
+ else if($relationship === 'Spouse')
+ {
+ return $is_payable_obj->spouse;
+ }
+
+ }else{
+ return 0;
+ }
+
+
+
+
+ }
+
+ public function createEmployeePolicyData($employee_id,$emp_code,$client_id,$client_policy_id,$basic_cover_si = null,$payable_employee = 0)
{
if($basic_cover_si == null)
@@ -314,6 +337,7 @@ class EmployeeRestController extends AdminController
$data['employee_id']= $employee_id;
$data['client_policy_id']= $client_policy_id;
$data['basic_cover_si']= $basic_cover_si;
+ $data['payable_employee']= $payable_employee;
$data['status']= 'draft';
$data['date_coverage'] = $this->getEmployeeCoverageDate($emp_code, $client_policy_id);
@@ -687,7 +711,7 @@ class EmployeeRestController extends AdminController
$notification = $this->notificationModel->where('client_id',$client_id)->where('template_name','member_welcome_mail')->first();
- $jwt = $this->request->getHeader('Authorization');
+ $jwt = $this->request->getHeaderLine('Authorization');
$jwtParts = explode(' ', $jwt);
$token = $jwtParts[2];
@@ -697,7 +721,6 @@ class EmployeeRestController extends AdminController
// 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) {
@@ -934,11 +957,13 @@ class EmployeeRestController extends AdminController
}
}
}
+
$emp_policy_data =[
'employee_id'=>$emp_id,
'client_policy_id'=>$policy_id,
'status'=> 'draft',
'date_coverage' => $date_coverage,
+ 'payable_employee' => check_pay_by_employee_or_company($client_policy['policy_terms'], $dataToInsert[$a]['relationship']),
'basic_cover_si'=>isset($basic_cover_si[$a]) ? $basic_cover_si[$a] : null
];
@@ -1133,7 +1158,7 @@ class EmployeeRestController extends AdminController
// Generate Notes string based on familyFloates terms
$array->notes = $this->FloterNotesConvertion($familyFloates);
- if($getSlabAndGridData['slab_rates'][0]['premium_type'] == 1)
+ if($getSlabAndGridData['slab_rates'][0]['premium_type'] == 1 || $getSlabAndGridData['slab_rates'][0]['premium_type'] == 3)
{
$array->floter_text_heading = 'Floater Sum Insured';
$array->floter_text_description = 'This is a floater sum insured. A floater is a type of sum insured that provides coverage to more than one member ot a family at the same time. Simply put, its a single insurance cover for the entire family.';
@@ -1150,6 +1175,9 @@ class EmployeeRestController extends AdminController
$floters = $this->FloterConvertion($familyFloates);
$data = [];
+ $dependent_and_si_value = 0;
+ $dependent_and_si_premium_value = 0;
+ $dependent_and_si_gst_value = 0;
foreach ($floters as $familyFloatesValue) {
$dependent = preg_replace('/\d/', '', $familyFloatesValue);
@@ -1157,6 +1185,9 @@ class EmployeeRestController extends AdminController
foreach ($empData as $key => $value) {
if ($value['family_floater_key'] === $dependent) {
$employee_policy = $this->employeePolicyModel->where('employee_id',$value['id'])->where('client_policy_id',$array->ClientPolicyId)->where('is_active', 1 )->get()->getRow();
+ if(isset($employee_policy->basic_cover_si)){ $dependent_and_si_value = ($dependent_and_si_value == 0) ? $employee_policy->basic_cover_si : $dependent_and_si_value; }
+ if(isset($employee_policy->rata_premimum)){ $dependent_and_si_premium_value = $dependent_and_si_premium_value + $employee_policy->rata_premimum;}
+ if(isset($employee_policy->gst)){ $dependent_and_si_gst_value = $dependent_and_si_gst_value + $employee_policy->gst;}
$temp['is_value_exist'] = true;
$temp['data']['family_floater_key'] = $familyFloatesValue;
@@ -1212,7 +1243,6 @@ class EmployeeRestController extends AdminController
}
-
// Add family floter buttons placement data for FE validation
if(count($floters)){
foreach ($floters as $familyFloatesValue) {
@@ -1233,6 +1263,9 @@ class EmployeeRestController extends AdminController
$array->mapped_family_floaters = $data;
$array->type = "GMC";
+ $array->family_floaters_of_dependent_and_si_value = $dependent_and_si_value > 0 ? $dependent_and_si_value : 0;
+ $array->family_floaters_of_dependent_and_si_premium_value = $dependent_and_si_premium_value > 0 ? round($dependent_and_si_premium_value) : 0;
+ $array->family_floaters_of_dependent_and_gst_value = $dependent_and_si_gst_value > 0 ? round($dependent_and_si_gst_value) : 0;
$checkGmcParentsPolicyExist = $this->clientPolicyModel->select('client_policy.id as ClientPolicyId , client_policy.client_id as ClientId, client_policy.policy_type_id as policy_type_id, policy_type.long_name as Policy_Name , client_policy.is_addon as is_addon , client_policy.open_for_enrollment as OpenForEnrollment , client_policy.inception_type as inception_type , client_policy.policy_terms as Policy_Terms')
->join('policy_type', 'client_policy.policy_type_id = policy_type.id', 'left')
@@ -1325,7 +1358,7 @@ class EmployeeRestController extends AdminController
// Generate Notes string based on familyFloates terms
$array->notes = $this->FloterNotesConvertion($familyFloates);
- if($getSlabAndGridData['slab_rates'][0]['premium_type'] == 1)
+ if($getSlabAndGridData['slab_rates'][0]['premium_type'] == 1 || $getSlabAndGridData['slab_rates'][0]['premium_type'] == 3)
{
$array->floter_text_heading = 'Floater Sum Insured';
$array->floter_text_description = 'This is a floater sum insured. A floater is a type of sum insured that provides coverage to more than one member ot a family at the same time. Simply put, its a single insurance cover for the entire family.';
@@ -1345,15 +1378,20 @@ class EmployeeRestController extends AdminController
$floters = $this->FloterConvertion($familyFloates);
$data = [];
+ $dependent_and_si_value = 0;
+ $dependent_and_si_premium_value = 0;
+ $dependent_and_si_gst_value = 0;
foreach ($floters as $familyFloatesValue) {
$dependent = preg_replace('/\d/', '', $familyFloatesValue);
-
if(count($empData)){
foreach ($empData as $key => $value) {
if ($value['family_floater_key'] === $dependent) {
$employee_policy = $this->employeePolicyModel->where('employee_id',$value['id'])->where('client_policy_id',$array->ClientPolicyId)->where('is_active', 1 )->get()->getRow();
- // dd( $employee_policy);
+ if(isset($employee_policy->basic_cover_si)){ $dependent_and_si_value = ($dependent_and_si_value == 0) ? $employee_policy->basic_cover_si : $dependent_and_si_value; }
+ if(isset($employee_policy->rata_premimum)){ $dependent_and_si_premium_value = $dependent_and_si_premium_value + $employee_policy->rata_premimum;}
+ if(isset($employee_policy->gst)){ $dependent_and_si_gst_value = $dependent_and_si_gst_value + $employee_policy->gst;}
+
$temp['is_value_exist'] = true;
$temp['data']['family_floater_key'] = $familyFloatesValue;
$temp['data']['employee_id'] = $value['id'];
@@ -1422,6 +1460,9 @@ class EmployeeRestController extends AdminController
$array->mapped_family_floaters = $data;
$array->type = "GMC - Parents";
+ $array->family_floaters_of_dependent_and_si_value = $dependent_and_si_value > 0 ? $dependent_and_si_value : 0;
+ $array->family_floaters_of_dependent_and_si_premium_value = $dependent_and_si_premium_value > 0 ? round($dependent_and_si_premium_value) : 0;
+ $array->family_floaters_of_dependent_and_gst_value = $dependent_and_si_gst_value > 0 ? round($dependent_and_si_gst_value) : 0;
return $array;
@@ -1539,7 +1580,7 @@ class EmployeeRestController extends AdminController
$string = ucwords($string);
$result .= ' + '.$string;
}else if($value != 0 && $key ==='self') {
- $result = 'Allowed memebrs Self ';
+ $result = 'Allowed members Self ';
}else if($value != 0 && $key ==='childrens') {
if($value > 1){ $result .= ' + '.$value.' Children'; }else{ $result .= ' + '.$value.' Child'; }
}else if($value != 0 && $key ==='elders_count') {
@@ -1558,7 +1599,7 @@ class EmployeeRestController extends AdminController
if($first_two_chars == " +"){
$modified_string = substr($result, 3);
- return "Allowed memebrs ".$modified_string;
+ return "Allowed members ".$modified_string;
}else{
return $result;
}
@@ -1656,7 +1697,7 @@ class EmployeeRestController extends AdminController
$responce['OpenForEnrollment'] = $array['open_for_enrollment'];
$responce['policy_terms'] = $decodedArray;
$responce['policy_type_id'] = $array['policy_type_id'];
- $responce['is_member_modify_allowed'] = $array['is_member_modify_allowed'];
+ //$responce['is_member_modify_allowed'] = $array['is_member_modify_allowed'];
$responce['disclaimer'] = $array['disclaimer'];
$tpaArray = $this->employeeModel->select('employees.name as name , employee_polices.tpa_id as tpa_id , employee_polices.rand_string as rand_string')
@@ -1680,7 +1721,7 @@ class EmployeeRestController extends AdminController
}
if(count($getSlabAndGridData['slab_rates'])){
- if($getSlabAndGridData['slab_rates'][0]['premium_type'] == 1)
+ if($getSlabAndGridData['slab_rates'][0]['premium_type'] == 1 || $getSlabAndGridData['slab_rates'][0]['premium_type'] == 3)
{
$responce['floter_text_heading'] = 'Floater Sum Insured';
}else{
@@ -1815,8 +1856,8 @@ class EmployeeRestController extends AdminController
$responce['family_floaters_of_dependent_and_si_array'] = $data;
$responce['family_floaters_of_dependent_and_si_value'] = $dependent_and_si_value > 0 ? $dependent_and_si_value : 0;
- $responce['family_floaters_of_dependent_and_si_premium_value'] = $dependent_and_si_premium_value > 0 ? $dependent_and_si_premium_value : 0;
- $responce['family_floaters_of_dependent_and_gst_value'] = $dependent_and_si_gst_value > 0 ? $dependent_and_si_gst_value : 0;
+ $responce['family_floaters_of_dependent_and_si_premium_value'] = $dependent_and_si_premium_value > 0 ? round($dependent_and_si_premium_value) : 0;
+ $responce['family_floaters_of_dependent_and_gst_value'] = $dependent_and_si_gst_value > 0 ? round($dependent_and_si_gst_value) : 0;
@@ -1874,7 +1915,7 @@ class EmployeeRestController extends AdminController
$responce['family_floaters_of_only_si_array'] = $only_si_array;
$responce['family_floaters_of_only_si_value'] = $only_si_value;
- $responce['family_floaters_of_only_si_premium_value'] = $only_si_premium_value;
+ $responce['family_floaters_of_only_si_premium_value'] = round($only_si_premium_value);
$responce['family_floaters_of_only_si_gst_value'] = $only_si_gst_value;
@@ -1927,8 +1968,8 @@ class EmployeeRestController extends AdminController
$responce['family_floaters_of_only_si_array'] = $only_si_array;
$responce['family_floaters_of_only_si_value'] = $only_si_value;
- $responce['family_floaters_of_only_si_premium_value'] = $only_si_premium_value;
- $responce['family_floaters_of_only_si_gst_value'] = $only_si_gst_value;
+ $responce['family_floaters_of_only_si_premium_value'] = round($only_si_premium_value);
+ $responce['family_floaters_of_only_si_gst_value'] = round($only_si_gst_value);
if($this->request->getGet('policy') == 'GMC-SI-PARENT-TOPUP'){
@@ -1961,13 +2002,6 @@ class EmployeeRestController extends AdminController
$emp_code = $postData['emp_code'];
$client_id = $postData['client_id'];
- $this->employeeModel->where('emp_code', $emp_code )
- ->where('client_id', $client_id )
- ->where('is_active', 1 )
- ->where('emp_status', 'draft' )
- ->set(array('emp_status'=>'enrolled'))
- ->update();
-
$empData = $this->employeeModel->where('emp_code', $emp_code )->where('client_id', $client_id ) ->where('is_active', 1 )->findAll();
//for mail common parameter
@@ -2000,6 +2034,16 @@ class EmployeeRestController extends AdminController
}
+
+ //update Employee table
+ $this->employeeModel->where('emp_code', $emp_code)->where('client_id', $client_id)->where('is_active', 1)
+ ->groupStart()
+ ->where('emp_status', 'draft')
+ ->orWhere('emp_status', 'enrolled')
+ ->groupEnd()
+ ->set(['emp_status' => 'enrolled'])
+ ->update();
+
$notification = $this->notificationModel->where('client_id' ,$client_id)->where('template_name', 'member_review_and_summary_mail')->first();
@@ -2065,11 +2109,21 @@ class EmployeeRestController extends AdminController
// retun array
public function calculatePremium($clientPolicyId = null , $empCode = null, $default_si = null , $client_branch_id = null)//family level
{
+ // dd($clientPolicyId, $empCode, $default_si, $client_branch_id);
helper('excel_util_helper');
- $client_policy_id = $this->request->getVar('client_policy_id') ?? $clientPolicyId;
- $emp_code = $this->request->getVar('emp_code') ?? $empCode;
- $default_si = $this->request->getVar('si') ?? $default_si;// si amt which choosed in add on policy
- $client_branch_id = $this->request->getVar('client_branch_id') ?? $client_branch_id;
+
+ if($this->request){ //
+ $client_policy_id = $this->request->getVar('client_policy_id') ?? $clientPolicyId;
+ $emp_code = $this->request->getVar('emp_code') ?? $empCode;
+ $default_si = $this->request->getVar('si') ?? $default_si;// si amt which choosed in add on policy
+ $client_branch_id = $this->request->getVar('client_branch_id') ?? $client_branch_id;
+ }else{
+ //Cli and enrollment
+ $client_policy_id = $clientPolicyId;
+ $emp_code = $empCode;
+ $default_si = $default_si;// si amt which choosed in add on policy
+ $client_branch_id =$client_branch_id;
+ }
// dd($client_policy_id);
@@ -2350,7 +2404,7 @@ class EmployeeRestController extends AdminController
function getEmployeeActiveOrInactivePolicy()
{
if($this->request->getGet('type') == 'Active'){ $policy_status = 1; }else{ $policy_status = 0; }
- $ClientPolicyData = $this->clientPolicyModel->select('client_policy.* , policy_type.policy_type as policy_type,insurers.name as insurer_name,tpa.name as tpa_name')
+ $ClientPolicyData = $this->clientPolicyModel->select('client_policy.* , policy_type.policy_type as policy_type,insurers.name as insurer_name,tpa.name as tpa_name,tpa.network_hospitals as network_hospitals_url')
->join('insurers', 'client_policy.insurer_id = insurers.id', 'left')
->join('tpa', 'client_policy.tpa_id = tpa.id', 'left')
->join('policy_type', 'client_policy.policy_type_id = policy_type.id', 'left')
@@ -2400,6 +2454,7 @@ class EmployeeRestController extends AdminController
$data['policy_no'] = $ClientPolicyValue['policy_no'];
$data['insurer_name'] = $ClientPolicyValue['insurer_name'];
$data['tpa_name'] = $ClientPolicyValue['tpa_name'];
+ $data['network_hospitals_url'] = $ClientPolicyValue['network_hospitals_url'];
$data['policy_start_date'] = $this->convertDateFormatDisplay($ClientPolicyValue['policy_start_date']);
$data['policy_end_date'] = $this->convertDateFormatDisplay($ClientPolicyValue['policy_end_date']);
// $data['policy_terms'] = $terms;
@@ -2429,7 +2484,7 @@ class EmployeeRestController extends AdminController
$si_gst_value = 0;
foreach ($employee_policy as $key => $value) {
- if(isset($value['basic_cover_si'])){ $si_value = $value['basic_cover_si']; }
+ if(isset($value['basic_cover_si'])){ $si_value = ($si_value == 0) ? $value['basic_cover_si'] : $si_value; }
if(isset($value['premium'])){ $si_premium_value = $si_premium_value + $value['premium'];}
if(isset($value['gst'])){ $si_gst_value = $si_gst_value + $value['gst'];}
}
@@ -2443,8 +2498,8 @@ class EmployeeRestController extends AdminController
$data['si_value'] = $si_value;
- $data['si_premium_value'] = ($ClientPolicyValue['policy_type_id'] == 1 || $ClientPolicyValue['policy_type_id'] == 2) ? 0 : $si_premium_value;
- $data['si_gst_value'] = ($ClientPolicyValue['policy_type_id'] == 1 || $ClientPolicyValue['policy_type_id'] == 2) ? 0 : $si_gst_value;
+ $data['si_premium_value'] = ($ClientPolicyValue['policy_type_id'] == 1 || $ClientPolicyValue['policy_type_id'] == 2) ? 0 : round($si_premium_value);
+ $data['si_gst_value'] = ($ClientPolicyValue['policy_type_id'] == 1 || $ClientPolicyValue['policy_type_id'] == 2) ? 0 : round($si_gst_value);
$data['EmployeePolicy'] = $employee_policy;
array_push($result, $data);
@@ -2463,6 +2518,8 @@ class EmployeeRestController extends AdminController
function policyTermsFiter($terms , $type)
{
+
+
$gpa = [
"sumInsured2" => "Sum Insured",
@@ -2492,18 +2549,25 @@ class EmployeeRestController extends AdminController
];
$gmc = [
- "sum_insured" => "Sum Insured",
+
"waiverofpreexistingdiseases" => "Waiver of Pre-existing Diseases",
- "maternitycoverage" => "Maternity Coverage",
- "babyday1cover" => "Baby Day 1 Cover",
- "9monthwaitingperiodwaived" => "9-month waiting Period �waived",
- "coverfromthedateofjoining" => "Cover from the date of Joining",
"waiverof1,2,3&4thyearexclusions" => "Waiver of 1, 2, 3 & 4th year Exclusions",
"waiverof30dayswaitingperiod" => "Waiver of 30 days waiting period",
+ "9monthwaitingperiodwaived" => "9-month waiting Period waived",
+ "twindelivery" => "Twin Delivery",
+ "maternitycoverage" => "Maternity Coverage",
+ "preandpostnatal" => "Pre and Post natal",
"prehospitalizationcover" => "Pre Hospitalization Cover",
- "copayzonewisecopay" => "Co-Pay/Zone wise Co Pay",
+ "posthospitalizationcover" => "Post Hospitalization Cover ",
+ "congenitaldiseasesinternal" => "Congenital Diseases - Internal ",
+ "congenitaldiseasesexternal" => "Congenital Diseases - External ",
"roomrentlimit" => "Room Rent Limit",
+ "proportionatedeductionclause" => "Proportionate Deduction Clause",
+ "ayudhtreatmentcover" => "AYUSH treatment covered",
+ "lasiksurgery" => "Lasik Surgery",
+ "cataract" => "Cataract",
"ailmentcapping" => "Ailment capping",
+ "moderntreatmentsasperirdai" => "Modern Treatment "
];
@@ -2512,15 +2576,51 @@ class EmployeeRestController extends AdminController
if($type == 'gpa'){
foreach ($gpa as $key => $value) {
if(isset($terms->$key))
- $finalarray[$value] = $terms->$key;
+ {
+ if($terms->$key == 1)
+ {
+ $termsValue = 'Yes';
+ }else if($terms->$key == 0)
+ {
+ $termsValue = 'No';
+ }else
+ {
+ $termsValue = $terms->$key;
+ }
+ $finalarray[$value] = $termsValue;
+ }
+ }
+ if(is_array($terms->gpa_special_condition_label) && is_array($terms->gpa_special_condition_input)){
+ for ($i=0; $i < count($terms->gpa_special_condition_label); $i++) {
+ $finalarray[$terms->gpa_special_condition_label[$i]] = $terms->gpa_special_condition_input[$i];
+ }
}
}else{
foreach ($gmc as $key => $value) {
if(isset($terms->$key))
- $finalarray[$value] = $terms->$key;
+ {
+ if($terms->$key == 1)
+ {
+ $termsValue = 'Yes';
+ }else if($terms->$key == 0)
+ {
+ $termsValue = 'No';
+ }else
+ {
+ $termsValue = $terms->$key;
+ }
+ $finalarray[$value] = $termsValue;
+ }
+ }
+ if(is_array($terms->special_condition_label) && is_array($terms->special_condition_input)){
+ for ($i=0; $i < count($terms->special_condition_label); $i++) {
+ $finalarray[$terms->special_condition_label[$i]] = $terms->special_condition_input[$i];
+ }
}
}
-
+
+
+
return $finalarray;
@@ -2585,17 +2685,24 @@ class EmployeeRestController extends AdminController
public function storeFireBase()
{
try {
- $json = $this->request->getJSON();
- $firebase_token = $json->firebase_token;
- $mobile = $json->mobile;
+
+ $firebase_token = isset($this->request->getJSON()->firebase_token) ? $this->request->getJSON()->firebase_token : null;
+ $mobile = isset($this->request->getJSON()->mobile) ? $this->request->getJSON()->mobile : null;
+ $email_id = isset($this->request->getJSON()->email_id) ? $this->request->getJSON()->email_id : null;
// Ensure the mobile number is provided
if (empty($mobile)) {
return $this->respond(['status' => 'failed', 'code' => 400, 'message' => 'Mobile number is required'], 400);
}
- // Fetch employee by mobile number
- $employee = $this->employeeModel->where('mobile', $mobile)->first();
+ // Fetch employee
+ if (isset($mobile))
+ {
+ $employee = $this->employeeModel->where('mobile', $mobile)->where('relationship', 'self')->where('is_active', 1)->first();
+ } else {
+ $employee = $this->employeeModel->where('email_corporate', $email_id)->where('relationship', 'self')->where('is_active', 1)->first();
+ }
+
if ($employee) {
// Check if firebase_token is provided
@@ -2665,59 +2772,223 @@ class EmployeeRestController extends AdminController
// }
- public function getFamilyPolicyDetails()
+ public function getBackToEnrolledDetails()
{
// Get query parameters
$empCode = $this->request->getGet('emp_code');
$clientId = $this->request->getGet('client_id');
$clientBranchId = $this->request->getGet('client_branch_id');
+
- if (!$empCode || !$clientId || !$clientBranchId) {
- return $this->fail("emp_code, client_id, and client_branch_id are required parameters.");
- }
+ if (!$empCode || !$clientId || !$clientBranchId) { return $this->fail("emp_code, client_id, and client_branch_id are required parameters."); }
- // Fetch employee family details
- $employees = $this->employeeModel->select('id,emp_code,name,relationship,dob,emp_status,is_addon_value')->where([
- 'emp_code' => $empCode,
- 'client_id' => $clientId,
- 'client_branch_id' => $clientBranchId,
- 'is_active' => 1
- ])->findAll();
+ //Fetch active employee details
+ $employees = $this->employeeModel->select('id,emp_code,name,relationship,dob,emp_status,is_addon_value,created_at,updated_at')
+ ->where([
+ 'emp_code' => $empCode,
+ 'client_id' => $clientId,
+ 'client_branch_id' => $clientBranchId,
+ 'is_active' => 1
+ ])
+ ->findAll();
- if (empty($employees)) {
- return $this->failNotFound("No employees found for the provided parameters.");
- }
+ //Find status of self
+ $selfEmployee = array_filter($employees, function($employee) { return $employee['relationship'] === 'Self'; });
+ $data['self_status'] = !empty($selfEmployee) ? array_values($selfEmployee)[0]['emp_status'] : null;
+ $data['self_enrolled_time'] = !empty($selfEmployee) ? array_values($selfEmployee)[0]['updated_at'] : null;
+ $data['self_employee_id'] = !empty($selfEmployee) ? array_values($selfEmployee)[0]['id'] : null;
- // Collect employee IDs
+
+ //Fetch employee policy details
$employeeIds = array_column($employees, 'id');
-
- // Fetch policies related to the employee IDs
$policies = $this->employeePolicyModel->whereIn('employee_id', $employeeIds)->where('is_active',1)->findAll();
- if (empty($policies)) {
- return $this->failNotFound("No policies found for the provided employees.");
+
+ //Find the stage of enrolment process
+ $employeeStatuses = array_column($employees, 'emp_status');
+ $employeePolicyStatuses = array_column($policies, 'status');
+ $uniqueStatuses = array_unique(array_merge($employeeStatuses, $employeePolicyStatuses));
+
+ if(count($uniqueStatuses) > 1){ $enrolmentStagekey = 1; }else{ if($uniqueStatuses[0] == 'draft'){ $enrolmentStagekey = 0; }else{ $enrolmentStagekey = 2; } }
+
+ $enrolmentStage = ['Draft Only','Intermittent Enrollment','Successful Enrollment'];
+ $data['enrolment_stage'] = $enrolmentStage[$enrolmentStagekey];
+
+
+
+ $data['revert_employee_data'] = [];
+ $data['revert_employee_policy_data'] = [];
+ if($enrolmentStagekey == 1)
+ {
+ //Find active employee history
+ $empIdsWithoutSelf = $employeeIds;
+ $key = array_search($data['self_employee_id'], $empIdsWithoutSelf);
+ unset($empIdsWithoutSelf[$key]);
+ foreach ($empIdsWithoutSelf as $key => $pk)
+ {
+ $retrivedData = $this->retriveOldData($data['self_enrolled_time'],'employees',$pk);
+ if($retrivedData != false)
+ array_push($data['revert_employee_data'] , $retrivedData);
+ }
+
+ //Find inactive employee history
+ $inActiveEmployees = $this->employeeModel->select('id,emp_code,name,relationship,dob,emp_status,is_addon_value,created_at,updated_at')
+ ->where([
+ 'emp_code' => $empCode,
+ 'client_id' => $clientId,
+ 'client_branch_id' => $clientBranchId,
+ 'is_active' => 0
+ ])
+ ->findAll();
+ $inActiveEmployeeIds = array_column($inActiveEmployees, 'id');
+ foreach ($inActiveEmployeeIds as $key => $pk)
+ {
+ $retrivedData = $this->retriveOldData($data['self_enrolled_time'],'employees',$pk);
+ if($retrivedData != false)
+ array_push($data['revert_employee_data'] , $retrivedData);
+ }
+
+
+ //Merged active and inactive employees , employee_polict history
+ $mergedEmpIds = array_merge($employeeIds,$inActiveEmployeeIds);
+ $empPolicyData = $this->employeePolicyModel->whereIn('employee_id', $mergedEmpIds)->findAll();
+ $employeePolicyIds = array_column($empPolicyData, 'id');
+ foreach ($employeePolicyIds as $key => $pk)
+ {
+ $retrivedData = $this->retriveOldData($data['self_enrolled_time'],'employee_polices',$pk);
+ if($retrivedData != false)
+ array_push($data['revert_employee_policy_data'] , $retrivedData);
+ }
}
- // Structure the response
- $result = [];
+
+ if($this->request->getGet('revert_data') == 1)
+ {
+ //update data back to employee
+ if(count($data['revert_employee_data'])){
+ foreach ($data['revert_employee_data'] as $key => $val)
+ {
+ $this->employeeModel->where('id',$val['id'] )->set($val['data'])->update();
+ }
+ }
+ //update data back to employee policy
+ if(count($data['revert_employee_policy_data'])){
+ foreach ($data['revert_employee_policy_data'] as $key => $val)
+ {
+ $this->employeePolicyModel->where('id',$val['id'] )->set($val['data'])->update();
+ }
+ }
+ //update enrolled status for self
+ if(count($data['revert_employee_data']) || count($data['revert_employee_policy_data'])){
+ $this->employeeModel->where('id',$data['self_employee_id'] )->set(array('emp_status'=>'enrolled'))->update();
+ $data['retrieve_status'] = 'Data revert successfully';
+ }else{
+ $data['retrieve_status'] = 'There is no data to revert';
+ }
+
+ }
+
+
+
+
+
+ // Fetch all policies related to these employees who currently active
+ $current_employee_data = $this->employeeModel->select('id,emp_code,name,relationship,dob,emp_status,is_addon_value,created_at,updated_at')
+ ->where([
+ 'emp_code' => $empCode,
+ 'client_id' => $clientId,
+ 'client_branch_id' => $clientBranchId,
+ 'is_active' => 1
+ ])
+ ->findAll();
+ $Ids = array_column($current_employee_data, 'id');
+ $policies = $this->employeePolicyModel->whereIn('employee_id', $Ids)->where('is_active',1)->findAll();
+ // Group policies by policy_id
+ $groupedPolicies = [];
foreach ($policies as $policy) {
- $policyEmployees = array_filter($employees, function ($emp) use ($policy) {
- return $emp['id'] === $policy['employee_id'];
- });
+ $policyId = $policy['client_policy_id'];
+
+ if (!isset($groupedPolicies[$policyId])) {
+ $groupedPolicies[$policyId] = [
+ 'policy_id' => $policy['id'],
+ 'client_policy_id' => $policy['client_policy_id'],
+ 'uhid' => $policy['uhid'],
+ 'status' => $policy['status'],
+ 'basic_cover_si' => $policy['basic_cover_si'],
+ 'date_coverage' => $policy['date_coverage'],
+ 'policy_end_date' => $policy['policy_end_date'],
+ 'members' => []
+ ];
+ }
- $result[] = [
- 'policy_id' => $policy['id'],
- 'client_policy_id' => $policy['client_policy_id'],
- 'uhid' => $policy['uhid'],
- 'status' => $policy['status'],
- 'basic_cover_si' => $policy['basic_cover_si'],
- 'date_coverage' => $policy['date_coverage'],
- 'policy_end_date' => $policy['policy_end_date'],
- 'members' => array_values($policyEmployees),
- ];
+ // Add member details to the current policy
+ foreach ($current_employee_data as $employee) {
+ if ($employee['id'] === $policy['employee_id']) {
+ $groupedPolicies[$policyId]['members'][] = [
+ 'id' => $employee['id'],
+ 'emp_code' => $employee['emp_code'],
+ 'name' => $employee['name'],
+ 'relationship' => $employee['relationship'],
+ 'dob' => $employee['dob'],
+ 'emp_status' => $employee['emp_status'],
+ 'is_addon_value' => $employee['is_addon_value']
+ ];
+ }
+ }
}
- return $this->respond(['family_policies' => $result]);
+ // Re-index the grouped policies
+ $data['currentPolicies'] = array_values($groupedPolicies);
+
+ return $this->respond(['data' => $data]);
+ }
+
+ public function retriveOldData($self_enrolled_time,$table,$pk)
+ {
+
+ $historyData = $this->auditHistoryModel->where('pk', $pk)->where('table_name',$table)->findAll();
+
+ $beforeEnrolled = [];
+ $afterEnrolled = [];
+ // Split the array
+ foreach ($historyData as $val) {
+ if ($val['created_at'] <= $self_enrolled_time) { $beforeEnrolled[] = $val; } else { $afterEnrolled[] = $val; }
+ }
+
+ if(count($beforeEnrolled) && count($afterEnrolled)){ //After enrolment edited some of the data
+
+ $temp['table'] = $table;
+ $temp['id'] = $pk;
+ // Extract earliest `old_value` for each `field_name`
+ $originalValues = [];
+ foreach ($afterEnrolled as $entry) {
+ $field = $entry['field_name'];
+ // If the field is not already in originalValues , update it
+ if (!isset($originalValues[$field])) {
+ $originalValues[$field] = $entry['old_value'];
+ }
+ }
+ $temp['data'] = $originalValues;
+ return $temp;
+
+ }else if(!count($beforeEnrolled) && !count($afterEnrolled)){ //After enrolment created new data
+
+ $temp['table'] = $table;
+ $temp['id'] = $pk;
+ $temp['data'] = ['is_active'=> 0 ];
+ return $temp;
+
+ }else if(!count($beforeEnrolled) && count($afterEnrolled)){ //After enrolment created new data and edited some of the data
+
+ $temp['table'] = $table;
+ $temp['id'] = $pk;
+ $temp['data'] = ['is_active'=> 0 ];
+ return $temp;
+
+ }else if(count($beforeEnrolled) && !count($afterEnrolled)){ //After enrolment nothing changes from the data
+
+ return false;
+ }
}
diff --git a/app/Controllers/EmployeeServiceController.php b/app/Controllers/EmployeeServiceController.php
index 6d5e6a98..d5e6d6f7 100755
--- a/app/Controllers/EmployeeServiceController.php
+++ b/app/Controllers/EmployeeServiceController.php
@@ -1582,9 +1582,15 @@ class EmployeeServiceController extends AdminController
// insert or update in db for inception addition depent addition
public function employeesOnboardProcess($params)
- {
+ {
+ // dd($params);
+
$familiy_data = $params['familiy_data'];
$file = $params['file'];
+
+ $policy_details = $this->clientPolicyModel->where('id', $file['policy_id'])->first();
+ // dd($policy_details);
+
foreach($familiy_data as $fkey => $value)
{
if(is_array($value))
@@ -1660,7 +1666,8 @@ class EmployeeServiceController extends AdminController
$policy_data['updated_by'] = $file['created_by'];
$policy_data['id'] = $employee_policy[0]['id'];
$policy_data['status'] = 'active';
-
+ $policy_data['payable_employee'] = check_pay_by_employee_or_company($policy_details['policy_terms'], $value['relationship']);
+
$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';
}
@@ -1670,6 +1677,8 @@ class EmployeeServiceController extends AdminController
$policy_data['client_policy_id'] = $file['policy_id'];
$policy_data['created_by'] = $file['created_by'];
$policy_data['status'] = 'active';
+ $policy_data['payable_employee'] = check_pay_by_employee_or_company($policy_details['policy_terms'], $value['relationship']);
+
$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';
}
@@ -1932,7 +1941,7 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){
public function employeesEnrollmentInsert($params)
{
-
+ // dd($this->request);
helper('excel_util_helper');
//get file name
$file_id = $params['file_id'];
@@ -1984,7 +1993,9 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){
// dd($policy_details);
//get policy slab rates
- $slab_details = $this->policiesModel->getPolicySlabRatesForEmpOnboard($file['policy_id'],$file['client_id']);
+ // $slab_details = $this->policiesModel->getPolicySlabRatesForEmpOnboard($file['policy_id'],$file['client_id']);
+ // dd($slab_details);
+
foreach ($excel_data as $key => $row)
{
$is_row_empty = check_row_is_empty_or_null($row);
@@ -2073,6 +2084,7 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){
$policy_data['updated_by'] = $file['created_by'];
$policy_data['id'] = $employee_policy[0]['id'];
$policy_data['status'] = 'draft';
+ $policy_data['payable_employee'] = check_pay_by_employee_or_company($policy_details['policy_terms'], $value['relationship']);
$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';
@@ -2083,6 +2095,8 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){
$policy_data['client_policy_id'] = $file['policy_id'];
$policy_data['created_by'] = $file['created_by'];
$policy_data['status'] = 'draft';
+ $policy_data['payable_employee'] = check_pay_by_employee_or_company($policy_details['policy_terms'], $value['relationship']);
+
$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';
}
@@ -2091,6 +2105,10 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){
$emp_policy_id = $this->employeePolicyModel->getInsertID();
$this->myLogger->logme('error',$log_message);
+ $employeeRestController = new EmployeeRestController();
+ $employeeRestController->updatePremiumAmount($file['policy_id'], $value['emp_code'], $file['client_branch_id']);
+
+
//save email of self for send mail later
if (isset($notification) && $notification['enabled'] == 1 && $notification['mail_content'] != '')
{
@@ -2099,7 +2117,14 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){
$params['dataToInsert'] = $value; //holds employee master data
$params['notification'] = $notification;
$params['client_data'] = $client_details;
- $params['common'] = [];
+ $params['common'] = [
+ 'client_id' => $file['client_id'],
+ 'client_branch_id' => $file['client_branch_id'],
+ 'client_policy_id' => $file['policy_id'],
+ 'employee_policy_id' => $emp_policy_id ?? null,
+ 'employee_id' => $emp_id,
+ 'mail_type' => 'member_welcome_mail',
+ ];
//store email and mail content via helper to send notification
$emp_emails[] = sendMailNotification::sendMailNotification('member_welcome_mail', $params);
}
@@ -2107,6 +2132,7 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){
}// endof if row is empty check
} //end of for loop
+ // dd($emp_emails);
// for bulk mail queue job push
if (!empty($emp_emails) && count($emp_emails) > 0) {
diff --git a/app/Controllers/PolicyTransactionController.php b/app/Controllers/PolicyTransactionController.php
index e2e70696..5e94b340 100644
--- a/app/Controllers/PolicyTransactionController.php
+++ b/app/Controllers/PolicyTransactionController.php
@@ -1744,6 +1744,7 @@ class PolicyTransactionController extends BaseController
$source_data = $this->PTCOShareDetailsModel->getNonReconcileredPolicyTransactions(month:$month,year:$year,insurer_id:$file['insurer_id'],insurer_branch_id:$file['branch_id']);
// var_dump($source_data);die();
// Kint::dump($source_data);//die();
+
// check policy no,insurer and etc in DB for this month
// if all good return true, otherwise return false with messssage
@@ -1752,34 +1753,37 @@ class PolicyTransactionController extends BaseController
$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
- $policy_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[1]);//policy_end_date from excel
- $client_name = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[3]);//clientname from excel
- $endorsement_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[2]);//policy_end_date from excel
-
- foreach ($source_data as $source_key => $source_row)
- {
- if( ($policy_no == $source_row['policy_no']) && $endorsement_no == $source_row['endorsement_no'] && change_date_format($policy_start_date,'d/m/Y','Y-m-d') == $source_row['policy_start_date'] && change_date_format($policy_end_date,'d/m/Y','Y-m-d') == $source_row['policy_end_date'] && $client_name == $source_row['client_name'])
+ $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
+ $policy_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[1]);//policy_end_date from excel
+ $client_name = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[3]);//clientname from excel
+ $endorsement_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[2]);//policy_end_date from excel
+
+ foreach ($source_data as $source_key => $source_row)
{
- $is_source_found = 1;
- unset($source_data[$source_key]);
- continue 2;
+ $source_endorsement_no = $source_row['endorsement_no'] !== null ? $source_row['endorsement_no'] : "";
+ if( ($policy_no == $source_row['policy_no']) && $endorsement_no == $source_endorsement_no && change_date_format($policy_start_date,'d-m-Y','Y-m-d') == $source_row['policy_start_date'] && change_date_format($policy_end_date,'d-m-Y','Y-m-d') == $source_row['policy_end_date'] && $client_name == $source_row['client_name'])
+ {
+ $is_source_found = 1;
+ unset($source_data[$source_key]);
+ continue 2;
+ }
+ }
+
+ if($is_source_found == 0)
+ {
+ // echo $excel_key.'-'.$excel_row[1] . '- not found
';
+ $error_data['error_code'] = 1;//match not found
+ // $error_data['error_data'] = ($error_data['error_data'] ?? []);
+ $error_data['error_data'] = array_merge($error_data['error_data'],[$excel_row[0]]);//match not found
}
- }
- if($is_source_found == 0)
- {
- // echo $excel_key.'-'.$excel_row[1] . '- not found
';
- $error_data['error_code'] = 1;//match not found
- // $error_data['error_data'] = ($error_data['error_data'] ?? []);
- $error_data['error_data'] = array_merge($error_data['error_data'],[$excel_row[0]]);//match not found
}
}
+
+ // dd($error_data);
+
if($error_data['error_code'])
{
$status = 'failed';
@@ -1850,94 +1854,96 @@ class PolicyTransactionController extends BaseController
$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
- $policy_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[1]);//policy_end_date from excel
- $client_name = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[3]);//clientname from excel
- $endorsement_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[2]);//policy_end_date from excel
-
- foreach ($source_data as $source_key => $source_row)
- {
- // Kint::dump(change_date_format($excel_row[3],'d/m/Y','Y-m-d'));
- if( ($policy_no == $source_row['policy_no']) && $endorsement_no == $source_row['endorsement_no'] && change_date_format($policy_start_date,'d/m/Y','Y-m-d') == $source_row['policy_start_date'] && change_date_format($policy_end_date,'d/m/Y','Y-m-d') == $source_row['policy_end_date'] && $client_name == $source_row['client_name'])
+
+ $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
+ $policy_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[1]);//policy_end_date from excel
+ $client_name = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[3]);//clientname from excel
+ $endorsement_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[2]);//policy_end_date from excel
+
+ foreach ($source_data as $source_key => $source_row)
{
- $is_source_found = 1;
-
- //calculate percentage first
- $total_amt = 0;
-
- $actual_bp_per = trim($excel_row[9]);
- $actual_bp_brokerage = trim($excel_row[12]);
- $actual_bp_amt = trim($excel_row[6]);
-
- if(($actual_bp_brokerage && $actual_bp_brokerage != 0 && $actual_bp_brokerage != ""))
+ // Kint::dump(change_date_format($excel_row[3],'d-m-Y','Y-m-d'));
+ $source_endorsement_no = $source_row['endorsement_no'] !== null ? $source_row['endorsement_no'] : "";
+ if( ($policy_no == $source_row['policy_no']) && $endorsement_no == $source_endorsement_no && change_date_format($policy_start_date,'d-m-Y','Y-m-d') == $source_row['policy_start_date'] && change_date_format($policy_end_date,'d-m-Y','Y-m-d') == $source_row['policy_end_date'] && $client_name == $source_row['client_name'])
{
- $total_amt += $actual_bp_brokerage;
- //percentage reverse calculation
- if($actual_bp_per == 0 || $actual_bp_per == "")
+ $is_source_found = 1;
+
+ //calculate percentage first
+ $total_amt = 0;
+
+ $actual_bp_per = trim($excel_row[9]);
+ $actual_bp_brokerage = trim($excel_row[12]);
+ $actual_bp_amt = trim($excel_row[6]);
+
+ if(($actual_bp_brokerage && $actual_bp_brokerage != 0 && $actual_bp_brokerage != ""))
{
- $actual_bp_per = round(($actual_bp_brokerage / $actual_bp_amt) * 100,2);
+ $total_amt += $actual_bp_brokerage;
+ //percentage reverse calculation
+ if($actual_bp_per == 0 || $actual_bp_per == "")
+ {
+ $actual_bp_per = round(($actual_bp_brokerage / $actual_bp_amt) * 100,2);
+ }
+
}
-
- }
- else
- {
- $actual_bp_brokerage = $actual_bp_amt * ($actual_bp_per / 100);
- $total_amt += $actual_bp_brokerage;
- }
-
- $actual_tp_per = trim($excel_row[10]);
- $actual_tp_brokerage = trim($excel_row[13]);
- $actual_tp_amt = trim($excel_row[7]);
-
- if($actual_tp_brokerage && $actual_tp_brokerage != 0 && $actual_tp_brokerage != "")
- {
- $total_amt += $actual_tp_brokerage;
- //percentage reverse calculation
- if($actual_tp_per == 0 || $actual_tp_per == "")
+ else
{
- $actual_tp_per = ($actual_tp_brokerage / $actual_tp_amt) * 100;
+ $actual_bp_brokerage = $actual_bp_amt * ($actual_bp_per / 100);
+ $total_amt += $actual_bp_brokerage;
}
- }
- else
- {
- $actual_tp_brokerage = $actual_tp_amt * ($actual_tp_per / 100);
- $total_amt += $actual_tp_brokerage;
- }
- $actual_tep_per = trim($excel_row[11]);
- $actual_tep_brokerage = trim($excel_row[14]);
- $actual_tep_amt = trim($excel_row[8]);
+ $actual_tp_per = trim($excel_row[10]);
+ $actual_tp_brokerage = trim($excel_row[13]);
+ $actual_tp_amt = trim($excel_row[7]);
- if($actual_tep_brokerage && $actual_tep_brokerage != 0 && $actual_tep_brokerage != "")
- {
- $total_amt += $actual_tep_brokerage;
- //percentage reverse calculation
- if($actual_tep_per == 0 || $actual_tep_per == "")
+ if($actual_tp_brokerage && $actual_tp_brokerage != 0 && $actual_tp_brokerage != "")
{
- $actual_tep_per = ($actual_tep_brokerage / $actual_tep_amt) * 100;
+ $total_amt += $actual_tp_brokerage;
+ //percentage reverse calculation
+ if($actual_tp_per == 0 || $actual_tp_per == "")
+ {
+ $actual_tp_per = ($actual_tp_brokerage / $actual_tp_amt) * 100;
+ }
}
+ else
+ {
+ $actual_tp_brokerage = $actual_tp_amt * ($actual_tp_per / 100);
+ $total_amt += $actual_tp_brokerage;
+ }
+
+ $actual_tep_per = trim($excel_row[11]);
+ $actual_tep_brokerage = trim($excel_row[14]);
+ $actual_tep_amt = trim($excel_row[8]);
+
+ if($actual_tep_brokerage && $actual_tep_brokerage != 0 && $actual_tep_brokerage != "")
+ {
+ $total_amt += $actual_tep_brokerage;
+ //percentage reverse calculation
+ if($actual_tep_per == 0 || $actual_tep_per == "")
+ {
+ $actual_tep_per = ($actual_tep_brokerage / $actual_tep_amt) * 100;
+ }
+ }
+ else
+ {
+ $actual_tep_brokerage = $actual_tep_amt * ($actual_tep_per / 100);
+ $total_amt += $actual_tep_brokerage;
+ }
+
+ //find variance
+ $variance_amt = $source_row['exp_amt'] - $total_amt;
+
+ $data_to_update[] = ['id' => $source_row['id'],'actual_bp_amt' => $actual_bp_amt,'actual_tp_amt' => $actual_tp_amt,'actual_tep_amt' => $actual_tep_amt,'actual_bp_per' => $actual_bp_per,'actual_tp_per' => $actual_tp_per,'actual_tep_per' => $actual_tep_per,'variance' => $variance_amt,'actual_tep_brokerage_amt' => $actual_tep_brokerage,'actual_tp_brokerage_amt' => $actual_tp_brokerage,'actual_bp_brokerage_amt' => $actual_bp_brokerage,'reward' => trim($excel_row[15]),'statement_id' => $file_id];
+
+ unset($source_data[$source_key]);
+ continue 2;
}
- else
- {
- $actual_tep_brokerage = $actual_tep_amt * ($actual_tep_per / 100);
- $total_amt += $actual_tep_brokerage;
- }
-
- //find variance
- $variance_amt = $source_row['exp_amt'] - $total_amt;
-
- $data_to_update[] = ['id' => $source_row['id'],'actual_bp_amt' => $actual_bp_amt,'actual_tp_amt' => $actual_tp_amt,'actual_tep_amt' => $actual_tep_amt,'actual_bp_per' => $actual_bp_per,'actual_tp_per' => $actual_tp_per,'actual_tep_per' => $actual_tep_per,'variance' => $variance_amt,'actual_tep_brokerage_amt' => $actual_tep_brokerage,'actual_tp_brokerage_amt' => $actual_tp_brokerage,'actual_bp_brokerage_amt' => $actual_bp_brokerage,'reward' => trim($excel_row[15]),'statement_id' => $file_id];
-
- unset($source_data[$source_key]);
- continue 2;
}
+
}
}
+ // dd($data_to_update);
$this->PTCOShareDetailsModel->updateBatch($data_to_update, 'id');
// dd($data_to_update);
// if($error_data['error_code'])
diff --git a/app/Controllers/RestAuthenticationController.php b/app/Controllers/RestAuthenticationController.php
index 8f65b9bf..56c65ff8 100755
--- a/app/Controllers/RestAuthenticationController.php
+++ b/app/Controllers/RestAuthenticationController.php
@@ -4,7 +4,7 @@
namespace App\Controllers;
-
+use App\Helpers\MailHelper;
use App\Controllers\LoginController;
use App\Helpers\DepositHelper;
use App\Helpers\JWTToken;
@@ -97,16 +97,51 @@ class RestAuthenticationController extends AdminController
$email = $this->request->getJSON()->email;
- $employeeData = $this->employeeModel->where('email', $email)
- ->where('relationship', 'self')
- ->where('emp_status !=', 'truncated')
- ->where('is_active', 1)
+ $employeeData = $this->employeeModel->where('email_corporate', $email)->where('relationship', 'self')
+ ->where('emp_status !=', 'truncated')->where('is_active', 1)
->first();
if ($employeeData) {
+
+ $otp = random_int(100000, 999999);
+
+ $update = $this->employeeModel->where('email_corporate', $email)->where('relationship', 'self')
+ ->where('is_active', 1)->set(array('otp' => $otp ))
+ ->update();
+ if($update)
+ {
+
+ $common = [
+ 'client_id' => $employeeData['client_id'],
+ 'client_branch_id' => $employeeData['client_branch_id'],
+ 'client_policy_id' => null,
+ 'employee_policy_id' => null,
+ 'employee_id' => $employeeData['id'],
+ 'mail_type' => 'otp_mail',
+ ];
+ $subject = 'Nhance user verification - OTP';
+ $mail_content = $otp.' is your verification code for Nhance.';
+ $res = MailHelper::send_email(['mail' => $employeeData['email_corporate'], 'subject' => $subject ,'common'=>$common ,'message' => $mail_content]);
+ $this->myLogger->logme("info", $res);
+
+ if(json_decode($res)->status == 'success')
+ {
+ $result = ['user_verification' => true ,'message' => "Verified Successfully"];
+ return $this->respond(['status' => 'success','code' => 200,'data' => $result],200);
+
+ }else{
+ $result = ['user_verification' => false , 'message' => "Mail sending failed , try again"];
+ return $this->respond(['status' => 'failed','code' => 404,'data' => $result],200);
+ }
+
+ }else{
+
+ $result = ['user_verification' => false , 'message' => "Verification failed , try again"];
+ return $this->respond(['status' => 'failed','code' => 404,'data' => $result],200);
+
+ }
+
- $result = ['user_verification' => true ,'message' => "Verified Successfully"];
- return $this->respond(['status' => 'success','code' => 200,'data' => $result],200);
} else {
$result = ['user_verification' => false , 'message' => "User not found"];
return $this->respond(['status' => 'failed','code' => 404,'data' => $result],200);
@@ -122,8 +157,10 @@ class RestAuthenticationController extends AdminController
{
try {
- $otp_verification = $this->request->getJSON()->otp_verification;
+ $otp_verification = isset($this->request->getJSON()->otp_verification) ? $this->request->getJSON()->otp_verification : null;
$mobile_number = isset($this->request->getJSON()->mobile_number) ? $this->request->getJSON()->mobile_number : null;
+
+ $otp = isset($this->request->getJSON()->otp) ? $this->request->getJSON()->otp : null;
$email_id = isset($this->request->getJSON()->email_id) ? $this->request->getJSON()->email_id : null;
if (isset($this->request->getJSON()->login_by_hr))
@@ -134,12 +171,12 @@ class RestAuthenticationController extends AdminController
{
$employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->where('emp_status !=', 'truncated')->where('is_active', 1)->first();
} else {
- $employeeData = $this->employeeModel->where('email', $email_id)->where('relationship', 'self')->where('emp_status !=', 'truncated')->where('is_active', 1)->first();
+ $employeeData = $this->employeeModel->where('email_corporate', $email_id)->where('otp', $otp)->where('relationship', 'self')->where('emp_status !=', 'truncated')->where('is_active', 1)->first();
}
}
- if ($employeeData && $otp_verification == true || $employeeData && isset($this->request->getJSON()->login_by_hr)) {
+ if ($employeeData && $otp_verification == true || $employeeData && isset($this->request->getJSON()->login_by_hr) || $employeeData && isset($this->request->getJSON()->otp) ) {
$auth = HttpRequestHelper::getRequestInfo();
if ($auth) {
$data = [
@@ -154,6 +191,11 @@ class RestAuthenticationController extends AdminController
$result = JWTToken::encode($employeeData);
+
+ if(isset($this->request->getJSON()->otp)){
+ $this->employeeModel->where('email_corporate', $email_id)->where('otp', $otp)->where('relationship', 'self')->set(['otp'=>null])->update();
+ }
+
return $this->respond(['status' => 'success','code' => 200,'data' => $result],200);
} else {
@@ -256,7 +298,7 @@ class RestAuthenticationController extends AdminController
if (isset($mobile_number)) {
$employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first();
} else {
- $employeeData = $this->employeeModel->where('email', $email_id)->where('relationship', 'self')->first();
+ $employeeData = $this->employeeModel->where('email_corporate', $email_id)->where('relationship', 'self')->first();
}
$mpin = $this->request->getJSON()->mpin;
@@ -299,7 +341,7 @@ class RestAuthenticationController extends AdminController
{
$employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('mpin', $old_mpin)->where('relationship', 'self')->first();
}else{
- $employeeData = $this->employeeModel->where('email', $email_id)->where('mpin', $old_mpin)->where('relationship', 'self')->first();
+ $employeeData = $this->employeeModel->where('email_corporate', $email_id)->where('mpin', $old_mpin)->where('relationship', 'self')->first();
}
@@ -338,7 +380,7 @@ class RestAuthenticationController extends AdminController
{
$employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first();
}else{
- $employeeData = $this->employeeModel->where('email', $email_id)->where('relationship', 'self')->first();
+ $employeeData = $this->employeeModel->where('email_corporate', $email_id)->where('relationship', 'self')->first();
}
if ($employeeData && $mpin == $employeeData["mpin"]) {
@@ -379,7 +421,7 @@ class RestAuthenticationController extends AdminController
{
$employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first();
}else{
- $employeeData = $this->employeeModel->where('email', $email_id)->where('relationship', 'self')->first();
+ $employeeData = $this->employeeModel->where('email_corporate', $email_id)->where('relationship', 'self')->first();
}
diff --git a/app/Controllers/UserController.php b/app/Controllers/UserController.php
index 8d68fc1a..ce177302 100755
--- a/app/Controllers/UserController.php
+++ b/app/Controllers/UserController.php
@@ -71,39 +71,43 @@ class UserController extends AdminController
$this->userTeamsModel->insert($teamData);
}
+ $db = \Config\Database::connect();
+ $tableName = 'hdz_staff';
+
+ // Set default values
+ $admin = 0;
+ $acm = 0;
+ $acm_id = null;
+
if ($userData['role'] == 3) {
-
- $db = \Config\Database::connect();
- $tableName = 'hdz_staff';
$admin = 0;
$acm = 1;
$acm_id = $insert;
-
- $password = '12345678'; //Default password
- $hashedPassword = password_hash($password, PASSWORD_DEFAULT);
-
- foreach ($temp_team as $key => $value) {
-
- $team = $this->teamModel->where('id', $value)->first();
-
- if ($team['name'] == 'Claims') {
- $hdz_staff = [
- 'emp_code' => $userData['emp_code'],
- 'fullname' => $userData['first_name'],
- 'username' => strtolower($userData['first_name']),
- 'email' => $userData['email'],
- 'admin' => $admin,
- 'acm' => $acm,
- 'acm_id' => $acm_id,
- 'registration' => time(),
- 'password' => $hashedPassword,
- 'active' => 1,
- ];
-
- $db->table($tableName)->insert($hdz_staff);
- }
- }
+ } else if (in_array($userData['role'], [1, 5])) {
+ $admin = 1;
+ $acm = 0;
+ $acm_id = null;
}
+
+ $password = '12345678'; // Default password
+ $hashedPassword = password_hash($password, PASSWORD_DEFAULT);
+
+ $hdz_staff = [
+ 'emp_code' => $userData['emp_code'],
+ 'fullname' => $userData['first_name'],
+ 'username' => strtolower($userData['first_name']),
+ 'email' => $userData['email'],
+ 'admin' => $admin,
+ 'acm' => $acm,
+ 'acm_id' => $acm_id,
+ 'registration' => time(),
+ 'password' => $hashedPassword,
+ 'active' => 1,
+ 'department' => 'a:7:{i:0;s:1:"1";i:1;s:1:"2";i:2;s:1:"5";i:3;s:1:"3";i:4;s:1:"9";i:5;s:1:"4";i:6;s:2:"10";}',
+ ];
+
+ $db->table($tableName)->insert($hdz_staff);
+
}
}
$this->myLogger->logme('error', 'User create Successfully created by id {data}', ['data' => get_session_userid()]);
@@ -149,33 +153,55 @@ class UserController extends AdminController
}
}
+ $db = \Config\Database::connect();
+ $tableName = 'hdz_staff';
+
+ $hdz_staff = [
+ 'emp_code' => $userData['emp_code'],
+ 'fullname' => $userData['first_name'],
+ 'username' => strtolower($userData['first_name']),
+ 'email' => $userData['email'],
+ 'registration' => time(),
+ 'active' => 1,
+ 'department' => 'a:7:{i:0;s:1:"1";i:1;s:1:"2";i:2;s:1:"5";i:3;s:1:"3";i:4;s:1:"9";i:5;s:1:"4";i:6;s:2:"10";}',
+ ];
+
if ($userData['role'] == 3) {
-
- $db = \Config\Database::connect();
- $tableName = 'hdz_staff';
- $admin = 1;
-
- foreach ($userData['team'] as $key => $value) {
- if ($value == 2) {
-
- $hdz_staff = [
- 'emp_code' => $userData['emp_code'],
- 'fullname' => $userData['first_name'],
- 'username' => strtolower($userData['first_name']),
- 'email' => $userData['email'],
- 'admin' => $admin,
- 'registration' => time(),
- 'active' => 1,
- ];
-
- $db->table($tableName)->where('emp_code', $userData['emp_code'])
- ->where('email', $userData['email'])
- ->set($hdz_staff)
- ->update();
- }
- }
-
+ $hdz_staff['admin'] = 0;
+ $hdz_staff['acm'] = 1;
+ $hdz_staff['acm_id'] = $id;
+ } elseif (in_array($userData['role'], [1, 5])) {
+ $hdz_staff['admin'] = 1;
+ $hdz_staff['acm'] = 0;
+ $hdz_staff['acm_id'] = null;
+ } else {
+
+ return redirect()->to(base_url('/user/list'));
}
+
+ // Check if staff data exists
+ $staffData = $db->table($tableName)
+ // ->where('emp_code', $userData['emp_code'])
+ ->where('email', $userData['email'])
+ ->get()->getResult();
+
+ if (!empty($staffData)) {
+
+ // Update existing record
+ $db->table($tableName)
+ // ->where('emp_code', $userData['emp_code'])
+ ->where('email', $userData['email'])
+ ->set($hdz_staff)->update();
+
+ } else {
+
+ $password = '12345678'; // Default password
+ $hdz_staff['password'] = password_hash($password, PASSWORD_DEFAULT);
+
+ // Insert new record
+ $db->table($tableName)->insert($hdz_staff);
+ }
+
}
return redirect()->to(base_url('/user/list'));
diff --git a/app/Helpers/sendMailNotification.php b/app/Helpers/sendMailNotification.php
index 26ee4af5..3ac48a4d 100755
--- a/app/Helpers/sendMailNotification.php
+++ b/app/Helpers/sendMailNotification.php
@@ -81,76 +81,18 @@ class sendMailNotification
$mail_content = str_replace("[[nhance_logo]]", "
", $mail_content);
$mail_content = str_replace("[[client_logo]]", "
", $mail_content);
$mail_content = str_replace("[[app_link]]", "Review Details", $mail_content);
- if ($emp_data && (isset($notification_data) && $notification_data['enabled'] == 1)) {
- if(isset($emp_data['relationship'])){
- if ($emp_data['relationship'] == 'Self') {
- if(count($emp_data) > 0){
- $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'];
- }
- }
- }else{
- $mail ='';
- }
-
- }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'];
- }
-
- if (isset($mail) && !empty($mail)) {
- $wholeData[] = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails'], 'reply_to' => $client_data['reply_to'], 'common' => $common];
- }
+
- }else{
-
- foreach ($emp_data as $key => $value) {
- if ($value['relationship'] != 'Self') {
- $emp_data = $EmployeeModel->where('client_id', $client_data['id'])->where('emp_code', $value['emp_code'])->where('is_active',1)->findAll();
- if(count($emp_data) > 1){
- $mail ='';
- 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'];
- }
- }
- }else{
- $mail ='';
- }
- }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)) {
- $wholeData[] = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails'], 'reply_to' => $client_data['reply_to'], 'common' => $common];
- }
- }
- }
+ $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'];
- if (count($wholeData) < 1) {
- $wholeData = [];
- }
+ $wholeData = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails'], 'reply_to' => $client_data['reply_to'], 'common' => $common];
return $wholeData;
- // }else{
- // return "false";
- // }
} else if($action == 'member_ecard_mail'){
@@ -249,7 +191,11 @@ class sendMailNotification
// echo '
';
// print_r($array_list); die;
+
+
foreach ($array_list as $item) {
+
+ $payable_employee_array = [];
if (count($item) != 0) {
@@ -257,6 +203,7 @@ class sendMailNotification
$temp_data = '';
$policy_name = '';
$is_addon = '';
+ $rowspan = count($item) ?? 2;
foreach ($item as $inner_item) {
@@ -269,6 +216,14 @@ class sendMailNotification
}
//end of getting policy premium data
+ // dd($policy_premium_data);
+
+ if($inner_item['payable_employee'] == 1 && $client_policy_data['policy_type_id'] == 2){
+ $payable_employee_array['emp_data'][] = $inner_item;
+ }
+
+ // dd($policy_premium_data);
+
$policy_name = $inner_item['policy_name'];
if ($inner_item['relationship'] == 'Self') {
@@ -283,8 +238,19 @@ class sendMailNotification
$gst_forself = '';
// if(checkFamilyFloaters($policy_premium_data, $client_policy_data, $inner_item)){
- $si = '₹ ' .format_indian_number($inner_item['basic_cover_si']);
- $premium = '₹ ' .format_indian_number(round($inner_item['premium']));
+
+ if($policy_premium_data['premium_type'] == 2){
+ $si = '₹ ' .format_indian_number($inner_item['basic_cover_si']);
+ }else{
+ if ($inner_item['relationship'] == 'Self') {
+ $payable_employee_array['si_amount'] = $inner_item['basic_cover_si'];
+ $payable_employee_array['self_premium'] = $inner_item['rata_premimum'];
+ $payable_employee_array['self_gst'] = $inner_item['gst'];
+ }
+ empty($inner_item['basic_cover_si']) ? $si = 0 : $si = '₹ ' .format_indian_number($inner_item['basic_cover_si']);
+ }
+
+ $premium = '₹ ' .format_indian_number(round($inner_item['rata_premimum']));
$gst_forself = '₹ ' .format_indian_number(round($inner_item['gst']));
// }
@@ -292,8 +258,13 @@ class sendMailNotification
$temp_data .= '| ' . $inner_item['name'] . ($inner_item['relationship'] == 'Self' ? ' (' . $inner_item['emp_code'] . ')' : '') . ' | ';
$temp_data .= '' . $inner_item['relationship'] . ' | ';
$temp_data .= '' . \DateTime::createFromFormat('Y-m-d', $inner_item['dob'])->format('d-m-Y') . ' | ';
- $temp_data .= '' . $si . ' | ';
-
+
+ if($policy_premium_data['premium_type'] == 2){
+ $temp_data .= '' . $si . ' | ';
+ }else{
+ $temp_data .= (($si != 0 && count($item) != 1) ? ('' . $si . ' | ') : ($si == 0 ? "" : '' . $si . ' | ') );
+ }
+
// Only Display SI Topup and Dependent Addon
if ($inner_item['is_addon'] == 2 || $inner_item['is_addon'] == 3) {
$temp_data .= '' . $premium . ' | ';
@@ -352,6 +323,140 @@ class sendMailNotification
$addtional_premium = 0;
$gst = 0;
}
+
+ // dd($payable_employee_array);
+ // dd(count($payable_employee_array['emp_data']));
+
+ if(count($payable_employee_array['emp_data']) > 0){
+
+ $table_content .= 'Policy Type :';
+ $temp_data = '';
+ $is_addon = '';
+ $rowspan = count($payable_employee_array['emp_data']) ?? 2;
+
+ $self_si_amount = $payable_employee_array['si_amount'] ?? 0;
+ $self_premium = $payable_employee_array['self_premium'] ?? 0;
+ $self_gst = $payable_employee_array['self_gst'] ?? 0;
+
+
+ // dd($payable_employee_array['si_amount'], $self_si_amount);
+
+ foreach ($payable_employee_array['emp_data'] as $inner_item) {
+
+ //getting policy premium data
+ $client_policy_data = $clientPolicyModel->where('id', $inner_item['client_policy_id'])->first();
+ if($client_policy_data['policy_type_id'] == 1 || $client_policy_data['policy_type_id'] == 6 || $client_policy_data['policy_type_id'] == 7 ){
+ $policy_premium_data = $PolicyPremium1Model->where('client_policy_id', $inner_item['client_policy_id'])->where('is_active', '1')->first();
+ }else{
+ $policy_premium_data = $PolicyPremium2Model->where('client_policy_id', $inner_item['client_policy_id'])->where('is_active', '1')->first();
+ }
+ //end of getting policy premium data
+
+ // dd($policy_premium_data);
+
+ $si = '';
+ $premium = '';
+ $gst_forself = '';
+
+ if($policy_premium_data['premium_type'] == 2){
+ $si = '₹ ' .format_indian_number($inner_item['basic_cover_si']);
+ }else{
+ empty($self_si_amount) ? $si = 0 : $si = '₹ ' .format_indian_number($self_si_amount);
+ }
+
+ if($policy_premium_data['premium_type'] == 1){
+
+ empty($self_premium) ? $premium = 0 : $premium = '₹ ' .format_indian_number($self_premium);
+ empty($self_gst) ? $gst_forself = 0 : $gst_forself = '₹ ' .format_indian_number($self_gst);
+
+ }else{
+
+ $premium = '₹ ' .format_indian_number(round($inner_item['rata_premimum']));
+ $gst_forself = '₹ ' .format_indian_number(round($inner_item['gst']));
+
+ }
+
+ $temp_data .= '';
+ $temp_data .= '| ' . $inner_item['name'] . ($inner_item['relationship'] == 'Self' ? ' (' . $inner_item['emp_code'] . ')' : '') . ' | ';
+ $temp_data .= '' . $inner_item['relationship'] . ' | ';
+ $temp_data .= '' . \DateTime::createFromFormat('Y-m-d', $inner_item['dob'])->format('d-m-Y') . ' | ';
+
+ // dd($si);
+
+ if($policy_premium_data['premium_type'] == 2){
+
+ $temp_data .= '' . $si . ' | ';
+ $temp_data .= '' . $premium . ' | ';
+ $temp_data .= '' . $gst_forself . ' | ';
+
+ }else{
+
+ if($policy_premium_data['premium_type'] == 1){
+
+ $temp_data .= (($si != 0 && count($item) != 1) ? ('' . $si . ' | ') : ($si == 0 ? "" : '' . $si . ' | ') );
+ $temp_data .= (($premium != 0 && count($item) != 1) ? ('' . $premium . ' | ') : ($premium == 0 ? "" : '' . $premium . ' | ') );
+ $temp_data .= (($gst_forself != 0 && count($item) != 1) ? ('' . $gst_forself . ' | ') : ($gst_forself == 0 ? "" : '' . $gst_forself . ' | ') );
+
+ }else{
+
+ $temp_data .= (($si != 0 && count($item) != 1) ? ('' . $si . ' | ') : ($si == 0 ? "" : '' . $si . ' | ') );
+ $temp_data .= '' . $premium . ' | ';
+ $temp_data .= '' . $gst_forself . ' | ';
+ }
+
+ $self_si_amount = 0;
+ $self_premium = 0;
+ $self_gst = 0;
+ }
+
+
+ $temp_data .= '
';
+
+ $is_addon = $inner_item['is_addon'];
+
+ $addtional_premium = $inner_item['rata_premimum'] + $addtional_premium;
+ $gst = $inner_item['gst'] + $gst;
+ }
+
+ $policy_name_for_policy_type = $inner_item['policy_name'];
+ if($client_policy_data['policy_type_id'] == 3 && $client_policy_data['is_addon'] == 3){
+ $policy_name_for_policy_type = 'Add-On Group Medical Coverage for Parents';
+ }
+
+ $table_content .= $policy_name_for_policy_type . ' ( Payable By Employee )
';
+ $table_content .= '
';
+
+ // Add text-align: center to the table head
+ $table_content .= '';
+ $table_content .= '';
+ $table_content .= '| Name | ';
+ $table_content .= 'Relation | ';
+ $table_content .= 'Date Of Birth | ';
+ $table_content .= 'Sum Insured | ';
+ $table_content .= 'Premium | ';
+ $table_content .= 'GST | ';
+
+ $table_content .= '
';
+ $table_content .= '';
+
+ // Add text-align: center to the table body
+ $table_content .= '' . $temp_data . '';
+ $table_content .= '
';
+
+
+ $addon_list_array = [
+ 'policy_name' => $policy_name_for_policy_type . '( Payable By Employee )',
+ 'addtional_premium' => round($addtional_premium),
+ 'gst' => round($gst)
+ ];
+ $Addon_list[] = $addon_list_array;
+
+
+ $temp_data = '';
+ $addtional_premium = 0;
+ $gst = 0;
+
+ }
}
if (count($Addon_list) > 0) {
@@ -393,6 +498,7 @@ class sendMailNotification
// $table_content .= '' . $sum_total_words . '
';
}
+ // dd($payable_employee_array, $Addon_list);
// print_r($table_content); die;
$mail_content = str_replace("[[member_name]]", $name . ' (' . $emp_code . ')' , $mail_content);
@@ -462,6 +568,9 @@ class sendMailNotification
$Addon_list = [];
foreach ($array_list as $item) {
+
+ $payable_employee_array = [];
+
if (count($item) != 0) {
$table_content .= 'Policy Type :';
$temp_data = '';
@@ -479,6 +588,10 @@ class sendMailNotification
}
//end of getting policy premium data
+ if($inner_item['payable_employee'] == 1 && $client_policy_data['policy_type_id'] == 2){
+ $payable_employee_array[] = $inner_item;
+ }
+
$policy_name = $inner_item['policy_name'];
if ($inner_item['relationship'] == 'Self') {
@@ -490,11 +603,11 @@ class sendMailNotification
$si = '';
$premium = '';
$gst_forself = '';
- if(checkFamilyFloaters($policy_premium_data, $client_policy_data, $inner_item)){
+ // if(checkFamilyFloaters($policy_premium_data, $client_policy_data, $inner_item)){
$si = '₹ ' .format_indian_number($inner_item['basic_cover_si']);
$premium = '₹ ' .format_indian_number(round($inner_item['premium']));
$gst_forself = '₹ ' .format_indian_number(round($inner_item['gst']));
- }
+ // }
$temp_data .= '';
$temp_data .= '| ' . $inner_item['name'] . $emp_code . ' | ';
@@ -560,6 +673,90 @@ class sendMailNotification
$addtional_premium = 0;
$gst = 0;
}
+
+ if(count($payable_employee_array) > 0){
+
+ $table_content .= 'Policy Type :';
+ $temp_data = '';
+ $is_addon = '';
+
+ foreach ($payable_employee_array as $inner_item) {
+
+
+ //getting policy premium data
+ $client_policy_data = $clientPolicyModel->where('id', $inner_item['client_policy_id'])->first();
+ if($client_policy_data['policy_type_id'] == 1 || $client_policy_data['policy_type_id'] == 6 || $client_policy_data['policy_type_id'] == 7 ){
+ $policy_premium_data = $PolicyPremium1Model->where('client_policy_id', $inner_item['client_policy_id'])->where('is_active', '1')->first();
+ }else{
+ $policy_premium_data = $PolicyPremium2Model->where('client_policy_id', $inner_item['client_policy_id'])->where('is_active', '1')->first();
+ }
+ //end of getting policy premium data
+
+
+ $si = '';
+ $premium = '';
+ $gst_forself = '';
+
+ $si = '₹ ' .format_indian_number($inner_item['basic_cover_si']);
+ $premium = '₹ ' .format_indian_number(round($inner_item['rata_premimum']));
+ $gst_forself = '₹ ' .format_indian_number(round($inner_item['gst']));
+
+ $temp_data .= '';
+ $temp_data .= '| ' . $inner_item['name'] . ($inner_item['relationship'] == 'Self' ? ' (' . $inner_item['emp_code'] . ')' : '') . ' | ';
+ $temp_data .= '' . $inner_item['relationship'] . ' | ';
+ $temp_data .= '' . \DateTime::createFromFormat('Y-m-d', $inner_item['dob'])->format('d-m-Y') . ' | ';
+ $temp_data .= '' . $si . ' | ';
+ $temp_data .= '' . $premium . ' | ';
+ $temp_data .= '' . $gst_forself . ' | ';
+
+ $temp_data .= '
';
+
+ $is_addon = $inner_item['is_addon'];
+
+ $addtional_premium = $inner_item['rata_premimum'] + $addtional_premium;
+ $gst = $inner_item['gst'] + $gst;
+ }
+
+ $policy_name_for_policy_type = $inner_item['policy_name'];
+ if($client_policy_data['policy_type_id'] == 3 && $client_policy_data['is_addon'] == 3){
+ $policy_name_for_policy_type = 'Add-On Group Medical Coverage for Parents';
+ }
+
+ $table_content .= $policy_name_for_policy_type . ' ( Payable By Employee )
';
+ $table_content .= '
';
+
+ // Add text-align: center to the table head
+ $table_content .= '';
+ $table_content .= '';
+ $table_content .= '| Name | ';
+ $table_content .= 'Relation | ';
+ $table_content .= 'Date Of Birth | ';
+ $table_content .= 'Sum Insured | ';
+ $table_content .= 'Premium | ';
+ $table_content .= 'GST | ';
+
+ $table_content .= '
';
+ $table_content .= '';
+
+ // Add text-align: center to the table body
+ $table_content .= '' . $temp_data . '';
+ $table_content .= '
';
+
+
+ $addon_list_array = [
+ 'policy_name' => $policy_name_for_policy_type . '( Payable By Employee )',
+ 'addtional_premium' => round($addtional_premium),
+ 'gst' => round($gst)
+ ];
+ $Addon_list[] = $addon_list_array;
+
+
+ $temp_data = '';
+ $addtional_premium = 0;
+ $gst = 0;
+
+ }
+
}
if (count($Addon_list) > 0) {
@@ -667,8 +864,11 @@ class sendMailNotification
$gst = 0;
$array_list = $params['array_list'];
$Addon_list = [];
-
+
foreach ($array_list as $item) {
+
+ $payable_employee_array = [];
+
if (count($item) != 0) {
$table_content .= 'Policy Type :';
$temp_data = '';
@@ -686,6 +886,10 @@ class sendMailNotification
}
//end of getting policy premium data
+ if($inner_item['payable_employee'] == 1 && $client_policy_data['policy_type_id'] == 2){
+ $payable_employee_array[] = $inner_item;
+ }
+
$policy_name = $inner_item['policy_name'];
if ($inner_item['relationship'] == 'Self') {
@@ -700,11 +904,11 @@ class sendMailNotification
// dd($policy_premium_data, $client_policy_data, $inner_item);
- if(checkFamilyFloaters($policy_premium_data, $client_policy_data, $inner_item)){
+ // if(checkFamilyFloaters($policy_premium_data, $client_policy_data, $inner_item)){
$si = '₹ ' .format_indian_number($inner_item['basic_cover_si']);
$premium = '₹ ' .format_indian_number(round($inner_item['premium']));
$gst_forself = '₹ ' .format_indian_number(round($inner_item['gst']));
- }
+ // }
$temp_data .= '';
$temp_data .= '| ' . $inner_item['name'] . $emp_code . ' | ';
@@ -770,6 +974,89 @@ class sendMailNotification
$addtional_premium = 0;
$gst = 0;
}
+
+ if(count($payable_employee_array) > 0){
+
+ $table_content .= 'Policy Type :';
+ $temp_data = '';
+ $is_addon = '';
+
+ foreach ($payable_employee_array as $inner_item) {
+
+
+ //getting policy premium data
+ $client_policy_data = $clientPolicyModel->where('id', $inner_item['client_policy_id'])->first();
+ if($client_policy_data['policy_type_id'] == 1 || $client_policy_data['policy_type_id'] == 6 || $client_policy_data['policy_type_id'] == 7 ){
+ $policy_premium_data = $PolicyPremium1Model->where('client_policy_id', $inner_item['client_policy_id'])->where('is_active', '1')->first();
+ }else{
+ $policy_premium_data = $PolicyPremium2Model->where('client_policy_id', $inner_item['client_policy_id'])->where('is_active', '1')->first();
+ }
+ //end of getting policy premium data
+
+
+ $si = '';
+ $premium = '';
+ $gst_forself = '';
+
+ $si = '₹ ' .format_indian_number($inner_item['basic_cover_si']);
+ $premium = '₹ ' .format_indian_number(round($inner_item['rata_premimum']));
+ $gst_forself = '₹ ' .format_indian_number(round($inner_item['gst']));
+
+ $temp_data .= '';
+ $temp_data .= '| ' . $inner_item['name'] . ($inner_item['relationship'] == 'Self' ? ' (' . $inner_item['emp_code'] . ')' : '') . ' | ';
+ $temp_data .= '' . $inner_item['relationship'] . ' | ';
+ $temp_data .= '' . \DateTime::createFromFormat('Y-m-d', $inner_item['dob'])->format('d-m-Y') . ' | ';
+ $temp_data .= '' . $si . ' | ';
+ $temp_data .= '' . $premium . ' | ';
+ $temp_data .= '' . $gst_forself . ' | ';
+
+ $temp_data .= '
';
+
+ $is_addon = $inner_item['is_addon'];
+
+ $addtional_premium = $inner_item['rata_premimum'] + $addtional_premium;
+ $gst = $inner_item['gst'] + $gst;
+ }
+
+ $policy_name_for_policy_type = $inner_item['policy_name'];
+ if($client_policy_data['policy_type_id'] == 3 && $client_policy_data['is_addon'] == 3){
+ $policy_name_for_policy_type = 'Add-On Group Medical Coverage for Parents';
+ }
+
+ $table_content .= $policy_name_for_policy_type . ' ( Payable By Employee )
';
+ $table_content .= '
';
+
+ // Add text-align: center to the table head
+ $table_content .= '';
+ $table_content .= '';
+ $table_content .= '| Name | ';
+ $table_content .= 'Relation | ';
+ $table_content .= 'Date Of Birth | ';
+ $table_content .= 'Sum Insured | ';
+ $table_content .= 'Premium | ';
+ $table_content .= 'GST | ';
+
+ $table_content .= '
';
+ $table_content .= '';
+
+ // Add text-align: center to the table body
+ $table_content .= '' . $temp_data . '';
+ $table_content .= '
';
+
+
+ $addon_list_array = [
+ 'policy_name' => $policy_name_for_policy_type . '( Payable By Employee )',
+ 'addtional_premium' => round($addtional_premium),
+ 'gst' => round($gst)
+ ];
+ $Addon_list[] = $addon_list_array;
+
+
+ $temp_data = '';
+ $addtional_premium = 0;
+ $gst = 0;
+
+ }
}
if (count($Addon_list) > 0) {
diff --git a/app/Helpers/utility_helper.php b/app/Helpers/utility_helper.php
index ca339500..79523f60 100755
--- a/app/Helpers/utility_helper.php
+++ b/app/Helpers/utility_helper.php
@@ -404,67 +404,68 @@ if(!function_exists('checkFamilyFloaters')){
}
}
+if (!function_exists('numberToWords')) {
+ function numberToWords($number)
+ {
+ $words = array(
+ '0' => 'Zero',
+ '1' => 'One',
+ '2' => 'Two',
+ '3' => 'Three',
+ '4' => 'Four',
+ '5' => 'Five',
+ '6' => 'Six',
+ '7' => 'Seven',
+ '8' => 'Eight',
+ '9' => 'Nine',
+ '10' => 'Ten',
+ '11' => 'Eleven',
+ '12' => 'Twelve',
+ '13' => 'Thirteen',
+ '14' => 'Fourteen',
+ '15' => 'Fifteen',
+ '16' => 'Sixteen',
+ '17' => 'Seventeen',
+ '18' => 'Eighteen',
+ '19' => 'Nineteen',
+ '20' => 'Twenty',
+ '30' => 'Thirty',
+ '40' => 'Forty',
+ '50' => 'Fifty',
+ '60' => 'Sixty',
+ '70' => 'Seventy',
+ '80' => 'Eighty',
+ '90' => 'Ninety'
+ );
-function numberToWords($number)
-{
- $words = array(
- '0' => 'Zero',
- '1' => 'One',
- '2' => 'Two',
- '3' => 'Three',
- '4' => 'Four',
- '5' => 'Five',
- '6' => 'Six',
- '7' => 'Seven',
- '8' => 'Eight',
- '9' => 'Nine',
- '10' => 'Ten',
- '11' => 'Eleven',
- '12' => 'Twelve',
- '13' => 'Thirteen',
- '14' => 'Fourteen',
- '15' => 'Fifteen',
- '16' => 'Sixteen',
- '17' => 'Seventeen',
- '18' => 'Eighteen',
- '19' => 'Nineteen',
- '20' => 'Twenty',
- '30' => 'Thirty',
- '40' => 'Forty',
- '50' => 'Fifty',
- '60' => 'Sixty',
- '70' => 'Seventy',
- '80' => 'Eighty',
- '90' => 'Ninety'
- );
-
- if ($number < 21) {
- return $words[$number];
- }
-
- if ($number < 100) {
- $tens = (int)($number / 10) * 10;
- $units = $number % 10;
- return $words[$tens] . ($units ? ' ' . $words[$units] : '');
- }
-
- if ($number < 1000) {
- $hundreds = (int)($number / 100);
- $remainder = $number % 100;
- return $words[$hundreds] . ' Hundred' . ($remainder ? ' and ' . numberToWords($remainder) : '');
- }
-
- $levels = array('', ' Thousand', ' Million', ' Billion', ' Trillion', ' Quadrillion', ' Quintillion');
-
- for ($i = 0, $unit = 1; $i < count($levels); $i++, $unit *= 1000) {
- if ($number < $unit * 1000) {
- $current = (int)($number / $unit);
- $remainder = $number % $unit;
- return numberToWords($current) . $levels[$i] . ($remainder ? ' ' . numberToWords($remainder) : '');
+ if ($number < 21) {
+ return $words[$number];
}
- }
- return $number; // Fallback for numbers beyond the supported range
+ if ($number < 100) {
+ $tens = (int)($number / 10) * 10;
+ $units = $number % 10;
+ return $words[$tens] . ($units ? ' ' . $words[$units] : '');
+ }
+
+ if ($number < 1000) {
+ $hundreds = (int)($number / 100);
+ $remainder = $number % 100;
+ return $words[$hundreds] . ' Hundred' . ($remainder ? ' and ' . numberToWords($remainder) : '');
+ }
+
+ $levels = array('', ' Thousand', ' Million', ' Billion', ' Trillion', ' Quadrillion', ' Quintillion');
+
+ for ($i = 0, $unit = 1; $i < count($levels); $i++, $unit *= 1000) {
+ if ($number < $unit * 1000) {
+ $current = (int)($number / $unit);
+ $remainder = $number % $unit;
+ return numberToWords($current) . $levels[$i] . ($remainder ? ' ' . numberToWords($remainder) : '');
+ }
+ }
+
+ return $number; // Fallback for numbers beyond the supported range
+ }
}
if (!function_exists('print_rr')) {
@@ -493,6 +494,7 @@ if (!function_exists('get_server_details')) {
];
}
}
+
if (!function_exists('isJsonString')) {
function isJsonString($input)
@@ -509,9 +511,7 @@ if (!function_exists('isValidDate')) {
}
}
-
-if (!function_exists('change_date_format'))
-{
+if (!function_exists('change_date_format')) {
function change_date_format($date_str, $source_format = null, $output_format = 'Y-m-d') {
@@ -584,3 +584,80 @@ if (!function_exists('change_date_format'))
return null;
}
}
+
+// if (!function_exists('check_pay_by_employee_or_company'))
+// {
+
+// function check_pay_by_employee_or_company($is_payable_employee = null, $relationship = null) {
+
+// $relationship = strtolower(str_replace(" ", "_", $relationship));
+
+// $result = 0;
+
+// if($relationship == 'self'){
+
+// $result = $is_payable_employee['self'] == 1 ? 1 : 0;
+
+// }else if($relationship == 'spouse'){
+
+// $result = $is_payable_employee['spouse'] == 1 ? 1 : 0;
+
+// }else if(in_array($relationship, ['son', 'daughter'])){
+
+// $result = $is_payable_employee['childern'] == 1 ? 1 : 0;
+
+// }else if(in_array($relationship, ['father', 'mother', 'father_in_law', 'mother_in_law'])){
+
+// $result = $is_payable_employee['elders'] == 1 ? 1 : 0;
+
+// }
+
+// return $result;
+// }
+// }
+
+if (!function_exists('check_pay_by_employee_or_company')) {
+
+ function check_pay_by_employee_or_company($policy_terms = null, $relationship = null)
+ {
+
+ // dd($policy_terms, $relationship);
+
+ if (!$policy_terms || !($policy_terms = json_decode($policy_terms, true))) {
+ return 0;
+ }
+
+ // dd($policy_terms, $relationship);
+
+ if (!isset($policy_terms['is_payable_employee'])) {
+ return 0;
+ }
+
+ $is_payable_employee = $policy_terms['is_payable_employee'];
+
+ $relationship = strtolower(str_replace(" ", "_", $relationship));
+
+ // dd($is_payable_employee, $relationship);
+
+ $relationshipMap = [
+ 'self' => 'self',
+ 'spouse' => 'spouse',
+ 'son' => 'childern',
+ 'daughter' => 'childern',
+ 'father' => 'elders',
+ 'mother' => 'elders',
+ 'father_in_law' => 'elders',
+ 'mother_in_law' => 'elders'
+ ];
+
+ if (array_key_exists($relationship, $relationshipMap)) {
+ $key = $relationshipMap[$relationship];
+
+ return isset($is_payable_employee[$key]) && $is_payable_employee[$key] == 1 ? 1 : 0;
+ }
+
+ return 0;
+ }
+
+}
+
diff --git a/app/Models/AuditHistoryModel.php b/app/Models/AuditHistoryModel.php
new file mode 100644
index 00000000..797515f9
--- /dev/null
+++ b/app/Models/AuditHistoryModel.php
@@ -0,0 +1,22 @@
+
\ No newline at end of file
diff --git a/app/Models/ClientModel.php b/app/Models/ClientModel.php
index 2151ec97..1013d0d0 100755
--- a/app/Models/ClientModel.php
+++ b/app/Models/ClientModel.php
@@ -39,6 +39,7 @@ class ClientModel extends Model
"email",
"reply_to",
"mail_domain",
+ "addon_subheading",
];
diff --git a/app/Models/ClientPolicyModel.php b/app/Models/ClientPolicyModel.php
index aac8cd01..cd68444d 100755
--- a/app/Models/ClientPolicyModel.php
+++ b/app/Models/ClientPolicyModel.php
@@ -54,6 +54,39 @@ class ClientPolicyModel extends Model
"is_member_modify_allowed",
];
+ // Callbacks
+ protected $allowCallbacks = true;
+ protected $beforeInsert = ["checkAndADDCreatedByValue"];
+ protected $afterInsert = [];
+ protected $beforeUpdate = ["checkAndUpdateUpdatedByValue"];
+ protected $afterUpdate = [];
+ protected $beforeFind = [];
+ protected $afterFind = [];
+ protected $beforeDelete = [];
+ protected $afterDelete = [];
+
+ protected function checkAndADDCreatedByValue(array $data)
+ {
+ // Check if 'updated_by' value is null or empty
+ if (empty($data['data']['created_by'])) {
+ // Set 'updated_by' value to the current session user ID
+ $data['data']['created_by'] = get_session_userid();
+ }
+
+ return $data;
+ }
+
+ protected function checkAndUpdateUpdatedByValue(array $data)
+ {
+ // Check if 'updated_by' value is null or empty
+ if (empty($data['data']['updated_by'])) {
+ // Set 'updated_by' value to the current session user ID
+ $data['data']['updated_by'] = get_session_userid();
+ }
+
+ return $data;
+ }
+
public function getClientPolicyById($id){
return $this->db->table('client_policy')
@@ -390,21 +423,26 @@ public function getCliendDataForExcelFileName($client_policy_id){
}
//for this using in CRONE JOB
-public function getPolicyDetailsForRemainder($client_id = null, $branch_id = null)
+public function getPolicyDetailsForRemainder($client_id = null, $branch_id = null, $policy_id = null)
{
$builder = $this->table('client_policy')
- ->where('client_policy.is_addon', 1)
- ->where('client_policy.open_for_enrollment', 1)
- ->where('client_policy.inception_type', 2)
->where('client_policy.is_active', 1)
->where('client_policy.policy_status', 1)
- ->whereIn('client_policy.policy_type_id', [2, 3]);
-
+ // ->where('client_policy.is_addon', 1)
+ // ->where('client_policy.inception_type', 2)
+ ->where('client_policy.open_for_enrollment', 1);
+
if ($client_id && $branch_id) {
$builder->where('client_policy.client_id', $client_id)
->where('client_policy.client_branch_id', $branch_id);
}
+ if(empty($policy_id)){
+ $builder->whereIn('client_policy.policy_type_id', [2, 3, 4, 5]);
+ }else{
+ $builder->where('client_policy.id', $policy_id);
+ }
+
return $builder->get()->getResultArray();
}
diff --git a/app/Models/EmployeeModel.php b/app/Models/EmployeeModel.php
index 9fd8fbdb..06c39c7f 100755
--- a/app/Models/EmployeeModel.php
+++ b/app/Models/EmployeeModel.php
@@ -106,7 +106,7 @@ class EmployeeModel extends Model
public function getEmpFamilybyEmpCode(string $client_policy_id = null,string $emp_code = null,string $client_id = null,array $emp_status = [],array $policy_status = [],array $relationship = [],array $client_branch_id = [])
{
- $result = $this->select(['employees.id as emp_id', 'employees.client_id','employees.client_branch_id', 'employees.relationship', 'employees.relationship_code', 'employees.change_event', 'employees.emp_code', 'employees.name', 'employees.email_personal', 'employees.email_corporate', 'employees.mobile', 'employees.gender', 'employees.dob', 'employees.doj', 'employees.basic_pay', 'employees.band', 'employees.designation', 'employees.emp_status','employees.unit','employee_polices.id as emp_policy_id', 'employee_polices.employee_id', 'employee_polices.client_policy_id', 'employee_polices.tpa_id', 'employee_polices.uhid', 'employee_polices.batch_code', 'employee_polices.status', 'employee_polices.pre_existing_alignments', 'employee_polices.basic_cover_si', 'employee_polices.date_coverage', 'employee_polices.policy_end_date', 'employee_polices.days', 'employee_polices.premium', 'employee_polices.rata_premimum', 'employee_polices.gst', 'employee_polices.date_of_exit', 'employee_polices.reason_for_exit','policy_type.long_name as policy_name','client_policy.is_addon'])
+ $result = $this->select(['employees.id as emp_id', 'employees.client_id','employees.client_branch_id', 'employees.relationship', 'employees.relationship_code', 'employees.change_event', 'employees.emp_code', 'employees.name', 'employees.email_personal', 'employees.email_corporate', 'employees.mobile', 'employees.gender', 'employees.dob', 'employees.doj', 'employees.basic_pay', 'employees.band', 'employees.designation', 'employees.emp_status','employees.unit','employee_polices.id as emp_policy_id', 'employee_polices.employee_id', 'employee_polices.client_policy_id', 'employee_polices.tpa_id', 'employee_polices.uhid', 'employee_polices.batch_code', 'employee_polices.status', 'employee_polices.pre_existing_alignments', 'employee_polices.basic_cover_si', 'employee_polices.date_coverage', 'employee_polices.policy_end_date', 'employee_polices.days', 'employee_polices.premium', 'employee_polices.rata_premimum', 'employee_polices.gst', 'employee_polices.date_of_exit', 'employee_polices.reason_for_exit','policy_type.long_name as policy_name','client_policy.is_addon', 'employee_polices.payable_employee'])
->join('employee_polices', 'employee_polices.employee_id = employees.id')
->join('client_policy', 'client_policy.id = employee_polices.client_policy_id')
->join('policy_type', 'policy_type.id = client_policy.policy_type_id','left')
diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php
index 6708da05..9d281507 100755
--- a/app/Models/EmployeePolicyModel.php
+++ b/app/Models/EmployeePolicyModel.php
@@ -33,7 +33,8 @@ class EmployeePolicyModel extends Model
"rand_string",
"is_active",
"claim_status",
- 'ecard_sent_status'
+ 'ecard_sent_status',
+ 'payable_employee',
];
// Callbacks
@@ -556,7 +557,7 @@ class EmployeePolicyModel extends Model
}
- public function getDeletionEmployeeDataForExportExcel($ref_data)
+ public function getDeletionEmployeeDataForExportExcel($ref_data, $return_type = 0)
{
$client_id = $ref_data['client_id'];
@@ -617,8 +618,7 @@ class EmployeePolicyModel extends Model
employee_polices.basic_cover_si,
employee_polices.uhid as uhid,
employee_polices.policy_end_date,
- employee_polices.premium,
- employee_polices.rata_premimum as pro_rata_premium,
+ employee_polices.rata_premimum as premium,
employee_polices.claim_status,
batch_data.emp_policy_id AS emp_policy_id,
@@ -713,9 +713,14 @@ class EmployeePolicyModel extends Model
group by group_key
");
- $result = $query->getResult();
+ if($return_type == 1){
+ $result = $query->getResultArray();
+ }else{
+ $result = $query->getResult();
+ }
// dd($this->db->getLastQuery(), $result);
+
return $result;
}
diff --git a/app/Views/client_onboarding.php b/app/Views/client_onboarding.php
index 267f3029..814a97cd 100755
--- a/app/Views/client_onboarding.php
+++ b/app/Views/client_onboarding.php
@@ -88,10 +88,16 @@ body {
Policies
+
+
+
+ Others
+
+
+
-
diff --git a/app/Views/client_others_tab.php b/app/Views/client_others_tab.php
new file mode 100644
index 00000000..e7f0979c
--- /dev/null
+++ b/app/Views/client_others_tab.php
@@ -0,0 +1,81 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/Views/client_policy.php b/app/Views/client_policy.php
index fd4a01a5..9d5fd143 100755
--- a/app/Views/client_policy.php
+++ b/app/Views/client_policy.php
@@ -175,14 +175,14 @@
-
+
@@ -257,7 +257,6 @@
}
})
-
var policy_PrimaryKey = $('#client_id_policy').val();
var policy_client = $('#policy_PrimaryKey').val();
@@ -827,11 +826,11 @@
}
// 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_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') {
@@ -1199,7 +1198,9 @@
} else if (input) {
// console.log( 'input type step 2', typeof input);
// Handle the case where input is a string
- number = parseFloat(input.replace(/,/g, ''), 10);
+ // number = parseFloat(input.replace(/,/g, ''), 10);
+ number = parseFloat(String(input).replace(/,/g, ''), 10);
+
} else {
// Handle the case where input is undefined or null
number = NaN; // or handle as needed
diff --git a/app/Views/employee_data_list.php b/app/Views/employee_data_list.php
index e023579b..97943e91 100755
--- a/app/Views/employee_data_list.php
+++ b/app/Views/employee_data_list.php
@@ -217,7 +217,7 @@
-
+
@@ -264,7 +264,7 @@
$(document).ready(function(){
var dob = flatpickr("#dob", {
- dateFormat: "d/m/Y",
+ dateFormat: "d/M/Y",
allowInput: false
});
})
diff --git a/app/Views/enrollment_list.php b/app/Views/enrollment_list.php
index edbdd473..d88a4619 100755
--- a/app/Views/enrollment_list.php
+++ b/app/Views/enrollment_list.php
@@ -17,7 +17,7 @@
/* background-color: #eb7a76; */
background-color: darkgrey;
/* padding-bottom: 1px; */
- padding-top: 10px;
+ /* padding-top: 10px; */
}
#tickets-table_filter {
@@ -59,24 +59,31 @@
+
+
+
+
+
-
+
-
+
@@ -84,7 +91,7 @@
-
@@ -234,6 +241,7 @@