MERGE_TEST_BDS

This commit is contained in:
Venba 2024-10-08 05:20:07 +00:00
commit 4eafb545ca
2668 changed files with 18110 additions and 641 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

View File

@ -99,5 +99,5 @@ class Autoload extends AutoloadConfig
* @var string[]
* @phpstan-var list<string>
*/
public $helpers = ['uuid','session','utility', 'form', 'url', 'oauth', 'fileupload', 'excel_import_export', 'file'];
public $helpers = ['uuid','session','utility', 'form', 'url', 'oauth', 'fileupload', 'excel_import_export', 'file', 'drive'];
}

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

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

@ -92,3 +92,25 @@ define('EVENT_PRIORITY_NORMAL', 100);
* @deprecated Use \CodeIgniter\Events\Events::PRIORITY_HIGH instead.
*/
define('EVENT_PRIORITY_HIGH', 10);
/**
* @User Role Constant
*/
define('ENROLLMENT_TEAM_ID', '1');
define('CLAIMS_TEAM_ID', '2');
define('BUSINESS_TEAM_ID', '3');
define('FINANCE_TEAM_ID', '4');
define('SALES_TEAM_ID', '5');
/**
* @User Teams Constant
*/
define('ADMIN_ROLE_ID', 1);
define('MANAGER_ROLE_ID', 2);
define('ACCOUNT_MANAGER_ROLE_ID', 3);
define('STAFF_ROLE_ID', 4);
define('HEAD_ROLE_ID', 5);

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

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

@ -131,6 +131,13 @@ $routes->group("/client", ["filter" => "authMVC"], function ($routes) {
$routes->post("edit", "ClientController::editClientPolicyPremium");
$routes->post("other_terms", "ClientController::otherPolicyTermsFormSubmit");
});
$routes->group("vehicle", ["filter" => "authMVC"], function ($routes) {
$routes->post("create", "ClientController::uploadVehicleFile");
$routes->post("edit", "ClientController::editUploadVehicleFile");
$routes->get("list/(:any)", "ClientController::listVehicleFiles/$1");
$routes->get("delete/(:any)", "ClientController::deleteVehicleFiles/$1");
});
});
@ -234,6 +241,12 @@ $routes->group("/master", ["filter" => "authMVC"], function ($routes) {
$routes->get("list/(:any)", "MasterController::getCDMasterDataByID/$1");
$routes->get("remove/(:any)", "MasterController::removeCDMaster/$1");
});
$routes->group("vehicle", ["filter" => "authMVC"], function ($routes) {
$routes->get("list", "MasterController::VehicleMasterList");
$routes->get("list/(:any)", "MasterController::getVehicleMasterDataByID/$1");
$routes->get("remove/(:any)", "MasterController::deactiveVehicleData/$1");
});
});
@ -278,12 +291,78 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
$routes->get("copy_insurer_templete/(:any)", "MasterController::copyInsurerTemplete/$1");
$routes->get("get_single_excel_template/(:any)", "MasterController::getSingleExcelTemplate/$1");
$routes->get("dublicate_template/(:any)", "MasterController::duplicateTemplate/$1");
$routes->get("getBranchByClientID/(:any)", "ClientController::getBranchByClientID/$1");
$routes->get("getPolicyDetailsByPolicyId/(:any)", "ClientController::getPolicyDetailsByPolicyId/$1");
$routes->get("getClientAndBranchAndPolicy", "ClientController::getClientAndBranchAndPolicy");
$routes->get("getCDAccNoByClientAndInsurer/(:any)", "ClientController::getCDAccNoByClientAndInsurer/$1");
$routes->post("createClientWithMinimalData", "ClientController::createClientWithMinimalData");
$routes->post("createVehicleWithMinimalData", "ClientController::createVehicleWithMinimalData");
$routes->post("createClientBranchWithMinamalData", "ClientController::createClientBranchWithMinamalData");
$routes->post("createClientPolicyWithMinimalData", "ClientController::createClientPolicyWithMinimalData");
$routes->post("createCDAccountNumberUsingAjax", "MasterController::createCDAccountNumberUsingAjax");
$routes->post("drive_file_upload", "PolicyTransactionController::uploadFile");
$routes->post("updateInvoiceStatus", "PolicyTransactionController::updateInvoiceStatus");
$routes->get("remove_co_share_data/(:any)", "PolicyTransactionController::removeCoShareData/$1");
$routes->get("check_cost_center/(:any)", "ClientController::check_cost_center/$1");
$routes->get("getPTCOShareCount/(:any)", "PolicyTransactionController::getPTCOShareCount/$1");
$routes->get("test_mail", "MasterController::testGmailAPI");
$routes->post("test_mail", "MasterController::testGmailAPI");
$routes->get("check_policy_no/(:any)", "ClientController::check_policy_no/$1");
$routes->get("get_client_policy_data_using_policy_no/(:any)", "ClientController::get_client_policy_data_using_policy_no/$1");
$routes->get("get_client_policy_data_using_policy_no_and_endo_no/(:any)", "ClientController::get_client_policy_data_using_policy_no_and_endo_no/$1");
$routes->get("checkInvoiceStatus/(:any)", "PolicyTransactionController::checkInvoiceStatus/$1");
$routes->get("base_policy_for_policy_inception/(:any)", "PolicyTransactionController::getBasePolicy/$1");
});
$routes->group("policy_tranction", ["filter" => "authMVC"], function ($routes) {
$routes->group("inception", ["filter" => "authMVC"], function ($routes) {
$routes->get("list", "PolicyTransactionController::viewInception");
$routes->post("create", "PolicyTransactionController::createInceptionPolicy");
$routes->get("list/(:any)", "PolicyTransactionController::getInceptionDataForEdit/$1");
$routes->get("remove/(:any)", "PolicyTransactionController::removeCDMaster/$1");
});
$routes->group("endorsement", ["filter" => "authMVC"], function ($routes) {
$routes->get("list", "PolicyTransactionController::viewEndorsement");
$routes->post("create", "PolicyTransactionController::createEndorsementPolicy");
$routes->get("list/(:any)", "PolicyTransactionController::getEndorsementDataForEdit/$1");
$routes->get("remove/(:any)", "PolicyTransactionController::removeCDMaster/$1");
});
$routes->group("report", ["filter" => "authMVC"], function ($routes) {
$routes->get("list", "PolicyTransactionController::reportBDS");
$routes->get("report-varience-list", "PolicyTransactionController::reportVarience");
$routes->get("report-business-list", "PolicyTransactionController::reportBusinessList");
$routes->get("report-finance-list", "PolicyTransactionController::reportFinanceList");
});
$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->get("deletePaymentEntry/(:any)", "PolicyTransactionController::deletePaymentEntry/$1");
$routes->get("downloadSampleInsurerStatement", "PolicyTransactionController::downloadSampleInsurerStatement");
$routes->get("getFileErr/(:any)", "PolicyTransactionController::getFileErr/$1");
});
});
$routes->get("driveListFiles", "GoogleDriveController::listFiles");
$routes->post('dmsSearch', 'PolicyTransactionController::dmsSearch', ['filter' => 'authMVC']);
$routes->get('dmsSearch', 'PolicyTransactionController::dmsSearch', ['filter' => 'authMVC']);
$routes->get('downloadGdriveFile', 'GoogleDriveController::downloadGdriveFile', ['filter' => 'authMVC']);
$routes->cli('cli/processjob', 'JobWorker::processJob');
$routes->cli('cli/processjobs', 'JobWorker::processJobs');
$routes->cli('cli/enrollment_status', 'JobWorker::enrollment_status');
$routes->get("processjob", "JobWorker::processJob");
$routes->cli('cli/new_gmail_token', 'MasterController::generateNewGmailAPIToken');
$routes->cli('cli/send_mail_cli(/:any)?', 'MasterController::testGmailAPIViaCLI$1');
$routes->cli('cli/app_check_list', 'MasterController::appCheckList');
$routes->cli('cli/new_gdrive_token', 'GoogleDriveController::generateNewGoogleDriveAccessToken');
@ -304,16 +383,18 @@ $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");
$routes->get("getEmployeeAndDependence", "EmployeeRestController::getEmployeeAndDependence");
$routes->post("editEmployeeAndDependence", "EmployeeRestController::editEmployeeAndDependence");
$routes->post("addEmployeeAndDependence", "EmployeeRestController::addEmployeeAndDependence");

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

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

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

@ -5,6 +5,8 @@ namespace Config;
use CodeIgniter\Config\BaseService;
use App\Libraries\Slug;
use App\Libraries\MyLogger;
use App\Libraries\GmailAPI;
use App\Libraries\MyGoogleDrive;
use App\Libraries\DataServiceSqlite;
use App\Controllers\Home;
@ -60,5 +62,23 @@ class Services extends BaseService
return new DataServiceSqlite();
}
public static function gmailapi($getShared = true)
{
if ($getShared) {
return static::getSharedInstance('gmailapi');
}
return new GmailAPI();
}
public static function myGoogleDrive($getShared = true)
{
if ($getShared) {
return static::getSharedInstance('myGoogleDrive');
}
return new MyGoogleDrive();
}
}

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

361
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,19 +145,30 @@ 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){
if($Data['options'] == 'Please Enter Your Mobile Number To View Your Policies')
{
$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);
}
}else if( $Data['options'] == 'Enter Your Claim Number'){
$result = $this->getTicket($value,$emp_code,$client_id);
return $this->respond(['status' => 'success','code' => 200,'data' => $result ],200);
}
}else{
@ -151,8 +184,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,16 +195,19 @@ class ChatBotController extends AdminController
'request_for' => $request_for,
'options' => null,
'text' => $ticket['message'],
'is_option' => "0"
'is_option' => "0",
'navigation' => "0",
'navigation_type' => null
];
}
return $this->respond(['status' => 'success','code' => 200,'data' => $result ],200);
}else{
$result = $this->sendDefaultMessage();
return $this->respond(['status' => 'success','code' => 200,'data' => $result ],200);
$result = $this->sendDefaultMessage();
return $this->respond(['status' => 'success','code' => 200,'data' => $result ],200);
}
}
@ -178,11 +216,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 +232,215 @@ 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];
// }
}else{
return ['status' => 'failed', 'response' => 'Employee Not Found'];
}
}
public function getTicket($value, $emp_code, $client_id)
{
// Construct the URL with query parameters
$url = 'https://venbait.in/nhance/helpdesk/dev/api/tickets/show/' . $value;
$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);
// Execute cURL request
$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'];
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];
}
}
}

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

@ -2,6 +2,7 @@
namespace App\Controllers;
use App\Helpers\DepositHelper;
use App\Helpers\MailHelper;
use App\helpers\JWTToken;
use CodeIgniter\HTTP\IncomingRequest;
use CodeIgniter\HTTP\RequestInterface;
@ -33,10 +34,12 @@ use App\Models\EmployeePolicyModel;
use App\Models\NotificationModel;
use App\Models\CDMasterModel;
use App\Models\PolicyTypeModel;
use App\Models\PolicyTransactionModel;
use App\Models\PolicyTransactionStatusModel;
use App\Models\VehicleModel;
use App\Controllers\EmpDataServiceController;
use App\Controllers\GoogleDriveController;
class ClientController extends AdminController
@ -68,6 +71,10 @@ class ClientController extends AdminController
protected $notificationModel;
protected $CDMasterModel;
protected $policyTypeModel;
protected $policyTransactionModel;
protected $policyTransactionStatusModel;
protected $vehicleModel;
public function __construct()
@ -99,6 +106,10 @@ class ClientController extends AdminController
$this->notificationModel = new NotificationModel();
$this->CDMasterModel = new CDMasterModel();
$this->policyTypeModel = new PolicyTypeModel();
$this->policyTransactionModel = new PolicyTransactionModel();
$this->policyTransactionStatusModel = new PolicyTransactionStatusModel();
$this->vehicleModel = new VehicleModel();
@ -108,43 +119,9 @@ class ClientController extends AdminController
}
public function Testing() //this function for only tsesting some logics not use for business logic
{
$results = $this->clientPolicyModel
->select('id, policy_terms')
->where('policy_terms IS NOT NULL')
->where('policy_terms <>', '')
->whereNotIn('policy_type_id', [1, 6, 7])
->orderBy('id', 'desc')
->get()
->getResultArray();
foreach ($results as $key => $result) {
$client_policy_id = $result['id'];
$policy_terms = json_decode($result['policy_terms'], true); // true to get associative array
if (isset($policy_terms['family_floaters'])) {
$family_floaters = $policy_terms['family_floaters'];
$parents = $family_floaters['parents'] ?? 0;
$parents_in_law = $family_floaters['parents-in-law'] ?? 0;
if ($parents == 1 && $parents_in_law == 1) {
$policy_terms['family_floaters']['parents'] = 0;
$policy_terms['family_floaters']['parents-in-law'] = 0;
$policy_terms['family_floaters']['either-parents-pil'] = 2;
$results[$key]['policy_terms'] = json_encode($policy_terms);
// Update the policy_terms in the database
$this->clientPolicyModel
->where('id', $client_policy_id)
->set('policy_terms', $results[$key]['policy_terms'])
->update();
}
}
}
dd($results);
{
// $empDataServiceController = new EmpDataServiceController();
// $empDataServiceController->storeEndorsementNumber(23, '00000000000000000560');
}
public function index()
@ -289,6 +266,7 @@ class ClientController extends AdminController
$data['policyGridData'] = $this->policyGridModel->findAll();
$data['policy_types'] = $this->policyTypeModel->findAll();
$data['policy_type'] = ['1'=>'Base Policy', '2' => 'SI Topup', '3' => 'Dependent Addon'];
$data['client_type'] = ['1'=>'Group', '2' => 'Retail'];
// echo "<pre>";
// print_r($data); die;
@ -343,10 +321,10 @@ class ClientController extends AdminController
$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['insurerName']= $this->insurerModel->getInsurerName($insurerId, $clientId);
$data['depositdata']= $this->clientPolicyModel->getdepositData($clientId,$insurerId);
$data['clientData'] = $this->clientPolicyModel->getClientById($clientId);
$data['deposiamount'] = $this->clientPolicyModel->getDepositSummary($clientId, $insurerId);
@ -354,7 +332,7 @@ class ClientController extends AdminController
// dd($data['depositdata']);
// print_r($data['depositdata'] );die;
// Load the view for the new list page
// Load the view for the new list page;
echo view('layout/header', $headerData);
echo view('view_deposit',$data);
echo view('layout/footer');
@ -412,6 +390,7 @@ class ClientController extends AdminController
$editData['policyGridData'] = $this->policyGridModel->findAll();
$editData['policy_types'] = $this->policyTypeModel->findAll();
$editData['policy_type'] = ['1'=>'Base Policy', '2' => 'SI Topup', '3' => 'Dependent Addon'];
$editData['client_type'] = ['1'=>'Group', '2' => 'Retail'];
// dd($editData['policy_types']);
@ -451,6 +430,7 @@ class ClientController extends AdminController
$data = $this->request->getPost();
$data['created_by'] = get_session_userid();
$data['client_logo'] = $file_name;
$data['client_code'] = generate_client_code();
if (!isset($data['is_download_btn'])) {
@ -502,15 +482,23 @@ class ClientController extends AdminController
}
}
public function createClientKYCInfo()
{
$this->myLogger->logme('error','create Client kyc function called');
$data = $this->request->getPost();
// print_r($data); die;
unset($data['file_name']);
$uploadFilePath = WRITEPATH . 'uploads/client_kyc_documents';
$File = file_Upload($this->request->getFile('file_name'), $uploadFilePath);
if(!empty($File)){
$data['file_name'] = $File;
$uploadFilePath = $uploadFilePath . '/' .$File;
$GoogleDriveController = new GoogleDriveController();
$GoogleDriveController->uploadFiletoGdrive(client_id: $data['client_id'], doc_type: 'KYC', file_path: $uploadFilePath, file_name: $data['file_name']);
}
$data['created_by'] = get_session_userid();
@ -665,11 +653,21 @@ class ClientController extends AdminController
$this->myLogger->logme('error','Client branch CREATE function called');
$data = $this->request->getPost();
// var_dump($data); die;
if (!isset($data['sez'])) {
$data['sez'] = 0;
} elseif ($data['sez']) {
$data['sez'] = 1;
}
$units = json_decode($data['units'], true) ?? [];
if (!is_array($units) || empty($units)) {
$client_data = $this->clientModel->where('id', $data['client_id'])->first();
$default_unit = trim(($client_data['short_name'] ?? '') . '-' . ($data['branch_code'] ?? ''), '-');
$data['units'] = json_encode([$default_unit]);
}
$data['created_by'] = get_session_userid();
$insert = $this->clientBranchModel->insert($data);
@ -723,6 +721,12 @@ class ClientController extends AdminController
$list_of_branch_units = $this->clientBranchModel->find($id);
$units = json_decode($list_of_branch_units['units']);
if (!is_array($units) || empty($units)) {
$client_data = $this->clientModel->where('id', $data['client_id'])->first();
$default_unit = trim(($client_data['short_name'] ?? '') . '-' . ($data['branch_code'] ?? ''), '-');
$data['units'] = json_encode([$default_unit]);
}
if (!empty($units)) {
foreach ($units as $unit) {
@ -733,6 +737,7 @@ class ClientController extends AdminController
$total_count = $emp_unit_count + $rr_unit_count + $rr_unit_count2;
}
$uncommonValues = [];
if ($total_count > 0) {
@ -758,7 +763,6 @@ class ClientController extends AdminController
}
}
if (!isset($data['sez'])) {
$data['sez'] = 0;
} elseif ($data['sez']) {
@ -819,7 +823,6 @@ class ClientController extends AdminController
$policy_type_id = $this->request->getPost('policy_type_id');
$client_branch_id = $this->request->getPost('client_branch_id');
$client_id = $this->request->getPost('client_id');
$policy_type_id = $this->request->getPost('policy_type_id');
$base_policy = $this->request->getPost('base_policy');
@ -843,7 +846,6 @@ class ClientController extends AdminController
$data['client_id'] = $client_id;
$data['tpa_branch_id'] = $tpaBranchId;
$data['tpa_id'] = $tpaId;
// $data['policy_id'] = $this->request->getPost('policy_id');
$data['policy_type_id'] = $this->request->getPost('policy_type_id');
$data['no_of_lives'] = $this->request->getPost('no_of_lives');
@ -864,47 +866,24 @@ class ClientController extends AdminController
$data['cd_ac_no'] = $this->request->getPost('cd_ac_no');
$data['gst'] = $this->request->getPost('gst');
if($policy_type_id == 1 || $policy_type_id == 2 || $policy_type_id == 6 || $policy_type_id == 7){
$data['is_addon'] = 1;
$data['is_addon'] = 1; // Base Policy
}else if($policy_type_id == 4 || $policy_type_id == 5){
$data['is_addon'] = 2;
$data['is_addon'] = 2; // SI TOPUP
}else if($policy_type_id == 3){
if($base_policy){
$data['is_addon'] = 3;
$data['is_addon'] = 3; // Dependent Addon
}else{
$data['is_addon'] = 1;
}
}
$policy_terms = $this->clientPolicyModel->where('id', $this->request->getPost('base_policy'))->first();
// if ($this->request->getPost('is_addon') == 2 || $this->request->getPost('is_addon') == 3) {
// if ($this->request->getPost('is_addon') == 3) {
// $policyTerm = $policy_terms['policy_terms'];
// $decoded_policyTerm = json_decode($policyTerm, true);
// $decoded_policyTerm['family_floater'] = 0;
// $decoded_policyTerm['family_floaters']['self'] = 0;
// $decoded_policyTerm['family_floaters']['spouse'] = 0;
// $decoded_policyTerm['family_floaters']['childrens'] = 0;
// $decoded_policyTerm['family_floaters']['parents'] = 0;
// $decoded_policyTerm['family_floaters']['parents-in-law'] = 0;
// $decoded_policyTerm['family_floaters']['either-parents-pil'] = 0;
// $data['policy_terms'] = json_encode($decoded_policyTerm);
// } else {
// if ($this->request->getPost('policy_type_id') != 3) {
// $data['policy_terms'] = $policy_terms['policy_terms'];
// }
// }
// }
$data['policy_start_date'] = change_date_format($this->request->getPost('policy_start_date'), 'd-m-Y', 'Y-m-d');
$data['policy_end_date'] = change_date_format($this->request->getPost('policy_end_date'), 'd-m-Y', 'Y-m-d');
@ -922,8 +901,41 @@ class ClientController extends AdminController
$data['created_by'] = get_session_userid();
$policy_tranction_data = [
'issuer' => 2,
'client_id' => $this->request->getPost('client_id'),
'client_branch_id' => $this->request->getPost('client_branch_id'),
'insurer_id' => $insurerId,
'insurer_branch_id' => $insurerBranchId,
'issue_type' => 1,
'policy_no' => $this->request->getPost('policy_no'),
'cd_ac_no' => $this->request->getPost('cd_ac_no'),
'policy_issue_date' => date('Y-m-d'),
'policy_start_date' => change_date_format($this->request->getPost('policy_start_date'), 'd-m-Y', 'Y-m-d'),
'policy_end_date' => change_date_format($this->request->getPost('policy_end_date'), 'd-m-Y', 'Y-m-d'),
'action_type' => 'inception',
'status' => 'pending',
'created_by' => get_session_userid(),
];
$insert = $this->clientPolicyModel->insert($data);
if($insert){
$policy_tranction_data['client_policy_id'] = $insert;
$policy_tranction_data_insert = $this->policyTransactionModel->insert($data);
if($policy_tranction_data_insert){
$statusData = [
'policy_tran_id' => $policy_tranction_data_insert,
'status' => 'pending',
'created_by' => get_session_userid(),
];
$this->policyTransactionStatusModel->insert($statusData);
}
$clientPoliceData = $this->clientPolicyModel->getClientPolicyByClientId($this->request->getPost('client_id'));
$clientPoliceData['role'] = get_role_id();
return $this->respond(['status' => true,'code' => 200,'data' => $clientPoliceData, 'method' => 'CERATE', 'post_data' => $data], 200);
@ -941,6 +953,8 @@ class ClientController extends AdminController
$id = $this->request->getPost('PrimaryKey');
$client_id = $this->request->getPost('client_id');
$policy_type_id = $this->request->getPost('policy_type_id');
$base_policy = $this->request->getPost('base_policy');
$insurerValue = (string) $this->request->getPost('insurer');
list($insurerBranchId, $insurerId) = explode('-', $insurerValue);
@ -991,17 +1005,34 @@ class ClientController extends AdminController
$data['reminder_date'] = null;
}
if($policy_type_id == 1 || $policy_type_id == 2 || $policy_type_id == 3 || $policy_type_id == 6 || $policy_type_id == 7){
// if($policy_type_id == 1 || $policy_type_id == 2 || $policy_type_id == 3 || $policy_type_id == 6 || $policy_type_id == 7){
$data['is_addon'] = 1;
// $data['is_addon'] = 1;
}else if($policy_type_id == 4){
// }else if($policy_type_id == 4){
$data['is_addon'] = 2;
// $data['is_addon'] = 2;
}else if($policy_type_id == 5){
// }else if($policy_type_id == 5){
$data['is_addon'] = 3;
// $data['is_addon'] = 3;
// }
if($policy_type_id == 1 || $policy_type_id == 2 || $policy_type_id == 6 || $policy_type_id == 7){
$data['is_addon'] = 1; // Base Policy
}else if($policy_type_id == 4 || $policy_type_id == 5){
$data['is_addon'] = 2; // SI TOPUP
}else if($policy_type_id == 3){
if($base_policy){
$data['is_addon'] = 3; // Dependent Addon
}else{
$data['is_addon'] = 1;
}
}
@ -1531,6 +1562,78 @@ class ClientController extends AdminController
public function uploadVehicleFile()
{
$this->myLogger->logme('error','uploadVehicleFile function called');
$data = $this->request->getPost();
$files = $this->request->getFiles();
// $data['client_id'] = 12;
// $data['vehicle_id'] = 1;
// upload path
$uploadFilePath = WRITEPATH . 'uploads/client_kyc_documents';
$insertedDocs = [];
// Check document names and files
if (isset($data['other_docs_name']) && isset($files['file_name'])) {
foreach ($data['other_docs_name'] as $key => $docName) {
// Get the corresponding file for this document name
$file = $files['file_name'][$key];
if (!empty($docName) && $file->isValid() && !$file->hasMoved()) {
// Upload the file
$uploadedFileName = file_Upload($file, $uploadFilePath);
if ($uploadedFileName) {
// Prepare data for each document upload
$docData = [
'client_id' => $data['client_id'],
'vehicle_id' => $data['vehicle_id'],
'other_docs_name' => $docName,
'file_name' => $uploadedFileName,
'created_by' => get_session_userid(),
];
// Insert into database
$insert = $this->clientKYCDocsModel->insert($docData);
if ($insert) {
$insertedDocs[] = $docData; // Collect successfully inserted docs
}
}
}
}
if (!empty($insertedDocs)) {
// Fetch all documents for the client
$vehicleDocs = $this->clientKYCDocsModel
->where('client_id', $data['client_id'])
->where('vehicle_id',$data['vehicle_id'])
->findAll();
return $this->respond(['status' => true, 'code' => 200, 'vehicle_docs' => $vehicleDocs, 'inserted_docs' => $insertedDocs], 200);
} else {
return $this->respond(['status' => false, 'code' => 400, 'message' => 'No documents uploaded or inserted'], 200);
}
} else {
return $this->respond(['status' => false, 'code' => 400, 'message' => 'Invalid data submission'], 200);
}
}
public function editUploadVehicleFile()
{
}
public function listVehicleFiles()
{
}
public function deleteVehicleFiles(){
}
@ -2236,7 +2339,8 @@ class ClientController extends AdminController
}
public function fetchPolicyDataForPolicyType($client_policy_id){
public function fetchPolicyDataForPolicyType($client_policy_id)
{
$client_policy_id = $this->request->getGet('client_policy_id');
$policy_type = $this->request->getGet('policy_type');
@ -3011,4 +3115,325 @@ class ClientController extends AdminController
}
}
public function getBranchByClientID($client_id)
{
$branch_list = $this->clientBranchModel->where('client_id', $client_id)->where('is_active', 1)->findAll();
$policy_list = [];
foreach ($branch_list as $value)
{
$policy_data = $this->clientPolicyModel
->select('client_policy.*, policy_type.policy_type')
->join('policy_type', 'policy_type.id = client_policy.policy_type_id')
->where('client_policy.client_id', $value['client_id'])
->where('client_policy.client_branch_id', $value['id'])
->where('client_policy.is_active', 1)
->findAll();
$policy_list[$value['id']] = $policy_data;
}
if($branch_list){
return $this->respond(['status' => true, 'data' => $branch_list, 'policy_data' => $policy_list], 200);
}else{
return $this->respond(['status' => false], 200);
}
}
public function getClientAndBranchAndPolicy()
{
$clients = $this->clientModel->where('is_active', 1)->findAll();
$vehicles = $this->vehicleModel
->select('vehicle.*, clients.client_type')
->join('clients', 'clients.id=vehicle.owner')
->where('vehicle.is_active', 1)->findAll();
$clientIds = array_column($clients, 'id');
// Fetch branches in a single query
$branches = $this->clientBranchModel
->whereIn('client_id', $clientIds)
->where('is_active', 1)
->findAll();
// Fetch policies in a single query
$policies = $this->clientPolicyModel
->select("
client_policy.*,
policy_type.policy_type,
policy_type.ebp,
policy_type.etp,
policy_type.iep,
policy_type.itp,
policy_type.bap,
DATE_FORMAT(client_policy.policy_start_date, '%d/%m/%Y') as policy_start_date,
DATE_FORMAT(client_policy.policy_end_date, '%d/%m/%Y') as policy_end_date
")
->join('policy_type', 'policy_type.id = client_policy.policy_type_id')
->whereIn('client_policy.client_id', $clientIds)
->where('client_policy.is_active', 1)
->findAll();
$branchList = [];
$policyList = [];
$policyListByClient = [];
$unitList = [];
foreach ($branches as $branch) {
$branchList[$branch['client_id']][] = $branch;
$unitList[$branch['id']][] = json_decode($branch['units']);
}
foreach ($policies as $policy) {
$policyList[$policy['client_branch_id']][] = $policy;
$policyListByClient[$policy['client_id']][] = $policy;
if (isset($policyCount[$policy['client_id']])) {
$policyCount[$policy['client_id']]++;
} else {
$policyCount[$policy['client_id']] = 1;
}
}
foreach ($clients as &$client) {
$client['client_policy_count'] = $policyCount[$client['id']] ?? 0;
}
if (!empty($branchList)) {
return $this->respond([
'status' => true,
'client_data' => $clients,
'vehicle_data' => $vehicles,
'branch_data' => $branchList,
'policy_data' => $policyList,
'policyListByClient' => $policyListByClient,
'unit_data' => $unitList,
], 200);
} else {
return $this->respond(['status' => false], 200);
}
}
public function getCDAccNoByClientAndInsurer($client, $insurer)
{
$cdmData = $this->CDMasterModel->where('client_id', $client)->where('insurer_id', $insurer)->findAll();
if($cdmData){
return $this->respond(['status' => true, 'data' => $cdmData], 200);
}else{
return $this->respond(['status' => false], 200);
}
}
public function createClientWithMinimalData()
{
$postData = $this->request->getPost();
// print_r($postData); die;
$client_type = $postData['client_type'];
$client_data = [
'client_type' => $postData['client_type'],
'client_name' => $postData['client_name'],
'short_name' => $postData['short_name'],
'pan' => $postData['pan'],
'client_code' => generate_client_code(),
];
// Add additional fields if client type is 2
if($client_type == 2) {
$client_data = array_merge($client_data, [
'dob' => $postData['dob'],
'aadhar' => $postData['aadhar'],
'phone' => $postData['phone'],
'email' => $postData['email'],
'entity_type_id' => 7
]);
} else {
$client_data['entity_type_id'] = $postData['entity_type_id'];
}
// Insert client data
$client_insert = $this->clientModel->insert($client_data);
if(!$client_insert) {
return $this->respond(['status' => false, 'message' => 'Failed to create client'], 200);
}
// Additional logic for non-individual clients (client_type != 2)
if($client_type != 2) {
$unit = $postData['short_name'] . '-' . $postData['branch_code'];
$branch_data = [
'client_id' => $client_insert,
'branch_name' => $postData['branch_name'],
'branch_code' => $postData['branch_code'],
'gst' => $postData['gst'],
'units' => $unit,
];
$branch_insert = $this->clientBranchModel->insert($branch_data);
if ($branch_insert) {
$contact_data = [
'ref_id' => $branch_insert,
'contact_type' => 'client',
'name' => $postData['name'],
'mobile' => $postData['mobile'],
];
$this->levelContactModel->insert($contact_data);
}
}
return $this->respond([
'status' => true,
'data' => $postData,
'client_id' => $client_insert,
'branch_id' => $branch_insert ?? null,
'message' => 'Client created successfully'
], 200);
}
public function createVehicleWithMinimalData()
{
$data = $this->request->getPost();
$id = $this->request->getPost('vehicle_primary_key');
if($id){
$vehicle_update = $this->vehicleModel->where('id', $id)->set($data)->update();
if($vehicle_update){
return $this->respond(['status' => true, 'message' => 'Vehicle details updated successfully'], 200);
}else{
return $this->respond(['status' => false, 'message' => 'Failed to update vehicle details'], 200);
}
}else{
$vehicle_insert = $this->vehicleModel->insert($data);
if($vehicle_insert){
$vehicles = $this->vehicleModel->where('is_active', 1)->findAll();
return $this->respond([
'status' => true,
'vehicle_id' => $vehicle_insert,
'owner_id' => $data['owner'],
'owner_branch_id' => $data['branch_id'] ?? null,
'owner_type' => $data['Owner_type'],
'vehicles' => $vehicles,
'message' => 'Vehicle created successfully
'], 200);
}else{
return $this->respond(['status' => false, 'message' => 'Failed to created vehicle'], 200);
}
}
}
public function createClientPolicyWithMinimalData()
{
$data = $this->request->getPost();
$insurerValue = (string) $this->request->getPost('insurer');
list($insurerBranchId, $insurerId) = explode('-', $insurerValue);
$data['insurer_branch_id'] = $insurerBranchId;
$data['insurer_id'] = $insurerId;
$data['policy_status'] = 1;
$data['is_addon'] = 1;
$data['gst'] = 18;
$data['created_by'] = get_session_userid();
$data['policy_start_date'] = change_date_format($this->request->getPost('policy_start_date'), 'd-m-Y', 'Y-m-d');
$data['policy_end_date'] = change_date_format($this->request->getPost('policy_end_date'), 'd-m-Y', 'Y-m-d');
$insert = $this->clientPolicyModel->insert($data);
if($insert){
$policies = $this->clientPolicyModel
->select('client_policy.*, policy_type.policy_type')
->join('policy_type', 'policy_type.id = client_policy.policy_type_id')
->where('client_policy.client_id', $data['client_id'])
->where('client_policy.client_branch_id', $data['client_branch_id'])
->where('client_policy.is_active', 1)
->findAll();
return $this->respond(['status' => true, 'data' => $policies, 'client_policy_id' => $insert, 'message' => 'Client policy created successfully'], 200);
}else{
return $this->respond(['status' => false, 'message' => 'Failed to created client policy'], 200);
}
}
public function getPolicyDetailsByPolicyId($id)
{
$policies = $this->clientPolicyModel
->select('client_policy.*, policy_type.policy_type')
->join('policy_type', 'policy_type.id = client_policy.policy_type_id')
->where('client_policy.id', $id)
->where('client_policy.is_active', 1)
->findAll();
if($policies){
return $this->respond(['status' => true, 'data' => $policies, 'message' => 'Client policy created successfully'], 200);
}else{
return $this->respond(['status' => false, 'message' => 'Failed to created client policy'], 200);
}
}
public function check_cost_center($cost_center)
{
$uniqueAC = $this->clientModel
->where('cost_center', $cost_center)
->where('is_active', 1)
->findAll();
if($uniqueAC != null){
return $this->respond(['status' => true, 'message' => 'The Cost Center is Already Exist', 'code' => 200], 200);
}else{
return $this->respond(['status' => false, 'code' => 404], 200);
}
}
public function check_policy_no($policy_no)
{
$uniqueAC = $this->clientPolicyModel
->where('policy_no', $policy_no)
->where('is_active', 1)
->findAll();
if($uniqueAC != null){
return $this->respond(['status' => true, 'message' => 'The Policy Number is Already Exist', 'code' => 200], 200);
}else{
return $this->respond(['status' => false, 'code' => 404], 200);
}
}
public function get_client_policy_data_using_policy_no($policy_no)
{
$data = $this->clientPolicyModel
->select('client_policy.*, clients.client_type')
->join('clients', 'client_policy.client_id = clients.id')
->where('client_policy.policy_no', $policy_no)
->where('client_policy.is_active', 1)
->first();
if($data){
return $this->respond(['status' => true, 'data'=> $data, 'code' => 200], 200);
}else{
return $this->respond(['status' => false, 'message' => 'No Data Found', 'code' => 404], 200);
}
}
public function get_client_policy_data_using_policy_no_and_endo_no($policy_no, $endorsement_no)
{
$data = $this->clientPolicyModel
->select('client_policy.*, endorsement.endorsement_type')
->join('endorsement', 'client_policy.id = endorsement.client_policy_id')
->where('client_policy.policy_no', $policy_no)
->where('endorsement.endorsement_no', $endorsement_no)
->where('client_policy.is_active', 1)
->first();
if($data){
return $this->respond(['status' => true, 'data'=> $data, 'code' => 200], 200);
}else{
return $this->respond(['status' => false, 'message' => 'No Data Found', 'code' => 404], 200);
}
}
}

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

@ -13,6 +13,7 @@ use CodeIgniter\API\ResponseTrait;
use App\Models\MessageModel;
use App\Models\UserMessageModel;
use App\Models\ClientModel;
use App\Models\PolicyTransactionModel;
use App\Models\JobModel;
use App\Models\ClientPolicyModel;
@ -30,6 +31,7 @@ class DashboardController extends AdminController
protected $clientPolicyModel;
protected $notificationModel;
protected $employeePolicyModel;
protected $policyTransactionModel;
protected $myLogger;
@ -42,6 +44,7 @@ class DashboardController extends AdminController
$this->notificationModel = new NotificationModel();
$this->employeePolicyModel = new EmployeePolicyModel();
$this->clientModel = new ClientModel();
$this->policyTransactionModel = new PolicyTransactionModel();
$this->myLogger = \Config\Services::mylogger();
@ -65,8 +68,9 @@ class DashboardController extends AdminController
$pendingActionsController = new PendingActionsController;
$pendingActionsData = $pendingActionsController->getPendingActionsForDashBoard();
$businessTeamData = $this->policyTransactionModel->getBusinessReportList();
$financeTeamData = $this->policyTransactionModel->getFinanceReportList();
$groupedData = [];
foreach ($results as $row) {
@ -157,6 +161,8 @@ class DashboardController extends AdminController
$session->set('enrollment_data', json_encode($data));
// echo "<pre>";
$data['pendingActionsData'] = $pendingActionsData;
$data['businessTeamCount'] = count($businessTeamData) ?? 0;
$data['financeTeamCount'] = count($financeTeamData) ?? 0;
// print_r($data);die;

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

@ -27,6 +27,7 @@ use App\Models\UserMessageModel;
use App\Models\CDMasterModel;
use App\Models\InsurerExcelExportTemplateModel;
use App\Models\ClientBranchModel;
use App\Models\EndorsementModel;
use App\Controllers\Jobs;
use App\Controllers\JobWorker;
@ -58,6 +59,7 @@ class EmpDataServiceController extends BaseController
protected $CDMasterModel;
protected $excelExportTemplateModel;
protected $clientBranchModel;
protected $endorsementModel;
public function __construct()
@ -80,6 +82,7 @@ class EmpDataServiceController extends BaseController
$this->CDMasterModel = new CDMasterModel();
$this->excelExportTemplateModel = new InsurerExcelExportTemplateModel();
$this->clientBranchModel = new ClientBranchModel();
$this->endorsementModel = new EndorsementModel();
}
@ -1808,6 +1811,11 @@ class EmpDataServiceController extends BaseController
$file_data = $this->getDataByFileId($file_id, 'success');
$this->setPullNotification($file_data);
// if(excelFileGDriveUpload($file_id, 'batch_file')){
// $this->myLogger->logme('error', 'Inception Update Google Drive File Upload -- File Uploaded Successfully');
// }else{
// $this->myLogger->logme('error', 'Inception Update Google Drive File Upload -- File Uploaded Field');
// }
return 'Import Inception Updated ' . $status_val . '- Updated Count : ' . $emp_count;
}
@ -2145,6 +2153,7 @@ class EmpDataServiceController extends BaseController
$status = $file['status'];
$batch_code = $file['batch_code'];
$user_id = $file['created_by'];
$event_type = $file['event_type'];
$status_val = 'success';
@ -2206,6 +2215,8 @@ class EmpDataServiceController extends BaseController
$this->empEndorsementModel->updateBatch($endorsement_details, 'group_key');
$this->employeePolicyModel->bulkUpdateForCorrection($emp_details);
$this->storeEndorsementNumber($file_id, $endorsement_id[0]);
// Update batch file status and amount
$this->batchFileModel->update($file_id, [
@ -2801,6 +2812,8 @@ class EmpDataServiceController extends BaseController
// }
$this->employeePolicyModel->bulkUpdateForEndorsement($endorsement_details);
$this->storeEndorsementNumber($file_id, $endorsement_id);
// Update batch file status and amount
$this->batchFileModel->update($file_id, [
@ -3320,6 +3333,7 @@ class EmpDataServiceController extends BaseController
$this->employeeModel->updateBatch($employees_table_data, 'id');
$this->employeePolicyModel->updateBatch($employee_policy_table_data, 'id');
$this->employeePolicyModel->bulkUpdateForEndorsement($emp_endorsement_table_data);
$this->storeEndorsementNumber($file_id, $endorsement_id);
// Update batch file status and amount
$this->batchFileModel->update($file_id, [
@ -4367,34 +4381,58 @@ class EmpDataServiceController extends BaseController
$this->messageModel->insert($msg_data);
}
public function updatajson()
{
// $columns = [
// ["column_index" => 0, "column_name" => "SR NO", "db_column_name" => 'index'],
// ["column_index" => 1, "column_name" => "EmployeeId", "db_column_name" => "emp_code"],
// ["column_index" => 2, "column_name" => "UHID", "db_column_name" => "uhid"],
// ["column_index" => 3, "column_name" => "DOJ", "db_column_name" => "emp_doj"],
// ["column_index" => 4, "column_name" => "Name OF Insured", "db_column_name" => "emp_name"],
// ["column_index" => 5, "column_name" => "Age", "db_column_name" => "emp_age"],
// ["column_index" => 6, "column_name" => "Gender", "db_column_name" => "emp_gender"],
// ["column_index" => 7, "column_name" => "DOC", "db_column_name" => null],
// ["column_index" => 8, "column_name" => "TOTALSI", "db_column_name" => "basic_cover_si"],
// ["column_index" => 9, "column_name" => "DOS", "db_column_name" => "dateofexit"],
// ["column_index" => 10, "column_name" => "Mobile", "db_column_name" => 'emp_mobile'],
// ["column_index" => 11, "column_name" => "EmailID", "db_column_name" => 'emp_email_c'],
// ["column_index" => 12, "column_name" => "REMARKS", "db_column_name" => "remarks"],
// ["column_index" => 13, "column_name" => "FLAG STATUS", "db_column_name" => null],
// ["column_index" => 14, "column_name" => "EXCEPTIONS", "db_column_name" => null],
// ["column_index" => 15, "column_name" => "ABHA", "db_column_name" => null]
// ];
// $json = json_encode($columns);
// $this->excelExportTemplateModel->where('id', 37)->set('jsoncolumns', $json)->update();
public function storeEndorsementNumber($file_id, $endorsement_no)
{
// Log the function entry with input parameters
$this->myLogger->logme('error', "storeEndorsementNumber --- Starting function with file_id: $file_id and endorsement_no: $endorsement_no");
// Log before querying the database
$this->myLogger->logme('error', "storeEndorsementNumber --- Fetching file data for file_id: $file_id");
$filedata = $this->batchFileModel
->select('
batch_files.client_id,
batch_files.client_policy_id,
batch_files.event_type, .
batch_files.created_by,
client_policy.insurer_id,
client_policy.tpa_id
')
->join('client_policy', 'batch_files.client_policy_id = client_policy.id')
->where('batch_files.id', $file_id)
->first();
// dd($filedata);
// Log after fetching data
if ($filedata) {
$this->myLogger->logme('error', 'File data fetched successfully: ' . json_encode($filedata));
// Log before inserting data
$this->myLogger->logme('error', 'storeEndorsementNumber --- Inserting endorsement data into endorsementModel');
$this->endorsementModel->insert([
'client_id' => $filedata['client_id'],
'client_policy_id' => $filedata['client_policy_id'],
'insurer_id' => $filedata['insurer_id'],
'tpa_id' => $filedata['tpa_id'],
'endorsement_no' => $endorsement_no,
'endorsement_type' => $filedata['event_type'],
'created_by' => $filedata['created_by'],
]);
// Log after data insertion
$this->myLogger->logme('error', 'storeEndorsementNumber --- Endorsement data inserted successfully for file_id: ' . $file_id);
} else {
// Log if no file data is found
$this->myLogger->logme('error', "storeEndorsementNumber --- No file data found for file_id: $file_id");
}
// Log function exit
$this->myLogger->logme('error',"storeEndorsementNumber --- Function execution completed for file_id: $file_id");
}
}

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

@ -148,6 +148,10 @@ class EmployeeController extends AdminController
public function employeesUplodWithEvents()
{
// $empDataServiceController = new EmpDataServiceController();
// !dd($empDataServiceController->importInceptionUpdateTPAandUHID(['file_id' => 79]));
// $job_details = new Jobs();
// $r = Jobs::addJob(['job_name' => 'add','payload' => ['a' => 10, 'b' => 35]]);
// print_r($r);//die();
@ -375,7 +379,7 @@ class EmployeeController extends AdminController
} else if ($actionType == 'deletion') {
$filePath = ROOTPATH . 'public/sample_excel/sample_deletion.xls';
} else if ($actionType == 'enrollment') {
$filePath = ROOTPATH . 'public/sample_excel/enrollment.xls';
$filePath = ROOTPATH . 'public/sample_excel/enrollment.xlsx';
}else if ($actionType == 'missed_inception') {
$filePath = ROOTPATH . 'public/sample_excel/sample_inception.xls';
}
@ -1194,8 +1198,14 @@ class EmployeeController extends AdminController
// $file['action'] = 'si_enhancement';
// $result = [];
// !dd($file);
if ($file['action'] == 'inception' || $file['action'] == 'dependent_addition' || $file['action'] == 'addition') {
$result = $this->employeeModel->getEmpListByFileId(file_id: $file_id, emp_status: ['active'], policy_status: ['active']);
if ($file['action'] == 'inception' || $file['action'] == 'dependent_addition' || $file['action'] == 'addition' || $file['action'] == 'enrollment') {
if($file['action'] == 'enrollment'){
$result = $this->employeeModel->getEmpListByFileId(file_id: $file_id, emp_status: ['draft','enrolled'], policy_status: ['draft','enrolled']);
}else{
$result = $this->employeeModel->getEmpListByFileId(file_id: $file_id, emp_status: ['active'], policy_status: ['active']);
}
// ~dd($result);
if (count($result) && $role_id == null) {
if(get_role_id() == 1 || get_role_id() == 5){
@ -1210,6 +1220,7 @@ class EmployeeController extends AdminController
$query = "UPDATE employees JOIN employee_polices ON employees.id = employee_polices.employee_id and employees.file_id = $file_id SET employees.emp_status = 'truncated', employee_polices.status = 'truncated', employees.is_active = 0,employee_polices.is_active = 0 WHERE employees.file_id = $file_id";
$db->query($query);
$affectedRows = $db->affectedRows();
// print_r($db->getLastQuery()); die;
// $affectedRows = 10;
//update file status

114
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,30 +324,36 @@ 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]))
{
foreach ($response[$emp_code] as $key => $value)
{
$checkIfExist = $this->employeePolicyModel->where('employee_id', $value['temp']['emp_id'])
if(isset($value['temp']))
{
$checkIfExist = $this->employeePolicyModel->where('employee_id', $value['temp']['emp_id'])
->where('client_policy_id', $value['policy_details']['client_policy_id'])
->where('is_active', 1 )
->findAll();
if($checkIfExist)
{
$this->employeePolicyModel
->where('client_policy_id',$value['policy_details']['client_policy_id'] )
->where('employee_id' , $value['temp']['emp_id'] )
->where('is_active', 1 )
->set(array('premium'=> $value['policy_details']['premium'] , 'rata_premimum'=> $value['policy_details']['rata_premimum'] , 'gst'=> $value['policy_details']['gst'] ))
->update();
if($checkIfExist)
{
$this->employeePolicyModel
->where('client_policy_id',$value['policy_details']['client_policy_id'] )
->where('employee_id' , $value['temp']['emp_id'] )
->where('is_active', 1 )
->set(array('premium'=> $value['policy_details']['premium'] , 'rata_premimum'=> $value['policy_details']['rata_premimum'] , 'gst'=> $value['policy_details']['gst'] ))
->update();
}
}
}
}
}
@ -834,7 +847,7 @@ class EmployeeRestController extends AdminController
$emp_id =0;
$data_after_gpa_or_gmc =[];
if ($policy['policy_type_id'] == 1) {
if ($client_policy['policy_type_id'] == 1) {
if (strtolower($dataToInsert[$a]['relationship']) == 'self') {
$data_after_gpa_or_gmc = $dataToInsert[$a];
}
@ -1015,6 +1028,7 @@ class EmployeeRestController extends AdminController
$self['data']['basic_cover_si'] = $employee_policy->basic_cover_si;
$array->mapped_family_floaters = $self;
$array->type = 'GPA';
@ -1142,7 +1156,7 @@ class EmployeeRestController extends AdminController
}
$array->mapped_family_floaters = $data;
$array->type = "Group Medical Coverage";
$array->type = "GMC";
$checkGmcParentsPolicyExist = $this->clientPolicyModel->select('client_policy.id as ClientPolicyId , client_policy.client_id as ClientId, client_policy.policy_type_id as policy_type_id, policy_type.long_name as Policy_Name , client_policy.is_addon as is_addon , client_policy.open_for_enrollment as OpenForEnrollment , client_policy.inception_type as inception_type , client_policy.policy_terms as Policy_Terms')
->join('policy_type', 'client_policy.policy_type_id = policy_type.id', 'left')
@ -1331,7 +1345,7 @@ class EmployeeRestController extends AdminController
}
$array->mapped_family_floaters = $data;
$array->type = "Group Medical Coverage - Parents";
$array->type = "GMC - Parents";
return $array;
@ -1398,10 +1412,7 @@ class EmployeeRestController extends AdminController
}
}
public function getGTLIPolicy($empData,$emp_code,$client_id,$client_branch_id)
{
}
public function FloterConvertion($array){
@ -1442,7 +1453,7 @@ class EmployeeRestController extends AdminController
if ($value > 0) {
if($value == 1 && $key ==='either-parents-pil') {
$result .= ' + Either 2 Parents or 2 Parents in law';
}if($value == 2 && $key ==='either-parents-pil') {
}else if($value == 2 && $key ==='either-parents-pil') {
$result .= ' + Any 2 of Parents and Parents in law';
}else if($value != 0 && $key ==='spouse') {
$string = str_replace('-', ' ', $key);
@ -1781,7 +1792,7 @@ class EmployeeRestController extends AdminController
$responce['family_floaters_of_only_si_value'] = $only_si_value;
$responce['family_floaters_of_only_si_premium_value'] = $only_si_premium_value;
$responce['family_floaters_of_only_si_gst_value'] = $only_si_gst_value;
$responce['type'] = "Group Medical Coverage - Top Up";
if($this->request->getGet('policy') == 'GMC-SI-TOPUP'){
return $this->respond(['status' => 'success','code' => 200,'data' => ['gmc_si_topup'=>$responce]], 200);
@ -1830,7 +1841,7 @@ class EmployeeRestController extends AdminController
$responce['family_floaters_of_only_si_value'] = $only_si_value;
$responce['family_floaters_of_only_si_premium_value'] = $only_si_premium_value;
$responce['family_floaters_of_only_si_gst_value'] = $only_si_gst_value;
$responce['type'] = "Group Medical Coverage - Parents Top Up";
if($this->request->getGet('policy') == 'GMC-SI-PARENT-TOPUP'){
return $this->respond(['status' => 'success','code' => 200,'data' => ['gmc_si_parent_topup'=>$responce]], 200);
@ -1929,12 +1940,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
$client_branch_id = $this->request->getVar('client_branch_id') ?? $client_branch_id;
// dd($client_policy_id);
@ -1963,13 +1975,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;
}
@ -2199,14 +2215,16 @@ class EmployeeRestController extends AdminController
function getEmployeeActiveOrInactivePolicy()
{
if($this->request->getGet('type') == 'Active'){ $policy_status = 1; }else{ $policy_status = 0; }
$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')
if($this->request->getGet('type') == 'Active'){ $policy_status = 1; }else{ $policy_status = 0; }
$ClientPolicyData = $this->clientPolicyModel->select('client_policy.* , policy_type.policy_type as policy_type,insurers.name as insurer_name,tpa.name as tpa_name')
->join('insurers', 'client_policy.insurer_id = insurers.id', 'left')
->join('tpa', 'client_policy.tpa_id = tpa.id', 'left')
->join('policy_type', 'client_policy.policy_type_id = policy_type.id', 'left')
->where('client_policy.client_id', $this->request->getGet('client_id') )
->where('client_policy.client_branch_id', $this->request->getGet('client_branch_id') )
->where('client_policy.is_active', 1 )
->where('client_policy.policy_status', $policy_status)
->where('client_policy.enrolment_visibility', 1 )
->orderby('client_policy.id' , 'ASC')
->findAll();
@ -2232,15 +2250,22 @@ class EmployeeRestController extends AdminController
$terms = json_decode($ClientPolicyValue['policy_terms']);
if($ClientPolicyValue['policy_type_id'] == 1){ $data['policy_terms'] = $this->policyTermsFiter($terms,'gpa'); }
else{ $data['policy_terms'] = $this->policyTermsFiter($terms,'gmc'); }
if($ClientPolicyValue['policy_type_id'] == 1)
{
$data['policy_terms'] = $this->policyTermsFiter($terms,'gpa');
$data['department_id'] = 3;
}else{
$data['policy_terms'] = $this->policyTermsFiter($terms,'gmc');
$data['department_id'] = 4;
}
$data['client_id'] = $ClientPolicyValue['client_id'];
$data['client_policy_id'] = $ClientPolicyValue['id'];
$data['policy_name'] = $ClientPolicyValue['policy_name'];
$data['policy_type'] = $ClientPolicyValue['policy_type'];
$data['policy_name'] = $ClientPolicyValue['policy_type'];
$data['policy_type'] = $ClientPolicyValue['policy_type'];
$data['policy_no'] = $ClientPolicyValue['policy_no'];
$data['insurer_name'] = $ClientPolicyValue['insurer_name'];
$data['tpa_name'] = $ClientPolicyValue['tpa_name'];
$data['policy_start_date'] = $this->convertDateFormatDisplay($ClientPolicyValue['policy_start_date']);
$data['policy_end_date'] = $this->convertDateFormatDisplay($ClientPolicyValue['policy_end_date']);
// $data['policy_terms'] = $terms;
@ -2251,10 +2276,11 @@ class EmployeeRestController extends AdminController
if($ClientPolicyValue['policy_type_id'] == 4){ $data['heading'] = 'Group Medical Coverage - Top Up'; }else
if($ClientPolicyValue['policy_type_id'] == 5){ $data['heading'] = 'Group Medical Coverage - Parents (Top Up)'; }
if($ClientPolicyValue['policy_type_id'] == 1){ $data['floter_text_heading'] = 'Sum Insured'; }
else
if($ClientPolicyValue['policy_type_id'] == 1 || $ClientPolicyValue['policy_type_id'] == 6 || $ClientPolicyValue['policy_type_id'] == 7)
{
if($terms->family_floater == 1){ $data['floter_text_heading'] = 'Floter Sum Insured'; }else{ $data['floter_text_heading'] = 'Sum Insured'; }
$data['floter_text_heading'] = 'Sum Insured';
}else{
if($terms->family_floater == 1){ $data['floter_text_heading'] = 'Floter Sum Insured'; }else{ $data['floter_text_heading'] = 'Sum Insured'; }
}
$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')
@ -2482,7 +2508,7 @@ class EmployeeRestController extends AdminController
public function sendPushNotification()
{
$deviceToken = 'ffvc39yhRk-J-vGE9luw6l:APA91bFgNv7lzvA3lGuJ_pMDHdZ_rey6SMg11P2DvJk-WWiBs0nXWCF0lo5nEka3dn3DeTCS5yx0WrHs1yKj5faitBQYKeKxLg2VpUkDcmk3FrTDGkZdHcnW1Go0G0K8dYAkajRIjSEJ';
$deviceToken = 'cMVKESh8QzqIl8nh_yqbcl:APA91bHKm87Sh1goVJNKZtctV4etgLMQboI0eyDVn3MH1yf9cO-2RtQRlFnKLdataOxosoxm7a4JvATKjfI1_Bids46mGw5m8zesp90mR4odCbD_cJtGmBeMYt4hssSY0YtAht1emK_H';
$title = 'Nhance';
$body = 'All your policy enrolled successfully ..!';

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

@ -1965,6 +1965,7 @@ public function employeesEnrollmentInsert($params)
$value['family_floater_key'] = null;
$value['client_id'] = $file['client_id'];
$value['client_branch_id'] = $file['client_branch_id'];
$value['file_id'] = $file_id;
$value['temp']['emp_id'] = null; // dummy value for using exisitng funciton in model
if (strtolower(trim($value['relationship'])) === 'mother' || strtolower(trim($value['relationship'])) === 'Father') {
@ -2045,13 +2046,13 @@ public function employeesEnrollmentInsert($params)
//store email and mail content via helper to send notification
$emp_emails[] = sendMailNotification::sendMailNotification('member_welcome_mail', $params);
Kint::dump($emp_emails);
Kint::dump($key.'-'.count($excel_data));
// Kint::dump($emp_emails);
// Kint::dump($key.'-'.count($excel_data));
// if mail count is 20 send bulk mail and reset emp_emails variable
if (count($emp_emails) == 20 || $key == count($excel_data) ) {
$job_details = new Jobs();
$r = Jobs::addJob(['job_name' => 'bulk_mail','payload' => $emp_emails]);
echo 'Mail triggered';
// echo 'Mail triggered';
$emp_emails = [];
}
@ -2059,6 +2060,12 @@ public function employeesEnrollmentInsert($params)
}
} //end of for loop
$this->fileModel->where('id', $file_id)->set(['status' => 'success','reason' => ''])->update();
$this->myLogger->logme("error",'{file_id} uploaded success',['file_id' => $file_id]);
$this->setPullNotification($this->getFileMetaDataByFileId($file_id,'success'));
return true;
}

View File

@ -0,0 +1,355 @@
<?php
namespace App\Controllers;
use App\Models\ClientModel;
use App\Models\ClientPolicyModel;
use Google_Service_Drive_DriveFile;
use Kint;
class GoogleDriveController extends BaseController
{
protected $clientModel;
protected $clientPolicyModel;
protected $googleDrive;
protected $driveService;
protected $cache;
public function __construct()
{
$this->clientModel = new ClientModel();
$this->clientPolicyModel = new ClientPolicyModel();
$this->googleDrive = \Config\Services::myGoogleDrive();
$this->driveService = $this->googleDrive->getDriveService();
$this->cache = \Config\Services::cache(); // Load the cache service
}
public function listFiles()
{
// dd($this->getClientFolderIds(client_id : 18));
$file_path = WRITEPATH.'uploads/client_kyc_documents/nhance_bpf.pdf';
// dd($file_path);
// dd($this->uploadFiletoGdrive(client_id : 18,doc_type:'KYC',file_path:$file_path,file_name:"dummy.pdf"));
dd( $this->uploadFiletoGdrive(client_id: 12, doc_type: 'KYC', file_path: $file_path, file_name: "dummy.pdf"));
$session = \Config\Services::session();
$fileName = $request->getVar('filename');
$fileType = $request->getVar('filetype');
$userAccess = $session->get('userEmail');
$parentFolderID = '1M0GH3GbNUOYZLNeHXA5U7C_P2NSx7F7O';
$searchQuery = '';//"'your-folder-id' in parents"
try {
// $driveService = $this->googleDrive->getDriveService();
$searchQuery = "name contains 'test' and 'vitvelz@gmail.com' in readers";
// Query to list files
$response = $this->driveService->files->listFiles([
'q' => $searchQuery,
'supportsAllDrives' => true,
'includeItemsFromAllDrives' => true,
'fields' => 'nextPageToken, files(id, name, mimeType, size, createdTime, modifiedTime, owners, shared, permissions, webViewLink, thumbnailLink)',
'pageSize' => 20,
]);
$files = $response->getFiles();
if (empty($files)) {
echo "No files found.";
} else {
foreach ($files as $file) {
echo "File Name: " . $file->getName() . " | File ID: " . $file->getId() . "<br>";
}
}
} catch (\Exception $e) {
return $this->response->setStatusCode(500)->setBody($e->getMessage());
}
}
//by file id
public function downloadFile(string $fileId = '',string $fileName = '',string $mimeType = '',string $fileSize = '')
{
// dd($fileName);
try {
if($fileName == '' && $mimeType == '')
{
// Get file metadata
$file = $this->driveService->files->get($fileId, ['fields' => 'name, mimeType,size']);
$fileName = $file->getName();
$mimeType = $file->getMimeType();
$fileSize = $file->getSize();
}
// Download the file content from Google Drive
$response = $this->driveService->files->get($fileId, ['alt' => 'media']);
$fileContent = $response->getBody()->getContents();
// dd($fileContent);
$temp_file_name = WRITEPATH.'/tmp/'.date('YmdHis');
$this->cache->save('temp_gdrive_file', $temp_file_name, 300);
file_put_contents( $temp_file_name, $fileContent );
// Use CodeIgniter helper for downloading the file
return $this->response->download($temp_file_name, null)->setFileName($fileName);
} catch (\Exception $e) {
return $this->response->setStatusCode(500)->setBody($e->getMessage());
}
}
public function generateNewGoogleDriveAccessToken()
{
$this->driveService->generateNewToken();
}
public function getClientFolderIds(int $client_id = 0,int $client_policy_id = 0)
{
// Fetch client short name from the database
if($client_id)
{
//check folder ids in cahce,
$cacheKey = "client_gdrive_folderids_{$client_id}";
$folderIds = $this->cache->get($cacheKey);
// dd($folderIds);
if($folderIds !== NULL)//if available retrun from cache
{
return $folderIds;
}
//if not in cache then get it from grdrive
$client = $this->clientModel->find($client_id);
$clientShortName = $client['short_name']; // Assuming short_name is the column for client's short name
}
else if($client_policy_id)
{
$cacheKey = "client_policy_gdrive_folderids_{$client_policy_id}";
$folderIds = $this->cache->get($cacheKey);
// dd($folderIds);
if($folderIds !== NULL)//if available retrun from cache
{
return $folderIds;
}
$client = $this->clientPolicyModel->select('c.short_name,pt.policy_type,client_policy.policy_no')
->join('clients c','client_policy.client_id = c.id')
->join('policy_type pt','client_policy.policy_type_id = pt.id')
->where('client_policy.id',$client_policy_id)
->get()->getResultarray();
// dd($client);
$clientShortName = $client[0]['short_name'];
$policyFolderName = $client[0]['policy_type'].'-'.$client[0]['policy_no'];
}
else
{
return [];
}
// dd($policyFolderName);
// Define parent folder ID where client folders are stored
$parentFolderId = getenv('GDRIVE_ROOT_FOLDER_ID');; // Replace with your specific folder ID
// Check if the client folder exists in GDrive, if not create one
$clientFolderId = $this->checkOrCreateFolder($clientShortName, $parentFolderId);
// Check or create KYC_DOCS folder inside the client folder
$kycFolderId = $this->checkOrCreateFolder('KYC_DOCS', $clientFolderId);
// Check or create POLICY_DOCS folder inside the client folder
$policyFolderId = $this->checkOrCreateFolder('POLICY_DOCS', $clientFolderId);
if($client_policy_id && (isset($policyFolderName)))
{
$clientPolicyFolderId = $this->checkOrCreateFolder($policyFolderName, $policyFolderId);
$clientPolicyUploadFolderId = $this->checkOrCreateFolder('UPLOADS', $clientPolicyFolderId);
}
// Return folder IDs in the specified format
$folderIds = [
'client_folder_id' => $clientFolderId, // example HCL,TCS
'kyc_doc_folder_id' => $kycFolderId, // KYC_DOCS inside HCL,TCS
'policy_doc_folder_id' => $policyFolderId, //POLICY_DOCS inside HCL,TCS
'client_policy_doc_folder_id' => isset($clientPolicyFolderId) ? $clientPolicyFolderId : null, //GMC-POLICY_NO inside POLICY_DOCS folder
'client_policy_uoload_doc_folder_id' => isset($clientPolicyUploadFolderId) ? $clientPolicyUploadFolderId : null, //UPLOADS folder in side GMC-POLICY_NO folder
];
// Save the folder IDs in cache for future requests
$this->cache->save($cacheKey, $folderIds, 604800); // Cache for 7 Days (3600 seconds * 24 * 7 )
return $folderIds;
}
// Method to check if a folder exists or create one if it doesn't
public function checkOrCreateFolder($folderName, $parentFolderId)
{
// Step 1: Check if the folder exists
$folderId = $this->getFolderId($folderName, $parentFolderId);
if ($folderId === null) {
// Step 2: If folder does not exist, create it
$folderId = $this->createFolder($folderName, $parentFolderId);
}
// Step 3: Return the folder ID
return $folderId;
}
// Method to get the folder ID by searching in Google Drive
private function getFolderId($folderName, $parentFolderId)
{
$query = "name = '$folderName' and mimeType = 'application/vnd.google-apps.folder' and '$parentFolderId' in parents and trashed = false";
$response = $this->driveService->files->listFiles([
'q' => $query,
'spaces' => 'drive',
'fields' => 'files(id, name)',
'pageSize' => 1,
]);
if (count($response->files) > 0) {
return $response->files[0]->id; // Return folder ID if found
}
return null; // Return null if folder doesn't exist
}
// Method to create a folder in Google Drive
private function createFolder($folderName, $parentFolderId)
{
$fileMetadata = new \Google_Service_Drive_DriveFile([
'name' => $folderName,
'mimeType' => 'application/vnd.google-apps.folder',
'parents' => [$parentFolderId]
]);
$folder = $this->driveService->files->create($fileMetadata, [
'fields' => 'id',
]);
return $folder->id; // Return the newly created folder's ID
}
// public function uploadFiletoGdrive(int $client_id = 0,int $client_policy_id = 0,string $doc_type,string
// $file_path,string $file_name)
public function uploadFiletoGdrive(int $client_id = 0, int $client_policy_id = 0, string $doc_type = '', string $file_path = '', string $file_name = '')
{
$gdriveFolderIds = $this->getClientFolderIds(client_id: $client_id,client_policy_id: $client_policy_id);
// Kint::dump($gdriveFolderIds);//die();
$parentFolderId = '';
if($client_id && $doc_type == 'KYC')
{
$parentFolderId = $gdriveFolderIds['kyc_doc_folder_id'];
}
else if($client_policy_id && $doc_type == 'POLICY')
{
$parentFolderId = $gdriveFolderIds['client_policy_doc_folder_id'];
}
else if($client_policy_id && $doc_type == 'UPLOADS')
{
$parentFolderId = $gdriveFolderIds['client_policy_uoload_doc_folder_id'];
}
if($parentFolderId == '')
{
return null;
}
// dd($parentFolderId);
$file = new \Google_Service_Drive_DriveFile([
'name' => $file_name,
'parents' => [$parentFolderId] // Specify the folder ID here
]);
$file_blob_data = file_get_contents($file_path);
$createdFile = $this->driveService->files->create($file, [
'data' => $file_blob_data,
'mimeType' => 'application/octet-stream',
'uploadType' => 'multipart',
'fields' => 'id' // Specify fields to return
]);
if($createdFile->id)
{
unlink($file_path);
}
return $createdFile->id;
}
public function downloadGdriveFile()
{
$client_id = $this->request->getGet('client_id');
$client_policy_id = $this->request->getGet('client_policy_id');
$file_type = $this->request->getGet('file_type');
$file_name = $this->request->getGet('file_name');
if(!is_numeric($client_policy_id))
$client_policy_id = 0;
else
$client_id = 0;
$gdriveFolderIds = $this->getClientFolderIds(client_id: $client_id,client_policy_id: $client_policy_id);
// dd($gdriveFolderIds);
$parentFolderId = '';
if($file_type == 'kyc')
{
$parentFolderId = $gdriveFolderIds['kyc_doc_folder_id'];
}
else if($file_type == 'policy')
{
$parentFolderId = $gdriveFolderIds['client_policy_doc_folder_id'];
}
else if($file_type == 'uploads')
{
$parentFolderId = $gdriveFolderIds['client_policy_uoload_doc_folder_id'];
}
if($parentFolderId == '')
{
return $this->response->setStatusCode(500)
->setHeader('Content-Type', 'text/html')
->setBody('<script>alert("File not found");</script>');
}
return $this->searchGdriveFileByName(parentFolderID: $parentFolderId, fileName: $file_name);
}
//search files in gdrive by parent folder id and name of the file
public function searchGdriveFileByName(string $parentFolderID,string $fileName)
{
//check exisitng temp file from cache and delete it
if($this->cache->get('temp_gdrive_file') && is_file($this->cache->get('temp_gdrive_file')))
{
unlink($this->cache->get('temp_gdrive_file'));
}
try {
$searchQuery = "'$parentFolderID' in parents and (name contains '$fileName')";
// Query to list files
$response = $this->driveService->files->listFiles([
'q' => $searchQuery,
'supportsAllDrives' => true,
'includeItemsFromAllDrives' => true,
'fields' => 'nextPageToken, files(id, name, mimeType, size)',
'pageSize' => 1,
]);
$files = $response->getFiles();
if (empty($files)) {
return $this->response->setStatusCode(500)
->setHeader('Content-Type', 'text/html')
->setBody('<script>alert("File not found");window.close();</script>');
}
else
{
//echo "File Name: " . $files[0]->getName() . " | File ID: " . $file[0]->getId() . "<br>";
// echo($files[0]->getId());
// echo 'working';
return $this->downloadFile(fileId:$files[0]->getId(),fileName:$files[0]->getName(),mimeType:$files[0]->getMimeType(),fileSize:$files[0]->getSize());
}
} catch (\Exception $e) {
return $this->response->setStatusCode(500)->setBody($e->getMessage());
}
}
}

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

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

@ -41,13 +41,20 @@ class LoginController extends BaseController
$user = $UserModel->getUserByEmail($value->email);
if($user){
if($user->is_active !== '0'){
$user_team = $UserModel->getUserTeamsByUserID($user->id);
// dd($user_team);
$session_data = [
'isLoggedIn' => True ,
'userid' => $user->id,
'userData' => $user,
'userProfile' => $value->picture,
'user_team' => $user_team,
];
set_session_data($session_data);
log_message('error', 'Set The UserId : `'. $user->id .'` in Session');
log_message('error', 'User Login Sucessfully');

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

@ -10,6 +10,7 @@ use CodeIgniter\API\ResponseTrait;
use CodeIgniter\Files\File;
use App\Helpers\DepositHelper;
use App\Helpers\MailHelper;
use App\Models\UserModel;
use App\Models\ClientModel;
@ -30,6 +31,8 @@ use App\Models\PolicyTypeModel;
use App\Models\CDMasterModel;
use App\Models\ClientDepositModel;
use App\Models\InsurerExcelExportTemplateModel;
use App\Models\SettingsModel;
use App\Models\VehicleModel;
class MasterController extends AdminController
{
@ -40,7 +43,7 @@ class MasterController extends AdminController
protected $userModel;
protected $insurerBranchModel;
protected $insurerKYCDocsModel;
protected $insurerPolicyModel;
protected $clientPolicyModel;
protected $insurerRMModel;
protected $kycDocsModel;
protected $kycEntityTypeModel;
@ -54,6 +57,8 @@ class MasterController extends AdminController
protected $clientModel;
protected $clientDepositModel;
protected $insurerTemplateModel;
protected $cli_colors;
protected $vehicleModel;
@ -66,7 +71,7 @@ class MasterController extends AdminController
$this->userModel = new UserModel();
// $this->insurerBranchModel = new ClientBranchModel();
$this->insurerKYCDocsModel = new ClientKYCDocsModel();
$this->insurerPolicyModel = new ClientPolicyModel();
$this->clientPolicyModel = new ClientPolicyModel();
$this->insurerRMModel = new ClientRMModel();
$this->insurerBranchModel = new InsurerBranchModel();
$this->insurerModel = new InsurerModel();
@ -82,6 +87,14 @@ class MasterController extends AdminController
$this->clientModel = new ClientModel();
$this->clientDepositModel = new ClientDepositModel();
$this->insurerTemplateModel = new InsurerExcelExportTemplateModel();
$this->vehicleModel = new VehicleModel();
$this->cli_colors = [
'red' => "\033[31m",
'green' => "\033[32m",
'yellow' => "\033[33m",
'blue' => "\033[34m",
'reset' => "\033[0m"
];
}
@ -1258,6 +1271,8 @@ class MasterController extends AdminController
$insert = $this->CDMasterModel->where('id', $id)->set($data)->update();
$data = $this->CDMasterModel->where('id', $id)->first();
$cd_transaction_updated_data = [
'balance' => $data['opening_bal'],
'amount' => $data['opening_bal']
@ -1343,6 +1358,103 @@ class MasterController extends AdminController
}
}
public function createCDAccountNumberUsingAjax()
{
$data = $this->request->getPost();
$date = (string) $this->request->getPost('opening_date');
$data['opening_date'] = date('Y-m-d', strtotime($date));
// array with data for CD Traction table
$cd_tranction_data = [
'amount' => $data['opening_bal'],
'sub_type_id' => 7,
'client_id' => $data['client_id'],
'client_policy_id' => null,
'cd_ac_no' => $data['cd_ac_no'],
'endorsement_no' => null,
'insurer_id' => (int) $data['insurer_id'],
'description' => 'opening Amount',
'transaction_type' => 'Credit',
'event_name' => null,
'updated_by' => 1,
];
$loggedInUserID = get_session_userid();
$insert = $this->CDMasterModel->insert($data);
if ($insert) {
//for CD Tranction Table
$response = DepositHelper::saveDeposit($cd_tranction_data, $loggedInUserID);
$cd_data = $this->CDMasterModel->where('client_id', $data['client_id'])->where('insurer_id', $data['insurer_id'])->findAll();
return $this->respond(['status' => true, 'data' => $cd_data, 'cd_ac_no'=>$data['cd_ac_no'], 'message' => 'CD Account number created successfully'], 200);
}else{
return $this->respond(['status' => false, 'message' => 'Failed to created CD Account number'], 200);
}
}
//Vehicle Master data Function
public function VehicleMasterList()
{
$data['page_name'] = 'Vehicle Master List';
$data['vehicle_type'] = [
'two_wheeler' => 'Two Wheeler',
'four_wheeler' => 'Four Wheeler',
'truck' => 'Truck',
'bus' => 'Bus',
'van' => 'Van',
'suv' => 'SUV',
'motorcycle' => 'Motorcycle',
'bicycle' => 'Bicycle'
];
$data['vehicle_des'] = [
'commercial' => 'Commercial',
'private' => 'Private',
];
$data['entity'] = $this->kycEntityTypeModel->where('is_active', 1)->findAll();
$data['clients'] = $this->clientModel->where('is_active', 1)->findAll();
$data['vehicle_Master_Data'] = $this->vehicleModel->getVehicleMasterList();
$this->loadLayout('vehicle_master_list', $data);
}
public function getVehicleMasterDataByID($id = null)
{
$vehicle_data = $this->vehicleModel
->select('vehicle.*, clients.client_type')
->join('clients', 'vehicle.owner = clients.id')
->where('vehicle.id', $id)
->where('vehicle.is_active', 1)
->first();
if ($vehicle_data) {
return $this->respond(['status' => true, 'code' => 200, 'data' => $vehicle_data], 200);
} else {
return $this->respond(['status' => false, 'code' => 404], 200);
}
}
public function deactiveVehicleData($id)
{
$this->myLogger->logme('error','deactiveVehicleData function called');
$data['updated_by'] = get_session_userid();
$data['is_active'] = 0;
$update = $this->vehicleModel->where('id', $id)->set($data)->update();
if($update){
return $this->respond(['status' => true,'code' => 200], 200);
}else{
return $this->respond(['status' => false,'code' => 404], 200);
}
}
//excel export template
@ -1440,4 +1552,171 @@ class MasterController extends AdminController
]);
}
}
public function generateNewGmailAPIToken()
{
$gmailapi = \Config\Services::gmailapi();
$gmailapi->generateNewToken();
}
//testing a sample mail from front end
public function testGmailAPI()
{
if ($this->request->getMethod() == 'post') {
$gmailapi = \Config\Services::gmailapi();
$to = $this->request->getPost('to');
$subject = $this->request->getPost('subject');
$mail_content = $this->request->getPost('content');
/*****CHOOSE ANY ONE AT A TIME, COMMENT ANOTHER ONE******/
/*****CALLING DIRECLT USING LIB******/
// $res = $gmailapi->sendMessage($to, $subject, $mail_content, 'info@nhanceindia.in', 'info@nhanceindia.in', $cc = [], $bcc = []);
// if($res['status'])
// {
// return $this->respond(['status' => 'success','code' => 200,'data' => $res],200);
// }
// else
// {
// $this->respond(['status' => 'failed','code' => 500,'data' => $res],200);
// }
/*****CALLING DIRECLT USING LIB******/
/*****CALLING VIA MAIL HELPER******/
$res = MailHelper::send_email(['mail' => $to, 'subject' => $subject, 'message' => $mail_content]);
return $this->respond(['status' => 'success','code' => 200,'data' => $res],200);
/*****CALLING VIA MAIL HELPER******/
}
$this->loadLayout('mail_test');
}
//testing a sample mail from cli
public function testGmailAPIViaCLI(string $email_id = 'velmurugan.s@venbainfotech.com')
{
// print_r($email_id);die();
$gmailapi = \Config\Services::gmailapi();
$res = MailHelper::send_email(['mail' => $email_id, 'subject' => 'Mail Via CLI', 'message' => 'This is sample mail sent via CLI mode']);
print_r($res);
}
public function appCheckList()
{
//check temprory folders in writeable and public/uploads folder
$this->checkAndCreateDirectories();
$this->checkGoogleOAuthCredentialsinDB();
$this->getCronJobsList();
$this->checkGdriveRootFolderID();
}
public function checkAndCreateDirectories()
{
echo "#################### CHECKING TEMP DIRECTORIES ############################\n";
// Array of folder names and their respective paths
$folders = [
'e_card_template' => WRITEPATH . 'e_card_template/',
'uploads' => WRITEPATH . 'uploads/',
'excel' => WRITEPATH . 'uploads/excel/',
'statements' => WRITEPATH . 'uploads/statements/',
'import_excel' => WRITEPATH . 'uploads/import_excel/',
'logs' => WRITEPATH . 'uploads/logs/',
'client_kyc_documents' => WRITEPATH . 'uploads/client_kyc_documents/',
'tmp' => WRITEPATH . 'tmp/',
'e_card_imgs' => ROOTPATH . 'public/e_card_imgs',
'uploads' => ROOTPATH . 'public/uploads',
'add_image_upload' => ROOTPATH . 'public/uploads/add_image_upload/',//adverdisement images for enrollment app
'logo' => ROOTPATH . 'public/uploads/logo/',
'template_bg' => ROOTPATH . 'public/uploads/template_bg/'
];
foreach ($folders as $folderName => $folderPath) {
// Check if the folder exists
if (!is_dir($folderPath)) {
// Try to create the folder
if (mkdir($folderPath, 0777, true)) {
// Set permissions to 0777
chmod($folderPath, 0777);
echo "\nDirectory '$folderPath' created successfully with 0777 permissions.\n";
} else {
// Handle error in directory creation
echo "Failed to create directory '$folderPath'.\n";
}
} else {
echo "Directory '$folderPath' already exists.\n";
}
}
echo "################################################################\n\n";
}
public function checkGoogleOAuthCredentialsinDB()
{
$settingsModel = new SettingsModel();
$token = $settingsModel->where('id', 1)->first();
echo "################ CHECKING GMAIL OAUTH FOR EMAIL ###################\n";
if (is_array($token) && is_null($token['gmail_api_oauth_credentials'])) {
echo "Email OAuth credentials not found in database.\n";
echo "Check the following..!\n";
echo "1. Update Gmail Oauth credentials in 'gmail_api_oauth_credentials' field in 'settings' table in JSON format.\n";
echo "2. Call this cli route to generate new access token: 'php public/index.php cli/new_gmail_token' from root of the project.\n";
echo "3. Call this cli route : 'php public/index.php cli/send_mail_cli someone@gmail.com' to send test mail to testGmailAPIViaCLI ( replace someone@gmail.com with real time mail).\n";
}
else
{
echo "Gmail OAuth for sending email is set in DB\n";
}
echo "################################################################\n\n";
}
function getCronJobsList()
{
// Execute the shell command to get cron jobs
$output = null;
$resultCode = null;
echo "#################### CHECKING CRONJOBS ############################\n";
// Use shell_exec to get cron jobs from the current user's crontab
$output = shell_exec('crontab -l 2>&1');
// Check if the command was successful
if (strpos($output, 'no crontab') !== false) {
echo "No cron jobs are set for this user.\n";
} elseif ($output) {
// Return the cron job list
echo nl2br($output);
echo "\n" ;// Convert newlines to <br> for easier HTML rendering
} else {
echo "Error retrieving cron jobs or no cron jobs set.\n";
}
echo "################################################################\n\n";
}
//check gdrive root folder id in env file
function checkGdriveRootFolderID()
{
echo "#################### CHECKING GDRIVE FOLDER ID IN ENV FILE ############################\n";
$id = getenv('GDRIVE_ROOT_FOLDER_ID');
if($id)
{
echo $this->cli_colors['green'] . "ID is :". $id . $this->cli_colors['reset']. "\n";
}
else
{
echo $this->cli_colors['red'] ."Gdrive Folder id not set in env file. set it under 'GDRIVE_ROOT_FOLDER_ID' in env file.". $this->cli_colors['reset'] ."\n";
}
echo "################################################################\n\n";
}
}

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

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

File diff suppressed because it is too large Load Diff

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

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

@ -71,7 +71,9 @@ class RestAuthenticationController extends AdminController
$mobile_number = $this->request->getJSON()->mobile_number;
$employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first();
$employeeData = $this->employeeModel->where('mobile', $mobile_number)
->where('relationship', 'self')
->where('is_active', 1)->first();
if ($employeeData) {
@ -126,7 +128,9 @@ class RestAuthenticationController extends AdminController
try {
$mobile_number = $this->request->getJSON()->mobile_number;
$HrData = $this->hrModel->where('mobile', $mobile_number)->where('contact_type', 'client')->first();
$HrData = $this->hrModel->where('mobile', $mobile_number)
->where('contact_type', 'client')
->where('is_active', 1)->first();
if ($HrData) {

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

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

@ -64,17 +64,28 @@ class UserController extends AdminController
if ($insert) {
$teamData['user_id'] = $insert;
foreach ($teams as $value) {
$teamData['team_id'] = $value;
$teamData['created_by'] = get_session_userid();
$this->userTeamsModel->insert($teamData);
}
if ($userData['role'] == 3) {
$db = \Config\Database::connect();
$tableName = 'hdz_staff';
$admin = 1;
$admin = 0;
$acm = 1;
$acm_id = $insert;
$password = '12345678'; //Default password
$hashedPassword = password_hash($password, PASSWORD_DEFAULT);
foreach ($temp_team as $key => $value) {
$team = $this->teamModel->where('id', $value)->first();
if ($team['name'] == 'Claims') {
$hdz_staff = [
'emp_code' => $userData['emp_code'],
@ -82,6 +93,8 @@ class UserController extends AdminController
'username' => strtolower($userData['first_name']),
'email' => $userData['email'],
'admin' => $admin,
'acm' => $acm,
'acm_id' => $acm_id,
'registration' => time(),
'password' => $hashedPassword,
'active' => 1,
@ -90,13 +103,6 @@ class UserController extends AdminController
$db->table($tableName)->insert($hdz_staff);
}
}
$teamData['user_id'] = $insert;
foreach ($teams as $value) {
$teamData['team_id'] = $value;
$teamData['created_by'] = get_session_userid();
$this->userTeamsModel->insert($teamData);
}
}
}
}
@ -117,12 +123,12 @@ class UserController extends AdminController
public function edit()
{
$teams = $this->request->getPost('team');
if (!$this->request->getPost()) {
return redirect()->to(base_url('/user/list'));
} else {
$id = $this->request->getPost('PrimaryKey');
$teams = $this->request->getPost('team');
$userData = $this->request->getPost();
unset($userData['csrf_test_name']);
unset($userData['PrimaryKey']);
@ -133,6 +139,16 @@ class UserController extends AdminController
if ($update) {
if ($teams) {
$this->userTeamsModel->where('user_id', $id)->delete();
$teamData['user_id'] = $id;
foreach ($teams as $value) {
$teamData['team_id'] = $value;
$teamData['created_by'] = get_session_userid();
$this->userTeamsModel->insert($teamData);
}
}
if ($userData['role'] == 3) {
$db = \Config\Database::connect();
@ -152,7 +168,6 @@ class UserController extends AdminController
'active' => 1,
];
$db->table($tableName)->where('emp_code', $userData['emp_code'])
->where('email', $userData['email'])
->set($hdz_staff)
@ -160,16 +175,6 @@ class UserController extends AdminController
}
}
$this->userTeamsModel->where('user_id', $id)->delete();
if ($teams) {
$teamData['user_id'] = $id;
foreach ($teams as $value) {
$teamData['team_id'] = $value;
$teamData['created_by'] = get_session_userid();
$this->userTeamsModel->insert($teamData);
}
}
}
}
@ -201,4 +206,4 @@ class UserController extends AdminController
$teamData = $this->teamModel->select('id, name')->findAll();
echo json_encode(array("status" => true , 'roleData' => $roleData, 'teamData' => $teamData,));
}
}
}

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

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

@ -50,13 +50,13 @@ class DepositHelper
'amount' => $data['amount'],
'sub_type' => $data['sub_type_id'],
'client_id' => $data['client_id'],
'client_policy_id' => $data['client_policy_id'],
'client_policy_id' => $data['client_policy_id'] ?? 0,
'cd_ac_no' => $data['cd_ac_no'],
'endorsement_no' => $data['endorsement_no'],
'insurer_id' => $data['insurer_id'],
'unit' => $data['unit'] ?? null,
'description' => $data['description'],
'event_name' => $data['event_name'],
'description' => $data['description'] ?? null,
'event_name' => $data['event_name'] ?? null,
'transaction_type' => $data['transaction_type'],
'is_active' => 1,
'created_by' => $loggedInUserID,
@ -99,17 +99,17 @@ class DepositHelper
$getLastBalanceQuery = "SELECT balance FROM cash_deposit WHERE cd_ac_no = ? AND is_active = 1 ORDER BY created_at DESC LIMIT 1";
$getLastBalanceParams = [$cd_ac_no];
$lastBalance = $model->query($getLastBalanceQuery, $getLastBalanceParams)->getRow()->balance ?? null;
$lastBalance = $model->query($getLastBalanceQuery, $getLastBalanceParams)->getRow()->balance ?? 0;
if(empty($lastBalance) && $lastBalance == null){
// if(empty($lastBalance) && $lastBalance == null){
$cd_model = new ClientDepositModel();
// $cd_model = new ClientDepositModel();
$getLastBalanceQuery = "SELECT opening_bal FROM cd_master WHERE client_id = ? AND insurer_id = ? AND cd_ac_no = ? AND is_active = 1 ORDER BY created_at DESC LIMIT 1";
$getLastBalanceParams = [$clientId, $insurerId, $cd_ac_no];
// $getLastBalanceQuery = "SELECT opening_bal FROM cd_master WHERE client_id = ? AND insurer_id = ? AND cd_ac_no = ? AND is_active = 1 ORDER BY created_at DESC LIMIT 1";
// $getLastBalanceParams = [$clientId, $insurerId, $cd_ac_no];
$lastBalance = $cd_model->query($getLastBalanceQuery, $getLastBalanceParams)->getRow()->opening_bal ?? 0;
}
// $lastBalance = $cd_model->query($getLastBalanceQuery, $getLastBalanceParams)->getRow()->opening_bal ?? 0;
// }
return $lastBalance;
}

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

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

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

@ -14,7 +14,7 @@ use App\Models\JobModel;
class MailHelper
{
public static function send_email($params)
public static function send_email_smtp($params)
{
// print_r($params);die;
@ -63,7 +63,7 @@ class MailHelper
}
}
public static function bulk_mail(array $mails = [])
public static function bulk_mail_smtp(array $mails = [])
{
// print_r();die;
$model = new JobModel();
@ -82,5 +82,69 @@ class MailHelper
}
}
//using GmailAPI
public static function send_email($params)
{
// print_r($params);die;
$myLogger = \Config\Services::mylogger();
$gmailapi = \Config\Services::gmailapi();
$emaill = $params['mail'];
$subject = $params['subject'];
$message = $params['message'];
if (isset($params['bcc'])) {
$bcc = $params['bcc'];
}else{
$bcc = [];
}
if (isset($params['cc'])) {
$cc = $params['cc'];
}else{
$cc = [];
}
try {
$res = $gmailapi->sendMessage($emaill, $subject, $message, 'info@nhanceindia.in', 'info@nhanceindia.in', $cc, $bcc);
if($res['status'])
{
return json_encode(['status' => 'success','code' => 200, 'message'=>('Email Sent Successfully...'.$emaill),'data' => $res,],200);
}
else
{
$myLogger->logme('error', "mail sent failed - $emaill");
return json_encode(['status' => 'failed','code' => 404,'message'=>( 'Email Sent Failed...' . $emaill ),'data' => $res ],404);
}
} catch (Exception $e) {
$msg = $e->getMessage();
$myLogger->logme('error', "mail sent failed - $msg");
return json_encode(['status' => 'failed','code' => 500,'data' => $msg],500);
}
}
public static function bulk_mail(array $mails = [])
{
// print_r();die;
$model = new JobModel();
$start = microtime(true);
$runtime= 0;
try {
foreach ( $mails as $index=>$mail) {
$runtime = microtime(true) - $start;
$send_mail = self::send_email($mail);
}
return json_encode(['status' => 'success','code' => 200, 'message'=>'Email Sent Successfully...'],200);
} catch (\Throwable $th) {
return json_encode(['status' => 'failed','code' => 500],500);
}
}
}
?>

View File

@ -0,0 +1,150 @@
<?php
use Google\Client as GoogleClient;
use Google\Service\Drive;
if (!function_exists('uploadFilesToGoogleDrive')) {
function uploadFilesToGoogleDrive(array $files, $doc_name, $pt_id)
{
$appName = getenv('GOOGLE_OAUTH_APP_NAME');
$clientID = getenv('GOOGLE_OAUTH_CLIENT_ID');
$clientSecret = getenv('GOOGLE_OAUTH_CLIENT_SECRET');
$redirectUri = getenv('GOOGLE_OAUTH_REDIRECT_URI');
$scopes = explode(',', getenv('GOOGLE_OAUTH_SCOPES'));
$accessToken = session()->get('access_token');
log_message('error', '////////////// --- G-Drive Access Token {data}', ['data' => $accessToken]);
// Initialize Google Client
$client = new GoogleClient();
$client->setApplicationName($appName);
$client->setClientId($clientID);
$client->setClientSecret($clientSecret);
$client->setRedirectUri($redirectUri);
$client->addScope($scopes);
// $client->setApprovalPrompt('force');
$client->setPrompt('consent');
$client->setAccessType('offline');
if ($accessToken) {
$client->setAccessToken($accessToken);
log_message('error', '////////////// --- G-Drive Access Token expired : {data}', ['data' => $client->isAccessTokenExpired()]);
if ($client->isAccessTokenExpired()) {
$refreshToken = session()->get('refresh_token');
log_message('error', '////////////// --- G-Drive Refresh Token : {data}', ['data' => $refreshToken]);
if ($refreshToken) {
$client->fetchAccessTokenWithRefreshToken($refreshToken);
$token = $client->getAccessToken();
if (isset($token['access_token'])) {
session()->set('access_token', $token['access_token']);
// $client->setAccessToken($token);
log_message('error', '////////////// --- G-Drive Access Token refreshed and stored successfully.');
} else {
log_message('error', '////////////// --- G-Drive Access Token not available after refresh.');
}
if (isset($token['refresh_token'])) {
session()->set('refresh_token', $token['refresh_token']);
log_message('error', '////////////// --- G-Drive Refresh Token updated successfully.');
} else {
log_message('error', '////////////// --- G-Drive Refresh Token not available after refresh.');
}
} else {
log_message('error', '////////////// --- G-Drive Refresh Token Not Available');
redirect()->to(filter_var($client->createAuthUrl(), FILTER_SANITIZE_URL));
}
} else {
log_message('error', '////////////// --- G-Drive Access Token is still valid.');
}
try {
$driveService = new Drive($client);
$folderName = 'New Folder';
// Check if the folder already exists
$response = $driveService->files->listFiles([
'q' => "mimeType='application/vnd.google-apps.folder' and name='{$folderName}' and trashed=false",
'fields' => 'files(id, name)'
]);
$filesList = $response->getFiles();
$folderId = null;
if (count($filesList) > 0) {
// Folder already exists
$folderId = $filesList[0]->getId();
} else {
// Create a new folder
$folder = new Drive\DriveFile();
$folder->setName($folderName);
$folder->setMimeType('application/vnd.google-apps.folder');
$createdFolder = $driveService->files->create($folder, [
'fields' => 'id'
]);
$folderId = $createdFolder->id;
}
$uploadedFiles = [];
foreach ($files as $key => $file) {
if (!empty($file)) {
$dname = $doc_name[$key];
$driveFile = new Drive\DriveFile();
$driveFile->setName($file->getClientName());
$driveFile->setParents([$folderId]);
$result = $driveService->files->create(
$driveFile,
[
'data' => file_get_contents($file->getTempName()),
'mimeType' => $file->getClientMimeType(),
'uploadType' => 'multipart'
]
);
$uploadedFiles[] = [
'file_name' => $file->getClientName(),
'drive_id' => $result->id,
'doc_name' => $dname,
'pt_id' => $pt_id,
'created_by' => get_session_userid(),
'url' => "https://drive.google.com/file/d/{$result->id}/view",
];
}
}
return $uploadedFiles;
} catch (\Exception $e) {
$errorDetails = [
'status' => 'error',
'error_message' => 'Error uploading files: ' . $e->getMessage(),
'error_code' => $e->getCode(),
'file' => $e->getFile(),
'line' => $e->getLine(),
'stack_trace' => $e->getTraceAsString()
];
return $errorDetails;
}
} else {
$url = $client->createAuthUrl();
return redirect()->to(filter_var($url, FILTER_SANITIZE_URL));
}
}
}

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

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

@ -234,7 +234,7 @@ if(!function_exists('check_si'))
$is_si_found = false;
$is_age_slab_found = false;
if($policy_details['policy_type_id'] == 1 && $slab_details[0]['policy_grid_id'] == 1 && $slab_details[0]['si_or_bp'] == 2) // GPA && grid type 1 for GPA && sub type is basic pay
if($policy_details['policy_type_id'] == 1 && $slab_details['slab_rates'][0]['policy_grid_id'] == 1 && $slab_details['slab_rates'][0]['si_or_bp'] == 2) // GPA && grid type 1 for GPA && sub type is basic pay
{
$is_si_found = true;
$is_age_slab_found = true;
@ -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'; }
@ -1570,7 +1581,7 @@ if(!function_exists('get_emp_records_from_audit_history'))
function get_emp_records_from_audit_history($employee_id)
{
$db = db_connect();
$query = "SELECT min(id) as id,pk,table_name,field_name,old_value FROM venbaehn_nhance.auditing_history where pk = $employee_id and table_name = 'employees' and field_name in ('name','dob','gender','mobile','email_corporate','relationship') group by field_name order by id asc";
$query = "SELECT min(id) as id,pk,table_name,field_name,old_value FROM auditing_history where pk = $employee_id and table_name = 'employees' and field_name in ('name','dob','gender','mobile','email_corporate','relationship') group by field_name order by id asc";
$res = $db->query($query);
// echo $db->getLastQuery();
$res = $res->getResultArray();
@ -1592,7 +1603,7 @@ if(!function_exists('get_emp_policy_records_from_audit_history'))
function get_emp_policy_records_from_audit_history($emp_policy_id)
{
$db = db_connect();
$query = "SELECT min(id) as id,pk,table_name,field_name,old_value FROM venbaehn_nhance.auditing_history where pk = $emp_policy_id and table_name = 'employee_polices' and field_name in ('basic_cover_si','premium','gst') group by field_name order by id asc";
$query = "SELECT min(id) as id,pk,table_name,field_name,old_value FROM auditing_history where pk = $emp_policy_id and table_name = 'employee_polices' and field_name in ('basic_cover_si','premium','gst') group by field_name order by id asc";
$res = $db->query($query);
// echo $db->getLastQuery();
$res = $res->getResultArray();

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

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

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

@ -27,13 +27,21 @@ if (!function_exists('googleOauthLogin')) {
$client->setClientSecret($clientSecret);
$client->setRedirectUri($redirectUri);
$client->addScope($scopesArray);
// $client->setApprovalPrompt('force');
$client->setPrompt('consent');
$client->setAccessType('offline');
// Check if an OAuth token is provided
if ($oauthToken) {
try {
// Attempt to fetch the access token with the provided OAuth token
$token = $client->fetchAccessTokenWithAuthCode($oauthToken);
session()->set('access_token', $token['access_token']);
if(isset($token['refresh_token'])){
session()->set('refresh_token', $token['refresh_token']);
}
$client->setAccessToken($token);
$oauth = new Oauth2($client);
// Get user information using the OAuth2 service

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

@ -105,9 +105,9 @@ class sendMailNotification
$wholeData = [];
}
return $wholeData;
// }else{
// return "false";
// }
// }else{
// return "false";
// }
} else if($action == 'member_ecard_mail'){
$notification = $params['notification'];
@ -160,7 +160,7 @@ class sendMailNotification
$client_data =$clientModel->where('id', $client_id)->first();
$notification_data = $notificationModel->where('client_id' ,$client_id)->where('template_name', $action)->first();
if ($notification_data['enabled'] == 1) {
if (isset($notification_data) && $notification_data['enabled'] == 1) {
$mail_content = $notification_data['mail_content'];
$subject = $notification_data['subject'];
$app_link = $_ENV['App_Url'];
@ -259,7 +259,7 @@ class sendMailNotification
$client_data =$clientModel->where('id', $client_id)->first();
$notification_data = $notificationModel->where('client_id' ,$client_id)->where('template_name', $action)->first();
if ($notification_data['enabled'] == 1) {
if (isset($notification_data) && $notification_data['enabled'] == 1) {
$client_rm_data= $clientRMModel->where('client_id', $client_id)->where('is_active',1)->findAll();
$user_list= [];
foreach ($client_rm_data as $key => $value) {
@ -376,7 +376,7 @@ class sendMailNotification
$notification_data = $notificationModel->where('client_id' ,$client_id)->where('template_name', $action)->first();
$clientRMModel =new ClientRMModel();
if ($notification_data['enabled'] == 1) {
if (isset($notification_data['enabled']) && $notification_data['enabled'] == 1) {
$client_rm_data= $clientRMModel->where('client_id', $client_id)->where('is_active',1)->findAll();
$user_list= [];
foreach ($client_rm_data as $key => $value) {

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

@ -140,6 +140,15 @@ if (!function_exists('get_session_context')) {
}
}
if (!function_exists('user_team')) {
function user_team()
{
// $CI =& get_instance();
$session = \Config\Services::session();
return $session->get('user_team');
}
}

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

@ -1,4 +1,10 @@
<?php
use App\Models\ClientModel;
use App\Models\UserTeamsModel;
use App\Models\FileModel;
use App\Models\BatchFileModelFileModel;
use App\Controllers\GoogleDriveController;
use App\Models\BatchFileModel;
// File: app/Helpers/Uuid_helper.php
@ -22,6 +28,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
@ -29,7 +36,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);
@ -65,8 +73,6 @@ if (!function_exists('file_unlink')) {
}
}
if (!function_exists('compressImage')) {
function compressImage($file, $destinationPath, $newWidth = 100, $newHeight = 100)
{
@ -82,9 +88,7 @@ if (!function_exists('compressImage')) {
}
}
if (!function_exists('fancy_date_time_format'))
{
if (!function_exists('fancy_date_time_format')) {
function fancy_date_time_format($datetime,$return_type = 'fancy') {
date_default_timezone_set('Asia/Kolkata');
@ -118,9 +122,7 @@ if (!function_exists('fancy_date_time_format'))
}
if(!function_exists('check_string_date'))
{
if(!function_exists('check_string_date')){
function check_string_date($str)
{
if (DateTime::createFromFormat('Y-m-d H:i:s', $str) !== false) {
@ -130,8 +132,6 @@ if(!function_exists('check_string_date'))
}
}
if (!function_exists('generate_download_link')) {
function generate_download_link($rand_string) {
@ -145,8 +145,6 @@ if (!function_exists('generate_download_link')) {
}
}
if (!function_exists('generate_random_alphanumeric')) {
function generate_random_alphanumeric($length = 6) {
$random_string = '';
@ -165,8 +163,6 @@ if (!function_exists('generate_random_alphanumeric')) {
}
}
if (!function_exists('get_base64_image')) {
function get_base64_image($path)
@ -184,7 +180,6 @@ if (!function_exists('get_base64_image')) {
}
}
if (!function_exists('format_indian_number')) {
function format_indian_number($number) {
// Round the number to two decimal places
@ -218,7 +213,6 @@ if (!function_exists('format_indian_number')) {
}
}
if (!function_exists('get_username')) {
function get_username($user_id) {
// Connect to the database
@ -238,7 +232,6 @@ if (!function_exists('get_username')) {
}
}
if (!function_exists('get_role_id')) {
function get_role_id() {
@ -247,6 +240,143 @@ if (!function_exists('get_role_id')) {
}
}
if (!function_exists('teams')) {
function teams() {
// Load the UserTeamsModel
$teamModel = new \App\Models\UserTeamsModel();
// Get the user ID from the session
$user_id = get_session_userid();
// Fetch the team IDs associated with the user
$user_teams = $teamModel->select('team_id')->where('user_id', $user_id)->findAll();
// Debugging: Log or print the query result to check its structure
// var_dump($user_teams); // You can use this temporarily for testing
// log_message('info', 'User Teams: ' . json_encode($user_teams)); // Optionally log it
// Check if the result is not empty
if (!empty($user_teams)) {
// Extract only the 'team_id' values
$team_ids = array_column($user_teams, 'team_id');
return $team_ids; // Return array of team IDs
} else {
return []; // Return empty array if no teams found
}
}
}
if (!function_exists('generate_client_code')) {
function generate_client_code($string = 'GC') {
$clientModel = new \App\Models\ClientModel();
$latestClient = $clientModel->select('id')->orderBy('id', 'DESC')->first();
$id = $latestClient ? $latestClient['id'] : 0;
$year = date('y');
$newId = $id + 1;
$client_code = $year . $string . $newId;
return $client_code;
}
}
if (!function_exists('generate_tsi_code')) {
function generate_tsi_code($type) {
$PolicyTransactionModel = new \App\Models\PolicyTransactionModel();
$latestClient = $PolicyTransactionModel->select('id')->orderBy('id', 'DESC')->first();
$id = $latestClient ? $latestClient['id'] : 0;
$year = date('y');
$month = date('m');
$string = 'P';
if($type == 2){
$string2 = 'R';
}else{
$string2 = 'F';
}
$newId = $id + 1;
$tsi_code = $string2 . $month . $year . $string . $newId;
return $tsi_code;
}
}
if (!function_exists('generateRandomCode')) {
function generateRandomCode($prefix = 'RTL-', $length = 6) {
// Generate a random number with the specified length
$randomNumber = str_pad(mt_rand(0, pow(10, $length)-1), $length, '0', STR_PAD_LEFT);
// Return the code with the prefix
return $prefix . $randomNumber;
}
}
if (!function_exists('excelFileGDriveUpload')) {
function excelFileGDriveUpload($file_id, $table_name) {
$doc_type = "UPLOADS";
$uploadFilePath = WRITEPATH . 'uploads/' . ($table_name == 'batch_file' ? 'import_excel' : 'excel');
$models = [
'batch_file' => [
'model' => new BatchFileModel(),
'select' => "client_id, client_policy_id, file_name"
],
'files' => [
'model' => new FileModel(),
'select' => "client_id, policy_id as client_policy_id, file_name"
],
];
if (!array_key_exists($table_name, $models)) {
return;
}
// Retrieve data
$data = $models[$table_name]['model']
->select($models[$table_name]['select'])
->where('id', $file_id)
->where('is_active', 1)
->first();
if ($data) {
$uploadFilePath .= '/' . $data['file_name'];
// dd($data, $uploadFilePath);
$GoogleDriveController = new GoogleDriveController();
$result = $GoogleDriveController->uploadFiletoGdrive(
// client_id : $data['client_id'],
client_policy_id: $data['client_policy_id'],
doc_type : $doc_type,
file_path : $uploadFilePath,
file_name : $data['file_name']
);
// dd($result);
return true;
}else{
return false;
}
}
}
function numberToWords($number)
{

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

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

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