diff --git a/app/Config/Routes.php b/app/Config/Routes.php index a1d8b6a9..ae7e6d50 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -186,7 +186,7 @@ $routes->group("/util", ["filter" => "authMVC"], function($routes){ $routes->get("get-file-error/(:any)", "EmployeeController::getUploadedFileError/$1"); $routes->get("kyc-other-docs-delete/(:any)", "ClientController::deleteClientKycOtherDocs/$1"); $routes->get("policy-premium", "ClientController::getpolicyGridData/$1"); - $routes->get("update-policy-status/(:any)", "ClientController::updateClientPolicyStatus/$1"); + $routes->get("update-policy-status", "ClientController::updateClientPolicyStatus/$1"); }); $routes->cli('processjob', 'JobWorker::processJob'); diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index d324b789..24c4a80b 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -658,9 +658,6 @@ class ClientController extends AdminController - - - public function getKycDocsById($id=null) { @@ -717,12 +714,12 @@ class ClientController extends AdminController public function getpolicyGridData() { - $policy_id = $this->request->getGet('policy_id'); - $client_id = $this->request->getGet('client_id'); + $client_policy_id = $this->request->getGet('client_policy_id'); + $record = $this->clientPolicyModel->where('id', $client_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",$client_id) + ->where("employees.client_id",$record['client_id']) ->where("employees.emp_status",'active') ->countAllResults(); @@ -733,7 +730,7 @@ class ClientController extends AdminController } - $data = $this->policesModel->getPolicyPremium($policy_id); + $data = $this->policesModel->getPolicyPremium($record['policy_id']); $policy_name = $data[0]->policy_name; $pattern = '/gmc/i'; $subject = $data[0]->policy_type; @@ -745,9 +742,9 @@ class ClientController extends AdminController $results = $this->policyGridModel->like('policy_type', $search_term)->findAll(); if($search_term === 'GPA'){ - $premiumData = $this->policyPremium1Model->where(['client_id' => $client_id, 'client_policy_id' => $policy_id, 'is_active' => 1])->findAll(); + $premiumData = $this->policyPremium1Model->where(['client_id' => $record['client_id'], 'client_policy_id' => $client_policy_id, 'is_active' => 1])->findAll(); }else{ - $premiumData = $this->policyPremium2Model->where(['client_id' => $client_id, 'client_policy_id' => $policy_id, 'is_active' => 1])->findAll(); + $premiumData = $this->policyPremium2Model->where(['client_id' => $record['client_id'], 'client_policy_id' => $client_policy_id, 'is_active' => 1])->findAll(); } @@ -763,12 +760,12 @@ class ClientController extends AdminController try { $this->myLogger->logme('error','Terms CREATE function called'); - // print_r($this->request->getPost()); - $client_id = $this->request->getPost("client_id"); - $policy_id = $this->request->getPost("policy_id"); + + /*** Client Policy Table Primary Key(ID) ***/ + $client_policy_id = $this->request->getPost("client_policy_id"); + $data['sum_insured'] =$this->request->getPost("sum_insured"); $data['family_floater'] =$this->request->getPost("family_floater"); - // print_r($data['familyfloater']); if (!$data['family_floater'] || $data['family_floater'] == 0) { $data['corporatebuffer'] = ""; $data['family_floaters'] = ""; @@ -827,14 +824,12 @@ class ClientController extends AdminController $jsonData = json_encode($data); $dataa = array( 'policy_terms' => $jsonData, - 'client_id' => $client_id, - 'policy_id' => $policy_id ); - $record = $this->clientPolicyModel->where(['client_id' => $client_id, 'policy_id' => $policy_id])->first(); + $record = $this->clientPolicyModel->where('id', $client_policy_id)->first(); if ($record) { - $update = $this->clientPolicyModel->update($record['id'], $dataa); + $update = $this->clientPolicyModel->update($client_policy_id, $dataa); if ($update) { return $this->respond(['status' => true,'code' => 200,'message' => 'Data updated successfully'], 200); } else { @@ -859,15 +854,17 @@ class ClientController extends AdminController public function getterms() { - $client_id = $this->request->getVar('client_id'); - $policy_id = $this->request->getVar('policy_id'); - $policy_name = $this->policesModel->select('name')->where('id', $policy_id)->first(); - $record = $this->clientPolicyModel->where(['client_id' => $client_id, 'policy_id' => $policy_id])->first(); + $client_policy_id = $this->request->getVar('client_policy_id'); + $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",$client_id) - ->where("employees.emp_status",'active') - ->countAllResults(); + ->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(); + if($emp_count = 0){ $emp_count = true; }else{ @@ -888,9 +885,8 @@ class ClientController extends AdminController try { $this->myLogger->logme('error','Policy GPA Terms CREATE function called'); - // print_r($this->request->getPost()); - $client_id = $this->request->getPost("client_id"); - $policy_id = $this->request->getPost("policy_id"); + /*** Client Policy Table Primary Key(ID) ***/ + $client_policy_id = $this->request->getPost("client_policy_id"); $data['sumInsured2'] =$this->request->getPost("sumInsured2"); $data['totalSumInsured'] =$this->request->getPost("totalSumInsured"); @@ -940,38 +936,30 @@ class ClientController extends AdminController $data['terrorism'] = $this->request->getPost("terrorism"); $data['worldwideCover'] = $this->request->getPost("worldwideCover"); + $jsonData = json_encode($data); + $dataa = array( + 'policy_terms' => $jsonData, + ); - print_r($data); - - // print_r($this->request->getPost()); - // die(); - - $jsonData = json_encode($data); - $dataa = array( - 'policy_terms' => $jsonData, - 'client_id' => $client_id, - 'policy_id' => $policy_id - ); - $record = $this->clientPolicyModel->where(['client_id' => $client_id, 'policy_id' => $policy_id])->first(); + $record = $this->clientPolicyModel->where('id', $client_policy_id)->first(); if ($record) { - $update = $this->clientPolicyModel->update($record['id'], $dataa); + $update = $this->clientPolicyModel->update($client_policy_id, $dataa); if ($update) { - return $this->respond(['status' => true,'code' => 200,'message' => 'Data updated successfully'], 200); + return $this->respond(['status' => true, 'code' => 200, 'message' => 'Data updated successfully', 'client_policy_id' => $client_policy_id], 200); } else { return $this->respond(['status' => false,'code' => 404, 'message' => 'Failed to update data'], 200); } }else{ $insert = $this->clientPolicyModel->insert($dataa); if ($insert) { - return $this->respond(['status' => true,'code' => 200,'message' => 'Data stored successfully'], 200); + return $this->respond(['status' => true,'code' => 200,'message' => 'Data stored successfully', 'client_policy_id' => $client_policy_id], 200); } else { return $this->respond(['status' => false,'code' => 404, 'message' => 'Failed to store data'], 200); } } } catch (\Exception $e) { - // Handle the exception + echo "Failed to insert data: " . $e->getMessage(); - // Log the error log_message('error', 'Failed to insert data: ' . $e->getMessage()); } @@ -992,11 +980,63 @@ class ClientController extends AdminController } - public function updateClientPolicyStatus($id=null){ + public function updateClientPolicyStatus(){ + + $client_policy_id = $this->request->getGet('client_policy_id'); + $record = $this->clientPolicyModel->where('id', $client_policy_id)->first(); + + + $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' => 'This Policy does not Create Terms'], 200); + } + + + $termsData = json_decode($termsData['policy_terms']); + + 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) && 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); + } + + if($racRate == 0){ + + return $this->respond(['status' => false,'code' => 200,'message' => 'The Policy has no Data for Rac Rate'], 200); + } + + $policy_status = $this->clientPolicyModel->where('id', $client_policy_id )->set('policy_status', 1)->update(); + return $this->respond(['status' => true,'code' => 200, 'message' => 'Policy Status Updated Successfully', 'data' => $termsData, 'racRate' => $racRate], 200); - $policy_status = $this->clientPolicyModel->where('id', $id )->set('policy_status', 1)->update(); - return $this->respond(['status' => true,'code' => 200,'data' => $id], 200); } diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index 531eeb86..e47f06a2 100644 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -18,9 +18,10 @@ use App\Controllers\JobWorker ; use App\Controllers\Jobs\SubJob; use App\Controllers\EmployeeServiceController; - use CodeIgniter\API\ResponseTrait; +use PhpOffice\PhpSpreadsheet\Spreadsheet; + class EmployeeController extends AdminController { @@ -192,9 +193,68 @@ class EmployeeController extends AdminController public function getExcelFileErrors() { + $file_id = $this->request->uri->getSegment(3); - - echo view('excel_errors'); + $file = $this->fileModel->find($file_id); + $error_data = json_decode($file['reason']); + $file_name_with_path = WRITEPATH."/uploads/excel/".$file['file_name']; + + //check the file exist or not + if(!file_exists($file_name_with_path)) + { + $error_message = "File not found"; + $this->myLogger->logme('error',($error_message . ' for file id ' . $file_id)); + } + + $spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($file_name_with_path); + $sheet = $spreadsheet->getActiveSheet(); + + $highestRowAndColumn = $sheet->getHighestRowAndColumn(); + $excel_data = $sheet->rangeToArray('A1:' . $highestRowAndColumn['column'] . $highestRowAndColumn['row']); + $data['excel_header'] = $excel_data[0]; + unset($excel_data[0]); + $data['excel_data'] = $excel_data; + + + echo '
';
+
+ // foreach ($error_data->error_data as $key => $value) {
+ // print_r($excel_data[$key]);
+ // foreach($value as $key2 => $value2){
+ // // echo '';
+ // // print_r($excel_data[$key][$value2->col_idx]);
+ // }
+
+ // }
+ $finalArray = [];
+ foreach ($error_data->error_data as $key => $value) {
+ foreach($value as $key2 => $value2){
+ $error_data = $value2->error;
+
+ echo '';
+ // print_r([$value2->col_idx]);
+ $excel_data[$key][$value2->col_idx] = $error_data;
+ // print_r($excel_data[$key]);
+
+ }
+ // print_r($excel_data[$key]);
+ // array_push($finalArray, $excel_data);
+ }
+
+ print_r($excel_data);
+
+ die;
+
+
+ // echo '######################################################################
';
+ // print_r($excel_data);
+ // echo '######################################################################
';
+ // print_r($error_data->error_data); die;
+
+ $headerData['page_name'] = 'Excel Error';
+ echo view('layout/header', $headerData);
+ echo view('excel_errors', $data);
+ echo view('layout/footer');
}
diff --git a/app/Views/client_policy.php b/app/Views/client_policy.php
index 98e859e4..f05775f0 100644
--- a/app/Views/client_policy.php
+++ b/app/Views/client_policy.php
@@ -203,10 +203,10 @@
@@ -286,11 +286,17 @@
${item.policy_name}
${item.tpa_short} - ${item.tpa_branch_code}
${rearrangeDateFormat(item.policy_start_date)} - ${rearrangeDateFormat(item.policy_end_date)}
- ${checkDateStatus(item.policy_end_date)}
+ ${checkDateStatus(item.policy_end_date, 1)}
-
-
-
+
`;
@@ -300,6 +306,17 @@
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
+ setTimeout(function() {
+ $('.loader').fadeOut();
+ $('.loader-mask').delay(350).fadeOut('slow');
+ if (xhr.status === 404) {
+ toastr.warning('Resource not found', 'Warning');
+ } else if (xhr.status === 500) {
+ toastr.warning('Internal server error', 'Warning');
+ } else {
+ toastr.warning('Unknown error occurred', 'Warning');
+ }
+ }, 1000);
}
});
});
@@ -406,22 +423,53 @@
$('body').on('click', '.btnOpenEnroll', function () {
- var policy_id = $(this).attr('data-id');
- console.log(policy_id)
- if(policy_id){
+ 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(client_policy_id){
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
}
- $.get(''+policy_id, function (data) {
- if(data){
+ $.ajax({
+ url: '',
+ type: 'GET',
+ data: {
+ client_policy_id : client_policy_id,
+ },
+ success: function(res) {
+ console.log(res);
+ if(res) {
+ setTimeout(function() {
+ $('.loader').fadeOut();
+ $('.loader-mask').delay(350).fadeOut('slow');
+ if(res.status === true){
+ toastr.success(res.message, 'Success');
+ }else if(res.status === false){
+ toastr.warning(res.message, 'Warning');
+ }
+ }, 1000);
+ }
+ },
+ error: function(xhr, status, error) {
+ console.error(xhr.responseText);
setTimeout(function() {
- $('.loader').fadeOut();
- $('.loader-mask').delay(350).fadeOut('slow');
- toastr.success('Policy Status Updated Successfully', 'Success');
+ $('.loader').fadeOut();
+ $('.loader-mask').delay(350).fadeOut('slow');
+ if (xhr.status === 404) {
+ toastr.warning('Resource not found', 'Warning');
+ } else if (xhr.status === 500) {
+ toastr.warning('Internal server error', 'Warning');
+ } else {
+ toastr.warning('Unknown error occurred', 'Warning');
+ }
}, 1000);
}
- })
+ });
});
diff --git a/app/Views/excel_errors.php b/app/Views/excel_errors.php
index e2ef8c06..0b9b2044 100644
--- a/app/Views/excel_errors.php
+++ b/app/Views/excel_errors.php
@@ -1,131 +1,34 @@
-
-
-
-
-
- nHANCE
-
-
-
-
-
- /assets/images/favicon.ico">
-
-
- /assets/css/bootstrap-material.min.css" rel="stylesheet" type="text/css"
- id="bs-default-stylesheet" />
- /assets/css/app-material.min.css" rel="stylesheet" type="text/css"
- id="app-default-stylesheet" />
-
- /assets/css/bootstrap-material-dark.min.css" rel="stylesheet" type="text/css"
- id="bs-dark-stylesheet" />
- /assets/css/app-material-dark.min.css" rel="stylesheet" type="text/css"
- id="app-dark-stylesheet" />
-
-
- /assets/css/icons.min.css" rel="stylesheet" type="text/css" />
-
-
-
-
-
-
-
-
-
-
-
- Contextual classes
-
- Use contextual classes to color table rows or individual cells.
-
-
-
-
-
-
- #
- Column heading
- Column heading
- Column heading
-
-
-
-
- 1
- Column content
- Column content
- Column content
-
-
- 2
- Column content
- Column content
- Column content
-
-
- 3
- Column content
- Column content
- Column content
-
-
- 4
- Column content
- Column content
- Column content
-
-
- 5
- Column content
- Column content
- Column content
-
-
- 6
- Column content
- Column content
- Column content
-
-
- 7
- Column content
- Column content
- Column content
-
-
- 8
- Column content
- Column content
- Column content
-
-
- 9
- Column content
- Column content
- Column content
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+ Excel Error List
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/Views/layout/header.php b/app/Views/layout/header.php
index cb8eb5f7..21d677aa 100644
--- a/app/Views/layout/header.php
+++ b/app/Views/layout/header.php
@@ -3,7 +3,7 @@
- nHance
+ = isset($page_name) ? $page_name : 'nHance'; ?>
diff --git a/app/Views/policy_gmc_terms.php b/app/Views/policy_gmc_terms.php
index c999c85f..993f1ba8 100644
--- a/app/Views/policy_gmc_terms.php
+++ b/app/Views/policy_gmc_terms.php
@@ -79,7 +79,7 @@
-