diff --git a/app/Config/Filters.php b/app/Config/Filters.php index 7add9fb4..4f16d072 100644 --- a/app/Config/Filters.php +++ b/app/Config/Filters.php @@ -12,6 +12,8 @@ use CodeIgniter\Filters\SecureHeaders; use App\Filters\AuthMVC; use App\Filters\HttpRequestLog; +use App\Filters\AuthJWT; + class Filters extends BaseConfig { /** @@ -29,7 +31,8 @@ class Filters extends BaseConfig 'invalidchars' => InvalidChars::class, 'secureheaders' => SecureHeaders::class, 'authMVC' => AuthMVC::class, - 'HttpRequestLog' => HttpRequestLog::class + 'HttpRequestLog' => HttpRequestLog::class, + 'authJWT' => AuthJWT::class ]; /** diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 72310f66..c65a956a 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -185,8 +185,20 @@ $routes->group("/util", ["filter" => "authMVC"], function($routes){ $routes->get("police-by-insurer/(:any)", "ClientController::getPolicesByInsurerId/$1"); $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("policy-premium", "ClientController::getpolicyGridData/$1"); + $routes->get("update-policy-status", "ClientController::updateClientPolicyStatus/$1"); }); $routes->cli('processjob', 'JobWorker::processJob'); + + +// $routes->get("/api", "RestAuthenticationController::index"); +$routes->post("/api/verifyEmployeeNumber", "RestAuthenticationController::verifyEmployeeWithMobileNumber"); +$routes->post("/api/getVerifiedUserData", "RestAuthenticationController::getVerifiedUserData"); + +$routes->group("/api", ["filter" => "authJWT"], function($routes){ + $routes->post("logined", "RestAuthenticationController::logined"); + $routes->post("getId", "RestAuthenticationController::getUserIdFromToken"); + +}); \ No newline at end of file diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 5d5029bf..8575d6b0 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -2,6 +2,7 @@ namespace App\Controllers; use App\Helpers\DepositHelper; +use App\helpers\JWTToken; use CodeIgniter\HTTP\IncomingRequest; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; @@ -29,6 +30,8 @@ use App\Models\PolicyPremium1Model; use App\Models\PolicyPremium2Model; use App\Models\EmployeeModel; + + class ClientController extends AdminController { use ResponseTrait; @@ -86,6 +89,15 @@ class ClientController extends AdminController public function index() { + + // $token = $_SESSION; + // $token = $request->getHeaderLine('Authorization'); + + + // print_r(JWTToken::getIdFromToken($token)); + + // die(); + $this->myLogger->logme('error','Client list function called'); $headerData['page_name'] = 'Client List'; $data['clientList'] = $this->clientModel->getCreatedByUserName(); @@ -121,81 +133,77 @@ class ClientController extends AdminController echo view('client_onboarding', $data); echo view('layout/footer'); - } - // In your controller - public function deposit($id = null) - { - $headerData['page_name'] = 'Client Deposit'; - - $data['clientData'] = $this->clientPolicyModel->getinsurerswithclientid($id); - $data['depositsummary'] = $this->clientPolicyModel->getDepositlistsummary($id); - - // Fetch associated insurer names and balances - $balances = $this->clientPolicyModel->getBalances($id); - $data['balances'] = $balances; - - echo view('layout/header', $headerData); - echo view('client_deposit_list', $data); - echo view('layout/footer'); - } - + } - -public function view_Deposit($insurerId) { - // Load your model to fetch data based on $clientId and $insurerId - $subTypeOptions = [ - 1 => 'Deposit', - 2 => 'Adjustment', - 3 => 'Deletion', - // Add more options as needed - ]; - $data['subTypeOptions'] = $subTypeOptions; + // In your controller + public function deposit($id = null) + { $headerData['page_name'] = 'Client Deposit'; - $data['insurerName']= $this->insurerModel->getInsurerName($insurerId); - $loggedInUserID = get_session_userid(); - // $data['clientData']= $this->clientPolicyModel->getinsurerswithinsurenceid($insurerId); - $clientId = $this->request->getGet('client_id'); - $data['depositdata']= $this->clientPolicyModel->getdepositData($clientId,$insurerId); - $data['clientData'] = $this->clientPolicyModel->getClientById($clientId); - $data['deposiamount'] = $this->clientPolicyModel->getDepositSummary($clientId, $insurerId); - - - // print_r($data['depositdata'] );die; - // Load the view for the new list page + + $data['clientData'] = $this->clientPolicyModel->getinsurerswithclientid($id); + $data['depositsummary'] = $this->clientPolicyModel->getDepositlistsummary($id); + + // Fetch associated insurer names and balances + $balances = $this->clientPolicyModel->getBalances($id); + $data['balances'] = $balances; + echo view('layout/header', $headerData); - echo view('view_deposit',$data); + echo view('client_deposit_list', $data); echo view('layout/footer'); -} + } + + public function view_Deposit($insurerId) + { + // Load your model to fetch data based on $clientId and $insurerId + $subTypeOptions = [ + 1 => 'Deposit', + 2 => 'Adjustment', + 3 => 'Deletion', + // Add more options as needed + ]; + $data['subTypeOptions'] = $subTypeOptions; + $headerData['page_name'] = 'Client Deposit'; + $data['insurerName']= $this->insurerModel->getInsurerName($insurerId); + $loggedInUserID = get_session_userid(); + // $data['clientData']= $this->clientPolicyModel->getinsurerswithinsurenceid($insurerId); + $clientId = $this->request->getGet('client_id'); + $data['depositdata']= $this->clientPolicyModel->getdepositData($clientId,$insurerId); + $data['clientData'] = $this->clientPolicyModel->getClientById($clientId); + $data['deposiamount'] = $this->clientPolicyModel->getDepositSummary($clientId, $insurerId); + + + // print_r($data['depositdata'] );die; + // Load the view for the new list page + echo view('layout/header', $headerData); + echo view('view_deposit',$data); + echo view('layout/footer'); + } + public function saveDeposit() + { + // Retrieve form data from POST request + $loggedInUserID = get_session_userid(); + + // Prepare the array with data + $data = [ + 'amount' => $this->request->getPost('amount'), + 'sub_type_id' => $this->request->getPost('sub_type_id'), + 'client_id' => $this->request->getPost('client_id'), + 'insurer_id' => $this->request->getPost('insurer_id'), + 'description' => $this->request->getPost('description'), + 'transaction_type' => $this->request->getPost('transaction_type') ?: 'Credit', + 'updated_by' => 1, // You need to set the correct value for updated_by + ]; + + // Call the saveDeposit function from DepositHelper + $response = DepositHelper::saveDeposit($data, $loggedInUserID); + + // Return a boolean value based on success + return $this->response->setJSON(['success' => $response['success']]); + } -public function saveDeposit() -{ - // Retrieve form data from POST request - $loggedInUserID = get_session_userid(); - - // Prepare the array with data - $data = [ - 'amount' => $this->request->getPost('amount'), - 'sub_type_id' => $this->request->getPost('sub_type_id'), - 'client_id' => $this->request->getPost('client_id'), - 'insurer_id' => $this->request->getPost('insurer_id'), - 'description' => $this->request->getPost('description'), - 'transaction_type' => $this->request->getPost('transaction_type') ?: 'Credit', - 'updated_by' => 1, // You need to set the correct value for updated_by - ]; - - // Call the saveDeposit function from DepositHelper - $response = DepositHelper::saveDeposit($data, $loggedInUserID); - - // Return a boolean value based on success - return $this->response->setJSON(['success' => $response['success']]); -} - - - - public function editClientOnboarding($id = null) { @@ -616,11 +624,10 @@ public function saveDeposit() $si = $this->request->getPost('si'); } $age_from = isset($this->request->getPost('age_from')[$i]) ? $this->request->getPost('age_from')[$i] : null; - $age_to = isset($this->request->getPost('age_to')[$i]) ? $this->request->getPost('age_to')[$i] : null; - $premium = isset($premiumData[$i]) ? $premiumData[$i] : null; - $grade = isset($this->request->getPost('grade')[$i]) ? $this->request->getPost('grade')[$i] : null; - $max_si = isset($this->request->getPost('max_si')[$i]) ? $this->request->getPost('max_si')[$i] : null; - $created_by = get_session_userid(); + $age_to = isset($this->request->getPost('age_to')[$i]) ? $this->request->getPost('age_to')[$i] : null; + $premium = isset($premiumData[$i]) ? $premiumData[$i] : null; + $grade = isset($this->request->getPost('grade')[$i]) ? $this->request->getPost('grade')[$i] : null; + $max_si = isset($this->request->getPost('max_si')[$i]) ? $this->request->getPost('max_si')[$i] : null; if ($si !== null) { $data['si'] = $si; @@ -663,9 +670,6 @@ public function saveDeposit() - - - public function getKycDocsById($id=null) { @@ -722,12 +726,12 @@ public function saveDeposit() 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(); @@ -738,7 +742,8 @@ public function saveDeposit() } - $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; if (preg_match($pattern, $subject)) { @@ -749,15 +754,16 @@ public function saveDeposit() $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(); } + // echo '
';
// print_r($results);
// print_r($data[0]->policy_type); die;
- return $this->respond(['status' => true,'code' => 200,'data' => $results, 'premiumData' => $premiumData, 'count' => $emp_count], 200);
+ return $this->respond(['status' => true,'code' => 200,'data' => $results, 'premiumData' => $premiumData, 'count' => $emp_count, 'policy_name' => $policy_name], 200);
}
@@ -765,20 +771,16 @@ public function saveDeposit()
{
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'] = "";
- }else{
$data['corporatebuffer'] = $this->request->getPost("corporatebuffer");
$data['family_floaters'] = $this->request->getPost("family_floaters") ?? [];
- }
$data['waiverofpreexistingdiseases'] =$this->request->getPost("waiverofpreexistingdiseases");
if ($data['waiverofpreexistingdiseases'] == 1) {
@@ -830,14 +832,12 @@ public function saveDeposit()
$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 {
@@ -862,14 +862,16 @@ public function saveDeposit()
public function getterms()
{
- $client_id = $this->request->getVar('client_id');
- $policy_id = $this->request->getVar('policy_id');
- $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{
@@ -877,9 +879,9 @@ public function saveDeposit()
}
if ($record) {
- return $this->respond(['Status' => true,'code' => 200,'data' => $record['policy_terms'], 'count' => $emp_count], 200);
+ return $this->respond(['Status' => true,'code' => 200,'data' => $record['policy_terms'], 'count' => $emp_count, 'policy_name' => $policy_name], 200);
} else {
- return $this->respond(['Status' => false,'code' => 200,'message' => 'Record not found.', 'count' => $emp_count], 200);
+ return $this->respond(['Status' => false,'code' => 200,'message' => 'Record not found.', 'count' => $emp_count, 'policy_name' => $policy_name], 200);
}
}
@@ -890,9 +892,8 @@ public function saveDeposit()
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");
@@ -942,38 +943,30 @@ public function saveDeposit()
$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());
}
@@ -994,4 +987,64 @@ public function saveDeposit()
}
+ 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);
+
+
+
+ }
+
}
\ No newline at end of file
diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php
index 38109249..0c338b67 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
{
@@ -197,9 +198,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/Controllers/RestAuthenticationController.php b/app/Controllers/RestAuthenticationController.php
new file mode 100644
index 00000000..e56cffb7
--- /dev/null
+++ b/app/Controllers/RestAuthenticationController.php
@@ -0,0 +1,120 @@
+myLogger = \Config\Services::mylogger();
+
+ $this->employeeModel = new EmployeeModel();
+
+ }
+
+ public function index()
+ {
+ $this->myLogger->logme('error','Rest Authentication function called');
+ $data =["id"=>"2", "role"=>"staff"];
+
+ print_r(JWTToken::encode($data));
+ }
+
+ public function logined()
+ {
+
+ $this->myLogger->logme('error','Rest Authentication function called');
+
+ echo "Rest Authentication Logined Success........";
+ }
+
+
+ public function verifyEmployeeWithMobileNumber()
+ {
+ try {
+ $mobile_number = $this->request->getJSON()->mobile_number;
+
+ $employeeData = $this->employeeModel->where('mobile', $mobile_number)->first();
+ if ($employeeData) {
+ $result = ['user_verification' => true];
+ return ['status' => 'success','code' => 200,'data' => $result];
+ } else {
+ $result = ['user_verification' => false];
+ return ['status' => 'failed','code' => 404,'data' => $result];
+ }
+ } catch (\Throwable $th) {
+ return ['status' => 'failed','code' => 505,'data' => $th];
+ }
+ }
+
+
+ public function getVerifiedUserData()
+ {
+ try {
+ $mobile_number = $this->request->getJSON()->mobile_number;
+
+ $employeeData = $this->employeeModel->where('mobile', $mobile_number)->first();
+ if ($employeeData) {
+ $result = JWTToken::encode($employeeData);
+ return ['status' => 'success','code' => 200,'data' => $result];
+ } else {
+ return ['status' => 'failed','code' => 404,'data' => "No data"];
+ }
+ } catch (\Throwable $th) {
+ return ['status' => 'failed','code' => 500,'data' => $th];
+ }
+ }
+
+
+
+ public function employeeLogout()
+ {
+
+ }
+
+ public function getUserIdFromToken()
+ {
+ $id = JWTToken::getUserIdFromToken();
+ // echo $id['id'];
+ echo "Id----> ";
+ print_r($id);
+ $role = JWTToken::getUserRoleFromToken();
+ echo " Role----> ";
+ echo $role;
+
+
+ $tokenArray = JWTToken::decodeToken();
+ echo " TokenArray----> ";
+ print_r($tokenArray);
+ }
+
+
+
+}
\ No newline at end of file
diff --git a/app/Filters/AuthJWT.php b/app/Filters/AuthJWT.php
new file mode 100644
index 00000000..a9b6911f
--- /dev/null
+++ b/app/Filters/AuthJWT.php
@@ -0,0 +1,55 @@
+getHeader('Authorization');
+
+ if ($jwt) {
+ if (JWTToken::validateJWT($jwt)) {
+ $data = JWTToken::validateJWT($jwt);
+ $data = json_decode($data);
+ if ($data->status) {
+ // $auth = $request->getHeader("Authorization");
+
+ return true;
+ }else{
+ header('Content-Type: application/json');
+ http_response_code(401);
+ $error = json_encode(["status" => 401, "message" => $data->message]);
+ echo $error;
+ exit;
+ }
+ }
+ } else {
+ header('Content-Type: application/json');
+ http_response_code(403);
+ $error = json_encode(["status" => 403, "message" => "Access Forbidden!"]);
+ echo $error;
+ exit();
+ }
+ }
+
+ public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
+ {
+ // Do something here after the response is sent
+ }
+
+
+
+}
diff --git a/app/Helpers/JWTToken.php b/app/Helpers/JWTToken.php
new file mode 100644
index 00000000..dcee4d0d
--- /dev/null
+++ b/app/Helpers/JWTToken.php
@@ -0,0 +1,128 @@
+ $iat,
+ "exp" => $exp,
+ ];
+ if ($data !== null) {
+ $request_data = array_merge($request_data, (array)$data);
+ }
+ try{
+ $token = JWT::encode($request_data ,$secret_Key,'HS512');
+
+ return $token;
+ // return ['status' => true,'token' => $token];
+ }
+ catch (Exception $e) {
+ return ['status' => false,'message' => $e->getMessage()];
+ }
+ }
+
+ public static function validateJWT($jwt)
+ {
+ $jwtParts = explode(' ', $jwt);
+
+ if (count($jwtParts) != 2 || $jwtParts[0] == 'Bearer') {
+ return false;
+ }
+
+ $token = $jwtParts[1];
+
+ try {
+ $decoded = JWT::decode($token, new Key("secret", 'HS512'));
+ return json_encode(['status' => true, 'message' => 'Token is valid', 'decoded' => (array) $decoded]);
+ } catch (ExpiredException $e) {
+ return json_encode(['status' => false, 'message' => 'Token has expired']);
+ } catch (BeforeValidException $e) {
+ return json_encode(['status' => false, 'message' => 'Token is not yet valid']);
+ } catch (SignatureInvalidException $e) {
+ return json_encode(['status' => false, 'message' => 'Token signature is invalid']);
+ } catch (\Exception $e) {
+ return json_encode(['status' => false, 'message' => 'An error occurred while decoding the token']);
+ }
+
+ }
+
+
+
+ public static function getIdFromToken($jwt)
+ {
+
+ $jwtParts = explode(' ', $jwt);
+
+ $token = $jwtParts[0];
+
+ try {
+ $decoded = JWT::decode($token, new Key("secret", 'HS512'));
+ return json_encode(['status' => true, 'message' => 'Token is valid', 'data' =>$decoded->data->id ]);
+ } catch (ExpiredException $e) {
+ return json_encode(['status' => false, 'message' => 'Token has expired']);
+ } catch (BeforeValidException $e) {
+ return json_encode(['status' => false, 'message' => 'Token is not yet valid']);
+ } catch (SignatureInvalidException $e) {
+ return json_encode(['status' => false, 'message' => 'Token signature is invalid']);
+ } catch (\Exception $e) {
+ return json_encode(['status' => false, 'message' => 'An error occurred while decoding the token']);
+ }
+
+
+ }
+
+ public static function getUserIdFromToken()
+ {
+ $request = \Config\Services::request();
+ $jwt = $request->getHeader('Authorization');
+ $jwtParts = explode(' ', $jwt);
+ $token = $jwtParts[1];
+
+ $decoded = JWT::decode($token, new Key("secret", 'HS512'));
+ return $decoded->id;
+ }
+
+ public static function getUserRoleFromToken()
+ {
+ $request = \Config\Services::request();
+ $jwt = $request->getHeader('Authorization');
+ $jwtParts = explode(' ', $jwt);
+ $token = $jwtParts[1];
+
+ $decoded = JWT::decode($token, new Key("secret", 'HS512'));
+ return $decoded->role;
+ }
+
+
+ public static function decodeToken()
+ {
+ $request = \Config\Services::request();
+ $jwt = $request->getHeader('Authorization');
+ $jwtParts = explode(' ', $jwt);
+ $token = $jwtParts[1];
+
+ $decoded = JWT::decode($token, new Key("secret", 'HS512'));
+ return $decoded;
+ }
+
+}
+
diff --git a/app/Models/PolicesModel.php b/app/Models/PolicesModel.php
index 779def89..8ed0fa8b 100644
--- a/app/Models/PolicesModel.php
+++ b/app/Models/PolicesModel.php
@@ -25,6 +25,7 @@ class PolicesModel extends Model
return $this->db->table('policies')
->select('policy_type.*')
+ ->select('policies.name as policy_name')
->join('policy_type', 'policy_type.id = policies.policy_type_id')
->where('policies.id', $policy_id)
->get()
diff --git a/app/Models/PolicyPremium2Model.php b/app/Models/PolicyPremium2Model.php
index f7b861be..0ed2777b 100644
--- a/app/Models/PolicyPremium2Model.php
+++ b/app/Models/PolicyPremium2Model.php
@@ -18,6 +18,7 @@ class PolicyPremium2Model extends Model
'age_to',
'si',
'premium',
+ 'max_si',
'grade',
"created_by",
"updated_by",
diff --git a/app/Views/client_list.php b/app/Views/client_list.php
index 09a34662..246a9126 100644
--- a/app/Views/client_list.php
+++ b/app/Views/client_list.php
@@ -38,11 +38,7 @@
diff --git a/app/Views/client_policy.php b/app/Views/client_policy.php
index 2dc48942..116a8467 100644
--- a/app/Views/client_policy.php
+++ b/app/Views/client_policy.php
@@ -91,7 +91,7 @@
-
+
@@ -126,6 +126,8 @@
$(document).ready(function () {
+ $('#policy_status_field').hide()
+
// Get today's date
var today = new Date();
@@ -198,9 +200,15 @@
${rearrangeDateFormat(item.policy_start_date)} - ${rearrangeDateFormat(item.policy_end_date)}
${checkDateStatus(item.policy_end_date, 1)}
-
-
-
+
`;
@@ -212,7 +220,6 @@
});
-
/******** for form submit using AJAX *******/
$("#policy_form").submit(function(event) {
@@ -279,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)}
-
-
-
+
`;
@@ -293,11 +306,21 @@
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);
}
});
});
-
/********* To get th POLICY base on Insurer *******/
$('#insurer').change(function() {
var id = $(this).val();
@@ -321,8 +344,7 @@
});
});
-
- // set the Policy_Type_id for Form Submit
+ /********* set the Policy_Type_id for Form Submit *******/
$('#policy').change(function(){
var dataId = $(this).children('option:selected').attr('data-id');
@@ -337,7 +359,6 @@
});
-
// get the client policy data for edit
$('body').on('click', '.btnPolicyEdit', function () {
@@ -354,7 +375,6 @@
success: function (res) {
console.log('clientPolicy : ', res);
-
$('#policy_form_action').val('= base_url("client/policy/edit"); ?>');
if (res.status === false) {
@@ -375,12 +395,17 @@
$('#start_date').val(rearrangeDateFormat(res.data.policy_start_date));
$('#end_date').val(rearrangeDateFormat(res.data.policy_end_date));
$('#policy_status').val(checkDateStatus(res.data.policy_end_date));
+ $('#policy_status_field').show();
- if(res.data.policy_type_id == 1){
- appendPolicyFormFields(1, res.data);
- }else if(res.data.policy_type_id >= 2) {
- appendPolicyFormFields(2, res.data);
- }
+ /** do not delete this comment condition
+
+ // if(res.data.policy_type_id == 1){
+ // appendPolicyFormFields(1, res.data);
+ // }else if(res.data.policy_type_id >= 2) {
+ // appendPolicyFormFields(2, res.data);
+ // }
+
+ do not delete this comment condition **/
var policeOptionHTML = '';
$.each(res.policy, function(index, item) {
@@ -396,6 +421,57 @@
});
});
+ $('body').on('click', '.btnOpenEnroll', function () {
+
+ 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();
+ }
+
+ $.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');
+ 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);
+ }
+ });
+
+ });
function appendPolicyFormFields(policy_type, data = false){
@@ -571,57 +647,70 @@
}
- // Function to convert numbers into Indian numbering system
- function convertToIndianNumberingSystem(number) {
- // Define Indian numbering system
- var suffixes = ["", "Thousand", "Lakh", "Crore"];
-
- // Split the number into groups of 3 digits each
- var numberChunks = [];
- while (number > 0) {
- numberChunks.push(number % 1000);
- number = Math.floor(number / 1000);
- }
+ const numberWords = {
+ 0: "Zero", 1: "One", 2: "Two", 3: "Three", 4: "Four", 5: "Five", 6: "Six", 7: "Seven", 8: "Eight", 9: "Nine",
+ 10: "Ten", 11: "Eleven", 12: "Twelve", 13: "Thirteen", 14: "Fourteen", 15: "Fifteen", 16: "Sixteen", 17: "Seventeen", 18: "Eighteen", 19: "Nineteen",
+ 20: "Twenty", 30: "Thirty", 40: "Forty", 50: "Fifty", 60: "Sixty", 70: "Seventy", 80: "Eighty", 90: "Ninety"
+ };
- // Convert each chunk into words
- var result = "";
- for (var i = 0; i < numberChunks.length; i++) {
- if (numberChunks[i] !== 0) {
- result = convertThreeDigitNumberToWords(numberChunks[i]) + " " + suffixes[i] + " " + result;
+ function convertNumberToWords(number) {
+ if (number === 0) {
+ return numberWords[number];
+ }
+
+ let word = '';
+
+ if (number >= 10000000) {
+ word += convertNumberToWords(Math.floor(number / 10000000)) + " Crore ";
+ number %= 10000000;
+ }
+
+ if (number >= 100000) {
+ word += convertNumberToWords(Math.floor(number / 100000)) + " Lakh ";
+ number %= 100000;
+ }
+
+ if (number >= 1000) {
+ word += convertNumberToWords(Math.floor(number / 1000)) + " Thousand ";
+ number %= 1000;
+ }
+
+ if (number >= 100) {
+ word += convertNumberToWords(Math.floor(number / 100)) + " Hundred ";
+ number %= 100;
+ }
+
+ if (number > 0) {
+ if (word !== '') {
+ word += "and ";
+ }
+ if (number <= 20) {
+ word += numberWords[number];
+ } else {
+ word += numberWords[Math.floor(number / 10) * 10] + " " + numberWords[number % 10];
}
}
-
- return result.trim();
+ return word.trim();
}
- // Function to convert a three-digit number into words
- function convertThreeDigitNumberToWords(num) {
- var ones = ["", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine"];
- var tens = ["", "Ten", "Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety"];
- var teens = ["", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen"];
-
- var words = "";
-
- // Convert hundreds place
- if (Math.floor(num / 100) > 0) {
- words += ones[Math.floor(num / 100)] + " Hundred ";
- num %= 100;
- }
-
- // Convert tens and ones place
- if (num >= 20) {
- words += tens[Math.floor(num / 10)] + " ";
- num %= 10;
- } else if (num >= 11 && num <= 19) {
- words += teens[num - 10] + " ";
- num = 0;
- }
-
- if (num > 0) {
- words += ones[num] + " ";
- }
-
- return words.trim();
+ function convertCommaNumberToWords(input) {
+ const number = parseInt(input.replace(/,/g, ''), 10);
+ return convertNumberToWords(number);
}
+ function onlyNumbers(event){
+ var charcode;
+ charcode = event.which || event.keyCode;
+ if(charcode>= 48 && charcode <= 57)return true;
+ return false;
+ }
+
+
+ function formatNumber(input) {
+ var value = input.value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
+ input.value = value;
+ }
+
+
+
\ No newline at end of file
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 4ac8c736..3294e809 100644
--- a/app/Views/policy_gmc_terms.php
+++ b/app/Views/policy_gmc_terms.php
@@ -13,7 +13,7 @@
.radiobuttondiv{
margin-left: 32px;
}
- .form-control-client-policy-master{
+ .{
width:62% !important;
margin-left: 30px;
margin-top: 3px
@@ -49,10 +49,10 @@
display:none;
}
.jodit-container{
- width: 821px !important;
- margin-top: 3px;
- margin-bottom: 3px;
- margin-left: 30px;
+ /* width: 821px !important; */
+ /* margin-top: 3px; */
+ /* margin-bottom: 3px; */
+ /* margin-left: 30px; */
/* height: 0px !important; */
/* min-height: 100px !important; */
}
@@ -65,7 +65,7 @@
.jodit-wysiwyg{
margin-bottom: 162px;
}
- .form-control-client-policy-masters{
+ .s{
margin-left: 30px;
width: 689px;
}
@@ -75,124 +75,179 @@