diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 2b5354d5..600d054e 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -921,6 +921,39 @@ class ClientController extends AdminController } $data = $this->request->getPost(); $insert = true; + }else if($policy_grid_id == '12'){ + + $premium=$this->request->getPost('12_premium[]'); + $sum_insure =$this->request->getPost('12_si[]'); + $relationship =$this->request->getPost('12_relationship[]'); + for ($i=0; $i < count($premium) ; $i++) { + $data['premium'] = str_replace(',', '',$premium[$i]); + $data['si'] = str_replace(',', '', $sum_insure[$i]); + $data['relationship'] = $relationship[$i]; + + $dataa= $this->policyPremium2Model->insert($data); + } + $data = $this->request->getPost(); + $insert = true; + }else if($policy_grid_id == '13'){ + + $premium=$this->request->getPost('13_premium[]'); + $sum_insure =$this->request->getPost('13_si[]'); + $age_from =$this->request->getPost('13_age_from[]'); + $age_to =$this->request->getPost('13_age_to[]'); + $relationship =$this->request->getPost('13_relationship[]'); + + for ($i=0; $i < count($premium) ; $i++) { + $data['premium'] = str_replace(',', '',$premium[$i]); + $data['si'] = str_replace(',', '', $sum_insure[$i]); + $data['age_from'] = $age_from[$i]; + $data['age_to'] = $age_to[$i]; + $data['relationship'] = $relationship[$i]; + + $dataa= $this->policyPremium2Model->insert($data); + } + $data = $this->request->getPost(); + $insert = true; } if($insert){ @@ -1003,6 +1036,12 @@ class ClientController extends AdminController $family_floater=json_decode($record['policy_terms'])->family_floater; } + $policy_terms_data = json_decode($record['policy_terms']); + $self = ""; + if ($policy_terms_data !== null && isset($policy_terms_data->family_floaters)) { + $self = $policy_terms_data->family_floaters; + } + $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']) @@ -1054,26 +1093,25 @@ class ClientController extends AdminController if($search_term === 'GMC'){ $resultss = []; - if ($family_floater == 1) { + try { foreach ($results as $index => $record) { - if ($index == '8' || $index == '7') { - // Clearing the $results array - $resultss[$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) { + if ($index == '0' || $index == '1' || $index == '2') { + $resultss[$index] = $record; + } + } else { + if ($index == '0' || $index == '1' || $index == '2' || $index == '3' || $index == '4' || $index == '5' || $index == '6' || $index == '8' || $index == '7' || $index == '9' || $index == '10') { + $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; - } + } catch (\Exception $e) { + $resultss = $results; // Reset $resultss to an empty array if an exception occurs } + + + $premiumDataa =''; if ($family_floater == 0) { // print_r($premiumData);die; @@ -1086,7 +1124,7 @@ class ClientController extends AdminController 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') { + }else if ($premiumData[0]['policy_grid_id'] == '10' || $premiumData[0]['policy_grid_id'] == '11' ) { $premiumDataa = $premiumData; } }else{ @@ -1103,15 +1141,15 @@ class ClientController extends AdminController // 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); + return $this->respond(['status' => true,'code' => 200,'data' => $resultss, 'premiumData' => json_encode($premiumDataa), 'count' => $emp_count, 'policy_name' => $policy_name, 'family_floater' => $family_floater, 'self' => $self], 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); + return $this->respond(['status' => true,'code' => 200,'data' => $results, 'premiumData' => json_encode($premiumData), 'count' => $emp_count, 'policy_name' => $policy_name, 'family_floater' => $family_floater, 'self' => $self], 200); }else{ - return $this->respond(['status' => false,'code' => 200,'data' => $results, 'premiumData' => json_encode($premiumData), 'count' => $emp_count, 'policy_name' => $policy_name,], 200); + return $this->respond(['status' => false,'code' => 200,'data' => $results, 'premiumData' => json_encode($premiumData), 'count' => $emp_count, 'policy_name' => $policy_name, 'family_floater' => $family_floater, 'self' => $self], 200); } } diff --git a/app/Controllers/EmpDataServiceController.php b/app/Controllers/EmpDataServiceController.php index 9e0e0517..4ce78926 100644 --- a/app/Controllers/EmpDataServiceController.php +++ b/app/Controllers/EmpDataServiceController.php @@ -490,8 +490,19 @@ class EmpDataServiceController extends BaseController try { - if ($value[15] === null || $value[16] === null) { - $missing_id[] = $key + 1; + + if($import_data['insurer_or_tpa'] == 'tpa'){ + + if ($value[15] === null) { + $missing_id[] = $key + 1; + } + + }else if($import_data['insurer_or_tpa'] == 'insurer'){ + + if ( $value[16] === null) { + $missing_id[] = $key + 1; + } + } $emp_code = $value[2]; @@ -501,26 +512,32 @@ class EmpDataServiceController extends BaseController $db = \Config\Database::connect(); // Execute the query - $query = $db->table('employee_polices') - ->select('employee_polices.id') - ->join('employees', 'employees.id = employee_polices.employee_id') - ->where('employee_polices.client_policy_id', $client_policy_id) - ->where('employees.client_id', $client_id) - ->where('employees.name', $name) - ->where('employees.emp_code', $emp_code) - ->where('(employee_polices.tpa_id IS NULL OR employee_polices.tpa_id = "")') - ->where('(employee_polices.uhid IS NULL OR employee_polices.uhid = "")') - ->where('employee_polices.is_active', 1) - ->limit(1) - ->get(); + $query = $db->table('employee_polices'); + $query->select('employee_polices.id'); + $query->join('employees', 'employees.id = employee_polices.employee_id'); + $query->where('employee_polices.client_policy_id', $client_policy_id); + $query->where('employees.client_id', $client_id); + $query->where('employees.name', $name); + $query->where('employees.emp_code', $emp_code); + if($import_data['insurer_or_tpa'] == 'tpa'){ + + $query->where('(employee_polices.tpa_id IS NULL OR employee_polices.tpa_id = "")'); + + }else if($import_data['insurer_or_tpa'] == 'insurer'){ + + $query->where('(employee_polices.uhid IS NULL OR employee_polices.uhid = "")'); + + } + $query->where('employee_polices.is_active', 1); + $query->limit(1); // Get the result - $result = $query->getRowArray(); + $result = $query->get()->getRowArray(); if (isset($result['id']) && $result['id'] !== null) { $empty_emp_tpa_uh_ids[] = $result['id']; } } catch (\Exception $e) { - // Handle the exception here + return 0; } } @@ -529,17 +546,46 @@ class EmpDataServiceController extends BaseController $missing_id_count = count($missing_id); $empty_id_count = count($empty_emp_tpa_uh_ids); - // dd($count, $missing_id_count, $empty_id_count, $data, $empty_emp_tpa_uh_ids); - if ($missing_id_count != $count && $missing_id_count != 0) { + if($import_data['insurer_or_tpa'] == 'tpa'){ + + if ($empty_id_count == 0) { + + return 3; + } + + if ($missing_id_count != 0) { + + return 2; + } + + + }else if($import_data['insurer_or_tpa'] == 'insurer'){ + + if ($empty_id_count == 0) { + + return 5; + } + + if ($missing_id_count != 0) { + + return 4; + } - return 2; } - if ($empty_emp_tpa_uh_ids != $count && $empty_id_count == 0) { + // if ($missing_id_count != $count) { - return 3; - } + // return 2; + // } + + + // if ($empty_emp_tpa_uh_ids != $count) { + + // return 3; + // } + + // dd($empty_emp_tpa_uh_ids); @@ -559,18 +605,28 @@ class EmpDataServiceController extends BaseController foreach ($data as $key => $value) { - if (!empty($value) && (isset($value[15]) || isset($value[16]))) { + if (!empty($value)) { - $tpa_id = $value[15] !== null ? $value[15] : ''; - $uhid = $value[16] !== null ? $value[16] : ''; + + if($import_data['insurer_or_tpa'] == 'tpa'){ - foreach ($empty_emp_tpa_uh_ids as $id) { - // Update employee policies based on the ID - $this->employeePolicyModel->where('id', $id)->set(['tpa_id' => $tpa_id, 'uhid' => $uhid])->update(); + $tpa_id = $value[15] !== null ? $value[15] : ''; + $uhid = $value[16] !== null ? $value[16] : ''; + + $data = ['tpa_id' => $tpa_id, 'uhid' => $uhid]; + + }else if($import_data['insurer_or_tpa'] == 'insurer'){ + + $tpa_id = $value[15] !== null ? $value[15] : ''; + $uhid = $value[16] !== null ? $value[16] : ''; + $data = ['tpa_id' => $tpa_id, 'uhid' => $uhid]; + } + + foreach ($empty_emp_tpa_uh_ids as $id) { + + $this->employeePolicyModel->where('id', $id)->set($data)->update(); } - // $query = $this->employeePolicyModel->getLastQuery(); - // echo $query . "
"; } else { @@ -580,17 +636,23 @@ class EmpDataServiceController extends BaseController - $policy_name = $this->getPolicyNameUsingClientPolicyId($client_policy_id); - $depositeData = [ - 'employeeIds' => $empty_emp_tpa_uh_ids, - 'client_id' => $client_id, - 'client_policy_id' => $client_policy_id, - 'count' => $count, - 'event' => $import_data['event_type'], - 'policy_name' => $policy_name['policy_name'], - ]; + if($import_data['insurer_or_tpa'] == 'tpa'){ + + $policy_name = $this->getPolicyNameUsingClientPolicyId($client_policy_id); + $depositeData = [ + 'employeeIds' => $empty_emp_tpa_uh_ids, + 'client_id' => $client_id, + 'client_policy_id' => $client_policy_id, + 'count' => $count, + 'event' => $import_data['event_type'], + 'policy_name' => $policy_name['policy_name'], + ]; + + $this->cashDepositCalculationForInception($depositeData); + + } + - $this->cashDepositCalculationForInception($depositeData); return 1; } diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index 6a3ba065..2676257c 100644 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -401,16 +401,28 @@ class EmployeeController extends AdminController return redirect()->to(base_url('employee/upload')); }else if($return == 2){ - session()->setFlashdata('error', 'The TPA ID or UHID columns are empty.'); + session()->setFlashdata('error', 'The TPA ID column is either partially or entirely empty.'); return redirect()->to(base_url('employee/upload')); }else if($return == 0){ - session()->setFlashdata('error', 'Please upload the correct file, something went wrong.'); + session()->setFlashdata('error', 'Please upload the correct file.'); return redirect()->to(base_url('employee/upload')); + }else if($return == 3){ - session()->setFlashdata('error', 'File already uploaded'); + session()->setFlashdata('error', 'The following list of employees has already been updated with the TPA ID.'); return redirect()->to(base_url('employee/upload')); - } }else if($event_type == 'correction'){ + + }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){ + session()->setFlashdata('error', 'The following list of employees has already been updated with the UHID.'); + return redirect()->to(base_url('employee/upload')); + + } + + }else if($event_type == 'correction'){ $return = $empDataServiceController->importExcelDataForCorrection($batch_data); if($return == 1){ @@ -422,7 +434,7 @@ class EmployeeController extends AdminController return redirect()->to(base_url('employee/upload')); }else if($return == 0){ - session()->setFlashdata('error', 'Please upload the correct file, something went wrong.'); + session()->setFlashdata('error', 'Please upload the correct file'); return redirect()->to(base_url('employee/upload')); }else if($return == 3){ session()->setFlashdata('error', 'File already uploaded'); @@ -441,7 +453,7 @@ class EmployeeController extends AdminController return redirect()->to(base_url('employee/upload')); }else if($return == 0){ - session()->setFlashdata('error', 'Please upload the correct file, something went wrong.'); + session()->setFlashdata('error', 'Please upload the correct file'); return redirect()->to(base_url('employee/upload')); }else if($return == 3){ session()->setFlashdata('error', 'File already uploaded'); @@ -460,7 +472,7 @@ class EmployeeController extends AdminController return redirect()->to(base_url('employee/upload')); }else if($return == 0){ - session()->setFlashdata('error', 'Please upload the correct file, something went wrong.'); + session()->setFlashdata('error', 'Please upload the correct file'); return redirect()->to(base_url('employee/upload')); }else if($return == 3){ session()->setFlashdata('error', 'File already uploaded'); @@ -704,9 +716,9 @@ class EmployeeController extends AdminController $file_data = $this->fileModel->find($file_id); $error = json_decode($file_data['reason']); - // echo '
';
-    //    print_r($error); die;
-    //    dd($error);
+        //    echo '
';
+        //    print_r($error); die;
+        //    dd($error);
     
         // Check if the file exists
         if (!$file_data) {
diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php
index 17f1c3f2..7c961144 100644
--- a/app/Models/EmployeePolicyModel.php
+++ b/app/Models/EmployeePolicyModel.php
@@ -107,6 +107,15 @@ class EmployeePolicyModel extends Model
         $client_policy_id = $ref_data['client_policy_id'];
         $insurer_or_tpa = $ref_data['insurer_or_tpa'];
 
+        if($insurer_or_tpa == 'tpa'){
+
+            $id = 'tpa_id';
+
+        }else if($insurer_or_tpa == 'insurer'){
+
+            $id = 'uhid';
+        }
+
         $sql = "
                 SELECT 
                 employees.name AS emp_name,
@@ -148,8 +157,7 @@ class EmployeePolicyModel extends Model
             WHERE batch_data.bf IS NULL
                 AND batch_data.bl IS NULL
                 AND employee_polices.client_policy_id = '{$client_policy_id}'
-                AND (employee_polices.tpa_id IS NULL OR employee_polices.tpa_id = '')
-                AND (employee_polices.uhid IS NULL OR employee_polices.uhid = '')
+                AND (employee_polices.{$id} IS NULL OR employee_polices.{$id} = '')
                 AND employee_polices.is_active = 1";
 
             // Get the result set
diff --git a/app/Models/PolicyPremium2Model.php b/app/Models/PolicyPremium2Model.php
index e390dcc7..85ee9972 100644
--- a/app/Models/PolicyPremium2Model.php
+++ b/app/Models/PolicyPremium2Model.php
@@ -24,6 +24,7 @@ class PolicyPremium2Model extends Model
         "updated_by",
         'is_active',  
         'premium_type',  
+        'relationship',  
         
     ];
 
diff --git a/app/Views/policy_grid.php b/app/Views/policy_grid.php
index 89946fec..4a5a8f6c 100644
--- a/app/Views/policy_grid.php
+++ b/app/Views/policy_grid.php
@@ -27,12 +27,13 @@
                                 
                             
 
-                            
+ @@ -66,7 +67,7 @@ $('#btnGridSubmit').hide(); $('.close').click(function() { - for (var i = 1; i <= 11; i++) { + for (var i = 1; i <= 13; i++) { $('#grid_' + i).remove(); } @@ -92,7 +93,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa if (dataIdValue == '1') { - for (var i = 1; i <= 11; i++) { + for (var i = 1; i <= 13; i++) { $('#grid_' + i).remove(); } @@ -164,7 +165,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa
`; } else if (dataIdValue == '2') { - for (var i = 1; i <= 11; i++) { + for (var i = 1; i <= 13; i++) { $('#grid_' + i).remove(); } @@ -186,7 +187,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa } else if (dataIdValue == '3') { - for (var i = 1; i <= 11; i++) { + for (var i = 1; i <= 13; i++) { $('#grid_' + i).remove(); } @@ -211,7 +212,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa } else if (dataIdValue == '4') { - for (var i = 1; i <= 11; i++) { + for (var i = 1; i <= 13; i++) { $('#grid_' + i).remove(); } grid_html = ` @@ -245,7 +246,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa } else if (dataIdValue == '5') { - for (var i = 1; i <= 11; i++) { + for (var i = 1; i <= 13; i++) { $('#grid_' + i).remove(); } @@ -278,7 +279,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa } else if (dataIdValue == '6') { - for (var i = 1; i <= 11; i++) { + for (var i = 1; i <= 13; i++) { $('#grid_' + i).remove(); } @@ -313,7 +314,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa } else if (dataIdValue == '7') { - for (var i = 1; i <= 11; i++) { + for (var i = 1; i <= 13; i++) { $('#grid_' + i).remove(); } @@ -346,7 +347,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa } else if (dataIdValue == '8') { - for (var i = 1; i <= 11; i++) { + for (var i = 1; i <= 13; i++) { $('#grid_' + i).remove(); } @@ -376,7 +377,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa } else if (dataIdValue == '9') { - for (var i = 1; i <= 11; i++) { + for (var i = 1; i <= 13; i++) { $('#grid_' + i).remove(); } @@ -406,7 +407,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa } else if (dataIdValue == '10') { - for (var i = 1; i <= 11; i++) { + for (var i = 1; i <= 13; i++) { $('#grid_' + i).remove(); } @@ -438,7 +439,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa } else if (dataIdValue == '11') { - for (var i = 1; i <= 11; i++) { + for (var i = 1; i <= 13; i++) { $('#grid_' + i).remove(); } @@ -469,8 +470,91 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa `; + } else if (dataIdValue == '12') { + + for (var i = 1; i <= 13; i++) { + $('#grid_' + i).remove(); + } + + grid_html = ` + +
+
+ + +
+
+
+ + +
+
+ + +
+
+
+ + +
+
`; + + } else if (dataIdValue == '13') { + + for (var i = 1; i <= 13; i++) { + $('#grid_' + i).remove(); + } + + grid_html = ` + +
+
+ + +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+ + +
+
`; + } else { - for (var i = 1; i <= 11; i++) { + for (var i = 1; i <= 13; i++) { $('#grid_' + i).remove(); } grid_html = ''; @@ -597,6 +681,7 @@ $('body').on('click', '.btnPolicyModel', function() { $('.loader').fadeIn(); $('.loader-mask').fadeIn(); + $.ajax({ url: '', type: "GET", @@ -608,6 +693,12 @@ $('body').on('click', '.btnPolicyModel', function() { $('#GridForm')[0].reset(); + if(res.family_floater == 1){ + $('#premium_type').show(); + }else{ + $('#premium_type').hide(); + } + setTimeout(function() { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); @@ -634,7 +725,8 @@ $('body').on('click', '.btnPolicyModel', function() { } var policy_grid_id_value = ''; - if (res.premiumData && res.premiumData.length > 0 && res.premiumData[0].policy_grid_id) { + if (res.premiumData && res.premiumData.length > 0 && res.premiumData[0] + .policy_grid_id) { policy_grid_id_value = res.premiumData[0].policy_grid_id; } @@ -649,23 +741,26 @@ $('body').on('click', '.btnPolicyModel', function() { }); $('#grid').html(policeGridOptionHTML); - if(res.premiumData[0].hasOwnProperty('premium_type')){ + if (res.premiumData[0].hasOwnProperty('premium_type')) { if (res.premiumData[0].premium_type == '2') { $('#individual').prop('checked', true) $('#single').prop('checked', false) - } else if (res.premiumData[0].premium_type == '1') { + } else if (res.premiumData[0].premium_type == '1') { $('#single').prop('checked', true) $('#individual').prop('checked', false) + + } else { + $('#single').prop('checked', false) + $('#individual').prop('checked', false) } } - var si_or_bp_value = ''; if (res.premiumData && res.premiumData.length > 0) { @@ -1101,6 +1196,78 @@ function appendGridtHtml(ui_type = false, data = false, ) { `; + } else if (ui_type == '12') { + + html = ` +
+
+ + +
+
+
+ + +
+
+ + +
+
+
+ + +
+
`; + } else if (ui_type == '13') { + + html = ` +
+
+ + +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+ + +
+
`; } @@ -1113,8 +1280,6 @@ function appendGridtHtml(ui_type = false, data = false, ) { Count++ - - // Number to word $(document).keyup(function(event) { if (event.target) {