From cf1c100b2af2ed568a6f303705e9294fe4ad3f6e Mon Sep 17 00:00:00 2001 From: velz Date: Mon, 24 Mar 2025 09:06:14 +0530 Subject: [PATCH 1/5] TEST_COMMIT --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index b56458c2..0a4cf0dd 100755 --- a/README.md +++ b/README.md @@ -9,3 +9,5 @@ From command propmt run the following cmds Run speeific method `php vendor/bin/phpunit tests\unit\PremiumCalculationTest.php --filter testPremiumCalculationWithPrimaryRackRateAndAdditionalRackRate` + +Test Comments \ No newline at end of file From 375d142a902439bc1c21fbcb37427a2836478c75 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Mon, 24 Mar 2025 15:16:43 +0530 Subject: [PATCH 2/5] CHANGE_USER_ROLE_AND_TEAMS_BASED_SHOWING_MENU : RV --- app/Config/Constants.php | 2 + app/Controllers/DashboardController.php | 50 ++- .../PolicyTransactionController.php | 43 +- app/Models/PolicyTransactionModel.php | 26 ++ app/Views/DashBoard.php | 105 +++-- app/Views/bds_dash.php | 7 +- app/Views/layout/header.php | 408 +++++++++--------- 7 files changed, 362 insertions(+), 279 deletions(-) diff --git a/app/Config/Constants.php b/app/Config/Constants.php index fb86b921..eee4bdcd 100755 --- a/app/Config/Constants.php +++ b/app/Config/Constants.php @@ -103,6 +103,8 @@ define('BUSINESS_TEAM_ID', '3'); define('FINANCE_TEAM_ID', '4'); define('SALES_TEAM_ID', '5'); define('MANAGEMENT_TEAM_ID', '6'); +define('BUSINESS_SUPPORT_TEAM_ID', '7'); +define('POS_TEAM_ID', '8'); /** * @User Teams Constant diff --git a/app/Controllers/DashboardController.php b/app/Controllers/DashboardController.php index d1a48afb..f4eb8d34 100755 --- a/app/Controllers/DashboardController.php +++ b/app/Controllers/DashboardController.php @@ -100,8 +100,10 @@ class DashboardController extends AdminController $data = []; - $db = db_connect(); - $sql = "SELECT + if (in_array(get_role_id(), [1,2,3,5]) || (in_array(MANAGEMENT_TEAM_ID, user_team()) || in_array(FINANCE_TEAM_ID, user_team()) || in_array(BUSINESS_TEAM_ID, user_team()))) { + + $db = db_connect(); + $sql = "SELECT clients.id AS client_id, clients.client_name, clients.short_name, @@ -144,30 +146,32 @@ class DashboardController extends AdminController GROUP BY clients.id, client_branch.id"; - $query = $db->query($sql); - $results = $query->getResultArray(); + $query = $db->query($sql); + $results = $query->getResultArray(); - $pendingActionsController = new PendingActionsController; - $pendingActionsData = $pendingActionsController->getPendingActionsForDashBoard(); - $businessTeamData = $this->policyTransactionModel->getBusinessReportList(); - $financeTeamData = $this->policyTransactionModel->getFinanceReportList(); - $businessTeamStatusData = $this->data_construct_for_bds($businessTeamData); - $financeTeamStatusData = $this->data_construct_for_bds($financeTeamData); + $pendingActionsController = new PendingActionsController; + $pendingActionsData = $pendingActionsController->getPendingActionsForDashBoard(); + $businessTeamData = $this->policyTransactionModel->getBusinessReportList(); + $financeTeamData = $this->policyTransactionModel->getFinanceReportList(); + $businessTeamStatusData = $this->data_construct_for_bds($businessTeamData); + $financeTeamStatusData = $this->data_construct_for_bds($financeTeamData); - $data['client_branch_emp_list'] = $results; - $session = \Config\Services::session(); - $session->set('enrollment_data', json_encode($data)); - - // echo "
";
-        $data['pendingActionsData'] = $pendingActionsData;
-        $data['businessTeamCount'] = count($businessTeamData) ?? 0;
-        $data['financeTeamCount'] = count($financeTeamData) ?? 0;
-        $data['businessTeamStatusData'] = $businessTeamStatusData;
-        $data['financeTeamStatusData'] = $financeTeamStatusData;
-        $data['policyStatus'] =  $this->policyStatus;
-        $data['colorShades'] =  $this->colorShades;
-        // print_r($data);die;
+            $data['client_branch_emp_list'] = $results;
+            $session = \Config\Services::session();
+            $session->set('enrollment_data', json_encode($data));
+
+            // echo "
";
+            $data['pendingActionsData'] = $pendingActionsData;
+            $data['businessTeamCount'] = count($businessTeamData) ?? 0;
+            $data['financeTeamCount'] = count($financeTeamData) ?? 0;
+            $data['businessTeamStatusData'] = $businessTeamStatusData;
+            $data['financeTeamStatusData'] = $financeTeamStatusData;
+            $data['policyStatus'] =  $this->policyStatus;
+            $data['colorShades'] =  $this->colorShades;
+            // print_r($data);die;
+
+        }
 
         $data['page_name'] = 'Dashboard';
 
diff --git a/app/Controllers/PolicyTransactionController.php b/app/Controllers/PolicyTransactionController.php
index 4a2a59d6..2c40bd30 100644
--- a/app/Controllers/PolicyTransactionController.php
+++ b/app/Controllers/PolicyTransactionController.php
@@ -790,13 +790,24 @@ class PolicyTransactionController extends BaseController
                 ->whereIn('client_policy.policy_type_id', [2, 3])
                 ->where('client_policy.is_active', 1)
                 ->findAll();
-        
-        $data['pt_files'] = $this->PTFileModel
-                ->join('policy_transaction', 'pt_files.pt_id = policy_transaction.id')
-                ->where('pt_files.pt_id', $id)
-                ->where('pt_files.is_active', 1)
-                ->findAll();
-                
+
+
+        $ptFileQuery = $this->PTFileModel
+            ->join('policy_transaction', 'pt_files.pt_id = policy_transaction.id')
+            ->where('pt_files.pt_id', $id)
+            ->where('pt_files.is_active', 1);
+
+        if (!in_array(get_role_id(), [1, 5]) && empty(array_intersect(user_team(), [MANAGEMENT_TEAM_ID, FINANCE_TEAM_ID, BUSINESS_TEAM_ID]))) {
+            
+            if (get_role_id() == 4 && in_array(POS_TEAM_ID, user_team())) {
+                $ptFileQuery->where('pt_files.created_by', get_session_userid());
+            }
+        }
+
+        $data['pt_files'] = $ptFileQuery->findAll();
+
+
+
         $data['pt_co_share_details'] = $this->PTCOShareDetailsModel
                 ->select("
                     pt_co_share_details.*,
@@ -1501,11 +1512,19 @@ class PolicyTransactionController extends BaseController
         
         if (!empty($uploadData)) {
 
-            $data['pt_files'] = $this->PTFileModel
-                ->join('policy_transaction', 'pt_files.pt_id = policy_transaction.id')
-                ->where('pt_files.pt_id', $pt_id)
-                ->where('pt_files.is_active', 1)
-                ->findAll();           
+        $ptFileQuery = $this->PTFileModel
+            ->join('policy_transaction', 'pt_files.pt_id = policy_transaction.id')
+            ->where('pt_files.pt_id', $pt_id)
+            ->where('pt_files.is_active', 1);
+
+        if (!in_array(get_role_id(), [1, 5]) && empty(array_intersect(user_team(), [MANAGEMENT_TEAM_ID, FINANCE_TEAM_ID, BUSINESS_TEAM_ID]))) {
+            
+            if (get_role_id() == 4 && in_array(POS_TEAM_ID, user_team())) {
+                $ptFileQuery->where('pt_files.created_by', get_session_userid());
+            }
+        }
+
+        $data['pt_files'] = $ptFileQuery->findAll();        
                  
             return $this->respond(['status' => true, 'message' => 'File uploaded successfully in G-Drive', 'data' => $data]);
         } else {
diff --git a/app/Models/PolicyTransactionModel.php b/app/Models/PolicyTransactionModel.php
index 136529d6..2a77d201 100644
--- a/app/Models/PolicyTransactionModel.php
+++ b/app/Models/PolicyTransactionModel.php
@@ -973,6 +973,19 @@ class PolicyTransactionModel extends Model
             ->where('policy_transaction.is_active', 1)
             ->where('policy_transaction.action_type', 'inception');
 
+        if (
+            (!in_array(get_role_id(), [1, 5])) &&
+            !(
+                in_array(MANAGEMENT_TEAM_ID, user_team()) ||
+                in_array(FINANCE_TEAM_ID, user_team()) ||
+                in_array(BUSINESS_TEAM_ID, user_team())
+            )
+        ) {
+            if (get_role_id() == 4 && in_array(POS_TEAM_ID, user_team())) {
+                $builder->where('policy_transaction.created_by', get_session_userid());
+            }
+        }
+
         // Optimize Date Filtering
         if (!empty($start_date) && !empty($end_date) && !empty($date_type)) {
             $builder->where("policy_transaction.$date_type >=", date('Y-m-d 00:00:00', strtotime($start_date)))
@@ -1034,6 +1047,19 @@ class PolicyTransactionModel extends Model
             ->where('policy_transaction.is_active', 1)
             ->where('policy_transaction.action_type !=', 'inception');
 
+        if (
+            (!in_array(get_role_id(), [1, 5])) &&
+            !(
+                in_array(MANAGEMENT_TEAM_ID, user_team()) ||
+                in_array(FINANCE_TEAM_ID, user_team()) ||
+                in_array(BUSINESS_TEAM_ID, user_team())
+            )
+        ) {
+            if (get_role_id() == 4 && in_array(POS_TEAM_ID, user_team())) {
+                $builder->where('policy_transaction.created_by', get_session_userid());
+            }
+        }
+            
 
         if ($start_date != 0 && $end_date != 0 && $date_type != 0) {
 
diff --git a/app/Views/DashBoard.php b/app/Views/DashBoard.php
index 4da6b9c0..3102ab15 100755
--- a/app/Views/DashBoard.php
+++ b/app/Views/DashBoard.php
@@ -139,40 +139,41 @@
 
 
 
+
 
 
 
 
+
 
 
 
diff --git a/app/Views/bds_dash.php b/app/Views/bds_dash.php
index 89a92413..c6711ec9 100644
--- a/app/Views/bds_dash.php
+++ b/app/Views/bds_dash.php
@@ -125,7 +125,12 @@ body{
 }
 
 
-
+ + + + + +
- +
-
+ + + + + +
  • + + + 2 + App Content Management + + +
  • + + + +
    + +
    + -
    - - -
    - - - - + From abd43b9154bbfc57d52fc32b4aee7c731fc2629c Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Mon, 24 Mar 2025 16:26:03 +0530 Subject: [PATCH 3/5] FIX_ACM_IN_CLIENT_SETUP : RV --- app/Controllers/ClientController.php | 4 ++-- app/Views/layout/header.php | 2 +- app/Views/view_rfq.php | 4 +++- app/Views/view_rfq_non_eb.php | 4 +++- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index fb78c67b..4ca4505d 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -594,7 +594,7 @@ class ClientController extends AdminController $data['insurer'] = $this->insurerBranchModel->getInsurerBranchesWithInsurerNames(); $data['tpa'] = $this->tpaBranchModel->getTpaBranchesWithTpaNames(); $data['state'] = $this->stateModel->getAllStates(); - $data['RM'] = $this->userModel->findAll(); + $data['RM'] = $this->userModel->where('is_active', 1)->findAll(); $data['policyGridData'] = $this->policyGridModel->findAll(); $data['policy_types'] = $this->policyTypeModel->findAll(); $data['policy_type'] = ['1' => 'Base Policy', '2' => 'SI Topup', '3' => 'Dependent Addon']; @@ -717,7 +717,7 @@ class ClientController extends AdminController $this->myLogger->logme('error', 'Edit Client Onboarding function called'); $headerData['page_name'] = 'Edit Client Onboarding'; - $editData['RM'] = $this->userModel->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(); diff --git a/app/Views/layout/header.php b/app/Views/layout/header.php index 1e7d1cbc..f10d9077 100755 --- a/app/Views/layout/header.php +++ b/app/Views/layout/header.php @@ -674,7 +674,7 @@ - +
  • diff --git a/app/Views/view_rfq.php b/app/Views/view_rfq.php index 21248ced..3922cdf6 100644 --- a/app/Views/view_rfq.php +++ b/app/Views/view_rfq.php @@ -225,7 +225,9 @@ -       + + +       Export Excel diff --git a/app/Views/view_rfq_non_eb.php b/app/Views/view_rfq_non_eb.php index 402b597e..f885138f 100644 --- a/app/Views/view_rfq_non_eb.php +++ b/app/Views/view_rfq_non_eb.php @@ -182,7 +182,9 @@
    - + + + Export Excel From 69751b02453362e8032ba5df89b0edf73d155bcc Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Tue, 25 Mar 2025 09:08:24 +0530 Subject: [PATCH 4/5] FIX_REST_TERMS_OBJ_ARR_ISSUE : RV --- app/Controllers/EmployeeRestController.php | 10 +--------- app/Views/layout/header.php | 2 +- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index f46fc522..2d7bf436 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -2532,10 +2532,6 @@ class EmployeeRestController extends AdminController $result = []; foreach ($ClientPolicyData as $key => $ClientPolicyValue) { - - - - if($ClientPolicyValue['policy_type_id'] == 1) { $policyGroup = 'gpa'; @@ -2555,11 +2551,7 @@ class EmployeeRestController extends AdminController } $terms = json_decode($ClientPolicyValue['policy_terms'] , true); - $data['policy_terms'] = isset($terms['enrollment_display_key']) - && !empty($terms['enrollment_display_key']) - ? $terms['enrollment_display_key'] - : $this->policyTermsFiter($terms, $policyGroup); - $terms = json_decode($ClientPolicyValue['policy_terms']); + $data['policy_terms'] = isset($terms['enrollment_display_key']) && !empty($terms['enrollment_display_key']) ? $terms['enrollment_display_key'] : $this->policyTermsFiter($terms, $policyGroup); $data['client_id'] = $ClientPolicyValue['client_id']; diff --git a/app/Views/layout/header.php b/app/Views/layout/header.php index f10d9077..0abdf8d5 100755 --- a/app/Views/layout/header.php +++ b/app/Views/layout/header.php @@ -563,7 +563,7 @@ - +
  • From 7c5845097395d52bc39ad0394a8afcd0204680ce Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Tue, 25 Mar 2025 11:39:13 +0530 Subject: [PATCH 5/5] FIX_VERIFY_MOB_EMAIL_STATUS_REST : RV --- app/Controllers/LeadsController.php | 75 ++++++++++--------- .../RestAuthenticationController.php | 2 +- app/Models/RFQModel.php | 1 + app/Views/view_rfq_non_eb.php | 11 ++- 4 files changed, 52 insertions(+), 37 deletions(-) diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index b361c5b3..8d926761 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -628,12 +628,16 @@ class LeadsController extends BaseController public function createRFQ() { - - // print_r($this->request->getPost('json')); die(); - $data = $this->request->getPost(); - $lead_id = $data['lead_id']; + $lead_id = $data['lead_id'] ?? null; + + if (!$lead_id) { + return $this->respond(['status' => false, 'message' => 'Lead ID is required'], 400); + } + $data['type'] = 1; + + // Deactivate existing RFQs for this lead and type $this->RFQModel ->where('lead_id', $lead_id) ->where('type', 1) @@ -641,41 +645,40 @@ class LeadsController extends BaseController ->set('is_active', 0) ->update(); - $registrationJson = $data['registration_json'] ?? null; // Use null coalescing operator for safety + // Handle registration_json + if (empty($data['registration_json'])) { + // Fetch the latest registration_json if not provided + $latest = $this->RFQModel + ->select('registration_json') + ->where('lead_id', $lead_id) + ->orderBy('id', 'DESC') + ->first(); - if ($registrationJson) { - // If registration_json is provided, insert the data directly - $result = $this->RFQModel->insert($data); - } else { - // If registration_json is not provided, fetch the latest registration_json from the database - $this->RFQModel->select('registration_json') - ->where("lead_id", $lead_id) - ->order_by('id', 'DESC') // Assuming 'id' is an auto-increment field - ->limit(1); - - $query = $this->RFQModel->get(); - $latestRegistrationJson = $query->row()->registration_json ?? null; - - if ($latestRegistrationJson) { - // If a valid registration_json is found, update the data and insert - $data['registration_json'] = $latestRegistrationJson; - $result = $this->RFQModel->insert($data); - } else { - // If no registration_json is found, insert the data as-is - $result = $this->RFQModel->insert($data); + if (!empty($latest['registration_json'])) { + $data['registration_json'] = $latest['registration_json']; } } - if ($result) { + // Insert new RFQ + $insertId = $this->RFQModel->insert($data); - $message = "RFQ submitted successfully"; - if ($data['submit_type'] == 'QCR') { - $message = "QCR submitted successfully"; - } - return $this->respond(['status' => true, 'id' => $result, 'message' => $message, 'data' => $data], 200); + if ($insertId) { + $message = ($data['submit_type'] ?? '') == 'QCR' ? 'QCR submitted successfully' : 'RFQ submitted successfully'; + return $this->respond([ + 'status' => true, + 'id' => $insertId, + 'message' => $message, + 'data' => $data + ], 200); } - return $this->respond(['status' => false, 'id' => $result, 'message' => "Failed to create RFQ", 'data' => $data], 200); + $message = ($data['submit_type'] ?? '') == 'QCR' ? 'Failed to create QCR' : 'Failed to create RFQ'; + return $this->respond([ + 'status' => false, + 'id' => null, + 'message' => $message, + 'data' => $data + ], 200); } public function createQCR() @@ -2575,15 +2578,19 @@ class LeadsController extends BaseController public function constructNonEbExcelToSaveTemp($lead_id, $type, $propsal_and_insurer = null) { - $rfq_data = $this->RFQModel->getRFQTableDataWithLeadIDAndType($lead_id, $type); - $lead_data = json_decode($rfq_data['custom_fields'], true) ?? []; if (!is_array($lead_data)) { $lead_data = []; } $lead_data = array_merge(['Insured' => $rfq_data['client_name']], $lead_data); + $policy_registration_data = []; + if(isset($rfq_data['registration_json']) && !empty($rfq_data['registration_json'])){ + $policy_registration_data = json_decode($rfq_data['registration_json'], true); + } + // dd($policy_registration_data); + // if(!empty($rfq_data['fin_years_claims'])){ // $claim_details = json_decode($rfq_data['fin_years_claims'], true) ?? []; // if(!empty($claim_details['finyear'])){ diff --git a/app/Controllers/RestAuthenticationController.php b/app/Controllers/RestAuthenticationController.php index 3d141b2b..27114883 100755 --- a/app/Controllers/RestAuthenticationController.php +++ b/app/Controllers/RestAuthenticationController.php @@ -118,7 +118,7 @@ class RestAuthenticationController extends AdminController ->where('employees.emp_status !=', 'truncated') ->where('employees.email_corporate', $email) ->where('EP.is_active', 1) - ->whereIn('EP.status', ['draft', 'enrolled']) + ->whereIn('EP.status', ['active']) ->first(); if (isset($employeeData['employee_id'])) { diff --git a/app/Models/RFQModel.php b/app/Models/RFQModel.php index 24d18529..4ffbf9d4 100644 --- a/app/Models/RFQModel.php +++ b/app/Models/RFQModel.php @@ -68,6 +68,7 @@ class RFQModel extends Model tpa_branch.branch_name as tpa_branch_name, policy_type.policy_type, rfq.json, + rfq.registration_json ') ->join('leads', 'rfq.lead_id = leads.id') ->join('policy_type', 'leads.policy_type_id = policy_type.id') diff --git a/app/Views/view_rfq_non_eb.php b/app/Views/view_rfq_non_eb.php index f885138f..5822cb9f 100644 --- a/app/Views/view_rfq_non_eb.php +++ b/app/Views/view_rfq_non_eb.php @@ -1989,10 +1989,13 @@ function saveRFQTODB(tableJSON, policyJson) { + let submit_type = "RFQ" + if(rfq_or_qcr == 2){submit_type = 'QCR'} + var formData = { lead_id: $("#lead_id").val(), json: JSON.stringify(tableJSON), - submit_type: "RFQ", + submit_type: submit_type, registration_json: policyJson } @@ -3209,7 +3212,11 @@ } else if (redirect_type == 2) { //EXCEL EXPORT - let url = $('#submitExcel').data('url'); + // let url = $('#submitExcel').data('url'); + + let lead_id = $('#lead_id').val(); + let url = '' + lead_id + '/' + rfq_or_qcr + '/' + 2 + window.location.href = url; } else if (redirect_type == 3) {