FIX_MERGE_CONFLICIT : RV

This commit is contained in:
VENKATESHWARAN 2024-09-19 15:59:18 +05:30
commit 187f947f4d
2635 changed files with 1483 additions and 170 deletions

0
.cpanel.yml Normal file → Executable file
View File

0
.env.sample Normal file → Executable file
View File

0
.gitignore vendored Normal file → Executable file
View File

0
.htaccess Normal file → Executable file
View File

0
LICENSE Normal file → Executable file
View File

0
Papirus-Team-Papirus-Apps-Fusion-icon.512.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 9.0 KiB

After

Width:  |  Height:  |  Size: 9.0 KiB

0
README.md Normal file → Executable file
View File

0
app/.htaccess Normal file → Executable file
View File

0
app/Common.php Normal file → Executable file
View File

0
app/Config/App.php Normal file → Executable file
View File

0
app/Config/Boot/development.php Normal file → Executable file
View File

0
app/Config/Boot/production.php Normal file → Executable file
View File

0
app/Config/Boot/test.php Normal file → Executable file
View File

0
app/Config/Boot/testing.php Normal file → Executable file
View File

0
app/Config/Boot/uat.php Normal file → Executable file
View File

0
app/Config/CURLRequest.php Normal file → Executable file
View File

0
app/Config/Cache.php Normal file → Executable file
View File

0
app/Config/Constants.php Normal file → Executable file
View File

0
app/Config/ContentSecurityPolicy.php Normal file → Executable file
View File

0
app/Config/Cookie.php Normal file → Executable file
View File

0
app/Config/Database.php Normal file → Executable file
View File

0
app/Config/Email.php Normal file → Executable file
View File

0
app/Config/Encryption.php Normal file → Executable file
View File

0
app/Config/Events.php Normal file → Executable file
View File

0
app/Config/Exceptions.php Normal file → Executable file
View File

0
app/Config/Feature.php Normal file → Executable file
View File

0
app/Config/Filters.php Normal file → Executable file
View File

0
app/Config/ForeignCharacters.php Normal file → Executable file
View File

0
app/Config/Format.php Normal file → Executable file
View File

0
app/Config/Generators.php Normal file → Executable file
View File

0
app/Config/Honeypot.php Normal file → Executable file
View File

0
app/Config/Images.php Normal file → Executable file
View File

0
app/Config/Kint.php Normal file → Executable file
View File

0
app/Config/Logger.php Normal file → Executable file
View File

0
app/Config/Migrations.php Normal file → Executable file
View File

0
app/Config/Mimes.php Normal file → Executable file
View File

0
app/Config/Modules.php Normal file → Executable file
View File

0
app/Config/Pager.php Normal file → Executable file
View File

0
app/Config/Paths.php Normal file → Executable file
View File

0
app/Config/Publisher.php Normal file → Executable file
View File

10
app/Config/Routes.php Normal file → Executable file
View File

@ -317,6 +317,13 @@ $routes->group("policy_tranction", ["filter" => "authMVC"], function ($routes) {
$routes->get("list", "PolicyTransactionController::reportBDS");
});
$routes->group("statement", ["filter" => "authMVC"], function ($routes) {
$routes->get("list", "PolicyTransactionController::statementList");
$routes->post("upload", "PolicyTransactionController::uploadInsurerStatement");
$routes->get("getPaymentDetails/(:any)", "PolicyTransactionController::getInvoicePaymentDetails/$1");
$routes->post("saveInvoicePaymentDetails", "PolicyTransactionController::saveInvoicePaymentDetails");
});
});
$routes->cli('cli/processjob', 'JobWorker::processJob');
@ -346,12 +353,11 @@ $routes->group("/api", ["filter" => "authJWT"], function ($routes) {
$routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) {
$routes->post("storeFireBase", "EmployeeRestController::storeFireBase");
$routes->post("saveMpin", "RestAuthenticationController::saveMpin");
$routes->post("updateMpin", "RestAuthenticationController::updateMpin");
$routes->get("getChatResponse", "ChatBotController::getChatResponse");
$routes->post("getChatResponse", "ChatBotController::getChatResponse");
$routes->get("getEmployeeProfile", "EmployeeRestController::getEmployeeProfile");
$routes->post("employeeUpload", "EmployeeRestController::employeeUpload");
$routes->get("relationshipList", "EmployeeRestController::relationshipList");

0
app/Config/Routing.php Normal file → Executable file
View File

0
app/Config/Security.php Normal file → Executable file
View File

0
app/Config/Services.php Normal file → Executable file
View File

0
app/Config/Session.php Normal file → Executable file
View File

0
app/Config/Toolbar.php Normal file → Executable file
View File

0
app/Config/UserAgents.php Normal file → Executable file
View File

0
app/Config/Validation.php Normal file → Executable file
View File

0
app/Config/View.php Normal file → Executable file
View File

0
app/Config/google-services.json Normal file → Executable file
View File

0
app/Controllers/AdminController.php Normal file → Executable file
View File

0
app/Controllers/AppContentManagementController.php Normal file → Executable file
View File

0
app/Controllers/BaseController.php Normal file → Executable file
View File

333
app/Controllers/ChatBotController.php Normal file → Executable file
View File

@ -74,39 +74,61 @@ class ChatBotController extends AdminController
public function getChatResponse()
{
// try {
$request_for = $this->request->getGet('request_for');
$option = $this->request->getGet('option');
$is_option = $this->request->getGet('is_option');
$emp_code = $this->request->getVar('emp_code');
$client_id = $this->request->getVar('client_id');
$client_branch_id = $this->request->getVar('client_branch_id');
$request_for = $this->request->getVar('request_for');
$option = $this->request->getVar('option');
$is_option = $this->request->getVar('is_option');
$responseData = $this->ChatBotModel->where('request', $request_for)
->where('is_active', 1 )
->first();
if ($responseData) {
if(isset($option) && $option != 0){
if(isset($option) && $option != 0)
{
$decodedData = json_decode($responseData['options'],true);
if (isset($decodedData[$option]) && $decodedData[$option] !== null) {
$requestFor = $decodedData[$option];
$responseData = $this->ChatBotModel->where('request', $requestFor)
->where('is_active', 1 )
->first();
if($responseData['request'] == 'Call' || $responseData['request'] == 'Mail'){
$AccountManagerDetails = $this->clientRMModel->select('client_rm.* , user_profiles.*')
->join('user_profiles', 'client_rm.user_id = user_profiles.id', 'left')
->where('client_rm.client_id', $client_id )
->where('client_rm.level', 3 )
->findAll();
if(isset($AccountManagerDetails) && $responseData['request'] == 'Call'){
$responseData['options'] = $AccountManagerDetails[0]['mobile'];
}else if(isset($AccountManagerDetails) && $responseData['request'] == 'Mail'){
$responseData['options'] = $AccountManagerDetails[0]['email'];
}
}
}else{
if( $request_for == 'Create claim'){
if( $request_for == 'Initiate claim'){
$result = [
'request_for' => $request_for,
'options' => json_decode($responseData['options'], true),
'text' => "Enter Message",
'is_option' => "0",
'policy_id' => $option,
'mobile_no' => $this->request->getGet('mobile_no')
'mobile_no' => $this->request->getVar('mobile_no'),
'navigation' => $responseData['navigation'],
'navigation_type' => $responseData['navigation_type']
];
return $this->respond(['status' => 'success','code' => 200,'data' => $result ],200);
@ -123,8 +145,8 @@ class ChatBotController extends AdminController
if(isset($is_option) && $is_option == 0){
$text = $this->request->getGet('text');
$value = $this->request->getGet('value');
$text = $this->request->getVar('text');
$value = $this->request->getVar('value');
$Data = $this->ChatBotModel->where('options', $text)->where('is_active', 1 )->first();
if($Data){
@ -132,7 +154,7 @@ class ChatBotController extends AdminController
{
$result = $this->getAllPolicyByMobileNumber($value,'text');
return $this->respond(['status' => 'success','code' => 200,'data' => $result ],200);
}else if($Data['options'] == 'Please Enter Your Mobile Number To Raise Ticket'){
}else if($Data['options'] == 'Please Enter Your Mobile Number To Raise Claim'){
$result = $this->getAllPolicyByMobileNumber($value,'options');
return $this->respond(['status' => 'success','code' => 200,'data' => $result ],200);
}
@ -151,8 +173,10 @@ class ChatBotController extends AdminController
$result = [
'request_for' => $request_for,
'options' => null,
'text' => $ticket['message'].', Your Ticket id is '.$ticket['ticket_id'],
'is_option' => "0"
'text' => $ticket['message'].', Your Claim id is '.$ticket['ticket_id'],
'is_option' => "0",
'navigation' => "0",
'navigation_type' => null
];
}else{
@ -160,7 +184,9 @@ class ChatBotController extends AdminController
'request_for' => $request_for,
'options' => null,
'text' => $ticket['message'],
'is_option' => "0"
'is_option' => "0",
'navigation' => "0",
'navigation_type' => null
];
}
@ -178,11 +204,15 @@ class ChatBotController extends AdminController
$result = [
'request_for' => $responseData['request'],
'options' => json_decode($responseData['options'], true),
'text' => $responseData['is_option'] != 1 ? $responseData['options'] : null,
'is_option' => $responseData['is_option']
'is_option' => $responseData['is_option'],
'navigation' => $responseData['navigation'],
'navigation_type' => $responseData['navigation_type']
];
return $this->respond(['status' => 'success','code' => 200,'data' => $result ],200);
@ -190,180 +220,181 @@ class ChatBotController extends AdminController
} else {
return $this->respond(['status' => 'failed','code' => 404,'data' => 'No Data'],404);
}
} else {
return $this->respond(['status' => 'failed','code' => 404,'data' => 'No Data'],404);
}
// } catch (\Throwable $th) {
// return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500);
// }
}
public function sendDefaultMessage()
{
$responseData = $this->ChatBotModel->where('id', 1)->where('is_active', 1 )->first();
return [
'request_for' => $responseData['request'],
'options' => json_decode($responseData['options'], true),
'text' => $responseData['is_option'] != 1 ? $responseData['options'] : null,
'is_option' => $responseData['is_option']
];
}
public function sendDefaultMessage()
{
$responseData = $this->ChatBotModel->where('id', 1)->where('is_active', 1 )->first();
return [
'request_for' => $responseData['request'],
'options' => json_decode($responseData['options'], true),
'text' => $responseData['is_option'] != 1 ? $responseData['options'] : null,
'is_option' => $responseData['is_option'],
'navigation' => $responseData['navigation'],
'navigation_type' => $responseData['navigation_type']
];
}
public function getAllPolicyByMobileNumber($mobileNo,$action)
{
$employee = $this->employeeModel->where('mobile', $mobileNo)->where('is_active', 1 )->first();
if($employee){
public function getAllPolicyByMobileNumber($mobileNo,$action)
{
$employee = $this->employeeModel->where('mobile', $mobileNo)->where('is_active', 1 )->first();
if($employee){
$employeeData = $this->employeeModel->where('emp_code', $employee['emp_code'])
->where('client_id',$employee['client_id'])
->where('client_branch_id',$employee['client_branch_id'])
->where('is_active', 1 )->findAll();
$whereArrayForId = [];
foreach ( $employeeData as $key => $value) { array_push($whereArrayForId, $value['id']); }
$employeeData = $this->employeeModel->where('emp_code', $employee['emp_code'])
->where('client_id',$employee['client_id'])
->where('client_branch_id',$employee['client_branch_id'])
->where('is_active', 1 )->findAll();
$whereArrayForId = [];
foreach ( $employeeData as $key => $value) { array_push($whereArrayForId, $value['id']); }
$ClientPolicyData = $this->clientPolicyModel->select('client_policy.* , policies.name as policy_name , policy_type.policy_type as policy_type')
->join('policies', 'client_policy.policy_id = policies.id', 'left')
->join('policy_type', 'client_policy.policy_type_id = policy_type.id', 'left')
->where('client_policy.client_id', $employee['client_id'] )
->where('client_policy.client_branch_id', $employee['client_branch_id'] )
->where('client_policy.is_active', 1 )
->where('client_policy.policy_status', 1)
->orderby('client_policy.id' , 'ASC')
->findAll();
$options = [];
$text = '';
if(count($ClientPolicyData) > 0 && count($employeeData) > 0)
{
foreach ($ClientPolicyData as $key => $ClientPolicyValue) {
$ClientPolicyData = $this->clientPolicyModel->select('client_policy.* , policy_type.long_name as policy_name , policy_type.policy_type as policy_type')
->join('policy_type', 'client_policy.policy_type_id = policy_type.id', 'left')
->where('client_policy.client_id', $employee['client_id'] )
->where('client_policy.client_branch_id', $employee['client_branch_id'] )
->where('client_policy.is_active', 1 )
->where('client_policy.policy_status', 1)
->orderby('client_policy.id' , 'ASC')
->findAll();
$options = [];
$text = '';
if(count($ClientPolicyData) > 0 && count($employeeData) > 0)
{
foreach ($ClientPolicyData as $key => $ClientPolicyValue) {
$data['policy_name'] = $ClientPolicyValue['policy_name'];
$data['policy_type'] = $ClientPolicyValue['policy_type'];
$data['policy_no'] = $ClientPolicyValue['policy_no'];
$data['policy_name'] = $ClientPolicyValue['policy_name'];
$data['policy_type'] = $ClientPolicyValue['policy_type'];
$data['policy_no'] = $ClientPolicyValue['policy_no'];
$employee_policy = $this->employeePolicyModel->select('employees.*,employee_polices.employee_id , employee_polices.basic_cover_si , employee_polices.premium , employee_polices.gst , employee_polices.tpa_id , employee_polices.rand_string , employee_polices.uhid as uhid')
->join('employees', 'employee_polices.employee_id = employees.id', 'left')
->whereIn('employee_polices.employee_id',$whereArrayForId)
->where('employee_polices.client_policy_id',$ClientPolicyValue['id'])
->where('employee_polices.is_active', 1 )->findAll();
if(count($employee_policy) > 0)
{
$policy[$ClientPolicyValue['id']] = $ClientPolicyValue['policy_name']."(".$ClientPolicyValue['policy_type'].")";
array_push($options, $policy);
$text .= $ClientPolicyValue['policy_name']."(".$ClientPolicyValue['policy_type'].") % ";
$employee_policy = $this->employeePolicyModel->select('employees.*,employee_polices.employee_id , employee_polices.basic_cover_si , employee_polices.premium , employee_polices.gst , employee_polices.tpa_id , employee_polices.rand_string , employee_polices.uhid as uhid')
->join('employees', 'employee_polices.employee_id = employees.id', 'left')
->whereIn('employee_polices.employee_id',$whereArrayForId)
->where('employee_polices.client_policy_id',$ClientPolicyValue['id'])
->where('employee_polices.is_active', 1 )->findAll();
if(count($employee_policy) > 0)
{
$policy[$ClientPolicyValue['id']] = $ClientPolicyValue['policy_name']."(".$ClientPolicyValue['policy_type'].")";
array_push($options, $policy);
$text .= $ClientPolicyValue['policy_name']." % ";
}else{
$text .= "There is no any active policies ";
}
}
if($action == 'options'){
return [
'request_for' => $this->request->getVar('request_for'),
'options' => $options[count($options) - 1],
'text' => null,
'is_option' => "1",
'mobile_no' => $mobileNo,
];
}else{
$text .= "There is no any active policies ";
return [
'request_for' => $this->request->getVar('request_for'),
'options' => null,
'text' => $text,
'is_option' => "0",
'mobile_no' => $mobileNo,
];
}
}
if($action == 'options'){
return [
'request_for' => $this->request->getGet('request_for'),
'options' => $options[count($options) - 1],
'text' => null,
'is_option' => "1",
'mobile_no' => $mobileNo,
];
}else{
return [
'request_for' => $this->request->getGet('request_for'),
'request_for' => $this->request->getVar('request_for'),
'options' => null,
'text' => $text,
'is_option' => "0",
'mobile_no' => $mobileNo,
'text' => "Dear ".$employee['name']." Policy not yet bound for you.",
'is_option' => "0"
];
}
}else{
return [
'request_for' => $this->request->getGet('request_for'),
'request_for' => $this->request->getVar('request_for'),
'options' => null,
'text' => "Dear ".$employee['name'].", % Policy not yet bound for you.",
'text' => "Invalid Mobile Number",
'is_option' => "0"
];
}
}else{
return [
'request_for' => $this->request->getGet('request_for'),
'options' => null,
'text' => "Invalid Mobile Number",
'is_option' => "0"
];
}
public function claimTicket()
{
}
$employee = $this->employeeModel->where('mobile', $this->request->getVar('mobile_no'))->where('is_active', 1 )->first();
if($employee){
public function claimTicket()
{
$url = 'https://venbait.in/nhance/helpdesk/dev/api/tickets/create';
$employee = $this->employeeModel->where('mobile', $this->request->getGet('mobile_no'))->where('is_active', 1 )->first();
if($employee){
$token = 'uncp8FvG310bEyYdV9MmStlo7KDRZ65fLWTeXCI2JzwPrNHjBqQhUiAgxsaO';
$headers = [
'Token: ' . $token,
];
$url = 'https://venbait.in/nhance/helpdesk/dev/api/tickets/create';
// Form data
$data = [
'opener' => 'user',
'department_id' => 2,
'subject' => 'Claim Raised by Chat Bot',
'body' => $this->request->getVar('value'),
'policy_id' => $this->request->getVar('policy_id'),
'emp_code' => $employee['emp_code'],
'mobile_number' => $this->request->getVar('mobile_no'),
'email' => 'adhavanvalli@gmail.com',
'fullname' => $employee['name'],
];
// Initialize cURL session
$ch = curl_init();
// Set cURL options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
return $response;
// Check for errors
// if (curl_errno($ch)) {
// $error = curl_error($ch);
// curl_close($ch);
// return ['status' => 'failed', 'response' => $error];
// } else {
// // Close cURL session
// curl_close($ch);
// return ['status' => 'success', 'response' => $response];
// }
$token = 'uncp8FvG310bEyYdV9MmStlo7KDRZ65fLWTeXCI2JzwPrNHjBqQhUiAgxsaO';
$headers = [
'Token: ' . $token,
];
// Form data
$data = [
'opener' => 'user',
'department_id' => 2,
'subject' => 'Claim Raised by Chat Bot',
'body' => $this->request->getGet('value'),
'policy_id' => $this->request->getGet('policy_id'),
'emp_code' => $employee['emp_code'],
'mobile_number' => $this->request->getGet('mobile_no'),
'email' => 'adhavanvalli@gmail.com',
'fullname' => $employee['name'],
];
// Initialize cURL session
$ch = curl_init();
// Set cURL options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
return $response;
// Check for errors
// if (curl_errno($ch)) {
// $error = curl_error($ch);
// curl_close($ch);
// return ['status' => 'failed', 'response' => $error];
// } else {
// // Close cURL session
// curl_close($ch);
// return ['status' => 'success', 'response' => $response];
// }
}else{
return ['status' => 'failed', 'response' => 'Employee Not Found'];
}else{
return ['status' => 'failed', 'response' => 'Employee Not Found'];
}
}
}

0
app/Controllers/ClientController.php Normal file → Executable file
View File

0
app/Controllers/DashboardController.php Normal file → Executable file
View File

0
app/Controllers/EmpDataServiceController.php Normal file → Executable file
View File

0
app/Controllers/EmployeeController.php Normal file → Executable file
View File

36
app/Controllers/EmployeeRestController.php Normal file → Executable file
View File

@ -27,6 +27,7 @@ use App\Models\NotificationModel;
use App\Models\UserModel;
use App\Models\FEContentModel;
use App\Models\AddImgModel;
use App\Models\ClientBranchModel;
use App\Controllers\Jobs ;
@ -69,6 +70,8 @@ class EmployeeRestController extends AdminController
protected $userModel;
protected $feContentModel;
protected $addImgModel;
protected $clientBranchModel;
public function __construct()
{
@ -90,6 +93,7 @@ class EmployeeRestController extends AdminController
$this->userModel = new UserModel();
$this->feContentModel = new FEContentModel();
$this->addImgModel = new AddImgModel();
$this->clientBranchModel = new ClientBranchModel();
}
@ -208,7 +212,7 @@ class EmployeeRestController extends AdminController
public function addEmployeeAndDependence()
{
try {
// try {
$data = $this->request->getJSON();
@ -216,6 +220,7 @@ class EmployeeRestController extends AdminController
$Count = 0;
foreach ($data as $item) {
if (isset($item->id)) {
//update old data
$id = $item->id;
@ -233,6 +238,8 @@ class EmployeeRestController extends AdminController
$item->gender = $this->GenderMap($item->relationship , $item->emp_code);
$item->dob = $this->convertDateFormatYMD($item->dob);
$item->emp_status = 'draft';
$employee = $this->employeeModel->insert($item);
if ($employee) {
@ -266,7 +273,7 @@ class EmployeeRestController extends AdminController
$this->updatePremiumAmount($data[0]->client_policy_id , $data[0]->emp_code);
$this->updatePremiumAmount($data[0]->client_policy_id , $data[0]->emp_code , $data[0]->client_branch_id);
$result = [];
@ -276,9 +283,9 @@ class EmployeeRestController extends AdminController
return $this->respond(['status' => 'failed','code' => 404,'data' => $result], 404);
}
}
} catch (\Exception $e) {
return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500);
}
// } catch (\Exception $e) {
// return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500);
// }
}
@ -317,9 +324,9 @@ class EmployeeRestController extends AdminController
return true;
}
public function updatePremiumAmount($client_policy_id , $emp_code)
public function updatePremiumAmount($client_policy_id , $emp_code , $client_branch_id)
{
$response = $this->calculatePremium($client_policy_id , $emp_code);
$response = $this->calculatePremium($client_policy_id , $emp_code , null , $client_branch_id);
if(count($response[$emp_code]))
{
@ -1935,12 +1942,13 @@ class EmployeeRestController extends AdminController
//Post method - which receives client_policy id and empcode of the family.
//Pull records againest emp code and calculate premium
// retun array
public function calculatePremium($clientPolicyId = null , $empCode = null, $default_si = null)//family level
public function calculatePremium($clientPolicyId = null , $empCode = null, $default_si = null , $client_branch_id = null)//family level
{
helper('excel_util_helper');
$client_policy_id = $this->request->getVar('client_policy_id') ?? $clientPolicyId;
$emp_code = $this->request->getVar('emp_code') ?? $empCode;
$default_si = $this->request->getVar('si') ?? $default_si;// si amt which choosed in add on policy
// dd($client_policy_id);
@ -1969,13 +1977,17 @@ class EmployeeRestController extends AdminController
// dd($this->employeeModel->getLastQuery());
// print_r($existing_famility_details);die();
$employee_data_group_by_family = data_group_by_family($existing_famility_details,$data_source = 'db');
// print_r(($employee_data_group_by_family));die();
// print_r(($employee_data_group_by_family));//die();
$existing_units = $this->clientBranchModel->getExisitingUnits(client_id: $client_id,client_branch_id: $client_branch_id);
foreach ($employee_data_group_by_family as $emp_id => $family)
{
$transformed_famility_details = transform_db_data_to_excel($family);
// print_r($transformed_famility_details);die();
$data = calculate_premium($transformed_famility_details,$policy_terms,$slab_details,$file,$default_si);
// dd($data);
$data = calculate_premium_new(family_data: $transformed_famility_details,policy_terms:$policy_terms,slab_details:$slab_details,fileArr: $file,existing_units: $existing_units,default_si : $default_si);
$employee_data_group_by_family[$emp_id] = $data;
}

0
app/Controllers/EmployeeServiceController.php Normal file → Executable file
View File

0
app/Controllers/Home.php Normal file → Executable file
View File

0
app/Controllers/JobWorker.php Normal file → Executable file
View File

0
app/Controllers/Jobs.php Normal file → Executable file
View File

0
app/Controllers/Jobs/AddJob.php Normal file → Executable file
View File

0
app/Controllers/Jobs/SubJob.php Normal file → Executable file
View File

0
app/Controllers/LoginController.php Normal file → Executable file
View File

0
app/Controllers/MasterController.php Normal file → Executable file
View File

0
app/Controllers/NotificationController.php Normal file → Executable file
View File

0
app/Controllers/PendingActionsController.php Normal file → Executable file
View File

View File

@ -25,7 +25,9 @@ use App\Models\EmployeeModel;
use App\Models\UserTeamsModel;
use App\Models\UserModel;
use App\Models\EmployeePolicyModel;
use App\Models\InsurerStatements;
use App\Models\InvPaymentDetailsModel;
use Kint;
class PolicyTransactionController extends BaseController
{
@ -51,6 +53,9 @@ class PolicyTransactionController extends BaseController
protected $userTeamsModel;
protected $userModel;
protected $employeePolicyModel;
protected $insurerStatements;
protected $invoiceStatus;
protected $invPaymentDetailsModel;
public function __construct()
{
@ -76,6 +81,14 @@ class PolicyTransactionController extends BaseController
$this->userTeamsModel = new UserTeamsModel();
$this->userModel = new UserModel();
$this->employeePolicyModel = new EmployeePolicyModel();
$this->insurerStatements = new InsurerStatements();
$this->invPaymentDetailsModel = new InvPaymentDetailsModel();
$this->invoiceStatus = [
'pending' => 'Pending',
'generated' => 'Generated',
'sent' => 'Sent',
'payment_received' => 'Payment Received',
];
}
// Policy Transaction Inception
@ -1012,6 +1025,438 @@ class PolicyTransactionController extends BaseController
$this->loadLayout('report_bds_filter', $data);
}
//insurer statement list page
public function statementList()
{
// dd($this->updateInsurerStatement(['file_id' => 13]));
// $data['insurers'] = $this->insurerModel->where('is_active',1)->findAll();
$data['invoice_status_array'] = $this->invoiceStatus;
$data['insurers'] = $this->insurerBranchModel ->getInsurerBranchesWithInsurerNames();
// dd( $data['insurers']);
$data['insurer_statement_list'] = $this->insurerStatements
->select('insurer_statements.*,
insurers.name AS insurer_name,insurers.short_name,user_profiles.first_name,insurer_branch.branch_code
')
->join('insurers', 'insurer_statements.insurer_id = insurers.id')
->join('insurer_branch', 'insurer_statements.branch_id = insurer_branch.id')
->join('user_profiles', 'insurer_statements.created_by = user_profiles.id')
->orderBy('insurer_statements.id', 'desc')
->findAll();
// dd( $data['insurer_statement_list']);
$this->loadLayout('insurer_statement_list', $data);
}
public function uploadInsurerStatement()
{
//validate uploaded file
$filename = '';
$validated = $this->validate([
'statement' => [
'uploaded[statement]',
'mime_in[statement,application/vnd.ms-excel,application/vnd,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.oasis.opendocument.spreadsheet]',
'max_size[statement,16384]',
],
]);
$this->createStatementFolder();
if ($validated)
{
$avatar = $this->request->getFile('statement');
if (!$avatar) {
$this->myLogger->logme("error", 'Statement File not found');
return $this->respond(['dataStatus' => false, 'code' => 400, 'message' => 'File not found'], 400);
}
$is_moved = $avatar->move(WRITEPATH . 'uploads/statements/');
if ($is_moved) {
$filename = $avatar->getName();
// Handle successful upload, e.g., log success or further processing
$this->myLogger->logme("error", 'Statement File moved successful');
} else {
$this->myLogger->logme("error", 'Statement File move failed');
return $this->respond(['dataStatus' => false, 'code' => 500, 'message' => 'File move failed'], 500);
}
} else {
$this->myLogger->logme("error", 'Statement Upload failed Invalid file');
return $this->respond(['dataStatus' => false, 'code' => 404, 'message' => 'Invalid file'], 404);
}
//process post variable entry in file table
$loggedInUserID = get_session_userid();
// dd($loggedInUserID);
// $loggedInUserID = 8;
$insurer = $this->request->getPost('insurer');
$insurer_id = explode('-', $insurer)[0];
$branch_id = explode('-', $insurer)[1];
// print_r($insurer_id);
// print_r($branch_id);
// die();
$month = $this->request->getPost('statement_month');
$month = change_date_format($month,'Y-M-d','Y-m-d');
// print_r($month);die;
$file_id = $this->insurerStatements->insert(['insurer_id' => $insurer_id, 'branch_id' => $branch_id, 'file_name' => $filename,'month' => $month, 'created_by' => $loggedInUserID]); //here field policy_id have client_policy_id and not policy id from policy master
$this->myLogger->logme("error", '{file_id} statement uploaded success', ['file_id' => $file_id]);
//validate file
$validation_result = $this->validateInsurerStatement(['file_id' => $file_id]);
//update file content to DB
if($validation_result['status'] )
{
$this->updateInsurerStatement(['file_id' => $file_id]);
}
if (!isset($file_id) || !$validation_result['status']) {
return $this->respond(['dataStatus' => false, 'code' => 404, 'message' => 'file not uploaded', 'error_data' => $validation_result['error_data'],'error_code' => $validation_result['error_code']], 200);
}
return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => 'file upload success'], 200);
}
public function createStatementFolder()
{
$folderPath = WRITEPATH . 'uploads/statements/';
// Check if the folder doesn't exist
if (!file_exists($folderPath))
{
// Create the folder
if (mkdir($folderPath, 0777, true)) {
$this->myLogger->logme('error','statement upload folder created successfully');
// Set permissions to a+rwx (read, write, execute for all)
chmod($folderPath, 0777);
$this->myLogger->logme('error','Permissions set to a+rwx.');
} else {
// echo "Failed to create folder.";
$this->myLogger->logme('error','Failed to create statement upload folder.');
}
}
else
{
$this->myLogger->logme('error','upload folder exists.');
}
}
public function validateInsurerStatement($params)
{
//get file info
$file_id = $params['file_id'];
$file = $this->insurerStatements->find($file_id);
// dd($file);
$date = new \DateTime($file['month']);
$month = $date->format('m');
$year = $date->format('Y');
$error_data = ['error_code' => '','error_data' => []];
$status = 'success';
$ret_status = true;
// dd($month.'-'.$year);
$return = [];
if(!isset($file))
{
//file not found in DB
return array('status' => false, 'msg' => 'statement file not found in DB');
}
$file_name_with_path = WRITEPATH."/uploads/statements/".$file['file_name'];
//check physical file
if(!file_exists($file_name_with_path))
{
//file not found update status and reason
$message = "Physcial file not found";
// echo $message;
$this->myLogger->logme('error',($message . ' for statement file id ' . $file_id));
$this->insurerStatements->where('id', $file_id)->set(['file_status' => 'failed','reason' => json_encode(['error_code' => 0,'error_data' => $message])])->update();
return array('status' => false, 'error_code' => 0); //0 - Physcial file not found
}
//get excel data to php array
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($file_name_with_path);
$sheet = $spreadsheet->getActiveSheet();
$highestRowAndColumn = $sheet->getHighestRowAndColumn();
// dd($highestRowAndColumn);
$excel_data = $sheet->rangeToArray('A1:' . $highestRowAndColumn['column'] . $highestRowAndColumn['row']);
unset($excel_data[0]);
// dd($excel_data);
//get no of line items and update in DB
$line_items = count($excel_data);
// get uploaded month transactions data
$source_data = $this->PTCOShareDetailsModel->getNonReconcileredPolicyTransactions(month:$month,year:$year,insurer_id:$file['insurer_id'],insurer_branch_id:$file['branch_id']);
// Kint::dump($source_data);
// Kint::dump($excel_data);
// check policy no,insurer and etc in DB for this month
// if all good return true, otherwise return false with messssage
foreach ($excel_data as $excel_key => $excel_row)
{
$is_source_found = 0;
$excel_row[4] = trim($excel_row[4]);
$excel_row[5] = trim($excel_row[5]);
// Kint::dump(change_date_format($excel_row[4],'d-m-Y','Y-m-d'));
// echo $excel_row[1].'#'.$excel_row[2] .'#'.$excel_row[3].'#'.change_date_format($excel_row[4],'d-m-Y','Y-m-d').'#'.change_date_format($excel_row[5],'d-m-Y','Y-m-d').'<br>';
foreach ($source_data as $source_key => $source_row)
{
// Kint::dump(change_date_format($excel_row[3],'d-m-Y','Y-m-d'));
if( (trim($excel_row[1]) == $source_row['policy_no']) && trim($excel_row[2]) == $source_row['endorsement_no'] && trim($excel_row[3]) == $source_row['client_name'] && change_date_format($excel_row[4],'d-m-Y','Y-m-d') == $source_row['policy_start_date'] && change_date_format($excel_row[5],'d-m-Y','Y-m-d') == $source_row['policy_end_date'])
{
$is_source_found = 1;
unset($source_data[$source_key]);
continue 2;
}
}
if($is_source_found == 0)
{
// echo $excel_key.'-'.$excel_row[1] . '- not found<br>';
$error_data['error_code'] = 1;//match not found
// $error_data['error_data'] = ($error_data['error_data'] ?? []);
$error_data['error_data'] = array_merge($error_data['error_data'],[$excel_row[0]]);//match not found
}
}
if($error_data['error_code'])
{
$status = 'failed';
$ret_status = false;
}
//update in DB
$this->insurerStatements->where('id', $file_id)->set(['line_items' => $line_items,'file_status' => $status,'reason' => json_encode($error_data)])->update();
return array('status' => $ret_status, 'error_code' => $error_data['error_code'],'error_data' => $error_data['error_data']);
}
public function updateInsurerStatement($params)
{
//get file info
$file_id = $params['file_id'];
$file = $this->insurerStatements->find($file_id);
// dd($file);
$date = new \DateTime($file['month']);
$month = $date->format('m');
$year = $date->format('Y');
$error_data = ['error_code' => '','error_data' => []];
$status = 'success';
$ret_status = true;
// dd($month.'-'.$year);
$return = [];
if(!isset($file))
{
//file not found in DB
return array('status' => false, 'msg' => 'statement file not found in DB');
}
$file_name_with_path = WRITEPATH."/uploads/statements/".$file['file_name'];
//check physical file
if(!file_exists($file_name_with_path))
{
//file not found update status and reason
$message = "Physcial file not found";
// echo $message;
$this->myLogger->logme('error',($message . ' for statement file id ' . $file_id));
$this->insurerStatements->where('id', $file_id)->set(['file_status' => 'failed','reason' => json_encode(['error_code' => 0,'error_data' => $message])])->update();
return array('status' => false, 'error_code' => 0); //0 - Physcial file not found
}
//get excel data to php array
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($file_name_with_path);
$sheet = $spreadsheet->getActiveSheet();
$highestRowAndColumn = $sheet->getHighestRowAndColumn();
// dd($highestRowAndColumn);
$excel_data = $sheet->rangeToArray('A1:' . $highestRowAndColumn['column'] . $highestRowAndColumn['row']);
unset($excel_data[0]);
// dd($excel_data);
//get no of line items and update in DB
$line_items = count($excel_data);
// get uploaded month transactions data
$source_data = $this->PTCOShareDetailsModel->getNonReconcileredPolicyTransactions(month:$month,year:$year,insurer_id:$file['insurer_id'],insurer_branch_id:$file['branch_id']);
// Kint::dump($source_data);die;
// Kint::dump($excel_data);
// check policy no,insurer and etc in DB for this month
// if all good return true, otherwise return false with messssage
$data_to_update = [];
foreach ($excel_data as $excel_key => $excel_row)
{
$is_source_found = 0;
$excel_row[4] = trim($excel_row[4]);
$excel_row[5] = trim($excel_row[5]);
foreach ($source_data as $source_key => $source_row)
{
// Kint::dump(change_date_format($excel_row[3],'d-m-Y','Y-m-d'));
if( (trim($excel_row[1]) == $source_row['policy_no']) && trim($excel_row[2]) == $source_row['endorsement_no'] && trim($excel_row[3]) == $source_row['client_name'] && change_date_format($excel_row[4],'d-m-Y','Y-m-d') == $source_row['policy_start_date'] && change_date_format($excel_row[5],'d-m-Y','Y-m-d') == $source_row['policy_end_date'])
{
$is_source_found = 1;
//calculate percentage first
$total_amt = 0;
$actual_bp_per = trim($excel_row[9]);
$actual_bp_brokerage = trim($excel_row[12]);
$actual_bp_amt = trim($excel_row[6]);
if(($actual_bp_brokerage && $actual_bp_brokerage != 0 && $actual_bp_brokerage != ""))
{
$total_amt += $actual_bp_brokerage;
//percentage reverse calculation
if($actual_bp_per == 0 || $actual_bp_per == "")
{
$actual_bp_per = round(($actual_bp_brokerage / $actual_bp_amt) * 100,2);
}
}
else
{
$actual_bp_brokerage = $actual_bp_amt * ($actual_bp_per / 100);
$total_amt += $actual_bp_brokerage;
}
$actual_tp_per = trim($excel_row[10]);
$actual_tp_brokerage = trim($excel_row[13]);
$actual_tp_amt = trim($excel_row[7]);
if($actual_tp_brokerage && $actual_tp_brokerage != 0 && $actual_tp_brokerage != "")
{
$total_amt += $actual_tp_brokerage;
//percentage reverse calculation
if($actual_tp_per == 0 || $actual_tp_per == "")
{
$actual_tp_per = ($actual_tp_brokerage / $actual_tp_amt) * 100;
}
}
else
{
$actual_tp_brokerage = $actual_tp_amt * ($actual_tp_per / 100);
$total_amt += $actual_tp_brokerage;
}
$actual_tep_per = trim($excel_row[11]);
$actual_tep_brokerage = trim($excel_row[14]);
$actual_tep_amt = trim($excel_row[8]);
if($actual_tep_brokerage && $actual_tep_brokerage != 0 && $actual_tep_brokerage != "")
{
$total_amt += $actual_tep_brokerage;
//percentage reverse calculation
if($actual_tep_per == 0 || $actual_tep_per == "")
{
$actual_tep_per = ($actual_tep_brokerage / $actual_tep_amt) * 100;
}
}
else
{
$actual_tep_brokerage = $actual_tep_amt * ($actual_tep_per / 100);
$total_amt += $actual_tep_brokerage;
}
//find variance
$variance_amt = $source_row['exp_amt'] - $total_amt;
$data_to_update[] = ['id' => $source_row['id'],'actual_bp_amt' => $actual_bp_amt,'actual_tp_amt' => $actual_tp_amt,'actual_tep_amt' => $actual_tep_amt,'actual_bp_per' => $actual_bp_per,'actual_tp_per' => $actual_tp_per,'actual_tep_per' => $actual_tep_per,'variance' => $variance_amt,'actual_tep_brokerage_amt' => $actual_tep_brokerage,'actual_tp_brokerage_amt' => $actual_tp_brokerage,'actual_bp_brokerage_amt' => $actual_bp_brokerage,'reward' => trim($excel_row[15]),'statement_id' => $file_id];
unset($source_data[$source_key]);
continue 2;
}
}
}
$this->PTCOShareDetailsModel->updateBatch($data_to_update, 'id');
// dd($data_to_update);
// if($error_data['error_code'])
// {
// $status = 'failed';
// $ret_status = false;
// }
//update in DB
//$this->insurerStatements->where('id', $file_id)->set(['file_status' => $status,'reason' => json_encode($error_data)])->update();
return array('status' => $ret_status, 'error_code' => $error_data['error_code'],'error_data' => $error_data['error_data']);
}
public function getInvoicePaymentDetails()
{
$statement_id = $this->request->getUri()->getSegment(4);
$inv_details = $this->insurerStatements->find($statement_id);
$inv_payment_details = $this->invPaymentDetailsModel
->where('statement_id',$statement_id)
->where('is_active',1)
->get()
->getResultArray();
// print_r($inv_details);
$data = [ 'invoice_status' => $inv_details['invoice_status'],
'invoice_no' => $inv_details['invoice_no'],
'invoice_date' => $inv_details['invoice_date'] ];
$data['payments'] = $inv_payment_details;
return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => $data], 200);
}
public function saveInvoicePaymentDetails()
{
$jsonData = $this->request->getJSON();
$jsonData = (array)$jsonData;
// echo 'Hi';
// print_r($jsonData);die();
$invoiceStatus = $jsonData['invoice_status'];
$hiddenStatementId = $jsonData['hidden_statement_id'];
$invoiceNo = $jsonData['invoice_no'];
$invoiceDate = $jsonData['invoice_date'];
//Update statement table
$parentData = [
'invoice_status' => $invoiceStatus,
'invoice_no' => $invoiceNo,
'invoice_date' => $invoiceDate,
'updated_by' => get_session_userid()
];
// $this->insurerStatements->update($hiddenStatementId, $parentData);
// Process child data
$invoiceAmounts = $jsonData['invoice_amount'];
$utrNos = $jsonData['utr_no'];
$paymentDates = $jsonData['payment_date'];
$pks = $jsonData['pk'];
foreach ($invoiceAmounts as $index => $invoiceAmount) {
$pk = $pks[$index]; // Get the pk for the current record
$utrNo = $utrNos[$index];
$paymentDate = $paymentDates[$index];
// Prepare data for insert/update
$childData = [
'inv_amt' => $invoiceAmount,
'utr_no' => $utrNo,
'received_date' => $paymentDate,
'statement_id' => $hiddenStatementId,
'id' => is_numeric($pk) ? (int)$pk : '',
];
if($pk){ $childData['updated_by'] = get_session_userid(); }
else { $childData['created_by'] = get_session_userid(); }
// print_r($childData);
// Insert or update
$this->invPaymentDetailsModel->save($childData);
print_r($this->invPaymentDetailsModel->errors());
}
return $this->respond(['dataStatus' => true, 'code' => 200], 200);
//return $this->response->setJSON(['dataStatus' => 'true']);
}
}

0
app/Controllers/PublicController.php Normal file → Executable file
View File

0
app/Controllers/RestAuthenticationController.php Normal file → Executable file
View File

0
app/Controllers/SwaggerController.php Normal file → Executable file
View File

0
app/Controllers/UserController.php Normal file → Executable file
View File

0
app/Database/Migrations/.gitkeep Normal file → Executable file
View File

0
app/Database/Seeds/.gitkeep Normal file → Executable file
View File

0
app/Filters/.gitkeep Normal file → Executable file
View File

0
app/Filters/AuthJWT.php Normal file → Executable file
View File

0
app/Filters/AuthMVC.php Normal file → Executable file
View File

0
app/Filters/CloseDbConnection.php Normal file → Executable file
View File

0
app/Filters/HttpRequestLog.php Normal file → Executable file
View File

0
app/Filters/RoleCheck.php Normal file → Executable file
View File

0
app/Helpers/.gitkeep Normal file → Executable file
View File

0
app/Helpers/DepositHelper.php Normal file → Executable file
View File

0
app/Helpers/HttpRequestHelper.php Normal file → Executable file
View File

0
app/Helpers/JWTToken.php Normal file → Executable file
View File

0
app/Helpers/MailHelper.php Normal file → Executable file
View File

0
app/Helpers/excel_import_export_helper.php Normal file → Executable file
View File

15
app/Helpers/excel_util_helper.php Normal file → Executable file
View File

@ -924,7 +924,19 @@ if (!function_exists('calculate_premium_new'))
$is_self_acting_self_set = true;
}
$family_data[$val]['temp'] = ['max_age' => max($applicable_members_from_familiy['max_age']),'max_count' => $applicable_members_from_familiy['max_count'],'grid_name' => $key,'grid_master' => $slab['grid_master'],'acting_self' => $acting_self,'premium_type' => $slab['slab_rates'][0]['premium_type']];
//$family_data[$val]['temp'] = ['max_age' => max($applicable_members_from_familiy['max_age']),'max_count' => $applicable_members_from_familiy['max_count'],'grid_name' => $key,'grid_master' => $slab['grid_master'],'acting_self' => $acting_self,'premium_type' => $slab['slab_rates'][0]['premium_type']];
$family_data[$val]['temp'] = array_merge(
$family_data[$val]['temp'] ?? [], // existing 'temp' data or an empty array if it doesn't exist
[
'max_age' => max($applicable_members_from_familiy['max_age']),
'max_count' => $applicable_members_from_familiy['max_count'],
'grid_name' => $key,
'grid_master' => $slab['grid_master'],
'acting_self' => $acting_self,
'premium_type' => $slab['slab_rates'][0]['premium_type']
]
);
}
}
else
@ -999,7 +1011,6 @@ if (!function_exists('transform_excel_data_to_db'))
{
function transform_excel_data_to_db($memArr,$actionArr)
{
$current_column_action = null;
if($actionArr['action'] == 'inception'){ $current_column_action = 'I'; }
else if($actionArr['action'] == 'addition'){ $current_column_action = 'A'; }

0
app/Helpers/fileupload_helper.php Normal file → Executable file
View File

0
app/Helpers/header.php Normal file → Executable file
View File

0
app/Helpers/oauth_helper.php Normal file → Executable file
View File

0
app/Helpers/sendMailNotification.php Normal file → Executable file
View File

0
app/Helpers/session_helper.php Normal file → Executable file
View File

4
app/Helpers/utility_helper.php Normal file → Executable file
View File

@ -24,6 +24,7 @@ if (!function_exists('change_date_format')) {
function change_date_format($data, $source_format, $output_format)
{
$data = trim($data);
// echo $data, $source_format, $output_format;return true;
try {
// Create DateTime object with the source format
@ -31,7 +32,8 @@ if (!function_exists('change_date_format')) {
// Check if the DateTime object is created successfully
if ($dateTime === false) {
throw new Exception('Invalid date or format');
$errors = DateTime::getLastErrors();
throw new Exception('Invalid date or format' . implode(', ', $errors['errors']));
}
// Format the DateTime object with the output format
$formattedDate = $dateTime->format($output_format);

0
app/Helpers/uuid_helper.php Normal file → Executable file
View File

0
app/Language/.gitkeep Normal file → Executable file
View File

0
app/Language/en/Validation.php Normal file → Executable file
View File

0
app/Libraries/.gitkeep Normal file → Executable file
View File

0
app/Libraries/DataServiceSqlite.php Normal file → Executable file
View File

Some files were not shown because too many files have changed in this diff Show More