diff --git a/app/Config/Routes.php b/app/Config/Routes.php
index 34c19b5b..c757962c 100644
--- a/app/Config/Routes.php
+++ b/app/Config/Routes.php
@@ -9,6 +9,8 @@ use CodeIgniter\Router\RouteCollection;
$routes->get('/swagger', 'SwaggerController::index', ['filter' => 'authMVC']);
+// Reminder Mail Notification
+$routes->get("reminder_mail", "NotificationController::reminder_mail");
// $routes->get('/', 'LoginController::index');
$routes->get('/test', 'Home::index');
@@ -18,6 +20,7 @@ $routes->get('/oauth2callback', 'LoginController::receiveGoogleOAuthResponse');
$routes->get('/auth/google', 'LoginController::initiateGoogleOAuth');
$routes->get('/update-emp-policy-status', 'ClientController::updateEmpAndPolicyStatus');
$routes->get('download-e-card/(:segment)', 'EmployeeController::generateIDCardForEmployee/$1');
+$routes->get('download-kyc-docs/(:segment)', 'ClientController::downloadKYCDocument/$1');
@@ -63,6 +66,11 @@ $routes->group("/client", ["filter" => "authMVC"], function ($routes) {
$routes->get("list/(:any)", "ClientController::editClientOnboarding/$1");
+ $routes->group("notification", ["filter" => "authMVC"], function ($routes) {
+ $routes->post("create", "NotificationController::createNotification");
+ $routes->post("update_enable", "NotificationController::update_enable");
+ $routes->get("getMailTemplateData/(:any)/(:any)", "NotificationController::getMailTemplateData/$1/$2");
+ });
$routes->group("general", ["filter" => "authMVC"], function ($routes) {
$routes->post("create", "ClientController::createClientGeneralInfo");
@@ -218,11 +226,13 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
$routes->get("init-Emp-onboard/(:any)", "EmployeeController::initiateManualEmployeesOnboardProcess/$1");
$routes->get("full-excel-error-file/(:any)", "EmployeeController::downloadFullExcelErrorFile/$1");
$routes->get("id-card", "EmployeeController::viewECard/$1");
+ $routes->get("preview-card/(:any)", "EmployeeController::previewTemplate/$1");
+ $routes->get("export-import-error-list/(:any)", "EmployeeController::errorListExportImport/$1");
});
$routes->cli('cli/processjob', 'JobWorker::processJob');
$routes->cli('cli/processjobs', 'JobWorker::processJobs');
-
+$routes->get("processjob", "JobWorker::processJob");
//Employee login api's
@@ -246,6 +256,7 @@ $routes->post("/calculatePremium", "EmployeeRestController::calculatePremium");
+
$routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) {
$routes->get("getEmployeeProfile", "EmployeeRestController::getEmployeeProfile");
@@ -271,6 +282,8 @@ $routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) {
$routes->get("removeEmpAndEmpPolicyData", "EmployeeRestController::removeEmpAndEmpPolicyData");
$routes->post("calculatePremium", "EmployeeRestController::calculatePremium");
+
+ $routes->get("getEmployeeOldPolicy", "EmployeeRestController::getEmployeeOldPolicy");
});
$routes->post("sendEmail", "EmployeeRestController::send_email");
diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php
index 3a058335..a6cd25ce 100644
--- a/app/Controllers/ClientController.php
+++ b/app/Controllers/ClientController.php
@@ -30,6 +30,7 @@ use App\Models\PolicyPremium1Model;
use App\Models\PolicyPremium2Model;
use App\Models\EmployeeModel;
use App\Models\EmployeePolicyModel;
+use App\Models\NotificationModel;
@@ -60,6 +61,7 @@ class ClientController extends AdminController
protected $clientDepositModel;
protected $employeeModel;
protected $employeePolicyModel;
+ protected $notificationModel;
public function __construct()
{
@@ -87,6 +89,7 @@ class ClientController extends AdminController
$this->policyPremium2Model = new PolicyPremium2Model();
$this->employeeModel = new EmployeeModel();
$this->employeePolicyModel = new EmployeePolicyModel();
+ $this->notificationModel = new NotificationModel();
@@ -264,9 +267,9 @@ class ClientController extends AdminController
$editData['client_kyc'] = $this->clientKYCDocsModel->where('client_id', $id)->findAll();
$editData['client_branch'] = $this->clientBranchModel->where(['client_id' => $id, 'is_active' => 1])->findAll();
$editData['client_relation'] = $this->clientRMModel->where(['client_id' => $id, 'is_active' => 1])->findAll();
-
+ // dd('Hi');
$clientPoliceData = $this->clientPolicyModel->getClientPolicyByClientId($id);
-
+ // dd($this->clientPolicyModel->getLastQuery());
foreach ($clientPoliceData as $key => $value) {
$clientPoliceData[$key]->policy_start_date = date('d-M-Y', strtotime($value->policy_start_date));
@@ -276,8 +279,9 @@ class ClientController extends AdminController
$editData['client_policy'] = $clientPoliceData;
- // echo "
";
- // dd($editData); die;
+ $editData['notification'] =$this->notificationModel->select('template_name,enabled')->where('client_id',$id)->findAll();
+ $editData['placeHolders'] = ['member_name','nhance_logo','tpa_id','ecard_download_link', 'client_logo', 'policy_no', 'member_summary', 'app_link', 'client_name'];
+
echo view('layout/header', $headerData);
echo view('client_onboarding', $editData);
@@ -587,7 +591,14 @@ class ClientController extends AdminController
$data['insurer_id'] = $insurerId;
$tpaValue = (string) $this->request->getPost('tpa');
- list($tpaBranchId, $tpaId) = explode('-', $tpaValue);
+
+ if ($tpaValue === null || $tpaValue === '') {
+ $tpaBranchId = null;
+ $tpaId = null;
+ } else {
+ list($tpaBranchId, $tpaId) = explode('-', $tpaValue);
+ }
+
$data['client_id'] = $client_id;
$data['tpa_branch_id'] = $tpaBranchId;
@@ -609,28 +620,33 @@ class ClientController extends AdminController
$data['is_addon'] = $this->request->getPost('is_addon');
$data['base_policy'] = $this->request->getPost('base_policy');
$data['policy_status'] = 1;
+ $data['inception_type'] = $this->request->getPost('inception_type') ? 2 : 1;
+
$policy_terms = $this->clientPolicyModel->where('id', $this->request->getPost('base_policy'))->first();
- if ( $this->request->getPost('is_addon') == 2 || $this->request->getPost('is_addon') == 3) {
+ if ($this->request->getPost('is_addon') == 2 || $this->request->getPost('is_addon') == 3) {
if ($this->request->getPost('is_addon') == 3) {
$policyTerm = $policy_terms['policy_terms'];
$decoded_policyTerm = json_decode($policyTerm, true);
- $decoded_policyTerm['family_floater'] =0;
- $decoded_policyTerm['family_floaters']['self'] =0;
- $decoded_policyTerm['family_floaters']['spouse'] =0;
- $decoded_policyTerm['family_floaters']['childrens'] =0;
- $decoded_policyTerm['family_floaters']['parents'] =0;
- $decoded_policyTerm['family_floaters']['parents-in-law'] =0;
- $decoded_policyTerm['family_floaters']['either-parents-pil'] =0;
+ $decoded_policyTerm['family_floater'] = 0;
+ $decoded_policyTerm['family_floaters']['self'] = 0;
+ $decoded_policyTerm['family_floaters']['spouse'] = 0;
+ $decoded_policyTerm['family_floaters']['childrens'] = 0;
+ $decoded_policyTerm['family_floaters']['parents'] = 0;
+ $decoded_policyTerm['family_floaters']['parents-in-law'] = 0;
+ $decoded_policyTerm['family_floaters']['either-parents-pil'] = 0;
$data['policy_terms'] = json_encode($decoded_policyTerm);
- }else{
- $data['policy_terms'] = $policy_terms['policy_terms'];
+ } else {
+ if ($this->request->getPost('policy_type_id') != 3) {
+
+ $data['policy_terms'] = $policy_terms['policy_terms'];
+ }
}
}
@@ -696,6 +712,8 @@ class ClientController extends AdminController
$data['is_addon'] = $this->request->getPost('is_addon');
$data['base_policy'] = $this->request->getPost('base_policy');
$data['policy_status'] = 1;
+ $data['inception_type'] = $this->request->getPost('inception_type') ? 2 : 1;
+
$policy_terms = $this->clientPolicyModel->where('id', $this->request->getPost('base_policy'))->first();
@@ -747,12 +765,19 @@ class ClientController extends AdminController
$policy_type = $this->request->getPost('policy_type');
$client_id = $this->request->getPost('client_id');
$client_policy_id = $this->request->getPost('client_policy_id');
- $premium_type = $this->request->getPost('premium_type');
+ // $premium_type = $this->request->getPost('premium_type');
if (!empty($client_id) && $client_id != null) {
$client_policy_data = $this->clientPolicyModel->where('id', $client_policy_id)->first();
$client_id = $client_policy_data['client_id'];
}
$policy_grid_id = $this->request->getPost('policy_grid_id');
+
+ if($policy_grid_id == 10 || $policy_grid_id == 11){
+ $premium_type = 1;
+ }else{
+ $premium_type = 2;
+ }
+
$si_or_bp = $this->request->getPost('si_or_bp');
$basic_multiplier = str_replace(',', '', $this->request->getPost('basic_multiplier'));
$premium_multiplier = str_replace(',', '', $this->request->getPost('premium_multiplier'));
@@ -776,10 +801,14 @@ class ClientController extends AdminController
if ($policy_grid_id == '1') {
+
+
if ($si_or_bp == '1') {
+
$premium = str_replace(',', '', $this->request->getPost('gpa_sum_premium[]'));
$sum_insure = str_replace(',', '', $this->request->getPost('gpa_sum_si[]'));
$multiplier = $this->request->getPost('gpa_sum_multiplier');
+
for ($i = 0; $i < count($premium); $i++) {
$data['si'] = $sum_insure[$i];
$data['premium'] = $premium[$i];
@@ -788,7 +817,26 @@ class ClientController extends AdminController
$policyPremium = $this->policyPremium1Model->insert($data);
}
- } else {
+
+ } else if ($si_or_bp == '3') {
+
+ $premium = str_replace(',', '', $this->request->getPost('gpa_sum_premium2[]'));
+ $sum_insure = str_replace(',', '', $this->request->getPost('gpa_sum_si2[]'));
+ $multiplier = $this->request->getPost('gpa_sum_multiplier2');
+ $grade = $this->request->getPost('gpa_band[]');
+
+ for ($i = 0; $i < count($premium); $i++) {
+ $data['si'] = $sum_insure[$i];
+ $data['premium'] = $premium[$i];
+ $data['grade'] = $grade[$i];
+ $data['multiplier'] = $multiplier;
+ $data['si_or_bp'] = $this->request->getPost('si_or_bp');
+
+ $policyPremium = $this->policyPremium1Model->insert($data);
+ }
+
+ }else {
+
$data['premium'] = str_replace(',', '', $this->request->getPost('gpa_basic_premium'));
$data['si'] = str_replace(',', '', $this->request->getPost('gpa_basic_si'));
$data['basic_multiplier'] = str_replace(',', '', $this->request->getPost('basic_multiplier'));
@@ -798,6 +846,7 @@ class ClientController extends AdminController
$policyPremium = $this->policyPremium1Model->insert($data);
}
+
$data = $this->request->getPost();
$insert = true;
} else if ($policy_grid_id == '2') {
@@ -819,6 +868,8 @@ class ClientController extends AdminController
$data = $this->request->getPost();
$insert = true;
} else if ($policy_grid_id == '4') {
+
+
$premium = $this->request->getPost('4_premium[]');
$sum_insure = $this->request->getPost('4_si');
$age_from = $this->request->getPost('4_age_from[]');
@@ -832,6 +883,8 @@ class ClientController extends AdminController
}
$data = $this->request->getPost();
$insert = true;
+
+
} else if ($policy_grid_id == '5') {
$premium = $this->request->getPost('5_premium[]');
$sum_insure = $this->request->getPost('5_si[]');
@@ -847,19 +900,23 @@ class ClientController extends AdminController
$data = $this->request->getPost();
$insert = true;
} else if ($policy_grid_id == '6') {
+
+
$premium = $this->request->getPost('6_premium[]');
- $sum_insure = $this->request->getPost('6_si[]');
+ $sum_insure = $this->request->getPost('6_si');
$age_from = $this->request->getPost('6_age_from[]');
$age_to = $this->request->getPost('6_age_to[]');
for ($i = 0; $i < count($premium); $i++) {
$data['premium'] = str_replace(',', '', $premium[$i]);
- $data['si'] = str_replace(',', '', $sum_insure[$i]);
+ $data['si'] = str_replace(',', '', $sum_insure);
$data['age_from'] = $age_from[$i];
$data['age_to'] = $age_to[$i];
$dataa = $this->policyPremium2Model->insert($data);
}
$data = $this->request->getPost();
$insert = true;
+
+
} else if ($policy_grid_id == '7') {
$premium = $this->request->getPost('7_premium[]');
$sum_insure = $this->request->getPost('7_si[]');
@@ -918,6 +975,7 @@ class ClientController extends AdminController
$data = $this->request->getPost();
$insert = true;
} else if ($policy_grid_id == '11') {
+
$premium = $this->request->getPost('11_premium[]');
$sum_insure = $this->request->getPost('11_si[]');
$grade = $this->request->getPost('11_grade[]');
@@ -926,7 +984,7 @@ class ClientController extends AdminController
$data['premium'] = str_replace(',', '', $premium[$i]);
$data['si'] = str_replace(',', '', $sum_insure[$i]);
$data['grade'] = $grade[$i];
- $data['max_si'] = $max_sum_insure[$i];
+ $data['max_si'] = str_replace(',', '', $max_sum_insure[$i]);
$dataa = $this->policyPremium2Model->insert($data);
}
$data = $this->request->getPost();
@@ -1117,12 +1175,13 @@ class ClientController extends AdminController
try {
foreach ($results as $index => $record) {
- if ($self->self == 1 && $self->spouse == 0 && $self->childrens == 0 && $self->parents == 0 && $self->{'parents-in-law'} == 0 && $self->{'either-parents-pil'} == 0 && $family_floater == 0) {
- if ($index == '0' || $index == '1' || $index == '2') {
+ // if ($self->self == 1 && $self->spouse == 0 && $self->childrens == 0 && $self->parents == 0 && $self->{'parents-in-law'} == 0 && $self->{'either-parents-pil'} == 0 && $family_floater == 0) {
+ if ($family_floater == 1) {
+ if ($index == '7' || $index == '8' || $index == '9' || $index == '10') {
$resultss[$index] = $record;
}
} else {
- if ($index == '3' || $index == '4' || $index == '5' || $index == '6' || $index == '8' || $index == '7' || $index == '9' || $index == '10') {
+ if ($index == '0' || $index == '1' || $index == '2' || $index == '3' || $index == '4' || $index == '5' || $index == '6') {
$resultss[$index] = $record;
}
}
@@ -1174,7 +1233,8 @@ class ClientController extends AdminController
public function policyGMCTerms()
{
try {
- // print_r($this->request->getPost('family_floaters'));die;
+ // echo "";
+ // print_r($this->request->getPost());die;
$this->myLogger->logme('error','Terms CREATE function called');
/*** Client Policy Table Primary Key(ID) ***/
@@ -1183,7 +1243,19 @@ class ClientController extends AdminController
$data['sum_insured'] =str_replace(',', '',$this->request->getPost("sum_insured"));
$data['family_floater'] =$this->request->getPost("family_floater");
$data['corporatebuffer'] = $this->request->getPost("corporatebuffer");
- $data['family_floaters'] = $this->request->getPost("family_floaters") ?? [];
+ $data['family_floaters'] = $this->request->getPost("family_floaters") ?? [];
+
+ // print_r($this->request->getPost());die;
+ $data['age_ratio']['self']['min'] = $this->request->getPost("self_min_age");
+ $data['age_ratio']['self']['max'] = $this->request->getPost("self_max_age");
+ $data['age_ratio']['spouse']['min'] = $this->request->getPost("spouse_min_age");
+ $data['age_ratio']['spouse']['max'] = $this->request->getPost("spouse_max_age");
+ $data['age_ratio']['child']['min'] = $this->request->getPost("child_min_age");
+ $data['age_ratio']['child']['max'] = $this->request->getPost("child_max_age");
+ $data['age_ratio']['elders']['min'] = $this->request->getPost("other_member_min_age");
+ $data['age_ratio']['elders']['max'] = $this->request->getPost("other_member_max_age");
+
+
// if (!in_array("self", $data['family_floaters'])) {
// array_unshift($data['family_floaters'], "self");
@@ -1254,7 +1326,8 @@ class ClientController extends AdminController
$data['family_floaters']['either-parents-pil'] =0;
}
}
-
+
+ $data['family_floaters']['elders_count'] =$this->request->getPost("member_count");
$data['waiverofpreexistingdiseases'] =$this->request->getPost("waiverofpreexistingdiseases");
if ($data['waiverofpreexistingdiseases'] == 1) {
@@ -1287,6 +1360,13 @@ class ClientController extends AdminController
$data['familytransportationbenefit'] =str_replace(',', '',$this->request->getPost("familytransportationbenefit"));
$data['reasonableandcustomarycharges'] =str_replace(',', '',$this->request->getPost("reasonableandcustomarycharges"));
$data['ayudhtreatmentcover'] =str_replace(',', '',$this->request->getPost("ayudhtreatmentcover"));
+
+ if ($data['ayudhtreatmentcover'] == 1) {
+ $data['ayushTreatmentCoverData'] = str_replace(',', '',$this->request->getPost("ayushTreatmentCoverData"));
+ }else{
+ $data['ayushTreatmentCoverData'] ="";
+ }
+
$data['armdcovered'] =str_replace(',', '',$this->request->getPost("armdcovered"));
$data['suminsuredenhancement'] =str_replace(',', '',$this->request->getPost("suminsuredenhancement"));
$data['automaticsuminsuredreinstatement'] =str_replace(',', '',$this->request->getPost("automaticsuminsuredreinstatement"));
@@ -1302,6 +1382,15 @@ class ClientController extends AdminController
$data['special_condition_label'] = str_replace(',', '',$this->request->getPost("special_condition_label")) ?? [];
$data['special_condition_input'] = str_replace(',', '',$this->request->getPost("special_condition_input")) ?? [];
+ $data['cataract'] =str_replace(',', '',$this->request->getPost("cataract"));
+
+ if ($data['cataract'] == 1) {
+ $data['cataractData'] = str_replace(',', '',$this->request->getPost("cataractData"));
+ }else{
+ $data['cataractData'] ="";
+ }
+
+
$jsonData = json_encode($data);
$dataa = array(
'policy_terms' => $jsonData,
@@ -1340,23 +1429,24 @@ class ClientController extends AdminController
$record = $this->clientPolicyModel->where('id', $client_policy_id)->first();
$policy_name = $this->policesModel->select('name')->where('id', $record['policy_id'])->first();
- $emp_count = $this->employeeModel ->join('client_policy cp',"employees.client_id = cp.client_id")
- ->join('employee_polices ep',"cp.id = ep.client_policy_id AND employees.id = ep.employee_id")
- ->where("employees.client_id", $record['client_id'])
- ->where("employees.emp_status",'active')
- ->countAllResults();
+ // $emp_count = $this->employeeModel ->join('client_policy cp',"employees.client_id = cp.client_id")
+ // ->join('employee_polices ep',"cp.id = ep.client_policy_id AND employees.id = ep.employee_id")
+ // ->where("employees.client_id", $record['client_id'])
+ // ->where("employees.emp_status",'active')
+ // ->countAllResults();
$emp_count_by_policy = $this->employeePolicyModel->where('client_policy_id',$client_policy_id)->where('is_active',1)->countAllResults();
- if($emp_count == 0){
- $emp_count = true;
- }else{
- $emp_count = false;
- }
+
+ // if($emp_count == 0){
+ // $emp_count = true;
+ // }else{
+ // $emp_count = false;
+ // }
if ($record) {
- return $this->respond(['Status' => true,'code' => 200,'data' => $record['policy_terms'], 'count' => $emp_count, 'policy_name' => $policy_name,'policy_addon' => $record['is_addon'], 'emp_count_by_policy'=>$emp_count_by_policy], 200);
+ return $this->respond(['Status' => true,'code' => 200,'data' => $record['policy_terms'], 'policy_name' => $policy_name,'policy_addon' => $record['is_addon'], 'emp_count_by_policy'=>$emp_count_by_policy], 200);
} else {
- return $this->respond(['Status' => false,'code' => 200,'message' => 'Record not found.', 'count' => $emp_count, 'policy_name' => $policy_name], 200);
+ return $this->respond(['Status' => false,'code' => 200,'message' => 'Record not found.', 'policy_name' => $policy_name], 200);
}
}
@@ -1371,6 +1461,8 @@ class ClientController extends AdminController
$data['sumInsured2'] =str_replace(',', '', $this->request->getPost("sumInsured2"));
$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['accidentalDeathBenefit'] =str_replace(',', '',$this->request->getPost("accidentalDeathBenefit"));
$data['permanentTotalDisablement'] =str_replace(',', '',$this->request->getPost("permanentTotalDisablement"));
$data['permanentPartialDisablement'] =$this->request->getPost("permanentPartialDisablement");
@@ -1416,6 +1508,9 @@ class ClientController extends AdminController
$data['animalSnakeInsectBite'] = $this->request->getPost("animalSnakeInsectBite");
$data['terrorism'] = $this->request->getPost("terrorism");
$data['worldwideCover'] = $this->request->getPost("worldwideCover");
+ $data['gpa_special_condition_label'] = str_replace(',', '',$this->request->getPost("gpa_special_condition_label")) ?? [];
+ $data['gpa_special_condition_input'] = str_replace(',', '',$this->request->getPost("gpa_special_condition_input")) ?? [];
+
$jsonData = json_encode($data);
$dataa = array(
@@ -1464,77 +1559,82 @@ class ClientController extends AdminController
public function updateClientPolicyStatus()
{
- $client_policy_id = $this->request->getGet('client_policy_id');
- $record = $this->clientPolicyModel->where('id', $client_policy_id)->first();
- $message = 'Policy updated Successfully' ;
- if($record['open_for_enrollment'] == 0){
- $open_for_enrollment_update_value = 1;
- $message = 'Update Open Enrollment Successfully';
- }else if($record['open_for_enrollment'] == 1){
- $open_for_enrollment_update_value = 0;
- $message = 'Update Open Enrollment Successfully';
- }
-
- $data = $this->policesModel->getPolicyPremium($record['policy_id']);
- $pattern = '/gmc/i';
- $subject = $data[0]->policy_type;
- if (preg_match($pattern, $subject)) {
- $search_term = 'GMC';
- } else {
- $search_term = 'GPA';
- }
-
- if($search_term === 'GPA'){
- $racRate = $this->policyPremium1Model->where(['client_id' => $record['client_id'], 'client_policy_id' => $client_policy_id, 'is_active' => 1])->countAllResults();
- }else if($search_term === 'GMC'){
- $racRate = $this->policyPremium2Model->where(['client_id' => $record['client_id'], 'client_policy_id' => $client_policy_id, 'is_active' => 1])->countAllResults();
- }
-
- $termsData = $this->clientPolicyModel->where(['id' => $client_policy_id, 'is_active' => 1])->first();
- if(empty($termsData['policy_terms'])){
- return $this->respond(['status' => false,'code' => 200,'message' => 'Please define policy terms '], 200);
- }
+ $client_policy_id = $this->request->getGet('client_policy_id');
+ $message = 'Policy updated Successfully';
- $termsData = json_decode($termsData['policy_terms']);
+ $record = $this->clientPolicyModel->where('id', $client_policy_id)->first();
- if (isset($termsData->sum_insured) && empty($termsData->sum_insured)) {
- return $this->respond(['status' => false,'code' => 200,'message' => 'The Policy terms Sum Insured field is empty', 'data' => $record], 200);
- }
+ if ($record['open_for_enrollment'] == 0) {
+ $open_for_enrollment_update_value = 1;
+ $message = 'Enrollment Opened Successfully';
+ } else if ($record['open_for_enrollment'] == 1) {
+ $open_for_enrollment_update_value = 0;
+ $message = 'Enrollment Closed Successfully';
+ }
- if (isset($termsData->SumInsured) && empty($termsData->sum_insured)) {
- return $this->respond(['status' => false,'code' => 200,'message' => 'The Policy terms Sum Insured field is empty'], 200);
- }
-
- // Check if 'family_floater' key exists and has a value
- if (isset($termsData->family_floater) && empty($termsData->family_floater)) {
- return $this->respond(['status' => false,'code' => 200,'message' => 'The Policy terms Family Floater field is empty'], 200);
- }
-
- // Check if 'family_floaters' key exists and has a value
- if (isset($termsData->family_floaters) && is_array($termsData->family_floaters) && count($termsData->family_floaters) <= 0) {
- return $this->respond(['status' => false,'code' => 200,'message' => 'The Policy terms Family Members field is empty'], 200);
- $familyFloatersCount = count($termsData->family_floaters);
- }
+ $data = $this->policesModel->getPolicyPremium($record['policy_id']);
+ $pattern = '/gmc/i';
+ $subject = $data[0]->policy_type;
+ if (preg_match($pattern, $subject)) {
+ $search_term = 'GMC';
+ } else {
+ $search_term = 'GPA';
+ }
- if($racRate == 0){
+ if ($search_term === 'GPA') {
+ $racRate = $this->policyPremium1Model->where(['client_id' => $record['client_id'], 'client_policy_id' => $client_policy_id, 'is_active' => 1])->countAllResults();
+ } else if ($search_term === 'GMC') {
+ $racRate = $this->policyPremium2Model->where(['client_id' => $record['client_id'], 'client_policy_id' => $client_policy_id, 'is_active' => 1])->countAllResults();
+ }
- return $this->respond(['status' => false,'code' => 200,'message' => 'Please define policy premium'], 200);
- }
+ $termsData = $this->clientPolicyModel->where(['id' => $client_policy_id, 'is_active' => 1])->first();
+ if (empty($termsData['policy_terms'])) {
+ return $this->respond(['status' => false, 'code' => 200, 'message' => 'Please define policy terms '], 200);
+ }
- $policy_status = $this->clientPolicyModel->where('id', $client_policy_id )->set('policy_status', 1)->update();
- $json_data ='';
- $open_for_enrollment = $this->clientPolicyModel->where('id', $client_policy_id )->set('open_for_enrollment', $open_for_enrollment_update_value)->update();
- if ($open_for_enrollment) {
- $open_for_enrollment_1 = $this->clientPolicyModel->where('id', $client_policy_id )->find();
- $open_for_enrollment_value = $open_for_enrollment_1[0]['open_for_enrollment'];
- $client_policy_id_value = $client_policy_id;
- $json_data = json_encode(['open_for_enrollment' => $open_for_enrollment_value, 'client_policy_id' => $client_policy_id_value]);
- }
+ $termsData = json_decode($termsData['policy_terms']);
- return $this->respond(['status' => true,'code' => 200, 'message' => $message, 'data' => $termsData, 'racRate' => $racRate, 'open_for_enrollment' => $json_data], 200);
+ if (isset($termsData->sum_insured) && empty($termsData->sum_insured)) {
+ 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)) {
+ return $this->respond(['status' => false, 'code' => 200, 'message' => 'The Policy terms Sum Insured field is empty'], 200);
+ }
+
+ // Check if 'family_floater' key exists and has a value
+ if (isset($termsData->family_floater) && $termsData->family_floater == null) {
+ return $this->respond(['status' => false, 'code' => 200, 'message' => 'The Policy terms Family Floater field is empty'], 200);
+ }
+
+ // Check if 'family_floaters' key exists and has a value
+ if (isset($termsData->family_floaters) && is_array($termsData->family_floaters) && count($termsData->family_floaters) <= 0) {
+ return $this->respond(['status' => false, 'code' => 200, 'message' => 'The Policy terms Family Members field is empty'], 200);
+ $familyFloatersCount = count($termsData->family_floaters);
+ }
+
+ if ($racRate == 0) {
+
+ return $this->respond(['status' => false, 'code' => 200, 'message' => 'Please define policy premium'], 200);
+ }
+
+ // $policy_status = $this->clientPolicyModel->where('id', $client_policy_id )->set('policy_status', 1)->update();
+
+ $json_data = '';
+ $open_for_enrollment = $this->clientPolicyModel->where('id', $client_policy_id)->set('open_for_enrollment', $open_for_enrollment_update_value)->update();
+ if ($open_for_enrollment) {
+ $open_for_enrollment_1 = $this->clientPolicyModel->where('id', $client_policy_id)->find();
+ $open_for_enrollment_value = $open_for_enrollment_1[0]['open_for_enrollment'];
+ $client_policy_id_value = $client_policy_id;
+
+ $json_data = json_encode(['open_for_enrollment' => $open_for_enrollment_value, 'client_policy_id' => $client_policy_id_value]);
+ }
+
+
+
+ return $this->respond(['status' => true, 'code' => 200, 'message' => $message, 'data' => $termsData, 'racRate' => $racRate, 'open_for_enrollment' => $json_data, 'client_policy_data' => $record], 200);
}
@@ -1584,4 +1684,17 @@ class ClientController extends AdminController
}
+
+
+ public function downloadKYCDocument($file_name)
+ {
+
+ $file = WRITEPATH . 'uploads/client_kyc_documents/' . $file_name; // Example file path
+
+ if (file_exists($file)) {
+ return $this->response->download($file, null)->setFileName($file_name);
+ } else {
+ return "File not found.";
+ }
+ }
}
\ No newline at end of file
diff --git a/app/Controllers/DashboardController.php b/app/Controllers/DashboardController.php
index ccd39f50..1a370981 100644
--- a/app/Controllers/DashboardController.php
+++ b/app/Controllers/DashboardController.php
@@ -22,6 +22,11 @@ class DashboardController extends AdminController
echo view('layout/footer');
}
+ public function dashboardNotifications()
+ {
+ //pull notofications to dashboard especially for file upload cases
+ }
+
}
diff --git a/app/Controllers/EmpDataServiceController.php b/app/Controllers/EmpDataServiceController.php
index e2e50f9f..728d81b8 100644
--- a/app/Controllers/EmpDataServiceController.php
+++ b/app/Controllers/EmpDataServiceController.php
@@ -9,6 +9,7 @@ use Psr\Log\LoggerInterface;
use App\Helpers\DepositHelper;
use App\Helpers\MailHelper;
+use App\Helpers\sendMailNotification;
use App\Models\EmployeeModel;
@@ -20,13 +21,17 @@ use App\Models\BatchListModel;
use App\Models\BatchFileModel;
use App\Models\EmpEndorsementModel;
use App\Models\ClientDepositModel;
+use App\Models\NotificationModel;
use App\Controllers\Jobs;
+use App\Controllers\JobWorker;
+
+
use PhpOffice\PhpSpreadsheet\Spreadsheet;
-// use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Reader\Exception as SpreadsheetReaderException;
+use PhpParser\Node\Expr\Cast\Double;
use function PHPUnit\Framework\returnSelf;
@@ -42,6 +47,7 @@ class EmpDataServiceController extends BaseController
protected $batchFileModel;
protected $empEndorsementModel;
protected $clientDepositModel;
+ protected $notificationModel;
public function __construct()
{
@@ -57,9 +63,10 @@ class EmpDataServiceController extends BaseController
$this->batchFileModel = new BatchFileModel();
$this->empEndorsementModel = new EmpEndorsementModel();
$this->clientDepositModel = new ClientDepositModel();
+ $this->notificationModel = new NotificationModel();
}
-
+
/**
* The below function are Inserts batch files and corresponding batch list entries into the database.
*
@@ -92,6 +99,19 @@ class EmpDataServiceController extends BaseController
}
+ public function insertBatchList($params){
+
+ foreach ($params['batch_list_data'] as $value) {
+
+ $batch_list_data['batch_code'] = $params['batch_code'];
+ $batch_list_data['emp_policy_id'] = $value['primaryKey'];
+ $batch_list_data['created_by'] = get_session_userid();
+ $this->batchListModel->insert($batch_list_data);
+ }
+
+ }
+
+
/**
* Generates an Excel file for Inception_Addititon_DependentAddititon, Correction, SI_Enhancement and Deletion events based on given export data.
*
@@ -106,22 +126,39 @@ class EmpDataServiceController extends BaseController
public function generateExcelForAdditionandInception($export_data)
{
+
+ $return = $this->removeOldExportInfoFromBatchFile($export_data);
+
// Fetch employee data for export from the database
$objects = $this->employeePolicyModel->getInceptionEmployeeDataForExportExcel($export_data);
- // dd($objects);
+ $insurer_id = $this->clientPolicyModel->where('id', $export_data['client_policy_id'])->first();
+
+ $cash_balance = $this->clientDepositModel->where('client_id', $export_data['client_id'])->where('insurer_id', $insurer_id['insurer_id'])->orderBy('id', 'DESC')->first();
+
$totals = 0;
foreach ($objects as $key => $value) {
-
+
$totals += $value->total;
}
-
+ if (!empty($cash_balance)) {
+
+ if ((int) $cash_balance['balance'] < (int) $totals) {
+
+ return 0;
+ }
+ } else {
+ // return 0;
+ }
+
+
// Log the count of exported data
$count = count($objects);
$export_data['count'] = $count;
$export_data['amount'] = $totals;
+ $export_data['status'] = 'success';
$this->myLogger->logme('error', 'Inception export data count : {data}', ['data' => $count]);
@@ -168,11 +205,27 @@ class EmpDataServiceController extends BaseController
// If Excel generation is successful
if ($success) {
+
+
// Batch files and list entry
- $return = $this->batchFilesAndBatchListEntry($export_data, $objects);
+ // $return = $this->batchFilesAndBatchListEntry($export_data, $objects);
+
+ $random_number_count = 4;
+ $export_data['batch_code'] = generate_random_string($random_number_count);
+ $export_data['created_by'] = get_session_userid();
+
+ $insert = $this->batchFileModel->insert($export_data);
+ $batch_file_batch_code = $this->batchFileModel->where('id', $insert)->first();
+ $batch_code = $batch_file_batch_code['batch_code'];
+
+ // $this->insertBatchList(['batch_code' => $batch_code, 'batch_list_data' => $objects ]);
+
+ $job_details = new Jobs();
+ $r = Jobs::addJob(['job_name' => 'insertBatchList','payload' => ['batch_code' => $batch_code, 'batch_list_data' => $objects ]]);
+
// If batch operation is successful
- if ($return) {
+ if (true) {
// Set headers for Excel file download
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="' . $export_data['file_name'] . '"');
@@ -186,7 +239,9 @@ class EmpDataServiceController extends BaseController
fclose($tempFile);
return true; // Excel file successfully generated and exported
+
} else {
+
return false; // Batch operation failed
}
}
@@ -280,7 +335,7 @@ class EmpDataServiceController extends BaseController
$ids = [];
$objects = $this->employeePolicyModel->getSIEnhancementEmployeesDataForExportExcel($export_data);
-
+
$totals = 0;
foreach ($objects as $obj) {
$ids[] = $obj->endorsement_primarykey;
@@ -386,7 +441,7 @@ class EmpDataServiceController extends BaseController
$count = count($objects);
$export_data['count'] = $count;
$export_data['amount'] = $rounded_totals;
-
+
$this->myLogger->logme('error', 'Deletion export data count : {data}', ['data' => $count]);
@@ -481,181 +536,467 @@ class EmpDataServiceController extends BaseController
public function importExcelDataForInception($import_data)
{
- $client_id = $import_data['client_id'];
- $client_policy_id = $import_data['client_policy_id'];
$file = $import_data['file'];
- $data = $this->readExcelToArray($file);
-
- if (!$data) {
-
- return 0;
- }
-
- unset($data[0]);
- array_pop($data);
- $count = count($data);
-
- $missing_id = [];
- $empty_emp_tpa_uh_ids = [];
- $totals = 0;
- foreach ($data as $key => $value) {
-
- try {
-
-
- if ($import_data['insurer_or_tpa'] == 'tpa') {
-
- if ($value[15] === null) {
- $missing_id[] = $key + 1;
- }
- } else if ($import_data['insurer_or_tpa'] == 'insurer') {
-
- if ($value[16] === null) {
- $missing_id[] = $key + 1;
- }
- }
-
- $emp_code = $value[2];
- $name = $value[1];
- $totals += $value[20];
-
- $db = \Config\Database::connect();
-
- // Execute the query
- $query = $db->table('employee_polices');
- $query->select('employee_polices.id');
- $query->join('employees', 'employees.id = employee_polices.employee_id');
- $query->where('employee_polices.client_policy_id', $client_policy_id);
- $query->where('employees.client_id', $client_id);
- $query->where('employees.name', $name);
- $query->where('employees.emp_code', $emp_code);
- if ($import_data['insurer_or_tpa'] == 'tpa') {
-
- $query->where('(employee_polices.tpa_id IS NULL OR employee_polices.tpa_id = "")');
- } else if ($import_data['insurer_or_tpa'] == 'insurer') {
-
- $query->where('(employee_polices.uhid IS NULL OR employee_polices.uhid = "")');
- }
- $query->where('employee_polices.is_active', 1);
- $query->limit(1);
-
- // Get the result
- $result = $query->get()->getRowArray();
- if (isset($result['id']) && $result['id'] !== null) {
- $empty_emp_tpa_uh_ids[] = $result['id'];
- }
- } catch (\Exception $e) {
-
- return 0;
- }
- }
-
-
- $missing_id_count = count($missing_id);
- $empty_id_count = count($empty_emp_tpa_uh_ids);
-
-
- if ($import_data['insurer_or_tpa'] == 'tpa') {
-
- if ($empty_id_count == 0) {
-
- return 3;
- }
-
- if ($missing_id_count != 0) {
-
- return 2;
- }
- } else if ($import_data['insurer_or_tpa'] == 'insurer') {
-
- if ($empty_id_count == 0) {
-
- return 5;
- }
-
- if ($missing_id_count != 0) {
-
- return 4;
- }
- }
-
- // if ($missing_id_count != $count) {
-
- // return 2;
- // }
-
-
- // if ($empty_emp_tpa_uh_ids != $count) {
-
- // return 3;
- // }
-
-
-
- // dd($empty_emp_tpa_uh_ids);
-
$is_moved = $file->move(WRITEPATH . 'uploads/import_excel');
$filename = $file->getName();
$this->myLogger->logme('error', 'Inception Import file name : {data}', ['data' => $filename]);
- $import_data['count'] = $count;
+
+ $random_number_count = 4;
+ $import_data['batch_code'] = generate_random_string($random_number_count);
+ $import_data['created_by'] = get_session_userid();
+ $import_data['status'] = 'pending';
$import_data['file_name'] = $filename;
- $import_data['amount'] = $totals;
+ $insert = $this->batchFileModel->insert($import_data);
- $this->insertBatchFileAndBatchListForImportExcel($import_data, $empty_emp_tpa_uh_ids);
-
- // dd($import_data, $empty_emp_tpa_uh_ids);
-
-
- $tpa_id = [];
- $uhid = [];
-
- foreach ($data as $key => $value) {
- $tpa_id[] = $value[15];
- $uhid[] = $value[16];
- }
-
- foreach ($empty_emp_tpa_uh_ids as $key => $id) {
-
- $dataToUpdateTPAID = ['tpa_id' => $tpa_id[$key]];
- $dataToUpdateUHID = ['uhid' => $uhid[$key]];
-
- $this->employeePolicyModel->where('id', $id)
- ->where('(employee_polices.tpa_id IS NULL OR employee_polices.tpa_id = "")')
- ->set($dataToUpdateTPAID)->update();
-
- $this->employeePolicyModel->where('id', $id)
- ->where('(employee_polices.uhid IS NULL OR employee_polices.uhid = "")')
- ->set($dataToUpdateUHID)->update();
- }
-
-
- if($import_data['insurer_or_tpa'] == 'tpa'){
-
- $policy_name = $this->getPolicyNameUsingClientPolicyId($client_policy_id);
- $depositeData = [
- 'employeeIds' => $empty_emp_tpa_uh_ids,
- 'client_id' => $client_id,
- 'client_policy_id' => $client_policy_id,
- 'count' => $count,
- 'event' => $import_data['event_type'],
- 'policy_name' => $policy_name['policy_name'],
- ];
-
- $this->cashDepositCalculationForInception($depositeData);
-
-
- $this->sendMailForDownloadingECard($empty_emp_tpa_uh_ids);
-
- }
+ $file_id['file_id'] = $insert;
+ $job_details = new Jobs();
+ $r = Jobs::addJob(['job_name' => 'importInceptionFileValidation','payload' => ['file_id' => $insert]]);
return 1;
}
+ public function importInceptionFileValidation($params)
+ {
+
+ $file_id = $params['file_id'];
+ $file = $this->batchFileModel->where('id', $file_id)->first();
+ $client_id = $file['client_id'];
+ $client_policy_id = $file['client_policy_id'];
+ $batch_code = $file['batch_code'];
+
+
+ $insurer_or_tpa = $file['insurer_or_tpa'];
+ if ($insurer_or_tpa == 'tpa') {
+
+ $id = 'tpa_id';
+ } else if ($insurer_or_tpa == 'insurer') {
+
+ $id = 'uhid';
+ }
+
+ $file_name_with_path = WRITEPATH . "/uploads/import_excel/" . $file['file_name'];
+ $excel_data = $this->readExcelFileToArray($file_name_with_path);
+ unset($excel_data[0]);
+ array_pop($excel_data);
+
+ $emp_count = count($excel_data);
+
+ $employee_data = $this->employeePolicyModel
+ ->select('
+
+ employee_polices.id as emp_policy_id,
+ employees.name AS emp_name,
+ employees.emp_code AS emp_code,
+ "Has Define" as emp_type,
+ employees.relationship_code AS emp_relationship_code,
+ employees.dob AS emp_dob,
+ employees.gender AS emp_gender,
+ employee_polices.pre_existing_alignments,
+ employee_polices.basic_cover_si,
+ employee_polices.date_coverage,
+ TIMESTAMPDIFF(YEAR, employees.dob, CURDATE()) AS emp_age,
+ employees.relationship AS emp_relationship,
+ employees.change_event AS change_event,
+ employee_polices.policy_end_date,
+ employee_polices.days,
+ employee_polices.tpa_id,
+ employee_polices.uhid,
+ employee_polices.premium,
+ employee_polices.rata_premimum,
+ employee_polices.gst,
+ (employee_polices.rata_premimum + employee_polices.gst) AS total
+ ')
+
+ ->join('employees', 'employees.id = employee_polices.employee_id')
+ ->where('employee_polices.client_policy_id', $client_policy_id)
+ ->where('employees.client_id', $client_id)
+ ->where("employee_polices.{$id} IS NULL OR employee_polices.{$id} = ''")
+ ->findAll();
+
+ // echo '';
+ // print_r($employee_data); die;
+
+
+ if ($employee_data == null || empty($employee_data)) {
+
+ if ($insurer_or_tpa == 'tpa') {
+
+ $data = [
+ 'status' => 'failed-1',
+ ];
+
+ $this->batchFileModel->where('id', $file_id)->set($data)->update();
+
+ return 3;
+
+ } else if ($insurer_or_tpa == 'insurer') {
+
+ $data = [
+ 'status' => 'failed-2',
+ ];
+
+ $this->batchFileModel->where('id', $file_id)->set($data)->update();
+
+ return 5;
+ }
+ }
+
+ $excel_data_count = count($excel_data);
+ $emp_data_count = count($employee_data);
+
+ // dd($excel_data_count, $emp_data_count);
+ $difference = $emp_data_count - $excel_data_count;
+
+ $status = 'in-progress';
+ if ($excel_data_count < $emp_data_count) {
+
+ $status = 'in-progress-partially';
+ $partially_updated_data = 'Expected : ' . $emp_data_count . ', ' . 'Updated : ' . $excel_data_count . ', ' . 'difference : ' . $difference;
+ }
+
+
+ if ($emp_data_count < $excel_data_count) {
+
+ $data = [
+ 'status' => 'failed-3',
+ ];
+
+ $this->batchFileModel->where('id', $file_id)->set($data)->update();
+ return 6;
+ }
+
+
+ $errors = []; // Initialize an array to store errors
+ $missing_id = [];
+ $batch_list_id = [];
+
+ foreach ($employee_data as $key => $emp_value) {
+
+ $key = $key + 1;
+
+ if(!isset($excel_data[$key])){
+ break;
+ }
+
+ if ($insurer_or_tpa == 'tpa') {
+ if ($excel_data[$key][15] === null) {
+ $missing_id[$key][] = [
+ 'row' => $key,
+ 'column' => 15,
+ ];
+ }
+ } else if ($insurer_or_tpa == 'insurer') {
+ if ($excel_data[$key][16] === null) {
+ $missing_id[$key][] = [
+ 'row' => $key,
+ 'column' => 16,
+ ];
+ }
+ }
+
+
+ if ($emp_value['emp_name'] != $excel_data[$key][1]) {
+ $errors[$key][] = [
+ 'row' => $key,
+ 'column' => 1,
+ 'db_data' => $emp_value['emp_name'],
+ 'excel_data' => $excel_data[$key][1]
+ ];
+ }
+
+ if ($emp_value['emp_code'] != $excel_data[$key][2]) {
+ $errors[$key][] = [
+ 'row' => $key,
+ 'column' => 2,
+ 'db_data' => $emp_value['emp_code'],
+ 'excel_data' => $excel_data[$key][2]
+ ];
+ }
+
+ if ($emp_value['emp_dob'] != $excel_data[$key][5]) {
+ $errors[$key][] = [
+ 'row' => $key,
+ 'column' => 5,
+ 'db_data' => $emp_value['emp_dob'],
+ 'excel_data' => $excel_data[$key][5]
+ ];
+ }
+
+ if ($emp_value['emp_gender'] != $excel_data[$key][6]) {
+ $errors[$key][] = [
+ 'row' => $key,
+ 'column' => 6,
+ 'db_data' => $emp_value['emp_gender'],
+ 'excel_data' => $excel_data[$key][6]
+ ];
+ }
+
+ if ($emp_value['pre_existing_alignments'] != $excel_data[$key][7]) {
+ $errors[$key][] = [
+ 'row' => $key,
+ 'column' => 7,
+ 'db_data' => $emp_value['pre_existing_alignments'],
+ 'excel_data' => $excel_data[$key][7]
+ ];
+ }
+
+ if ($emp_value['basic_cover_si'] != $excel_data[$key][8]) {
+ $errors[$key][] = [
+ 'row' => $key,
+ 'column' => 8,
+ 'db_data' => $emp_value['basic_cover_si'],
+ 'excel_data' => $excel_data[$key][8]
+ ];
+ }
+
+ if ($emp_value['emp_relationship'] != $excel_data[$key][11]) {
+ $errors[$key][] = [
+ 'row' => $key,
+ 'column' => 11,
+ 'db_data' => $emp_value['emp_relationship'],
+ 'excel_data' => $excel_data[$key][11]
+ ];
+ }
+
+ if ($emp_value['policy_end_date'] != $excel_data[$key][13]) {
+ $errors[$key][] = [
+ 'row' => $key,
+ 'column' => 13,
+ 'db_data' => $emp_value['policy_end_date'],
+ 'excel_data' => $excel_data[$key][13]
+ ];
+ }
+
+ if ($emp_value['days'] != $excel_data[$key][14]) {
+ $errors[$key][] = [
+ 'row' => $key,
+ 'column' => 14,
+ 'db_data' => $emp_value['days'],
+ 'excel_data' => $excel_data[$key][14]
+ ];
+ }
+
+ if ($emp_value['premium'] != $excel_data[$key][17]) {
+ $errors[$key][] = [
+ 'row' => $key,
+ 'column' => 17,
+ 'db_data' => $emp_value['premium'],
+ 'excel_data' => $excel_data[$key][17]
+ ];
+ }
+
+ if ($emp_value['rata_premimum'] != $excel_data[$key][18]) {
+ $errors[$key][] = [
+ 'row' => $key,
+ 'column' => 18,
+ 'db_data' => $emp_value['rata_premimum'],
+ 'excel_data' => $excel_data[$key][18]
+ ];
+ }
+
+ if ($emp_value['gst'] != $excel_data[$key][19]) {
+ $errors[$key][] = [
+ 'row' => $key,
+ 'column' => 19,
+ 'db_data' => $emp_value['gst'],
+ 'excel_data' => $excel_data[$key][19]
+ ];
+ }
+
+ if ($insurer_or_tpa == 'tpa') {
+
+ if ($emp_value['uhid'] != $excel_data[$key][16]) {
+ $errors[$key][] = [
+ 'row' => $key,
+ 'column' => 16,
+ 'db_data' => $emp_value['uhid'],
+ 'excel_data' => $excel_data[$key][16]
+ ];
+ }
+
+ } else if ($insurer_or_tpa == 'insurer') {
+
+ if ($emp_value['tpa_id'] != $excel_data[$key][15]) {
+ $errors[$key][] = [
+ 'row' => $key,
+ 'column' => 15,
+ 'db_data' => $emp_value['tpa_id'],
+ 'excel_data' => $excel_data[$key][15]
+ ];
+ }
+ }
+
+
+ $batch_list_id[] = $emp_value['emp_policy_id'];
+ }
+
+
+ $error_count = count($errors);
+ $json_errors = json_encode($errors);
+
+ // echo $json_errors; die;
+
+ $missing_id_count = count($missing_id);
+ $json_missing_id = json_encode($missing_id);
+
+ // dd($error_count, $missing_id_count, $json_errors, $json_missing_id);
+
+ // dd($batch_list_id);
+
+ if ($missing_id_count > 0) {
+
+ $data = [
+ 'error_data' => $json_missing_id,
+ 'status' => 'failed',
+ ];
+
+ $this->batchFileModel->where('id', $file_id)->set($data)->update();
+
+ if ($insurer_or_tpa == 'tpa') {
+
+ return 2;
+
+ } else if ($insurer_or_tpa == 'insurer') {
+
+ return 4;
+ }
+ }
+
+
+ if ($error_count > 0) {
+
+ $data = [
+ 'error_data' => $json_errors,
+ 'status' => 'failed',
+ ];
+
+ $this->batchFileModel->where('id', $file_id)->set($data)->update();
+ return 0;
+
+ } else {
+
+ $data = [
+ 'count' => $emp_count,
+ 'status' => $status,
+ 'error_data' => $partially_updated_data ?? null,
+ ];
+
+ $this->batchFileModel->where('id', $file_id)->set($data)->update();
+
+
+ foreach ($batch_list_id as $key => $value) {
+
+ $data = [
+ 'emp_policy_id' => $value,
+ 'batch_code' => $batch_code,
+ ];
+
+ $insert = $this->batchListModel->insert($data);
+ }
+
+
+ $parameters['file_id'] = $file_id;
+
+ $job_details = new Jobs();
+ $r = Jobs::addJob(['job_name' => 'importInceptionUpdateTPAandUHID','payload' => ['file_id' => $file_id]]);
+
+ }
+
+ }
+
+
+ public function importInceptionUpdateTPAandUHID($params)
+ {
+
+ $file_id = $params['file_id'];
+ $file = $this->batchFileModel->find($file_id);
+ if (!$file) {
+ $data = [
+ 'status' => 'failed-4',
+ ];
+
+ $this->batchFileModel->where('id', $file_id)->set($data)->update();
+ return 0; // Return error code if file not found
+ }
+
+ $client_id = $file['client_id'];
+ $client_policy_id = $file['client_policy_id'];
+ $insurer_or_tpa = $file['insurer_or_tpa'];
+ $status = $file['status'];
+ $batch_code = $file['batch_code'];
+
+ $status_val = 'success';
+ if($status == 'in-progress-partially'){
+
+ $status_val = 'partially success';
+ }
+
+
+ $file_name_with_path = WRITEPATH . "/uploads/import_excel/" . $file['file_name'];
+ $excel_data = $this->readExcelFileToArray($file_name_with_path);
+ unset($excel_data[0]); // Remove header row
+ array_pop($excel_data); // Remove footer row
+
+ $totals = 0;
+ $emp_count = count($excel_data);
+ $db = \Config\Database::connect();
+
+ foreach ($excel_data as $key => $value) {
+
+ $name = $value[1];
+ $emp_code = $value[2];
+ $tpa_id = $value[15];
+ $uhid = $value[16];
+ $amount = $value[20];
+
+ $totals += $amount;
+
+ $sql = "
+ UPDATE employee_polices
+ JOIN employees ON employees.id = employee_polices.employee_id
+ SET tpa_id = ?
+ WHERE employees.name = ?
+ AND employees.emp_code = ?
+ AND (employee_polices.tpa_id IS NULL OR employee_polices.tpa_id = '')";
+
+ $params = [$tpa_id, $name, $emp_code];
+ $db->query($sql, $params);
+
+
+
+ $sql = "
+ UPDATE employee_polices
+ JOIN employees ON employees.id = employee_polices.employee_id
+ SET employee_polices.uhid = ?
+ WHERE employees.name = ?
+ AND employees.emp_code = ?
+ AND (employee_polices.uhid IS NULL OR employee_polices.uhid = '')";
+
+ $params = [$uhid, $name, $emp_code];
+ $db->query($sql, $params);
+ }
+
+ // Update batch file status and amount
+ $this->batchFileModel->update($file_id, [
+ 'count' => $emp_count,
+ 'status' => $status_val,
+ 'amount' => $totals,
+ ]);
+
+ return 1;
+ }
+
+
+
+
+
+
+
public function importExcelDataForCorrection($import_data)
{
@@ -1037,7 +1378,7 @@ class EmpDataServiceController extends BaseController
$missing_id = [];
$empty_emp_tpa_uh_ids = [];
- $totals = 0 ;
+ $totals = 0;
foreach ($data as $key => $value) {
try {
@@ -1536,15 +1877,15 @@ class EmpDataServiceController extends BaseController
{
if ($file->isValid() && !$file->hasMoved()) {
$file = $file;
-
+
try {
$reader = IOFactory::createReaderForFile($file->getPathname());
$spreadsheet = $reader->load($file->getPathname());
-
+
// Get the active sheet
$sheet = $spreadsheet->getActiveSheet();
-
+
// Iterate through rows to read data
$data = [];
foreach ($sheet->getRowIterator() as $row) {
@@ -1554,9 +1895,8 @@ class EmpDataServiceController extends BaseController
}
$data[] = $rowData;
}
-
- return $data;
+ return $data;
} catch (SpreadsheetReaderException $e) {
error_log('PhpSpreadsheet reader exception: ' . $e->getMessage());
@@ -1566,7 +1906,7 @@ class EmpDataServiceController extends BaseController
return false;
}
}
-
+
public function insertBatchFileAndBatchListForImportExcel($data, $ids)
@@ -1595,10 +1935,12 @@ class EmpDataServiceController extends BaseController
public function sendMailForDownloadingECard(array $ids)
{
try {
+ $count = 0;
+
foreach ($ids as $key => $id) {
-
+
$get_emp_email_and_other_details = $this->employeePolicyModel
- ->select('employee_polices.client_policy_id, employees.emp_code, employees.email_corporate, employees.name, employee_polices.rand_string, employee_polices.tpa_id')
+ ->select('employee_polices.client_policy_id, employees.emp_code, employees.email_corporate,employees.client_id as client_id, employees.name, employee_polices.rand_string, employee_polices.tpa_id')
->join('employees', 'employees.id = employee_polices.employee_id')
->where('employees.emp_status', 'active')
->where('employees.is_active', '1')
@@ -1606,46 +1948,34 @@ class EmpDataServiceController extends BaseController
->where('employee_polices.is_active', '1')
->where('employee_polices.id', $id)->first();
- if ($get_emp_email_and_other_details != null && $get_emp_email_and_other_details != "") {
-
- $name = $get_emp_email_and_other_details['name'];
- $email = $get_emp_email_and_other_details['email_corporate'];
+ // echo "";
+ // print_r($notification);
+ // die;
+ $client_data = $this->clientModel->where('id',$get_emp_email_and_other_details['client_id'])->first();
+
+ $notification = $this->notificationModel->where('client_id',$get_emp_email_and_other_details['client_id'])->where('template_name','member_ecard_mail')->first();
+ if ($get_emp_email_and_other_details != null && $get_emp_email_and_other_details != "" && $notification['enabled'] == 1) {
$rand_string = $get_emp_email_and_other_details['rand_string'];
$tpa_id = $get_emp_email_and_other_details['tpa_id'];
- $link = generate_download_link($rand_string);
- $subject = 'Download E-Card';
-
- $html = '
- Dear ' .$name .',
- Your Policy( ' .$tpa_id .' ) has been successfully created. Please click the link below to download the insurance card:
- Download Insurance Card
- Thank you,
- ';
+
+ $params['rand_string'] = $rand_string;
+ $params['tpa_id'] = $tpa_id;
+ $params['notification'] = $notification;
+ $params['client_data'] = $client_data;
+ $params['notification'] = $notification;
+ $params['notification'] = $notification;
+ $params['get_emp_email_and_other_details'] = $get_emp_email_and_other_details;
+ $wholeData = sendMailNotification::sendMailNotification('member_ecard_mail', $params);
+
+ $count++;
-
- if ($email != null && $email != "") {
-
- $mail_data = [
- 'mail' => $email,
- 'subject' => $subject,
- 'message' => $html
- ];
-
- // dd($mail_data);
-
- $result = Mailhelper::send_email($mail_data);
- $decoded_result = (array) json_decode($result);
-
- $data = [
- 'status' => $decoded_result['status'],
- 'message'=>$decoded_result['message'] ?? 'Internal Server Error',
- 'email' => $decoded_result['data']
- ];
-
- // dd($data);
- $this->myLogger->logme('error', 'status : {status}, message : {message}, email : {email}', $data);
- }
+ if($count == 20 || $count == count($ids)-1){
+ $job_details = new Jobs();
+ $r = Jobs::addJob(['job_name' => 'bulk_mail','payload' => $wholeData]);
+ $wholeData = [];
+ $count = 0;
+ }
}
}
return true; // Email(s) sent successfully
@@ -1655,4 +1985,49 @@ class EmpDataServiceController extends BaseController
return false; // Email(s) sending failed
}
}
+
+
+
+ public function readExcelFileToArray($path)
+ {
+
+ $spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($path);
+ $sheet = $spreadsheet->getActiveSheet();
+
+ $highestRowAndColumn = $sheet->getHighestRowAndColumn();
+ $excel_data = $sheet->rangeToArray('A1:' . $highestRowAndColumn['column'] . $highestRowAndColumn['row']);
+
+ return $excel_data;
+ }
+
+
+ public function removeOldExportInfoFromBatchFile($params){
+
+ $client_id = $params['client_id'];
+ $client_policy_id = $params['client_policy_id'];
+ $insurer_or_tpa = $params['insurer_or_tpa'];
+ $event_type = $params['event_type'];
+ $actions = $params['actions'];
+
+
+ $batch_data = $this->batchFileModel
+ ->where('client_id', $client_id)
+ ->where('client_policy_id', $client_policy_id)
+ ->where('insurer_or_tpa', $insurer_or_tpa)
+ ->where('event_type', $event_type)
+ ->where('actions', $actions)
+ ->first();
+
+ if(!empty($batch_data)){
+
+ $id = $batch_data['id'];
+ $batch_code = $batch_data['batch_code'];
+
+ $this->batchFileModel->where('id', $id)->delete();
+ $this->batchListModel->where('batch_code', $batch_code)->delete();
+
+ }
+
+
+ }
}
diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php
index 5b73effc..2409f694 100644
--- a/app/Controllers/EmployeeController.php
+++ b/app/Controllers/EmployeeController.php
@@ -16,9 +16,10 @@ use App\Models\BatchListModel;
use App\Models\BatchFileModel;
use App\Models\EmpEndorsementModel;
use App\Models\ClientPolicyModel;
+use App\Models\TPAModel;
-use App\Controllers\Jobs ;
-use App\Controllers\JobWorker ;
+use App\Controllers\Jobs;
+use App\Controllers\JobWorker;
use App\Controllers\Jobs\SubJob;
use App\Controllers\EmployeeServiceController;
use App\Controllers\EmpDataServiceController;
@@ -30,10 +31,12 @@ use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
use Dompdf\Dompdf;
+use Dompdf\Options;
+
class EmployeeController extends AdminController
{
-
+
use ResponseTrait;
protected $myLogger;
@@ -45,6 +48,7 @@ class EmployeeController extends AdminController
protected $batchFileModel;
protected $empEndorsementModel;
protected $clientPolicyModel;
+ protected $TPAModel;
public function __construct()
{
@@ -59,6 +63,7 @@ class EmployeeController extends AdminController
$this->batchFileModel = new BatchFileModel();
$this->empEndorsementModel = new EmpEndorsementModel();
$this->clientPolicyModel = new ClientPolicyModel();
+ $this->TPAModel = new TPAModel();
}
public function list()
@@ -66,32 +71,28 @@ class EmployeeController extends AdminController
// $model = new UserModel();
$data = [];
$data['status'] = ['draft' => 'Draft', 'active' => 'Active', 'inactive' => 'In-Active', 'expired' => 'Expired'];
- if(count($this->request->getGet()))
- {
+ if (count($this->request->getGet())) {
$filterData = $this->request->getGet();
- $data['employees'] = $this->employeePolicyModel->getEmployeePolicy(client_id: $filterData['client_id'],policy_id: $filterData['policy_id'], status: $filterData['status']);
+ $data['employees'] = $this->employeePolicyModel->getEmployeePolicy(client_id: $filterData['client_id'], policy_id: $filterData['policy_id'], status: $filterData['status']);
$data['getData'] = $filterData;
}
- $this->myLogger->logme('error','list called');
- $this->loadLayout('employee_list',$data);
+ $this->myLogger->logme('error', 'list called');
+ $this->loadLayout('employee_list', $data);
}
public function getClientWithPolicies()
{
//echo $this->request->isAJAX();die();
- $result = $this->clientModel->clientsWithPolicies();
+ $result = $this->clientModel->clientsWithPolicies();
- // print_r($result);die();
- if(!count($result))
- {
- return $this->respond(['dataStatus' => false,'code' => 404,'message' => 'no data found'], 200);
- }
- else
- {
-
- return $this->respond(['dataStatus' => true,'code' => 200,'data' => $result], 200);
- }
+ // print_r($result);die();
+ if (!count($result)) {
+ return $this->respond(['dataStatus' => false, 'code' => 404, 'message' => 'no data found'], 200);
+ } else {
+
+ return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => $result], 200);
+ }
}
@@ -103,22 +104,19 @@ class EmployeeController extends AdminController
// $file_id = $this->request->getGet();
// echo $file_id;die();
$file = $this->fileModel->find($file_id);
- // print_r($result);die();
- if(!isset($file))
- {
- return $this->respond(['dataStatus' => false,'code' => 404,'message' => 'no data found'], 200);
- }
- else
- {
-
- return $this->respond(['dataStatus' => true,'code' => 200,'data' => $file['reason']], 200);
- }
+ // print_r($result);die();
+ if (!isset($file)) {
+ return $this->respond(['dataStatus' => false, 'code' => 404, 'message' => 'no data found'], 200);
+ } else {
+
+ return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => $file['reason']], 200);
+ }
}
//handles employee & dependent bulk upload with events like inception,addition,deletion, correction and SI enhancements
public function employeesUplodWithEvents()
{
-
+
// $job_details = new Jobs();
// $r = Jobs::addJob(['job_name' => 'add','payload' => ['a' => 10, 'b' => 35]]);
// print_r($r);//die();
@@ -143,7 +141,7 @@ class EmployeeController extends AdminController
// $empServiceController = new EmployeeServiceController();
// $res = $empServiceController->employeesSIEnhanceProcess(['file_id' => '38']);
// dd($res);
-
+
// $empServiceController = new EmployeeServiceController();
// $res = $empServiceController->employeesCorrectionProcess(['file_id' => '37']);
// // dd($res);
@@ -163,86 +161,78 @@ class EmployeeController extends AdminController
// $this->fileModel->where('id', '12')->set(['status' => 'failed','reason' => $failure_reason])->update();
// dd($failure_reason);
// }
-
- if($this->request->getMethod() == 'post')
- {
+
+ if ($this->request->getMethod() == 'post') {
//validate uploaded file
- $filename = '';
- $validated = $this->validate([
- 'emplist' => [
- 'uploaded[emplist]',
- 'mime_in[emplist,application/vnd.ms-excel,application/vnd,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.oasis.opendocument.spreadsheet]',
- 'max_size[emplist,8192]',
- ],
- ]);
-
- if ($validated) {
- $avatar = $this->request->getFile('emplist');
- $is_moved = $avatar->move(WRITEPATH . 'uploads/excel/');
- $filename = $avatar->getName();
-
- }
- else
- {
- return $this->respond(['dataStatus' => false,'code' => 404,'message' => 'invalid file'], 200);
- }
+ $filename = '';
+ $validated = $this->validate([
+ 'emplist' => [
+ 'uploaded[emplist]',
+ 'mime_in[emplist,application/vnd.ms-excel,application/vnd,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.oasis.opendocument.spreadsheet]',
+ 'max_size[emplist,8192]',
+ ],
+ ]);
- //process post variable entry in file table
- $loggedInUserID = get_session_userid();
- // $loggedInUserID = 8;
+ if ($validated) {
+ $avatar = $this->request->getFile('emplist');
+ $is_moved = $avatar->move(WRITEPATH . 'uploads/excel/');
+ $filename = $avatar->getName();
+ } else {
+ return $this->respond(['dataStatus' => false, 'code' => 404, 'message' => 'invalid file'], 200);
+ }
- $client_id = $this->request->getPost('client_id');
- $policy_id = $this->request->getPost('policy_id');
- $action = $this->request->getPost('upload-action-type');
- $status = 'inprogress';
+ //process post variable entry in file table
+ $loggedInUserID = get_session_userid();
+ // $loggedInUserID = 8;
- $file_id = $this->fileModel->insert(['file_name' => $filename,'client_id' => $client_id,'policy_id' => $policy_id,'created_by' => $loggedInUserID,'status' => $status,'action' => $action]);//here field policy_id have client_policy_id and not policy id from policy master
- $this->myLogger->logme("error",'{file_id} uploaded success',['file_id' => $file_id]);
+ $client_id = $this->request->getPost('client_id');
+ $policy_id = $this->request->getPost('policy_id');
+ $action = $this->request->getPost('upload-action-type');
+ $status = 'inprogress';
- //start validation process
-
- $empServiceController = new EmployeeServiceController();
- $result = $empServiceController->excelFileFormatValidation(['file_id' => $file_id]);
- //endof validation process
- if(isset($result['error_summary']) && count($result['error_summary']))
- {
- return $this->respond(['dataStatus' => false,'code' => 404,'message' => 'file rejected with errors'], 200);
- }
+ $file_id = $this->fileModel->insert(['file_name' => $filename, 'client_id' => $client_id, 'policy_id' => $policy_id, 'created_by' => $loggedInUserID, 'status' => $status, 'action' => $action]); //here field policy_id have client_policy_id and not policy id from policy master
+ $this->myLogger->logme("error", '{file_id} uploaded success', ['file_id' => $file_id]);
- return $this->respond(['dataStatus' => true,'code' => 200,'data' => 'file upload success'], 200);
+ //start validation process
+ $empServiceController = new EmployeeServiceController();
+ $result = $empServiceController->excelFileFormatValidation(['file_id' => $file_id]);
+ //endof validation process
+ if (isset($result['error_summary']) && count($result['error_summary'])) {
+ return $this->respond(['dataStatus' => false, 'code' => 404, 'message' => 'file rejected with errors'], 200);
+ }
+
+ return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => 'file upload success'], 200);
}
-
- $data['events'] = ['inception' => 'Inception (Employee + Dependents)','addition' => 'Addition (Employee + Dependents)','dependent_addition' => 'Dependent Addition (Only Dependents)','deletion' => 'Deletion','correction' =>'Correction','si_enhancement' =>'SI Enhancement'];
- $data['actions'] = ['inception' => 'Inception (Employee + Dependents)','addition' => 'Addition (Employee + Dependents)','dependent_addtion' => 'Dependent Addition (Only Dependents)','deletion' => 'Deletion','correction' =>'Correction','si_enhancement' =>'SI Enhancement'];
-
- $data['import_or_export'] = ['import' => 'Import','export' =>'Export'];
- $data['insurer_or_tpa'] = ['insurer' => 'Insurer','tpa' =>'TPA'];
+
+ $data['events'] = ['inception' => 'Inception (Employee + Dependents)', 'addition' => 'Addition (Employee + Dependents)', 'dependent_addition' => 'Dependent Addition (Only Dependents)', 'deletion' => 'Deletion', 'correction' => 'Correction', 'si_enhancement' => 'SI Enhancement'];
+ $data['actions'] = ['inception' => 'Inception (Employee + Dependents)', 'addition' => 'Addition (Employee + Dependents)', 'dependent_addtion' => 'Dependent Addition (Only Dependents)', 'deletion' => 'Deletion', 'correction' => 'Correction', 'si_enhancement' => 'SI Enhancement'];
+
+ $data['import_or_export'] = ['import' => 'Import', 'export' => 'Export'];
+ $data['insurer_or_tpa'] = ['insurer' => 'Insurer', 'tpa' => 'TPA'];
$data['fileList'] = $this->fileModel
- ->select(['files.*','up.emp_code','up.first_name','pm.name as policy_name','c.short_name', 'cp.id as client_policy_id'])
- ->join('user_profiles up','files.created_by = up.id')
- ->join('client_policy cp','files.policy_id = cp.id','left')
- ->join('policies pm','cp.policy_id = pm.id','left')
- ->join('clients c','files.client_id = c.id and files.client_id = cp.client_id','left')
- ->where('files.created_by',get_session_userid())->orderBy('files.created_at','desc')->findAll();
+ ->select(['files.*', 'up.emp_code', 'up.first_name', 'pm.name as policy_name', 'c.short_name', 'cp.id as client_policy_id'])
+ ->join('user_profiles up', 'files.created_by = up.id')
+ ->join('client_policy cp', 'files.policy_id = cp.id', 'left')
+ ->join('policies pm', 'cp.policy_id = pm.id', 'left')
+ ->join('clients c', 'files.client_id = c.id and files.client_id = cp.client_id', 'left')
+ ->where('files.created_by', get_session_userid())->orderBy('files.created_at', 'desc')->findAll();
$data['batch_list'] = $this->batchFileModel->select('batch_files.*, policies.name as policy_name, clients.short_name as client_short_name')
- ->join('client_policy', 'client_policy.id = batch_files.client_policy_id')
- ->join('policies', 'policies.id = client_policy.policy_id')
- ->join('clients', 'clients.id = client_policy.client_id')
- ->orderBy('batch_files.id','desc')
- ->findAll();
+ ->join('client_policy', 'client_policy.id = batch_files.client_policy_id')
+ ->join('policies', 'policies.id = client_policy.policy_id')
+ ->join('clients', 'clients.id = client_policy.client_id')
+ ->orderBy('batch_files.id', 'desc')
+ ->findAll();
// dd($data['fileList']);die();
- if($this->request->getMethod() == "get")
- {
- $this->loadLayout('import_export',$data);
+ if ($this->request->getMethod() == "get") {
+ $this->loadLayout('import_export', $data);
}
-
}
public function getExcelFileErrors()
@@ -261,7 +251,6 @@ class EmployeeController extends AdminController
$data['message'] = 'File Not Found Physically';
return view('errors/404', $data);
-
} else {
echo view('errors/html/production');
@@ -285,23 +274,23 @@ class EmployeeController extends AdminController
// $actionType = $this->request->getGet();
$filePath = '';
// Path to your file
- if($actionType == 'inception'){
+ if ($actionType == 'inception') {
$filePath = ROOTPATH . 'public/sample_excel/sample_inception.xls';
- }else if($actionType == 'correction'){
+ } else if ($actionType == 'correction') {
$filePath = ROOTPATH . 'public/sample_excel/sample_correction .xls';
- }else if($actionType == 'si_enhancement'){
+ } else if ($actionType == 'si_enhancement') {
$filePath = ROOTPATH . 'public/sample_excel/sample_si_enhancement.xls';
- }else if($actionType == 'dependent_addtion'){
+ } else if ($actionType == 'dependent_addtion') {
$filePath = ROOTPATH . 'public/sample_excel/sample_dependent_addition.xls';
- }else if($actionType == 'addition'){
+ } else if ($actionType == 'addition') {
$filePath = ROOTPATH . 'public/sample_excel/sample_addition.xls';
- }else if($actionType == 'deletion'){
+ } else if ($actionType == 'deletion') {
$filePath = ROOTPATH . 'public/sample_excel/sample_deletion.xls';
}
-
+
// Check if the file exists
if (file_exists($filePath)) {
-
+
// Set the appropriate MIME type
$mimeType = mime_content_type($filePath);
@@ -327,19 +316,19 @@ class EmployeeController extends AdminController
public function importExport()
{
- $this->myLogger->logme('error','importExport function called');
+ $this->myLogger->logme('error', 'importExport function called');
$empDataServiceController = new EmpDataServiceController();
$client_id = $this->request->getPost('client_id');
$client_policy_id = $this->request->getPost('client_policy_id');
$insurer_or_tpa = $this->request->getPost('insurer_or_tpa');
$event_type = $this->request->getPost('event_type');
- $actions = $this->request->getPost('action_type');
+ $actions = $this->request->getPost('action_type');
$client_data = $this->clientModel->where('id', $client_id)->first();
$policy_name = $this->clientPolicyModel->select('policies.name')->join('policies', 'policies.id = client_policy.policy_id')->where('client_policy.id', $client_policy_id)->first();
$file_name = generate_filename($client_data['short_name'], $event_type, $actions, $insurer_or_tpa, $policy_name['name']);
-
+
$batch_data = [
'client_id' => $client_id,
'client_policy_id' => $client_policy_id,
@@ -347,157 +336,167 @@ class EmployeeController extends AdminController
'event_type' => $event_type,
'actions' => $actions,
'file_name' => $file_name,
- ];
+ ];
// $event_type = 'si_enhancement';
- if($actions == 'export'){
+ if ($actions == 'export') {
- if($event_type == 'inception' || $event_type == 'addition' || $event_type == 'dependent_addition' ){
+ if ($event_type == 'inception' || $event_type == 'addition' || $event_type == 'dependent_addition') {
+
+ $return = $empDataServiceController->generateExcelForAdditionandInception($batch_data);
+
+ if($return == 0){
+
+ session()->setFlashdata('error', "Insufficient deposit amount.");
+ return redirect()->to(base_url('employee/upload'));
+ }
- $return = $empDataServiceController->generateExcelForAdditionandInception($batch_data);
- if(!$return){
- if($insurer_or_tpa == 'tpa'){
+ if (!$return) {
+
+ if ($insurer_or_tpa == 'tpa') {
session()->setFlashdata('error', "No data was found for this action. The TPA ID has already been updated.");
- return redirect()->to(base_url('employee/upload'));
-
- }else if($insurer_or_tpa == 'insurer'){
+ return redirect()->to(base_url('employee/upload'));
+ } else if ($insurer_or_tpa == 'insurer') {
session()->setFlashdata('error', "No data was found for this action. The UHID has already been updated.");
- return redirect()->to(base_url('employee/upload'));
+ return redirect()->to(base_url('employee/upload'));
}
- } else{
- $this->myLogger->logme('error','Successfully exported Excel file in {data}.', ['data' => $event_type]);
+
+ } else {
+ $this->myLogger->logme('error', 'Successfully exported Excel file in {data}.', ['data' => $event_type]);
}
+ } else if ($event_type == 'correction') {
- } else if($event_type == 'correction'){
-
- $return = $empDataServiceController->generateExcelForCorrection($batch_data);
- if(!$return){
+ $return = $empDataServiceController->generateExcelForCorrection($batch_data);
+ if (!$return) {
session()->setFlashdata('error', 'No data found about this action');
- return redirect()->to(base_url('employee/upload'));
- } else{
- $this->myLogger->logme('error','Successfully exported Excel file in Correction.');
- }
+ return redirect()->to(base_url('employee/upload'));
+ } else {
+ $this->myLogger->logme('error', 'Successfully exported Excel file in Correction.');
+ }
+ } else if ($event_type == 'si_enhancement') {
- } else if($event_type == 'si_enhancement'){
-
- $return = $empDataServiceController->generateExcelForSIEnhancement($batch_data);
- if(!$return){
+ $return = $empDataServiceController->generateExcelForSIEnhancement($batch_data);
+ if (!$return) {
session()->setFlashdata('error', 'No data found about this action');
- return redirect()->to(base_url('employee/upload'));
- } else{
- $this->myLogger->logme('error','Successfully exported Excel file in SI_Enhancement.');
- }
+ return redirect()->to(base_url('employee/upload'));
+ } else {
+ $this->myLogger->logme('error', 'Successfully exported Excel file in SI_Enhancement.');
+ }
+ } else if ($event_type == 'deletion') {
- }else if($event_type == 'deletion'){
-
- $return = $empDataServiceController->generateExcelForDeletion($batch_data);
- if(!$return){
+ $return = $empDataServiceController->generateExcelForDeletion($batch_data);
+ if (!$return) {
session()->setFlashdata('error', 'No data found about this action');
- return redirect()->to(base_url('employee/upload'));
- } else{
- $this->myLogger->logme('error','Successfully exported Excel file in Deletion.');
- }
+ return redirect()->to(base_url('employee/upload'));
+ } else {
+ $this->myLogger->logme('error', 'Successfully exported Excel file in Deletion.');
+ }
}
-
-
- }else if($actions == 'import'){
+ } else if ($actions == 'import') {
$batch_data['file'] = $this->request->getFile('import_file_data');
+
- if($event_type == 'inception' || $event_type == 'addition' || $event_type == 'dependent_addition'){
+ if ($event_type == 'inception' || $event_type == 'addition' || $event_type == 'dependent_addition') {
- $return = $empDataServiceController->importExcelDataForInception($batch_data);
- if($return == 1){
- session()->setFlashdata('success', 'Data updated successfully');
+
+ $file = $this->request->getFile('import_file_data');
+
+ $is_moved = $file->move(WRITEPATH . 'uploads/import_excel');
+ $filename = $file->getName();
+ $this->myLogger->logme('error', 'Inception Import file name : {data}', ['data' => $filename]);
+
+
+ $random_number_count = 4;
+ $batch_data['batch_code'] = generate_random_string($random_number_count);
+ $batch_data['created_by'] = get_session_userid();
+ $batch_data['status'] = 'pending';
+ $batch_data['file_name'] = $filename;
+
+ $file_id = $this->batchFileModel->insert($batch_data);
+
+ $job_details = new Jobs();
+ $r = Jobs::addJob(['job_name' => 'importInceptionFileValidation','payload' => ['file_id' => $file_id]]);
+
+ $return = 1;
+
+ // $return = $empDataServiceController->importExcelDataForInception($batch_data);
+
+ if ($return == 1) {
+ session()->setFlashdata('success', 'Data updated successfully. File is being validated.');
return redirect()->to(base_url('employee/upload'));
-
- }else if($return == 2){
+ } else if ($return == 2) {
session()->setFlashdata('error', 'The TPA ID column is either partially or entirely empty.');
return redirect()->to(base_url('employee/upload'));
-
- }else if($return == 0){
+ } else if ($return == 0) {
session()->setFlashdata('error', 'Please upload the correct file.');
return redirect()->to(base_url('employee/upload'));
-
- }else if($return == 3){
+ } else if ($return == 3) {
session()->setFlashdata('error', 'The list of employees provided has already been updated with the TPA ID, or this is not the correct file');
return redirect()->to(base_url('employee/upload'));
-
- }else if($return == 4){
+ } else if ($return == 4) {
session()->setFlashdata('error', 'The UHID column is either partially or entirely empty.');
return redirect()->to(base_url('employee/upload'));
-
- }else if($return == 5){
+ } else if ($return == 5) {
session()->setFlashdata('error', 'The list of employees provided has already been updated with the UHID, or this is not the correct file');
return redirect()->to(base_url('employee/upload'));
-
- }
-
- }else if($event_type == 'correction'){
+ } else if ($return == 6) {
+ session()->setFlashdata('error', 'The Excel record count exceeds the DB record count.');
+ return redirect()->to(base_url('employee/upload'));
+ }
+ } else if ($event_type == 'correction') {
$return = $empDataServiceController->importExcelDataForCorrection($batch_data);
- if($return == 1){
+ if ($return == 1) {
session()->setFlashdata('success', 'Data updated successfully');
return redirect()->to(base_url('employee/upload'));
-
- }else if($return == 2){
+ } else if ($return == 2) {
session()->setFlashdata('error', 'The Endorsement ID columns are empty.');
return redirect()->to(base_url('employee/upload'));
-
- }else if($return == 0){
+ } else if ($return == 0) {
session()->setFlashdata('error', 'Please upload the correct file');
return redirect()->to(base_url('employee/upload'));
- }else if($return == 3){
+ } else if ($return == 3) {
session()->setFlashdata('error', 'File already uploaded');
return redirect()->to(base_url('employee/upload'));
}
-
- }else if($event_type == 'si_enhancement'){
+ } else if ($event_type == 'si_enhancement') {
$return = $empDataServiceController->importExcelDataForSIEnhancement($batch_data);
- if($return == 1){
+ if ($return == 1) {
session()->setFlashdata('success', 'Data updated successfully');
return redirect()->to(base_url('employee/upload'));
-
- }else if($return == 2){
+ } else if ($return == 2) {
session()->setFlashdata('error', 'The Endorsement ID columns are empty.');
return redirect()->to(base_url('employee/upload'));
-
- }else if($return == 0){
+ } else if ($return == 0) {
session()->setFlashdata('error', 'Please upload the correct file');
return redirect()->to(base_url('employee/upload'));
- }else if($return == 3){
+ } else if ($return == 3) {
session()->setFlashdata('error', 'File already uploaded');
return redirect()->to(base_url('employee/upload'));
}
-
- }else if($event_type == 'deletion'){
+ } else if ($event_type == 'deletion') {
$return = $empDataServiceController->importExcelDataForDeletion($batch_data);
- if($return == 1){
+ if ($return == 1) {
session()->setFlashdata('success', 'Data updated successfully');
return redirect()->to(base_url('employee/upload'));
-
- }else if($return == 2){
+ } else if ($return == 2) {
session()->setFlashdata('error', 'The Endorsement ID columns are empty.');
return redirect()->to(base_url('employee/upload'));
-
- }else if($return == 0){
+ } else if ($return == 0) {
session()->setFlashdata('error', 'Please upload the correct file');
return redirect()->to(base_url('employee/upload'));
- }else if($return == 3){
+ } else if ($return == 3) {
session()->setFlashdata('error', 'File already uploaded');
return redirect()->to(base_url('employee/upload'));
}
-
}
-
}
-
-
}
-
+
// -------------------------------------------------------------------------------------------
@@ -512,18 +511,17 @@ class EmployeeController extends AdminController
{
$data = [];
- $data['status'] = ['pending' => 'Pending', 'inprogress' => 'In-Progress', 'complete'=>'Complete'];
- if(count($this->request->getGet()))
- {
+ $data['status'] = ['pending' => 'Pending', 'inprogress' => 'In-Progress', 'complete' => 'Complete'];
+ if (count($this->request->getGet())) {
$filterData = $this->request->getGet();
- $data['employees'] = $this->employeePolicyModel->getEmployeeEndorsementList(client_id: $filterData['client_id'],policy_id: $filterData['policy_id'], status: $filterData['status']);
+ $data['employees'] = $this->employeePolicyModel->getEmployeeEndorsementList(client_id: $filterData['client_id'], policy_id: $filterData['policy_id'], status: $filterData['status']);
$data['getData'] = $filterData;
// echo "";
// print_r($data); die;
}
-
- $this->myLogger->logme('error','list called');
- $this->loadLayout('endorsement_list',$data);
+
+ $this->myLogger->logme('error', 'list called');
+ $this->loadLayout('endorsement_list', $data);
}
@@ -541,13 +539,13 @@ class EmployeeController extends AdminController
{
// Create instance of EmpDataServiceController
$empDataServiceController = new EmpDataServiceController();
-
+
// Check if $id is provided
if ($id) {
// Retrieve group key and actions based on $id
$group_key_actions = $this->empEndorsementModel->select('group_key, actions')->where('id', $id)->first();
$groupedData = $this->empEndorsementModel->where('group_key', $group_key_actions['group_key'])->findAll();
-
+
// If group key and actions are found
if ($group_key_actions) {
// Retrieve endorsement data based on actions
@@ -567,7 +565,7 @@ class EmployeeController extends AdminController
$formatedData[0]['new_value'] = formatDateOrReturn($formatedData[0]['new_value']);
break;
}
-
+
// Return response with data
return $this->respond([
'dataStatus' => true,
@@ -575,7 +573,6 @@ class EmployeeController extends AdminController
'data' => $formatedData,
'data2' => $groupedData
], 200);
-
} else {
// Return response if group key and actions are not found
return $this->respond(['dataStatus' => false, 'code' => 404, 'message' => 'no data found'], 200);
@@ -591,21 +588,21 @@ class EmployeeController extends AdminController
// this funciton initiate Inception/adition/DA of employees data only form enrollment app when passing
// client_policy_id pull draft and enrolled status employees and proceed to calculatin and make entry in DB
public function initiateManualEmployeesOnboardProcess($client_policy_id)
- {
- $client_data = $this->clientPolicyModel->select('clients.client_name as client_name, policies.name as policy_name')
- ->join('clients', 'clients.id = client_policy.client_id')
- ->join('policies', 'policies.id = client_policy.policy_id')
- ->where('client_policy.id', $client_policy_id)
- ->first();
+ {
+ $client_data = $this->clientPolicyModel->select('clients.client_name as client_name, policies.name as policy_name')
+ ->join('clients', 'clients.id = client_policy.client_id')
+ ->join('policies', 'policies.id = client_policy.policy_id')
+ ->where('client_policy.id', $client_policy_id)
+ ->first();
- $empServiceController = new EmployeeServiceController();
- $res = $empServiceController->employeesOnboardPreprocess(['client_policy_id' => $client_policy_id]);
- // dd($res);
+ $empServiceController = new EmployeeServiceController();
+ $res = $empServiceController->employeesOnboardPreprocess(['client_policy_id' => $client_policy_id]);
+ // dd($res);
- $count = count($res);
- $message = $count . ' Employees are Initiate Onboard Process againts Client '. $client_data['client_name'] . ' and the Policy is ' . $client_data['policy_name'] ;
- session()->setFlashdata('success1', $message);
- return redirect()->to(base_url('/employee/upload'));
+ $count = count($res);
+ $message = $count . ' Employees are Initiate Onboard Process againts Client ' . $client_data['client_name'] . ' and the Policy is ' . $client_data['policy_name'];
+ session()->setFlashdata('success1', $message);
+ return redirect()->to(base_url('/employee/upload'));
}
@@ -641,18 +638,17 @@ class EmployeeController extends AdminController
echo $errorMessage;
}
}
-
-
+
+
public function featchEmpList()
{
- $client_id = $this->request->getGet('client_id');
- $policy_id = $this->request->getGet('policy_id');
+ $client_id = $this->request->getGet('client_id');
+ $policy_id = $this->request->getGet('policy_id');
- $emp_data['employees'] = $this->employeePolicyModel->getEmployeePolicyForFileList($client_id, $policy_id);
- $html = view('employee_data_list', $emp_data);
-
- return $this->respond(['dataStatus' => true,'code' => 200,'data' => $html], 200);
+ $emp_data['employees'] = $this->employeePolicyModel->getEmployeePolicyForFileList($client_id, $policy_id);
+ $html = view('employee_data_list', $emp_data);
+ return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => $html], 200);
}
@@ -662,37 +658,35 @@ class EmployeeController extends AdminController
// $emp_data['employees'] = $this->employeePolicyModel->getViewEmpSuccessList($file_id);
// $html = view('view_file_upload_emp_list', $emp_data);
$file_name = $this->fileModel
- ->select(['files.*','up.emp_code','up.first_name','pm.name as policy_name','c.short_name', 'cp.id as client_policy_id'])
- ->join('user_profiles up','files.created_by = up.id')
- ->join('client_policy cp','files.policy_id = cp.id','left')
- ->join('policies pm','cp.policy_id = pm.id','left')
- ->join('clients c','files.client_id = c.id and files.client_id = cp.client_id','left')
- ->where('files.id', $file_id)->first();
-
+ ->select(['files.*', 'up.emp_code', 'up.first_name', 'pm.name as policy_name', 'c.short_name', 'cp.id as client_policy_id'])
+ ->join('user_profiles up', 'files.created_by = up.id')
+ ->join('client_policy cp', 'files.policy_id = cp.id', 'left')
+ ->join('policies pm', 'cp.policy_id = pm.id', 'left')
+ ->join('clients c', 'files.client_id = c.id and files.client_id = cp.client_id', 'left')
+ ->where('files.id', $file_id)->first();
+
try {
$filePath = WRITEPATH . '/uploads/excel/' . $file_name['file_name'];
-
+
if (file_exists($filePath)) {
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($filePath);
$sheet = $spreadsheet->getActiveSheet();
-
+
$highestRowAndColumn = $sheet->getHighestRowAndColumn();
$excel_data = $sheet->rangeToArray('A1:' . $highestRowAndColumn['column'] . $highestRowAndColumn['row']);
// dd($excel_data);
$emp_data['thead'] = $excel_data[0];
unset($excel_data[0]);
$emp_data['tbody'] = $excel_data;
-
- $html = view('view_file_upload_emp_list', $emp_data);
+ $html = view('view_file_upload_emp_list', $emp_data);
} else {
$html = 'No Data Found
';
}
-
- return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => $html, 'file_data' => $file_name, 'excel_data' => $excel_data], 200);
+ return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => $html, 'file_data' => $file_name, 'excel_data' => $excel_data], 200);
} catch (\Exception $e) {
// Handle exception
$errorMessage = 'Error occurred: ' . $e->getMessage();
@@ -702,209 +696,298 @@ class EmployeeController extends AdminController
}
}
- public function getEmpCount($id = null){
- $data = $this->employeePolicyModel->select('employee_polices.id')
- ->where('employee_polices.is_active', 1)
- ->where('employee_polices.client_policy_id', $id)
- ->findAll();
+ public function getEmpCount($id = null)
+ {
- $emp_count = count($data);
+ $data = $this->employeePolicyModel->select('employee_polices.id')
+ ->where('employee_polices.is_active', 1)
+ ->where('employee_polices.client_policy_id', $id)
+ ->findAll();
- if($data){
- return $this->respond(['dataStatus' => true, 'code' => 200, 'emp_count' => $emp_count], 200);
-
- }else{
-
- return $this->respond(['dataStatus' => false, 'code' => 404], 404);
-
- }
+ $emp_count = count($data);
+ if ($data) {
+ return $this->respond(['dataStatus' => true, 'code' => 200, 'emp_count' => $emp_count], 200);
+ } else {
+ return $this->respond(['dataStatus' => false, 'code' => 404], 404);
+ }
}
+
public function downloadFullExcelErrorFile($file_id, $rowIndex = 1, $colIndex = 1)
{
// Get file data from the database
$file_data = $this->fileModel->find($file_id);
$error = json_decode($file_data['reason']);
- // echo '';
- // print_r($error); die;
- // dd($error);
-
- // Check if the file exists
- if (!$file_data) {
- $error_message = "File not found";
- $this->myLogger->logme('error', $error_message . ' for file id ' . $file_id);
- return $error_message;
- }
-
- $fileName = $file_data['file_name'];
- $filePath = WRITEPATH . '/uploads/excel/' . $fileName;
-
- // Check if the file exists
- if (!file_exists($filePath)) {
- $error_message = "File not found";
- $this->myLogger->logme('error', $error_message . ' for file id ' . $file_id);
- return $error_message;
- }
-
- // Load the Excel file
- $spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($filePath);
- $sheet = $spreadsheet->getActiveSheet();
-
- // echo '';
-
- foreach ($error->error_data as $index => $error_data) {
-
- $rowIndex = $index+1;
-
- if( $error->error_type == 1 ){
-
- foreach ($error_data as $key => $value) {
-
- $colIndex = $value->col_idx+1;
-
- $originalValue = $sheet->getCell([$colIndex, $rowIndex])->getValue();
-
- $newValue = implode(', ',$value->error);
- $val = $originalValue . ' ( ' . $newValue . ' )';
- $sheet->setCellValue([$colIndex, $rowIndex], $val);
-
- $style = [
- 'fill' => [
- 'fillType' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID,
- 'startColor' => ['rgb' => 'ffad99'] // Red color
- ]
- ];
-
- $sheet->getStyle([$colIndex, $rowIndex])->applyFromArray($style);
-
- }
- }else if( $error->error_type == 2){
-
-
- foreach ($error_data as $key => $value) {
-
-
- $originalValue = $sheet->getCell([1, $rowIndex])->getValue();
-
- $newValue = implode(', ',$value->error);
- $val = $originalValue . ' ( ' . $newValue . ' )';
- $sheet->setCellValue([$colIndex, $rowIndex], $val);
-
- $style = [
- 'fill' => [
- 'fillType' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID,
- 'startColor' => ['rgb' => 'ffad99'] // Red color
- ]
- ];
- $sheet->getStyle([$colIndex, $rowIndex])->applyFromArray($style);
-
- }
-
- }
+ // echo '';
+ // print_r($error); die;
+ // dd($error);
+ // Check if the file exists
+ if (!$file_data) {
+ $error_message = "File not found";
+ $this->myLogger->logme('error', $error_message . ' for file id ' . $file_id);
+ return $error_message;
}
-
-
- // Create a new filename for the modified Excel file
- $newFileName = 'error_with_highlight_' . $fileName;
-
- // Save the modified Excel file to a new location
- $newFilePath = WRITEPATH . '/uploads/excel/' . $newFileName;
- $writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet);
- $writer->save($newFilePath);
-
- // Set headers to force download
- $response = service('response');
- $response->setHeader('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
- $response->setHeader('Content-Disposition', 'attachment;filename="' . $newFileName . '"');
- $response->setHeader('Cache-Control', 'max-age=0');
- $response->setHeader('Content-Length', filesize($newFilePath));
- $response->setBody(file_get_contents($newFilePath));
-
- // Delete the temporary file
- unlink($newFilePath);
-
- // Return the response
- return $response;
+ $fileName = $file_data['file_name'];
+ $filePath = WRITEPATH . '/uploads/excel/' . $fileName;
+
+ // Check if the file exists
+ if (!file_exists($filePath)) {
+ $error_message = "File not found";
+ $this->myLogger->logme('error', $error_message . ' for file id ' . $file_id);
+ $data['message'] = 'Physical File Not Found';
+ return view('errors/404', $data);
+ }
+
+ // Load the Excel file
+ $spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($filePath);
+ $sheet = $spreadsheet->getActiveSheet();
+
+ // echo '';
+
+ foreach ($error->error_data as $index => $error_data) {
+
+ $rowIndex = $index + 1;
+
+ if ($error->error_type == 1) {
+
+ foreach ($error_data as $key => $value) {
+
+ $colIndex = $value->col_idx + 1;
+
+ $originalValue = $sheet->getCell([$colIndex, $rowIndex])->getValue();
+
+ $newValue = implode(', ', $value->error);
+ $val = $originalValue . ' ( ' . $newValue . ' )';
+ $sheet->setCellValue([$colIndex, $rowIndex], $val);
+
+ $style = [
+ 'fill' => [
+ 'fillType' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID,
+ 'startColor' => ['rgb' => 'ffad99'] // Red color
+ ]
+ ];
+
+ $sheet->getStyle([$colIndex, $rowIndex])->applyFromArray($style);
+ }
+ } else if ($error->error_type == 2) {
+
+
+ foreach ($error_data as $key => $value) {
+
+
+ $originalValue = $sheet->getCell([1, $rowIndex])->getValue();
+
+ $newValue = implode(', ', $value->error);
+ $val = $originalValue . ' ( ' . $newValue . ' )';
+ $sheet->setCellValue([$colIndex, $rowIndex], $val);
+
+ $style = [
+ 'fill' => [
+ 'fillType' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID,
+ 'startColor' => ['rgb' => 'ffad99'] // Red color
+ ]
+ ];
+ $sheet->getStyle([$colIndex, $rowIndex])->applyFromArray($style);
+ }
+ }
+ }
+
+
+
+ // Create a new filename for the modified Excel file
+ $newFileName = 'error_with_highlight_' . $fileName;
+
+ // Save the modified Excel file to a new location
+ $newFilePath = WRITEPATH . '/uploads/excel/' . $newFileName;
+ $writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet);
+ $writer->save($newFilePath);
+
+ // Set headers to force download
+ $response = service('response');
+ $response->setHeader('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
+ $response->setHeader('Content-Disposition', 'attachment;filename="' . $newFileName . '"');
+ $response->setHeader('Cache-Control', 'max-age=0');
+ $response->setHeader('Content-Length', filesize($newFilePath));
+ $response->setBody(file_get_contents($newFilePath));
+
+ // Delete the temporary file
+ unlink($newFilePath);
+
+ // Return the response
+ return $response;
}
+
public function generateIDCardForEmployee($rand_string)
{
- $get_emp_code_and_client_policy_id = $this->employeePolicyModel
- ->select('employee_polices.client_policy_id, employees.emp_code')
- ->join('employees', 'employees.id = employee_polices.employee_id')
- ->where('employees.emp_status', 'active')
- ->where('employees.is_active', '1')
- ->where('employee_polices.status', 'active')
- ->where('employee_polices.is_active', '1')
- ->where('employee_polices.rand_string', $rand_string)->first();
- if($get_emp_code_and_client_policy_id == null || $get_emp_code_and_client_policy_id == ""){
+ try {
- $data['message'] = 'Record Not Found';
- return view('errors/404', $data);
+ $get_emp_code_and_client_policy_id = $this->employeePolicyModel
+ ->select('employee_polices.client_policy_id, employees.emp_code, tpa.short_name')
+ ->join('client_policy', 'client_policy.id = employee_polices.client_policy_id')
+ ->join('employees', 'employees.id = employee_polices.employee_id')
+ ->join('tpa', 'tpa.id = client_policy.tpa_id')
+ ->where('employees.emp_status', 'active')
+ ->where('employees.is_active', '1')
+ ->where("employee_polices.tpa_id IS NOT NULL AND employee_polices.tpa_id <> ''")
+ ->where('employee_polices.status', 'active')
+ ->where('employee_polices.is_active', '1')
+ ->where('employee_polices.rand_string', $rand_string)->first();
- }
+ // dd($get_emp_code_and_client_policy_id);
- $client_policy_id = $get_emp_code_and_client_policy_id['client_policy_id'];
- $emp_code = $get_emp_code_and_client_policy_id['emp_code'];
- $data['data'] = $this->employeePolicyModel->getECardDataUsingMd5($client_policy_id, $emp_code);
- // $this->loadLayout('id_card_view', $data);exit;
- $html = view('id_card_view', $data);
+ if ($get_emp_code_and_client_policy_id == null || $get_emp_code_and_client_policy_id == "") {
- $dompdf = new Dompdf();
- $dompdf->loadHtml($html);
- $dompdf->setPaper('A4', 'landscape');
- $dompdf->render();
-
- $filename = 'ECard.pdf'; // Default filename
-
- foreach ($data['data'] as $key => $value) {
-
- if ($value['relationship'] == "Self") {
-
- $filename = $value['tpa_id']; // Update filename if relationship is "Self"
-
- } elseif (!empty($value['tpa_id']) && $filename == 'ECard.pdf') {
-
- $filename = $value['tpa_id'];
+ $data['message'] = 'Record Not Found';
+ return view('errors/404', $data);
}
- }
- $dompdf->stream($filename);
+ $client_policy_id = $get_emp_code_and_client_policy_id['client_policy_id'];
+ $emp_code = $get_emp_code_and_client_policy_id['emp_code'];
+
+ // $data['data'] = $this->employeePolicyModel->getECardDataUsingMd5($client_policy_id, $emp_code);
+ $data = $this->employeePolicyModel->getECardDataUsingMd5($client_policy_id, $emp_code);
+
+ $template_data_path = WRITEPATH . 'e_card_template/';
+ $tpa_short_name = strtolower(str_replace(' ', '_', $get_emp_code_and_client_policy_id['short_name'])) . '.html';
+ $final_path = $template_data_path . $tpa_short_name;
+
+ if (!file_exists($final_path)) {
+
+ $data['message'] = 'Record Not Found';
+ return view('errors/404', $data);
+ }
+
+ $tmplt_data = file_get_contents($final_path);
+
+
+ $html = ""; // Initialize the HTML variable
+ foreach ($data as $key => $value) {
+
+ // Get the HTML content from the template
+ // $htmlContent = view('ecard_template/md_tpa');
+ $htmlContent = $tmplt_data;
+
+ // Define the placeholders and their corresponding values
+ $placeholders = [
+ '{TPA_ID}' => $value['tpa_id'],
+ '{NAME}' => $value['name'],
+ '{UHID}' => $value['uhid'],
+ '{GENDER}' => $value['gender'],
+ '{DOB}' => date('d-M-Y', strtotime($value['dob'])),
+ '{SELF_NAME}' => $value['self'] ?? $value['name'],
+ '{POLICY_DATE}' => date('d-M-Y', strtotime($value['policy_end_date'])),
+ '{INSURER_NAME}' => $value['insurer_name'],
+ '{INSURER_LOGO}' => base_url() . 'public/uploads/logo/' . $value['insurer_logo'],
+ '{FRONT_CARD}' => base_url() . 'public/uploads/template_bg/' . $value['front_card'],
+ '{BACK_CARD}' => base_url() . 'public/uploads/logo/' . $value['back_card'],
+ '{EMP_ID}' =>$value['emp_code'],
+ '{CORPORATE_NAME}' =>$value['client_name'],
+ '{AGE}' =>$value['emp_age'],
+ ];
+
+ // Replace placeholders with values in HTML content
+ foreach ($placeholders as $placeholder => $replaceValue) {
+ $htmlContent = str_replace($placeholder, $replaceValue, $htmlContent);
+ }
+
+ $html .= $htmlContent;
+ }
+
+ echo '' . $html . '
+ ';
+
+
+
+ // $file_name = $get_emp_code_and_client_policy_id['short_names'] ?? 'md_tpa';
+ // $file_name = strtolower(str_replace(' ', '_', $file_name));
+
+
+
+ // $file_path = ROOTPATH . 'app/Views/ecard_template/' . $file_name . '.php';
+
+ // if (is_file($file_path)) {
+ // $view_file = 'ecard_template/' . $file_name;
+
+ // } else {
+ // $view_file = 'ecard_template/default_ecard';
+
+ // }
+
+
+ // $dpi = 132;
+ // $html = view('ecard_template/md_tpa');
+ // // echo $html; die;
+
+ // $options = new Options();
+ // $options->set('isRemoteEnabled', true);
+ // $options->set('isPhpEnabled', true);
+ // $options->setDpi($dpi);
+ // $dompdf = new Dompdf($options);
+
+ // $dompdf->loadHtml($html);
+ // $dompdf->setPaper('A4', 'portrait');
+ // $dompdf->render();
+
+
+ // $filename = 'ECard.pdf'; // Default filename
+
+ // foreach ($data['data'] as $key => $value) {
+
+ // if ($value['relationship'] == "Self") {
+
+ // $filename = $value['tpa_id'] . '.pdf'; // Update filename if relationship is "Self"
+ // } elseif (!empty($value['tpa_id']) && $filename == 'ECard.pdf') {
+
+ // $filename = $value['tpa_id'] . '.pdf';
+ // }
+ // }
+
+ // $dompdf->stream($filename, array("Attachment" => false));
+
+ } catch (\Exception $e) {
+
+ $data['message'] = 'Record Not Founds';
+ return view('errors/404', $data);
+ }
}
+
public function viewECard()
{
- $this->loadLayout('id_card_view');
-
+ $this->loadLayout('ecard_template/default_ecard');
}
+
public function truncateFileData() //truncateFileDataIn DB (de activate rows)
{
- $file_id = $this->request->uri->getSegment(3);
- // $file_id = 112;
- $file = $this->fileModel->find($file_id);
- // $file['action'] = 'si_enhancement';
- // $result = [];
- // !dd($file);
- if($file['action'] == 'inception' || $file['action'] == 'dependent_addition' || $file['action'] == 'addition')
- {
- $result = $this->employeeModel->getEmpListByFileId(file_id: $file_id,emp_status: ['active'],policy_status:['active']);
+ $file_id = $this->request->uri->getSegment(3);
+ // $file_id = 112;
+ $file = $this->fileModel->find($file_id);
+ // $file['action'] = 'si_enhancement';
+ // $result = [];
+ // !dd($file);
+ if ($file['action'] == 'inception' || $file['action'] == 'dependent_addition' || $file['action'] == 'addition') {
+ $result = $this->employeeModel->getEmpListByFileId(file_id: $file_id, emp_status: ['active'], policy_status: ['active']);
// ~dd($result);
- if(count($result))
- {
- return $this->respond(['dataStatus' => false,'code' => 404,'message' => 'File data already processed'], 200);
- }
- else
- {
+ if (count($result)) {
+ return $this->respond(['dataStatus' => false, 'code' => 404, 'message' => 'File data already processed'], 200);
+ } else {
//update emp and emp plocies
$db = db_connect();
@@ -916,41 +999,146 @@ class EmployeeController extends AdminController
//update file status
$this->fileModel->where('id', $file_id)->set(['status' => 'truncated'])->update();
- return $this->respond(['dataStatus' => true,'code' => 200,'data' => round($affectedRows/2)], 200);
- }
- }
- else if($file['action'] == 'si_enhancement' || $file['action'] == 'correction' || $file['action'] == 'deletion')
- {
+ return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => round($affectedRows / 2)], 200);
+ }
+ } else if ($file['action'] == 'si_enhancement' || $file['action'] == 'correction' || $file['action'] == 'deletion') {
$res = $this->empEndorsementModel->select(['count(id) as count'])
- ->where('emp_endorsement.file_id',$file_id)
- ->groupStart()
- ->where('emp_endorsement.endorsement_id is not null')
- ->orwhereIn('emp_endorsement.status',['complete'])
- ->groupEnd()
- ->get()
- ->getResult();
+ ->where('emp_endorsement.file_id', $file_id)
+ ->groupStart()
+ ->where('emp_endorsement.endorsement_id is not null')
+ ->orwhereIn('emp_endorsement.status', ['complete'])
+ ->groupEnd()
+ ->get()
+ ->getResult();
// print_r($this->empEndorsementModel->getLastQuery());
- // echo $res[0]->count;die();
- if($res[0]->count == 0)
- {
+ // echo $res[0]->count;die();
+ if ($res[0]->count == 0) {
//update truncated status to db
- $this->empEndorsementModel->where('file_id',$file_id)
- ->set(['status' => 'truncated'])
- ->update();
+ $this->empEndorsementModel->where('file_id', $file_id)
+ ->set(['status' => 'truncated'])
+ ->update();
//update file status
$this->fileModel->where('id', $file_id)->set(['status' => 'truncated'])->update();
- return $this->respond(['dataStatus' => true,'code' => 200,'data' => 'success'], 200);
+ return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => 'success'], 200);
+ } else {
+ return $this->respond(['dataStatus' => false, 'code' => 404, 'message' => 'File data already processed'], 200);
}
- else
- {
- return $this->respond(['dataStatus' => false,'code' => 404,'message' => 'File data already processed'], 200);
- }
- }
-
+ }
}
-
-
-
-
-
-}
\ No newline at end of file
+
+
+ public function previewTemplate($id = null){
+
+
+ $tpa_id = $this->TPAModel->where('id', $id)->first();
+
+ $template_data_path = WRITEPATH . 'e_card_template/';
+ $tpa_short_name = strtolower(str_replace(' ', '_', $tpa_id['short_name'])) . '.html';
+ $final_path = $template_data_path . $tpa_short_name;
+
+ if (!file_exists($final_path)) {
+
+ $data['message'] = 'Record Not Found';
+ return view('errors/404', $data);
+ }
+
+ $tmplt_data = file_get_contents($final_path);
+
+ $placeholders = [
+ '{FRONT_CARD}' => base_url() . 'public/uploads/template_bg/' . $tpa_id['front_card'],
+ '{BACK_CARD}' => base_url() . 'public/uploads/logo/' . $tpa_id['back_card'],
+ ];
+
+ // Get the values to replace the placeholders
+ $replaceValues = array_values($placeholders);
+
+ // Get the placeholders to search for
+ $searchPlaceholders = array_keys($placeholders);
+
+ // Replace placeholders with values in HTML content
+ $htmlContent = str_replace($searchPlaceholders, $replaceValues, $tmplt_data);
+
+
+ echo $htmlContent;
+
+
+ }
+
+
+ public function errorListExportImport($file_id)
+ {
+
+ $empDataServiceController = new EmpDataServiceController();
+
+ $file = $this->batchFileModel->where('id', $file_id)->first();
+ $client_id = $file['client_id'];
+ $client_policy_id = $file['client_policy_id'];
+ $insurer_or_tpa = $file['insurer_or_tpa'];
+
+ $error_data = json_decode($file['error_data']);
+
+ $file_name_with_path = WRITEPATH . "/uploads/import_excel/" . $file['file_name'];
+
+ if (!file_exists($file_name_with_path)) {
+ $error_message = "File not found";
+ $this->myLogger->logme('error', ($error_message . ' for file id ' . $file_id));
+ $data['message'] = 'Physical File Not Found';
+ return view('errors/404', $data);
+ }
+
+ $excel_data = $empDataServiceController->readExcelFileToArray($file_name_with_path);
+ $excelErrorData['excel_header'] = $excel_data[0];
+ unset($excel_data[0]);
+ array_pop($excel_data);
+
+
+ $finalArray = [];
+ foreach ($error_data as $key => $values) {
+
+ foreach ($values as $key2 => $value) {
+
+ $row = $value->row;
+ $column = $value->column;
+
+ if(property_exists($value, 'db_data')){
+
+ $error = 'Expected value: ' . ($value->db_data == null || $value->db_data == "" ? 'NULL' : $value->db_data);
+
+ }else{
+
+ if ($insurer_or_tpa == 'tpa') {
+
+ $error = 'Expected value : TPA ID';
+
+ } else if ($insurer_or_tpa == 'insurer') {
+
+ $error = 'Expected value : UHID';
+ }
+
+ }
+ $data = ['value' => $excel_data[$row][$column], 'error' => $error,];
+ $excel_data[$row][$column] = $data;
+ }
+
+ array_push($finalArray, $excel_data[$key]);
+ }
+
+
+ foreach ($finalArray as $fkey => $value) {
+ foreach ($value as $vkey => $arrayData) {
+ if (!is_array($arrayData)) {
+ $data = ['value' => $arrayData];
+ $finalArray[$fkey][$vkey] = $data;
+ }
+ }
+ }
+
+ $excelErrorData['excel_data'] = $finalArray;
+ $excelErrorData['file_id'] = $file_id;
+
+ // dd($finalArray);
+
+ echo view('export_import_error_list', $excelErrorData);
+ }
+
+}
diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php
index 33db711e..3c8a145d 100644
--- a/app/Controllers/EmployeeRestController.php
+++ b/app/Controllers/EmployeeRestController.php
@@ -9,16 +9,22 @@ use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
+use App\Helpers\sendMailNotification;
+
use App\Models\EmployeeModel;
use App\Models\EmployeePolicyModel;
use App\Models\ClientModel;
+use App\Models\ClientRMModel;
use App\Models\PolicesModel;
use App\Models\RelationshipModel;
use App\Models\FileModel;
use App\Models\ClientPolicyModel;
use App\Models\PolicyPremium1Model;
use App\Models\PolicyPremium2Model;
+use App\Models\PolicyTypeModel;
+use App\Models\NotificationModel;
+use App\Models\UserModel;
use App\Controllers\Jobs ;
use App\Controllers\JobWorker ;
@@ -41,13 +47,17 @@ class EmployeeRestController extends AdminController
protected $employeeModel;
protected $employeePolicyModel;
protected $clientModel;
+ protected $clientRMModel;
protected $fileModel;
protected $policesModel;
protected $relationshipModel;
protected $clientPolicyModel;
protected $policyPremium1Model;
protected $policyPremium2Model;
-
+ protected $policyTypeModel;
+ protected $notificationModel;
+ protected $userModel;
+
public function __construct()
{
// helper('utility');
@@ -56,15 +66,19 @@ class EmployeeRestController extends AdminController
$this->employeeModel = new EmployeeModel();
$this->employeePolicyModel = new EmployeePolicyModel();
$this->clientModel = new ClientModel();
+ $this->clientRMModel = new ClientRMModel();
$this->policesModel = new PolicesModel();
$this->relationshipModel = new RelationshipModel();
$this->fileModel= new FileModel();
$this->clientPolicyModel = new ClientPolicyModel();
$this->policyPremium1Model = new PolicyPremium1Model();
$this->policyPremium2Model = new PolicyPremium2Model();
+ $this->policyTypeModel = new PolicyTypeModel();
+ $this->notificationModel = new NotificationModel();
+ $this->userModel = new UserModel();
}
-
+
public function getEmployeeProfile()
{
try {
@@ -301,7 +315,7 @@ class EmployeeRestController extends AdminController
->where('client_policy_id',$value['policy_details']['client_policy_id'] )
->where('employee_id' , $value['temp']['emp_id'] )
->where('is_active', 1 )
- ->set(array('premium'=> $value['policy_details']['premium'] , 'gst'=> $value['policy_details']['gst'] ))
+ ->set(array('premium'=> $value['policy_details']['premium'] , 'rata_premimum'=> $value['policy_details']['rata_premimum'] , 'gst'=> $value['policy_details']['gst'] ))
->update();
}
@@ -518,134 +532,7 @@ class EmployeeRestController extends AdminController
}
- // public function getEmployeePolicy()
- // {
- // try {
- // $id = $this->request->getGet('id');
- // $emp_code = $this->request->getGet('emp_code');
-
- // $keysToRemove = ["removable_keys"];
-
- // $empPolicy = $this->employeeModel->getEmployeePolicy($id);
-
- // $empData = $this->employeeModel->where('emp_code',$emp_code)->findAll();
- // if ($empPolicy) {
-
- // $result = [];
- // foreach ($empPolicy as $array) {
-
- // $decodedArray = json_decode($array->Policy_Terms);
- // $refusingData = (object) array_diff_key((array) $decodedArray, array_flip($keysToRemove));
-
-
- // $array->Policy_Terms = $refusingData;
- // $getSlabAndGridData = $this->policesModel->getPolicySlabRatesForEmpOnboard($array->ClientPolicyId,$array->ClientId);
- // $array->SlabRates = $getSlabAndGridData['slab_rates'];
- // $array->GridMaster = $getSlabAndGridData['grid_master'];
-
- // if($getSlabAndGridData['grid_master']['policy_type'] == "GPA"){
- // $default_si = $array->Policy_Terms->sumInsured2;
- // $index = -1;
- // foreach ($array->SlabRates as $key => $value) {
- // if ($value['si'] == $default_si) {
- // $index = $key;
- // break;
- // }
- // }
- // if ($index >= 0) {
- // $element =$array->SlabRates[$index];
- // array_splice($array->SlabRates, $index, 1);
- // array_unshift($array->SlabRates, $element);
- // }
-
- // $employee_policy = $this->employeePolicyModel->where('employee_id',$id)->where('client_policy_id',$array->ClientPolicyId)->get()->getRow();
- // if($employee_policy){
- // $gpaSI['family_floater_key'] = 'self';
- // $gpaSI['label'] = 'Self';
- // $gpaSI['employee_id'] = $employee_policy->employee_id;
- // $gpaSI['basic_cover_si'] = isset($employee_policy->basic_cover_si) ? $employee_policy->basic_cover_si : null;
- // $gpaSI['premium'] = isset($employee_policy->premium) ? $employee_policy->premium : null;
- // $gpaSI['client_policy_id'] = $array->ClientPolicyId;
-
- // $array->mapped_family_floaters = $gpaSI;
- // }else{
- // $gpaSI['family_floater_key'] = 'self';
- // $gpaSI['label'] = 'Self';
- // $gpaSI['employee_id'] = $id;
- // $gpaSI['basic_cover_si'] = null;
- // $gpaSI['premium'] = null;
- // $gpaSI['client_policy_id'] = $array->ClientPolicyId;
-
- // $array->mapped_family_floaters = $gpaSI;
- // }
-
- // }else if($getSlabAndGridData['grid_master']['policy_type'] == "GMC"){
-
- // // re-arranging order of si
- // $default_si = $array->Policy_Terms->sum_insured;
- // // Filter the array using the callback function
- // $getPremium = array_filter($array->SlabRates , function ($value) use ($default_si) { return $value['si'] == $default_si; } );
- // $default_premium = $getPremium[0]['premium'];
-
- // $index = -1;
- // foreach ($array->SlabRates as $key => $value) {
- // if ($value['si'] == $default_si) {
- // $index = $key;
- // break;
- // }
- // }
- // if ($index >= 0) {
- // $element =$array->SlabRates[$index];
- // array_splice($array->SlabRates, $index, 1);
- // array_unshift($array->SlabRates, $element);
- // }
-
- // //map family floates array to employee and dependent
- // $familyFloates = $array->Policy_Terms->family_floaters;
- // $data = [];
- // foreach ($familyFloates 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)->get()->getRow();
- // $temp['family_floater_key'] = $familyFloatesValue;
- // $temp['label'] = $value['relationship'];
- // $temp['name'] = $value['name'];
- // $temp['employee_id'] = $value['id'];
- // $temp['basic_cover_si'] = isset($employee_policy->basic_cover_si) ? $employee_policy->basic_cover_si : null;
- // $temp['premium'] = isset($employee_policy->premium) ? $employee_policy->premium : null;
- // $temp['client_policy_id'] = $array->ClientPolicyId;
- // array_push($data,$temp);
- // unset($empData[$key]);
- // break;
- // }
- // }
- // }
- // }
- // $array->mapped_family_floaters = $data;
-
- // $temp2=[];
- // foreach ($array->SlabRates as $key => $value) {
- // $value['additional_premium'] = $value['premium'] - $default_premium;
- // array_push($temp2,$value);
- // }
- // $array->SlabRates = $temp2;
-
-
-
- // }
-
- // $result[] = $array;
- // }
- // return $this->respond(['status' => 'success','code' => 200,'data' => $result], 200);
- // }else{
- // return $this->respond(['status' => 'failed','code' => 404,'data' => []], 404);
- // }
- // } catch (\Exception $e) {
- // return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500);
- // }
- // }
+
// Get the RelationShip list
@@ -718,14 +605,26 @@ class EmployeeRestController extends AdminController
// Upload the Employee Detail in DB by Sheet Data
public function employeeUpload()
{
+
+
+
+
try {
+ // echo $this->request->getPost('client_id');
+ // die;
$file = $this->request->getFile('file');
$client_id = $this->request->getPost('client_id');
$policy_id = $this->request->getPost('policy_id');
+ $client_data = $this->clientModel->where('id', $client_id)->first();
+
+ $notification = $this->notificationModel->where('client_id',$client_id)->where('template_name','member_welcome_mail')->first();
+
$jwt = $this->request->getHeader('Authorization');
$jwtParts = explode(' ', $jwt);
+ // print_r($jwtParts);die;
$token = $jwtParts[2];
+ // return "hello";
$decodedPayload = json_decode(base64_decode(explode('.', $token)[1]), true);
@@ -735,7 +634,6 @@ class EmployeeRestController extends AdminController
$client_policy = $this->clientPolicyModel->where('id', $policy_id)->where('client_id', $client_id)->first();
-
if ($client_policy) {
$policy = $this->policesModel->where('id', $client_policy['policy_id'])->first();
$policy_permium_1 = $this->policyPremium1Model->where(['client_id' => $client_id , 'client_policy_id' => $policy_id,'is_active' =>1])-> first();
@@ -911,105 +809,98 @@ class EmployeeRestController extends AdminController
$count = 0;
for ($a=0; $a employeeModel->checkExistingEmployee($dataToInsert[$a]);
- $emp_id =0;
-
- $data_after_gpa_or_gmc =[];
- if ($policy['policy_type_id'] == 1) {
- if (strtolower($dataToInsert[$a]['relationship']) == 'self') {
- $data_after_gpa_or_gmc = $dataToInsert[$a];
- }
- }else{
- $data_after_gpa_or_gmc = $dataToInsert[$a];
- }
- date_default_timezone_set('Asia/Kolkata');
- $current_timestamp = time();
- $formatted_date_time = date('Y-m-d H:i:s', $current_timestamp);
-
- if ($employee) {
-
-
- $emp_id =$employee['id'];
- $id =$emp_id;
- $data_after_gpa_or_gmc['id'] = $id;
- $data_after_gpa_or_gmc['updated_by'] = $employee_id;
- $data_after_gpa_or_gmc['updated_at'] = $formatted_date_time;
- $result = $this->employeeModel->save($data_after_gpa_or_gmc);
- if ($result) {
- $log_message = 'Update Employee - '.$employee['name'].'('.$employee['emp_code'].') with PK '.$employee['id'];
- $this->myLogger->logme('error',('Update - ' . $employee['id'].' - '. $employee['emp_code'] .' - '.$employee['name']));
- }
- }else{
- if ($dataToInsert[$a]['emp_code'] != 0) {
- $result =false;
- if (count($data_after_gpa_or_gmc) != 0) {
- $data_after_gpa_or_gmc['created_by'] = $employee_id;
- $result = $this->employeeModel->insert($data_after_gpa_or_gmc);
- }
- $emp_id =$result;
- if ($result) {
- $emp = $this->employeeModel->where('id', $result)->get()->getResult();
-
- $policy_name = $this->employeePolicyModel->where('employee_id', $result)->get()->getResult();;
-
-
- $log_message = 'Insert Employee- '.$dataToInsert[$a]['name'] .'('.$dataToInsert[$a]['emp_code'] .') with PK ';
- $this->myLogger->logme('error',('Insert - ' . $dataToInsert[$a]['emp_code'] .' - '. $dataToInsert[$a]['name']));
- }
- }
- }
- $emp_policy_data =[
- 'employee_id'=>$emp_id,
- 'client_policy_id'=>$policy_id,
- 'status'=> 'draft',
- 'basic_cover_si'=>isset($basic_cover_si[$a]) ? $basic_cover_si[$a] : null
- ];
-
- $employee_policy = $this->employeePolicyModel->checkExistingEmpPolicy(['employee_id' => $emp_id,'client_policy_id' => $policy_id]);
- if ($employee_policy) {
- foreach ($employee_policy as $existing_policy) {
- $emp_policy_data['id']= $existing_policy['id'];
- $emp_policy_data['updated_at'] = $formatted_date_time;
- $this->employeePolicyModel->save($emp_policy_data);
- }
- } else {
- $emp_policy = $this->employeePolicyModel->insert($emp_policy_data);
- }
-
-
- //trigger
- $mail = $dataToInsert[$a]['email_corporate'];
- $subject = 'Welcome, Employee Benefit Program Enrolment';
- // $message = 'Dear ' . $dataToInsert[$a]['name'] . ",
We are glad to welcome you to the employee benefit program ," .$policy_name['name'] ."offered by your employer,
Click on the link below to review your personal and family details:
Review Details" ;
- $data['employee_name']=$dataToInsert[$a]['name'];
- $data['policy_name']=$policy['name'];
- $data['App_Url'] = $_ENV['App_Url'];
+ $employee = $this->employeeModel->checkExistingEmployee($dataToInsert[$a]);
+ $emp_id =0;
- $message = view('mail_welcome', $data);
+ $data_after_gpa_or_gmc =[];
+ if ($policy['policy_type_id'] == 1) {
+ if (strtolower($dataToInsert[$a]['relationship']) == 'self') {
+ $data_after_gpa_or_gmc = $dataToInsert[$a];
+ }
+ }else{
+ $data_after_gpa_or_gmc = $dataToInsert[$a];
+ }
+ date_default_timezone_set('Asia/Kolkata');
+ $current_timestamp = time();
+ $formatted_date_time = date('Y-m-d H:i:s', $current_timestamp);
- if ($dataToInsert[$a]['relationship'] == 'Self' && $mail != null || $mail != '') {
- $count++;
- $wholeData[] = ['mail' => $mail, 'subject' => $subject,'message'=> $message];
+ if ($employee) {
+
+
+ $emp_id =$employee['id'];
+ $id =$emp_id;
+ $data_after_gpa_or_gmc['id'] = $id;
+ $data_after_gpa_or_gmc['updated_by'] = $employee_id;
+ $data_after_gpa_or_gmc['updated_at'] = $formatted_date_time;
+ $result = $this->employeeModel->save($data_after_gpa_or_gmc);
+ if ($result) {
+ $log_message = 'Update Employee - '.$employee['name'].'('.$employee['emp_code'].') with PK '.$employee['id'];
+ $this->myLogger->logme('error',('Update - ' . $employee['id'].' - '. $employee['emp_code'] .' - '.$employee['name']));
+ }
+ }else{
+ if ($dataToInsert[$a]['emp_code'] != 0) {
+ $result =false;
+ if (count($data_after_gpa_or_gmc) != 0) {
+ $data_after_gpa_or_gmc['created_by'] = $employee_id;
+ $result = $this->employeeModel->insert($data_after_gpa_or_gmc);
+ }
+ $emp_id =$result;
+ if ($result) {
+ $emp = $this->employeeModel->where('id', $result)->get()->getResult();
+
+ $policy_name = $this->employeePolicyModel->where('employee_id', $result)->get()->getResult();;
+
+
+ $log_message = 'Insert Employee- '.$dataToInsert[$a]['name'] .'('.$dataToInsert[$a]['emp_code'] .') with PK ';
+ $this->myLogger->logme('error',('Insert - ' . $dataToInsert[$a]['emp_code'] .' - '. $dataToInsert[$a]['name']));
+ }
+ }
+ }
+ $emp_policy_data =[
+ 'employee_id'=>$emp_id,
+ 'client_policy_id'=>$policy_id,
+ 'status'=> 'draft',
+ 'basic_cover_si'=>isset($basic_cover_si[$a]) ? $basic_cover_si[$a] : null
+ ];
+
+ $employee_policy = $this->employeePolicyModel->checkExistingEmpPolicy(['employee_id' => $emp_id,'client_policy_id' => $policy_id]);
+ if ($employee_policy) {
+ foreach ($employee_policy as $existing_policy) {
+ $emp_policy_data['id']= $existing_policy['id'];
+ $emp_policy_data['updated_at'] = $formatted_date_time;
+ $this->employeePolicyModel->save($emp_policy_data);
+ }
+ } else {
+ $emp_policy = $this->employeePolicyModel->insert($emp_policy_data);
}
- // print_r($wholeData);
- // if ($dataToInsert[$a]['email_corporate'] != null || $dataToInsert[$a]['email_corporate'] != '' && $dataToInsert[$a]['relationship'] == 'Self') {
- if($count == 20 || $a == count($dataToInsert)-1){
- $job_details = new Jobs();
- $r = Jobs::addJob(['job_name' => 'bulk_mail','payload' => $wholeData]);
- // $wholeData[]= $r;
- // Mailhelper::bulk_mail($wholeData);
- $wholeData = [];
- $count = 0;
+ if ($notification['enabled'] == 1) {
+ //trigger
+ if ($dataToInsert[$a]['relationship'] == 'Self') {
+
+ $params['dataToInsert'] = $dataToInsert[$a];
+ $params['notification'] = $notification;
+ $params['client_data'] = $client_data;
+
+ $wholeData[] = sendMailNotification::sendMailNotification('member_welcome_mail', $params);
+ $count++;
+ }
+ if($count == 20 || $a == count($dataToInsert)-1){
+ $job_details = new Jobs();
+ $r = Jobs::addJob(['job_name' => 'bulk_mail','payload' => $wholeData]);
+ // $wholeData[]= $r;
+
+ // Mailhelper::bulk_mail($wholeData);
+ $wholeData = [];
+ $count = 0;
+ }
+
+
+ // if ($dataToInsert[$a]['email_corporate'] != null || $dataToInsert[$a]['email_corporate'] != '' && $dataToInsert[$a]['relationship'] == 'Self') {
+
}
- // print_r($r);//die();
- // $jobWorker = new JobWorker();
- //JobWorker::processJob($r);
- // $return_log = MailHelper::send_email($mail,$subject, $message);
- // $return_log = json_decode($return_log);
- // $this->myLogger->logme('info', "Email Status : {mail_status}, Sender Email:{email}", ['mail_status' => $return_log->status, 'email'=> $return_log->data]);
}
return $this->respond(['status' => 'success', 'code' => 200, 'message' => "Success" ], 200);
}else{
@@ -1039,10 +930,11 @@ public function getEmployeePolicy()
$keysToRemove = ["removable_keys"];
// Retrieve employee policy data by passing the employee primary key
$empPolicy = $this->employeeModel->getEmployeePolicy($id);
+
// Retrieve employee and dependents data by passing the employee code
$employeeData = $this->employeeModel->where('emp_code',$emp_code)->where('client_id',$client_id)
->where('is_active', 1 )->where('is_addon_value',0)->findAll();
- // dd($empPolicy);
+
if ($empPolicy) {
@@ -1050,8 +942,8 @@ public function getEmployeePolicy()
foreach ($empPolicy as $array) {
// Reset employee array
$empData = $employeeData;
-
+
// Removes specific keys from the decoded array and assigns the result to $refusingData
$decodedArray = json_decode($array->Policy_Terms);
$refusingData = (object) array_diff_key((array) $decodedArray, array_flip($keysToRemove));
@@ -1062,12 +954,18 @@ public function getEmployeePolicy()
$array->SlabRates = $getSlabAndGridData['slab_rates'];
$array->GridMaster = $getSlabAndGridData['grid_master'];
+ if($array->tpa_id != null){
+ $array->eCardDownload = base_url('download-e-card/') . $array->rand_string;
+ }else{ $array->eCardDownload = null; }
+
+
// Construct value for policy type GPA
if($getSlabAndGridData['grid_master']['policy_type'] == "GPA"){
-
+
// Filter employee data where the family_floater_key is 'self'
$selfData = array_filter($empData, fn($arr) => trim(strtolower($arr['family_floater_key'])) === 'self');
-
+ $employee_policy = $this->employeePolicyModel->where('employee_id',$selfData[0]['id'])->where('client_policy_id',$array->ClientPolicyId)->where('is_active', 1 )->get()->getRow();
+
$self['is_value_exist'] = true;
$self['data']['family_floater_key'] = 'self';
$self['data']['employee_id'] = $id;
@@ -1076,6 +974,7 @@ public function getEmployeePolicy()
$self['data']['dob'] = $this->convertDateFormatDMY($selfData[0]['dob']);
$self['data']['mobile'] = $selfData[0]['mobile'];
$self['data']['client_policy_id'] = $array->ClientPolicyId;
+ $self['data']['basic_cover_si'] = $employee_policy->basic_cover_si;
$array->mapped_family_floaters = $self;
@@ -1089,7 +988,7 @@ public function getEmployeePolicy()
}else if($getSlabAndGridData['grid_master']['policy_type'] == "GMC"){
-
+
// Map family floaters that already exist in the employee table
$familyFloates = $array->Policy_Terms->family_floaters;
@@ -1114,6 +1013,7 @@ public function getEmployeePolicy()
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();
$temp['is_value_exist'] = true;
$temp['data']['family_floater_key'] = $familyFloatesValue;
$temp['data']['employee_id'] = $value['id'];
@@ -1121,7 +1021,12 @@ public function getEmployeePolicy()
$temp['data']['name'] = $value['name'];
$temp['data']['dob'] = $this->convertDateFormatDMY($value['dob']);
$temp['data']['client_policy_id'] = $array->ClientPolicyId;
- $temp['data']['form_type'] = $dependent;
+ $temp['data']['form_type'] = $dependent;
+ $temp['data']['basic_cover_si'] = $employee_policy->basic_cover_si;
+ $ageKey = ($dependent == 'parent' || $dependent == 'parent_in_law') ? 'elders' : $dependent;
+
+ $temp['data']['age_validation'] = $decodedArray->age_ratio->$ageKey;
+
array_push($data,$temp);
unset($empData[$key]);
$floters = array_diff($floters, [$familyFloatesValue]);
@@ -1130,7 +1035,9 @@ public function getEmployeePolicy()
}
}
}
-
+ // dd($data);
+
+
// Remove Unwanted floter key from floters array based on either-parents-pil term value
if($familyFloates->{'either-parents-pil'} == 1 && count($floters))
{
@@ -1164,28 +1071,178 @@ public function getEmployeePolicy()
}
$array->mapped_family_floaters = $data;
-
+ $array->type = "Group Medical Coverage";
+ $checkGmcParentsPolicyExist = $this->clientPolicyModel->select('client_policy.id as ClientPolicyId , client_policy.client_id as ClientId, policies.id as PolicyId , client_policy.policy_type_id as policy_type_id, policies.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('policies', 'client_policy.policy_id = policies.id', 'left')
+ ->where('client_policy.policy_type_id', 3 )
+ ->where('client_policy.is_addon', 1 )
+ ->where('client_policy.client_id', $this->request->getGet('client_id') )
+ ->where('client_policy.is_active', 1 )
+ ->get()
+ ->getResult();
+ if($checkGmcParentsPolicyExist)
+ {
+ $GmcParrentsData = $this->getGmcParrentsPolicy($checkGmcParentsPolicyExist,$emp_code,$client_id);
+ return $this->respond(['status' => 'success','code' => 200,'data' => [$array,$GmcParrentsData]], 200);
+
+ }
if($this->request->getGet('policy') == 'GMC'){
- return $this->respond(['status' => 'success','code' => 200,'data' => $array], 200);
+ return $this->respond(['status' => 'success','code' => 200,'data' => [$array]], 200);
}
}
// $result[] = $array;
}
+
return $this->respond(['status' => 'success','code' => 200,'data' => []], 200);
}else{
- return $this->respond(['status' => 'failed','code' => 404,'data' => []], 404);
+ return $this->respond(['status' => 'failed','code' => 404,'data' => []], 200);
}
} catch (\Exception $e) {
return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500);
}
}
+
+public function getGmcParrentsPolicy($GmcParrentsPolicy,$emp_code,$client_id)
+{
+
+ $employeeData = $this->employeeModel->where('emp_code',$emp_code)->where('client_id',$client_id)
+ ->where('is_active', 1 )->where('is_addon_value',0)->findAll();
+ foreach ($GmcParrentsPolicy as $key => $array) {
+
+
+
+ // Reset employee array
+ $empData = $employeeData;
+
+
+ $array->Policy_Terms = json_decode($array->Policy_Terms);
+
+
+ // Retrieve slab rate and grid master data by passing the ClientPolicyId and ClientId
+ $getSlabAndGridData = $this->policesModel->getPolicySlabRatesForEmpOnboard($array->ClientPolicyId,$array->ClientId);
+ $array->SlabRates = $getSlabAndGridData['slab_rates'];
+ $array->GridMaster = $getSlabAndGridData['grid_master'];
+
+ $tpaArray = $this->employeeModel->select('employees.name as name , employee_polices.tpa_id as tpa_id , employee_polices.rand_string as rand_string')
+ ->join('employee_polices', 'employee_polices.employee_id = employees.id')
+ ->where('employees.emp_code',$emp_code)
+ ->where('employees.is_active',1)
+ ->where('employee_polices.client_policy_id',$array->ClientPolicyId)
+ ->get()
+ ->getResult();
+
+ if(count($tpaArray))
+ {
+
+ if($tpaArray[0]->tpa_id != null)
+ $array->eCardDownload = base_url('download-e-card/') . $tpaArray[0]->rand_string;
+ else
+ $array->eCardDownload = null;
+
+ }else{
+ $array->eCardDownload = null;
+ }
+
+ // if($array->tpa_id != null){
+ // $array->eCardDownload = base_url('download-e-card/') . $array->rand_string;
+ // }else{ $array->eCardDownload = null; }
+ $array->eCardDownload = null;
+
+ // Map family floaters that already exist in the employee table
+ $familyFloates = $array->Policy_Terms->family_floaters;
+
+ // Generate Notes string based on familyFloates terms
+ $array->notes = $this->FloterNotesConvertion($familyFloates);
+
+ if($getSlabAndGridData['slab_rates'][0]['premium_type'] == 1)
+ {
+ $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.';
+ }else{
+ $array->floter_text_heading = 'Sum Insured';
+ $array->floter_text_description = '';
+ }
+
+ // Convert familyFloaters terms data to plain array
+ $floters = $this->FloterConvertion($familyFloates);
+ $data = [];
+ 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);
+ $temp['is_value_exist'] = true;
+ $temp['data']['family_floater_key'] = $familyFloatesValue;
+ $temp['data']['employee_id'] = $value['id'];
+ $temp['data']['relationship'] = $value['relationship'];
+ $temp['data']['name'] = $value['name'];
+ $temp['data']['dob'] = $this->convertDateFormatDMY($value['dob']);
+ $temp['data']['client_policy_id'] = $array->ClientPolicyId;
+ $temp['data']['form_type'] = $dependent;
+ $temp['data']['basic_cover_si'] = $employee_policy->basic_cover_si;
+ $ageKey = ($dependent == 'parent' || $dependent == 'parent_in_law') ? 'elders' : $dependent;
+ $temp['data']['age_validation'] = $array->Policy_Terms->age_ratio->$ageKey;
+
+ array_push($data,$temp);
+ unset($empData[$key]);
+ $floters = array_diff($floters, [$familyFloatesValue]);
+ break;
+ }
+ }
+ }
+ }
+
+ // Remove Unwanted floter key from floters array based on either-parents-pil term value
+ if($familyFloates->{'either-parents-pil'} == 1 && count($floters))
+ {
+ $count_parent = 0;
+ $count_parent_in_law = 0;
+ foreach ($floters as $value) {
+ if (preg_replace('/\d/', '', $value) == 'parent') { $count_parent++; }
+ if (preg_replace('/\d/', '', $value) == 'parent_in_law') {$count_parent_in_law++;}
+ }
+ if($count_parent != 2) {
+ $floters = array_filter($floters, fn($value) => strpos($value, 'parent_in_law') === false);
+ }
+ if($count_parent_in_law != 2) {
+ $floters = array_filter($floters, fn($value) => strpos($value, 'parent') === false || strpos($value, 'parent_in_law') !== false);
+ }
+ }
+
+ // Add family floter buttons placement data for FE validation
+ if(count($floters)){
+ foreach ($floters as $familyFloatesValue) {
+
+ $temp2['is_value_exist'] = false;
+ $temp2['data']['family_floater_key'] = $familyFloatesValue;
+ $temp2['data']['client_policy_id'] = $array->ClientPolicyId;
+ $temp2['data']['button_name'] = 'Add '.ucfirst(str_replace('_', ' ', preg_replace('/\d/', '', $familyFloatesValue)));
+ $temp2['data']['form_type'] = preg_replace('/\d/', '', $familyFloatesValue);
+
+ array_push($data,$temp2);
+
+ }
+ }
+
+ $array->mapped_family_floaters = $data;
+ $array->type = "Group Medical Coverage - Parents";
+
+ return $array;
+
+ }
+
+}
public function FloterConvertion($array){
$result = [];
@@ -1219,7 +1276,7 @@ public function FloterConvertion($array){
public function FloterNotesConvertion($array){
- $result = 'Can Add Self ';
+ $result = ' ';
foreach ($array as $key => $value) {
if ($value > 0) {
if($value != 0 && $key ==='either-parents-pil') {
@@ -1229,6 +1286,7 @@ public function FloterNotesConvertion($array){
$string = ucwords($string);
$result .= ' + '.$string;
}else if($value != 0 && $key ==='self') {
+ $result = 'Can Add Self ';
}else if($value != 0 && $key ==='childrens') {
if($value > 1){ $result .= ' + '.$value.' Children'; }else{ $result .= ' + '.$value.' Child'; }
}else{
@@ -1265,29 +1323,69 @@ public function getAddOnPolicy()
try {
$addOnEmployeeData = $this->employeeModel->where('is_active', 1 )->where('emp_code',$this->request->getGet('emp_code'))->where('client_id',$this->request->getGet('client_id'))->where('is_addon_value',1)->findAll();
- $GMCEmployeeData = $this->employeeModel->where('is_active', 1 )->where('emp_code',$this->request->getGet('emp_code'))->where('client_id',$this->request->getGet('client_id'))->where('is_addon_value',0)->findAll();
+
- $clientPolicy = $this->clientPolicyModel->where('client_id',$this->request->getGet('client_id'))->findAll();
- // dd($clientPolicy);
+ $clientPolicy = $this->clientPolicyModel->where('client_id',$this->request->getGet('client_id'))
+ ->where('policy_status', 1)
+ ->findAll();
+
if(count($clientPolicy))
{
+ $band = $addOnEmployeeData = $this->employeeModel->where('is_active', 1 )->where('emp_code',$this->request->getGet('emp_code'))->where('client_id',$this->request->getGet('client_id'))->where('family_floater_key','self')->get()->getRow()->band;
$PolicyData = [];
foreach ($clientPolicy as $key => $array) {
$responce = [];
-
+
$decodedArray = json_decode($array['policy_terms']);
$policy_terms = $decodedArray;
$getSlabAndGridData = $this->policesModel->getPolicySlabRatesForEmpOnboard($array['id'],$array['client_id']);
+ $uniqueData = [];
+ $siValues = [];
+ foreach ($getSlabAndGridData['slab_rates'] as $item) {
+ if($getSlabAndGridData['grid_master']['emp_band'] == 1 ){
+ if ($item['grade'] == $band) {
+ $uniqueData[] = $item;
+ }
+ }else{
+ if (!in_array($item['si'], $siValues)) {
+ $uniqueData[] = $item;
+ $siValues[] = $item['si'];
+ }
+ }
+
+ }
+
+
$responce['policy_name'] = $this->policesModel->where('id',$array['policy_id'])->get()->getRow()->name;
- $responce['SlabRates'] = $getSlabAndGridData['slab_rates'];
+ $responce['SlabRates'] = $uniqueData;
$responce['GridMaster'] = $getSlabAndGridData['grid_master'];
$responce['client_id'] = $array['client_id'];
$responce['client_policy_id'] = $array['id'];
$responce['is_addon'] = $array['is_addon'];
- $responce['open_for_enrollment'] = $array['open_for_enrollment'];
+ $responce['OpenForEnrollment'] = $array['open_for_enrollment'];
$responce['policy_terms'] = $decodedArray;
+ $responce['policy_type_id'] = $array['policy_type_id'];
+
+ $tpaArray = $this->employeeModel->select('employees.name as name , employee_polices.tpa_id as tpa_id , employee_polices.rand_string as rand_string')
+ ->join('employee_polices', 'employee_polices.employee_id = employees.id')
+ ->where('employees.emp_code',$this->request->getGet('emp_code'))
+ ->where('employees.is_active',1)
+ ->where('employee_polices.client_policy_id',$array['id'])
+ ->get()
+ ->getResult();
+
+ if(count($tpaArray))
+ {
+ if($tpaArray[0]->tpa_id != null)
+ $responce['eCardDownload'] = base_url('download-e-card/') . $tpaArray[0]->rand_string;
+ else
+ $responce['eCardDownload'] = null;
+
+ }else{
+ $responce['eCardDownload'] = null;
+ }
if(count($getSlabAndGridData['slab_rates'])){
if($getSlabAndGridData['slab_rates'][0]['premium_type'] == 1)
@@ -1299,7 +1397,7 @@ public function getAddOnPolicy()
}
- if($array['is_addon'] == 3)
+ if($array['is_addon'] == 3 && $array['policy_type_id'] == 3)//dependent add on policy
{
@@ -1409,18 +1507,34 @@ public function getAddOnPolicy()
}
//array_push($PolicyData, $responce);
- }else if($array['is_addon'] == 2){
+ }else if($array['is_addon'] == 2 && $array['policy_type_id'] == 4)//Topup policy
+ {
+
+ $whereArray = [];
+ foreach ( $decodedArray->family_floaters as $key => $value) {
+ if($value != 0){
+ if($key == 'parents'){ $text = 'parent'; }else if($key == 'childrens'){ $text = 'child'; }else if($key == 'parents-in-law'){$text = 'parent_in_law';}else{ $text = $key; }
+ array_push($whereArray,$text);
+ }
+ }
+
+
+ $getAddOnType = $this->clientPolicyModel->where('id',$array['base_policy'])->where('policy_status', 1)->get()->getRow();
+ $basePolicyAddOnType = $getAddOnType->is_addon;
+ // if is_addon value is 1 it is GMC if not it is one of the Add On policy
+ if($basePolicyAddOnType == 1){ $is_addon_value = 0; }else{ $is_addon_value = 1; }
$only_si_array = [];
$only_si_value = 0;
$only_si_premium_value = 0;
$only_si_gst_value = 0;
- foreach ($GMCEmployeeData as $key => $value) {
+ $BasePolicyEmployeeData = $this->employeeModel->where('is_active', 1 )->where('emp_code',$this->request->getGet('emp_code'))->where('client_id',$this->request->getGet('client_id'))->where('is_addon_value',$is_addon_value)->whereIn('family_floater_key',$whereArray)->findAll();
+ foreach ($BasePolicyEmployeeData as $key => $value) {
$employee_policy = $this->employeePolicyModel->where('employee_id',$value['id'])->where('client_policy_id',$array['id'])->where('is_active', 1 )->get()->getRow();
if(isset($employee_policy->basic_cover_si)){ $only_si_value = $employee_policy->basic_cover_si; }
- if(isset($employee_policy->premium)){ $only_si_premium_value = $only_si_premium_value + $employee_policy->premium;}
+ if(isset($employee_policy->premium)){ $only_si_premium_value = $only_si_premium_value + $employee_policy->rata_premimum;}
if(isset($employee_policy->gst)){ $only_si_gst_value = $only_si_gst_value + $employee_policy->gst;}
$temp3['is_value_exist'] = true;
$temp3['data']['employee_id'] = $value['id'];
@@ -1438,12 +1552,62 @@ public function getAddOnPolicy()
$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['type'] = "Group Medical Coverage - Top Up";
if($this->request->getGet('policy') == 'GMC-SI-TOPUP'){
return $this->respond(['status' => 'success','code' => 200,'data' => ['gmc_si_topup'=>$responce]], 200);
}
+ }else if($array['is_addon'] == 2 && $array['policy_type_id'] == 5)//Parents Topup policy
+ {
+
+ $whereArray = [];
+ foreach ( $decodedArray->family_floaters as $key => $value) {
+ if($value != 0){
+ if($key == 'parents'){ $text = 'parent'; }else if($key == 'childrens'){ $text = 'child'; }else if($key == 'parents-in-law'){$text = 'parent_in_law';}else{ $text = $key; }
+ array_push($whereArray,$text);
+ }
+ }
+
+ $getAddOnType = $this->clientPolicyModel->where('id',$array['base_policy'])->where('policy_status', 1)->get()->getRow();
+ $basePolicyAddOnType = $getAddOnType->is_addon;
+ // if is_addon value is 1 it is GMC if not it is one of the Add On policy
+ if($basePolicyAddOnType == 1){ $is_addon_value = 0; }else{ $is_addon_value = 1; }
+ $only_si_array = [];
+ $only_si_value = 0;
+ $only_si_premium_value = 0;
+ $only_si_gst_value = 0;
+ $BasePolicyEmployeeData = $this->employeeModel->where('is_active', 1 )->where('emp_code',$this->request->getGet('emp_code'))->where('client_id',$this->request->getGet('client_id'))->where('is_addon_value',$is_addon_value)->whereIn('family_floater_key',$whereArray)->findAll();
+ foreach ($BasePolicyEmployeeData as $key => $value) {
+
+ $employee_policy = $this->employeePolicyModel->where('employee_id',$value['id'])->where('client_policy_id',$array['id'])->where('is_active', 1 )->get()->getRow();
+ if(isset($employee_policy->basic_cover_si)){ $only_si_value = $employee_policy->basic_cover_si; }
+ if(isset($employee_policy->premium)){ $only_si_premium_value = $only_si_premium_value + $employee_policy->rata_premimum;}
+ if(isset($employee_policy->gst)){ $only_si_gst_value = $only_si_gst_value + $employee_policy->gst;}
+ $temp3['is_value_exist'] = true;
+ $temp3['data']['employee_id'] = $value['id'];
+ $temp3['data']['relationship'] = $value['relationship'];
+ $temp3['data']['name'] = $value['name'];
+ $temp3['data']['dob'] = $this->convertDateFormatDMY($value['dob']);
+ $temp3['data']['client_policy_id'] = $array['id'];
+ $temp3['data']['basic_cover_si'] = isset($employee_policy->basic_cover_si) ? $employee_policy->basic_cover_si : null;
+ $temp3['data']['premium'] = isset($employee_policy->premium) ? $employee_policy->premium : null;
+ array_push($only_si_array,$temp3);
+
+ }
+
+ $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['type'] = "Group Medical Coverage - Parents Top Up";
+
+ if($this->request->getGet('policy') == 'GMC-SI-PARENT-TOPUP'){
+ return $this->respond(['status' => 'success','code' => 200,'data' => ['gmc_si_parent_topup'=>$responce]], 200);
+ }
+
+
}
}
@@ -1452,7 +1616,7 @@ public function getAddOnPolicy()
return $this->respond(['status' => 'success','code' => 200,'data' => []], 200);
}else{
- return $this->respond(['status' => 'failed','code' => 404,'data' => []], 404);
+ return $this->respond(['status' => 'failed','code' => 404,'data' => []], 200);
}
} catch (\Exception $e) {
return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500);
@@ -1461,9 +1625,9 @@ public function getAddOnPolicy()
public function iAgreeForAddOn()
{
-
$postData = json_decode($this->request->getBody(), true);
+
$client_policy_id = $postData['client_policy_id'];
$emp_code = $postData['emp_code'];
$client_id = $postData['client_id'];
@@ -1476,15 +1640,41 @@ public function iAgreeForAddOn()
if (!is_null($client_policy_id) && is_array($client_policy_id))
{
+ $array_list = [];
foreach ($client_policy_id as $key => $value)
{
$this->employeePolicyModel->where('client_policy_id', $value )
->where('is_active', 1 )
->set(array('status'=>'enrolled'))
->update();
+ $find = $this->employeeModel->getEmpFamilybyEmpCode(client_policy_id: $value,emp_code: $emp_code,client_id: $client_id,emp_status:['draft','enrolled'],policy_status:['draft','enrolled']);
+ $array_list[] = $find;
}
+ $params ['array_list'] = $array_list;
+ $params ['client_policy_id'] = $client_policy_id;
+ $params ['emp_code'] = $emp_code;
+ $params ['client_id'] = $client_id;
+ $wholeData =sendMailNotification::sendMailNotification('member_review_and_summary_mail', $params);
+
+ MailHelper::send_email($wholeData[0]);
+
+ if (isset($wholeData[0])) {
+
+ $account_manager_wholeData =sendMailNotification::sendMailNotification('account_maneger_summary_mail', $params);
+
+ foreach ($account_manager_wholeData as $key => $value) {
+ MailHelper::send_email($value);
+ }
+
+ $client_hr_wholeData =sendMailNotification::sendMailNotification('client_hr_summary_mail', $params);
+
+ foreach ($client_hr_wholeData as $key => $value) {
+ MailHelper::send_email($value);
+ }
+ }
+
}
-
+
return $this->respond(['status' => 'success','code' => 200,'data' => [] ], 200);
}
@@ -1554,6 +1744,8 @@ public function getCashDepositData()
$ClientPolicyData = $this->clientPolicyModel->select('client_policy.client_id as clientId , client_policy.insurer_id as insurerId,insurers.name as insurer_name')
->join('insurers', 'client_policy.insurer_id = insurers.id', 'left')
->where('client_policy.client_id', $this->request->getGet('client_id') )
+ ->where('client_policy.is_active', 1 )
+ ->where('client_policy.policy_status', 1)
->groupBy('client_policy.insurer_id')
->findAll();
$result = [];
@@ -1569,15 +1761,18 @@ public function getCashDepositData()
$data['balance'] = count($data['depositData']) ? $data['depositData'][0]->balance : 0;
$data['policyDetails'] = [];
- $ClientPolicyData =$this->clientPolicyModel->select('client_policy.id as client_policy_id , client_policy.client_id as client_id, policies.id as policy_id,policies.policy_type_id as policy_type_id, policies.name as policy_name , client_policy.is_addon as is_addon')
+ $ClientPolicyData = $this->clientPolicyModel->select('client_policy.id as client_policy_id , client_policy.client_id as client_id, policies.id as policy_id , client_policy.policy_type_id as policy_type_id, policies.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 ')
->join('policies', 'client_policy.policy_id = policies.id', 'left')
->where('client_policy.insurer_id', $value['insurerId'] )
->where('client_policy.client_id', $this->request->getGet('client_id') )
+ ->where('client_policy.is_active', 1 )
+ ->where('client_policy.policy_status', 1)
->findAll();
+ // dd( $ClientPolicyData);
foreach ($ClientPolicyData as $key => $value)
{
- $getSlabAndGridData = $this->policesModel->getPolicySlabRatesForEmpOnboard( $value['client_policy_id'],$value['client_id']);
- if($value['is_addon'] == "2"){ $value['type'] = 'SI TopUp'; }else if($value['is_addon'] == "3"){ $value['type'] = 'Dependent AddOn'; }else{ $value['type'] = $getSlabAndGridData['grid_master']['policy_type']; }
+
+ $value['type'] = $this->policyTypeModel->where('id',$value['policy_type_id'])->get()->getRow()->policy_type;
$employeeDetails = $this->employeePolicyModel->getEmployeePolicy( client_id:$value['client_id'],policy_id: $value['client_policy_id'],status:0);
$enrolledCount = 0;
$draftCount = 0;
@@ -1740,7 +1935,7 @@ public function removeEmpAndEmpPolicyData()
return $this->respond(['status' => 'success','code' => 200,'data' =>[] ], 200);
}else{
- return $this->respond(['status' => 'failed','code' => 404,'data' => [] ], 404);
+ return $this->respond(['status' => 'failed','code' => 404,'data' => [] ], 200);
}
@@ -1752,4 +1947,93 @@ public function removeEmpAndEmpPolicyData()
+
+function getEmployeeOldPolicy()
+{
+ $ClientPolicyData = $this->clientPolicyModel->select('client_policy.* , policies.name as policy_name , policy_type.policy_type as policy_type')
+ ->join('policies', 'client_policy.policy_id = policies.id', 'left')
+ ->join('policy_type', 'client_policy.policy_type_id = policy_type.id', 'left')
+ ->where('client_policy.client_id', $this->request->getGet('client_id') )
+ ->where('client_policy.is_active', 1 )
+ ->where('client_policy.policy_status', 0)
+ ->orderby('client_policy.id' , 'ASC')
+ ->findAll();
+
+ // Retrieve employee and dependents data by passing the employee code
+ $employeeData = $this->employeeModel->where('emp_code',$this->request->getGet('emp_code'))
+ ->where('client_id',$this->request->getGet('client_id'))
+ ->where('is_active', 1 )->findAll();
+ $whereArrayForId = [];
+ foreach ( $employeeData as $key => $value) { array_push($whereArrayForId, $value['id']); }
+
+ if(count($ClientPolicyData) > 0 && count($employeeData) > 0)
+ {
+ $result = [];
+ foreach ($ClientPolicyData as $key => $ClientPolicyValue) {
+
+ $terms = json_decode($ClientPolicyValue['policy_terms']);
+ // dd($terms);
+ $data['client_id'] = $ClientPolicyValue['client_id'];
+ $data['client_policy_id'] = $ClientPolicyValue['id'];
+ $data['policy_name'] = $ClientPolicyValue['policy_name'];
+ $data['policy_type'] = $ClientPolicyValue['policy_type'];
+ $data['policy_type'] = $ClientPolicyValue['policy_type'];
+ $data['policy_start_date'] = $this->convertDateFormatDisplay($ClientPolicyValue['policy_start_date']);
+ $data['policy_end_date'] = $this->convertDateFormatDisplay($ClientPolicyValue['policy_end_date']);
+
+ if($ClientPolicyValue['policy_type_id'] == 1){ $data['heading'] = 'Group Personal Accident Coverage'; }else
+ if($ClientPolicyValue['policy_type_id'] == 2){ $data['heading'] = 'Group Medical Coverage'; }else
+ if($ClientPolicyValue['policy_type_id'] == 3){ $data['heading'] = 'Group Medical Coverage - Parents'; }else
+ if($ClientPolicyValue['policy_type_id'] == 4){ $data['heading'] = 'Group Medical Coverage - Top Up'; }else
+ if($ClientPolicyValue['policy_type_id'] == 5){ $data['heading'] = 'Group Medical Coverage - Parents (Top Up)'; }
+
+ if($ClientPolicyValue['policy_type_id'] == 1){ $data['floter_text_heading'] = 'Sum Insured'; }
+ else
+ {
+ if($terms->family_floater == 1){ $data['floter_text_heading'] = 'Floter Sum Insured'; }else{ $data['floter_text_heading'] = 'Sum Insured'; }
+ }
+
+ $employee_policy = $this->employeePolicyModel->select('employees.*,employee_polices.employee_id , employee_polices.basic_cover_si , employee_polices.premium , employee_polices.gst , employee_polices.tpa_id , employee_polices.rand_string')
+ ->join('employees', 'employee_polices.employee_id = employees.id', 'left')
+ ->whereIn('employee_polices.employee_id',$whereArrayForId)
+ ->where('employee_polices.client_policy_id',$ClientPolicyValue['id'])
+ ->where('employee_polices.is_active', 1 )->findAll();
+ $si_value = 0;
+ $si_premium_value = 0;
+ $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['premium'])){ $si_premium_value = $si_premium_value + $value['premium'];}
+ if(isset($value['gst'])){ $si_gst_value = $si_gst_value + $value['gst'];}
+ }
+
+ $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['EmployeePolicy'] = $employee_policy;
+ array_push($result, $data);
+ }
+
+ return $this->respond(['status' => 'success','code' => 200,'data' => $result ], 200);
+
+ }else{
+ return $this->respond(['status' => 'failed','code' => 404,'data' => [] ], 200);
+ }
+
+}
+
+
+private function convertDateFormatDisplay($dateString)
+{
+ // Attempt to create a DateTime object from the provided date string
+ $dateTime = \DateTime::createFromFormat('Y-m-d', $dateString);
+
+ if ($dateTime instanceof \DateTime) {
+ return $dateTime->format('d-M-Y');
+ } else {
+ return null;
+ }
+}
+
}
\ No newline at end of file
diff --git a/app/Controllers/EmployeeServiceController.php b/app/Controllers/EmployeeServiceController.php
index 855db866..085c2727 100644
--- a/app/Controllers/EmployeeServiceController.php
+++ b/app/Controllers/EmployeeServiceController.php
@@ -34,7 +34,7 @@ class EmployeeServiceController extends AdminController
protected $policiesModel;
protected $empEndorsementModel;
protected $general_relationships = ['self' => ['name' => 'Self', 'gender' => 'M','age_min' => 18,'age_max' => null], 'spouse' => ['name' => 'Spouse', 'gender' => 'F','age_min' => 18,'age_max' => null], 'son' => ['name' => 'Son', 'gender' => 'M','age_min' => null,'age_max' => 25], 'daughter' => ['name' => 'Daughter', 'gender' => 'F','age_min' => null,'age_max' => 25], 'father' => ['name' => 'Father', 'gender' => 'M','age_min' => 18,'age_max' => null], 'mother' => ['name' => 'Mother', 'gender' => 'F','age_min' => 18,'age_max' => null], 'father-in-law' => ['name' => 'Father in Law', 'gender' => 'M','age_min' => 18,'age_max' => null], 'mother-in-law' => ['name' => 'Mother in Law', 'gender' => 'F','age_min' => 18,'age_max' => null]];
- protected $inception_excel_columns = ['sno'=>['col_idx'=>0,'col_cell_name'=>'A','col_name'=>'S.No','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'emp_id'=>['col_idx'=>1,'col_cell_name'=>'B','col_name'=>'EMP ID','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'name_of_emp_dep'=>['col_idx'=>2,'col_cell_name'=>'C','col_name'=>'NAME OF EMP/DEP','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'dob'=>['col_idx'=>3,'col_cell_name'=>'D','col_name'=>'DOB','is_mandatory'=>['I','A','DA'],'data_type'=>'str','format'=>'d-M-Y','allowed_values'=>null,'custom'=>'check_dob_diff','params'=>['row','relationship']],'gender'=>['col_idx'=>4,'col_cell_name'=>'E','col_name'=>'Gender','is_mandatory'=>['I','A','DA'],'data_type'=>'str','format'=>null,'allowed_values'=>['M','F']],'relationship'=>['col_idx'=>5,'col_cell_name'=>'F','col_name'=>'RELATIONSHIP','is_mandatory'=>['I','A','DA'],'data_type'=>'str','format'=>null,'allowed_values'=>null,'custom'=>'check_relationship','params'=>['row','relationship','policy_terms']],'basic_cover_si'=>['col_idx'=>6,'col_cell_name'=>'G','col_name'=>'BASIC COVER SI','is_mandatory'=>['I','A','DA'],'data_type'=>'str','format'=>null,'allowed_values'=>null,'custom' => 'check_si','params' => ['row','policy_terms','slab_details']],'doc'=>['col_idx'=>7,'col_cell_name'=>'H','col_name'=>'Date of Coverage','is_mandatory'=>['A','DA'],'data_type'=>'str','format'=>'d-M-Y','allowed_values'=>null,'params'=>['row']],'doj'=>['col_idx'=>8,'col_cell_name'=>'I','col_name'=>'DOJ','is_mandatory'=>false,'data_type'=>'str','format'=>'d-M-Y','allowed_values'=>null,'custom'=>'check_doj','params'=>['row']],'basic_pay'=>['col_idx'=>9,'col_cell_name'=>'J','col_name'=>'Basic Pay','is_mandatory'=>false,'data_type'=>'str','format'=>null,'allowed_values'=>null,'custom'=>'check_basic_pay','params'=>['row','policy_terms','slab_details']],'band_grade'=>['col_idx'=>10,'col_cell_name'=>'K','col_name'=>'Band/Grade','is_mandatory'=>false,'data_type'=>'str','format'=>null,'allowed_values'=>null,'custom'=>'check_employee_band','params'=>['row','policy_terms','slab_details']],'designation'=>['col_idx'=>11,'col_cell_name'=>'L','col_name'=>'Designation','is_mandatory'=>false,'data_type'=>'str','format'=>null,'allowed_values'=>null],'phone'=>['col_idx'=>12,'col_cell_name'=>'M','col_name'=>'Phone','is_mandatory'=>false,'data_type'=>'str','format'=>null,'allowed_values'=>null],'email'=>['col_idx'=>13,'col_cell_name'=>'N','col_name'=>'Email','is_mandatory'=>false,'data_type'=>'str','format'=>null,'allowed_values'=>null],'pre_existing_ailments'=>['col_idx'=>14,'col_cell_name'=>'O','col_name'=>'PRE EXISTING AILMENTS','is_mandatory'=>['I','A','DA'],'data_type'=>'str','format'=>null,'allowed_values'=>['0','1']],'change_event'=>['col_idx'=>15,'col_cell_name'=>'P','col_name'=>'Change event','is_mandatory'=>['A','DA','D'],'data_type'=>'str','format'=>null,'allowed_values'=>null],'date_of_exit'=>['col_idx'=>16,'col_cell_name'=>'Q','col_name'=>'Date of exit','is_mandatory'=>['D'],'data_type'=>'str','format'=>'d-M-Y','allowed_values'=>null],'reason_for_exit'=>['col_idx'=>17,'col_cell_name'=>'R','col_name'=>'Reason for exit','is_mandatory'=>['D'],'data_type'=>'str','format'=>null,'allowed_values'=>null]];
+ protected $inception_excel_columns = ['sno'=>['col_idx'=>0,'col_cell_name'=>'A','col_name'=>'S.No','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'emp_id'=>['col_idx'=>1,'col_cell_name'=>'B','col_name'=>'EMP ID','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'name_of_emp_dep'=>['col_idx'=>2,'col_cell_name'=>'C','col_name'=>'NAME OF EMP/DEP','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'dob'=>['col_idx'=>3,'col_cell_name'=>'D','col_name'=>'DOB','is_mandatory'=>['I','A','DA'],'data_type'=>'str','format'=>'d-M-Y','allowed_values'=>null,'custom'=>'check_dob_diff','params'=>['row','relationship','default_age_ratio']],'gender'=>['col_idx'=>4,'col_cell_name'=>'E','col_name'=>'Gender','is_mandatory'=>['I','A','DA'],'data_type'=>'str','format'=>null,'allowed_values'=>['M','F']],'relationship'=>['col_idx'=>5,'col_cell_name'=>'F','col_name'=>'RELATIONSHIP','is_mandatory'=>['I','A','DA'],'data_type'=>'str','format'=>null,'allowed_values'=>null,'custom'=>'check_relationship','params'=>['row','relationship','policy_terms']],'basic_cover_si'=>['col_idx'=>6,'col_cell_name'=>'G','col_name'=>'BASIC COVER SI','is_mandatory'=>['I','A','DA'],'data_type'=>'str','format'=>null,'allowed_values'=>null,'custom' => 'check_si','params' => ['row','policy_terms','slab_details']],'doc'=>['col_idx'=>7,'col_cell_name'=>'H','col_name'=>'Date of Coverage','is_mandatory'=>['A','DA'],'data_type'=>'str','format'=>'d-M-Y','allowed_values'=>null,'params'=>['row']],'doj'=>['col_idx'=>8,'col_cell_name'=>'I','col_name'=>'DOJ','is_mandatory'=>false,'data_type'=>'str','format'=>'d-M-Y','allowed_values'=>null,'custom'=>'check_doj','params'=>['row']],'basic_pay'=>['col_idx'=>9,'col_cell_name'=>'J','col_name'=>'Basic Pay','is_mandatory'=>false,'data_type'=>'str','format'=>null,'allowed_values'=>null,'custom'=>'check_basic_pay','params'=>['row','policy_terms','slab_details']],'band_grade'=>['col_idx'=>10,'col_cell_name'=>'K','col_name'=>'Band/Grade','is_mandatory'=>false,'data_type'=>'str','format'=>null,'allowed_values'=>null,'custom'=>'check_employee_band','params'=>['row','policy_terms','slab_details']],'designation'=>['col_idx'=>11,'col_cell_name'=>'L','col_name'=>'Designation','is_mandatory'=>false,'data_type'=>'str','format'=>null,'allowed_values'=>null],'phone'=>['col_idx'=>12,'col_cell_name'=>'M','col_name'=>'Phone','is_mandatory'=>false,'data_type'=>'str','format'=>null,'allowed_values'=>null,'custom' => 'check_dup_mobileno','params' => ['row','existing_mobilenos']],'email'=>['col_idx'=>13,'col_cell_name'=>'N','col_name'=>'Email','is_mandatory'=>false,'data_type'=>'str','format'=>null,'allowed_values'=>null],'pre_existing_ailments'=>['col_idx'=>14,'col_cell_name'=>'O','col_name'=>'PRE EXISTING AILMENTS','is_mandatory'=>['I','A','DA'],'data_type'=>'str','format'=>null,'allowed_values'=>['0','1']],'change_event'=>['col_idx'=>15,'col_cell_name'=>'P','col_name'=>'Change event','is_mandatory'=>['A','DA','D'],'data_type'=>'str','format'=>null,'allowed_values'=>null],'date_of_exit'=>['col_idx'=>16,'col_cell_name'=>'Q','col_name'=>'Date of exit','is_mandatory'=>['D'],'data_type'=>'str','format'=>'d-M-Y','allowed_values'=>null],'reason_for_exit'=>['col_idx'=>17,'col_cell_name'=>'R','col_name'=>'Reason for exit','is_mandatory'=>['D'],'data_type'=>'str','format'=>null,'allowed_values'=>null]];
protected $deletion_excel_columns = ['sno'=>['col_idx'=>0,'col_cell_name'=>'A','col_name'=>'S.No','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'emp_id'=>['col_idx'=>1,'col_cell_name'=>'B','col_name'=>'EMP ID','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'name_of_emp_dep'=>['col_idx'=>2,'col_cell_name'=>'C','col_name'=>'NAME OF EMP/DEP','is_mandatory'=>true,'data_type'=>'str','format'=>null,'allowed_values'=>null],'change_event'=>['col_idx'=>3,'col_cell_name'=>'D','col_name'=>'Change event','is_mandatory'=>['D'],'data_type'=>'str','format'=>null,'allowed_values'=>null],'date_of_exit'=>['col_idx'=>4,'col_cell_name'=>'E','col_name'=>'Date of exit','is_mandatory'=>['D'],'data_type'=>'str','format'=>'d-M-Y','allowed_values'=>null],'reason_for_exit'=>['col_idx'=>5,'col_cell_name'=>'F','col_name'=>'Reason for exit','is_mandatory'=>['D'],'data_type'=>'str','format'=>null,'allowed_values'=>null]];
@@ -140,11 +140,12 @@ class EmployeeServiceController extends AdminController
// dd($columns_to_check);die();
// get policy and rack details
- $policy_terms = $this->clientPolicyModel->getPolicyDetails($file['client_id'],$file['policy_id']);
- $policy_terms = json_decode($policy_terms[0]->policy_terms);
+ $policy_details = $this->clientPolicyModel->getPolicyDetails($file['client_id'],$file['policy_id']);
+ $policy_terms = json_decode($policy_details[0]->policy_terms);
$policy_terms = (array) $policy_terms;// convert obj to array
+ $default_age_ratio = isset($policy_details[0]->age_ratio) ? json_decode($policy_details[0]->age_ratio) : [];
//
- // dd($policy_terms);
+ // dd($default_age_ratio);
//get policy slab rates
$slab_details = $this->policiesModel->getPolicySlabRatesForEmpOnboard($file['policy_id'],$file['client_id']);
@@ -153,6 +154,9 @@ class EmployeeServiceController extends AdminController
//remove header
unset($excel_data[0]);
$relationship = $this->general_relationships;
+ //get exisiting mobilr nos
+ $existing_mobilenos = $this->employeePolicyModel->getExisitingMobileNos(client_policy_id: $file['policy_id']);
+ // dd($existing_mobilenos);
foreach ($excel_data as $row_key => $row)
{
@@ -169,10 +173,12 @@ class EmployeeServiceController extends AdminController
{
break;
}
- //iterate each row
+
+ //iterate each row for columns validations
foreach ($row as $col_key => $col)
{
+
$is_mandatory = $columns_to_check[$keys[$col_key]]['is_mandatory'];
$format = $columns_to_check[$keys[$col_key]]['format'];
$allowed_values = $columns_to_check[$keys[$col_key]]['allowed_values'];
@@ -263,13 +269,8 @@ class EmployeeServiceController extends AdminController
$result['error_summary'] = array_count_values($result['error_summary']);
$status = 'failed';
$failure_reason = ((json_encode($result)));
- $this->fileModel->where('id', $file_id)->set(['status' => $status,'reason' => $failure_reason])->update();
+ $this->fileModel->where('id', $file_id)->set(['status' => $status,'reason' => $failure_reason])->update();
$this->myLogger->logme("error",'{file_id} uploaded failed',['file_id' => $file_id]);
- //return $this->respond(['dataStatus' => true,'code' => 404,'data' => 'file upload failed with errors'], 200);
- // dd($failure_reason);
-
-
- //print_r($r);
}
else //trigger next data validation via job queue server
{
@@ -350,13 +351,15 @@ class EmployeeServiceController extends AdminController
if($file['action'] == 'dependent_addition')
{
$existing_famility_details = $this->employeeModel->getEmpFamilybyEmpCode(emp_code: $emp_id,client_id: $file['client_id'],client_policy_id: $file ['policy_id'],emp_status: ['active'],policy_status:['active']);
- // dd($existing_famility_details);
+ // dd(($existing_famility_details));
//transsform familiy details from db columns to exxcel row with column indexs for checking remaining functionalitites
$existing_famility_details = transform_db_data_to_excel($existing_famility_details,$file);
- // dd($existing_famility_details);
+ // dd(array_keys($existing_famility_details[0]));
$family = array_merge($family,$existing_famility_details);
+ // kint::dump($family);
+ $family = data_group_by_family($family)[ $emp_id ];// reason to call this again is bring self to first index of the array
}
- // kint::dump($family);die();
+ // kint::dump($family);//die();
//check name dup within a family
if($file['action'] == 'inception' || $file['action'] == 'addition' || $file['action'] == 'dependent_addition')
@@ -373,14 +376,26 @@ class EmployeeServiceController extends AdminController
}
}
- if(($file['action'] == 'inception' || $file['action'] == 'addition') && ($policy_details['is_addon'] != 3)) // 3 is depent addon
+ if(($file['action'] == 'inception' || $file['action'] == 'addition' || $file['action'] == 'dependent_addition') && ($policy_details['policy_type_id'] != 3)) // 3 is GMC parents (base policy or dep addon)
{
$res = check_self_available_in_family($family,$file['action']);
// dd($res);
if(!$res['is_self_found'])
{
array_push($result['error_summary'],14); // Self not found
- $result['error_data'][ $res['emp_code'] ]['name_of_emp_dep']['error'][] = "Self not found ";
+ $result['error_data'][ $res['row_id'] ]['sno']['error'][] = "Self not found ";
+ }
+ }
+
+ //check self avaialbe where self data is not available either in excel or same policy (i.e.) gMC parents
+ if($policy_details['policy_type_id'] == 3) // 3 is GMC parents (base policy or dep addon)
+ {
+ $self_details = $this->employeeModel->getEmpFamilybyEmpCode(emp_code: $emp_id,client_id: $file['client_id'],emp_status: ['active'],policy_status:['active']);
+ // dd($self_details);
+ if(!count($self_details))
+ {
+ array_push($result['error_summary'],14); // Self not found
+ $result['error_data'][ $family[0][0] ]['sno']['error'][] = "Self not found ";
}
}
@@ -458,8 +473,7 @@ class EmployeeServiceController extends AdminController
else //inception OR addition OR dependent addition
{
//proceed next data level validation in JOB queue
- $job_details = new Jobs();
-
+ $job_details = new Jobs();
$r = Jobs::addJob(['job_name' => 'employeesOnboardPreprocess','payload' => ['file_id' => $file_id]]);
// $jobWorker = new JobWorker();
// JobWorker::processJob($r);
@@ -501,7 +515,12 @@ class EmployeeServiceController extends AdminController
}
$columns_to_check = [];
- if($file['action'] == 'inception'){ $columns_to_check = $this->inception_excel_columns; }
+ if($file['action'] == 'inception'){ $columns_to_check = $this->inception_excel_columns; }
+ if($file['action'] == 'addition'){ $columns_to_check = $this->inception_excel_columns; }
+ if($file['action'] == 'dependent_addition'){ $columns_to_check = $this->inception_excel_columns; }
+ if($file['action'] == 'deletion'){ $columns_to_check = $this->deletion_excel_columns; }
+ if($file['action'] == 'correction'){ $columns_to_check = $this->correction_excel_columns; }
+ if($file['action'] == 'si_enhancement'){ $columns_to_check = $this->si_enhance_excel_columns; }
// get policy and rack details
$policy_terms = $this->clientPolicyModel->getPolicyDetails($file['client_id'],$file['policy_id']);
@@ -515,6 +534,7 @@ class EmployeeServiceController extends AdminController
$highestRowAndColumn = $sheet->getHighestRowAndColumn();
$allowedHighestColumn = end($columns_to_check);
+ // dd($allowedHighestColumn);
$excel_data = $sheet->rangeToArray('A1:' . $allowedHighestColumn['col_cell_name'] . $highestRowAndColumn['row']);
unset($excel_data[0]);
@@ -537,6 +557,7 @@ class EmployeeServiceController extends AdminController
$existing_famility_details = transform_db_data_to_excel($existing_famility_details,$file);
// Kint::dump($existing_famility_details);
$family = array_merge($family,$existing_famility_details);
+ $family = data_group_by_family($family)[ $emp_id ];// reason to call this again is bring self to first index of the array
// dd($family);
}
@@ -589,7 +610,7 @@ class EmployeeServiceController extends AdminController
// die();
- return ($employee_data_group_by_family);
+ return (($employee_data_group_by_family));
}
@@ -826,15 +847,10 @@ class EmployeeServiceController extends AdminController
{
$familiy_data = $params['familiy_data'];
$file = $params['file'];
- // dd($file);
- // print_r($familiy_data);
- // echo '------------------------------------------------------';
-
-
-
+ $slab_details = $this->policiesModel->getPolicySlabRatesForEmpOnboard($file['policy_id'],$file['client_id']);
foreach($familiy_data as $fkey => $value)
{
- if($file['id'] == null || $value['temp']['source'] == 'excel') //insert data come from excel and from db i.e. ( $file['id'] == null for enrollment data)
+ if($file['id'] == null || $value['temp']['source'] == 'excel' || (($file['action'] == 'dependent_addition' && in_array($value['temp']['source'],[10,11]) && ($slab_details['slab_rates'][0]['premium_type'] == 1 && strtolower($value['relationship']) == 'self') || ($slab_details['slab_rates'][0]['premium_type'] == 1 || $slab_details['slab_rates'][0]['premium_type'] == null)))) //insert data come from excel and from db i.e. ( $file['id'] == null for enrollment data)
{
$employee = $this->employeeModel->checkExistingEmp($value);
@@ -842,11 +858,26 @@ class EmployeeServiceController extends AdminController
$temp = $value['temp'];
unset($value['policy_details']);
unset($value['temp']);
+ // Kint::dump($value);
+ // Kint::dump($policy_data);
+ //start implemet of si enhancement of grid type 10,11
+ if(count($employee) && (($file['action'] == 'dependent_addition' && in_array($value['temp']['source'],[10,11]) && ($slab_details['slab_rates'][0]['premium_type'] == 1 && strtolower($value['relationship']) == 'self') || ($slab_details['slab_rates'][0]['premium_type'] == 2 || $slab_details['slab_rates'][0]['premium_type'] == null))))
+ {
+ $res = $this->employeesSIEnhanceProcessWhileOnbboard(employee:$employee[0],policy_data: $policy_data,file:$file);// where employee holds existing emp data and policy_data holds new si enhancement
+ if(!$res)
+ {
+ //if endorsement not happend no need to update emp/policy details in DB.
+ break;
+ }
+ }
+ //end implemet of si enhancement of grid type 10,11
+
//save employee table
if(count($employee))
{
$value['updated_by'] = $file['created_by'];
$value['id'] = $employee[0]['id'];
+ $value['emp_status'] = 'active';
$log_message = 'Update Employee - '.$employee[0]['name'].'('.$employee[0]['emp_code'].') with PK '.$employee[0]['id'];
// $this->myLogger->logme('error',('Update - ' . $employee[0]['id'].' - '. $employee[0]['emp_code'] .' - '.$employee[0]['name']));
}
@@ -895,7 +926,50 @@ class EmployeeServiceController extends AdminController
}// for end
}//function end
-
+ // $employee -> holds existing emp model obj and $policy_data holds new policy changes as array
+ public function employeesSIEnhanceProcessWhileOnbboard(array $employee,array $policy_data,array $file)
+ {
+ $employee = $this->employeeModel->where('emp_code', $employee['emp_code'])->where('name',$employee['name'])->where('client_id',$employee['client_id'])->where('is_active',1)->first();
+
+ $employee_policy = $this->employeePolicyModel->where('employee_id',$employee['id'])->where('client_policy_id',$file['policy_id'])->first();
+ // dd($employee_policy);
+ $slab_details = $this->policiesModel->getPolicySlabRatesForEmpOnboard($employee_policy['client_policy_id'],$employee['client_id']);
+
+ //check si has changed in normal case OR check premium only changed, still treat as SI enhancement in grid type 10
+ if($employee_policy['basic_cover_si'] != $policy_data['basic_cover_si'] || ($slab_details['grid_master']['ui_type'] == 10 && $policy_data['premimum'] != null && $policy_data['premimum'] != "" && $employee_policy['premimum'] != $policy_data['premimum']))
+ {
+ $existing_endorsements = $this->empEndorsementModel->where('actions','si')
+ ->where('table_name','employee_polices')
+ ->where('endorsement_id is null')
+ ->where('emp_code',$employee['emp_code'])
+ ->where('name',$employee['name'])
+ ->where('field_name','basic_cover_si')
+ ->findAll();
+ // dd($existing_endorsements);
+ //make entry in endorsement table
+ if(!count($existing_endorsements))
+ {
+
+ foreach ($slab_details['slab_rates'] as $skey => $slab_value)
+ {
+ if($slab_value['si'] == $policy_data['basic_cover_si'])
+ {
+ $group_key = rand(100000, 999999);
+ $this->empEndorsementModel->save(['pk' => (int)$employee['id'],'emp_code' => $employee['emp_code'],'table_name' => 'employee_polices','actions' => 'si','name' => $employee['name'],'field_name' => 'basic_cover_si','old_value' => $employee_policy['basic_cover_si'],'new_value' => $policy_data['basic_cover_si'],'created_by' => $file['created_by'],'remarks' => 'general si enhancement via DA','group_key' => $group_key,'file_id' => $file['id']]);
+ $this->empEndorsementModel->save(['pk' => (int)$employee['id'],'emp_code' => $employee['emp_code'],'table_name' => 'employee_polices','actions' => 'si','name' => $employee['name'],'field_name' => 'premium','old_value' => $employee_policy['premium'],'new_value' => $slab_value['premium'],'created_by' => $file['created_by'],'remarks' => 'general si enhancement via DA','group_key' => $group_key,'file_id' => $file['id']]);
+ $this->empEndorsementModel->save(['pk' => (int)$employee['id'],'emp_code' => $employee['emp_code'],'table_name' => 'employee_polices','actions' => 'si','name' => $employee['name'],'field_name' => 'si_enhancement_date','old_value' => null,'new_value' => date('Y-m-d'),'created_by' => $file['created_by'],'remarks' => 'general si enhancement via DA','group_key' => $group_key,'file_id' => $file['id']]);
+ $this->myLogger->logme('error',($employee['emp_code'].' - '.$employee['name'].'- ( NEW/OLD SI - '.$employee_policy['basic_cover_si'].'/'.$policy_data['basic_cover_si'].')'. '( NEW/OLD PREMIUM - '.$employee_policy['premium'].'/'.$policy_data['premimum'].') '.' - si enhancement via DA'));
+ return true; //retun true when endorsement inserted
+
+ }
+ }
+ }
+ return false; //retun false when endorsement not happend
+ }
+ return false; //retun false when endorsement not happend
+
+
+ }
// ---------------------------------------------------------------------------------
diff --git a/app/Controllers/JobWorker.php b/app/Controllers/JobWorker.php
index 00b060ae..9ae90d51 100644
--- a/app/Controllers/JobWorker.php
+++ b/app/Controllers/JobWorker.php
@@ -14,7 +14,11 @@ class JobWorker extends AdminController
* Constructs the class
*/
- private static $event_class_mapping = ['add' => ['type' => 'HC','handler' => 'App\\Helpers\\HttpRequestHelper'], 'sub' => ['type' => 'CC','handler' => 'App\\Controllers\\Jobs\SubJob'],'fancy_date_time_format' => [ 'type' => 'HF','handler' => 'fancy_date_time_format'],'addNumber' => ['type' => 'HC','handler' => 'App\\Model\\HttpRequestHelper'],'excelFileFormatValidation' => ['type' => 'CC','handler' => 'App\\Controllers\\EmployeeServiceController'],'excelFileDataValidation' => ['type' => 'CC','handler' => 'App\\Controllers\\EmployeeServiceController'],'employeesOnboardPreprocess' => ['type' => 'CC','handler' => 'App\\Controllers\\EmployeeServiceController'],'employeeDisembark' => ['type' => 'CC','handler' => 'App\\Controllers\\EmployeeServiceController'],'employeesSIEnhanceProcess' => ['type' => 'CC','handler' => 'App\\Controllers\\EmployeeServiceController'],'employeesCorrectionProcess' => ['type' => 'CC','handler' => 'App\\Controllers\\EmployeeServiceController'],'send_email' => ['type' => 'HC','handler' => 'App\\Helpers\\MailHelper'],'bulk_mail' => ['type' => 'HC','handler' => 'App\\Helpers\\MailHelper']];
+ private static $event_class_mapping = [
+ 'add' => ['type' => 'HC', 'handler' => 'App\\Helpers\\HttpRequestHelper'], 'sub' => ['type' => 'CC', 'handler' => 'App\\Controllers\\Jobs\SubJob'], 'fancy_date_time_format' => ['type' => 'HF', 'handler' => 'fancy_date_time_format'], 'addNumber' => ['type' => 'HC', 'handler' => 'App\\Model\\HttpRequestHelper'], 'excelFileFormatValidation' => ['type' => 'CC', 'handler' => 'App\\Controllers\\EmployeeServiceController'], 'excelFileDataValidation' => ['type' => 'CC', 'handler' => 'App\\Controllers\\EmployeeServiceController'], 'employeesOnboardPreprocess' => ['type' => 'CC', 'handler' => 'App\\Controllers\\EmployeeServiceController'], 'employeeDisembark' => ['type' => 'CC', 'handler' => 'App\\Controllers\\EmployeeServiceController'], 'employeesSIEnhanceProcess' => ['type' => 'CC', 'handler' => 'App\\Controllers\\EmployeeServiceController'], 'employeesCorrectionProcess' => ['type' => 'CC', 'handler' => 'App\\Controllers\\EmployeeServiceController'], 'send_email' => ['type' => 'HC', 'handler' => 'App\\Helpers\\MailHelper'], 'bulk_mail' => ['type' => 'HC', 'handler' => 'App\\Helpers\\MailHelper'], 'insertBatchList' => ['type' => 'CC', 'handler' => 'App\\Controllers\\EmpDataServiceController'],
+ 'importInceptionFileValidation' => ['type' => 'CC', 'handler' => 'App\\Controllers\\EmpDataServiceController'],
+ 'importInceptionUpdateTPAandUHID' => ['type' => 'CC', 'handler' => 'App\\Controllers\\EmpDataServiceController'],
+ ];
public function __construct()
{
// echo 'HiC';//die();
@@ -66,6 +70,7 @@ class JobWorker extends AdminController
*/
public static function processJob(array $jobdata = [])
{
+
// print_r($jobdata);
// echo 'listen';
// die();
diff --git a/app/Controllers/MasterController.php b/app/Controllers/MasterController.php
index 3ec5bec3..a2c011a2 100644
--- a/app/Controllers/MasterController.php
+++ b/app/Controllers/MasterController.php
@@ -7,6 +7,7 @@ use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
use CodeIgniter\API\ResponseTrait;
+use CodeIgniter\Files\File;
use App\Models\UserModel;
use App\Models\ClientModel;
@@ -186,8 +187,11 @@ class MasterController extends AdminController
{
$this->myLogger->logme('error','Insurer general info function called');
+ $uploadFilePath = ROOTPATH . 'public/uploads/logo/';
+ $file_name = file_Upload($this->request->getFile('insurer_logo'), $uploadFilePath);
$data = $this->request->getPost();
$data['created_by'] = get_session_userid();
+ $data['insurer_logo'] = $file_name;
$insert = $this->insurerModel->insert($data);
if($insert){
@@ -249,9 +253,18 @@ class MasterController extends AdminController
public function editInsurerGeneralInfo()
{
$this->myLogger->logme('error','edit Insurer general info function called');
+
+ $uploadFilePath = ROOTPATH . 'public/uploads/logo/';
+ $file_name = file_Upload($this->request->getFile('insurer_logo'), $uploadFilePath);
+
$id = $this->request->getPost('PrimaryKey');
$data = $this->request->getPost();
$data['updated_by'] = get_session_userid();
+
+ if(!empty($file_name)){
+ $data['insurer_logo'] = $file_name;
+ }
+
$update = $this->insurerModel->update($id,$data);
if($update){
echo json_encode(array("status" => true , 'data' => $data));
@@ -399,10 +412,50 @@ class MasterController extends AdminController
{
$this->myLogger->logme('error','TPA general info function called');
+
+ $uploadFilePath = ROOTPATH . 'public/uploads/logo/';
+ $file_name = file_Upload($this->request->getFile('tpa_logo'), $uploadFilePath);
+
+ $template_bg_path = ROOTPATH . 'public/uploads/template_bg';
+ $front_card_file_name = file_Upload($this->request->getFile('fc'), $template_bg_path);
+ $back_card_file_name = file_Upload($this->request->getFile('bc'), $template_bg_path);
+
+
+ $eCardTemplate = $this->request->getPost('ecard_content');
$data = $this->request->getPost();
$data['created_by'] = get_session_userid();
+ $data['tpa_logo'] = $file_name;
+ $data['front_card'] = $front_card_file_name;
+ $data['back_card'] = $back_card_file_name;
$insert = $this->tpaModel->insert($data);
+
+ $tpa_name = (string) $this->request->getPost('name');
+ $short_name = (string) $this->request->getPost('short_name');
+
+ $filename = strtolower(str_replace(' ', '_', $short_name)) . '.html';
+ $file_directory = WRITEPATH . 'e_card_template/';
+ $file_path = $file_directory . $filename;
+
+ // Ensure that the directory exists, if not, create it
+ if (!is_dir($file_directory)) {
+ mkdir($file_directory, 0777, true);
+ }
+
+ // Set the appropriate content type
+ header('Content-type:text/html; charset=utf-8');
+
+ // Write the HTML content to the file
+ $data = file_put_contents($file_path, $eCardTemplate);
+
+
+ if ($data !== false) {
+ $this->myLogger->logme('error', 'TPA: {tpa}, e-Card HTML template file saved successfully: {data}, filepath is: {path}', ['data' => $filename, 'tpa' => $tpa_name, 'path' => $file_path]);
+ } else {
+ $this->myLogger->logme('error', 'TPA: {tpa}, e-Card HTML template file unable to save: {data}', ['data' => $filename, 'tpa' => $tpa_name]);
+ }
+
+
if($insert){
$tpa_data = $this->tpaModel->where(['id' => $insert, 'is_active' => 1])->first();
echo json_encode(array("status" => true , 'data' => $tpa_data));
@@ -457,11 +510,23 @@ class MasterController extends AdminController
$this->myLogger->logme('error','Edit TPA Onboarding function called');
$headerData['page_name'] = 'Edit TPA Master';
- $editData['tpa'] = $this->tpaModel->where(['id' => $id, 'is_active' => 1])->first();
+ $tpa_data = $this->tpaModel->where(['id' => $id, 'is_active' => 1])->first();
+
+ $editData['tpa'] = $tpa_data;
$editData['tpa_branch'] = $this->tpaBranchModel->where(['tpa_id' => $id, 'is_active' => 1])->findAll();
$editData['state'] = $this->stateModel->getAllStates();
+ $filename = strtolower(str_replace(' ', '_', $tpa_data['short_name'])) . '.html';
+ $template_data_path = WRITEPATH . 'e_card_template/';
+ $final_path = $template_data_path . $filename;
+
+ if (file_exists($final_path)) {
+
+ $tmplt_data = file_get_contents($final_path);
+ $editData['template_data'] = $tmplt_data;
+ }
+
// echo "";
// print_r($editData); die;
@@ -477,10 +542,61 @@ class MasterController extends AdminController
public function editTPAGeneralInfo()
{
$this->myLogger->logme('error','edit TPA general info function called');
+
+ $uploadFilePath = ROOTPATH . 'public/uploads/logo/';
+ $file_name = file_Upload($this->request->getFile('tpa_logo'), $uploadFilePath);
+
+ $template_bg_path = ROOTPATH . 'public/uploads/template_bg';
+ $front_card_file_name = file_Upload($this->request->getFile('fc'), $template_bg_path);
+ $back_card_file_name = file_Upload($this->request->getFile('bc'), $template_bg_path);
+
$id = $this->request->getPost('PrimaryKey');
$data = $this->request->getPost();
$data['updated_by'] = get_session_userid();
+
+ if(!empty($file_name)){
+ $data['tpa_logo'] = $file_name;
+ }
+
+ if(!empty($front_card_file_name)){
+ $data['front_card'] = $front_card_file_name;
+ }
+
+ if(!empty($back_card_file_name)){
+ $data['back_card'] = $back_card_file_name;
+ }
+
$update = $this->tpaModel->update($id,$data);
+
+
+ $tpa_name = (string) $this->request->getPost('name');
+ $short_name = (string) $this->request->getPost('short_name');
+ $eCardTemplate = $this->request->getPost('ecard_content');
+
+ $filename = strtolower(str_replace(' ', '_', $short_name)) . '.html';
+ $file_directory = WRITEPATH . 'e_card_template/';
+ $file_path = $file_directory . $filename;
+
+ // Ensure that the directory exists, if not, create it
+ if (!is_dir($file_directory)) {
+ mkdir($file_directory, 0777, true);
+ }
+
+ // Set the appropriate content type
+ header('Content-type:text/html; charset=utf-8');
+
+ // Write the HTML content to the file
+ $data = file_put_contents($file_path, $eCardTemplate);
+
+
+ if ($data !== false) {
+ $this->myLogger->logme('error', 'TPA: {tpa}, e-Card HTML template file saved successfully: {data}, filepath is: {path}', ['data' => $filename, 'tpa' => $tpa_name, 'path' => $file_path]);
+ } else {
+ $this->myLogger->logme('error', 'TPA: {tpa}, e-Card HTML template file unable to save: {data}', ['data' => $filename, 'tpa' => $tpa_name]);
+ }
+
+
+
if($update){
echo json_encode(array("status" => true , 'data' => $data));
}else{
@@ -504,9 +620,6 @@ class MasterController extends AdminController
}
-
-
-
public function editTPABranch()
{
$this->myLogger->logme('error','TPA branch CREATE function called');
@@ -548,8 +661,6 @@ class MasterController extends AdminController
}
-
-
public function tpaBranchList($id = null)
{
$this->myLogger->logme('error','TPA List function called');
diff --git a/app/Controllers/NotificationController.php b/app/Controllers/NotificationController.php
new file mode 100644
index 00000000..e0a6280c
--- /dev/null
+++ b/app/Controllers/NotificationController.php
@@ -0,0 +1,159 @@
+myLogger = \Config\Services::mylogger();
+ $this->notificationModel = new NotificationModel();
+ }
+
+ // This is for Template Name Camel Case to Snake Case for store in DB
+ public function camelCaseToSnakeCase($input)
+ {
+ $input = preg_replace('/(?camelCaseToSnakeCase($this->request->getPost('template_name'));
+ $form_data['subject'] = $this->request->getPost('subject');
+ $form_data['mail_content'] = $this->request->getPost('mailContent');
+ $form_data['client_id'] = $this->request->getPost('client_id');
+ $notificationModel = new NotificationModel();
+
+ $find_notification = $notificationModel->where('client_id',$form_data['client_id'])->where('template_name',$form_data['template_name'])->first();
+ if ($find_notification) {
+ $id = $find_notification['id'];
+ $form_data['updated_by'] = get_session_userid();
+ $notificationModel->update($id,$form_data);
+ $complete = "Update";
+ }else{
+ $form_data['created_by'] = get_session_userid();
+ $notificationModel->insert($form_data);
+ $complete = "Inserted";
+ }
+ return json_encode($complete);
+
+ }
+
+ // This is for the Enabls in Notification area and Update the Recipient and HR Mail Id in( Enables -> Notification table and Mail id's -> Client table)
+ public function update_enable()
+ {
+ $checkboxNames = [
+ 'member_welcome_mail_btn',
+ 'member_reminder_mail_btn',
+ 'member_ecard_mail_btn',
+ 'member_review_and_summary_mail_btn',
+ 'account_maneger_summary_mail_btn',
+ 'client_hr_summary_mail_btn'
+ ];
+ $data = [];
+
+ foreach ($checkboxNames as $checkboxName)
+ {
+ $data[str_replace('_btn', '', $checkboxName)] = ($this->request->getPost($checkboxName) === "true") ? 1 : 0;
+ }
+
+ $notificationModel = new NotificationModel();
+ $clientModel = new ClientModel();
+
+ $id =$this->request->getPost('client_id');
+ $clientData['common_mails'] = $this->request->getPost('nhance_team_mail_ids');
+ $clientData['hr_mails'] = $this->request->getPost('hr_mail_id');
+ $clientModel->update($id,$clientData);
+
+ foreach ($data as $key => $value)
+ {
+ $find = $notificationModel->where('client_id',$this->request->getPost('client_id'))->where('template_name', $key)->first();
+ if ($find)
+ {
+ $id = $find['id'];
+ $changeData['enabled']= $value;
+ $update = $notificationModel->update($id, $changeData);
+ }
+ }
+ return json_encode("true");
+ }
+
+ // This for Load the Template Data for in View Page
+ public function getMailTemplateData($template_name,$client_id)
+ {
+ $notificationModel = new NotificationModel();
+
+ $value = $notificationModel->where('client_id',$client_id)->where('template_name',$template_name)->first();
+
+ return json_encode($value);
+ }
+
+ // This will send the Reminder Mail
+ public function reminder_mail()
+ {
+ $clientModel = new ClientModel();
+ $employeeModel = new EmployeeModel();
+ $notificationModel = new NotificationModel();
+
+ $client_list = $clientModel->where('is_active',1)->findAll();
+
+ $wholeData = [];
+ foreach($client_list as $key=>$value){
+ $notification_data = $notificationModel->where('client_id',$value['id'])->where('template_name', 'member_reminder_mail')->first();
+
+ $client_data = $clientModel->where('id', $value['id'])->first();
+
+ if(isset($notification_data) && $notification_data['enabled'] == 1){
+ $emp_data = $employeeModel->where('client_id', $value['id'])->where('is_active',1)->where('emp_status','draft')->findAll();
+ if( count($emp_data) != 0)
+ {
+ $params['emp_data'] = $emp_data;
+ $params['client_data'] = $client_data;
+ $params['notification_data'] = $notification_data;
+ $wholeData[] =sendMailNotification::sendMailNotification('member_reminder_mail', $params);
+ }
+ }
+ }
+
+ $count = 0;
+ foreach ($wholeData as $index => $values) {
+ $whole_index = $index;
+ foreach ($values as $index => $value) {
+ $count++;
+ $temp_whole_data[] = $value;
+ if($count == 20 || $whole_index == count($wholeData)-1 && $index == count($values)-1){
+ $job_details = new Jobs();
+ $r = Jobs::addJob(['job_name' => 'bulk_mail','payload' => $temp_whole_data]);
+
+ $temp_whole_data = [];
+ $count = 0;
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/Controllers/PendingActionsController.php b/app/Controllers/PendingActionsController.php
new file mode 100644
index 00000000..9670dbba
--- /dev/null
+++ b/app/Controllers/PendingActionsController.php
@@ -0,0 +1,26 @@
+request->getJSON()->mobile_number;
$otp = $this->request->getJSON()->otp;
- $employeeData = $this->employeeModel->where('mobile', $mobile_number)->first();
+ $employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first();
if ($employeeData && $otp == $employeeData["otp"] || $employeeData && isset($this->request->getJSON()->login_by_hr)) {
$auth = HttpRequestHelper::getRequestInfo();
if ($auth) {
diff --git a/app/Helpers/MailHelper.php b/app/Helpers/MailHelper.php
index 212d78d9..55d17264 100644
--- a/app/Helpers/MailHelper.php
+++ b/app/Helpers/MailHelper.php
@@ -16,9 +16,16 @@ class MailHelper
{
public static function send_email($params)
{
+
+ // print_r($params);die;
$emaill = $params['mail'];
$subject = $params['subject'];
$message = $params['message'];
+ if (isset($params['bcc'])) {
+ $bcc = $params['bcc'];
+ }else{
+ $bcc= '';
+ }
try {
$email = \Config\Services::email();
@@ -27,7 +34,17 @@ class MailHelper
$email->setTo($emaill);
+ if (!empty($bcc)) {
+ // Convert the comma-separated string into an array
+ $bccList = explode(',', $bcc);
+ // Trim whitespace from each email ID
+ $bccList = array_map('trim', $bccList);
+ // Set BCC recipients
+ $email->setBCC($bccList);
+ }
+
$email->setSubject($subject);
+
$email->setMessage($message);
if ($email->send()) {
@@ -44,6 +61,7 @@ class MailHelper
public static function bulk_mail(array $mails = [])
{
+ // print_r();die;
$model = new JobModel();
$start = microtime(true);
$runtime= 0;
diff --git a/app/Helpers/excel_util_helper.php b/app/Helpers/excel_util_helper.php
index 1e98e9fb..e4561843 100644
--- a/app/Helpers/excel_util_helper.php
+++ b/app/Helpers/excel_util_helper.php
@@ -1,6 +1,7 @@
slugify($row[5]);
// echo $col;//die();
- // if($col != 'self' && $col != 'spouse')
- // {
+ if($col != 'self' && $col != 'spouse')
+ {
if(!isset($relationship[ $col ]))
{
return array('status' => false,'error' => 'Rule Conflict: Unknown Relationship');
@@ -104,7 +105,7 @@ if(!function_exists('check_relationship'))
}
- // }
+ }
return array('status' => true);
}
else
@@ -142,6 +143,13 @@ if(!function_exists('check_employee_band'))
if($row['current_action'] != null && in_array(strtoupper($row['current_action']), ['I','A','DA']))// check rule only of action column data available
{
$is_emp_band_needed = $slab_details['grid_master']['emp_band'];
+ if($slab_details['grid_master']['ui_type'] == 1) //gpa rack rate 1
+ {
+ if($slab_details['slab_rates'][0]['si_or_bp'] == 3)
+ {
+ $is_emp_band_needed = true;
+ }
+ }
$slug = \Config\Services::slug();
$relationship = $slug->slugify($row[5]);
// echo $relationship;echo $row[7];
@@ -170,21 +178,65 @@ if(!function_exists('check_si'))
{
function check_si($row,$policy_terms,$slab_details)
{
+ $return_array = array('status' => true,'error' => '');
+ $is_si_found = false;
+ $is_age_slab_found = false;
if($row['current_action'] != null && in_array(strtoupper($row['current_action']), ['I','A','DA','SI']))// check rule only of action column data available
{
$received_si = $row['current_action'] == 'SI' ? $row[3] : $row[6];
- $found = false;
foreach ($slab_details['slab_rates'] as $skey => $slab_value)
{
- if($slab_value['si'] == $received_si)
+ if($is_si_found && $is_age_slab_found)
{
- $found = true;
break;
}
+
+ if(!$is_si_found && $slab_value['si'] == $received_si) //match si amount
+ {
+ $is_si_found = true;
+ }
+
+ // check age slab
+ if($row[3] != null && DateTime::createFromFormat('d-M-Y', $row[3]) !== false)// dob
+ {
+ $dob = change_date_format($row[3],'d-M-Y','Y-m-d');
+ // echo $row[3].' - '.$dob;echo '
';
+ $currentDateTime = new DateTime();//die();
+ $passedDateTime = new DateTime($dob);
+ $interval = $currentDateTime->diff($passedDateTime);
+ if(!$is_age_slab_found)
+ {
+ if(isset($slab_value['age_from']) && isset($slab_value['age_to']))
+ {
+ if($slab_value['age_from'] !== null && $slab_value['age_to'] !== null && $slab_value['age_from'] <= $interval->y && $slab_value['age_to'] >= $interval->y && $slab_value['si'] == $received_si)
+ {
+ $is_age_slab_found = true;// send true if age slab found
+ }
+ }
+ else
+ {
+ $is_age_slab_found = true;// send true if age conditin is not applicable
+ }
+
+ }
+
+ }//end of check age slab
}
- if(!$found) { return array('status' => false,'error' => "Sum insured not found"); }
- return array('status' => true);
- }else { return array('status' => true); } // in else condition no need to check rule, just return true
+
+ }
+
+ if(!$is_si_found)
+ {
+ $return_array['status'] = false;
+ $return_array['error'] = "Sum insured not found";
+ }
+ if(!$is_age_slab_found)
+ {
+ $return_array['status'] = false;
+ $return_array['error'] = !empty($return_array['error']) ? ($return_array['error'].', '.'Sum insured not configured for this age slab') : 'Sum insured not configured for this age slab';
+ }
+
+ return $return_array;
}
}
@@ -207,18 +259,31 @@ if(!function_exists('check_basic_pay'))
if (!function_exists('check_dob_diff'))
{
- function check_dob_diff($row,$relationships) {
+ function check_dob_diff($row,$relationships,$default_age_ratio) {
// echo 'called';
if($row['current_action'] != null && in_array(strtoupper($row['current_action']), ['I','A','DA']))// check rule only of action column data available
{
if($row[3] != null && $row[5] != null)
{
+ if (DateTime::createFromFormat('d-M-Y', $row[3]) === false)
+ {
+ return array('status' => false,'error' => 'Not a valid Date');
+ }
+ // return array('status' => true);
$dob = change_date_format($row[3],'d-M-Y','Y-m-d');
// echo $row[3].' - '.$dob;echo '
';
$currentDateTime = new DateTime();//die();
+ // print_r($currentDateTime);
+ // die();
$passedDateTime = new DateTime($dob);
+ // print_r($passedDateTime);
+
$interval = $currentDateTime->diff($passedDateTime);
-
+ //remap default age ratio data into relationship array
+ if(count($default_age_ratio))
+ {
+ $relationships = remap_default_age_ratio_into_relationship($relationships,$default_age_ratio);
+ }
$slug = \Config\Services::slug();
$relationship = $slug->slugify($row[5]);
$age_min = isset($relationships[$relationship]['age_min']) ? $relationships[$relationship]['age_min'] : NULL;
@@ -247,7 +312,7 @@ if (!function_exists('data_group_by_family'))
function data_group_by_family($emp_data,$data_source = 'excel')
{
$result = [];
- // dd($emp_data);
+ // Kint::dump($emp_data);
foreach ($emp_data as $rkey => $row)
{
if($data_source == 'excel')
@@ -305,8 +370,13 @@ if (!function_exists('check_self_available_in_family'))
{
function check_self_available_in_family($family_data)
{
-
+
$is_self_found = false;
+
+ $row_id_from_excel = array_filter($family_data,function($item){ return !isset($item['temp']);});
+ // Kint::dump($row_id_from_excel);
+ $row_id_from_excel = current($row_id_from_excel); // get excel sno/rowid of employee amoung familiy array where this array has both data from excel and db
+ $row_id_from_excel = $row_id_from_excel[0];
foreach ($family_data as $rkey => $row)
{
if($row[5] != null && strtolower($row[5]) == 'self')//$row[5] = relationship $row[4] = Gender
@@ -317,7 +387,7 @@ if (!function_exists('check_self_available_in_family'))
}
- return ['is_self_found' => $is_self_found,'emp_code' => $family_data[0][1]];
+ return ['is_self_found' => $is_self_found,'emp_code' => $family_data[0][1],'row_id' => $row_id_from_excel];
}
}
@@ -335,28 +405,31 @@ if (!function_exists('name_and_empid_check_in_db'))
foreach ($family_data as $rkey => $row)
{
- $res = $employeeModel
- ->join('client_policy cp',"employees.client_id = cp.client_id")
- ->join('employee_polices ep',"cp.id = ep.client_policy_id AND employees.id = ep.employee_id")
- // ->where("cp.id",$policy_id)
- ->where("employees.client_id",$client_id)
- ->where("employees.is_active",1)
- ->where("ep.is_active",1)
- // ->where("ep.client_id",$client_id)
- ->where('name',$row[2])->where('emp_code',$row[1])
- ->findAll();
-
- // dd($employeeModel->getLastQuery());
-
-
- if(($current_action == 'deletion' || $current_action == 'correction' || $current_action == 'si_enhancement') && !count($res))
- {
- array_push($result['del'],$row[0]);
- }
- if(($current_action == 'inception' || $current_action == 'dependent_addition' || $current_action == 'addition') && count($res))
- {
- array_push($result['i'],$row[0]);
- }
+ if(isset($row['temp']) && $row['temp']['source'] != 'db')
+ {
+ $res = $employeeModel
+ ->join('client_policy cp',"employees.client_id = cp.client_id")
+ ->join('employee_polices ep',"cp.id = ep.client_policy_id AND employees.id = ep.employee_id")
+ // ->where("cp.id",$policy_id)
+ ->where("employees.client_id",$client_id)
+ ->where("employees.is_active",1)
+ ->where("ep.is_active",1)
+ // ->where("ep.client_id",$client_id)
+ ->where('name',$row[2])->where('emp_code',$row[1])
+ ->findAll();
+
+ // dd($employeeModel->getLastQuery());
+
+
+ if(($current_action == 'deletion' || $current_action == 'correction' || $current_action == 'si_enhancement') && !count($res))
+ {
+ array_push($result['del'],$row[0]);
+ }
+ if(($current_action == 'inception' || $current_action == 'dependent_addition' || $current_action == 'addition') && count($res))
+ {
+ array_push($result['i'],$row[0]);
+ }
+ }
}
@@ -386,9 +459,9 @@ if (!function_exists('check_dependent_conflict'))
$self_emp_row_id = null;
$temp_counts = [2,3,4,5,6,7,8,9,10]; //temp variable for check relation repetaed count
$slug = \Config\Services::slug();
-
- // if($policy_terms['family_floater'] == true)
- // {
+ // dd($policy_terms);
+ if(isset($policy_terms['family_floater']) && !empty($policy_terms['family_floaters']))
+ {
// $temp_string = implode(" ",$policy_terms['family_floaters']);
$temp = $policy_terms['family_floaters'];
@@ -466,7 +539,7 @@ if (!function_exists('check_dependent_conflict'))
if(($allowed_spouse_count < $received_spouse_count) || ($allowed_child_count < $received_child_count) )
{
$result['status'] = false;
- $result['error_data'][] = ['code' => 12,'col_name' => 'sno','msg' => 'Rule conflict: Dependent count greater than allowed dependent count','row_id' => (isset($self_emp_row_id) ? $self_emp_row_id : $family_data[0][0])];//dependent count mismatch
+ $result['error_data'][] = ['code' => 12,'col_name' => 'sno','msg' => 'Rule conflict: As per policy, count of dependents has exceeded configured count','row_id' => (isset($self_emp_row_id) ? $self_emp_row_id : $family_data[0][0])];//dependent count mismatch
}
// || ($allowed_parents_count < $received_parents_count) || ($allowed_parent_in_laws_count < $received_parent_in_laws_count)
@@ -478,7 +551,7 @@ if (!function_exists('check_dependent_conflict'))
if((2 < $received_parents_count) || (2 < $received_parent_in_laws_count))
{
$result['status'] = false;
- $result['error_data'][] = ['code' => 12,'col_name' => 'sno','msg' => 'Rule conflict: Dependent count greater than allowed dependent count','row_id' => (isset($self_emp_row_id) ? $self_emp_row_id : $family_data[0][0])];//dependent count mismatch
+ $result['error_data'][] = ['code' => 12,'col_name' => 'sno','msg' => 'Rule conflict: As per policy, count of dependents has exceeded configured count','row_id' => (isset($self_emp_row_id) ? $self_emp_row_id : $family_data[0][0])];//dependent count mismatch
}
}
@@ -488,19 +561,16 @@ if (!function_exists('check_dependent_conflict'))
{
// dd($allowed_adults);
$result['status'] = false;
- $result['error_data'][] = ['code' => 12,'col_name' => 'sno','msg' => 'Rule conflict: Dependent count greater than allowed dependent count','row_id' => (isset($self_emp_row_id) ? $self_emp_row_id : $family_data[0][0])];//dependent count mismatch
+ $result['error_data'][] = ['code' => 12,'col_name' => 'sno','msg' => 'Rule conflict:As per policy, count of dependents has exceeded configured count','row_id' => (isset($self_emp_row_id) ? $self_emp_row_id : $family_data[0][0])];//dependent count mismatch
}
- // }
- // else
- // {
- // if(count($family_data) > 1)
- // {
- // $result['status'] = false;
- // $result['error_data'][] = ['code' => 11,'col_name' => 'sno','msg' => 'Rule conflict: Dependents not allowed','row_id' => $row[0]];//dependents not allowed
- // }
- // }
+ }
+ else
+ {
+ $result['status'] = true;
+ }
+
return $result;
@@ -525,7 +595,7 @@ if (!function_exists('calculate_premimum'))
function calculate_premimum($family_data,$policy_terms,$slab_details,$fileArr,$default_si = null)
{
//
- // dd($fileArr);
+ // dd($slab_details);
// grid type
// 1 = premium => si
$result = [];
@@ -574,7 +644,7 @@ if (!function_exists('calculate_premimum'))
$transformed_familiy_member_data['policy_details']['basic_cover_si'] = isset($emp_details_with_empband_max_age_max_count[ $transformed_familiy_member_data['emp_code'] ]['si']) ? $emp_details_with_empband_max_age_max_count[ $transformed_familiy_member_data['emp_code'] ]['si'] : $transformed_familiy_member_data['policy_details']['basic_cover_si'];
- if( $fileArr['id'] == null || (in_array($grid_type,[10,11]) || $transformed_familiy_member_data['temp']['source'] == 'excel'))//if file id is null then data coming from enrollment (from DB) otherwise data coming from xcel, so calculate only data from excel (new entry) note: even data coming from excel for event dependet additon we fetch other dependts from db and calculate premium for whole family
+ if( $fileArr['id'] == null || $transformed_familiy_member_data['temp']['source'] == 'excel' || ($fileArr['action'] == 'dependent_addition' && in_array($grid_type,[10,11]) && $slab_details['slab_rates'][0]['premium_type'] == 1 && strtolower($transformed_familiy_member_data['relationship']) == 'self'))//if file id is null then data coming from enrollment (from DB) otherwise data coming from xcel, so calculate only data from excel (new entry) note: even data coming from excel for event dependet additon we fetch other dependts from db and calculate premium for whole family
{
$transformed_familiy_member_data = premium_calculation_manager($transformed_familiy_member_data,$policy_terms,$slab_details,$default_si);
@@ -652,6 +722,8 @@ if (!function_exists('premium_calculation_manager'))
{
function premium_calculation_manager($emp_data,$policy_terms,$slab_details,$default_si = null)
{
+
+ $myLogger = \Config\Services::mylogger();
// grid type
// 1 = premium => si
// dd($emp_data);
@@ -687,14 +759,15 @@ if (!function_exists('premium_calculation_manager'))
//gird and calculation start
$slug = \Config\Services::slug();
$grid_type = $slab_details['grid_master']['ui_type'];
-
+ $is_match_found = false;
switch ($grid_type) {
case "1":
//GPA - Sum Insured (SI) * Multiplier
$employee_received_si = $default_si == null ? $emp_data['policy_details']['basic_cover_si'] : $default_si;
+ $employee_received_band = $emp_data['temp']['band'];
foreach ($slab_details['slab_rates'] as $skey => $slab_value)
{
- if($slab_value['si'] == $employee_received_si)
+ if(($slab_value['si'] == $employee_received_si) || ($slab_value['grade'] != null && $slab_value['grade'] == $employee_received_band && $slab_value['si'] == $employee_received_si))
{
$emp_data['policy_details']['basic_cover_si'] = $slab_value['si'];
$emp_data['policy_details']['date_coverage'] = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
@@ -703,7 +776,7 @@ if (!function_exists('premium_calculation_manager'))
$emp_data['policy_details']['premium'] = $slab_value['premium'];
$emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($slab_value['premium'],$emp_data['policy_details']['days']);
$emp_data['policy_details']['gst'] = (float) number_format(($emp_data['policy_details']['rata_premimum'] * (18/100)),2,'.','');
-
+ $is_match_found = true;
break;
}
}
@@ -723,7 +796,7 @@ if (!function_exists('premium_calculation_manager'))
$emp_data['policy_details']['premium'] = $slab_value['premium'];
$emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($slab_value['premium'],$emp_data['policy_details']['days']);
$emp_data['policy_details']['gst'] = (float) number_format(($emp_data['policy_details']['rata_premimum'] * (18/100)),2,'.','');
-
+ $is_match_found = true;
break;
}
}
@@ -742,7 +815,7 @@ if (!function_exists('premium_calculation_manager'))
$emp_data['policy_details']['premium'] = $slab_value['premium'];
$emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($slab_value['premium'],$emp_data['policy_details']['days']);
$emp_data['policy_details']['gst'] = (float) number_format(($emp_data['policy_details']['rata_premimum'] * (18/100)),2,'.','');
-
+ $is_match_found = true;
break;
}
}
@@ -766,7 +839,7 @@ if (!function_exists('premium_calculation_manager'))
$emp_data['policy_details']['premium'] = $slab_value['premium'];
$emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($slab_value['premium'],$emp_data['policy_details']['days']);
$emp_data['policy_details']['gst'] = (float) number_format(($emp_data['policy_details']['rata_premimum'] * (18/100)),2,'.','');
-
+ $is_match_found = true;
break;
}
}
@@ -786,7 +859,7 @@ if (!function_exists('premium_calculation_manager'))
$emp_data['policy_details']['premium'] = $slab_value['premium'];
$emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($slab_value['premium'],$emp_data['policy_details']['days']);
$emp_data['policy_details']['gst'] = (float) number_format(($emp_data['policy_details']['rata_premimum'] * (18/100)),2,'.','');
-
+ $is_match_found = true;
break;
}
}
@@ -795,6 +868,28 @@ if (!function_exists('premium_calculation_manager'))
//GMC - Employees + Dependent Age band
$employee_received_si = $default_si == null ? $emp_data['policy_details']['basic_cover_si'] : $default_si;
foreach ($slab_details['slab_rates'] as $skey => $slab_value)
+ {
+ $age = calculate_days_bw_dates(from_date: $emp_data['dob'])->y;
+ if($slab_value['si'] == $employee_received_si && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age) && (($slab_value['premium_type'] == 1 && strtolower($emp_data['relationship']) == 'self') || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null) ))
+ {
+ // echo $emp_data['name'];
+ $emp_data['policy_details']['basic_cover_si'] = $slab_value['si'];
+ $emp_data['policy_details']['date_coverage'] = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
+ $emp_data['policy_details']['policy_end_date'] = $policy_terms['policy_end_date'];
+ $emp_data['policy_details']['days'] = calculate_days_bw_dates($emp_data['policy_details']['date_coverage'],$policy_terms['policy_end_date'])->days;
+ $emp_data['policy_details']['premium'] = $slab_value['premium'];
+ $emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($slab_value['premium'],$emp_data['policy_details']['days']);
+ $emp_data['policy_details']['gst'] = (float) number_format(($emp_data['policy_details']['rata_premimum'] * (18/100)),2,'.','');
+ $is_match_found = true;
+ break;
+ }
+
+ }
+ break;
+ case "7":
+ //GMC - Employees + Dependent Age + SI
+ $employee_received_si = $default_si == null ? $emp_data['policy_details']['basic_cover_si'] : $default_si;
+ foreach ($slab_details['slab_rates'] as $skey => $slab_value)
{
$age = calculate_days_bw_dates(from_date: $emp_data['dob'])->y;
if($slab_value['si'] == $employee_received_si && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age) && (($slab_value['premium_type'] == 1 && strtolower($emp_data['relationship']) == 'self') || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null) ))
@@ -807,27 +902,7 @@ if (!function_exists('premium_calculation_manager'))
$emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($slab_value['premium'],$emp_data['policy_details']['days']);
$emp_data['policy_details']['gst'] = (float) number_format(($emp_data['policy_details']['rata_premimum'] * (18/100)),2,'.','');
- break;
- }
- }
- break;
- case "7":
- //GMC - Employees + Dependent Age + SI
- $employee_received_si = $default_si == null ? $emp_data['policy_details']['basic_cover_si'] : $default_si;
- foreach ($slab_details['slab_rates'] as $skey => $slab_value)
- {
- $age = calculate_days_bw_dates(from_date: $emp_data['dob'])->y;
- if($slab_value['si'] == $employee_received_si && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age) && (($slab_value['premium_type'] == 1 && strtolower($emp_data['relationship']) == 'self') || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null) ))
- {
- $emp_data['policy_details']['basic_cover_si'] = $slab_value['si'];
- $emp_data['policy_details']['date_coverage'] = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
- $emp_data['policy_details']['policy_end_date'] = $policy_terms['policy_end_date'];
- $emp_data['policy_details']['days'] = calculate_days_bw_dates($policy_terms['policy_start_date'],$policy_terms['policy_end_date'])->days;
- $emp_data['policy_details']['premium'] = $slab_value['premium'];
- $emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($slab_value['premium'],$emp_data['policy_details']['days']);
- $emp_data['policy_details']['gst'] = (float) number_format(($emp_data['policy_details']['rata_premimum'] * (18/100)),2,'.','');
-
-
+ $is_match_found = true;
break;
}
}
@@ -845,11 +920,11 @@ if (!function_exists('premium_calculation_manager'))
$emp_data['policy_details']['basic_cover_si'] = $slab_value['si'];
$emp_data['policy_details']['date_coverage'] = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
$emp_data['policy_details']['policy_end_date'] = $policy_terms['policy_end_date'];
- $emp_data['policy_details']['days'] = calculate_days_bw_dates($policy_terms['policy_start_date'],$policy_terms['policy_end_date'])->days;
+ $emp_data['policy_details']['days'] = calculate_days_bw_dates($emp_data['policy_details']['date_coverage'],$policy_terms['policy_end_date'])->days;
$emp_data['policy_details']['premium'] = $slab_value['premium'];
$emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($slab_value['premium'],$emp_data['policy_details']['days']);
$emp_data['policy_details']['gst'] = (float) number_format(($emp_data['policy_details']['rata_premimum'] * (18/100)),2,'.','');
-
+ $is_match_found = true;
break;
}
}
@@ -866,11 +941,11 @@ if (!function_exists('premium_calculation_manager'))
$emp_data['policy_details']['basic_cover_si'] = $slab_value['si'];
$emp_data['policy_details']['date_coverage'] = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
$emp_data['policy_details']['policy_end_date'] = $policy_terms['policy_end_date'];
- $emp_data['policy_details']['days'] = calculate_days_bw_dates($policy_terms['policy_start_date'],$policy_terms['policy_end_date'])->days;
+ $emp_data['policy_details']['days'] = calculate_days_bw_dates($emp_data['policy_details']['date_coverage'],$policy_terms['policy_end_date'])->days;
$emp_data['policy_details']['premium'] = $slab_value['premium'];
$emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($slab_value['premium'],$emp_data['policy_details']['days']);
$emp_data['policy_details']['gst'] = (float) number_format(($emp_data['policy_details']['rata_premimum'] * (18/100)),2,'.','');
-
+ $is_match_found = true;
break;
}
}
@@ -888,11 +963,11 @@ if (!function_exists('premium_calculation_manager'))
$emp_data['policy_details']['basic_cover_si'] = $employee_received_si;
$emp_data['policy_details']['date_coverage'] = isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date'];
$emp_data['policy_details']['policy_end_date'] = $policy_terms['policy_end_date'];
- $emp_data['policy_details']['days'] = calculate_days_bw_dates($policy_terms['policy_start_date'],$policy_terms['policy_end_date'])->days;
+ $emp_data['policy_details']['days'] = calculate_days_bw_dates($emp_data['policy_details']['date_coverage'],$policy_terms['policy_end_date'])->days;
$emp_data['policy_details']['premium'] = $slab_value['premium'];
$emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($slab_value['premium'],$emp_data['policy_details']['days']);
$emp_data['policy_details']['gst'] = ((float) number_format(($emp_data['policy_details']['rata_premimum'] * (18/100)),2,'.',''));
-
+ $is_match_found = true;
break;
}
}
@@ -915,13 +990,13 @@ if (!function_exists('premium_calculation_manager'))
$familiy_si_covered = ($familiy_si_covered >= $slab_value['max_si'] ? $slab_value['max_si'] : $familiy_si_covered);
$emp_data['policy_details']['basic_cover_si'] = $familiy_si_covered;
- $emp_data['policy_details']['date_coverage'] = (empty($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
+ $emp_data['policy_details']['date_coverage'] = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
$emp_data['policy_details']['policy_end_date'] = $policy_terms['policy_end_date'];
- $emp_data['policy_details']['days'] = calculate_days_bw_dates($policy_terms['policy_start_date'],$policy_terms['policy_end_date'])->days;
- $emp_data['policy_details']['premium'] = $slab_value['premium'];
- $emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($slab_value['premium'],$emp_data['policy_details']['days']);
+ $emp_data['policy_details']['days'] = calculate_days_bw_dates($emp_data['policy_details']['date_coverage'],$policy_terms['policy_end_date'])->days;
+ $emp_data['policy_details']['premium'] = get_premium_for_si(slab_details: $slab_details,si_amount: $familiy_si_covered,band: $employee_received_band);
+ $emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($emp_data['policy_details']['premium'],$emp_data['policy_details']['days']);
$emp_data['policy_details']['gst'] = ((float) number_format(($emp_data['policy_details']['rata_premimum'] * (18/100)),2,'.',''));
-
+ $is_match_found = true;
break;
}
}
@@ -940,13 +1015,13 @@ if (!function_exists('premium_calculation_manager'))
{
$emp_data['policy_details']['basic_cover_si'] = $employee_received_si;
- $emp_data['policy_details']['date_coverage'] = (empty($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
+ $emp_data['policy_details']['date_coverage'] = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
$emp_data['policy_details']['policy_end_date'] = $policy_terms['policy_end_date'];
- $emp_data['policy_details']['days'] = calculate_days_bw_dates($policy_terms['policy_start_date'],$policy_terms['policy_end_date'])->days;
+ $emp_data['policy_details']['days'] = calculate_days_bw_dates($emp_data['policy_details']['date_coverage'],$policy_terms['policy_end_date'])->days;
$emp_data['policy_details']['premium'] = $slab_value['premium'];
$emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($slab_value['premium'],$emp_data['policy_details']['days']);
$emp_data['policy_details']['gst'] = ((float) number_format(($emp_data['policy_details']['rata_premimum'] * (18/100)),2,'.',''));
-
+ $is_match_found = true;
break;
}
}
@@ -965,13 +1040,13 @@ if (!function_exists('premium_calculation_manager'))
{
$emp_data['policy_details']['basic_cover_si'] = $employee_received_si;
- $emp_data['policy_details']['date_coverage'] = (empty($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
+ $emp_data['policy_details']['date_coverage'] = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
$emp_data['policy_details']['policy_end_date'] = $policy_terms['policy_end_date'];
- $emp_data['policy_details']['days'] = calculate_days_bw_dates($policy_terms['policy_start_date'],$policy_terms['policy_end_date'])->days;
+ $emp_data['policy_details']['days'] = calculate_days_bw_dates($emp_data['policy_details']['date_coverage'],$policy_terms['policy_end_date'])->days;
$emp_data['policy_details']['premium'] = $slab_value['premium'];
$emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($slab_value['premium'],$emp_data['policy_details']['days']);
$emp_data['policy_details']['gst'] = ((float) number_format(($emp_data['policy_details']['rata_premimum'] * (18/100)),2,'.',''));
-
+ $is_match_found = true;
break;
}
}
@@ -980,10 +1055,28 @@ if (!function_exists('premium_calculation_manager'))
default:
- echo "Not a valid grid";
+ $this->myLogger->logme('error',($emp_data['emp_code'].'-'.$emp_data['name'].' - grid type not found'));
}
-
- // unset($emp_data['temp']);//remove temp data
+ if(!$is_match_found)
+ {
+ $age = calculate_days_bw_dates(from_date: $emp_data['dob'])->y;
+ $log_message = '[ client_policy_id : ' .$emp_data['policy_details']['client_policy_id'].' - '. $emp_data['emp_code'].' - '.$emp_data['name'] .' - '. $emp_data['policy_details']['basic_cover_si'] . ', Age : '. $age.' ]';
+ if($slab_details['slab_rates'][0]['premium_type'] == 1)
+ {
+ $log_message .= ' - skipping, calculating only self..!';
+ //reset emp si and others policy level data if premium only for self
+ $emp_data['policy_details']['policy_end_date'] = $policy_terms['policy_end_date'];
+ $emp_data['policy_details']['basic_cover_si'] = 0;
+ $emp_data['policy_details']['premium'] = 0;
+ $emp_data['policy_details']['rata_premimum'] = 0;
+ $emp_data['policy_details']['gst'] = 0;
+ $emp_data['policy_details']['days'] = 0;
+ }
+ else { $log_message .= '- skipping, slab rate not found'; }
+ $myLogger->logme('error',$log_message);
+ // echo $log_message;
+
+ }
return $emp_data;
}
@@ -1125,4 +1218,83 @@ if(!function_exists('replace_original_data'))
}
return $current_data;
}
+}
+
+if(!function_exists('get_premium_for_si'))
+{
+ function get_premium_for_si(array $slab_details,string $si_amount,string $band)
+ {
+ foreach ($slab_details['slab_rates'] as $skey => $slab_value)
+ {
+ if($slab_value['si'] == $si_amount && $slab_value['grade'] == $band)
+ {
+ return $slab_value['premium'];
+ }
+ }
+ return 0;
+ }
+}
+
+if(!function_exists('remap_default_age_ratio_into_relationship'))
+{
+ function remap_default_age_ratio_into_relationship(array $general_relationships,array $default_age_ratio)
+ {
+ foreach ($default_age_ratio as $relationship => $age_ratio)
+ {
+ switch ($relationship) {
+ case 'child':
+ if (isset($general_relationships['son'])) {
+ $general_relationships['son']['age_min'] = $age_ratio['min'];
+ $general_relationships['son']['age_max'] = $age_ratio['max'];
+ }
+ if (isset($general_relationships['daughter'])) {
+ $general_relationships['daughter']['age_min'] = $age_ratio['min'];
+ $general_relationships['daughter']['age_max'] = $age_ratio['max'];
+ }
+ break;
+ case 'elders':
+ if (isset($general_relationships['father'])) {
+ $general_relationships['father']['age_min'] = $age_ratio['min'];
+ $general_relationships['father']['age_max'] = $age_ratio['max'];
+ }
+ if (isset($general_relationships['mother'])) {
+ $general_relationships['mother']['age_min'] = $age_ratio['min'];
+ $general_relationships['mother']['age_max'] = $age_ratio['max'];
+ }
+ if (isset($general_relationships['father-in-law'])) {
+ $general_relationships['father-in-law']['age_min'] = $age_ratio['min'];
+ $general_relationships['father-in-law']['age_max'] = $age_ratio['max'];
+ }
+ if (isset($general_relationships['mother-in-law'])) {
+ $general_relationships['mother-in-law']['age_min'] = $age_ratio['min'];
+ $general_relationships['mother-in-law']['age_max'] = $age_ratio['max'];
+ }
+ break;
+ default:
+ if (isset($general_relationships[$relationship])) {
+ $general_relationships[$relationship]['age_min'] = $age_ratio['min'];
+ $general_relationships[$relationship]['age_max'] = $age_ratio['max'];
+ }
+ break;
+ }
+ }
+
+ return $general_relationships;
+ }
+}
+
+
+if(!function_exists('check_dup_mobileno'))
+{
+ function check_dup_mobileno(array $row,array $existing_mobilenos)
+ {
+ foreach($existing_mobilenos as $k => $value)
+ {
+ if ($row['12'] == $value['mobile']) {
+ return array('status' => false,'error' => "Duplicate Mobile No");
+ // break;
+ }
+ }
+ return array('status' => true);
+ }
}
\ No newline at end of file
diff --git a/app/Helpers/sendMailNotification.php b/app/Helpers/sendMailNotification.php
new file mode 100644
index 00000000..f93e79f6
--- /dev/null
+++ b/app/Helpers/sendMailNotification.php
@@ -0,0 +1,413 @@
+", $mail_content);
+ $mail_content = str_replace("[[nhance_logo]]", "
", $mail_content);
+ $mail_content = str_replace("[[member_name]]", $employee_name, $mail_content);
+ $mail_content = str_replace("[[client_name]]", $client_data['client_name'], $mail_content);
+
+ $mail_content = str_replace("[[app_link]]", "Review Details", $mail_content);
+ if ($dataToInsert['relationship'] == 'Self' && $mail != null || $mail != '') {
+ $wholeData = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content,'bcc'=> $client_data['common_mails']];
+ }
+ return $wholeData;
+ } else if($action == 'member_reminder_mail'){
+
+ // print_r($params);die;
+ $EmployeeModel = new EmployeeModel();
+ $emp_data = $params['emp_data'];
+ $notification_data = $params['notification_data'];
+ $client_data = $params['client_data'];
+
+ $subject = $notification_data['subject'];
+ $app_link = $_ENV['App_Url'];
+ $mail_content = $notification_data['mail_content'];
+ $nhance_logo = $_ENV['NHANCE_LOGO'];
+
+ $mail_content = str_replace("[[client_name]]", $client_data['client_name'], $mail_content);
+ $mail_content = str_replace("[[nhance_logo]]", "
", $mail_content);
+ $mail_content = str_replace("[[app_link]]", "Review Details", $mail_content);
+
+ if ($emp_data && (isset($notification_data) && $notification_data['enabled'] == 1)) {
+ 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();
+
+ foreach ($emp_data as $key => $value) {
+ if ($value['relationship'] == 'Self') {
+ $employee_name =$value['name'];
+ $mail_content = str_replace("[[member_name]]", $employee_name, $mail_content);
+
+ $mail = $value['email_corporate'];
+ }
+ }
+ }else{
+ $employee_name =$value['name'];
+ $mail_content = str_replace("[[member_name]]", $employee_name, $mail_content);
+ $mail = $value['email_corporate'];
+ }
+ $wholeData[] = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails']];
+ }
+ return $wholeData;
+ }else{
+ return "false";
+ }
+ } else if($action == 'member_ecard_mail'){
+
+ $notification = $params['notification'];
+ $get_emp_email_and_other_details = $params['get_emp_email_and_other_details'];
+ $rand_string = $params['rand_string'];
+ $client_data = $params['client_data'];
+ $tpa_id = $params['tpa_id'];
+
+
+ $mail_content = $notification['mail_content'];
+ $mail = $get_emp_email_and_other_details['email_corporate'];
+ $subject = $notification['subject'];
+ $link = generate_download_link($rand_string);
+ $app_link = $_ENV['App_Url'];
+ $name = $get_emp_email_and_other_details['name'];
+ $mail_content = $notification['mail_content'];
+ $nhance_logo = $_ENV['NHANCE_LOGO'];
+
+ $client_logo = base_url() . "public/uploads/logo/" . $client_data['client_logo'];
+ // $client_logo = $nhance_logo;
+
+ $mail_content = str_replace("[[nhance_logo]]", "
", $mail_content);
+ $mail_content = str_replace("[[client_logo]]", "
", $mail_content);
+
+ $mail_content = str_replace("[[member_name]]", $name, $mail_content);
+ $mail_content = str_replace("[[app_link]]", "Review Details", $mail_content);
+ // $mail_content = str_replace("[[tpa_id]]", $tpa_id, $mail_content);
+ $mail_content = str_replace("[[ecard_download_link]]", "Download Insurance Card", $mail_content);
+ $mail_content = str_replace("[[client_name]]", $client_data['client_name'], $mail_content);
+
+ $wholeData = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content,'bcc'=> $client_data['common_mails']];
+
+ return $wholeData;
+ } else if($action == 'member_review_and_summary_mail'){
+
+ $array_list = $params['array_list'];
+ $client_policy_id = $params['client_policy_id'];
+ $emp_code = $params['emp_code'];
+ $client_id = $params['client_id'];
+
+ $clientModel = new ClientModel();
+ $notificationModel = new NotificationModel();
+
+ $client_data =$clientModel->where('id', $client_id)->first();
+ $notification_data = $notificationModel->where('client_id' ,$client_id)->where('template_name', $action)->first();
+
+ if ($notification_data['enabled'] == 1) {
+ $mail_content = $notification_data['mail_content'];
+ $subject = $notification_data['subject'];
+ $app_link = $_ENV['App_Url'];
+ $nhance_logo = $_ENV['NHANCE_LOGO'];
+
+ $client_logo = base_url() . "public/uploads/logo/" . $client_data['client_logo'];
+ // $client_logo = $nhance_logo;
+
+ $mail_content = str_replace("[[client_name]]", $client_data['client_name'], $mail_content);
+ $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);
+
+ // Step 1: Replace the placeholder with an HTML table structure
+ $mail = '';
+ // print_r($array_list);die;
+ $table_content = '';
+ $addtional_premium = 0;
+ $gst = 0;
+ foreach ($array_list as $item) {
+ $table_content .= 'Policy Name : ';
+ $temp_data ='';
+ foreach ($item as $inner_item) {
+ $policy_name = $inner_item['policy_name'];
+ $temp_data .= '| ' . $inner_item['name'] . ' | '.$inner_item['mobile'].' | ₹'.number_format($inner_item['basic_cover_si'], 2, '.', ',').' | '.\DateTime::createFromFormat('Y-m-d', $inner_item['dob'])->format('d-m-Y').' |
';
+ if($inner_item['relationship'] == 'Self' || $inner_item['relationship'] == 'self'){
+ $mail = $inner_item['email_corporate'];
+ $name = $inner_item['name'];
+ }
+ // print_r($inner_item);die;
+ $is_addon = $inner_item['is_addon'];
+
+ if($inner_item['is_addon'] == 2 || $inner_item['is_addon'] == 3){
+ $addtional_premium = $inner_item['rata_premimum'] + $addtional_premium;
+ $gst = $inner_item['gst'] + $gst;
+ }
+ }
+ $table_content .= $policy_name.'
| Name | Mobile Number | Sum Insure | Date Of Birth |
';
+ $table_content .= $temp_data;
+ $table_content .= '
';
+
+ if ($is_addon == 2 || $is_addon == 3) {
+ $addon_list_array = [
+ 'policy_name'=>$policy_name,
+ 'addtional_premium'=>$addtional_premium,
+ 'gst'=>$gst
+ ];
+ $Addon_list[]= $addon_list_array;
+
+ }
+
+
+ $temp_data = '';
+ $addtional_premium = 0;
+ $gst = 0;
+ }
+
+ $table_content .='
| Policy Name | Additional Premium | GST | Total |
';
+ $sum_tolal = 0;
+ foreach ($Addon_list as $key => $value) {
+ $sum_tolal = $value['gst'] + $value['addtional_premium'] + $sum_tolal;
+ $table_content .= '| '.$value['policy_name'].' | ₹'.$value['addtional_premium'].' | '.$value['gst'].' | '.$value['gst'] + $value['addtional_premium'] .' |
';
+ }
+ $table_content .= ' | | Total | '.$sum_tolal.' |
';
+ $table_content .= '
';
+ $mail_content = str_replace("[[member_name]]", $name, $mail_content);
+
+ $mail_content = str_replace("[[member_summary]]", $table_content , $mail_content);
+ // $mail = "aadhavanvalli@gmail.com";
+
+ $wholeData[] = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails']];
+
+ return $wholeData;
+
+ }
+ // print_r($wholeData);die;
+ } else if($action == 'account_maneger_summary_mail'){
+
+ $client_id = $params['client_id'];
+
+ $clientModel = new ClientModel();
+
+ $client_data =$clientModel->where('id', $client_id)->first();
+ $notificationModel = new NotificationModel();
+ $notification_data = $notificationModel->where('client_id' ,$client_id)->where('template_name', $action)->first();
+ $clientRMModel =new ClientRMModel();
+
+ if ($notification_data['enabled'] == 1) {
+ $client_rm_data= $clientRMModel->where('client_id', $client_id)->where('is_active',1)->findAll();
+ $user_list= [];
+ foreach ($client_rm_data as $key => $value) {
+ if($value['level'] == 3){
+ $userModel = new UserModel();
+ $user_data = $userModel->where('id', $value['user_id'])->first();
+ $user_list[]=$user_data;
+ }
+ }
+
+
+
+ $mail_content = $notification_data['mail_content'];
+ $subject = $notification_data['subject'];
+ $app_link = $_ENV['App_Url'];
+ $nhance_logo = $_ENV['NHANCE_LOGO'];
+
+ $client_logo = base_url() . "public/uploads/logo/" . $client_data['client_logo'];
+ // $client_logo = $nhance_logo;
+
+ $mail_content = str_replace("[[client_name]]", $client_data['client_name'], $mail_content);
+ $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);
+
+ // Step 1: Replace the placeholder with an HTML table structure
+ $mail = '';
+ // print_r($array_list);die;
+ $table_content = '';
+ $addtional_premium = 0;
+ $gst = 0;
+ $array_list = $params['array_list'];
+
+ foreach ($array_list as $item) {
+ $table_content .= 'Policy Name : ';
+ $temp_data ='';
+ foreach ($item as $inner_item) {
+ $policy_name = $inner_item['policy_name'];
+ $temp_data .= '| ' . $inner_item['name'] . ' | '.$inner_item['mobile'].' | ₹'.number_format($inner_item['basic_cover_si'], 2, '.', ',').' | '.\DateTime::createFromFormat('Y-m-d', $inner_item['dob'])->format('d-m-Y').' |
';
+ // print_r($inner_item);die;
+ $is_addon = $inner_item['is_addon'];
+
+ if($inner_item['is_addon'] == 2 || $inner_item['is_addon'] == 3){
+ $addtional_premium = $inner_item['rata_premimum'] + $addtional_premium;
+ $gst = $inner_item['gst'] + $gst;
+ }
+ }
+ $table_content .= $policy_name.'
| Name | Mobile Number | Sum Insure | Date Of Birth |
';
+ $table_content .= $temp_data;
+ $table_content .= '
';
+
+ if ($is_addon == 2 || $is_addon == 3) {
+ $addon_list_array = [
+ 'policy_name'=>$policy_name,
+ 'addtional_premium'=>$addtional_premium,
+ 'gst'=>$gst
+ ];
+ $Addon_list[]= $addon_list_array;
+
+ }
+
+
+ $temp_data = '';
+ $addtional_premium = 0;
+ $gst = 0;
+
+ }
+
+ $table_content .='
| Policy Name | Additional Premium | GST | Total |
';
+ $sum_tolal = 0;
+ foreach ($Addon_list as $key => $value) {
+ $sum_tolal = $value['gst'] + $value['addtional_premium'] + $sum_tolal;
+ $table_content .= '| '.$value['policy_name'].' | ₹'.$value['addtional_premium'].' | '.$value['gst'].' | '.$value['gst'] + $value['addtional_premium'] .' |
';
+ }
+ $table_content .= ' | | Total | '.$sum_tolal.' |
';
+ $table_content .= '
';
+
+ $mail_content = str_replace("[[member_summary]]", $table_content , $mail_content);
+
+ $account_manager_mail_list = [];
+ foreach ($user_list as $key => $value) {
+ $full_name = $value['first_name'] .' ' .$value['last_name'];
+ $mail_content = str_replace("[[member_name]]", $full_name , $mail_content);
+
+ $wholeData[] = ['mail' => $value['email'], 'subject' => $subject,'message'=> $mail_content];
+ // $wholeData[] = ['mail' => $value['email'], 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails']];
+ }
+ return $wholeData;
+ }
+ } else if($action == 'client_hr_summary_mail'){
+
+ $client_id = $params['client_id'];
+
+ $clientModel = new ClientModel();
+
+ $client_data =$clientModel->where('id', $client_id)->first();
+ $notificationModel = new NotificationModel();
+ $notification_data = $notificationModel->where('client_id' ,$client_id)->where('template_name', $action)->first();
+ $clientRMModel =new ClientRMModel();
+
+ if ($notification_data['enabled'] == 1) {
+ $client_rm_data= $clientRMModel->where('client_id', $client_id)->where('is_active',1)->findAll();
+ $user_list= [];
+ foreach ($client_rm_data as $key => $value) {
+ if($value['level'] == 3){
+ $userModel = new UserModel();
+ $user_data = $userModel->where('id', $value['user_id'])->first();
+ $user_list[]=$user_data;
+ }
+ }
+
+
+
+ $mail_content = $notification_data['mail_content'];
+ $subject = $notification_data['subject'];
+ $app_link = $_ENV['App_Url'];
+ $nhance_logo = $_ENV['NHANCE_LOGO'];
+
+ $client_logo = base_url() . "public/uploads/logo/" . $client_data['client_logo'];
+ // $client_logo = $nhance_logo;
+
+ $mail_content = str_replace("[[nhance_logo]]", "
", $mail_content);
+ $mail_content = str_replace("[[client_logo]]", "
", $mail_content);
+ $mail_content = str_replace("[[client_name]]", $client_data['client_name'], $mail_content);
+
+ $mail_content = str_replace("[[app_link]]", "Review Details", $mail_content);
+
+ // Step 1: Replace the placeholder with an HTML table structure
+ $mail = '';
+ // print_r($array_list);die;
+ $table_content = '';
+ $addtional_premium = 0;
+ $gst = 0;
+ $array_list = $params['array_list'];
+
+ foreach ($array_list as $item) {
+ $table_content .= 'Policy Name : ';
+ $temp_data ='';
+ foreach ($item as $inner_item) {
+ $policy_name = $inner_item['policy_name'];
+ $temp_data .= '| ' . $inner_item['name'] . ' | '.$inner_item['mobile'].' | ₹'.number_format($inner_item['basic_cover_si'], 2, '.', ',').' | '.\DateTime::createFromFormat('Y-m-d', $inner_item['dob'])->format('d-m-Y').' |
';
+ // print_r($inner_item);die;
+ $is_addon = $inner_item['is_addon'];
+
+ if($inner_item['is_addon'] == 2 || $inner_item['is_addon'] == 3){
+ $addtional_premium = $inner_item['rata_premimum'] + $addtional_premium;
+ $gst = $inner_item['gst'] + $gst;
+ }
+ }
+ $table_content .= $policy_name.'
| Name | Mobile Number | Sum Insure | Date Of Birth |
';
+ $table_content .= $temp_data;
+ $table_content .= '
';
+
+ if ($is_addon == 2 || $is_addon == 3) {
+ $addon_list_array = [
+ 'policy_name'=>$policy_name,
+ 'addtional_premium'=>$addtional_premium,
+ 'gst'=>$gst
+ ];
+ $Addon_list[]= $addon_list_array;
+
+ }
+
+
+ $temp_data = '';
+ $addtional_premium = 0;
+ $gst = 0;
+
+ }
+
+ $table_content .='
| Policy Name | Additional Premium | GST | Total |
';
+ $sum_tolal = 0;
+ foreach ($Addon_list as $key => $value) {
+ $sum_tolal = $value['gst'] + $value['addtional_premium'] + $sum_tolal;
+ $table_content .= '| '.$value['policy_name'].' | ₹'.$value['addtional_premium'].' | '.$value['gst'].' | '.$value['gst'] + $value['addtional_premium'] .' |
';
+ }
+ $table_content .= ' | | Total | '.$sum_tolal.' |
';
+ $table_content .= '
';
+
+ $mail_content = str_replace("[[member_summary]]", $table_content , $mail_content);
+
+
+ $hr_mails = $client_data['hr_mails'];
+ $mail_array = explode(',', $hr_mails);
+ $mail_array = array_map('trim', $mail_array);
+
+ foreach ($mail_array as $key => $value) {
+ $wholeData[] = ['mail' => $value, 'subject' => $subject,'message'=> $mail_content];
+ // $wholeData[] = ['mail' => $value, 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails']];
+ }
+
+ return $wholeData;
+ }
+
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/Helpers/utility_helper.php b/app/Helpers/utility_helper.php
index 7e74234c..220f06f6 100644
--- a/app/Helpers/utility_helper.php
+++ b/app/Helpers/utility_helper.php
@@ -167,6 +167,24 @@ if (!function_exists('generate_random_alphanumeric')) {
+if (!function_exists('get_base64_image')) {
+
+ function get_base64_image($path)
+ {
+ // Get file extension
+ $type = pathinfo($path, PATHINFO_EXTENSION);
+
+ // Read file content
+ $dataContent = file_get_contents($path);
+
+ // Encode as base64
+ $base64Image = 'data:image/' . $type . ';base64,' . base64_encode($dataContent);
+
+ return $base64Image;
+ }
+}
+
+
diff --git a/app/Models/BatchFileModel.php b/app/Models/BatchFileModel.php
index 5976d6a2..1d2b4a0d 100644
--- a/app/Models/BatchFileModel.php
+++ b/app/Models/BatchFileModel.php
@@ -22,6 +22,8 @@ class BatchFileModel extends Model
"updated_by",
"is_active",
"amount",
+ "status",
+ "error_data",
];
// Callbacks
diff --git a/app/Models/ClientModel.php b/app/Models/ClientModel.php
index af579498..27b48bc9 100644
--- a/app/Models/ClientModel.php
+++ b/app/Models/ClientModel.php
@@ -26,6 +26,8 @@ class ClientModel extends Model
"created_by",
"updated_by",
"is_active",
+ "common_mails",
+ "hr_mails"
];
@@ -43,6 +45,7 @@ class ClientModel extends Model
->join('policies p', 'p.id = client_policy.policy_id')
->where('client_policy.client_id',$client['id'])
->where('client_policy.is_active', 1)
+ ->where('client_policy.policy_status', 1)
->findAll();
$client['policies'] = $clientPolicies;
diff --git a/app/Models/ClientPolicyModel.php b/app/Models/ClientPolicyModel.php
index d0d80b54..291b13f9 100644
--- a/app/Models/ClientPolicyModel.php
+++ b/app/Models/ClientPolicyModel.php
@@ -34,6 +34,7 @@ class ClientPolicyModel extends Model
"policy_terms",
"open_for_enrollment",
"is_addon",
+ "inception_type",
"base_policy",
"created_by",
"updated_by",
@@ -75,12 +76,13 @@ class ClientPolicyModel extends Model
->select('policy_type.policy_type as policy_type_name')
->join('insurers', 'insurers.id = client_policy.insurer_id')
->join('insurer_branch', 'client_policy.insurer_branch_id = insurer_branch.id')
- ->join('tpa', 'tpa.id = client_policy.tpa_id')
- ->join('tpa_branch', 'client_policy.tpa_branch_id = tpa_branch.id')
+ ->join('tpa', 'tpa.id = client_policy.tpa_id', 'left')
+ ->join('tpa_branch', 'client_policy.tpa_branch_id = tpa_branch.id', 'left')
->join('policies', 'policies.id = client_policy.policy_id')
->join('policy_type', 'policy_type.id = policies.policy_type_id')
->where('client_policy.client_id', $client_id)
->where('client_policy.policy_status', 1)
+ ->where('client_policy.is_active', 1)
->get()
->getResult();
diff --git a/app/Models/EmployeeModel.php b/app/Models/EmployeeModel.php
index fdd19e40..7ec30755 100644
--- a/app/Models/EmployeeModel.php
+++ b/app/Models/EmployeeModel.php
@@ -36,7 +36,8 @@ class EmployeeModel extends Model
"updated_at",
"is_active",
"file_id",
- "is_addon_value"
+ "is_addon_value",
+ "is_createdby_hr"
];
// Callbacks
@@ -95,17 +96,19 @@ 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 = [])
+ public function getEmpFamilybyEmpCode(string $client_policy_id = null,string $emp_code = null,string $client_id = null,array $emp_status = [],array $policy_status = [],array $relationship = [])
{
- $result = $this->select(['employees.id as emp_id', 'employees.client_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','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'])
+ $result = $this->select(['employees.id as emp_id', 'employees.client_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','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','policies.name as policy_name','client_policy.is_addon'])
->join('employee_polices', 'employee_polices.employee_id = employees.id')
+ ->join('client_policy', 'client_policy.id = employee_polices.client_policy_id')
+ ->join('policies', 'policies.id = client_policy.policy_id')
->where('employees.is_active',1)
->when($client_policy_id, function($query) use ($client_policy_id){
return $query->where('employee_polices.client_policy_id',$client_policy_id);
})
-
+
->where('employee_polices.is_active',1)
- // ->where('employees.emp_status', ($emp_status !== null ? $emp_status : 'active'))
+ ->where('employees.is_active',1)
// ->where('employees.emp_code',$emp_code)
->when($emp_code, function($query) use ($emp_code){
return $query->where('employees.emp_code',$emp_code);
@@ -114,6 +117,9 @@ class EmployeeModel extends Model
->when(count($emp_status), function($query) use ($emp_status){
return $query->whereIn('employees.emp_status', $emp_status);
})
+ ->when(count($relationship), function($query) use ($relationship){
+ return $query->whereIn('employees.relationship', $relationship);
+ })
->when(count($policy_status), function($query) use ($policy_status){
return $query->whereIn('employee_polices.status', $policy_status);
})
@@ -132,9 +138,10 @@ class EmployeeModel extends Model
{
return $this->db->table('employee_polices')
- ->select(' policies.name as Policy_Name , client_policy.policy_terms as Policy_Terms, client_policy.client_id as ClientId, client_policy.policy_id as PolicyId,client_policy.id as ClientPolicyId, client_policy.open_for_enrollment as OpenForEnrollment') // Select all columns from both tables
+ ->select(' policies.name as Policy_Name , client_policy.policy_terms as Policy_Terms, client_policy.client_id as ClientId, client_policy.policy_id as PolicyId,client_policy.id as ClientPolicyId, client_policy.open_for_enrollment as OpenForEnrollment , employee_polices.tpa_id as tpa_id , employee_polices.rand_string as rand_string') // Select all columns from both tables
->join('client_policy', 'client_policy.id = employee_polices.client_policy_id')
->join('policies', 'policies.id = client_policy.policy_id')
+ ->where('client_policy.policy_status', 1)
->where('employee_polices.employee_id', $id)
->get()
->getResult();
diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php
index 0b824d77..5b5caf18 100644
--- a/app/Models/EmployeePolicyModel.php
+++ b/app/Models/EmployeePolicyModel.php
@@ -720,6 +720,8 @@ class EmployeePolicyModel extends Model
e.doj,
e.band,
TIMESTAMPDIFF(YEAR, e.dob, CURDATE()) AS emp_age,
+ (SELECT name FROM employees WHERE relationship = "Self" and emp_code = ' . $this->db->escape($emp_code) . ') AS self,
+
ep.tpa_id,
ep.uhid,
@@ -728,12 +730,22 @@ class EmployeePolicyModel extends Model
clients.client_name,
clients.short_name AS client_short_name,
+ cp.policy_start_date,
+
policies.name AS policy_name,
insurers.name AS insurer_name,
insurers.short_name AS insurer_short_name,
+ insurers.insurer_logo,
+
+ insurer_branch.branch_name,
+ insurer_branch.branch_code,
+ insurer_branch.city as insurer_branch_city,
tpa.name AS tpa_name,
+ tpa.tpa_logo AS tpa_logo,
+ tpa.front_card,
+ tpa.back_card,
tpa.short_name AS tpa_short_name'
)
@@ -742,7 +754,9 @@ class EmployeePolicyModel extends Model
->join('clients', 'clients.id = cp.client_id')
->join('policies', 'policies.id = cp.policy_id')
->join('insurers', 'insurers.id = cp.insurer_id')
+ ->join('insurer_branch', 'insurer_branch.id = cp.insurer_branch_id')
->join('tpa', 'tpa.id = cp.tpa_id')
+ ->where("ep.tpa_id IS NOT NULL AND ep.tpa_id <> ''")
->where('e.emp_status', 'active')
->where('e.is_active', '1')
->where('ep.status', 'active')
@@ -753,8 +767,26 @@ class EmployeePolicyModel extends Model
->getResultArray();
return $result;
+
}
+ public function getExisitingMobileNos(string $client_policy_id)
+ {
+ $result = $this->select(['employee_polices.id','emp.id as emp_id','emp.relationship','emp.emp_code','emp.name','emp.email_corporate','emp.mobile as mobile'])
+ ->join('employees emp', 'employee_polices.employee_id = emp.id')
+ ->join('client_policy cp', 'employee_polices.client_policy_id = cp.id')
+ ->where('employee_polices.client_policy_id',$client_policy_id)
+ ->whereIn('employee_polices.status', ['Active'])
+ ->whereIn('emp.emp_status', ['Active'])
+ ->where('emp.is_active', 1)
+ ->where('emp.relationship', 'Self')
+ ->where('emp.mobile is not null')
+ ->where('employee_polices.is_active', 1)
+ ->findAll();
+
+ return ($result);
+ }
+
}
\ No newline at end of file
diff --git a/app/Models/InsurerModel.php b/app/Models/InsurerModel.php
index c23804c1..acda3845 100644
--- a/app/Models/InsurerModel.php
+++ b/app/Models/InsurerModel.php
@@ -14,6 +14,7 @@ class InsurerModel extends Model
"category",
"name",
"short_name",
+ "insurer_logo",
"created_by",
"updated_by",
"is_active",
diff --git a/app/Models/NotificationModel.php b/app/Models/NotificationModel.php
new file mode 100644
index 00000000..d78d2a69
--- /dev/null
+++ b/app/Models/NotificationModel.php
@@ -0,0 +1,12 @@
+
-.table-responsive {
- overflow-x: auto;
-}
+ .table-responsive {
+ overflow-x: auto;
+ }
@@ -27,29 +27,51 @@
Action |
Count |
Amount |
+
status |
- $file) {
+ $file) {
?>
-
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
-
-
+
+ |
+ |
+ 5 ? substr($file['file_name'], 0, 10) . "..." : $file['file_name'] ?> |
+ |
+ |
+ |
+ |
+ |
+ |
+ |
+
+
+
+
+
+
+
+
+
+ failed
+
+ failed
+
+ failed
+
+ failed
+
+
+
+ |
+
+
+
@@ -59,31 +81,31 @@
\ No newline at end of file
diff --git a/app/Views/client_basic_info.php b/app/Views/client_basic_info.php
index 3f08c20a..68749f6f 100644
--- a/app/Views/client_basic_info.php
+++ b/app/Views/client_basic_info.php
@@ -203,11 +203,13 @@ input:checked + .slider:before {
document.addEventListener("DOMContentLoaded", function() {
const switchCheckbox = document.getElementById('switch-checkbox');
const switchInner = document.querySelector('.switch-inner');
-
- switchInner.addEventListener('click', function() {
+ if (switchInner) {
+ switchInner.addEventListener('click', function() {
switchCheckbox.checked = !switchCheckbox.checked;
switchInner.style.transform = switchCheckbox.checked ? 'translateX(100%)' : 'translateX(0)';
});
+ }
+
});
diff --git a/app/Views/client_kyc.php b/app/Views/client_kyc.php
index d842b1f4..f53b7c16 100644
--- a/app/Views/client_kyc.php
+++ b/app/Views/client_kyc.php
@@ -176,6 +176,26 @@
$('#name_'+item.kyc_doc_type_id).html(item.file_name);
$('#form_'+item.kyc_doc_type_id).hide();
+ console.log('step 1')
+
+ if(item.file_name != null && item.file_name != ""){
+ console.log('step 2')
+
+ $('#download_'+item.kyc_doc_type_id).show();
+ $('#download_' + item.kyc_doc_type_id).attr('href', '= base_url('download-kyc-docs/') ?>' + item.file_name);
+ $('#delete_'+item.kyc_doc_type_id).show();
+
+ }
+ else{
+ console.log('step 3')
+
+ $('#download_'+item.kyc_doc_type_id).hide();
+ $('#download_' + item.kyc_doc_type_id).attr('href', '#');
+ $('#delete_'+item.kyc_doc_type_id).hide();
+
+ }
+ console.log('step 4')
+
});
},
@@ -212,19 +232,27 @@
var tbody = $('#tbody');
tbody.empty();
- $.each(res.data, function (index, item) {
+ $.each(res.data, function(index, item) {
var row = `
- | ${item.file_name} |
- |
+ ${item.file_name} |
+
+
+ |
|
- |
+
+
+
+ |
`;
tbody.append(row);
});
+
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
@@ -250,7 +278,10 @@
| ${item.other_docs_name} |
${item.file_name} |
- |
+
+
+
+ |
`;
@@ -267,6 +298,29 @@
$('#name_'+item.kyc_doc_type_id).show();
$('#name_'+item.kyc_doc_type_id).html(item.file_name);
$('#form_'+item.kyc_doc_type_id).hide();
+
+ console.log('step 1')
+
+ if(item.file_name != null && item.file_name != ""){
+ console.log('step 2')
+
+ $('#download_'+item.kyc_doc_type_id).show();
+ $('#download_' + item.kyc_doc_type_id).attr('href', '= base_url('download-kyc-docs/') ?>' + item.file_name);
+ $('#delete_'+item.kyc_doc_type_id).show();
+
+
+ }
+ else{
+ console.log('step 3')
+
+ $('#download_'+item.kyc_doc_type_id).hide();
+ $('#download_' + item.kyc_doc_type_id).attr('href', '#');
+ $('#delete_'+item.kyc_doc_type_id).hide();
+
+
+ }
+ console.log('step 4')
+
}, 1000);
});
@@ -335,7 +389,10 @@
| ${item.other_docs_name} |
${item.file_name} |
- |
+
+
+
+ |
`;
}
diff --git a/app/Views/client_onboarding.php b/app/Views/client_onboarding.php
index bca575d2..5ae22d1a 100644
--- a/app/Views/client_onboarding.php
+++ b/app/Views/client_onboarding.php
@@ -34,6 +34,7 @@ body {
+
@@ -75,6 +76,12 @@ body {
Branch & Contacts
+
+
+
+ Notifications
+
+
@@ -83,6 +90,8 @@ body {
+
+
@@ -95,8 +104,8 @@ body {
-
+
diff --git a/app/Views/client_policy.php b/app/Views/client_policy.php
index d47726fb..8ee76ec5 100644
--- a/app/Views/client_policy.php
+++ b/app/Views/client_policy.php
@@ -14,6 +14,7 @@
Policy |
TPA |
Date |
+
Enrollment Status |
Status |
Action |
@@ -79,7 +80,7 @@
-
+
+
+
+
+
+
+
+
@@ -151,6 +162,7 @@
onChange: function(selectedDates, dateStr, instance) {
var endDate = new Date(selectedDates[0]);
endDate.setFullYear(endDate.getFullYear() + 1);
+ endDate.setDate(endDate.getDate() - 1); // Set end date to last day of selected year
endDatePicker.setDate(endDate);
}
});
@@ -158,6 +170,7 @@
// Calculate the end date (today + 1 year)
var endDate = new Date(today);
endDate.setFullYear(endDate.getFullYear() + 1);
+ endDate.setDate(endDate.getDate() - 1); // Set end date to last day of next year
// Initialize Flatpickr for the end date with the calculated end date
var endDatePicker = flatpickr("#end_date", {
@@ -167,6 +180,7 @@
});
+
$('#add_form').hide();
$('.btnBack').hide();
@@ -192,6 +206,7 @@
$('#first').hide();
$('#second').hide();
+ $('#third').hide();
$('#base_policy_id').hide();
$('#base_policy').prop('required', false);
@@ -232,15 +247,42 @@
} else {
search_term = subject; // Set default value if neither 'GMC' nor 'GPA' exists
}
+ // console.log('search_term :', search_term)
+
+ var enrollmentStatus = '';
+ if(item.inception_type == 1){
+
+ enrollmentStatus = 'N/A'
+
+ }else if(item.inception_type == 2){
+
+ if(item.open_for_enrollment == 1){
+
+ enrollmentStatus = 'Open'
+
+
+ }else if(item.open_for_enrollment == 0){
+
+ enrollmentStatus = 'Closed'
+
+ }
+
+ }
+
+ var tpaValue = 'TPA Unavailable';
+
+ if (item.tpa_short && item.tpa_branch_code) {
+ tpaValue = item.tpa_short + '-' + item.tpa_branch_code;
+ }
- console.log('search_term :', search_term)
policyTable += `
| ${item.insurer_short} - ${item.insurer_branch_name} |
${item.policy_name} (${item.policy_type_name}) |
- ${item.tpa_short} - ${item.tpa_branch_code} |
+ ${tpaValue} |
${(item.policy_start_date)} / ${(item.policy_end_date)} |
+ ${(enrollmentStatus)} |
${checkDateStatus(item.policy_end_date, 1)} |
@@ -248,16 +290,7 @@
|
@@ -284,6 +317,12 @@
policy_PrimaryKey = $('#client_id_policy').val();
policy_client = $('#policy_PrimaryKey').val();
+ var policyDataId = $('#policy').children('option:selected').attr('data-id');
+ var basePolicyDataId = $('#base_policy').children('option:selected').attr('data-id');
+
+ console.log('policyDataId', policyDataId);
+ console.log('basePolicyDataId', basePolicyDataId);
+
if (policy_PrimaryKey === '' && policy_client === '') {
toastr.error('Client is required', 'Error');
$('#insurer').val('');
@@ -292,6 +331,22 @@
return;
}
+ if (basePolicyDataId == policyDataId) {
+
+ toastr.warning('The policy cannot be the same as the base policy.', 'Warning');
+ return;
+ }
+
+ if (basePolicyDataId == 3 || basePolicyDataId == 2) {
+
+ if (policyDataId == 1) {
+
+ toastr.warning('The GPA policy cannot be Select.', 'Warning');
+ return;
+ }
+
+ }
+
var isValid = $('#policy_form').parsley().validate();
if (!isValid) {
console.log('Form is Empty', 'Warning');
@@ -353,14 +408,41 @@
subject; // Set default value if neither 'GMC' nor 'GPA' exists
}
- console.log('search_term :', search_term)
+ // console.log('search_term :', search_term)
+
+ var enrollmentStatus = '';
+ if(item.inception_type == 1){
+
+ enrollmentStatus = 'N/A'
+
+ }else if(item.inception_type == 2){
+
+ if(item.open_for_enrollment == 1){
+
+ enrollmentStatus = 'Open'
+
+
+ }else if(item.open_for_enrollment == 0){
+
+ enrollmentStatus = 'Closed'
+
+ }
+
+ }
+
+ var tpaValue = 'TPA Unavailable';
+
+ if (item.tpa_short && item.tpa_branch_code) {
+ tpaValue = item.tpa_short + '-' + item.tpa_branch_code;
+ }
policyTable += `
| ${item.insurer_short} - ${item.insurer_branch_name} |
${item.policy_name} (${item.policy_type_name}) |
- ${item.tpa_short} - ${item.tpa_branch_code} |
+ ${tpaValue} |
${rearrangeDateFormat(item.policy_start_date)} - ${rearrangeDateFormat(item.policy_end_date)} |
+ ${(enrollmentStatus)} |
${checkDateStatus(item.policy_end_date, 1)} |
@@ -368,16 +450,7 @@
|
@@ -408,6 +481,7 @@
}, 1000);
}
});
+
});
$(document).ready(function() {
@@ -461,7 +535,8 @@
'">' + item.name + '( ' + item.policy_type + ' )';
}
} else if ($policy_type_value == 1) {
- if (item.policy_type_id == 1 || item.policy_type_id == 2) {
+
+ if (item.policy_type_id == 1 || item.policy_type_id == 2 || item.policy_type_id == 3) {
OptionsHTML += '';
+ 'selected="selected"' : '') + '>' + item.name + '( ' + item.policy_type + ' )';
});
$('#base_policy').html(OptionsHTML);
setTimeout(function() {
$('#policy').val(res.data.policy_id).change();
+ $('#base_policy').val(res.data.base_policy);
+ $('#base_policy').change();
}, 3000);
+
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
@@ -640,24 +803,27 @@
});
});
-
$('body').on('click', '.btnOpenEnroll', function() {
Swal.fire({
title: "Are you sure?",
- text: "You need to approve this!",
- icon: "warning",
- showCancelButton: true,
- confirmButtonColor: "#3085d6",
- cancelButtonColor: "#d33",
- confirmButtonText: "Yes, delete it!"
+ text: "You need to approve this!",
+ icon: "info",
+ showCancelButton: true,
+ confirmButtonColor: "#3085d6",
+ confirmButtonText: "Yes",
}).then((result) => {
- if (result.isConfirmed) {
- var client_policy_id = $(this).attr('data-id');
- var policy_id = $(this).attr('id');
- var client_id = $('#client_id_policy').val()
- // console.log('client_policy_id', client_policy_id);
+
+ if (result.isConfirmed) {
+
+ var client_policy_id = $(this).attr('data-id');
+ var policy_id = $(this).attr('id');
+ var client_id = $('#client_id_policy').val()
+
+ console.log('client_policy_id', client_policy_id)
+ console.log('policy_id', policy_id)
+ console.log('client_id', client_id)
if (client_policy_id) {
$('.loader').fadeIn();
@@ -671,30 +837,28 @@
client_policy_id: client_policy_id,
},
success: function(res) {
- console.log(res);
+
+ console.log(res.client_policy_data);
if (res) {
if (res.open_for_enrollment) {
var json_decode = JSON.parse(res.open_for_enrollment);
var open_for_enrollment = json_decode.open_for_enrollment;
var client_policy_id = json_decode.client_policy_id;
+
if (open_for_enrollment == 1) {
- // console.log($('[data-id="' + client_policy_id + '"]');
+
$('.btnOpenEnroll').each(function(index, element) {
if ($(element).data('id') == client_policy_id) {
- $(element).css({
- 'background-color': 'lightgrey',
- });
- $(element).html('Open Enrollment');
+ $(element).html('Open');
}
});
+
} else {
+
$('.btnOpenEnroll').each(function(index, element) {
if ($(element).data('id') == client_policy_id) {
- $(element).css({
- 'background-color': '',
- });
- $(element).html('Open Enrollment');
+ $(element).html('Closed');
}
});
}
@@ -734,6 +898,7 @@
});
+
function appendPolicyFormFields(policy_type, data = false) {
var html = '';
@@ -1028,6 +1193,10 @@
gpaSumInsureMultiplier(input);
}
+ if (input.id == 'gpa_sum_si2') {
+ gpaSumInsureMultiplier(input);
+ }
+
// if(input.id == 'basic_pay'){
// var inputNumber = input.value;
// if (inputNumber) {
@@ -1133,11 +1302,13 @@
$('#base_policy').prop('required', true);
$('#first').show();
$('#second').show();
+ $('#third').show();
} else if ($(this).val() == '0') {
$('#first').hide();
$('#second').hide();
+ $('#third').hide();
$('#base_policy_id').hide();
$('#base_policy').prop('required', false);
@@ -1146,6 +1317,7 @@
$('#first').show();
$('#second').show();
+ $('#third').show();
$('#base_policy_id').hide();
$('#base_policy').prop('required', false);
}
@@ -1176,9 +1348,22 @@
var OptionsHTML = '';
OptionsHTML += '';
$.each(res.data, function(index, item) {
- OptionsHTML += '';
+ if ($('#policy_type').val() == 1) {
+
+ console.log('if')
+
+ if (item.policy_type_id == 1 || item.policy_type_id == 2) {
+ console.log('if 2')
+ OptionsHTML += '';
+ }
+
+ } else {
+ console.log('if')
+ OptionsHTML += '';
+ }
});
$('#base_policy').html(OptionsHTML);
},
@@ -1195,7 +1380,7 @@
}
-
+ var dataId = 0;
$(document).ready(function() {
$('#base_policy').change(function() {
@@ -1204,6 +1389,12 @@
var policy_type = $('#policy_type').val()
console.log(client_policy_id);
+ dataId = $('#policy').children('option:selected').attr('data-id');
+ console.log('dataId', dataId)
+
+ base_policy_data_id = $(this).children('option:selected').attr('data-id');
+ console.log('base_policy_data_id', base_policy_data_id);
+
var queryParams = {
client_policy_id: client_policy_id,
policy_type: policy_type,
@@ -1238,26 +1429,37 @@
$('#start_date').val(rearrangeDateFormat(res.data.policy_start_date)).change();
$('#end_date').val(rearrangeDateFormat(res.data.policy_end_date)).change();
-
var policeOptionHTML = '';
$policy_type_value = $('#policy_type').val();
$.each(res.policy, function(index, item) {
- // if ($policy_type_value == 3) {
- // if (item.policy_type_id == 5) {
console.log(item);
-
-
policeOptionHTML += '';
- // }
- // }
});
+
$('#policy').html(policeOptionHTML);
+ if (dataId == 3 || policy_type == 1) {
+
+ console.log('step 1')
+
+ setTimeout(function() {
+ console.log('step 2')
+ var $option = $('#policy').find('option[data-id="3"]');
+ if ($option.length > 0) {
+ console.log('step 3')
+ $option.prop('selected', true).change();
+ } else {
+ console.log('step 4');
+ toastr.warning('The insurer does not have a GMC-Parents policy.', 'Warning');
+ }
+ }, 1500);
+ }
+
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
@@ -1269,6 +1471,7 @@
}, 500);
}
});
+
});
})
diff --git a/app/Views/client_rm.php b/app/Views/client_rm.php
index 539a0c8f..a47280ee 100644
--- a/app/Views/client_rm.php
+++ b/app/Views/client_rm.php
@@ -157,8 +157,7 @@ $(document).ready(function(){
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
- toastr.warning('Something Wrong!', 'warning');
- }, 1000);
+ console.log('Something Wrong!', 'warning'); }, 1000);
}
});
diff --git a/app/Views/id_card_view.php b/app/Views/ecard_template/default_ecard.php
similarity index 95%
rename from app/Views/id_card_view.php
rename to app/Views/ecard_template/default_ecard.php
index 7c781b31..0ed04d23 100644
--- a/app/Views/id_card_view.php
+++ b/app/Views/ecard_template/default_ecard.php
@@ -3,7 +3,7 @@
- NHANCE
+ E-Card
@@ -23,6 +23,7 @@
+
@@ -49,6 +50,7 @@
= htmlspecialchars(formatDateOrReturn($value['policy_end_date'])) ?>
+
@@ -77,6 +79,12 @@
+
+
+ button
+
+
|