diff --git a/app/Config/Routes.php b/app/Config/Routes.php index f5119b25..fe10e12f 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -18,6 +18,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'); @@ -218,6 +219,7 @@ $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->cli('cli/processjob', 'JobWorker::processJob'); diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 773eb420..c3b3b4b6 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -264,9 +264,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)); @@ -277,7 +277,7 @@ class ClientController extends AdminController // echo "
";
- // dd($editData); die;
+ // dd($clientPoliceData); die;
echo view('layout/header', $headerData);
echo view('client_onboarding', $editData);
@@ -587,7 +587,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 +616,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 +708,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 +761,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 +797,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 +813,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 +842,7 @@ class ClientController extends AdminController
$policyPremium = $this->policyPremium1Model->insert($data);
}
+
$data = $this->request->getPost();
$insert = true;
} else if ($policy_grid_id == '2') {
@@ -819,6 +864,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 +879,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 +896,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 +971,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 +980,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 +1171,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;
}
}
@@ -1301,6 +1356,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"));
@@ -1316,6 +1378,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,
@@ -1354,23 +1425,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);
}
}
@@ -1432,6 +1504,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(
@@ -1480,77 +1555,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);
}
@@ -1600,4 +1680,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/EmpDataServiceController.php b/app/Controllers/EmpDataServiceController.php
index e2e50f9f..af0710f0 100644
--- a/app/Controllers/EmpDataServiceController.php
+++ b/app/Controllers/EmpDataServiceController.php
@@ -27,6 +27,7 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet;
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;
@@ -108,16 +109,24 @@ class EmpDataServiceController extends BaseController
{
// Fetch employee data for export from the database
$objects = $this->employeePolicyModel->getInceptionEmployeeDataForExportExcel($export_data);
+
+ $insurer_id = $this->clientPolicyModel->where('id', $export_data['client_policy_id'])->first();
- // dd($objects);
-
+ $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((int) $cash_balance['balance'] < (int) $totals){
+
+ return 0;
+ }
+
+
// Log the count of exported data
$count = count($objects);
$export_data['count'] = $count;
@@ -1598,7 +1607,7 @@ class EmpDataServiceController extends BaseController
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.name, employees.id as employee_id, employees.emp_code 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')
@@ -1608,7 +1617,9 @@ class EmpDataServiceController extends BaseController
if ($get_emp_email_and_other_details != null && $get_emp_email_and_other_details != "") {
+ $employee_id = $get_emp_email_and_other_details['employee_id'];
$name = $get_emp_email_and_other_details['name'];
+ $emp_code = $get_emp_email_and_other_details['name'];
$email = $get_emp_email_and_other_details['email_corporate'];
$rand_string = $get_emp_email_and_other_details['rand_string'];
$tpa_id = $get_emp_email_and_other_details['tpa_id'];
@@ -1645,7 +1656,17 @@ class EmpDataServiceController extends BaseController
// dd($data);
$this->myLogger->logme('error', 'status : {status}, message : {message}, email : {email}', $data);
+
+ }else{
+
+ $this->myLogger->log('error', 'The employee (primaryKey : {id}, Name : {name}, Emp Code : {emp_code} ) has no corporate email.', ['id' => $employee_id, 'name' => $name, 'emp_code' => $emp_code]);
+
}
+
+ }else{
+
+ $this->myLogger->log('error', 'The employee policy ID ( {id} ) has no active policy or the employee is not active.', ['id' => $id]);
+
}
}
return true; // Email(s) sent successfully
@@ -1655,4 +1676,5 @@ class EmpDataServiceController extends BaseController
return false; // Email(s) sending failed
}
}
+
}
diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php
index 5b73effc..b1b33241 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,141 @@ 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', "The insurer has an 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){
+ 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 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 ($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 +485,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 +513,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 +539,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 +547,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 +562,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 +612,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 +632,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 +670,297 @@ 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);
+ 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);
+ }
+ }
+ }
+
+
+
+ // 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 +972,69 @@ 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;
+
+
+ }
+
+}
diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php
index f562ef09..84079452 100644
--- a/app/Controllers/EmployeeRestController.php
+++ b/app/Controllers/EmployeeRestController.php
@@ -304,7 +304,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();
}
@@ -949,6 +949,7 @@ public function getEmployeePolicy()
// 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';
@@ -958,6 +959,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;
@@ -996,6 +998,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'];
@@ -1003,7 +1006,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]);
@@ -1012,7 +1020,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))
{
@@ -1147,13 +1157,16 @@ public function getGmcParrentsPolicy($GmcParrentsPolicy,$emp_code,$client_id)
// 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'];
@@ -1161,7 +1174,11 @@ public function getGmcParrentsPolicy($GmcParrentsPolicy,$emp_code,$client_id)
$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'] = $array->Policy_Terms->age_ratio->$ageKey;
+
array_push($data,$temp);
unset($empData[$key]);
$floters = array_diff($floters, [$familyFloatesValue]);
@@ -1300,6 +1317,7 @@ public function getAddOnPolicy()
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 = [];
@@ -1307,9 +1325,26 @@ public function getAddOnPolicy()
$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'];
@@ -1460,11 +1495,12 @@ public function getAddOnPolicy()
}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{ $text = $key; }
+ 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);
}
}
@@ -1483,7 +1519,7 @@ public function getAddOnPolicy()
$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'];
@@ -1514,7 +1550,7 @@ public function getAddOnPolicy()
$whereArray = [];
foreach ( $decodedArray->family_floaters as $key => $value) {
if($value != 0){
- if($key == 'parents'){ $text = 'parent'; }else if($key == 'childrens'){ $text = 'child'; }else{ $text = $key; }
+ 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);
}
}
@@ -1532,7 +1568,7 @@ public function getAddOnPolicy()
$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'];
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/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/ClientPolicyModel.php b/app/Models/ClientPolicyModel.php
index 74c2ebd5..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,8 +76,8 @@ 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)
diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php
index 1333e08c..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,6 +767,7 @@ class EmployeePolicyModel extends Model
->getResultArray();
return $result;
+
}
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/PolicyPremium1Model.php b/app/Models/PolicyPremium1Model.php
index 814c0e51..5609ba08 100644
--- a/app/Models/PolicyPremium1Model.php
+++ b/app/Models/PolicyPremium1Model.php
@@ -24,6 +24,7 @@ class PolicyPremium1Model extends Model
"created_by",
"updated_by",
'is_active',
+ 'grade',
'premium_type',
];
diff --git a/app/Models/TPAModel.php b/app/Models/TPAModel.php
index 50bb07b8..215c734d 100644
--- a/app/Models/TPAModel.php
+++ b/app/Models/TPAModel.php
@@ -12,6 +12,9 @@ class TPAModel extends Model
"id",
"name",
"short_name",
+ "front_card",
+ "back_card",
+ "tpa_logo",
"created_by",
"updated_by",
"is_active",
diff --git a/app/Views/batch_list.php b/app/Views/batch_list.php
index dea70840..fd853354 100644
--- a/app/Views/batch_list.php
+++ b/app/Views/batch_list.php
@@ -40,7 +40,7 @@
-
+ 5 ? substr($file['file_name'], 0, 10) . "..." : $file['file_name'] ?>
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_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 @@
@@ -77,6 +79,12 @@
+
+
+ button
+
+