From 3e13091b34b8ebe927133840aa43e3b230a62a17 Mon Sep 17 00:00:00 2001 From: vadivelJ96 Date: Thu, 9 Oct 2025 16:56:16 +0530 Subject: [PATCH 01/28] CHANGE_Post_app_having_pre_branch_id - VADIVEL J 2025-09-10 --- app/Config/Routes.php | 1 + app/Controllers/ClientController.php | 123 ++++++++++++++-- app/Controllers/TestingController.php | 198 ++++++++++++++++++++++---- app/Views/client_branch.php | 12 +- 4 files changed, 291 insertions(+), 43 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 9996931c..61aea374 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -700,6 +700,7 @@ $routes->group('test', function($routes) { $routes->get('viewrfq', 'TestingController::viewRFQNonEb'); $routes->get('exportexcel', 'TestingController::exportExcel'); $routes->post('saverfq', 'TestingController::saverfq'); + $routes->get('mapping_client_id_and_branch_id','TestingController::mapping_client_id_and_branch_id'); }); $routes->cli('cli/testcli', 'TestingController::testcli'); diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 9baf11cd..8d3b8063 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -1098,14 +1098,47 @@ class ClientController extends AdminController } $data['created_by'] = get_session_userid(); + + + // before updating check if pre_branch_id is already existing in the current db + + if(isset($data['pre_branch_id']) && !empty($data['pre_branch_id'])) + { + $existing_pre_branch = $this->clientBranchModel + ->where('pre_branch_id',$data['pre_branch_id']) + //->where('id !=',$post_branch_id) + ->first(); + + if($existing_pre_branch) + { + return $this->respond([ + 'status' => false, + 'code' => 409, + 'message' => 'The pre branch id '.$data['pre_branch_id'].' is already mapped with another branch. Please check.', + ], 409); + } + } + + + $insert = $this->clientBranchModel->insert($data); + $post_branch_id = $insert; + if ($insert) { $level_contact_data = $this->request->getPost('level_contect_data'); $level_contact_data = !empty($level_contact_data) ? json_decode($level_contact_data, true) : null; $this->saveLevelContacts($level_contact_data, $insert); } + if($post_branch_id && isset($data['pre_branch_id']) && !empty($data['pre_branch_id'])) + { + // need to update the client_branch in the pre + $result = $this->updatePreClientBranch($data['pre_branch_id'],$post_branch_id , "create"); + + log_message('error','Pre client_branch update result for pre_branch_id '.$data['pre_branch_id'].' and post_branch_id '.$post_branch_id.' is '.json_encode($result)); + } + if ($insert) { $branchData = $this->clientBranchModel->where('client_id', $this->request->getPost('client_id'))->findAll(); $branchData['role'] = get_role_id(); @@ -1130,7 +1163,11 @@ class ClientController extends AdminController $this->myLogger->logme('error', 'Client branch EDIT function called'); $id = $this->request->getPost('branch_id_primarykey'); $client_id = $this->request->getPost('client_id'); + $pre_branch_id = $this->request->getPost('pre_branch_id') ?? ''; + $data = $this->request->getPost(); + $data['pre_branch_id'] = $pre_branch_id; + $units = $this->request->getPost('units'); $emp_unit_count = 0; @@ -1189,7 +1226,41 @@ class ClientController extends AdminController } $data['updated_by'] = get_session_userid(); + + $post_branch_id = $id; + + // before updating check if pre_branch_id is already existing in the current db + + if(isset($data['pre_branch_id']) && !empty($data['pre_branch_id'])) + { + $existing_pre_branch = $this->clientBranchModel + ->where('pre_branch_id',$data['pre_branch_id']) + ->where('id !=',$post_branch_id) + ->first(); + + if($existing_pre_branch) + { + return $this->respond([ + 'status' => false, + 'code' => 409, + 'message' => 'The pre branch id '.$data['pre_branch_id'].' is already mapped with another branch. Please check.', + ], 409); + } + } + $insert = $this->clientBranchModel->update($id, $data); + + + + if($post_branch_id && isset($data['pre_branch_id']) && !empty($data['pre_branch_id'])) + { + // need to update the client_branch in the pre + $result = $this->updatePreClientBranch($data['pre_branch_id'],$post_branch_id , "update"); + + log_message('error','Pre client_branch update result for pre_branch_id '.$data['pre_branch_id'].' and post_branch_id '.$post_branch_id.' is '.json_encode($result)); + } + + $this->myLogger->logme('error', 'Client branch EDITED by {data}', ['data' => get_session_userid()]); @@ -7107,9 +7178,15 @@ class ClientController extends AdminController $post_branch_id = $value['post_branch_id']; $post_hr_id = $value['post_hr_id']; - $value['pre_client_id'] = $this->getPreClientId($post_branch_id); - $value['pre_branch_id'] = $this->getPreBranchId($post_branch_id); - $value["pre_hr_id"] = $this->getPreHrId($post_branch_id); + $preBranchId = $this->getPreBranchIdByPostBranchId($post_branch_id); + + if (!empty($preBranchId)) { + $value['pre_branch_id'] = $preBranchId; + $value['pre_client_id'] = $this->getPreClientIdByPreBranchId($preBranchId); + $value["pre_hr_id"] = $this->getPreHrIdByPreBranchId($preBranchId); + } + + // INSERT or UPDATE if (empty($value['pk']) || (int)$value['pk'] === 0) { @@ -7176,26 +7253,28 @@ class ClientController extends AdminController } } - private function getPreClientId($post_branch_id){ + private function getPreClientIdByPreBranchId($pre_branch_id){ $db2 = \Config\Database::connect('preDB'); - $pre_client_id = $db2->table('client_branch')->where('post_branch_id',$post_branch_id)->where('is_Active',1)->get()->getResultArray()[0]['client_id']??[]; + $pre_client_id = $db2->table('client_branch')->where('id',$pre_branch_id)->where('is_Active',1)->get()->getResultArray()[0]['client_id']??""; return $pre_client_id; } - private function getPreBranchId($post_branch_id){ - $db2 = \Config\Database::connect('preDB'); - $pre_branch_id = $db2->table('client_branch')->where('post_branch_id',$post_branch_id)->where('is_Active',1)->get()->getResultArray()[0]['id']??[]; - return $pre_branch_id; - } - private function getPreHrId($post_branch_id){ + private function getPreHrIdByPreBranchId($pre_branch_id){ $db2 = \Config\Database::connect('preDB'); $pre_hr_id = $db2->table('client_branch cb') ->select('lc.id') ->join('level_contacts lc','lc.ref_id = cb.id') - ->where('post_branch_id',$post_branch_id)->where('is_Active',1)->get()->getResultArray()[0]['id']??[]; + ->where('cb.id',$pre_branch_id)->where('cb.is_Active',1)->where('lc.is_Active',1)->get()->getResultArray()[0]['id']??""; return $pre_hr_id; } + private function getPreBranchIdByPostBranchId($post_branch_id){ + $db2 = \Config\Database::connect(); + $pre_branch_id = $db2->table('client_branch')->where('id',$post_branch_id)->where('is_Active',1)->get()->getResultArray()[0]['pre_branch_id']??""; + return $pre_branch_id; + } + + // ------------------- DEMO CLIENT FUNCTION -------------------------------------------------------------------------------- public function wipeDemoClient() @@ -7584,6 +7663,26 @@ class ClientController extends AdminController } + private function updatePreClientBranch($pre_branch_id,$post_branch_id ,$operation) + { + + + + $preDB = \Config\Database::connect('preDB'); + + if($operation != 'create'){ + + $builder = $preDB->table('client_branch'); + $builder->where('post_branch_id', $post_branch_id); + $builder->update(['post_branch_id' => null]); + } + + $builder = $preDB->table('client_branch'); + $builder->where('id', $pre_branch_id); + $builder->update(['post_branch_id' => $post_branch_id]); + + return true; + } diff --git a/app/Controllers/TestingController.php b/app/Controllers/TestingController.php index 87310adc..7f8bc7d3 100644 --- a/app/Controllers/TestingController.php +++ b/app/Controllers/TestingController.php @@ -20,7 +20,7 @@ class TestingController extends BaseController { $this->myLogger = \Config\Services::mylogger(); } - + public function saveForm() { // Get JSON input @@ -35,7 +35,7 @@ class TestingController extends BaseController } public function testcli() - { + { echo "hi"; $this->myLogger->logme('error', "test log"); echo "hi 2"; @@ -79,19 +79,19 @@ class TestingController extends BaseController $options->set('debugLayoutBlocks', false); $options->set('debugLayoutInline', false); $options->set('debugLayoutPaddingBox', false); - + // Initialize DomPDF $dompdf = new Dompdf($options); - + // Load HTML content $dompdf->loadHtml($html); - + // Set paper size and orientation $dompdf->setPaper('A4', 'landscape'); // or 'portrait' - + // Render PDF $dompdf->render(); - + // Output PDF to browser $filename = 'ecard_' . date('Y-m-d_H-i-s') . '.pdf'; $dompdf->stream($filename, ['Attachment' => true]); // Set to false for inline view @@ -111,7 +111,7 @@ class TestingController extends BaseController 'POLICY_DATE' => '31/12/2024', 'INSURER_NAME' => 'ZURICH KOTAK GTNERAL INSURANCE COIIPANY lNDlA LIMITED', 'TPA_NAME' => 'HealthIndia Insurance TPA Services Pvt. Ltd.', - 'FRONT_CARD' => base_url() .('public/uploads/template_bg/Nhance_Ecard_working_1_front_3.png'), + 'FRONT_CARD' => base_url() . ('public/uploads/template_bg/Nhance_Ecard_working_1_front_3.png'), 'BACK_CARD' => base_url() . ('public/uploads/template_bg/Nhance_Ecard_working_1_Back_3.png'), 'LEVELS' => 'Level 1: 1800-XXX-XXXX
Level 2: support@company.com' ]; @@ -127,7 +127,7 @@ class TestingController extends BaseController 'POLICY_DATE' => '31/12/2024', 'INSURER_NAME' => 'ABC Insurance Co.', 'TPA_NAME' => 'XYZ TPA Ltd.', - 'FRONT_CARD' => base_url() .('public/uploads/template_bg/Nhance_Ecard_working_1_front_3.png'), + 'FRONT_CARD' => base_url() . ('public/uploads/template_bg/Nhance_Ecard_working_1_front_3.png'), 'BACK_CARD' => base_url() . ('public/uploads/template_bg/Nhance_Ecard_working_1_Back_3.png'), 'LEVELS' => 'Level 1: 1800-XXX-XXXX
Level 2: support@company.com' ]; @@ -157,12 +157,12 @@ class TestingController extends BaseController { // Load your HTML template $template = file_get_contents(WRITEPATH . 'e_card_template/common.html'); - + // Replace placeholders with actual data foreach ($data as $key => $value) { $template = str_replace('{' . $key . '}', $value, $template); } - + return $template; } @@ -225,21 +225,21 @@ class TestingController extends BaseController $employeePolicy = new EmployeePolicyModel(); $data = $employeePolicy - ->select('client_policy.policy_type_id') - ->join('employees', 'employee_polices.employee_id = employees.id') - ->join('client_policy', 'employee_polices.client_policy_id = client_policy.id') - ->where('employees.is_active', 1) - ->where('employees.emp_status', ['active', 'expired']) - ->where('employee_polices.is_active', 1) - ->where('employee_polices.status', ['active', 'expired']) - ->where('employees.client_id', $client_id) - ->where('employees.emp_code', $emp_code) - ->groupBy('employee_polices.client_policy_id') - ->findAll(); - + ->select('client_policy.policy_type_id') + ->join('employees', 'employee_polices.employee_id = employees.id') + ->join('client_policy', 'employee_polices.client_policy_id = client_policy.id') + ->where('employees.is_active', 1) + ->where('employees.emp_status', ['active', 'expired']) + ->where('employee_polices.is_active', 1) + ->where('employee_polices.status', ['active', 'expired']) + ->where('employees.client_id', $client_id) + ->where('employees.emp_code', $emp_code) + ->groupBy('employee_polices.client_policy_id') + ->findAll(); } - public function ptedfitdata($id){ + public function ptedfitdata($id) + { $policy_transaction = new PolicyTransactionController(); $data = $policy_transaction->getInceptionDataForEdit($id); // dd($data); @@ -249,7 +249,7 @@ class TestingController extends BaseController $dataArray = $data['pt_co_share_details']; // Example $cd_ac_pk = 'CD12345'; $role_id = 1; - $team_id = ['6']; + $team_id = ['6']; $insurer_branch = $insurer_branch; return view('pt_calc_table', [ @@ -315,7 +315,7 @@ class TestingController extends BaseController } public function viewRFQNonEb() - { + { $insurerBranchModel = new InsurerBranchModel(); $data['page_name'] = "RFQ NON EB"; $data['insurer'] = $insurerBranchModel->getInsurerBranchesWithInsurerNames(); @@ -323,7 +323,8 @@ class TestingController extends BaseController return $this->loadLayout('view_rfq_non_eb_new', $data); } - public function saverfq(){ + public function saverfq() + { $json = $this->request->getPost('json'); $json = json_encode($json); print_r($json); @@ -342,8 +343,147 @@ class TestingController extends BaseController // print_rr($policy_data['json']); die; $policy_data = json_decode($policy_data['json'], true); $policy_data = array_slice($policy_data, 0, -2); - print_rr($policy_data); die; - dd($policy_data); + print_rr($policy_data); + die; + dd($policy_data); } + + public function mapping_client_id_and_branch_id() + { + + $post_clients_list = $this->getNonDuplicatePostClients(); + + $pre_clients_list = $this->getNonDuplicatePreClients(); + + + + if ( + !empty($pre_clients_list) && + !empty($post_clients_list) + ) { + + $postDB = \Config\Database::connect(); + $preDB = \Config\Database::connect('preDB'); + + foreach ($post_clients_list as $post_client) { + + foreach ($pre_clients_list as $pre_client) { + + if (trim($post_client['short_name']) == trim($pre_client['short_name'])) { + + $postDB->table('clients')->where('id', $post_client['id'])->update(['pre_client_id' => $pre_client['id']]); + + $preDB->table('clients')->where('id', $pre_client['id'])->update(['post_client_id' => $post_client['id']]); + + // upto here we updated client_id in both dbs. + + $post_branches = $postDB->table('client_branch') + ->where('client_id', $post_client['id']) + ->get() + ->getResultArray() ?? []; + + $pre_branches = $preDB->table('client_branch') + ->where('client_id', $pre_client['id']) + ->get() + ->getResultArray() ?? []; + + if (!empty($post_branches) && !empty($pre_branches)) { + + + foreach ($post_branches as $post_branch) { + + $pre_branch = $preDB->table('client_branch') + ->where('client_id', $pre_client['id']) + ->where('branch_code', $post_branch['branch_code']) + ->get() + ->getRowArray() ?? []; + + if (!empty($pre_branch)) { + $postDB->table('client_branch')->where('id', $post_branch['id'])->update(['pre_branch_id' => $pre_branch['id']]); + } + } + + foreach ($pre_branches as $pre_branch) { + + $post_branch = $postDB->table('client_branch') + ->where('client_id', $post_client['id']) + ->where('branch_code', $pre_branch['branch_code']) + ->get() + ->getRowArray() ?? []; + + if (!empty($post_branch)) { + $preDB->table('client_branch')->where('id', $pre_branch['id'])->update(['post_branch_id' => $post_branch['id']]); + } + } + } + } + } + } + } + } + + + private function getNonDuplicatePostClients() + { + + + $postDB = \Config\Database::connect(); + + $sql = "SELECT * + FROM clients AS post_clients + WHERE post_clients.client_type = 1 + AND post_clients.is_active = 1 + AND (post_clients.short_name NOT IN + ( + SELECT ir_post_clients.short_name + FROM clients as ir_post_clients + WHERE ir_post_clients.client_type = 1 + AND ir_post_clients.short_name IS NOT NULL + AND TRIM(ir_post_clients.short_name) <> '' + AND ir_post_clients.is_active = 1 + GROUP BY ir_post_clients.short_name + HAVING COUNT(*) > 1) + ) + ORDER BY post_clients.short_name"; + + $binds = []; + + $query = $postDB->query($sql, $binds); + + $results = $query->getResultArray() ?? []; + + return $results; + } + + private function getNonDuplicatePreClients() + { + + $preDB = \Config\Database::connect('preDB'); + + $sql = "SELECT * + FROM clients AS pre_clients + WHERE pre_clients.client_type = 1 + AND pre_clients.is_active = 1 + AND (pre_clients.short_name NOT IN + ( + SELECT ir_pre_clients.short_name + FROM clients as ir_pre_clients + WHERE ir_pre_clients.client_type = 1 + AND ir_pre_clients.short_name IS NOT NULL + AND TRIM(ir_pre_clients.short_name) <> '' + AND ir_pre_clients.is_active = 1 + GROUP BY ir_pre_clients.short_name + HAVING COUNT(*) > 1) + ) + ORDER BY pre_clients.short_name"; + + $binds = []; + + $query = $preDB->query($sql, $binds); + + $results = $query->getResultArray() ?? []; + + return $results; + } } diff --git a/app/Views/client_branch.php b/app/Views/client_branch.php index 940cf017..7b30c166 100755 --- a/app/Views/client_branch.php +++ b/app/Views/client_branch.php @@ -86,13 +86,18 @@
+ + + + + - + - +
@@ -479,6 +484,9 @@ $("#branch_form").submit(function(event) { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); console.log('Something Wrong!', 'warning'); + if(xhr.status == 409){ + alert('The Current Branch is Already Existing..!!'); + } }, 300); }, complete: function() { From df84cbba14d4490697dfe03478787e8d8c81955e Mon Sep 17 00:00:00 2001 From: vadivelJ96 Date: Thu, 9 Oct 2025 17:14:02 +0530 Subject: [PATCH 02/28] CHANGE_Post_app_having_pre_branch_id - VADIVEL J 2025-10-09 --- app/Controllers/ClientController.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 36b62d05..63ddac11 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -1137,7 +1137,7 @@ class ClientController extends AdminController return $this->respond([ 'status' => false, 'code' => 409, - 'message' => 'The pre branch id '.$data['pre_branch_id'].' is already mapped with another branch. Please check.', + 'message' => 'The branch is already mapped with another branch. Please check.', ], 409); } } @@ -1266,7 +1266,7 @@ class ClientController extends AdminController return $this->respond([ 'status' => false, 'code' => 409, - 'message' => 'The pre branch id '.$data['pre_branch_id'].' is already mapped with another branch. Please check.', + 'message' => 'The branch is already mapped with another branch. Please check.', ], 409); } } @@ -7202,7 +7202,7 @@ class ClientController extends AdminController $post_hr_id = $value['post_hr_id']; $preBranchId = $this->getPreBranchIdByPostBranchId($post_branch_id); - + if (!empty($preBranchId)) { $value['pre_branch_id'] = $preBranchId; $value['pre_client_id'] = $this->getPreClientIdByPreBranchId($preBranchId); From 51b74549ac330581e55812cd66a8903be5026ff6 Mon Sep 17 00:00:00 2001 From: vadivelJ96 Date: Thu, 9 Oct 2025 17:56:09 +0530 Subject: [PATCH 03/28] CHANGE_UI_FIX - VADIVEL J 2025-10-09 --- app/Views/client_onboarding.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/Views/client_onboarding.php b/app/Views/client_onboarding.php index 567fc409..4b6693ed 100755 --- a/app/Views/client_onboarding.php +++ b/app/Views/client_onboarding.php @@ -418,7 +418,7 @@
- @@ -434,7 +434,7 @@
- @@ -1156,4 +1156,10 @@ }) + + + $(function() { + $('.select2').select2(); + }); + \ No newline at end of file From 11bef9921f68fa8f761b72e5b7f049ff1bc25122 Mon Sep 17 00:00:00 2001 From: vadivelJ96 Date: Thu, 9 Oct 2025 20:28:57 +0530 Subject: [PATCH 04/28] CHANGE_UI_FIX - VADIVEL J 2025-10-09 --- app/Views/client_onboarding.php | 62 ++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 28 deletions(-) diff --git a/app/Views/client_onboarding.php b/app/Views/client_onboarding.php index 4b6693ed..70b8e3b5 100755 --- a/app/Views/client_onboarding.php +++ b/app/Views/client_onboarding.php @@ -1043,38 +1043,47 @@ \ No newline at end of file From bbbd968431b37bfeb21e9e0f6fda7d105856cf88 Mon Sep 17 00:00:00 2001 From: vadivelJ96 Date: Fri, 10 Oct 2025 09:48:06 +0530 Subject: [PATCH 05/28] CHANGE_UI_FIX - VADIVEL J 2025-10-10 --- app/Views/client_onboarding.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/Views/client_onboarding.php b/app/Views/client_onboarding.php index 70b8e3b5..b27a9673 100755 --- a/app/Views/client_onboarding.php +++ b/app/Views/client_onboarding.php @@ -1052,6 +1052,9 @@ $('#auto_fetch_branch').html(``); + $('.loader').fadeIn(); + $('.loader-mask').fadeIn(); + $.ajax({ url: "", type: "POST", @@ -1076,6 +1079,8 @@ console.error("Error occurred:", status, error); }, complete: function() { + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); console.log("auto_fetch_client call is completed..!!"); } }); From 16e93fccccde5edcae1bed09f764d13a03a10349 Mon Sep 17 00:00:00 2001 From: vadivelJ96 Date: Fri, 10 Oct 2025 10:56:28 +0530 Subject: [PATCH 06/28] CHANGE_UI_FIX - VADIVEL J 2025-10-10 --- app/Views/client_branch.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/Views/client_branch.php b/app/Views/client_branch.php index f5d435b8..f11fcd7a 100755 --- a/app/Views/client_branch.php +++ b/app/Views/client_branch.php @@ -302,6 +302,7 @@ $('#btnBranchAdd').click(function() { $('#district').val(''); $('#branch_city').val(''); $('#branch_form')[0].reset(); + $('#branch_form').parsley().reset(); $('.ac').css('display', 'block'); contactCount = 1 @@ -392,8 +393,15 @@ $("#branch_form").submit(function(event) { $('.loader').fadeIn(); $('.loader-mask').fadeIn(); + + + if (branch_PrimaryKey == '') { + $('#branch_form input[name="pre_branch_id"]').val(''); + } + var formData = new FormData($('#branch_form')[0]); + const jsonString = JSON.stringify(selectedValues); const level_contect_data_json_string = JSON.stringify(level_contect_data); console.log('jsonString', jsonString); @@ -484,7 +492,7 @@ $("#branch_form").submit(function(event) { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); console.log('Something Wrong!', 'warning'); - if(xhr.status == 409){ + if(xhr.status === 409){ alert('The Current Branch is Already Existing..!!'); } }, 300); @@ -554,7 +562,7 @@ $('body').on('click', '.btnBranchEdit', function() { $('#district').val(res.data.district); $('#branch_city').val(res.data.city); $('#branch_PrimaryKey').val(res.data.id); - $('#pre_branch_id').val(res.data.pre_branch_id) + $('#pre_branch_id').val(res.data.pre_branch_id??'') if(res.data.sez == 1){ $('#sez').prop('checked', true); From 148c2785647ccec3b0833fec2e8006c2133e3268 Mon Sep 17 00:00:00 2001 From: vadivelJ96 Date: Fri, 10 Oct 2025 12:29:20 +0530 Subject: [PATCH 07/28] CHANGE_UI_FIX - VADIVEL J 2025-10-10 --- app/Views/client_branch.php | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/app/Views/client_branch.php b/app/Views/client_branch.php index f11fcd7a..f35d5f99 100755 --- a/app/Views/client_branch.php +++ b/app/Views/client_branch.php @@ -302,7 +302,8 @@ $('#btnBranchAdd').click(function() { $('#district').val(''); $('#branch_city').val(''); $('#branch_form')[0].reset(); - $('#branch_form').parsley().reset(); + $('#branch_form').parsley().reset(); + $('#pre_branch_id').val(''); $('.ac').css('display', 'block'); contactCount = 1 @@ -393,12 +394,6 @@ $("#branch_form").submit(function(event) { $('.loader').fadeIn(); $('.loader-mask').fadeIn(); - - - if (branch_PrimaryKey == '') { - $('#branch_form input[name="pre_branch_id"]').val(''); - } - var formData = new FormData($('#branch_form')[0]); From 9e661ad4c2d2fd5bf396b8d59e91cfa05582f81a Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Fri, 10 Oct 2025 15:13:38 +0530 Subject: [PATCH 08/28] FIX_LIVE_ISSUE_GTLI_TERMS : RV --- app/Controllers/EmployeeRestController.php | 23 +++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 341bfcf2..1b7310b6 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -2868,14 +2868,14 @@ class EmployeeRestController extends AdminController }else if($ClientPolicyValue['policy_type_id'] == 6) { - $policyGroup = 'gpa'; + $policyGroup = 'other'; $data['ticket_type_id'] = 3; $data['claim_subject'] = "Claim EDLI"; $data['sum_insured_label'] = "Sum Assured"; }else if($ClientPolicyValue['policy_type_id'] == 7) { - $policyGroup = 'gpa'; + $policyGroup = 'other'; $data['ticket_type_id'] = 4; $data['claim_subject'] = "Claim GTLI"; $data['sum_insured_label'] = "Sum Assured"; @@ -2969,9 +2969,6 @@ class EmployeeRestController extends AdminController function policyTermsFiter($terms , $type) { - - - $gpa = [ "sumInsured2" => "Sum Insured", "totalSumInsured" => "Total Sum Assured", @@ -3021,8 +3018,6 @@ class EmployeeRestController extends AdminController "moderntreatmentsasperirdai" => "Modern Treatment " ]; - - $finalarray = []; if($type == 'gpa'){ foreach ($gpa as $key => $value) { @@ -3046,6 +3041,18 @@ class EmployeeRestController extends AdminController $finalarray[$terms->gpa_special_condition_label[$i]] = $terms->gpa_special_condition_input[$i]; } } + }else if($type == 'other'){ + foreach ($terms as $key => $value) { + if($key != "multiple_sum_insured" && $value != ""){ + $result = ucwords(str_replace('_', ' ', $key)); + $finalarray[$result] = $value; + } + } + if(isset(($terms->gpa_special_condition_label)) && is_array($terms->gpa_special_condition_label) && is_array($terms->gpa_special_condition_input)){ + for ($i=0; $i < count($terms->gpa_special_condition_label); $i++) { + $finalarray[$terms->gpa_special_condition_label[$i]] = $terms->gpa_special_condition_input[$i]; + } + } }else{ foreach ($gmc as $key => $value) { if(isset($terms->$key)) @@ -3070,9 +3077,7 @@ class EmployeeRestController extends AdminController } } - return $finalarray; - } From 2dc2447fb6232d83f47d3ac1202a2a81ab58b221 Mon Sep 17 00:00:00 2001 From: venba-Inspriron-3558 Date: Fri, 10 Oct 2025 18:58:15 +0530 Subject: [PATCH 09/28] FIX_75. The system should allow the same HR contact to be linked with different corporates, instead of restricting them to just one. --- app/Config/Routes.php | 1 + app/Controllers/ClientController.php | 9 +++++ app/Models/ClientModel.php | 13 +++++++ app/Views/client_branch.php | 53 +++++++++++++++++++++++++++- 4 files changed, 75 insertions(+), 1 deletion(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index d640d843..10fb373c 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -172,6 +172,7 @@ $routes->group("/client", ["filter" => "authMVC"], function ($routes) { $routes->group("others", ["filter" => "authMVC"], function ($routes) { $routes->post("create", "ClientController::createOtherTabContent"); + $routes->post('check-duplicate', 'ClientController::validateDuplicateByClientBranch'); }); }); diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 63ddac11..fb0c5d6f 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -132,6 +132,15 @@ class ClientController extends AdminController //-------------------------------------------------------------------------------------------------------- + public function validateDuplicateByClientBranch() + { + $request = service('request'); + $value = $request->getPost('value'); + $clientId = $request->getPost('client_id'); + $branchId = $request->getPost('branch_id'); + $isDuplicate = $this->clientModel->isDuplicateByClientBranch($value, $clientId, $branchId); + return $this->response->setJSON(['isDuplicate' => $isDuplicate]); + } public function checkDuplicateTableFieldValue() { $table = $this->request->getPost('table'); diff --git a/app/Models/ClientModel.php b/app/Models/ClientModel.php index 9abe8929..09db986d 100755 --- a/app/Models/ClientModel.php +++ b/app/Models/ClientModel.php @@ -226,5 +226,18 @@ class ClientModel extends Model return $result; } + public function isDuplicateByClientBranch($email, $clientId, $branchId) + { + $builder = $this->db->table('level_contacts lc') + ->select('lc.id') + ->join('client_branch cb', 'lc.ref_id = cb.id', 'left') + ->where('lc.email', $email) + ->where('lc.contact_type', 'client') + ->where('cb.client_id', $clientId) + ->where('lc.ref_id', $branchId) + ->get(); + + return $builder->getNumRows() > 0 ? true : false; + } } diff --git a/app/Views/client_branch.php b/app/Views/client_branch.php index f35d5f99..4db64b3b 100755 --- a/app/Views/client_branch.php +++ b/app/Views/client_branch.php @@ -649,7 +649,7 @@ function appendContactHtml(contact = false, reset = false) {
- +
@@ -972,6 +972,57 @@ function validateInput(input, table, field, submitButId){ } +function validateDuplicateByClientBranch(input, submitButId) { + let value = $(input).val().trim(); + let clientId = $('#client_id_branch').val(); + let branchId = $('#branch_id_primarykey').val(); + console.log(`Ln968 cId: ${clientId} | bId: ${branchId}`); + + // Don't forgot be careful + // 1 Local duplication check (User entered) + let isLocalDuplicate = false; + $('input[name="email[]"]').each(function() { + if (this !== input && $(this).val().trim() === value && value !== '') { + isLocalDuplicate = true; + return false; // break loop + } + }); + + if (isLocalDuplicate) { + console.log(`r u n Local`); + toastr.warning("Email is duplicate!", 'WARNING'); + $('#' + submitButId).prop('disabled', true); + return; // don’t call server if duplicate in UI + } + + // Don't forgot be careful + // 2 Server-side duplicate check (DB) + if (!isLocalDuplicate && value !== '') { + console.log(`r u n Server`); + $.ajax({ + url: '', + type: 'POST', + data: { + client_id: clientId, + branch_id: branchId, + value: value + }, + dataType: 'json', + success: function(response) { + if (response.isDuplicate) { + toastr.warning("Email already exists!", 'WARNING'); + $('#' + submitButId).prop('disabled', true); + } else { + $('#' + submitButId).prop('disabled', false); + } + }, + error: function(xhr, status, error) { + console.error('AJAX Error:', error); + } + }); + } +} + function getContactsData() { const contacts = []; From d0c7ea1143502251bbdb7e1ad5f05c201f4235bf Mon Sep 17 00:00:00 2001 From: venba-Inspriron-3558 Date: Sat, 11 Oct 2025 12:00:29 +0530 Subject: [PATCH 10/28] FIX_resolved - Email duplication based on ClientBrach vvj reported --- app/Views/client_branch.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Views/client_branch.php b/app/Views/client_branch.php index 4db64b3b..024c3741 100755 --- a/app/Views/client_branch.php +++ b/app/Views/client_branch.php @@ -198,7 +198,7 @@
+ name="email[]" id="email" data-parsley-trigger="change" data-parsley-type="email" onkeyup="validateDuplicateByClientBranch(this, 'branchBtnSubmit')" required>
From 21310082a032c24a4b1ee5a216be878e4aabf01e Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Sat, 11 Oct 2025 15:32:27 +0530 Subject: [PATCH 11/28] CHANGE_EB_EXCEL_CHANGE : RV --- app/Controllers/LeadsController.php | 38 ++++-- app/Views/leads_form.php | 176 +++++++++++++++++++++++++--- app/Views/leads_form_handler.php | 1 - app/Views/rfq/gpa.php | 79 ++++++++++--- 4 files changed, 252 insertions(+), 42 deletions(-) diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index 40afde50..59608e7e 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -138,7 +138,10 @@ class LeadsController extends BaseController $this->cause_of_death = [ 'natural_death' => 'Natural Death', 'suicide' => 'Suicide', - 'accident' => 'Accident' + 'accident' => 'Accident', + 'cardiac_arrest' => 'Cardiac Arrest', + 'septic_shock' => 'Septic shock', + 'heart_attack' => 'Heart Attack', ]; $this->member_data_excel_columns = [ @@ -2408,8 +2411,11 @@ class LeadsController extends BaseController $row = 2; foreach ($claim_details['finyear'] as $record) { $col = 'A'; - foreach ($record as $value) { + foreach ($record as $array_key => $value) { $label = ucwords(str_replace('_', ' ', ($value ?? ""))); + if(in_array($array_key, ['sum_insured', 'claim_amount', 'settled'])){ + $label = formatIndianCurrency(intval($label)); + } $sheet->setCellValue($col . $row, $label); $col++; } @@ -2427,19 +2433,27 @@ class LeadsController extends BaseController } // Enable wrap text for all cells - $maxColLetter = chr(64 + count($headers)); // Last column letter - $sheet->getStyle("A2:{$maxColLetter}{$row}")->getAlignment()->setWrapText(true); + // $maxColLetter = chr(64 + count($headers)); // Last column letter + // $sheet->getStyle("A2:{$maxColLetter}{$row}")->getAlignment()->setWrapText(true); - // Optional: center vertically for neatness - $sheet->getStyle("A2:{$maxColLetter}{$row}")->getAlignment()->setVertical(\PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER); + // // Optional: center vertically for neatness + // $sheet->getStyle("A2:{$maxColLetter}{$row}")->getAlignment()->setVertical(\PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER); - // Optional: Make row height auto (helps when wrap text is on) - for ($i = 2; $i < $row; $i++) { - $sheet->getRowDimension($i)->setRowHeight(-1); - } + $maxColLetter = chr(64 + count($headers)); + $dataRange = "A1:{$maxColLetter}" . ($row - 1); - } - } + $sheet->getStyle($dataRange)->getAlignment() + ->setWrapText(true) + ->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER) + ->setVertical(\PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER); + + // Optional: Make row height auto (helps when wrap text is on) + for ($i = 2; $i < $row; $i++) { + $sheet->getRowDimension($i)->setRowHeight(-1); + } + + } + } // Save to temporary location $uploadFilePath = WRITEPATH . 'tmp/' . $filename; diff --git a/app/Views/leads_form.php b/app/Views/leads_form.php index 12ef9a30..52902934 100644 --- a/app/Views/leads_form.php +++ b/app/Views/leads_form.php @@ -1862,6 +1862,7 @@ let claimData = []; $(".claim-row").each(function() { + let year = $(this).find("[name='first_year[]']").val(); let claimAmount = $(this).find("[name='first_claim_amount[]']").val(); let claimStatus = $(this).find("[name='first_claim_status[]']").val(); @@ -1869,13 +1870,22 @@ let causeOfDeath = $(this).find("[name='first_cause_of_death[]']").val(); let deathDate = $(this).find("[name='first_death_date[]']").val(); + let emp_id = $(this).find("[name='emp_id[]']").val(); + let emp_name = $(this).find("[name='emp_name[]']").val(); + let gender = $(this).find("[name='gender[]']").val(); + let designation = $(this).find("[name='designation[]']").val(); + let sum_insured = $(this).find("[name='sum_insured[]']").val(); + claimData.push({ "year": year, - "claim_amount": claimAmount, - "status": claimStatus, - "claim_type": claimType, + "emp_id": emp_id, + "emp_name": emp_name, + "gender": gender, + "designation": designation, + "sum_insured": sum_insured, + "death_date": deathDate, "cause_of_death": causeOfDeath, - "death_date": deathDate + "settled": claimAmount, }); }); @@ -1893,6 +1903,93 @@ //----------------------------------------------------------------------------------------------------------- + // do not remove this + // function appendThreeYearsClaims(count) { + + // // let count = $('#appendAreaForClaim').data('count'); + // console.log("count", count); + + // let policy_type_id = $('#policy_type_id_' + count).val() + // console.log('policy_type_id', policy_type_id); + + // console.log('claimIndex from parent', claimIndex); + // let increment = claimIndex; + + // let claimsFields = ` + //
+ + //
+ // + // + //
+ //
+ // + // + //
+ //
+ // + // + //
+ // + // + // + //
+ //
+ // x + // + + //
+ //
+ //
+ // `; + + // // Append new claim fields + // let referenceDiv = document.getElementById('appendAreaForClaim_' + count); + + // if (referenceDiv) { + // referenceDiv.insertAdjacentHTML('beforeend', claimsFields); + // } else { + // console.error('Element not found: appendAreaForClaim_' + count); + // } + + // // Increment claim index + // console.log("claim index " + claimIndex); + // claimIndex++; + // console.log("after claim index " + claimIndex); + + // if (policy_type_id == 1) { + // $('.gpaClaimFileds').show(); + // $('.lifeClaimFields').hide(); + // } else if (policy_type_id == 6 || policy_type_id == 7) { + // $('.gpaClaimFileds').hide(); + // $('.lifeClaimFields').show(); + // } + + // // Initialize Select2 for the newly added fields + // $("#first_year_" + increment).select2(); + // $("#claim_type_" + increment).select2(); + // $("#first_cause_of_death_" + increment).select2(); + + // toggleRequiredFields(); + // } + function appendThreeYearsClaims(count) { // let count = $('#appendAreaForClaim').data('count'); @@ -1916,15 +2013,46 @@ } ?>
+
- - + +
+ +
- - + +
-