From de07c1c06100dce15c9b59f2983ebc71e78f6b89 Mon Sep 17 00:00:00 2001 From: venba-Inspriron-3558 Date: Sat, 11 Oct 2025 11:58:32 +0530 Subject: [PATCH 1/6] FIX_resolved - Email duplication based on ClientBrach vvj reported --- app/Views/client_branch.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Views/client_branch.php b/app/Views/client_branch.php index fe817b3..b8370c8 100755 --- a/app/Views/client_branch.php +++ b/app/Views/client_branch.php @@ -207,7 +207,7 @@
+ name="email[]" id="email" data-parsley-trigger="change" data-parsley-type="email" onkeyup="validateDuplicateByClientBranch(this, 'branchBtnSubmit')" required>
@@ -946,11 +946,11 @@ function validateInput(input, table, field, submitBtnId){ } 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; From 6dfdb270a23ee798a5e55d8bc5a8ee140c542061 Mon Sep 17 00:00:00 2001 From: venba-Inspriron-3558 Date: Sat, 11 Oct 2025 16:05:16 +0530 Subject: [PATCH 2/6] FIX_resolved - Email duplication based on ClientBrach vrs reported --- app/Controllers/ClientController.php | 10 ++++---- app/Models/ClientModel.php | 4 ++-- app/Views/client_branch.php | 35 +++++++++++++++++----------- 3 files changed, 29 insertions(+), 20 deletions(-) diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 7d412c5..d2eb167 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -153,11 +153,11 @@ 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); + $value = $this->request->getPost('value'); + $clientId = $this->request->getPost('client_id'); + $branchId = $this->request->getPost('branch_id'); + $field = $this->request->getPost('field'); + $isDuplicate = $this->clientModel->isDuplicateByClientBranch($value, $field, $clientId, $branchId); return $this->response->setJSON(['isDuplicate' => $isDuplicate]); } diff --git a/app/Models/ClientModel.php b/app/Models/ClientModel.php index d7708b7..89c77d6 100755 --- a/app/Models/ClientModel.php +++ b/app/Models/ClientModel.php @@ -214,12 +214,12 @@ class ClientModel extends Model return $result; } - public function isDuplicateByClientBranch($email, $clientId, $branchId) + public function isDuplicateByClientBranch($value, $field, $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.'.$field, $value) ->where('lc.contact_type', 'client') ->where('cb.client_id', $clientId) ->where('lc.ref_id', $branchId) diff --git a/app/Views/client_branch.php b/app/Views/client_branch.php index b8370c8..297451d 100755 --- a/app/Views/client_branch.php +++ b/app/Views/client_branch.php @@ -207,12 +207,12 @@
+ name="email[]" id="email" data-parsley-trigger="change" data-parsley-type="email" onchange="validateDuplicateByClientBranch(this, 'email','branchBtnSubmit')" required>
- +
- +
@@ -945,17 +945,21 @@ function validateInput(input, table, field, submitBtnId){ } -function validateDuplicateByClientBranch(input, submitButId) { - +function validateDuplicateByClientBranch(input, field, 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}`); + let label = $(input).closest('.form-group').find('label').text().replace('*', '').trim(); + let message = label ? label + " is duplicate!" : "Value is duplicate!"; + + console.log(`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 !== '') { + $('input[name="' + field + '[]"]').each(function(index) { + console.log(`Entered value: ${value} | Contact ${index+1} value: ${$(this).val()}`); + if (this !== input && $(this).val().trim() === value) { isLocalDuplicate = true; return false; // break loop } @@ -963,7 +967,8 @@ function validateDuplicateByClientBranch(input, submitButId) { if (isLocalDuplicate) { console.log(`r u n Local`); - toastr.warning("Email is duplicate!", 'WARNING'); + console.log(`btn Dis - true`); + toastr.warning(message, 'WARNING'); $('#' + submitButId).prop('disabled', true); return; // don’t call server if duplicate in UI } @@ -971,21 +976,25 @@ function validateDuplicateByClientBranch(input, submitButId) { // 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 + value: value, + field: field }, dataType: 'json', success: function(response) { if (response.isDuplicate) { - toastr.warning("Email already exists!", 'WARNING'); + console.log(`r u n Server`); + console.log(`btn Dis - true`); + toastr.warning(message, 'WARNING'); $('#' + submitButId).prop('disabled', true); } else { + console.log(`btn Dis - false`); $('#' + submitButId).prop('disabled', false); } }, From dabbda38091a80c7cd9d3cb7ed1ef3e5839882fa Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Sat, 11 Oct 2025 16:10:01 +0530 Subject: [PATCH 3/6] GWM --- app/Controllers/EmployeeRestController.php | 68 +++++++--------------- 1 file changed, 22 insertions(+), 46 deletions(-) diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 9bab925..904f54a 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -1774,53 +1774,28 @@ class EmployeeRestController extends AdminController public function getClientDetails() { - log_message('error', 'STEP 1: getClientDetails called'); - try { - // STEP 2: Extract Authorization header - $jwt = $this->request->getHeaderLine('Authorization'); - log_message('error', 'STEP 2: Authorization header: ' . $jwt); + $pre_client_id = $this->request->getGet('pre_client_id'); + $pre_branch_id = $this->request->getGet('pre_branch_id'); + $post_client_id = $this->request->getGet('post_client_id'); + $post_branch_id = $this->request->getGet('post_branch_id'); + - $jwtParts = explode(' ', $jwt); - if (count($jwtParts) < 2) { - log_message('error', 'STEP 2.1: Invalid Authorization header format'); - return $this->respond(['status' => 'failed', 'code' => 400, 'data' => 'Invalid Authorization header'], 400); - } + if ($pre_client_id != null) { + - $token = $jwtParts[1]; - log_message('error', 'STEP 3: Extracted JWT token'); - - $tokenParts = explode('.', $token); - if (count($tokenParts) !== 3) { - log_message('error', 'STEP 3.1: Invalid JWT structure'); - return $this->respond(['status' => 'failed', 'code' => 400, 'data' => 'Invalid JWT token'], 400); - } - - $decodedPayload = json_decode(base64_decode($tokenParts[1]), true); - log_message('error', 'STEP 4: Decoded JWT payload: ' . json_encode($decodedPayload)); - - $token_type = $decodedPayload['token_type'] ?? null; - log_message('error', 'STEP 5: Token type = ' . $token_type); - - $client_id = $this->request->getGet('client_id'); - $client_branch_id = $this->request->getGet('client_branch_id'); - log_message('error', 'STEP 6: Query params - client_id: ' . $client_id . ', client_branch_id: ' . $client_branch_id); - - if ($token_type === 'pre') { - log_message('error', 'STEP 7: Handling "pre" token type'); - - $client = $this->clientModel->where('id', $client_id)->first(); + $client = $this->clientModel->where('id', $pre_client_id)->first(); if ($client) { - log_message('error', 'STEP 8: Found client: ' . json_encode($client)); + $client['client_logo'] = base_url() . 'public/uploads/logo/' . $client['client_logo']; $clientPolicy = $this->clientPolicyModel - ->where('client_id', $client_id) - ->where('client_branch_id', $client_branch_id) + ->where('client_id', $pre_client_id) + ->where('client_branch_id', $pre_branch_id) ->findAll(); - log_message('error', 'STEP 9: Found client policy count: ' . count($clientPolicy)); + return $this->respond([ 'status' => 'success', @@ -1831,33 +1806,34 @@ class EmployeeRestController extends AdminController ] ], 200); } else { - log_message('error', 'STEP 10: No client found for client_id: ' . $client_id); + return $this->respond(['status' => 'failed', 'code' => 404, 'data' => []], 404); } - } elseif ($token_type === 'post') { - log_message('error', 'STEP 11: Handling "post" token type'); + } elseif ($post_client_id != null) { + $restAuthController = new RestAuthenticationController; $queryParams = [ - 'client_id' => $client_id, - 'client_branch_id' => $client_branch_id + 'client_id' => $post_client_id, + 'client_branch_id' => $post_branch_id ]; - log_message('error', 'STEP 12: Calling post enrollment API with params: ' . json_encode($queryParams)); + return $restAuthController->callThirdPartyGETAPI($queryParams, 'getClientDetails'); - return $restAuthController->callThirdPartyGETAPI($queryParams, 'getClientDetails', ['token' => $jwt]); } else { - log_message('error', 'STEP 13: Unknown token_type: ' . $token_type); + return $this->respond(['status' => 'failed', 'code' => 404, 'data' => []], 404); } } catch (\Exception $e) { - log_message('error', 'STEP 14: Exception occurred - ' . $e->getMessage()); + return $this->respond(['status' => 'failed', 'code' => 500, 'data' => $e->getMessage()], 500); } } + + public function getSiMappedArray($policy_id,$base_policy_id) { $selfGMC = $this->employeeModel->select('employees.name , employee_polices.basic_cover_si') From 2221f628882fd46eeda898e82dfbf3a48e3d306e Mon Sep 17 00:00:00 2001 From: venba-Inspriron-3558 Date: Sat, 11 Oct 2025 17:23:22 +0530 Subject: [PATCH 4/6] FIX_Branch id checked --- app/Views/client_branch.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/Views/client_branch.php b/app/Views/client_branch.php index 297451d..0fc1fa1 100755 --- a/app/Views/client_branch.php +++ b/app/Views/client_branch.php @@ -315,6 +315,7 @@ $('#btnBranchAdd').click(function() { $('#branch_form').parsley().reset(); $('.ac').css('display', 'block'); $('#post_branch_id').val(''); + $('#branch_id_primarykey').val(''); contactCount = 1 var addButton = document.getElementById('add'); @@ -378,6 +379,8 @@ $("#branch_form").submit(function(event) { var selectedValues = $("#selected").val(); console.log(selectedValues, selectedValues); + console.log("branch_id_primarykey", $('#branch_id_primarykey').val()); + let level_contect_data = getContactsData(); console.log('level_contect_data', level_contect_data); From fcfef148e216a179439e9935d07afbb85e09e99a Mon Sep 17 00:00:00 2001 From: vadivelJ96 Date: Sat, 11 Oct 2025 18:19:03 +0530 Subject: [PATCH 5/6] CHANGE_UI_FIX - VADIVEL J 2025-10-11 --- app/Views/client_branch.php | 2 +- app/Views/client_onboarding.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Views/client_branch.php b/app/Views/client_branch.php index 882a7f1..1e4ee40 100755 --- a/app/Views/client_branch.php +++ b/app/Views/client_branch.php @@ -73,7 +73,7 @@
+ class="btn btn-primary waves-effect waves-light btn-sm "> Fetch Client Branch (Post-Enrolment)
diff --git a/app/Views/client_onboarding.php b/app/Views/client_onboarding.php index 40cf999..dc37b06 100755 --- a/app/Views/client_onboarding.php +++ b/app/Views/client_onboarding.php @@ -115,7 +115,7 @@ body {