diff --git a/app/Config/Routes.php b/app/Config/Routes.php
index cc9ea843..b26c46c4 100755
--- a/app/Config/Routes.php
+++ b/app/Config/Routes.php
@@ -8,6 +8,7 @@ use CodeIgniter\Router\RouteCollection;
*/
$routes->post('/chat', 'ChatbotControllerNew::index');
$routes->get('/widget', 'ChatbotControllerNew::widget');
+$routes->get('/chatbottest', 'ChatbotControllerNew::chatbotest');
$routes->get('/chatbot', 'ChatbotControllerNew::chatbot');
$routes->get('/swagger', 'SwaggerController::index', ['filter' => 'authMVC']);
@@ -87,6 +88,8 @@ $routes->group("/client", ["filter" => "authMVC"], function ($routes) {
$routes->get('deposit/(:num)', 'ClientController::deposit/$1');
$routes->get('remove/(:num)', 'ClientController::removeClient/$1');
$routes->get("list/(:any)", "ClientController::editClientOnboarding/$1");
+ $routes->post('wipe', 'ClientController::wipeDemoClient');
+
// application/config/routes.php
// Add a route for the view_Deposit method
diff --git a/app/Controllers/Chatbot/EcardDownloadConversation.php b/app/Controllers/Chatbot/EcardDownloadConversation.php
index c38d6977..1f303c13 100644
--- a/app/Controllers/Chatbot/EcardDownloadConversation.php
+++ b/app/Controllers/Chatbot/EcardDownloadConversation.php
@@ -23,7 +23,7 @@ class EcardDownloadConversation extends Conversation
$policy_list = ChatbotHelper::getListOfPolicies($chat_session_info);
$buttons = [];
$question = 'Choose Policy to Download Ecard:';
- log_message('error', ('policy_list : ' . json_encode($policy_list)));
+ // log_message('error', ('policy_list : ' . json_encode($policy_list)));
if(is_array($policy_list) && count($policy_list))
{
diff --git a/app/Controllers/ChatbotControllerNew.php b/app/Controllers/ChatbotControllerNew.php
index dc38a3c9..544c40d4 100644
--- a/app/Controllers/ChatbotControllerNew.php
+++ b/app/Controllers/ChatbotControllerNew.php
@@ -25,9 +25,13 @@ class ChatbotControllerNew extends BaseController
public function __construct()
{
set_session_context('CHATBOT CON');
+
$this->myLogger = \Config\Services::mylogger();
$this->session = \Config\Services::session();
+ $sessionID = session_id();
+ $this->myLogger->logme('error', 'COOKIE - ' . $sessionID);
+
// $this->myLogger->logme('error', 'CALLED');
// Load BotMan driver
@@ -51,6 +55,9 @@ class ChatbotControllerNew extends BaseController
// $this->myLogger->logme('error', $method);
if (isset($extras) && $method == 'widget') {
+ $request = \Config\Services::request();
+ $cookieHeader = $request->getHeaderLine('Cookie');
+
$extras = $extras->parameters;
$this->session->set('CHATBOT_EMP_ID', $extras->employee_id);
$this->session->set('CHATBOT_ORIGIN', $extras->origin);
@@ -104,10 +111,10 @@ class ChatbotControllerNew extends BaseController
log_message("error","Inside Bot Type Function");
$bot->types(); // Typing indicator for the first message
- sleep(0.5); // Delay
+ sleep(0.1); // Delay
});
// Start the Main Menu when user says "hi" or "start"
- $this->botman->hears('start|hi|hello', function (BotMan $bot) {
+ $this->botman->hears('start|hi|hello|help|help me', function (BotMan $bot) {
if ($this->isMemberLoggedIn){
$bot->reply('Hi how can i assist?');
$bot->startConversation(new MainMenuConversation());
@@ -139,9 +146,14 @@ class ChatbotControllerNew extends BaseController
// }
+ public function chatbotest()
+ {
+ $this->loadLayout('chatbottest.php');
+ }
+
public function chatbot()
{
- $this->loadLayout('chatbot.php');
+ echo view('chatbot.php');
}
public function widget()
diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php
index 10aeea5f..bff1d34f 100755
--- a/app/Controllers/ClientController.php
+++ b/app/Controllers/ClientController.php
@@ -635,6 +635,7 @@ class ClientController extends AdminController
$balances = $this->clientPolicyModel->getBalances($id);
$data['balances'] = $balances;
+ // dd($data);
if($requestFrom == 'rest'){ return $data; }
echo view('layout/header', $headerData);
@@ -746,12 +747,15 @@ class ClientController extends AdminController
$this->myLogger->logme('error', 'Edit Client Onboarding function called');
$headerData['page_name'] = 'Edit Client Onboarding';
- $editData['RM'] = $this->userModel->where('is_active', 1)->findAll();
+ $editData['RM'] = $this->userModel->where('is_active', 1)->findAll();
$editData['tpa'] = $this->tpaBranchModel->getTpaBranchesWithTpaNames();
$editData['state'] = $this->stateModel->getAllStates();
$editData['police'] = $this->policesModel->findAll();
$editData['entity'] = $this->kycEntityTypeModel->findAll();
$editData['insurer'] = $this->insurerBranchModel->getInsurerBranchesWithInsurerNames();
+ $editData['insurers'] = $this->insurerModel->where('is_active', 1)->findAll();
+ $editData['insurer_branch'] = $this->insurerBranchModel->where('is_active', 1)->findAll();
+ $editData['clients'] = $this->clientModel->where('is_active', 1)->findAll();
$editData['kyc_docs'] = $this->kycDocsModel->findAll();
$editData['policyGridData'] = $this->policyGridModel->findAll();
$editData['policy_types'] = $this->policyTypeModel->findAll();
@@ -805,7 +809,12 @@ class ClientController extends AdminController
$data['is_download_btn'] = 1;
}
+ if(empty($data['parent_client_id'])){
+ $data['parent_client_id'] = null;
+ }
+
$insert = $this->clientModel->insert($data);
+
if ($insert) {
$client_data = $this->clientModel->where(['id' => $insert, 'is_active' => 1])->first();
return $this->respond(['status' => true, 'code' => 200, 'data' => $client_data], 200);
@@ -834,6 +843,9 @@ class ClientController extends AdminController
$data['is_download_btn'] = 1;
}
+ if(empty($data['parent_client_id'])){
+ $data['parent_client_id'] = null;
+ }
// print_r($data);die;
$update = $this->clientModel->update($id, $data);
@@ -2545,6 +2557,7 @@ class ClientController extends AdminController
// $data['special_condition_label'] = str_replace(',', '', $this->request->getPost("special_condition_label")) ?? [];
// $data['special_condition_input'] = str_replace(',', '', $this->request->getPost("special_condition_input")) ?? [];
// $data['multiple_sum_insured'] = str_replace(',', '', $this->request->getPost("multiple_sum_insured")) ?? [];
+
$fields = [
'waiverofpreexistingdiseases' => false,
'waiverof1,2,3&4thyearexclusions' => false,
@@ -2599,6 +2612,8 @@ class ClientController extends AdminController
if ($value !== null && $value !== '') {
$data[$field] = $needsCleanup ? str_replace(',', '', $value) : $value;
+ }else{
+ $data[$field] = $value;
}
}
@@ -2865,6 +2880,8 @@ class ClientController extends AdminController
try {
$this->myLogger->logme('error', 'Policy GPA Terms CREATE function called');
+ // print_r($this->request->getPost()); die;
+
/*** Client Policy Table Primary Key(ID) ***/
$client_policy_id = $this->request->getPost("client_policy_id");
@@ -2936,6 +2953,8 @@ class ClientController extends AdminController
$value = $this->request->getPost($field);
if ($value !== null) {
$data[$field] = str_replace(',', '', $value);
+ }else{
+ $data[$field] = $value;
}
}
@@ -2944,6 +2963,8 @@ class ClientController extends AdminController
$value = $this->request->getPost($field);
if ($value !== null) {
$data[$field] = $value;
+ }else{
+ $data[$field] = $value;
}
}
@@ -3551,22 +3572,56 @@ class ClientController extends AdminController
return $this->respond(['status' => true, 'code' => 200, 'message' => 'Additionaly Rack Rate Data Remove Successfully'], 200);
}
- public function get_cd_ac($client_id, $insurer_id)
+ public function get_cd_ac($client_id, $insurer_id, $insurer_branch_id)
{
+ // Get client data
+ $client_data = $this->clientModel
+ ->where('is_active', 1)
+ ->where('id', $client_id)
+ ->first();
- $cd_data = $this->CDMasterModel
+ $cd_data = [];
+
+ // If client has a parent, fetch parent client CD data
+ if (!empty($client_data['parent_client_id'])) {
+ $parent_cd_data = $this->CDMasterModel
+ ->where('client_id', $client_data['parent_client_id'])
+ ->where('insurer_id', $insurer_id)
+ ->where('insurer_branch_id', $insurer_branch_id)
+ ->where('is_active', 1)
+ ->findAll();
+
+ $cd_data = array_merge($cd_data, $parent_cd_data);
+ }
+
+ // Fetch current client CD data
+ $client_cd_data = $this->CDMasterModel
->where('client_id', $client_id)
->where('insurer_id', $insurer_id)
+ ->where('insurer_branch_id', $insurer_branch_id)
->where('is_active', 1)
->findAll();
- if ($cd_data) {
- return $this->respond(['status' => true, 'code' => 200, 'data' => $cd_data], 200);
+ $cd_data = array_merge($cd_data, $client_cd_data);
+
+ if (!empty($cd_data)) {
+ return $this->respond([
+ 'status' => true,
+ 'code' => 200,
+ 'data' => $cd_data
+ ], 200);
} else {
- return $this->respond(['status' => false, 'code' => 404, 'insurer_id' => $insurer_id, 'client_id' => $client_id], 200);
+ return $this->respond([
+ 'status' => false,
+ 'code' => 404,
+ 'client_id' => $client_id,
+ 'insurer_id' => $insurer_id,
+ 'insurer_branch_id' => $insurer_branch_id
+ ], 200);
}
}
+
public function otherPolicyTermsFormSubmit()
{
@@ -4095,21 +4150,60 @@ class ClientController extends AdminController
}
-
- public function getCDAccNoByClientAndInsurer($client, $insurer)
+ public function getCDAccNoByClientAndInsurer($client_id, $insurer_id, $insurer_branch_id)
{
- $cdmData = $this->CDMasterModel
- ->where('client_id', $client)
- ->where('insurer_id', $insurer)
- ->where('is_active', 1)
- ->findAll();
+ // Get client data
+ $client_data = $this->clientModel
+ ->where('is_active', 1)
+ ->where('id', $client_id)
+ ->first();
- if ($cdmData) {
- return $this->respond(['status' => true, 'data' => $cdmData], 200);
+ $cd_data = [];
+
+ // If client has a parent, fetch parent client CD data
+ if (!empty($client_data['parent_client_id'])) {
+ $parent_cd_data = $this->CDMasterModel
+ ->where('client_id', $client_data['parent_client_id'])
+ ->where('insurer_id', $insurer_id)
+ ->where('insurer_branch_id', $insurer_branch_id)
+ ->where('is_active', 1)
+ ->findAll();
+
+ $cd_data = array_merge($cd_data, $parent_cd_data);
+ }
+
+ // Fetch current client CD data
+ $client_cd_data = $this->CDMasterModel
+ ->where('client_id', $client_id)
+ ->where('insurer_id', $insurer_id)
+ ->where('insurer_branch_id', $insurer_branch_id)
+ ->where('is_active', 1)
+ ->findAll();
+
+ $cd_data = array_merge($cd_data, $client_cd_data);
+
+ if (!empty($cd_data)) {
+ return $this->respond([ 'status' => true,'code' => 200, 'data' => $cd_data], 200);
} else {
- return $this->respond(['status' => false], 200);
+ return $this->respond(['status' => false,'code' => 404,'client_id' => $client_id,'insurer_id' => $insurer_id,'insurer_branch_id' => $insurer_branch_id ], 200);
}
}
+
+ // public function getCDAccNoByClientAndInsurer($client, $insurer, $insurer_branch_id)
+ // {
+ // $cdmData = $this->CDMasterModel
+ // ->where('client_id', $client)
+ // ->where('insurer_id', $insurer)
+ // ->where('insurer_branch_id', $insurer_branch_id)
+ // ->where('is_active', 1)
+ // ->findAll();
+
+ // if ($cdmData) {
+ // return $this->respond(['status' => true, 'data' => $cdmData], 200);
+ // } else {
+ // return $this->respond(['status' => false], 200);
+ // }
+ // }
public function createClientWithMinimalData()
{
@@ -6141,7 +6235,7 @@ class ClientController extends AdminController
}
}
- // ---------------------------------------------------------------------------------------------------
+ // ---------------- HR ACCESS CONTROL -----------------------------------------------------------------------------------
public function viewHrAccessData()
{
@@ -6208,6 +6302,14 @@ class ClientController extends AdminController
$pre_client_data = $db2->table('clients')->where('is_active', 1)->where('short_name', $post_client_data['short_name'])->get()->getRowArray();
+ if(empty($pre_client_data)){
+
+ $hrAccessData['pre_hr_data'] = [];
+ $hrAccessData['pre_policy_data'] = [];
+ $combinedHrAccessData = $this->constructHrAccessData($hrAccessData, $client_id);
+ return $combinedHrAccessData;
+ }
+
$hrAccessData['pre_hr_data'] = $db2->table('client_branch')
->select('lc.id as pre_hr_id, lc.name as hr_name, lc.mobile as hr_mobile, lc.email as hr_mail')
->join('level_contacts lc', 'client_branch.id = lc.ref_id')
@@ -6479,8 +6581,585 @@ class ClientController extends AdminController
}
}
+ // ------------------- DEMO CLIENT FUNCTION --------------------------------------------------------------------------------
+ // public function wipeDemoClient()
+ // {
+ // // $this->myLogger->logme('error', "Wipe Demo Client function called");
+ // $this->myLogger->logme('error', "Wipe Demo Client function called"); // Red text
+ // $this->myLogger->logme('error', "Wipe Demo client Payload : " . json_encode($this->request->getPost() ?? []));
+ // $client_id = $this->request->getPost('client_id');
+
+ // if (empty($client_id)) {
+ // return $this->respond(['status' => false, 'message' => 'Client id required'], 404);
+ // }
+
+ // // 1. Client Model
+ // $client_data = $this->clientModel->where('id', $client_id)->where('is_active', 1)->first();
+ // $this->myLogger->logme('error', "Client data : " . json_encode($client_data ?? []));
+
+ // if (!empty($client_data)) {
+ // $is_deleted = $this->clientModel->where('id', $client_id)->delete();
+
+ // if ($is_deleted) {
+ // $this->myLogger->logme('error', "Client data removed successfully.");
+ // } else {
+ // $this->myLogger->logme('error', "Client record does not exist.");
+ // }
+ // } else {
+ // return $this->respond(['status' => false, 'message' => 'Client not found'], 404);
+ // }
+
+ // // 2. Client RM Model
+ // $client_rm_data = $this->clientRMModel->where('client_id', $client_id)->first();
+ // $this->myLogger->logme('error', "Client Relationship Manager data : " . json_encode($client_rm_data ?? []));
+
+ // if (!empty($client_rm_data)) {
+ // $is_deleted = $this->clientRMModel->where('client_id', $client_id)->delete();
+
+ // if ($is_deleted) {
+ // $this->myLogger->logme('error', "Client Relationship Manager data removed successfully.");
+ // } else {
+ // $this->myLogger->logme('error', "Client Relationship Manager record does not exist. To delete");
+ // }
+ // } else {
+ // $this->myLogger->logme('error', "Client Relationship Manager data not found.");
+ // }
+
+ // // 3. Client KYC Docs Model
+ // $client_kyc_data = $this->clientKYCDocsModel->where('client_id', $client_id)->findAll();
+ // $this->myLogger->logme('error', "Client KYC Docs data : " . json_encode($client_kyc_data ?? []));
+
+ // if (!empty($client_kyc_data)) {
+ // $is_deleted = $this->clientKYCDocsModel->where('client_id', $client_id)->delete();
+ // if ($is_deleted) {
+ // $this->myLogger->logme('error', "Client KYC Docs data removed successfully.");
+ // } else {
+ // $this->myLogger->logme('error', "Client KYC Docs record does not exist. To delete");
+ // }
+ // } else {
+ // $this->myLogger->logme('error', "Client KYC Docs data not found.");
+ // }
+
+ // // 4. Client Branch Model
+ // $client_branch_data = $this->clientBranchModel->where('client_id', $client_id)->findAll();
+ // $this->myLogger->logme('error', "Client Branch data : " . json_encode($client_branch_data ?? []));
+
+ // $branch_ids = array_column($client_branch_data, 'id') ?? [];
+ // $this->myLogger->logme('error', "Client Branch id count : " . count($branch_ids ?? []));
+
+ // if (!empty($client_branch_data)) {
+
+ // $is_deleted = $this->clientBranchModel->where('client_id', $client_id)->delete();
+
+ // if ($is_deleted) {
+ // $this->myLogger->logme('error', "Client Branch data removed successfully.");
+
+ // if(!empty($branch_ids)){
+
+ // $level_contact_data = $this->levelContactModel->where('contact_type', 'client')->whereIn('ref_id', $branch_ids)->findAll();
+ // $this->myLogger->logme('error', "Level Contact data : " . json_encode($level_contact_data ?? []));
+
+ // $is_deleted = $this->levelContactModel->where('contact_type', 'client')->whereIn('ref_id', $branch_ids)->delete();
+ // if ($is_deleted) {
+ // $this->myLogger->logme('error', "Level Contact data removed successfully.");
+ // } else {
+ // $this->myLogger->logme('error', "Level Contact record does not exist. To delete");
+ // }
+
+ // }else{
+ // $this->myLogger->logme('error', "Level Contact data not found.");
+ // }
+
+ // } else {
+ // $this->myLogger->logme('error', "Client Branch record does not exist. To delete");
+ // }
+ // } else {
+ // $this->myLogger->logme('error', "Client Branch data not found.");
+ // }
+
+ // // 5. Client Policy Model
+ // $client_policy_data = $this->clientPolicyModel->where('client_id', $client_id)->findAll();
+ // $this->myLogger->logme('error', "Client Policy data : " . json_encode($client_policy_data ?? []));
+
+ // $policy_ids = array_column($client_policy_data, 'id') ?? [];
+ // $this->myLogger->logme('error', "Client Policy id count : " . count($policy_ids ?? []));
+
+ // if (!empty($client_policy_data)) {
+ // $is_deleted = $this->clientPolicyModel->where('client_id', $client_id)->delete();
+ // if ($is_deleted) {
+
+ // $this->myLogger->logme('error', "Client Policy data removed successfully.");
+
+ // if(!empty($policy_ids)){
+
+ // $employee_policy_data = $this->employeePolicyModel->whereIn('client_policy_id', $policy_ids)->findAll();
+ // $this->myLogger->logme('error', "Employee Policy data count : " . count($employee_policy_data ?? []));
+
+ // $is_deleted = $this->employeePolicyModel->whereIn('client_policy_id', $policy_ids)->delete();
+ // if ($is_deleted) {
+ // $this->myLogger->logme('error', "Employee policy data removed successfully.");
+ // } else {
+ // $this->myLogger->logme('error', "Employee policy record does not exist. To delete");
+ // }
+
+ // }else{
+ // $this->myLogger->logme('error', "Employee policy data not found.");
+ // }
+
+ // } else {
+ // $this->myLogger->logme('error', "Client Policy record does not exist. To delete");
+ // }
+ // } else {
+ // $this->myLogger->logme('error', "Client Policy data not found.");
+ // }
+
+ // // 6. Employee Model
+ // $employee_data = $this->employeeModel->where('client_id', $client_id)->findAll();
+ // $this->myLogger->logme('error', "Employee data count : " . count($employee_data ?? []));
+
+ // if (!empty($employee_data)) {
+
+ // $is_deleted = $this->employeeModel->where('client_id', $client_id)->delete();
+ // if ($is_deleted) {
+ // $this->myLogger->logme('error', "Employee data removed successfully.");
+ // } else {
+ // $this->myLogger->logme('error', "Employee record does not exist. To delete");
+ // }
+ // } else {
+ // $this->myLogger->logme('error', "Employee data not found.");
+ // }
+
+ // // 7. Client Deposit Model
+ // $client_deposit_data = $this->clientDepositModel->where('client_id', $client_id)->findAll();
+ // $this->myLogger->logme('error', "Client Deposit data : " . json_encode($client_deposit_data ?? []));
+
+ // if (!empty($client_deposit_data)) {
+ // $is_deleted = $this->clientDepositModel->where('client_id', $client_id)->delete();
+ // if ($is_deleted) {
+ // $this->myLogger->logme('error', "Client Deposit data removed successfully.");
+ // } else {
+ // $this->myLogger->logme('error', "Client Deposit record does not exist. To delete");
+ // }
+ // } else {
+ // $this->myLogger->logme('error', "Client Deposit data not found.");
+ // }
+
+ // // 8. Policy Premium 1 Model
+ // $policy_premium1_data = $this->policyPremium1Model->where('client_id', $client_id)->findAll();
+ // $this->myLogger->logme('error', "Policy Premium 1 data count : " . count($policy_premium1_data ?? []));
+
+ // if (!empty($policy_premium1_data)) {
+ // $is_deleted = $this->policyPremium1Model->where('client_id', $client_id)->delete();
+ // if ($is_deleted) {
+ // $this->myLogger->logme('error', "Policy Premium 1 data removed successfully.");
+ // } else {
+ // $this->myLogger->logme('error', "Policy Premium 1 record does not exist. To delete");
+ // }
+ // } else {
+ // $this->myLogger->logme('error', "Policy Premium 1 data not found.");
+ // }
+
+ // // 9. Policy Premium 2 Model
+ // $policy_premium2_data = $this->policyPremium2Model->where('client_id', $client_id)->findAll();
+ // $this->myLogger->logme('error', "Policy Premium 2 data count: " . count($policy_premium2_data ?? []));
+
+ // if (!empty($policy_premium2_data)) {
+ // $is_deleted = $this->policyPremium2Model->where('client_id', $client_id)->delete();
+ // if ($is_deleted) {
+ // $this->myLogger->logme('error', "Policy Premium 2 data removed successfully.");
+ // } else {
+ // $this->myLogger->logme('error', "Policy Premium 2 record does not exist. To delete");
+ // }
+ // } else {
+ // $this->myLogger->logme('error', "Policy Premium 2 data not found.");
+ // }
+
+ // // 10. Notification Model
+ // $notification_data = $this->notificationModel->where('client_id', $client_id)->findAll();
+ // $this->myLogger->logme('error', "Notification data : " . json_encode($notification_data ?? []));
+
+ // if (!empty($notification_data)) {
+ // $is_deleted = $this->notificationModel->where('client_id', $client_id)->delete();
+ // if ($is_deleted) {
+ // $this->myLogger->logme('error', "Notification data removed successfully.");
+ // } else {
+ // $this->myLogger->logme('error', "Notification record does not exist. To delete");
+ // }
+ // } else {
+ // $this->myLogger->logme('error', "Notification data not found.");
+ // }
+
+ // // 11. CD Master Model
+ // $cd_master_data = $this->CDMasterModel->where('client_id', $client_id)->findAll();
+ // $this->myLogger->logme('error', "CD Master data : " . json_encode($cd_master_data ?? []));
+
+ // if (!empty($cd_master_data)) {
+ // $is_deleted = $this->CDMasterModel->where('client_id', $client_id)->delete();
+ // if ($is_deleted) {
+ // $this->myLogger->logme('error', "CD Master data removed successfully.");
+ // } else {
+ // $this->myLogger->logme('error', "CD Master record does not exist. To delete");
+ // }
+ // } else {
+ // $this->myLogger->logme('error', "CD Master data not found.");
+ // }
+
+ // // 12. Policy Transaction Model
+ // $policy_transaction_data = $this->policyTransactionModel->where('client_id', $client_id)->findAll();
+ // $this->myLogger->logme('error', "Policy Transaction data : " . json_encode($policy_transaction_data ?? []));
+
+ // $pt_ids = array_column($policy_transaction_data, 'id') ?? [];
+ // $this->myLogger->logme('error', "Policy Transaction id count : " . count($pt_ids ?? []));
+
+ // if (!empty($policy_transaction_data)) {
+ // $is_deleted = $this->policyTransactionModel->where('client_id', $client_id)->delete();
+ // if ($is_deleted) {
+ // $this->myLogger->logme('error', "Policy Transaction data removed successfully.");
+
+ // if(!empty($pt_ids)){
+
+ // $pt_co_share_data = $this->PTCOShareDetailsModel->whereIn('pt_id', $pt_ids)->findAll();
+ // $this->myLogger->logme('error', "PT CO Share data : " . json_encode($pt_co_share_data ?? []));
+
+ // $is_deleted = $this->PTCOShareDetailsModel->whereIn('pt_id', $pt_ids)->delete();
+ // if ($is_deleted) {
+ // $this->myLogger->logme('error', "PT CO Share data removed successfully.");
+ // } else {
+ // $this->myLogger->logme('error', "PT CO Share record does not exist. To delete");
+ // }
+
+ // }else{
+ // $this->myLogger->logme('error', "PT CO Share data not found.");
+ // }
+
+ // } else {
+ // $this->myLogger->logme('error', "Policy Transaction record does not exist. To delete");
+ // }
+ // } else {
+ // $this->myLogger->logme('error', "Policy Transaction data not found.");
+ // }
+
+ // $this->myLogger->logme('error', "Wipe Demo Client function closed");
+ // return $this->respond(['status' => true, 'message' => 'Demo client data wiped successfully'], 200);
+ // }
+
+ public function wipeDemoClient()
+ {
+ $this->myLogger->logme('error', "========================================");
+ $this->myLogger->logme('error', "WIPE DEMO CLIENT FUNCTION STARTED");
+ $this->myLogger->logme('error', "========================================");
+
+ $this->myLogger->logme('error', "Request Payload: " . json_encode($this->request->getPost() ?? []));
+ $client_id = $this->request->getPost('client_id');
+
+ if (empty($client_id)) {
+ $this->myLogger->logme('error', "ERROR: Client ID is required");
+ return $this->respond(['status' => false, 'message' => 'Client id required'], 404);
+ }
+
+ $this->myLogger->logme('error', "Client ID to wipe: " . $client_id);
+ $this->myLogger->logme('error', "----------------------------------------");
+
+ // ========================================
+ // 1. CLIENT MODEL DELETION
+ // ========================================
+ $this->myLogger->logme('error', "1. PROCESSING CLIENT MODEL");
+ $client_data = $this->clientModel->where('id', $client_id)->where('is_active', 1)->first();
+ $this->myLogger->logme('error', " Found Client Data: " . json_encode($client_data ?? []));
+
+ if (!empty($client_data)) {
+ $is_deleted = $this->clientModel->where('id', $client_id)->delete();
+ if ($is_deleted) {
+ $this->myLogger->logme('error', " ✓ Client data removed successfully");
+ } else {
+ $this->myLogger->logme('error', " ✗ Failed to delete client record");
+ }
+ } else {
+ $this->myLogger->logme('error', " ✗ Client not found or inactive");
+ return $this->respond(['status' => false, 'message' => 'Client not found'], 404);
+ }
+ $this->myLogger->logme('error', "----------------------------------------");
+
+ // ========================================
+ // 2. CLIENT RM MODEL DELETION
+ // ========================================
+ $this->myLogger->logme('error', "2. PROCESSING CLIENT RM MODEL");
+ $client_rm_data = $this->clientRMModel->where('client_id', $client_id)->first();
+ $this->myLogger->logme('error', " Found Client RM Data: " . json_encode($client_rm_data ?? []));
+
+ if (!empty($client_rm_data)) {
+ $is_deleted = $this->clientRMModel->where('client_id', $client_id)->delete();
+ if ($is_deleted) {
+ $this->myLogger->logme('error', " ✓ Client RM data removed successfully");
+ } else {
+ $this->myLogger->logme('error', " ✗ Failed to delete Client RM record");
+ }
+ } else {
+ $this->myLogger->logme('error', " ℹ No Client RM data found");
+ }
+ $this->myLogger->logme('error', "----------------------------------------");
+
+ // ========================================
+ // 3. CLIENT KYC DOCS MODEL DELETION
+ // ========================================
+ $this->myLogger->logme('error', "3. PROCESSING CLIENT KYC DOCS MODEL");
+ $client_kyc_data = $this->clientKYCDocsModel->where('client_id', $client_id)->findAll();
+ $this->myLogger->logme('error', " Found Client KYC Records: " . count($client_kyc_data ?? []));
+ $this->myLogger->logme('error', " Client KYC Data: " . json_encode($client_kyc_data ?? []));
+
+ if (!empty($client_kyc_data)) {
+ $is_deleted = $this->clientKYCDocsModel->where('client_id', $client_id)->delete();
+ if ($is_deleted) {
+ $this->myLogger->logme('error', " ✓ Client KYC Docs data removed successfully");
+ } else {
+ $this->myLogger->logme('error', " ✗ Failed to delete Client KYC Docs records");
+ }
+ } else {
+ $this->myLogger->logme('error', " ℹ No Client KYC Docs data found");
+ }
+ $this->myLogger->logme('error', "----------------------------------------");
+
+ // ========================================
+ // 4. CLIENT BRANCH MODEL DELETION
+ // ========================================
+ $this->myLogger->logme('error', "4. PROCESSING CLIENT BRANCH MODEL");
+ $client_branch_data = $this->clientBranchModel->where('client_id', $client_id)->findAll();
+ $branch_ids = array_column($client_branch_data, 'id') ?? [];
+ $this->myLogger->logme('error', " Found Client Branch Records: " . count($client_branch_data ?? []));
+ $this->myLogger->logme('error', " Branch IDs: " . json_encode($branch_ids));
+ $this->myLogger->logme('error', " Client Branch Data: " . json_encode($client_branch_data ?? []));
+
+ if (!empty($client_branch_data)) {
+ $is_deleted = $this->clientBranchModel->where('client_id', $client_id)->delete();
+ if ($is_deleted) {
+ $this->myLogger->logme('error', " ✓ Client Branch data removed successfully");
+
+ // Delete related Level Contact data
+ if (!empty($branch_ids)) {
+ $this->myLogger->logme('error', " 4a. PROCESSING RELATED LEVEL CONTACT DATA");
+ $level_contact_data = $this->levelContactModel->where('contact_type', 'client')->whereIn('ref_id', $branch_ids)->findAll();
+ $this->myLogger->logme('error', " Found Level Contact Records: " . count($level_contact_data ?? []));
+ $this->myLogger->logme('error', " Level Contact Data: " . json_encode($level_contact_data ?? []));
+
+ $is_deleted = $this->levelContactModel->where('contact_type', 'client')->whereIn('ref_id', $branch_ids)->delete();
+ if ($is_deleted) {
+ $this->myLogger->logme('error', " ✓ Level Contact data removed successfully");
+ } else {
+ $this->myLogger->logme('error', " ✗ Failed to delete Level Contact records");
+ }
+ } else {
+ $this->myLogger->logme('error', " ℹ No Branch IDs available for Level Contact deletion");
+ }
+ } else {
+ $this->myLogger->logme('error', " ✗ Failed to delete Client Branch records");
+ }
+ } else {
+ $this->myLogger->logme('error', " ℹ No Client Branch data found");
+ }
+ $this->myLogger->logme('error', "----------------------------------------");
+
+ // ========================================
+ // 5. CLIENT POLICY MODEL DELETION
+ // ========================================
+ $this->myLogger->logme('error', "5. PROCESSING CLIENT POLICY MODEL");
+ $client_policy_data = $this->clientPolicyModel->where('client_id', $client_id)->findAll();
+ $policy_ids = array_column($client_policy_data, 'id') ?? [];
+ $this->myLogger->logme('error', " Found Client Policy Records: " . count($client_policy_data ?? []));
+ $this->myLogger->logme('error', " Policy IDs: " . json_encode($policy_ids));
+ $this->myLogger->logme('error', " Client Policy Data: " . json_encode($client_policy_data ?? []));
+
+ if (!empty($client_policy_data)) {
+ $is_deleted = $this->clientPolicyModel->where('client_id', $client_id)->delete();
+ if ($is_deleted) {
+ $this->myLogger->logme('error', " ✓ Client Policy data removed successfully");
+
+ // Delete related Employee Policy data
+ if (!empty($policy_ids)) {
+ $this->myLogger->logme('error', " 5a. PROCESSING RELATED EMPLOYEE POLICY DATA");
+ $employee_policy_data = $this->employeePolicyModel->whereIn('client_policy_id', $policy_ids)->findAll();
+ $this->myLogger->logme('error', " Found Employee Policy Records: " . count($employee_policy_data ?? []));
+
+ $is_deleted = $this->employeePolicyModel->whereIn('client_policy_id', $policy_ids)->delete();
+ if ($is_deleted) {
+ $this->myLogger->logme('error', " ✓ Employee Policy data removed successfully");
+ } else {
+ $this->myLogger->logme('error', " ✗ Failed to delete Employee Policy records");
+ }
+ } else {
+ $this->myLogger->logme('error', " ℹ No Policy IDs available for Employee Policy deletion");
+ }
+ } else {
+ $this->myLogger->logme('error', " ✗ Failed to delete Client Policy records");
+ }
+ } else {
+ $this->myLogger->logme('error', " ℹ No Client Policy data found");
+ }
+ $this->myLogger->logme('error', "----------------------------------------");
+
+ // ========================================
+ // 6. EMPLOYEE MODEL DELETION
+ // ========================================
+ $this->myLogger->logme('error', "6. PROCESSING EMPLOYEE MODEL");
+ $employee_data = $this->employeeModel->where('client_id', $client_id)->findAll();
+ $this->myLogger->logme('error', " Found Employee Records: " . count($employee_data ?? []));
+
+ if (!empty($employee_data)) {
+ $is_deleted = $this->employeeModel->where('client_id', $client_id)->delete();
+ if ($is_deleted) {
+ $this->myLogger->logme('error', " ✓ Employee data removed successfully");
+ } else {
+ $this->myLogger->logme('error', " ✗ Failed to delete Employee records");
+ }
+ } else {
+ $this->myLogger->logme('error', " ℹ No Employee data found");
+ }
+ $this->myLogger->logme('error', "----------------------------------------");
+
+ // ========================================
+ // 7. CLIENT DEPOSIT MODEL DELETION
+ // ========================================
+ $this->myLogger->logme('error', "7. PROCESSING CLIENT DEPOSIT MODEL");
+ $client_deposit_data = $this->clientDepositModel->where('client_id', $client_id)->findAll();
+ $this->myLogger->logme('error', " Found Client Deposit Records: " . count($client_deposit_data ?? []));
+ $this->myLogger->logme('error', " Client Deposit Data: " . json_encode($client_deposit_data ?? []));
+
+ if (!empty($client_deposit_data)) {
+ $is_deleted = $this->clientDepositModel->where('client_id', $client_id)->delete();
+ if ($is_deleted) {
+ $this->myLogger->logme('error', " ✓ Client Deposit data removed successfully");
+ } else {
+ $this->myLogger->logme('error', " ✗ Failed to delete Client Deposit records");
+ }
+ } else {
+ $this->myLogger->logme('error', " ℹ No Client Deposit data found");
+ }
+ $this->myLogger->logme('error', "----------------------------------------");
+
+ // ========================================
+ // 8. POLICY PREMIUM 1 MODEL DELETION
+ // ========================================
+ $this->myLogger->logme('error', "8. PROCESSING POLICY PREMIUM 1 MODEL");
+ $policy_premium1_data = $this->policyPremium1Model->where('client_id', $client_id)->findAll();
+ $this->myLogger->logme('error', " Found Policy Premium 1 Records: " . count($policy_premium1_data ?? []));
+
+ if (!empty($policy_premium1_data)) {
+ $is_deleted = $this->policyPremium1Model->where('client_id', $client_id)->delete();
+ if ($is_deleted) {
+ $this->myLogger->logme('error', " ✓ Policy Premium 1 data removed successfully");
+ } else {
+ $this->myLogger->logme('error', " ✗ Failed to delete Policy Premium 1 records");
+ }
+ } else {
+ $this->myLogger->logme('error', " ℹ No Policy Premium 1 data found");
+ }
+ $this->myLogger->logme('error', "----------------------------------------");
+
+ // ========================================
+ // 9. POLICY PREMIUM 2 MODEL DELETION
+ // ========================================
+ $this->myLogger->logme('error', "9. PROCESSING POLICY PREMIUM 2 MODEL");
+ $policy_premium2_data = $this->policyPremium2Model->where('client_id', $client_id)->findAll();
+ $this->myLogger->logme('error', " Found Policy Premium 2 Records: " . count($policy_premium2_data ?? []));
+
+ if (!empty($policy_premium2_data)) {
+ $is_deleted = $this->policyPremium2Model->where('client_id', $client_id)->delete();
+ if ($is_deleted) {
+ $this->myLogger->logme('error', " ✓ Policy Premium 2 data removed successfully");
+ } else {
+ $this->myLogger->logme('error', " ✗ Failed to delete Policy Premium 2 records");
+ }
+ } else {
+ $this->myLogger->logme('error', " ℹ No Policy Premium 2 data found");
+ }
+ $this->myLogger->logme('error', "----------------------------------------");
+
+ // ========================================
+ // 10. NOTIFICATION MODEL DELETION
+ // ========================================
+ $this->myLogger->logme('error', "10. PROCESSING NOTIFICATION MODEL");
+ $notification_data = $this->notificationModel->where('client_id', $client_id)->findAll();
+ $this->myLogger->logme('error', " Found Notification Records: " . count($notification_data ?? []));
+ $this->myLogger->logme('error', " Notification Data: " . json_encode($notification_data ?? []));
+
+ if (!empty($notification_data)) {
+ $is_deleted = $this->notificationModel->where('client_id', $client_id)->delete();
+ if ($is_deleted) {
+ $this->myLogger->logme('error', " ✓ Notification data removed successfully");
+ } else {
+ $this->myLogger->logme('error', " ✗ Failed to delete Notification records");
+ }
+ } else {
+ $this->myLogger->logme('error', " ℹ No Notification data found");
+ }
+ $this->myLogger->logme('error', "----------------------------------------");
+
+ // ========================================
+ // 11. CD MASTER MODEL DELETION
+ // ========================================
+ $this->myLogger->logme('error', "11. PROCESSING CD MASTER MODEL");
+ $cd_master_data = $this->CDMasterModel->where('client_id', $client_id)->findAll();
+ $this->myLogger->logme('error', " Found CD Master Records: " . count($cd_master_data ?? []));
+ $this->myLogger->logme('error', " CD Master Data: " . json_encode($cd_master_data ?? []));
+
+ if (!empty($cd_master_data)) {
+ $is_deleted = $this->CDMasterModel->where('client_id', $client_id)->delete();
+ if ($is_deleted) {
+ $this->myLogger->logme('error', " ✓ CD Master data removed successfully");
+ } else {
+ $this->myLogger->logme('error', " ✗ Failed to delete CD Master records");
+ }
+ } else {
+ $this->myLogger->logme('error', " ℹ No CD Master data found");
+ }
+ $this->myLogger->logme('error', "----------------------------------------");
+
+ // ========================================
+ // 12. POLICY TRANSACTION MODEL DELETION
+ // ========================================
+ $this->myLogger->logme('error', "12. PROCESSING POLICY TRANSACTION MODEL");
+ $policy_transaction_data = $this->policyTransactionModel->where('client_id', $client_id)->findAll();
+ $pt_ids = array_column($policy_transaction_data, 'id') ?? [];
+ $this->myLogger->logme('error', " Found Policy Transaction Records: " . count($policy_transaction_data ?? []));
+ $this->myLogger->logme('error', " Policy Transaction IDs: " . json_encode($pt_ids));
+ $this->myLogger->logme('error', " Policy Transaction Data: " . json_encode($policy_transaction_data ?? []));
+
+ if (!empty($policy_transaction_data)) {
+ $is_deleted = $this->policyTransactionModel->where('client_id', $client_id)->delete();
+ if ($is_deleted) {
+ $this->myLogger->logme('error', " ✓ Policy Transaction data removed successfully");
+
+ // Delete related PT CO Share data
+ if (!empty($pt_ids)) {
+ $this->myLogger->logme('error', " 12a. PROCESSING RELATED PT CO SHARE DATA");
+ $pt_co_share_data = $this->PTCOShareDetailsModel->whereIn('pt_id', $pt_ids)->findAll();
+ $this->myLogger->logme('error', " Found PT CO Share Records: " . count($pt_co_share_data ?? []));
+ $this->myLogger->logme('error', " PT CO Share Data: " . json_encode($pt_co_share_data ?? []));
+
+ $is_deleted = $this->PTCOShareDetailsModel->whereIn('pt_id', $pt_ids)->delete();
+ if ($is_deleted) {
+ $this->myLogger->logme('error', " ✓ PT CO Share data removed successfully");
+ } else {
+ $this->myLogger->logme('error', " ✗ Failed to delete PT CO Share records");
+ }
+ } else {
+ $this->myLogger->logme('error', " ℹ No Policy Transaction IDs available for PT CO Share deletion");
+ }
+ } else {
+ $this->myLogger->logme('error', " ✗ Failed to delete Policy Transaction records");
+ }
+ } else {
+ $this->myLogger->logme('error', " ℹ No Policy Transaction data found");
+ }
+
+ $this->myLogger->logme('error', "========================================");
+ $this->myLogger->logme('error', "WIPE DEMO CLIENT FUNCTION COMPLETED");
+ $this->myLogger->logme('error', "Client ID: " . $client_id . " - Successfully processed");
+ $this->myLogger->logme('error', "========================================");
+
+ return $this->respond(['status' => true, 'message' => 'Demo client data wiped successfully'], 200);
+ }
}
diff --git a/app/Controllers/EmpDataServiceController.php b/app/Controllers/EmpDataServiceController.php
index 9d3eeecf..6da138fd 100755
--- a/app/Controllers/EmpDataServiceController.php
+++ b/app/Controllers/EmpDataServiceController.php
@@ -199,13 +199,21 @@ class EmpDataServiceController extends BaseController
$totals = round($totals, 2);
- if($export_data['insurer_or_tpa'] == 'insurer') //check CD amt related issue for only insurer, not tpa
+ //check CD amt insufficient only insurer, not tpa // DO NOT REMOVE THIS
+ if($export_data['insurer_or_tpa'] == 'insurer')
{
if (!empty($cash_balance)) {
if ((int) $cash_balance['balance'] < (int) $totals) {
$this->myLogger->logme('error', 'Inception export failed due to insufficient deposit amount.');
$this->myLogger->logme('error', 'Inception export failed due to insufficient deposit amount. CASH BALANCE : {balance} and TOTAL AMOUNT : {total}', ['balance' => $cash_balance['balance'], 'total' => $totals]);
- return 0;
+ session()->set('cd_balance', false);
+ session()->set('cd_amount', $cash_balance['balance']);
+ session()->set('excel_file_amt', $totals);
+ }else{
+ session()->set('cd_balance', true);
+ session()->set('cd_amount', $cash_balance['balance']);
+ session()->set('excel_file_amt', $totals);
+
}
}
}
@@ -700,13 +708,21 @@ class EmpDataServiceController extends BaseController
// echo '
';
// print_r($ids); die;
- if($export_data['insurer_or_tpa'] == 'insurer') //check CD amt related issue for only insurer, not tpa
+ //check CD amt insufficiend for only insurer, not tpa // DO NOT REMOVE THIS
+ if($export_data['insurer_or_tpa'] == 'insurer')
{
if (!empty($cash_balance)) {
if ((int) $cash_balance['balance'] < (int) $rounded_totals) {
$this->myLogger->logme('error', 'Inception export failed due to insufficient deposit amount.');
$this->myLogger->logme('error', 'Inception export failed due to insufficient deposit amount. CASH BALANCE : {balance} and TOTAL AMOUNT : {total}', ['balance' => $cash_balance['balance'], 'total' => $totals]);
- return 0;
+ session()->set('cd_balance', false);
+ session()->set('cd_amount', $cash_balance['balance']);
+ session()->set('excel_file_amt', $rounded_totals);
+ }else{
+ session()->set('cd_balance', true);
+ session()->set('cd_amount', $cash_balance['balance']);
+ session()->set('excel_file_amt', $rounded_totals);
+
}
}
}
@@ -1003,22 +1019,29 @@ class EmpDataServiceController extends BaseController
$cash_balance['balance'] = $balance['opening_bal'];
}
+ // Calculate the total amount from the objects
+ $totals = 0;
+ foreach ($inceptionData as $item) {
+ $totals = $totals + $item->total;
+ }
-
- // Calculate the total amount from the objects
- $totals = 0;
- foreach ($inceptionData as $item) {
- $totals = $totals + $item->total;
- }
$totals = round($totals, 2);
- if($export_data['insurer_or_tpa'] != 'tpa')// check overal emp premium amt with cd balance only for insurer export, not tpa export
+
+ if($export_data['insurer_or_tpa'] != 'tpa')// check overal emp premium amt with cd balance only for insurer export, not tpa export
{
if (!empty($cash_balance)) {
if ((int) $cash_balance['balance'] < (int) $totals) {
$this->myLogger->logme('error', 'Inception export failed due to insufficient deposit amount.');
$this->myLogger->logme('error', 'Inception export failed due to insufficient deposit amount. CASH BALANCE : {balance} and TOTAL AMOUNT : {total}', ['balance' => $cash_balance['balance'], 'total' => $totals]);
- return 0;
+ session()->set('cd_balance', false);
+ session()->set('cd_amount', $cash_balance['balance']);
+ session()->set('excel_file_amt', $totals);
+ }else{
+ session()->set('cd_balance', true);
+ session()->set('cd_amount', $cash_balance['balance']);
+ session()->set('excel_file_amt', $totals);
+
}
}
}
@@ -1359,6 +1382,8 @@ class EmpDataServiceController extends BaseController
$batch_code = $file['batch_code'];
$user_id = $file['created_by'];
+ $client_policy_data = $this->clientPolicyModel->where('id', $client_policy_id)->first();
+
$insurer_or_tpa = $file['insurer_or_tpa'];
if ($insurer_or_tpa == 'tpa') {
$id = 'tpa_id';
@@ -1516,37 +1541,40 @@ class EmpDataServiceController extends BaseController
//--- TPA ID Duplicate check start ---
- $current_tpa_id = $excel_data[$key][13];
+ // Duplicate checking for only GMC's and GPA
+ if(in_array($client_policy_data['policy_type_id'], [1,2,3,4,5])){
+ $current_tpa_id = $excel_data[$key][13];
- if (isset($tpa_id_all[$current_tpa_id])) {
+ if (isset($tpa_id_all[$current_tpa_id])) {
- // Add the current row to errors
- $errors[$key][] = [
- 'row' => $key,
- 'column' => 13,
- 'db_data' => "Duplicate TPA ID Found",
- 'excel_data' => $current_tpa_id
- ];
-
- // Add all existing rows with the same TPA ID to errors
- foreach ($tpa_id_all[$current_tpa_id] as $existing_row) {
- $errors[$existing_row][] = [
- 'row' => $existing_row,
+ // Add the current row to errors
+ $errors[$key][] = [
+ 'row' => $key,
'column' => 13,
'db_data' => "Duplicate TPA ID Found",
'excel_data' => $current_tpa_id
];
- }
+
+ // Add all existing rows with the same TPA ID to errors
+ foreach ($tpa_id_all[$current_tpa_id] as $existing_row) {
+ $errors[$existing_row][] = [
+ 'row' => $existing_row,
+ 'column' => 13,
+ 'db_data' => "Duplicate TPA ID Found",
+ 'excel_data' => $current_tpa_id
+ ];
+ }
- } else {
- if($current_tpa_id != "" && $current_tpa_id != null){
- $tpa_id_all[$current_tpa_id][] = $key;
- }
+ } else {
+ if($current_tpa_id != "" && $current_tpa_id != null){
+ $tpa_id_all[$current_tpa_id][] = $key;
+ }
+ }
}
//--- TPA ID Duplicate check end ---
- if ($insurer_or_tpa == 'tpa') {
+ if ($insurer_or_tpa == 'tpa' && in_array($client_policy_data['policy_type_id'], [1,2,3,4,5])) {
if ($excel_data[$key][13] === null) {
$missing_id[$key][] = [
@@ -1688,7 +1716,7 @@ class EmpDataServiceController extends BaseController
];
}
- if ($insurer_or_tpa == 'tpa') {
+ if ($insurer_or_tpa == 'tpa' && in_array($client_policy_data['policy_type_id'], [1,2,3,4,5])) {
if ($emp_value['uhid'] != $excel_data[$key][14]) {
$errors[$key][] = [
@@ -1699,7 +1727,7 @@ class EmpDataServiceController extends BaseController
];
}
- } else if ($insurer_or_tpa == 'insurer') {
+ } else if ($insurer_or_tpa == 'insurer' && in_array($client_policy_data['policy_type_id'], [1,2,3,4,5])) {
if ($emp_value['tpa_id'] != $excel_data[$key][13]) {
$errors[$key][] = [
diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php
index 512122c6..dd80cd05 100755
--- a/app/Controllers/EmployeeController.php
+++ b/app/Controllers/EmployeeController.php
@@ -302,9 +302,11 @@ class EmployeeController extends AdminController
//for TPA/insurer upload
$data['events'] = ['inception' => 'Inception (Employee + Dependents)', 'missed_inception' => 'Missed Inception (Employee + Dependents)', 'addition' => 'Addition (Employee + Dependents)', 'dependent_addition' => 'Dependent Addition (Only Dependents)', 'deletion' => 'Deletion', 'correction' => 'Correction', 'si_enhancement' => 'SI Enhancement'];
//for inception upload
- $data['actions'] = ['inception' => 'Inception (Employee + Dependents)', 'missed_inception' => 'Missed Inception (Employee + Dependents)', 'addition' => 'Addition (Employee + Dependents)', 'dependent_addition' => 'Dependent Addition (Only Dependents)', 'deletion' => 'Deletion', 'correction' => 'Correction', 'si_enhancement' => 'SI Enhancement','enrollment' => 'Enrolment'];
-
- $data['import_or_export'] = ['import' => 'Import', 'export' => 'Export'];
+ $data['actions'] = ['inception' => 'Inception (Employee + Dependents)', 'missed_inception' => 'Missed Inception (Employee + Dependents)', 'addition' => 'Addition (Employee + Dependents)', 'dependent_addition' => 'Dependent Addition (Only Dependents)', 'deletion' => 'Deletion', 'correction' => 'Correction', 'si_enhancement' => 'SI Enhancement'];
+ // $data['actions'] = ['inception' => 'Inception (Employee + Dependents)', 'missed_inception' => 'Missed Inception (Employee + Dependents)', 'addition' => 'Addition (Employee + Dependents)', 'dependent_addition' => 'Dependent Addition (Only Dependents)', 'deletion' => 'Deletion', 'correction' => 'Correction', 'si_enhancement' => 'SI Enhancement','enrollment' => 'Enrolment'];
+
+ // $data['import_or_export'] = ['import' => 'Import', 'export' => 'Export'];
+ $data['import_or_export'] = ['import' => 'Upload', 'export' => 'Download'];
$data['insurer_or_tpa'] = ['insurer' => 'Insurer', 'tpa' => 'TPA'];
// $data['fileList'] = $this->fileModel
diff --git a/app/Controllers/EmployeeServiceController.php b/app/Controllers/EmployeeServiceController.php
index 938c9099..2cc47520 100755
--- a/app/Controllers/EmployeeServiceController.php
+++ b/app/Controllers/EmployeeServiceController.php
@@ -1319,6 +1319,7 @@ class EmployeeServiceController extends AdminController
//get file name
$file_id = $params['file_id'];
$file = $this->fileModel->find($file_id);
+ // dd($file);
$file_name_with_path = WRITEPATH."/uploads/excel/".$file['file_name'];
@@ -1330,6 +1331,7 @@ class EmployeeServiceController extends AdminController
$excel_data = $sheet->rangeToArray('A1:' . $allowedHighestColumn['col_cell_name'] . $highestRowAndColumn['row']);
// $excel_data = $sheet->rangeToArray('A1:' . $highestRowAndColumn['column'] . $highestRowAndColumn['row']);
+ // dd($excel_data);
unset($excel_data[0]);
// kint::dump($excel_data);
$endorsement_data = [];
@@ -1379,10 +1381,14 @@ class EmployeeServiceController extends AdminController
->where('employee_polices.client_policy_id',$file['policy_id'])
->where('employees.emp_status !=','truncated')
->where('employees.is_active', 1)
+ ->where('employee_polices.status !=','truncated')
+ ->where('employee_polices.is_active', 1)
->first();
// $employee = $this->employeeModel->where('emp_code', $row[1])->where('name',$row[2])->where('client_id',$file['client_id'])->first();
// dd($employee);
+ // kint::dump($employee);
+
if(is_array($employee) && count($employee))
{
// dd($employee);
@@ -1406,7 +1412,13 @@ class EmployeeServiceController extends AdminController
if(!in_array($employee['id'],$endorsement_data))//make entry in endorsement firsttime only with checking that PK of emp exisintg in variable $endorsement_data
{
- $employee_policy = $this->employeePolicyModel->where('employee_id',$employee['id'])->where('client_policy_id',$file['policy_id'])->first();
+ $employee_policy = $this->employeePolicyModel
+ ->where('employee_id',$employee['id'])
+ ->where('client_policy_id',$file['policy_id'])
+ ->where('status !=','truncated')
+ ->where('is_active', 1)
+ ->first();
+
$data = ['emp_id' => $employee['id'],'name' => $employee['name'],'emp_status' => $employee['emp_status'],'emp_policy_id' => $employee_policy['id'],'emp_code' => $employee['emp_code'],'change_event' => $employee['change_event'],'date_of_exit' => $employee_policy['date_of_exit'],'reason_for_exit' => $employee_policy['reason_for_exit'],'status' => $employee_policy['status'],'claim_status' => $employee_policy['claim_status']];
$endorsement($data,$file,$row);
$endorsement_data[] = $employee['id'];
@@ -1447,7 +1459,7 @@ class EmployeeServiceController extends AdminController
//set success msg to pull notifications
$this->setPullNotification($this->getFileMetaDataByFileId($file_id,'success'));
- return $endorsement_data;
+ return $endorsement_data;
}
diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php
index 174bad00..178b5599 100644
--- a/app/Controllers/LeadsController.php
+++ b/app/Controllers/LeadsController.php
@@ -207,6 +207,8 @@ class LeadsController extends BaseController
private function prepareLeadData()
{
$data = $this->request->getPost();
+ $data['client_type'] = 1;
+ $data['pan'] = "";
if ($data['lead_type'] != 1) {
$client_data = $this->clientModel->where('id', $data['client_id'])->where('is_active', 1)->first();
diff --git a/app/Controllers/MasterController.php b/app/Controllers/MasterController.php
index 0a3c357d..61c5aedf 100755
--- a/app/Controllers/MasterController.php
+++ b/app/Controllers/MasterController.php
@@ -1225,53 +1225,204 @@ class MasterController extends AdminController
$data['page_name'] = 'CD Master List';
$data['CD_Master_Data'] = $this->CDMasterModel->getCDMasterList();
$data['insurers'] = $this->insurerModel->where('is_active', 1)->findAll();
+ $data['insurer_branch'] = $this->insurerBranchModel->where('is_active', 1)->findAll();
$data['clients'] = $this->clientModel->where('is_active', 1)->findAll();
$this->loadLayout('cd_master_list', $data);
}
- public function createCDMasterData()
- {
+ // public function createCDMasterData()
+ // {
+ // $data = $this->request->getPost();
+ // $id = $data['PrimaryKey'];
+ // $date = (string) $this->request->getPost('opening_date');
+ // $data['opening_date'] = date('Y-m-d', strtotime($date));
+ // // print_rr($data);die();
+
+ // $loggedInUserID = get_session_userid();
+
+ // if (empty($id)) {
+
+ // if ($data) {
+
+ // $insert = $this->CDMasterModel->insert($data);
+
+ // if ($insert) {
+
+ // // Prepare the array with data
+ // $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' => $data['insurer_id'],
+ // 'description' => 'opening Amount',
+ // 'transaction_type' => 'Credit',
+ // 'event_name' => null,
+ // 'updated_by' => 1,
+ // ];
+
+ // $cd_tranction_data['cd_ac_pk'] = $this->CDMasterModel->insertID();
+ // $response = DepositHelper::saveDeposit($cd_tranction_data, $loggedInUserID);
+
+ // session()->setFlashdata('success', "Cash Deposite Master Added Successfully");
+ // return redirect()->to(base_url('/master/cash_deposite/list'));
+ // } else {
+
+ // session()->setFlashdata('error', "Cash Deposite Master Added Failed");
+ // return redirect()->to(base_url('/master/cash_deposite/list'));
+ // }
+ // } else {
+
+ // session()->setFlashdata('error', "Cash Deposite Master Added Failed. Data Not Found");
+ // return redirect()->to(base_url('/master/cash_deposite/list'));
+ // }
+
+ // } else {
+
+ // if ($data) {
+
+ // $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']
+ // ];
+
+ // $cd_tranction = $this->clientDepositModel
+ // ->where('client_id', $data['client_id'])
+ // ->where('insurer_id', $data['insurer_id'])
+ // ->where('cd_ac_no', $data['cd_ac_no'])
+ // ->where('sub_type', 7)
+ // ->set($cd_transaction_updated_data)->update();
+
+ // if ($insert) {
+
+ // session()->setFlashdata('success', "Cash Deposite Master Updated Successfully");
+ // return redirect()->to(base_url('/master/cash_deposite/list'));
+ // } else {
+
+ // session()->setFlashdata('error', "Cash Deposite Master Update Failed");
+ // return redirect()->to(base_url('/master/cash_deposite/list'));
+ // }
+ // } else {
+
+ // session()->setFlashdata('error', "Cash Deposite Master Update Failed. Data Not Found");
+ // return redirect()->to(base_url('/master/cash_deposite/list'));
+ // }
+ // }
+ // }
+
+ public function createCDMasterData()
+ {
+ $this->myLogger->logme("error", 'Create CD Master Data API called.');
$data = $this->request->getPost();
- $date = (string) $this->request->getPost('opening_date');
+ $this->myLogger->logme("error", 'Received POST data: ' . json_encode($data));
+
+ $id = $data['PrimaryKey'] ?? null;
+ $date = (string) ($data['opening_date'] ?? '');
$data['opening_date'] = date('Y-m-d', strtotime($date));
- // print_rr($data);die();
- // Prepare the array with data
- $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' => $data['insurer_id'],
- 'description' => 'opening Amount',
- 'transaction_type' => 'Credit',
- 'event_name' => null,
- 'updated_by' => 1,
- ];
+ $this->myLogger->logme("error", 'Formatted opening_date: ' . $data['opening_date']);
$loggedInUserID = get_session_userid();
-
- if ($data) {
+ $this->myLogger->logme("error", 'Logged in user ID: ' . $loggedInUserID);
+ // === INSERT ===
+ if (empty($id)) {
+
+ $this->myLogger->logme("error", 'Performing INSERT operation.');
$insert = $this->CDMasterModel->insert($data);
+ $this->myLogger->logme("error", 'Insert result: ' . json_encode($insert));
if ($insert) {
- $cd_tranction_data['cd_ac_pk'] = $this->CDMasterModel->insertID();
- $response = DepositHelper::saveDeposit($cd_tranction_data, $loggedInUserID);
- session()->setFlashdata('success', "Cash Deposite Master Added Successfully");
- return redirect()->to(base_url('/master/cash_deposite/list'));
+ $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' => $data['insurer_id'],
+ 'description' => 'Opening Amount',
+ 'transaction_type' => 'Credit',
+ 'event_name' => null,
+ 'updated_by' => 1,
+ 'cd_ac_pk' => $insert,
+ ];
+
+ $this->myLogger->logme("error", 'Saving initial deposit with data: ' . json_encode($cd_tranction_data));
+ $response = DepositHelper::saveDeposit($cd_tranction_data, $loggedInUserID);
+ $this->myLogger->logme("error", 'Deposit save response: ' . json_encode($response));
+
+ $cd_master_data = $this->CDMasterModel->where('is_active', 1)->where('id', $insert)->first();
+ $this->myLogger->logme("error", 'Inserted CD Master data: ' . json_encode($cd_master_data));
+
+ $cd_master_full_data = $this->CDMasterModel->where('is_active', 1)
+ ->where('client_id', $data['client_id'])
+ ->where('insurer_id', $data['insurer_id'])
+ ->where('insurer_branch_id', $data['insurer_branch_id'])
+ ->findAll();
+
+ return $this->respond([
+ 'status' => true,
+ 'code' => 500,
+ 'message' => "CD Master Added Successfully",
+ 'cd_master_data' => $cd_master_data,
+ 'data' => $cd_master_full_data
+ ]);
+
} else {
- session()->setFlashdata('error', "Cash Deposite Master Added Failed");
- return redirect()->to(base_url('/master/cash_deposite/list'));
+ $this->myLogger->logme('error', 'CD Master Insert Failed.');
+ return $this->respond([
+ 'status' => true,
+ 'code' => 500,
+ 'message' => "CD Master Add Failed",
+ ], 200);
}
- } else {
+ }
- session()->setFlashdata('error', "Cash Deposite Master Added Failed. Data Not Found");
- return redirect()->to(base_url('/master/cash_deposite/list'));
+ // === UPDATE ===
+ $this->myLogger->logme("error", 'Performing UPDATE operation for ID: ' . $id);
+
+ $updated = $this->CDMasterModel->where('id', $id)->set($data)->update();
+ $this->myLogger->logme("error", 'Update result: ' . json_encode($updated));
+
+ $existingData = $this->CDMasterModel->where('is_active', 1)->where('id', $id)->first();
+ $this->myLogger->logme("error", 'Existing data after update: ' . json_encode($existingData));
+
+ $cd_transaction_updated_data = [
+ 'balance' => $existingData['opening_bal'],
+ 'amount' => $existingData['opening_bal']
+ ];
+
+ $updateDeposit =$this->clientDepositModel
+ ->where('client_id', $existingData['client_id'])
+ ->where('insurer_id', $existingData['insurer_id'])
+ ->where('cd_ac_no', $existingData['cd_ac_no'])
+ ->where('sub_type', 7)
+ ->set($cd_transaction_updated_data)
+ ->update();
+ $this->myLogger->logme("error", 'Client Deposit Update result: ' . json_encode($updateDeposit));
+
+ if ($updated) {
+ $this->myLogger->logme("error", 'CD Master Updated Successfully.');
+ return $this->respond([
+ 'status' => true,
+ 'message' => "CD Master Updated Successfully"
+ ]);
+ } else {
+ $this->myLogger->logme('error', 'CD Master Update Failed.');
+ return $this->respond([
+ 'status' => true,
+ 'code' => 500,
+ 'message' => "CD Master Updated Failed",
+ ], 200);
}
}
@@ -1598,7 +1749,6 @@ class MasterController extends AdminController
}
}
-
public function generateNewGmailAPIToken()
{
$gmailapi = \Config\Services::gmailapi();
@@ -1609,49 +1759,46 @@ class MasterController extends AdminController
//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');
- $common = ['mail_type'=>'test_mail_ui'];
- /*****CHOOSE ANY ONE AT A TIME, COMMENT ANOTHER ONE******/
+ if ($this->request->getMethod() == 'post') {
+ // $gmailapi = \Config\Services::gmailapi();
- /*****CALLING DIRECLT USING LIB******/
- // $res = $gmailapi->sendMessage($to, $subject, $mail_content, 'info@nhanceindia.in', 'info@nhanceindia.in', $cc = [], $bcc = []);
+ $to = $this->request->getPost('to');
+ $subject = $this->request->getPost('subject');
+ $mail_content = $this->request->getPost('content');
+ $common = ['mail_type' => 'test_mail_ui'];
+ /*****CHOOSE ANY ONE AT A TIME, COMMENT ANOTHER ONE******/
- // 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 DIRECLT USING LIB******/
+ // $res = $gmailapi->sendMessage($to, $subject, $mail_content, 'info@nhanceindia.in', 'info@nhanceindia.in', $cc = [], $bcc = []);
- /*****CALLING VIA MAIL HELPER******/
- $res = MailHelper::send_email(['mail' => $to, 'subject' => $subject,'common'=>$common ,'message' => $mail_content]);
- return $this->respond(['status' => 'success','code' => 200,'data' => $res],200);
- /*****CALLING VIA MAIL HELPER******/
+ // 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, 'common' => $common, '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
+
+ //testing a sample mail from cli
public function testGmailAPIViaCLI(string $email_id = 'velmurugan.s@venbainfotech.com')
{
-
+
$email_id = CLI::getOption('to') ? CLI::getOption('to') : $email_id;
// print_r($email_id);die();
- // $gmailapi = \Config\Services::gmailapi();
- $message = 'Dear {{RECIPIENT_NAME}},
We are reaching out to request a quotation for the following insurance coverage. Please review the details below and provide your quote at your earliest convenience.
RFQ Details
| Client name | {{CLIENT_NAME}} |
|---|
| Coverage Type | {{POLICY_LONG_NAME}} |
|---|
| Policy Start Date | {{POLICY_START_DATE}} |
|---|
| Policy Duration | {{DURATION}} |
|---|
Please note: Additional terms and details are included in the attachment for your reference.
Please feel free to reach out if you require any further information to prepare the quote. We look forward to receiving your proposal.
Best regards,
Nhance India Pvt Ltd
';
+ // $gmailapi = \Config\Services::gmailapi();
+ $message = 'Dear {{RECIPIENT_NAME}},
We are reaching out to request a quotation for the following insurance coverage. Please review the details below and provide your quote at your earliest convenience.
RFQ Details
| Client name | {{CLIENT_NAME}} |
|---|
| Coverage Type | {{POLICY_LONG_NAME}} |
|---|
| Policy Start Date | {{POLICY_START_DATE}} |
|---|
| Policy Duration | {{DURATION}} |
|---|
Please note: Additional terms and details are included in the attachment for your reference.
Please feel free to reach out if you require any further information to prepare the quote. We look forward to receiving your proposal.
Best regards,
Nhance India Pvt Ltd
';
// $attachments = [
// ["filePath" => WRITEPATH."uploads/excel/sample/correction.xls","fileName" => "correction.xls"],
@@ -1661,34 +1808,34 @@ class MasterController extends AdminController
// ];
$attachments = [
- ["filePath" => ROOTPATH."public/sample_excel/sample_addition.xls","fileName" => "sample_addition.xls"],
- ["filePath" => ROOTPATH."public/sample_excel/sample_inception.xls","fileName" => "sample_inception.xls"],
- ["filePath" => ROOTPATH."public/assets/images/login_bg.jpg","fileName" => "login_bg.jpg"]
+ ["filePath" => ROOTPATH . "public/sample_excel/sample_addition.xls", "fileName" => "sample_addition.xls"],
+ ["filePath" => ROOTPATH . "public/sample_excel/sample_inception.xls", "fileName" => "sample_inception.xls"],
+ ["filePath" => ROOTPATH . "public/assets/images/login_bg.jpg", "fileName" => "login_bg.jpg"]
];
- $common = ['mail_type'=>'test_mail_cli'];
+ $common = ['mail_type' => 'test_mail_cli'];
$email_id = CLI::getOption('to') ? CLI::getOption('to') : $email_id;
- $res = MailHelper::send_email(['mail' => $email_id, 'subject' => 'Mail Via CLI', 'message' => $message,'attachments' => $attachments,'common'=>$common]);
- echo "Inside the master controller";
- print_r($res);
-
+ $res = MailHelper::send_email(['mail' => $email_id, 'subject' => 'Mail Via CLI', 'message' => $message, 'attachments' => $attachments, 'common' => $common]);
+ echo "Inside the master controller";
+ print_r($res);
}
- public function testZeptoSMTP() {
+ public function testZeptoSMTP()
+ {
$message = 'Dear {{RECIPIENT_NAME}},
We are reaching out to request a quotation for the following insurance coverage. Please review the details below and provide your quote at your earliest convenience.
RFQ Details
| Client name | {{CLIENT_NAME}} |
|---|
| Coverage Type | {{POLICY_LONG_NAME}} |
|---|
| Policy Start Date | {{POLICY_START_DATE}} |
|---|
| Policy Duration | {{DURATION}} |
|---|
Please note: Additional terms and details are included in the attachment for your reference.
Please feel free to reach out if you require any further information to prepare the quote. We look forward to receiving your proposal.
Best regards,
Nhance India Pvt Ltd
';
$attachments = [
- ["filePath" => ROOTPATH."public/sample_excel/sample_addition.xls","fileName" => "sample_addition.xls"],
- ["filePath" => ROOTPATH."public/sample_excel/sample_inception.xls","fileName" => "sample_inception.xls"],
- ["filePath" => ROOTPATH."public/assets/images/login_bg.jpg","fileName" => "login_bg.jpg"]
+ ["filePath" => ROOTPATH . "public/sample_excel/sample_addition.xls", "fileName" => "sample_addition.xls"],
+ ["filePath" => ROOTPATH . "public/sample_excel/sample_inception.xls", "fileName" => "sample_inception.xls"],
+ ["filePath" => ROOTPATH . "public/assets/images/login_bg.jpg", "fileName" => "login_bg.jpg"]
];
- $email_id = ['srinivas.saravanan@venbainfotech.com','srinivassaravanan2002@gmail.com'];
- $params = ['mail'=>$email_id];
- $common = ['mail_type'=>'test_mail_cli'];
+ $email_id = ['srinivas.saravanan@venbainfotech.com', 'srinivassaravanan2002@gmail.com'];
+ $params = ['mail' => $email_id];
+ $common = ['mail_type' => 'test_mail_cli'];
// $bcc = "vijayalakshmi@nhanceindia.in,vitvelz@gmail.com,velmurugan.s@venbainfotech.com,hariharan@nhanceindia.in,hariharan@jubiliant.in,srinivas.saravanan@venbainfotech.com";
// Send email and get response
- $result = MailHelper::send_email(['mail' => $email_id, 'params'=>$params,'subject' => 'Mail Via CLI','message' => $message,'attachments' => $attachments,'common'=>$common]);
-
+ $result = MailHelper::send_email(['mail' => $email_id, 'params' => $params, 'subject' => 'Mail Via CLI', 'message' => $message, 'attachments' => $attachments, 'common' => $common]);
- log_message('error',json_encode($result));
+
+ log_message('error', json_encode($result));
// Format the response for display/debugging
$response = [
'success' => $result['success'] ?? false,
@@ -1703,15 +1850,16 @@ class MasterController extends AdminController
// Return JSON response
return $this->response->setJSON($result);
}
+
public function testCheckBounceMails()
{
- $gmailapi = \Config\Services::gmailapi();
- $from_date = CLI::getOption('from') ? CLI::getOption('from') : null;
- $to_date = CLI::getOption('to') ? CLI::getOption('to') : null;
- $count = CLI::getOption('count') ? CLI::getOption('count') : null;
- $page = CLI::getOption('page') ? CLI::getOption('page') : null;
- $res = $gmailapi->checkBounceStatus(from_date:$from_date,to_date:$to_date,count:$count,page:$page);
- print_r($res);
+ $gmailapi = \Config\Services::gmailapi();
+ $from_date = CLI::getOption('from') ? CLI::getOption('from') : null;
+ $to_date = CLI::getOption('to') ? CLI::getOption('to') : null;
+ $count = CLI::getOption('count') ? CLI::getOption('count') : null;
+ $page = CLI::getOption('page') ? CLI::getOption('page') : null;
+ $res = $gmailapi->checkBounceStatus(from_date: $from_date, to_date: $to_date, count: $count, page: $page);
+ print_r($res);
}
public function appCheckList()
@@ -1721,7 +1869,6 @@ class MasterController extends AdminController
$this->checkGoogleOAuthCredentialsinDB();
$this->getCronJobsList();
$this->checkGdriveRootFolderID();
-
}
public function checkAndCreateDirectories()
@@ -1740,7 +1887,7 @@ class MasterController extends AdminController
'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
+ '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/',
'attachments' => WRITEPATH . 'uploads/attachments/',
@@ -1776,21 +1923,18 @@ class MasterController extends AdminController
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 --to someone@gmail.com' to send test mail to testGmailAPIViaCLI ( replace someone@gmail.com with real time mail).\n";
- }
- else
- {
+ } 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
@@ -1806,7 +1950,7 @@ class MasterController extends AdminController
} elseif ($output) {
// Return the cron job list
echo nl2br($output);
- echo "\n" ;// Convert newlines to
for easier HTML rendering
+ echo "\n"; // Convert newlines to
for easier HTML rendering
} else {
echo "Error retrieving cron jobs or no cron jobs set.\n";
}
@@ -1818,13 +1962,10 @@ class MasterController extends AdminController
{
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";
+ 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";
}
@@ -1834,16 +1975,16 @@ class MasterController extends AdminController
$message = 'Dear {{RECIPIENT_NAME}},
We are reaching out to request a quotation for the following insurance coverage. Please review the details below and provide your quote at your earliest convenience.
RFQ Details
| Client name | {{CLIENT_NAME}} |
|---|
| Coverage Type | {{POLICY_LONG_NAME}} |
|---|
| Policy Start Date | {{POLICY_START_DATE}} |
|---|
| Policy Duration | {{DURATION}} |
|---|
Please note: Additional terms and details are included in the attachment for your reference.
Please feel free to reach out if you require any further information to prepare the quote. We look forward to receiving your proposal.
Best regards,
Nhance India Pvt Ltd
';
$attachments = [
- ["filePath" => ROOTPATH."public/sample_excel/sample_addition.xls","fileName" => "sample_addition.xls"],
- ["filePath" => ROOTPATH."public/sample_excel/sample_inception.xls","fileName" => "sample_inception.xls"],
- ["filePath" => ROOTPATH."public/assets/images/login_bg.jpg","fileName" => "login_bg.jpg"]
+ ["filePath" => ROOTPATH . "public/sample_excel/sample_addition.xls", "fileName" => "sample_addition.xls"],
+ ["filePath" => ROOTPATH . "public/sample_excel/sample_inception.xls", "fileName" => "sample_inception.xls"],
+ ["filePath" => ROOTPATH . "public/assets/images/login_bg.jpg", "fileName" => "login_bg.jpg"]
];
$email_id = 'venkateshraman786@gmail.com';
- $params = ['mail'=>$email_id];
+ $params = ['mail' => $email_id];
$multi_mails = ['venkateshraman786@gmail.com', 'gowtham.manavalan.la@gmail.com', 'venkatesh.r@venbainfotech.com'];
- $common = ['mail_type'=>'test_mail_cli'];
+ $common = ['mail_type' => 'test_mail_cli'];
$bcc = "vitvelz@gmail.com,velmurugan.s@venbainfotech.com,srinivas.saravanan@venbainfotech.com";
- $result = MailHelper::send_email(['mail' => $multi_mails, 'bcc'=>$bcc, 'params'=>$params,'subject' => 'Send Multiple " To " emails','message' => $message,'attachments' => $attachments,'common'=>$common]);
+ $result = MailHelper::send_email(['mail' => $multi_mails, 'bcc' => $bcc, 'params' => $params, 'subject' => 'Send Multiple " To " emails', 'message' => $message, 'attachments' => $attachments, 'common' => $common]);
dd($result);
}
diff --git a/app/Controllers/RestAuthenticationController.php b/app/Controllers/RestAuthenticationController.php
index 0c2089b6..b2567d9c 100755
--- a/app/Controllers/RestAuthenticationController.php
+++ b/app/Controllers/RestAuthenticationController.php
@@ -484,7 +484,7 @@ class RestAuthenticationController extends AdminController
$this->authHistoryModel->insert($data);
}
-
+ $employeeData['token_type'] = "post";
$result = JWTToken::encode($employeeData);
if(isset($this->request->getJSON()->otp)){
@@ -1081,6 +1081,7 @@ class RestAuthenticationController extends AdminController
]);
}
+ $employeeData['token_type'] = "post";
$token = JWTToken::encode($employeeData);
log_message('error', ' ');
diff --git a/app/Controllers/TicketController.php b/app/Controllers/TicketController.php
index 68122d7a..5e119628 100644
--- a/app/Controllers/TicketController.php
+++ b/app/Controllers/TicketController.php
@@ -42,6 +42,8 @@ class TicketController extends BaseController
public $placeHolders;
public $extraFields;
public $nonIDReason;
+ public $removeArrayKey;
+
protected $clientModel;
protected $ticketMasterModel;
@@ -280,7 +282,6 @@ class TicketController extends BaseController
58 => ['cancel_remark' => 'Cancel Remark']
];
-
$this->nonIDReason = [
"Newborn Baby" => "Newborn Baby",
"Newly Wedded Spouse" => "Newly Wedded Spouse",
@@ -289,6 +290,46 @@ class TicketController extends BaseController
"Exceptional Case" => "Exceptional Case"
];
+ $this->removeArrayKey = [
+ 2 => [],
+ 6 => [],
+ 12 => [],
+ 15 => [],
+ 16 => [],
+ 17 => [],
+ 18 => [],
+ 19 => [],
+ 21 => [],
+ 22 => [],
+ 23 => [],
+ 25 => [],
+ 26 => [],
+ 27 => [],
+ 28 => [],
+ 29 => [],
+ 31 => [],
+ 32 => [],
+ 33 => [],
+ 35 => [],
+ 36 => [],
+ 37 => [],
+ 38 => [],
+ 39 => [],
+ 41 => [],
+ 42 => [],
+ 43 => [],
+ 45 => [],
+ 46 => [],
+ 49 => [],
+ 50 => [],
+ 51 => [],
+ 52 => [],
+ 55 => [],
+ 56 => [],
+ 57 => [],
+ 60 => []
+ ];
+
$this->ticketMasterModel = new TicketMasterModel();
$this->claimStatus = new TicketClaimStatusModel();
$this->clientModel = new ClientModel();
@@ -1712,9 +1753,22 @@ class TicketController extends BaseController
$lastMatchedStatus = $incoming_form_values['claim_status_id'];
// Use the provided `extra_fields_array_for_validate` from the incoming data
- $statusMapping = json_decode($incoming_form_values['extra_fields_array_for_validate']);
+ $statusMapping = json_decode($incoming_form_values['extra_fields_array_for_validate'], true);
+ // print_r($statusMapping);
+ // echo "-------------------------------";
+
+ //for remove the non used arrays
+ foreach ($statusMapping as $key1 => $value1) {
+ foreach ($this->removeArrayKey as $key2 => $value2) {
+ if($key1 === $key2){
+ unset($statusMapping[$key1]);
+ }
+ }
+ }
+ // print_r($statusMapping); die;
- if($incoming_form_values['claim_status_id'] != $old_ticket_data['claim_status_id']){
+ // if($incoming_form_values['claim_status_id'] != $old_ticket_data['claim_status_id']){
+
foreach ($statusMapping as $status => $requiredFields) {
if(!empty($requiredFields) && $status != $old_ticket_data['claim_status_id']){
@@ -1749,7 +1803,8 @@ class TicketController extends BaseController
$lastMatchedStatus = 2;
}
}
- }
+
+ // }
return $lastMatchedStatus;
}
diff --git a/app/Helpers/excel_import_export_helper.php b/app/Helpers/excel_import_export_helper.php
index ad484ffe..9c72c973 100755
--- a/app/Helpers/excel_import_export_helper.php
+++ b/app/Helpers/excel_import_export_helper.php
@@ -664,12 +664,18 @@ if(!function_exists('generate_insurer_based_excel')){
$rowData = [];
foreach ($excel_header_array as $header) {
+
$fieldName = $header['db_column_name'];
+ $defaultValue = isset($header['default_value']) ? $header['default_value'] : null;
if ($fieldName === 'index') {
$value = $serialNumber;
} else {
- $value = $row->$fieldName ?? '';
+ if(empty($fieldName) && !empty($defaultValue)){
+ $value = $defaultValue;
+ }else{
+ $value = $row->$fieldName ?? '';
+ }
}
$rowData[] = $value;
diff --git a/app/Models/CDMasterModel.php b/app/Models/CDMasterModel.php
index 663ea3bc..ee503a86 100755
--- a/app/Models/CDMasterModel.php
+++ b/app/Models/CDMasterModel.php
@@ -17,6 +17,7 @@ class CDMasterModel extends Model
'id',
'client_id',
'insurer_id',
+ 'insurer_branch_id',
'cd_ac_no',
'opening_bal',
'opening_date',
@@ -66,9 +67,10 @@ class CDMasterModel extends Model
$query = $this->db->table('cd_master')
- ->select('cd_master.*, clients.client_name, clients.short_name, insurers.name AS insurer_name, user_profiles.first_name AS user_name, IFNULL(cd_ac_counts.cd_ac_no_count, 0) AS cd_ac_no_count, IFNULL(cd_ac_counts_for_cdt.cd_ac_no_count_cd_tranction, 0) AS cd_ac_no_count_cd_tranction')
+ ->select('cd_master.*, clients.client_name, clients.short_name, insurers.name AS insurer_name, user_profiles.first_name AS user_name, IFNULL(cd_ac_counts.cd_ac_no_count, 0) AS cd_ac_no_count, IFNULL(cd_ac_counts_for_cdt.cd_ac_no_count_cd_tranction, 0) AS cd_ac_no_count_cd_tranction, insurer_branch.branch_name as insurer_branch_name')
->join('clients', 'clients.id = cd_master.client_id')
->join('insurers', 'insurers.id = cd_master.insurer_id')
+ ->join('insurer_branch', 'cd_master.insurer_branch_id = insurer_branch.id', "left")
->join('user_profiles', 'user_profiles.id = cd_master.created_by')
->join(
'(SELECT cd_master.cd_ac_no, cd_master.id, COUNT(client_policy.cd_ac_no) AS cd_ac_no_count
@@ -102,6 +104,7 @@ class CDMasterModel extends Model
->where('clients.is_active', 1)
->where('insurers.is_active', 1)
->where('user_profiles.is_active', 1)
+ ->orderBy('cd_master.id', "desc")
->get();
$result = $query->getResultArray();
diff --git a/app/Models/ClientModel.php b/app/Models/ClientModel.php
index a09f75f1..e1407c2c 100755
--- a/app/Models/ClientModel.php
+++ b/app/Models/ClientModel.php
@@ -40,6 +40,7 @@ class ClientModel extends Model
"reply_to",
"mail_domain",
"addon_subheading",
+ "parent_client_id",
];
diff --git a/app/Models/ClientPolicyModel.php b/app/Models/ClientPolicyModel.php
index 1ad8e8bb..132080de 100755
--- a/app/Models/ClientPolicyModel.php
+++ b/app/Models/ClientPolicyModel.php
@@ -174,10 +174,11 @@ class ClientPolicyModel extends Model
$builder = $this->db->table('client_policy')
->select('client_policy.*, cd_master.cd_ac_no as cd_master_account_no')
- ->select('insurers.name as insurer_name, insurers.short_name as insurer_short')
+ ->select('insurers.name as insurer_name, insurers.short_name as insurer_short, insurer_branch.branch_name as insurer_branch_name')
->select('clients.client_name as client_name')
->join('clients', 'clients.id = client_policy.client_id')
->join('insurers', 'insurers.id = client_policy.insurer_id')
+ ->join('insurer_branch', 'client_policy.insurer_branch_id = insurer_branch.id', 'left')
->join('cd_master', 'cd_master.insurer_id = insurers.id AND cd_master.client_id = client_policy.client_id')
->where('client_policy.client_id', $id)
->where('cd_master.id = client_policy.cd_ac_pk')
@@ -190,7 +191,9 @@ class ClientPolicyModel extends Model
$builder->whereIn('client_policy.id', $policyId);
}
- return $builder->get()->getResult();
+ $data = $builder->get()->getResult();
+ // dd($this->db->getLastQuery());
+ return $data;
diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php
index ec4b9222..e6b02543 100755
--- a/app/Models/EmployeePolicyModel.php
+++ b/app/Models/EmployeePolicyModel.php
@@ -1085,10 +1085,10 @@ class EmployeePolicyModel extends Model
}
$status_condition = "{$insurer_or_tpa}" === 'tpa'
- ? "employee_polices.status = 'inactive' AND employees.emp_status = 'active'"
+ ? "employee_polices.status = 'active' AND employees.emp_status = 'active'"
: "employee_polices.status = 'active' AND employees.emp_status = 'active'";
- $endorsement_condition = "{$insurer_or_tpa}" === 'tpa' ? "AND (a.endorsement_id IS NOT NULL OR a.endorsement_id != '')" : "AND (a.endorsement_id IS NULL OR a.endorsement_id = '')";
+ $endorsement_condition = "{$insurer_or_tpa}" === 'tpa' ? "AND (a.endorsement_id IS NULL OR a.endorsement_id = '')" : "AND (a.endorsement_id IS NULL OR a.endorsement_id = '')";
$query = $this->db->query("
SELECT DISTINCT
diff --git a/app/Models/PolicyTransactionModel.php b/app/Models/PolicyTransactionModel.php
index 5eabf684..ba9b2fcd 100644
--- a/app/Models/PolicyTransactionModel.php
+++ b/app/Models/PolicyTransactionModel.php
@@ -765,7 +765,12 @@ class PolicyTransactionModel extends Model
),
2
) AS unbilled_amt,
- created_user.first_name as user_name
+ created_user.first_name as user_name,
+ CASE
+ WHEN `pt_co_share_details`.`co_share_type` IN (0, 1) THEN `policy_transaction`.`policy_no`
+ WHEN `pt_co_share_details`.`co_share_type` > 1 THEN `pt_co_share_details`.`follower_policy_no`
+ ELSE `policy_transaction`.`policy_no` -- Default fallback
+ END AS `policy_no`
")
->join('pt_co_share_details', 'policy_transaction.id = pt_co_share_details.pt_id', 'left')
@@ -986,7 +991,12 @@ class PolicyTransactionModel extends Model
pt_co_share_details.tp_amt AS tp,
clients.pan,
DATE_FORMAT(policy_transaction.created_at, '%d %b %Y %h:%i %p') AS created_at,
- user_profiles.first_name as user_name
+ user_profiles.first_name as user_name,
+ CASE
+ WHEN `pt_co_share_details`.`co_share_type` IN (0, 1) THEN `policy_transaction`.`policy_no`
+ WHEN `pt_co_share_details`.`co_share_type` > 1 THEN `pt_co_share_details`.`follower_policy_no`
+ ELSE `policy_transaction`.`policy_no` -- Default fallback
+ END AS `policy_no`
")
->join('pt_co_share_details', 'policy_transaction.id = pt_co_share_details.pt_id', 'left')
->join('clients', 'clients.id = policy_transaction.client_id', 'left')
@@ -1049,8 +1059,8 @@ class PolicyTransactionModel extends Model
// Optimize Query Execution
$builder->orderBy('policy_transaction.id', 'desc');
-
- return $builder->get()->getResultArray();
+ $data = $builder->get()->getResultArray();
+ return $data;
}
@@ -1065,7 +1075,12 @@ class PolicyTransactionModel extends Model
client_branch.branch_name as client_branch_name,
insurers.name AS insurer_name,
insurers.short_name AS insurer_short_name,
- policy_type.policy_type
+ policy_type.policy_type ,
+ CASE
+ WHEN `pt_co_share_details`.`co_share_type` IN (0, 1) THEN `policy_transaction`.`policy_no`
+ WHEN `pt_co_share_details`.`co_share_type` > 1 THEN `pt_co_share_details`.`follower_policy_no`
+ ELSE `policy_transaction`.`policy_no` -- Default fallback
+ END AS `policy_no`
')
->join('pt_co_share_details', 'policy_transaction.id = pt_co_share_details.pt_id', 'left')
->join('clients', 'policy_transaction.client_id = clients.id', 'left')
@@ -1228,7 +1243,12 @@ class PolicyTransactionModel extends Model
AND co_share_stmt_details.is_active = 1
),
2
- ) AS variance_amt
+ ) AS variance_amt,
+ CASE
+ WHEN `pt_co_share_details`.`co_share_type` IN (0, 1) THEN `policy_transaction`.`policy_no`
+ WHEN `pt_co_share_details`.`co_share_type` > 1 THEN `pt_co_share_details`.`follower_policy_no`
+ ELSE `policy_transaction`.`policy_no` -- Default fallback
+ END AS `policy_no`
")
@@ -1317,7 +1337,6 @@ class PolicyTransactionModel extends Model
'clients.client_name',
'insurers.name AS insurer_name',
'policy_type.policy_type',
- 'policy_transaction.policy_no',
'policy_transaction.endorsement_no',
"CASE
WHEN policy_transaction.action_type = 'inception' THEN 'I'
@@ -1327,7 +1346,12 @@ class PolicyTransactionModel extends Model
'pt_co_share_details.bp_amt',
'pt_co_share_details.tp_amt',
'pt_co_share_details.tep_amt',
- 'policy_transaction.status'
+ 'policy_transaction.status',
+ 'CASE
+ WHEN `pt_co_share_details`.`co_share_type` IN (0, 1) THEN `policy_transaction`.`policy_no`
+ WHEN `pt_co_share_details`.`co_share_type` > 1 THEN `pt_co_share_details`.`follower_policy_no`
+ ELSE `policy_transaction`.`policy_no` -- Default fallback
+ END AS `policy_no`'
])
->join('pt_co_share_details', 'policy_transaction.id = pt_co_share_details.pt_id', 'left')
->join('clients', 'clients.id = policy_transaction.client_id', 'left')
@@ -1417,7 +1441,12 @@ class PolicyTransactionModel extends Model
policy_transaction.action_type AS action_type_full,
pt_co_share_details.exp_amt,
pt_co_share_details.variance,
- policy_transaction.status
+ policy_transaction.status,
+ CASE
+ WHEN `pt_co_share_details`.`co_share_type` IN (0, 1) THEN `policy_transaction`.`policy_no`
+ WHEN `pt_co_share_details`.`co_share_type` > 1 THEN `pt_co_share_details`.`follower_policy_no`
+ ELSE `policy_transaction`.`policy_no` -- Default fallback
+ END AS `policy_no`
")
->join('pt_co_share_details', 'policy_transaction.id = pt_co_share_details.pt_id', 'left')
->join('clients', 'clients.id = policy_transaction.client_id', 'left')
@@ -1490,7 +1519,6 @@ class PolicyTransactionModel extends Model
clients.client_name,
insurers.name AS insurer_name,
policy_type.policy_type,
- policy_transaction.policy_no,
policy_transaction.endorsement_no,
CASE
WHEN policy_transaction.action_type = 'inception' THEN 'I'
@@ -1525,7 +1553,12 @@ class PolicyTransactionModel extends Model
inv_payment_details.statement_id = insurer_statements.id
AND inv_payment_details.is_active = 1
),
- 2) AS outstanding_amount
+ 2) AS outstanding_amount,
+ CASE
+ WHEN `pt_co_share_details`.`co_share_type` IN (0, 1) THEN `policy_transaction`.`policy_no`
+ WHEN `pt_co_share_details`.`co_share_type` > 1 THEN `pt_co_share_details`.`follower_policy_no`
+ ELSE `policy_transaction`.`policy_no` -- Default fallback
+ END AS `policy_no`
")
->join('pt_co_share_details', 'policy_transaction.id = pt_co_share_details.pt_id', 'left')
->join('insurer_statements', 'pt_co_share_details.statement_id = insurer_statements.id', 'left')
diff --git a/app/Views/UserList.php b/app/Views/UserList.php
index be654b8d..b7de1d73 100755
--- a/app/Views/UserList.php
+++ b/app/Views/UserList.php
@@ -1,4 +1,4 @@
- -->
+
+
+
@@ -96,7 +286,7 @@ table.dataTable tbody td {
-