diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 1800a38a..44768c63 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -936,73 +936,102 @@ class ClientController extends AdminController $data = $this->policesModel->getPolicyPremium($record['policy_id']); $policy_name = $data[0]->policy_name; - $pattern = '/gmc/i'; + $gmc_pattern = '/gmc/i'; + $gpa_pattern = '/gpa/i'; $subject = $data[0]->policy_type; - if (preg_match($pattern, $subject)) { + if (preg_match($gmc_pattern, $subject)) { $search_term = 'GMC'; - } else { + } else if (preg_match($gpa_pattern, $subject)){ $search_term = 'GPA'; + }else{ + $search_term = ""; } + $results = $this->policyGridModel->like('policy_type', $search_term)->findAll(); + if($search_term === 'GPA'){ + $premiumData = $this->policyPremium1Model->where(['client_id' => $record['client_id'], 'client_policy_id' => $client_policy_id, 'is_active' => 1])->findAll(); - }else{ + }else if($search_term === 'GMC'){ + $premiumData = $this->policyPremium2Model->where(['client_id' => $record['client_id'], 'client_policy_id' => $client_policy_id, 'is_active' => 1])->findAll(); + + }else{ + + $premiumData = ""; } + // echo $record['client_id']; // echo "-----"; // echo $client_policy_id; // print_r($premiumData);die; // echo '
';
// echo $family_floater;
- $resultss = [];
- if ($family_floater == 1) {
+
+ if($search_term === 'GMC'){
- foreach ($results as $index => $record) {
- if ($index == '8' || $index == '7') {
- // Clearing the $results array
+ $resultss = [];
+ if ($family_floater == 1) {
+
+ foreach ($results as $index => $record) {
+ if ($index == '8' || $index == '7') {
+ // Clearing the $results array
+ $resultss[$index] = $record;
+ }
+ }
+ }else if($family_floater == 0){
+ foreach ($results as $index => $record) {
+ if ($index == '0' || $index == '1' || $index == '2' || $index == '3' || $index == '4' || $index == '5' || $index == '6') {
+ // Clearing the $results array
+ $resultss[$index] = $record;
+ }
+ }
+ }else{
+ foreach ($results as $index => $record) {
$resultss[$index] = $record;
}
}
- }else if($family_floater == 0){
- foreach ($results as $index => $record) {
- if ($index == '0' || $index == '1' || $index == '2' || $index == '3' || $index == '4' || $index == '5' || $index == '6') {
- // Clearing the $results array
- $resultss[$index] = $record;
- }
+ $premiumDataa ='';
+ if ($family_floater == 0) {
+ // print_r($premiumData);die;
+ if (count($premiumData) == 0) {
+ $premiumDataa = $premiumData;
+ }else if ($premiumData[0]['policy_grid_id'] == '3' || $premiumData[0]['policy_grid_id'] == '4' || $premiumData[0]['policy_grid_id'] == '5' || $premiumData[0]['policy_grid_id'] == '6' || $premiumData[0]['policy_grid_id'] == '7' || $premiumData[0]['policy_grid_id'] == '8' || $premiumData[0]['policy_grid_id'] == '9' ) {
+ $premiumDataa = $premiumData;
+ }
+ }
+ else if($family_floater == 1){
+ if(count($premiumData) == 0){
+ $premiumDataa = $premiumData;
+ }else if ($premiumData[0]['policy_grid_id'] == '10' || $premiumData[0]['policy_grid_id'] == '11') {
+ $premiumDataa = $premiumData;
+ }
+ }else{
+ $premiumDataa = $premiumData;
}
- }else{
- foreach ($results as $index => $record) {
- $resultss[$index] = $record;
+
+ if($premiumDataa == ""){
+ $premiumDataa = $premiumData;
}
- }
- $premiumDataa ='';
- if ($family_floater == 0) {
+
// print_r($premiumData);die;
- if (count($premiumData) == 0) {
- $premiumDataa = $premiumData;
- }else if ($premiumData[0]['policy_grid_id'] == '3' || $premiumData[0]['policy_grid_id'] == '4' || $premiumData[0]['policy_grid_id'] == '5' || $premiumData[0]['policy_grid_id'] == '6' || $premiumData[0]['policy_grid_id'] == '7' || $premiumData[0]['policy_grid_id'] == '8' || $premiumData[0]['policy_grid_id'] == '9' ) {
- $premiumDataa = $premiumData;
- }
- }
- else if($family_floater == 1){
- if(count($premiumData) == 0){
- $premiumDataa = $premiumData;
- }else if ($premiumData[0]['policy_grid_id'] == '10' || $premiumData[0]['policy_grid_id'] == '11') {
- $premiumDataa = $premiumData;
- }
+
+ // print_r($data[0]->policy_type); die;
+ // echo "hello";
+ // return json_encode($premiumData);
+
+ return $this->respond(['status' => true,'code' => 200,'data' => $resultss, 'premiumData' => json_encode($premiumDataa), 'count' => $emp_count, 'policy_name' => $policy_name,], 200);
+
+ }else if($search_term === 'GPA'){
+
+ return $this->respond(['status' => true,'code' => 200,'data' => $results, 'premiumData' => json_encode($premiumData), 'count' => $emp_count, 'policy_name' => $policy_name,], 200);
+
}else{
- $premiumDataa = $premiumData;
+
+ return $this->respond(['status' => false,'code' => 200,'data' => $results, 'premiumData' => json_encode($premiumData), 'count' => $emp_count, 'policy_name' => $policy_name,], 200);
+
}
-
- // print_r($premiumData);die;
-
- // print_r($data[0]->policy_type); die;
- // echo "hello";
- // return json_encode($premiumData);
- return $this->respond(['status' => true,'code' => 200,'data' => $resultss, 'premiumData' => json_encode($premiumDataa), 'count' => $emp_count, 'policy_name' => $policy_name,], 200);
-
}
public function policyGMCTerms()
@@ -1082,6 +1111,10 @@ class ClientController extends AdminController
$data['family_floaters']['parents'] =2;
$data['family_floaters']['parents-in-law'] =2;
$data['family_floaters']['either-parents-pil'] =0;
+ }else{
+ $data['family_floaters']['parents'] =0;
+ $data['family_floaters']['parents-in-law'] =0;
+ $data['family_floaters']['either-parents-pil'] =0;
}
}
diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php
index c22adea1..a5909186 100644
--- a/app/Controllers/EmployeeRestController.php
+++ b/app/Controllers/EmployeeRestController.php
@@ -189,7 +189,12 @@ class EmployeeRestController extends AdminController
$item->family_floater_key = $this->RelationshipMap($item->relationship);
$item->dob = $this->convertDateFormatYMD($item->dob);
$employee = $this->employeeModel->insert($item);
+
if ($employee) {
+ if(!isset($item->is_addon_value))
+ {
+ $this->createEmployeePolicyData($employee,$item->emp_code,$item->client_id,$item->client_policy_id);
+ }
$Count++;
}
@@ -211,6 +216,34 @@ class EmployeeRestController extends AdminController
}
+ public function createEmployeePolicyData($employee_id,$emp_code,$client_id,$client_policy_id)
+ {
+
+
+
+ $client_policy = $this->clientPolicyModel->where('id', $client_policy_id)->where('client_id', $client_id)->first();
+ $policy_terms = json_decode($client_policy['policy_terms']);
+ $basic_cover_si = $policy_terms->sum_insured;
+
+ $getSlabAndGridData = $this->policesModel->getPolicySlabRatesForEmpOnboard($client_policy_id,$client_id);
+ $SlabRatesArray = $getSlabAndGridData['slab_rates'];
+ $premium = $this->findPremiumAmount($SlabRatesArray, $basic_cover_si);
+
+
+
+ $data['employee_id']= $employee_id;
+ $data['client_policy_id']= $client_policy_id;
+ $data['basic_cover_si']= $basic_cover_si;
+ $data['premium']= $premium;
+
+ $this->employeePolicyModel->insert($data);
+
+
+ return true;
+
+
+ }
+
public function RelationshipMap($value){
if ($value === 'Mother' || $value === 'Father') {
@@ -274,10 +307,8 @@ class EmployeeRestController extends AdminController
public function getEmployeeAndDependenceByClientId()
{
try {
- $empData = $this->employeePolicyModel->getEmployeePolicy( $this->request->getGet('client_id'), $this->request->getGet('client_policy_id'));
- // $empData = $this->employeeModel->where('client_id', $this->request->getGet('client_id'))
- // ->where('relationship !=', null)
-
+ $empData = $this->employeePolicyModel->getEmployeePolicy( client_id:$this->request->getGet('client_id'),policy_id: $this->request->getGet('client_policy_id'),status:0);
+
if ($empData) {
return $this->respond(['status' => 'success', 'code' => 200, 'data' => $empData], 200);
} else {
@@ -302,7 +333,7 @@ class EmployeeRestController extends AdminController
foreach ($ClientPolicyData as $key => $value) {
$getSlabAndGridData = $this->policesModel->getPolicySlabRatesForEmpOnboard( $value['client_policy_id'],$value['client_id']);
if($value['is_addon'] == 1){
- $value['type'] = 'Add-On';
+ $value['type'] = 'AddOn';
}else{
$value['type'] = $getSlabAndGridData['grid_master']['policy_type'];
}
diff --git a/app/Helpers/excel_import_export_helper.php b/app/Helpers/excel_import_export_helper.php
index af0b8e07..e840fded 100644
--- a/app/Helpers/excel_import_export_helper.php
+++ b/app/Helpers/excel_import_export_helper.php
@@ -87,9 +87,9 @@ if (!function_exists('generate_excel')) {
try {
// Save Excel file to the specified path
- // $writer->save($filename);
- $filePath = WRITEPATH."/uploads/import_excel/" . $filename;
- $writer->save($filePath);
+ $writer->save($filename);
+ // $filePath = WRITEPATH."/uploads/import_excel/" . $filename;
+ // $writer->save($filePath);
return true; // Return true if file was successfully saved
} catch (\Exception $e) {
// Log or handle the exception
@@ -417,4 +417,103 @@ if (!function_exists('formatDateOrReturn')) {
return $value;
}
}
+}
+
+
+if (!function_exists('format_Excel_BasedOn_Client'))
+{
+ function format_Excel_BasedOn_Client($objects, $client_excel_header)
+ {
+
+ $data = [];
+
+ // Initialize serial number
+ $serialNumber = 1;
+
+ // Iterate through each object
+ foreach ($objects as $obj)
+ {
+ // Extract all values for the object based on the header order
+ $rowData = [];
+ foreach ($client_excel_header as $header) {
+
+ $normalizedHeader = strtolower(str_replace(' ', '', $header));
+
+ switch ($normalizedHeader) {
+ case 's.no':
+ $rowData[] = $serialNumber++; // Serial Number
+ break;
+ case 'empid':
+ $rowData[] = $obj->emp_code; // Employee Code
+ break;
+ case 'nameofemp/dep':
+ $rowData[] = $obj->emp_name; // Employee Name
+ break;
+ case 'emp/deptype':
+ $rowData[] = $obj->emp_type; // Employee Type
+ break;
+ case 'relation':
+ $rowData[] = $obj->emp_relationship_code; // RELATION
+ break;
+ case 'dob':
+ $rowData[] = $obj->emp_dob; // Employee DOB
+ break;
+ case 'gender':
+ $rowData[] = $obj->emp_gender; //Employee GENDER
+ break;
+ case 'preexistingailments':
+ $rowData[] = $obj->pre_existing_alignments; // PRE EXISTING AILMENTS
+ break;
+ case 'basiccoversi':
+ $rowData[] = $obj->basic_cover_si; // Employee BASIC COVER SI
+ break;
+ case 'dateofcoverage':
+ $rowData[] = $obj->date_coverage; // DATE OF COVERAGE
+ break;
+ case 'age':
+ $rowData[] = $obj->emp_age; // Employee AGE
+ break;
+ case 'relationship':
+ $rowData[] = $obj->emp_relationship; // Employee RELATIONSHIP
+ break;
+ case 'remarks':
+ $rowData[] = $obj->change_event; // REMARKS
+ break;
+ case 'policyenddate':
+ $rowData[] = $obj->policy_end_date; // POLICY END DATE
+ break;
+ case 'noofdays':
+ $rowData[] = $obj->days; // NO OF DAYS
+ break;
+ case 'tpaid':
+ $rowData[] = ''; // TPA ID
+ break;
+ case 'uhid':
+ $rowData[] = ''; // UHID
+ break;
+ case 'premium':
+ $rowData[] = $obj->premium; // PREMIUM
+ break;
+ case 'proratapremium':
+ $rowData[] = $obj->rata_premimum; // PR0 RATA PREMIUM
+ break;
+ case 'gst':
+ $rowData[] = $obj->gst; // GST
+ break;
+ case 'total':
+ $rowData[] = $obj->total; // TOTAL
+ break;
+ default:
+ // If the header doesn't match any property, add an empty string
+ $rowData[] = '';
+ break;
+ }
+ }
+ // Append the row data to the main data array
+ $data[] = $rowData;
+ }
+
+ return $data;
+
+ }
}
\ No newline at end of file
diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php
index 8340dbf5..3cdd2177 100644
--- a/app/Models/EmployeePolicyModel.php
+++ b/app/Models/EmployeePolicyModel.php
@@ -69,7 +69,7 @@ class EmployeePolicyModel extends Model
// -----------------------------------------------------------------------------------------------------
public function getEmployeePolicy($client_id,$policy_id,$status)
{
- $result = $this->select(['employee_polices.*','pm.name as policy_name','im.short_name as insurer_short_name','ib.branch_name as insurer_branch_name','ib.branch_code as insurer_branch_code','tpam.name as tpa_name','tpam.short_name as tpa_short_name','tpab.branch_code as tpa_branch_code','cm.client_name','cm.short_name as client_short_name','emp.relationship','emp.relationship_code','emp.change_event','emp.emp_code','emp.name','emp.email_corporate','emp.dob','emp.gender','emp.emp_status','emp.is_active as emp_is_active'])
+ $result = $this->select(['employee_polices.*','pm.name as policy_name','im.short_name as insurer_short_name','ib.branch_name as insurer_branch_name','ib.branch_code as insurer_branch_code','tpam.name as tpa_name','tpam.short_name as tpa_short_name','tpab.branch_code as tpa_branch_code','cm.client_name','cm.short_name as client_short_name','emp.relationship','emp.relationship_code','emp.change_event','emp.emp_code','emp.name','emp.email_corporate','emp.dob','emp.gender','emp.emp_status','emp.is_active as emp_is_active','emp.mobile as mobile'])
->join('employees emp', 'employee_polices.employee_id = emp.id')
->join('client_policy cp', 'employee_polices.client_policy_id = cp.id') //cp - client policy
->join('policies pm', 'cp.policy_id = pm.id') //pm - policy master
diff --git a/app/Views/policy_grid.php b/app/Views/policy_grid.php
index 13655d71..fb7e5b22 100644
--- a/app/Views/policy_grid.php
+++ b/app/Views/policy_grid.php
@@ -568,6 +568,7 @@
var client_policy_id = $(this).data('id');
$('#client_policy_id').val(client_policy_id);
+ console.log('client_policy_id',client_policy_id)
var policy_type_string = $(this).attr('id');
console.log('policy_type_string', policy_type_string)
@@ -590,7 +591,7 @@
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}, 1000);
- console.log('res',res);
+ console.log('policy grid responce',res);
var temp_for_premiumData = JSON.parse(res.premiumData);
res.premiumData= JSON.parse(res.premiumData);