From b9320f22daaab0b42a87405c2aae7a7fb4182c4d Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Fri, 21 Jun 2024 15:38:49 +0530 Subject: [PATCH 1/9] FIX_RACK_RATE_ISSUES_AND_OTHER : RV --- app/Controllers/ClientController.php | 54 ++++-- app/Views/client_info.php | 5 +- app/Views/other_policy_terms.php | 189 +++++++++++++------ app/Views/policy_gmc_terms.php | 20 +- app/Views/policy_gpa_terms.php | 12 +- app/Views/policy_grid.php | 262 +++++++++++++++------------ 6 files changed, 335 insertions(+), 207 deletions(-) diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 86556e52..0503143e 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -1907,7 +1907,7 @@ class ClientController extends AdminController "sum_insured" => "Sum Insured", "family_floater" => "Family Floater", "family_floaters" => "Family Floaters", - "member_count" => "Elders Count:", + "elders_count" => "Elders Count:", "other_member_min_age" => "Min Age:", "other_member_max_age" => "Min Age:", "waiverofpreexistingdiseases" => "Waiver of Pre-existing Diseases", @@ -2067,19 +2067,27 @@ class ClientController extends AdminController } else if (array_key_exists($key, $mapping)) { $transformedData[$mapping[$key]] = $value; } else if ($key == 'special_condition_label') { - - foreach ($value as $key => $value) { - $transformedData[$value] = $data['special_condition_input'][$key]; + + if (is_array($value)) { + foreach ($value as $key => $value) { + $transformedData[$value] = $data['special_condition_input'][$key]; + } } - } else if ($key == 'gpa_special_condition_label') { - foreach ($value as $key => $value) { - $transformedData[$value] = $data['gpa_special_condition_input'][$key]; + } else if ($key == 'gpa_special_condition_label') { + if (is_array($value)) { + foreach ($value as $key => $value) { + $transformedData[$value] = $data['gpa_special_condition_input'][$key]; + } + } + } else if ($key == 'other_special_condition_label') { + if (is_array($value)) { + foreach ($value as $key => $value) { + $transformedData[$value] = $data['other_special_condition_label'][$key]; + } } } else if ($key == 'age_ratio') { - if (isset($data['sumInsured2'])) { - $transformedData['Self'] = "(Min: " . $data['age_ratio']['self']['min'] . ", Max: " . $data['age_ratio']['self']['max'] . ")"; } } else { @@ -2217,21 +2225,33 @@ class ClientController extends AdminController } - public function getPolicyTerms($client_policy_id){ + public function getPolicyTerms($client_policy_id) + { $policy_terms = $this->clientPolicyModel->where('id', $client_policy_id)->first(); - if(isset($policy_terms['policy_terms']) && $policy_terms['policy_terms'] != null){ + if (isset($policy_terms['policy_terms']) && $policy_terms['policy_terms'] != null) { $JSON = json_decode($policy_terms['policy_terms']); - $si = $JSON->sum_insured ?? $JSON->sumInsured2; - $multi_si = $JSON->multiple_sum_insured; - $multi_si[] = $si; - }else{ - $$multi_si = []; + + $si = null; + if (isset($JSON->sum_insured) && !empty($JSON->sum_insured)) { + $si = $JSON->sum_insured; + } elseif (isset($JSON->sumInsured2) && !empty($JSON->sumInsured2)) { + $si = $JSON->sumInsured2; + } + + if ($si !== null) { + $multi_si = $JSON->multiple_sum_insured ?? []; + $multi_si[] = $si; + } else { + $multi_si = []; + } + } else { + $multi_si = []; } - return $this->respond(['status' => true, 'data'=>$multi_si], 200); + return $this->respond(['status' => true, 'data' => $multi_si], 200); } diff --git a/app/Views/client_info.php b/app/Views/client_info.php index f029a2b0..bcad4293 100644 --- a/app/Views/client_info.php +++ b/app/Views/client_info.php @@ -270,18 +270,20 @@ $(document).ready(function() { $(document).on('click', '.policy_terms', function() { var terms = $(this).data('id'); console.log(terms); + console.log(JSON.stringify(terms)); // terms = JSON.parse(terms); $('#modal_body').empty(); function createListItems(obj) { + const fragment = document.createDocumentFragment(); for (const key in obj) { if (obj.hasOwnProperty(key) && obj[key] !== null && obj[key] !== '' && key != 'family_floater' && key != 'gpa_special_condition_input' && key != 'gpa_special_condition_label' && key != 'special_condition_label' && key != - 'special_condition_input' && key != 'age_ratio') { + 'special_condition_input' && key != 'age_ratio' && key != "multiple_sum_insured" && key != "other_special_condition_label" && key != "other_special_condition_input") { const listItem = document.createElement('li'); @@ -326,6 +328,7 @@ $(document).on('click', '.policy_terms', function() { } $('#modal_body').append(createListItems(terms)); + }); \ No newline at end of file diff --git a/app/Views/other_policy_terms.php b/app/Views/other_policy_terms.php index 6e1160c2..d21d40c4 100644 --- a/app/Views/other_policy_terms.php +++ b/app/Views/other_policy_terms.php @@ -78,7 +78,8 @@ label { x -
+
@@ -87,7 +88,7 @@ label { -
+

@@ -108,12 +109,10 @@ label { @@ -395,13 +422,14 @@ $(document).on('click', '#otherPolicyTermsClose', function() { }); -$("#sumInsured2").on("keyup", function() { +$("#sum_insured_others").on("keyup", function() { var inputNumber = $(this).val(); + console.log('sum_insured_others keyup', inputNumber) if (inputNumber) { var result = convertCommaNumberToWords(inputNumber); - $("#numberToWordSumInsured").text(result); + $("#numberToWordOthers").text(result); } else { - $("#numberToWordSumInsured").text(""); + $("#numberToWordOthers").text(""); } }); @@ -417,6 +445,20 @@ $("#totalSumInsured").on("keyup", function() { }); +function si_keup_num_to_word2(input) { + + console.log('keyup sum insured'); + var inputNumber = $(input).val(); + console.log(inputNumber) + if (inputNumber) { + var result = convertCommaNumberToWords(inputNumber); + + $("#numberToWordOthers").text(result); + } else { + $("#numberToWordOthers").text(""); + } +}; + function appendPolicyTermsHTML(policy_type) { @@ -429,6 +471,25 @@ function appendPolicyTermsHTML(policy_type) {
+
+
+ +
+
+ +
+
+ +
+
+
+
+
+
+
+ +
+
@@ -523,11 +584,30 @@ function appendPolicyTermsHTML(policy_type) { ` } else if (policy_type == 6) { - + termsHTML = `
+
+
+ +
+
+ +
+
+ +
+
+
+
+
+
+
+ +
+
@@ -592,28 +672,31 @@ function appendPolicyTermsHTML(policy_type) { } -function appendOtherTermsSIAddMore(data = null){ +function appendOtherSIAddMore(data = null) { - console.log('function called') + const addMoreContainer = document.getElementById('sum_insured_add_more'); - var html = ` -
-
- -
-
- -
-
- - -
-
-
-
-
`; + console.log(addMoreContainer) - $('#other_si_add_more').append(html); + const html = ` +
+
+ +
+
+ +
+
+ + +
+
+
+
+
+
+
`; + + addMoreContainer.insertAdjacentHTML('beforeend', html); } - \ No newline at end of file diff --git a/app/Views/policy_gmc_terms.php b/app/Views/policy_gmc_terms.php index f64b7f4b..a28f44df 100644 --- a/app/Views/policy_gmc_terms.php +++ b/app/Views/policy_gmc_terms.php @@ -111,9 +111,9 @@
- +
-
+
@@ -141,14 +141,14 @@ Self: -
Min Age:
-
Max Age:
+
Min Age:
+
Max Age:
Spouse: -
Min Age:
-
Max Age:
+
Min Age:
+
Max Age:
Children: @@ -190,8 +190,8 @@
Elders Count:
-
Min Age:
-
Max Age:
+
Min Age:
+
Max Age:
@@ -1418,9 +1418,9 @@
- +
-
+
diff --git a/app/Views/policy_gpa_terms.php b/app/Views/policy_gpa_terms.php index b19fd8a6..8754b519 100644 --- a/app/Views/policy_gpa_terms.php +++ b/app/Views/policy_gpa_terms.php @@ -91,9 +91,9 @@
- +
-
+
@@ -137,13 +137,13 @@
Min Age: - +
Max Age: - +
@@ -792,9 +792,9 @@
- +
-
+
diff --git a/app/Views/policy_grid.php b/app/Views/policy_grid.php index 927895d0..b1fa3667 100644 --- a/app/Views/policy_grid.php +++ b/app/Views/policy_grid.php @@ -827,12 +827,16 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa }; -$("#GridForm").submit(async function(event) { +$("#GridForm").submit(function(event) { + + event.preventDefault(); var check = checkDuplicate(0); console.log(check) + if(check){ + return; + } - event.preventDefault(); if ($('#grid_emp_count').val() == 'false') { toastr.warning('Client has active employees', 'Warning'); @@ -854,9 +858,16 @@ $("#GridForm").submit(async function(event) { checkPolicyTermsSI(function(result) { + + console.log('checkPolicyTermsSI callback') + console.log(result); + if (!result) { - if (check) { + console.log('after result'); + + + if (check = false) { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); } else { @@ -901,15 +912,14 @@ $("#GridForm").submit(async function(event) { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); - toastr.warning(`Value does not exist in the Policy Terms.`); - + toastr.warning(`Sum Insured Amount does not exist in the Policy Terms.`); } -}).catch(function(error) { - console.error('Error checking policy terms:', error); - // Handle error if necessary - toastr.error(`Error checking policy terms: ${error}`); - }); + }).catch(function(error) { + console.error('Error checking policy terms:', error); + // Handle error if necessary + console.log(`Error checking policy terms: ${error}`); + }); }); @@ -941,46 +951,61 @@ $("#AdditionalGridForm").submit(function(event) { var formData = new FormData($('#AdditionalGridForm')[0]); var policy_form_action = ''; + checkPolicyTermsSI(function(result) { - if (check) { - $('.loader').fadeOut(); - $('.loader-mask').delay(350).fadeOut('slow'); - } else { - $.ajax({ - data: formData, - url: policy_form_action, - type: "POST", - dataType: 'json', - processData: false, - contentType: false, - success: function(res) { - - //console.log("Response", res); - - if (res.status === false) { - toastr.error('Policy Dose Not Create', 'Error'); - return; - } + if (!result) { + if (check) { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); + } else { + $.ajax({ + data: formData, + url: policy_form_action, + type: "POST", + dataType: 'json', + processData: false, + contentType: false, + success: function(res) { - var message = (policy_PrimaryKey === '') ? - 'Policy Additional Rack Rate Added successfully' : - 'Policy Additional Rack Rate Added Successfully'; - toastr.success(message, 'Success'); - $('.close').click(); + //console.log("Response", res); - }, - error: function(xhr, status, error) { + if (res.status === false) { + toastr.error('Policy Dose Not Create', 'Error'); + return; + } - console.error(xhr.responseText); - console.error(status, error); - $('.loader').fadeOut(); - $('.loader-mask').delay(350).fadeOut('slow'); + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + + var message = (policy_PrimaryKey === '') ? + 'Policy Additional Rack Rate Added successfully' : + 'Policy Additional Rack Rate Added Successfully'; + toastr.success(message, 'Success'); + $('.close').click(); + + }, + error: function(xhr, status, error) { + + console.error(xhr.responseText); + console.error(status, error); + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + } + }); } - }); - } + + }else{ + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + toastr.warning(`Sum Insured Amount does not exist in the Policy Terms.`); + } + + }).catch(function(error) { + console.error('Error checking policy terms:', error); + // Handle error if necessary + console.log(`Error checking policy terms: ${error}`); + }); }); @@ -2936,126 +2961,123 @@ function checkTermsSISameAsRackRateSI(input) { } - function checkPolicyTermsSI(callback) { +function checkPolicyTermsSI(callback) { + console.log('checkPolicyTermsSI function called'); - console.log('r function called'); - - var id = $('#additional_grid')[0]; + var id = $('#additional_grid')[0]; var container = $('#additional_grid_content_input'); - var val = 0; + var val = 0; if (val == 0) { id = $('#grid')[0]; container = $('#grid_content_input'); } - console.log(id); console.log(container); - var siInputs = 0; + var siInputs = null; - if (id.value === '2') { - siInputs = container.find('input[name="gpa_si"]'); - } else if (id.value === '3') { - siInputs = container.find('input[name="3_si[]"]'); - } else if (id.value === '4') { - siInputs = container.find('input[name="4_si[]"]'); - } else if (id.value === '5') { - siInputs = container.find('input[name="5_si[]"]'); - } else if (id.value === '6') { - siInputs = container.find('input[name="6_si[]"]'); - } else if (id.value === '7') { - siInputs = container.find('input[name="7_si[]"]'); - } else if (id.value === '8') { - siInputs = container.find('input[name="8_si[]"]'); - } else if (id.value === '9') { - siInputs = container.find('input[name="9_si[]"]'); - } else if (id.value === '10') { - siInputs = container.find('input[name="10_si[]"]'); - } else if (id.value === '11') { - siInputs = container.find('input[name="11_si[]"]'); - } else if (id.value === '1') { - var selectedValue = $('#si_or_bp').val(); - - if (selectedValue == 1) { - siInputs = container.find('input[name="gpa_sum_si[]"]'); - } else if (selectedValue == 3) { - siInputs = container.find('input[name="gpa_sum_si2[]"]'); - } + switch (id.value) { + case '1': + var selectedValue = $('#si_or_bp').val(); + if (selectedValue == 1) { + siInputs = container.find('input[name="gpa_sum_si[]"]'); + } else if (selectedValue == 3) { + siInputs = container.find('input[name="gpa_sum_si2[]"]'); + } + break; + case '2': + siInputs = container.find('input[name="gpa_si"]'); + break; + case '3': + siInputs = container.find('input[name="3_si[]"]'); + break; + case '4': + siInputs = container.find('input[name="4_si[]"]'); + break; + case '5': + siInputs = container.find('input[name="5_si[]"]'); + break; + case '6': + siInputs = container.find('input[name="6_si[]"]'); + break; + case '7': + siInputs = container.find('input[name="7_si[]"]'); + break; + case '8': + siInputs = container.find('input[name="8_si[]"]'); + break; + case '9': + siInputs = container.find('input[name="9_si[]"]'); + break; + case '10': + siInputs = container.find('input[name="10_si[]"]'); + break; + case '11': + siInputs = container.find('input[name="11_si[]"]'); + break; + default: + siInputs = []; } + console.log('siInputs', siInputs); + var client_policy_id = $('#client_policy_id').val(); - console.log('client_policy_id', client_policy_id) + console.log('client_policy_id', client_policy_id); var url = '' + client_policy_id; - var arrayLength = 0; + console.log('url', url); $.ajax({ url: url, type: 'GET', dataType: 'json', success: function(response) { + console.log(response); console.log(response.data); - var array1 = response.data; - var array2 = []; + var policy_terms_si = response.data; + var rack_rate_si = []; siInputs.each(function() { var input = $(this).val(); - array2.push(input.replace(/,/g, '')); + rack_rate_si.push(input.replace(/,/g, '')); }); - console.log('array1', array1) - console.log('array2', array2) + console.log('policy_terms_si', policy_terms_si); + console.log('rack_rate_si', rack_rate_si); + let new_array = []; - function intersection(arr1, arr2) { - return arr1.filter(value => arr2.includes(value)); + rack_rate_si.forEach(element => { + if (!policy_terms_si.includes(element)) { + new_array.push(element); + } + }); + + console.log('filtered array', new_array); + + var arrayLength = new_array.length; + console.log('arrayLength', arrayLength); + + if (arrayLength > 0) { + callback(true); + } else { + callback(false); } - - var commonElements = intersection(array1, array2); - - function removeCommonElements(arr, common) { - return arr.filter(value => !common.includes(value)); - } - - array1 = removeCommonElements(array1, commonElements); - array2 = removeCommonElements(array2, commonElements); - - console.log('array1', array1) - console.log('array2', array2) - - - // var result = array1.concat(array2); - var result = array1; - - console.log('result', result) - - arrayLength = result.length; - - console.log('arrayLength', arrayLength) - - if (arrayLength > 0) { - callback(true); - } else { - callback(false); - } - }, error: function(xhr, status, error) { - console.error(xhr.responseText); - console.error(status, error); - toastr.error(`Failed to retrieve Policy Terms. Error: ${error}`); + console.log(xhr.responseText); + console.log(status, error); + console.log(`Failed to retrieve Policy Terms. Error: ${error}`); callback(false); } }); - - } \ No newline at end of file From 9ff46033eb61773250e07a2c41d53c048138c448 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Fri, 21 Jun 2024 17:20:29 +0530 Subject: [PATCH 2/9] FIX_RACK_RATE_TERMS_FIELD_NAME_CNG : RV --- app/Controllers/ClientController.php | 63 ++++++++++++++++++---------- app/Views/client_info.php | 18 ++++++-- app/Views/policy_gmc_terms.php | 23 +++++++--- app/Views/policy_gpa_terms.php | 14 +++++-- app/Views/policy_grid.php | 6 +-- 5 files changed, 83 insertions(+), 41 deletions(-) diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 0503143e..ba3da3d8 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -2227,33 +2227,50 @@ class ClientController extends AdminController public function getPolicyTerms($client_policy_id) { - $policy_terms = $this->clientPolicyModel->where('id', $client_policy_id)->first(); - - - if (isset($policy_terms['policy_terms']) && $policy_terms['policy_terms'] != null) { - $JSON = json_decode($policy_terms['policy_terms']); - - $si = null; - if (isset($JSON->sum_insured) && !empty($JSON->sum_insured)) { - $si = $JSON->sum_insured; - } elseif (isset($JSON->sumInsured2) && !empty($JSON->sumInsured2)) { - $si = $JSON->sumInsured2; - } - - if ($si !== null) { - $multi_si = $JSON->multiple_sum_insured ?? []; - $multi_si[] = $si; - } else { - $multi_si = []; - } - } else { - $multi_si = []; + + if (!$policy_terms) { + return $this->respond(['status' => false, 'error' => 'Policy not found'], 404); } - + + if (is_array($policy_terms)) { + if (!isset($policy_terms['policy_terms'])) { + return $this->respond(['status' => false, 'error' => 'Policy terms not found in array'], 500); + } + $JSON = json_decode($policy_terms['policy_terms']); + } elseif (is_object($policy_terms)) { + if (!isset($policy_terms->policy_terms)) { + return $this->respond(['status' => false, 'error' => 'Policy terms not found in object'], 500); + } + $JSON = json_decode($policy_terms->policy_terms); + } else { + return $this->respond(['status' => false, 'error' => 'Unexpected data type for policy terms'], 500); + } + + if (!$JSON) { + return $this->respond(['status' => false, 'error' => 'Invalid JSON format in policy terms'], 500); + } + + $multi_si = []; + + if (isset($JSON->sum_insured) && !empty($JSON->sum_insured)) { + $multi_si[] = $JSON->sum_insured; + } elseif (isset($JSON->sumInsured2) && !empty($JSON->sumInsured2)) { + $multi_si[] = $JSON->sumInsured2; + } + + if (isset($JSON->multiple_sum_insured) && is_array($JSON->multiple_sum_insured)) { + foreach ($JSON->multiple_sum_insured as $msi) { + if (!empty($msi)) { + $multi_si[] = $msi; + } + } + } + return $this->respond(['status' => true, 'data' => $multi_si], 200); } - + + public function getPolicyTermsFormJson($policy_type_id){ diff --git a/app/Views/client_info.php b/app/Views/client_info.php index bcad4293..9eebe82d 100644 --- a/app/Views/client_info.php +++ b/app/Views/client_info.php @@ -280,10 +280,20 @@ $(document).on('click', '.policy_terms', function() { const fragment = document.createDocumentFragment(); for (const key in obj) { - if (obj.hasOwnProperty(key) && obj[key] !== null && obj[key] !== '' && key != - 'family_floater' && key != 'gpa_special_condition_input' && key != - 'gpa_special_condition_label' && key != 'special_condition_label' && key != - 'special_condition_input' && key != 'age_ratio' && key != "multiple_sum_insured" && key != "other_special_condition_label" && key != "other_special_condition_input") { + if ( + obj.hasOwnProperty(key) && + obj[key] !== null && + obj[key] !== '' && + key != 'family_floater' && + key != 'family_floater' && + key != 'gpa_special_condition_input' && + key != 'gpa_special_condition_label' && + key != 'special_condition_label' && + key != 'special_condition_input' && + key != 'age_ratio' && + key != "multiple_sum_insured" && + key != "other_special_condition_label" && + key != "other_special_condition_input") { const listItem = document.createElement('li'); diff --git a/app/Views/policy_gmc_terms.php b/app/Views/policy_gmc_terms.php index a28f44df..28ff4417 100644 --- a/app/Views/policy_gmc_terms.php +++ b/app/Views/policy_gmc_terms.php @@ -507,7 +507,7 @@
From 644a525976141d55b5d8d950b448682b8fc644bd Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Fri, 21 Jun 2024 19:57:29 +0530 Subject: [PATCH 3/9] FIX_CLIENT_INFO_AND_RR_CHECK_SI : RV --- app/Views/client_info.php | 82 ++++++++++++++++++++++----------------- app/Views/policy_grid.php | 23 +++++++---- 2 files changed, 62 insertions(+), 43 deletions(-) diff --git a/app/Views/client_info.php b/app/Views/client_info.php index 9eebe82d..94bc56ee 100644 --- a/app/Views/client_info.php +++ b/app/Views/client_info.php @@ -16,7 +16,8 @@
- +
-
+
@@ -204,7 +205,7 @@
-
+
@@ -253,7 +254,7 @@ - @@ -270,62 +271,71 @@ $(document).ready(function() { $(document).on('click', '.policy_terms', function() { var terms = $(this).data('id'); console.log(terms); + console.log(terms.length); console.log(JSON.stringify(terms)); + + // terms = JSON.parse(terms); $('#modal_body').empty(); function createListItems(obj) { - + + if (obj.length == 0) { + const message = document.createElement('div'); + message.textContent = 'Policy Terms Not Available'; + message.style.display = 'flex'; + message.style.justifyContent = 'center'; + message.style.alignItems = 'center'; + message.style.height = '100%'; // Adjust as necessary to fit the context + message.style.textAlign = 'center'; + return message; + } + const fragment = document.createDocumentFragment(); for (const key in obj) { if ( - obj.hasOwnProperty(key) && - obj[key] !== null && - obj[key] !== '' && - key != 'family_floater' && - key != 'family_floater' && - key != 'gpa_special_condition_input' && - key != 'gpa_special_condition_label' && - key != 'special_condition_label' && - key != 'special_condition_input' && - key != 'age_ratio' && - key != "multiple_sum_insured" && - key != "other_special_condition_label" && - key != "other_special_condition_input") { - + obj.hasOwnProperty(key) && + obj[key] !== null && + obj[key] !== '' && + key !== 'family_floater' && + key !== 'gpa_special_condition_input' && + key !== 'gpa_special_condition_label' && + key !== 'special_condition_label' && + key !== 'special_condition_input' && + key !== 'age_ratio' && + key !== 'multiple_sum_insured' && + key !== 'other_special_condition_label' && + key !== 'other_special_condition_input' + ) { const listItem = document.createElement('li'); + let formattedKey = key.replace(/_/g, ' '); - var formattedKey = ''; - formattedKey = key.replace(/_/g, ' '); - obj[key] = obj[key].replace(/<\/?[^>]+>/gi, ''); + console.log('type', typeof obj[key]) + // Strip HTML tags from values + if (typeof obj[key] === 'string') { + console.log('before', obj[key]) + obj[key] = obj[key].replace(/<\/?[^>]+>/gi, ''); + console.log('after', obj[key]) + } + + // Convert 0 and 1 to 'No' and 'Yes' if (obj[key] == 0) { obj[key] = 'No'; } - if (obj[key] == 1) { obj[key] = 'Yes'; } - console.log(formattedKey) - - if (key == 'burnExpenses' && obj[key] == 'Yes') { - - listItem.innerHTML = - `${formattedKey.charAt(0).toUpperCase() + formattedKey.slice(1)}: ${obj['burnExpensesData']}`; - - } else if (typeof obj[key] === 'object' && !Array.isArray(obj[key])) { - + // Handle nested objects + if (typeof obj[key] === 'object' && !Array.isArray(obj[key])) { listItem.innerHTML = `${formattedKey.charAt(0).toUpperCase() + formattedKey.slice(1)}:`; const nestedList = document.createElement('ul'); - nestedList.appendChild(createListItems(obj[key])); - listItem.appendChild(nestedList); - } else { listItem.innerHTML = `${formattedKey.charAt(0).toUpperCase() + formattedKey.slice(1)}: ${Array.isArray(obj[key]) ? JSON.stringify(obj[key]) : obj[key]}`; @@ -337,8 +347,8 @@ $(document).on('click', '.policy_terms', function() { return fragment; } + $('#modal_body').append(createListItems(terms)); }); - \ No newline at end of file diff --git a/app/Views/policy_grid.php b/app/Views/policy_grid.php index d80a764c..a4f5a177 100644 --- a/app/Views/policy_grid.php +++ b/app/Views/policy_grid.php @@ -2597,6 +2597,8 @@ function si_orbp_change_function() { // $('.gpa_sum_insure_remove').remove(); var selectedValue = $('#si_or_bp').val(); + console.log('selectedValue', selectedValue) + if (selectedValue == 2) { $('.gpa_sum_insure_remove').hide(); @@ -2682,8 +2684,8 @@ function si_orbp_change_function() { $('#basic_multiplier').removeAttr('required', false); $('#premium_multiplier').removeAttr('required', false); $('#basic_pay').removeAttr('required', false); - $('#gpa_basic_si').removeAttr('required', false); - $('#gpa_basic_premium').removeAttr('required', false); + $('#gpa_basic_si_first').removeAttr('required', false); + $('#gpa_basic_premium_first').removeAttr('required', false); $('#gpa_sum_multiplier2').removeAttr('required', false); $('#gpa_sum_si2').removeAttr('required', false); @@ -2734,8 +2736,8 @@ function si_orbp_change_function() { $('#basic_multiplier').removeAttr('required', false); $('#premium_multiplier').removeAttr('required', false); $('#basic_pay').removeAttr('required', false); - $('#gpa_basic_si').removeAttr('required', false); - $('#gpa_basic_premium').removeAttr('required', false); + $('#gpa_basic_si_first').removeAttr('required', false); + $('#gpa_basic_premium_first').removeAttr('required', false); $('#gpa_sum_multiplier').attr('required', false); $('#gpa_sum_si').attr('required'); @@ -2994,13 +2996,13 @@ function checkPolicyTermsSI(callback) { siInputs = container.find('input[name="3_si[]"]'); break; case '4': - siInputs = container.find('input[name="4_si[]"]'); + siInputs = container.find('input[name="4_si"]'); break; case '5': siInputs = container.find('input[name="5_si[]"]'); break; case '6': - siInputs = container.find('input[name="6_si[]"]'); + siInputs = container.find('input[name="6_si"]'); break; case '7': siInputs = container.find('input[name="7_si[]"]'); @@ -3009,7 +3011,7 @@ function checkPolicyTermsSI(callback) { siInputs = container.find('input[name="8_si[]"]'); break; case '9': - siInputs = container.find('input[name="9_si[]"]'); + siInputs = container.find('input[name="gpa_si"]'); break; case '10': siInputs = container.find('input[name="10_si[]"]'); @@ -3017,6 +3019,12 @@ function checkPolicyTermsSI(callback) { case '11': siInputs = container.find('input[name="11_si[]"]'); break; + case '12': + siInputs = container.find('input[name="12_si[]"]'); + break; + case '13': + siInputs = container.find('input[name="13_si[]"]'); + break; default: siInputs = []; } @@ -3044,6 +3052,7 @@ function checkPolicyTermsSI(callback) { siInputs.each(function() { var input = $(this).val(); + console.log('input value', input); rack_rate_si.push(input.replace(/,/g, '')); }); From b32e9f80ac90c1660043ea54d3f0a9432be9784a Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Mon, 24 Jun 2024 17:26:46 +0530 Subject: [PATCH 4/9] CHANGE_EMP_FILTER_ADD_2_FIELDS_CHECK_HR_NO_DATATABLE_CSV : RV --- app/Config/Routes.php | 1 + app/Controllers/ClientController.php | 12 ++++ app/Controllers/EmployeeController.php | 7 ++- app/Models/EmployeePolicyModel.php | 79 +++++++++++++++++++------- app/Views/client_branch.php | 31 +++++++++- app/Views/employee_list.php | 22 +++++-- app/Views/endorsement_list.php | 32 ++++++++--- app/Views/layout/footer.php | 1 + app/Views/policy_grid_excel.php | 16 ++++-- 9 files changed, 158 insertions(+), 43 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 041caaa3..73ce3697 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -248,6 +248,7 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) { $routes->get("check_policy_type/(:any)", "ClientController::checkPolicyType/$1"); $routes->get("getPolicyTerms/(:any)", "ClientController::getPolicyTerms/$1"); $routes->get("getPolicyTermsFormJson/(:any)", "ClientController::getPolicyTermsFormJson/$1"); + $routes->get("checkHRNumber/(:any)", "ClientController::checkHRNumber/$1"); }); $routes->cli('cli/processjob', 'JobWorker::processJob'); diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index ba3da3d8..7b5c4e8d 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -2283,4 +2283,16 @@ class ClientController extends AdminController } + public function checkHRNumber($mobileNumber) + { + try { + $mobileNumberCount = $this->levelContactModel->where('mobile', $mobileNumber)->countAllResults(); + return $this->respond(['status' => true, 'data' => $mobileNumberCount], 200); + } catch (\Exception $e) { + log_message('error', 'Error checking mobile number: ' . $e->getMessage()); + return $this->respond(['status' => false, 'data' => 0, 'message' => 'An error occurred while checking the mobile number. Please try again later.'], 500); + } + } + + } \ No newline at end of file diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index 80571810..c2447397 100644 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -79,13 +79,16 @@ class EmployeeController extends AdminController $data['employees'] = $this->employeePolicyModel->getEmployeePolicy( client_id: $filterData['client_id'], policy_id: $filterData['policy_id'], - status: $filterData['status'], - branch_id: $filterData['branch_id'] + branch_id: $filterData['branch_id'], + emp_code : $filterData['emp_code'], + emp_name : $filterData['emp_name'], + status : $filterData['status'], ); $data['getData'] = $filterData; } + // dd($this->request->getGet()); $this->myLogger->logme('error', 'list called'); $this->loadLayout('employee_list', $data); } diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php index 2dcac592..15bf295d 100644 --- a/app/Models/EmployeePolicyModel.php +++ b/app/Models/EmployeePolicyModel.php @@ -76,31 +76,68 @@ class EmployeePolicyModel extends Model } // ----------------------------------------------------------------------------------------------------- - public function getEmployeePolicy($client_id,$policy_id,$status,$branch_id) + public function getEmployeePolicy($client_id = 0, $policy_id=0, $status=0, $branch_id=0, $emp_code="", $emp_name="") { - $result = $this->select(['employee_polices.*','pm.name as policy_name','im.short_name as insurer_short_name','ib.branch_name as insurer_branch_name','ib.branch_code as insurer_branch_code','tpam.name as tpa_name','tpam.short_name as tpa_short_name','tpab.branch_code as tpa_branch_code','cm.client_name','cm.short_name as client_short_name','emp.relationship','emp.relationship_code','emp.change_event','emp.emp_code','emp.name','emp.email_corporate','emp.dob','emp.gender','emp.emp_status','emp.is_active as emp_is_active','emp.mobile as mobile']) - ->join('employees emp', 'employee_polices.employee_id = emp.id') - ->join('client_policy cp', 'employee_polices.client_policy_id = cp.id') //cp - client policy - ->join('policies pm', 'cp.policy_id = pm.id') //pm - policy master - ->join('insurers im', 'cp.insurer_id = im.id') //im - insurar master - ->join('insurer_branch ib', 'cp.insurer_branch_id = ib.id') //ib - insurar branch - ->join('tpa tpam', 'cp.tpa_id = tpam.id','left') //tpam - tpa master - ->join('tpa_branch tpab', 'cp.tpa_branch_id = tpab.id','left') //tpab - tpa brach - ->join('clients cm', 'cp.client_id = cm.id') //cm - client master - ->where('emp.client_id',$client_id) - ->where('emp.client_branch_id',$branch_id) - ->where('employee_polices.is_active',1) - ->where('emp.is_active',1) - ->where('employee_polices.client_policy_id',$policy_id) - ->orderBy('emp.emp_code','ASC')->orderBy('employee_polices.employee_id','ASC'); - - - if($status != 0 && !empty($status)){ + + $result = $this->select([ + 'employee_polices.*', + 'pm.name as policy_name', + 'im.short_name as insurer_short_name', + 'ib.branch_name as insurer_branch_name', + 'ib.branch_code as insurer_branch_code', + 'tpam.name as tpa_name', + 'tpam.short_name as tpa_short_name', + 'tpab.branch_code as tpa_branch_code', + 'cm.client_name', + 'cm.short_name as client_short_name', + 'emp.relationship', + 'emp.relationship_code', + 'emp.change_event', + 'emp.emp_code', + 'emp.name', + 'emp.email_corporate', + 'emp.dob', + 'emp.gender', + 'emp.emp_status', + 'emp.is_active as emp_is_active', + 'emp.mobile as mobile' + ]) + ->join('employees emp', 'employee_polices.employee_id = emp.id') + ->join('client_policy cp', 'employee_polices.client_policy_id = cp.id') //cp - client policy + ->join('policies pm', 'cp.policy_id = pm.id') //pm - policy master + ->join('insurers im', 'cp.insurer_id = im.id') //im - insurer master + ->join('insurer_branch ib', 'cp.insurer_branch_id = ib.id') //ib - insurer branch + ->join('tpa tpam', 'cp.tpa_id = tpam.id', 'left') //tpam - tpa master + ->join('tpa_branch tpab', 'cp.tpa_branch_id = tpab.id', 'left') //tpab - tpa branch + ->join('clients cm', 'cp.client_id = cm.id') //cm - client master + ->orderBy('emp.emp_code', 'ASC') + ->orderBy('employee_polices.employee_id', 'ASC'); + + // Conditionally add where clauses + if ($client_id !=0 && !empty($client_id)) { + $result->where('emp.client_id', $client_id); + } + if ($branch_id !=0 && !empty($branch_id)) { + $result->where('emp.client_branch_id', $branch_id); + } + if ($policy_id !=0 && !empty($policy_id)) { + $result->where('employee_polices.client_policy_id', $policy_id); + } + if ($status !=0 && !empty($status)) { $result->where('employee_polices.status', $status); } + if (!empty($emp_code)) { + $result->where('emp.emp_code', $emp_code); + } + if (!empty($emp_name)) { + $result->like('emp.name', $emp_name); + } - $result = $result->findAll(); - return ($result); + // Always check these conditions + $result->where('employee_polices.is_active', 1) + ->where('emp.is_active', 1); + + return $result->findAll(); } diff --git a/app/Views/client_branch.php b/app/Views/client_branch.php index 93ea7137..213f47c2 100644 --- a/app/Views/client_branch.php +++ b/app/Views/client_branch.php @@ -89,7 +89,7 @@
- +
@@ -423,7 +423,7 @@ $(document).ready(function () {
- +
@@ -563,6 +563,33 @@ $(document).ready(function () { + function checkMobileNumber(input){ + + console.log('function called') + console.log(input); + console.log('Input Value', input.value); + + var mobileNumber = input.value; + var url = '' + mobileNumber; + + $.get(url, function(response){ + + console.log(response) + console.log(response.data) + + if(response.data > 0){ + toastr.warning('The Mobile Number Already Exist.', 'Warning'); + input.value = ""; + return; + } + + }).fail(function(xhr, status, error) { + console.error(xhr.responseText); + console.error(status, error); + }); + + } + \ No newline at end of file diff --git a/app/Views/employee_list.php b/app/Views/employee_list.php index 479260a6..65b8285b 100644 --- a/app/Views/employee_list.php +++ b/app/Views/employee_list.php @@ -59,6 +59,16 @@ table.dataTable tbody td {
+
+
+ +
+ +
+
+ +
+
@@ -318,18 +328,22 @@ function fetchEmpolyeeList(event) { var policy_id = $('#policies').val(); var status = $('#status2').val(); var branch_id = $('#branch_id').val(); + var emp_code = $('#emp_code').val(); + var emp_name = $('#emp_name').val(); // console.log(client_id + '-' + policy_id); - if (client_id == '0' || policy_id == '0') { - alert('Please select values in both dropdowns.'); - return; - } + // if (client_id == '0' || policy_id == '0') { + // alert('Please select values in both dropdowns.'); + // return; + // } var queryParams = { client_id: client_id, policy_id: policy_id, branch_id: branch_id, + emp_code : emp_code, + emp_name : emp_name, status : status, }; diff --git a/app/Views/endorsement_list.php b/app/Views/endorsement_list.php index 4fa12d55..45f7423b 100644 --- a/app/Views/endorsement_list.php +++ b/app/Views/endorsement_list.php @@ -587,16 +587,25 @@ dom: "<'row'<'col-sm-0'f><'col-sm-9 text-right'B>>" + "<'row'<'col-sm-12'tr>>" + "<'row'<'col-sm-5'i><'col-sm-7'p>>", - "buttons": [{ - "extend": 'csv', - "text": 'CSV', - "title": 'Endorsement-List', - "className": 'my_class', - "exportOptions": { - "columns": ':not(:last-child)' - }, + buttons: [{ + extend: 'csv', + text: 'CSV', + title: 'Endorsement-List', + className: 'my_class', + exportOptions: { + columns: ':not(:last-child)', + format: { + body: function (data, row, column, node) { + // Convert data to string to avoid scientific notation in CSV + if (!isNaN(data) && parseFloat(data) > 1e20) { + return `'${data}`; + } + return data.toString();// Ensures all data is treated as strings + } + } + } }], - "initComplete": function(settings, json) { + initComplete: function(settings, json) { $('.my_class').css({ "position": "relative", "left": "79px" @@ -608,7 +617,12 @@ }, paging: true, // pagingType: 'full_numbers' + columnDefs: [ + { type: 'scientific', targets: 0 } // Apply custom sorting type to the first column + ], }); + + }); \ No newline at end of file diff --git a/app/Views/layout/footer.php b/app/Views/layout/footer.php index 11e7405f..f43042ed 100644 --- a/app/Views/layout/footer.php +++ b/app/Views/layout/footer.php @@ -136,6 +136,7 @@ + \ No newline at end of file From 33a07a816ed1d5298e213c9468bec5e695e05320 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Mon, 24 Jun 2024 17:38:16 +0530 Subject: [PATCH 5/9] FIX_LEVEL_CONTACT_QUERY : RV --- app/Controllers/ClientController.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 7b5c4e8d..02269a95 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -2286,8 +2286,16 @@ class ClientController extends AdminController public function checkHRNumber($mobileNumber) { try { - $mobileNumberCount = $this->levelContactModel->where('mobile', $mobileNumber)->countAllResults(); - return $this->respond(['status' => true, 'data' => $mobileNumberCount], 200); + $mobileNumberCount = $this->levelContactModel + ->join('client_branch', 'client_branch.id = level_contacts.ref_id') + ->join('clients', 'clients.id = client_branch.client_id') + ->where('clients.is_active', 1) + ->where('client_branch.is_active', 1) + ->where('level_contacts.is_active', 1) + ->where('level_contacts.contact_type', 'client') + ->where('level_contacts.mobile', $mobileNumber) + ->countAllResults(); + return $this->respond(['status' => true, 'data' => $mobileNumberCount, 'message' => "try"], 200); } catch (\Exception $e) { log_message('error', 'Error checking mobile number: ' . $e->getMessage()); return $this->respond(['status' => false, 'data' => 0, 'message' => 'An error occurred while checking the mobile number. Please try again later.'], 500); From 4cd6a4aee4c05085ac062da14d96e4ae3c11ac1e Mon Sep 17 00:00:00 2001 From: bitbucket Date: Tue, 25 Jun 2024 10:10:13 +0530 Subject: [PATCH 6/9] FEATURE_ chat bot : GWM --- app/Config/Routes.php | 7 +- app/Controllers/ChatBotController.php | 118 ++++++++++++++++++++++++++ app/Models/ChatBotModel.php | 22 +++++ 3 files changed, 145 insertions(+), 2 deletions(-) create mode 100644 app/Controllers/ChatBotController.php create mode 100644 app/Models/ChatBotModel.php diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 34426123..95cbabf3 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -267,9 +267,9 @@ $routes->group("/api", ["filter" => "authJWT"], function ($routes) { - +$routes->get("getChatResponse", "ChatBotController::getChatResponse"); $routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) { - + $routes->get("getChatResponse", "ChatBotController::getChatResponse"); $routes->get("getEmployeeProfile", "EmployeeRestController::getEmployeeProfile"); $routes->post("employeeUpload", "EmployeeRestController::employeeUpload"); $routes->get("relationshipList", "EmployeeRestController::relationshipList"); @@ -300,6 +300,9 @@ $routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) { $routes->get("getAdvertisementImage", "EmployeeRestController::getAdvertisementImage"); }); + + + $routes->post("sendEmail", "EmployeeRestController::send_email"); diff --git a/app/Controllers/ChatBotController.php b/app/Controllers/ChatBotController.php new file mode 100644 index 00000000..d048ada7 --- /dev/null +++ b/app/Controllers/ChatBotController.php @@ -0,0 +1,118 @@ +myLogger = \Config\Services::mylogger(); + $this->employeeModel = new EmployeeModel(); + $this->employeePolicyModel = new EmployeePolicyModel(); + $this->clientModel = new ClientModel(); + $this->clientRMModel = new ClientRMModel(); + $this->policesModel = new PolicesModel(); + $this->relationshipModel = new RelationshipModel(); + $this->fileModel= new FileModel(); + $this->clientPolicyModel = new ClientPolicyModel(); + $this->policyPremium1Model = new PolicyPremium1Model(); + $this->policyPremium2Model = new PolicyPremium2Model(); + $this->policyTypeModel = new PolicyTypeModel(); + $this->notificationModel = new NotificationModel(); + $this->userModel = new UserModel(); + $this->feContentModel = new FEContentModel(); + $this->addImgModel = new AddImgModel(); + $this->ChatBotModel = new ChatBotModel(); + } + + + public function getChatResponse() + { + // try { + $request_for = $this->request->getGet('request_for'); + $option = $this->request->getGet('option'); + + $requestData = $this->ChatBotModel->where('request', $request_for) + ->where('is_active', 1 ) + ->first(); + + if ($requestData) { + + + + if($option != 0){ + + $decodedData = json_decode($requestData['options'],true); + + $requestFor = $decodedData[$request_for][$option]; + + $requestData = $this->ChatBotModel->where('request', $requestFor) + ->where('is_active', 1 ) + ->first(); + } + + + $result = ['request_for'=>$requestData['request'],'options'=>json_decode($requestData['options'],true)]; + return $this->respond(['status' => 'success','code' => 200,'data' => $result ],200); + + + + + } else { + + return $this->respond(['status' => 'failed','code' => 404,'data' => 'No Data'],404); + } + // } catch (\Throwable $th) { + // return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500); + // } + } + + + +} + diff --git a/app/Models/ChatBotModel.php b/app/Models/ChatBotModel.php new file mode 100644 index 00000000..caae27a5 --- /dev/null +++ b/app/Models/ChatBotModel.php @@ -0,0 +1,22 @@ + \ No newline at end of file From 9d6c23ff4e5dccc6dd33a3f602fa5a00e03fc97b Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Tue, 25 Jun 2024 15:08:21 +0530 Subject: [PATCH 7/9] FIX_DELETE_CONFIRM_ROLE_AND_OTHERS : RV --- app/Config/Routes.php | 2 +- app/Controllers/ClientController.php | 9 +- app/Controllers/MasterController.php | 22 +- app/Helpers/utility_helper.php | 9 + app/Models/CDMasterModel.php | 22 + app/Models/ClientPolicyModel.php | 2 + app/Views/cd_master_list.php | 56 +- app/Views/client_branch.php | 790 +++++++++++++++------------ app/Views/client_list.php | 71 ++- app/Views/client_policy.php | 11 +- app/Views/client_rm.php | 4 +- app/Views/insurer_branch.php | 70 ++- app/Views/insurer_list.php | 65 ++- app/Views/kyc_docs.php | 69 ++- app/Views/kyc_list.php | 68 ++- app/Views/policies.php | 72 +-- app/Views/policy_type_list.php | 65 ++- app/Views/tpa_branch.php | 66 ++- app/Views/tpa_list.php | 66 ++- 19 files changed, 890 insertions(+), 649 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 73ce3697..9567f9a7 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -213,7 +213,7 @@ $routes->group("/master", ["filter" => "authMVC"], function ($routes) { $routes->post("create", "MasterController::createCDMasterData"); $routes->post("edit", "MasterController::editCDMasterData"); $routes->get("list/(:any)", "MasterController::getCDMasterDataByID/$1"); - // $routes->get("remove/(:any)", "MasterController::policyTypeRemove/$1"); + $routes->get("remove/(:any)", "MasterController::removeCDMaster/$1"); }); }); diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 02269a95..2a3e5782 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -301,9 +301,9 @@ class ClientController extends AdminController $editData['client_kyc'] = $this->clientKYCDocsModel->where('client_id', $id)->findAll(); $editData['client_branch'] = $this->clientBranchModel->where(['client_id' => $id, 'is_active' => 1])->findAll(); $editData['client_relation'] = $this->clientRMModel->where(['client_id' => $id, 'is_active' => 1])->findAll(); - // dd('Hi'); + $editData['client_branch']['role'] = get_role_id(); $clientPoliceData = $this->clientPolicyModel->getClientPolicyByClientId($id); - // dd($this->clientPolicyModel->getLastQuery()); + foreach ($clientPoliceData as $key => $value) { $clientPoliceData[$key]->policy_start_date = date('d-M-Y', strtotime($value->policy_start_date)); @@ -311,12 +311,10 @@ class ClientController extends AdminController } $editData['client_policy'] = $clientPoliceData; - - $editData['notification'] =$this->notificationModel->select('template_name,enabled')->where('client_id',$id)->findAll(); $editData['placeHolders'] = ['member_name','nhance_logo','tpa_id','ecard_download_link', 'client_logo', 'policy_no', 'member_summary', 'app_link', 'post_enrollment_app_link', 'client_name']; - + // dd($editData); echo view('layout/header', $headerData); echo view('client_onboarding', $editData); echo view('layout/footer'); @@ -565,6 +563,7 @@ class ClientController extends AdminController if($insert){ $branchData = $this->clientBranchModel->where('client_id', $this->request->getPost('client_id'))->findAll(); + $branchData['role'] = get_role_id(); return $this->respond(['status' => true,'code' => 200,'data' => $branchData], 200); }else{ return $this->respond(['status' => false,'code' => 404, 'message' => 'no data found'], 200); diff --git a/app/Controllers/MasterController.php b/app/Controllers/MasterController.php index 04f1e336..5d6ec3b9 100644 --- a/app/Controllers/MasterController.php +++ b/app/Controllers/MasterController.php @@ -1123,13 +1123,7 @@ class MasterController extends AdminController public function CDMasterList() { - $data['CD_Master_Data'] = $this->CDMasterModel - ->select('cd_master.*, clients.client_name, clients.short_name, insurers.name as insurer_name, user_profiles.first_name as user_name') - ->join('clients', 'clients.id = cd_master.client_id') - ->join('insurers', 'insurers.id = cd_master.insurer_id') - ->join('user_profiles', 'user_profiles.id = cd_master.created_by') - ->where('cd_master.is_active', 1) - ->findAll(); + $data['CD_Master_Data'] = $this->CDMasterModel->getCDMasterList(); $data['insurers'] = $this->insurerModel->findAll(); $data['clients'] = $this->clientModel->findAll(); $this->loadLayout('cd_master_list', $data); @@ -1217,4 +1211,18 @@ class MasterController extends AdminController } } + + public function removeCDMaster($id){ + + $this->myLogger->logme('error','CDMaster Remove function called'); + $data['updated_by'] = get_session_userid(); + $data['is_active'] = 0; + $update = $this->CDMasterModel->where('id', $id)->set($data)->update(); + if($update){ + return $this->respond(['status' => true,'code' => 200], 200); + }else{ + return $this->respond(['status' => false,'code' => 404], 200); + } + } + } \ No newline at end of file diff --git a/app/Helpers/utility_helper.php b/app/Helpers/utility_helper.php index 2dbcb1ce..87945e48 100644 --- a/app/Helpers/utility_helper.php +++ b/app/Helpers/utility_helper.php @@ -239,3 +239,12 @@ if (!function_exists('get_username')) { } +if (!function_exists('get_role_id')) { + function get_role_id() { + + $role_id = get_session_userdata()->role; + return $role_id; + } +} + + diff --git a/app/Models/CDMasterModel.php b/app/Models/CDMasterModel.php index 491d1007..0e5c39a1 100644 --- a/app/Models/CDMasterModel.php +++ b/app/Models/CDMasterModel.php @@ -61,4 +61,26 @@ class CDMasterModel extends Model return $data; } + public function getCDMasterList(){ + + $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') + ->join('clients', 'clients.id = cd_master.client_id') + ->join('insurers', 'insurers.id = cd_master.insurer_id') + ->join('user_profiles', 'user_profiles.id = cd_master.created_by') + ->join( + '(SELECT cd_master.cd_ac_no, COUNT(client_policy.cd_ac_no) AS cd_ac_no_count + FROM cd_master + JOIN client_policy ON client_policy.cd_ac_no = cd_master.cd_ac_no + GROUP BY cd_master.cd_ac_no) AS cd_ac_counts', + 'cd_ac_counts.cd_ac_no = cd_master.cd_ac_no', + 'left' + ) + ->where('cd_master.is_active', 1) + ->get(); + + $result = $query->getResultArray(); + return $result; + } + } diff --git a/app/Models/ClientPolicyModel.php b/app/Models/ClientPolicyModel.php index a339b142..a69cf852 100644 --- a/app/Models/ClientPolicyModel.php +++ b/app/Models/ClientPolicyModel.php @@ -77,12 +77,14 @@ class ClientPolicyModel extends Model ->select('insurer_branch.branch_name as insurer_branch_name, insurer_branch.branch_code as insurer_branch_code') ->select('tpa_branch.branch_name as tpa_branch_name, tpa_branch.branch_code as tpa_branch_code') ->select('policy_type.policy_type as policy_type_name') + ->select('client_branch.branch_name as branch_name') ->join('insurers', 'insurers.id = client_policy.insurer_id') ->join('insurer_branch', 'client_policy.insurer_branch_id = insurer_branch.id') ->join('tpa', 'tpa.id = client_policy.tpa_id', 'left') ->join('tpa_branch', 'client_policy.tpa_branch_id = tpa_branch.id', 'left') ->join('policies', 'policies.id = client_policy.policy_id') ->join('policy_type', 'policy_type.id = policies.policy_type_id') + ->join('client_branch', 'client_branch.id = client_policy.client_branch_id') ->where('client_policy.client_id', $client_id) ->where('client_policy.policy_status', 1) ->where('client_policy.is_active', 1) diff --git a/app/Views/cd_master_list.php b/app/Views/cd_master_list.php index 7a001b39..21e599ce 100644 --- a/app/Views/cd_master_list.php +++ b/app/Views/cd_master_list.php @@ -58,12 +58,12 @@ table.dataTable thead th {
@@ -290,4 +290,50 @@ table.dataTable thead th { }) + +function removeCDMaster(element) { + + Swal.fire({ + title: "Are you sure?", + text: "You need to remove this CD.", + icon: "info", + showCancelButton: true, + confirmButtonColor: "#3085d6", + confirmButtonText: "Yes", + }).then((result) => { + + if (result.isConfirmed) { + var id = element.getAttribute('data-id'); + var form_action = '' + id; + $.ajax({ + url: form_action, + type: "GET", + dataType: 'json', + processData: false, + contentType: false, + success: function(res) { + // console.log(res.status == true); + if(res){ + if (res.status == true) { + toastr.success('CD removed successfully.', 'success'); + location.reload(); + } else { + toastr.warning('Failed to remove CD.', 'warning'); + } + } + }, + error: function (xhr, status, error) { + console.error(xhr.responseText); + console.error(status, error); + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + console.log('Something Wrong!', 'warning'); + } + }); + } + + }); + +} + \ No newline at end of file diff --git a/app/Views/client_branch.php b/app/Views/client_branch.php index 213f47c2..81b308e4 100644 --- a/app/Views/client_branch.php +++ b/app/Views/client_branch.php @@ -1,11 +1,12 @@
- +
- +
-
- +
+
@@ -23,52 +24,51 @@
- +
- +
- - - - + + + +
- +
- - + +
- +
- - + +
- - + +
@@ -79,26 +79,37 @@
- +
- +
- +
- +
- - + +
@@ -119,168 +130,196 @@ \ No newline at end of file diff --git a/app/Views/client_list.php b/app/Views/client_list.php index 4548631a..2d84afdf 100644 --- a/app/Views/client_list.php +++ b/app/Views/client_list.php @@ -59,7 +59,9 @@ table.dataTable thead th {
@@ -111,38 +113,47 @@ table.dataTable thead th { function removeClient(element) { - var id = element.getAttribute('data-id'); - var form_action = '' + id; - $.ajax({ - url: form_action, - type: "GET", - dataType: 'json', - processData: false, - contentType: false, - success: function(res) { - // console.log(res.status == true); - if(res){ - if (res.status == true) { - toastr.success('Remove Done!', 'success'); - location.reload(); + Swal.fire({ + title: "Are you sure?", + text: "You need to remove this client.", + icon: "info", + showCancelButton: true, + confirmButtonColor: "#3085d6", + confirmButtonText: "Yes", + }).then((result) => { - } else { - toastr.warning('Remove Not Done!', 'warning'); - } + if (result.isConfirmed) { + var id = element.getAttribute('data-id'); + var form_action = '' + id; + $.ajax({ + url: form_action, + type: "GET", + dataType: 'json', + processData: false, + contentType: false, + success: function(res) { + // console.log(res.status == true); + if(res){ + if (res.status == true) { + toastr.success('Client removed successfully.', 'success'); + location.reload(); + } else { + toastr.warning('Failed to remove client.', 'warning'); + } + } + }, + error: function (xhr, status, error) { + console.error(xhr.responseText); + console.error(status, error); + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + console.log('Something Wrong!', 'warning'); + } + }); } - }, - error: function (xhr, status, error) { - console.error(xhr.responseText); - console.error(status, error); - setTimeout(function() { - $('.loader').fadeOut(); - $('.loader-mask').delay(350).fadeOut('slow'); - toastr.warning('Something Wrong!', 'warning'); - }, 1000); - } - }); - + + }); } diff --git a/app/Views/client_policy.php b/app/Views/client_policy.php index e5626a3a..a27e1d92 100644 --- a/app/Views/client_policy.php +++ b/app/Views/client_policy.php @@ -7,14 +7,15 @@
-
+
+ - + @@ -263,8 +264,9 @@ + - + + - + @@ -316,6 +316,8 @@ $('#policy_form_action').val(''); $('#policy_status_field').hide() $('#base_policy_id').hide(); + $('#policy_PrimaryKey').val(""); + $('#insurer_policy_id').val(""); $('#first').hide(); @@ -635,6 +637,7 @@ }); + }); $(document).ready(function() { @@ -649,28 +652,35 @@ console.log('client_id', client_id) console.log('branch_id', branch_id) console.log('policy_type_id', dataId) + console.log('client_policy_id', $('#policy_PrimaryKey').val()) + + $('#policy_type_id').val(dataId); - var url = '' + id + '/' + dataId + '/' + branch_id + '/' + client_id + var url = '' + dataId + '/' + branch_id + '/' + client_id; - $.get(url, function(response){ + if (dataId && branch_id && client_id) { // Check if all parameters exist + if ($('#policy_PrimaryKey').val() == "" || id != $('#insurer_policy_id').val()) { + $.get(url, function(response) { + console.log(response); + console.log(response.count); - console.log(response) - //console.log(response.data) + if (response.count > 0) { + console.log('Policy already exist in the branch'); + toastr.error('Policy already exist in the branch', 'Error'); + $('#policy').val('').change(); + } + console.log('outer'); - if(response.count > 0){ - console.log('Policy already exist in the branch') - toastr.error('Policy already exist in the branch', 'Error'); - $('#policy').val('').change(); + }).fail(function(xhr, status, error) { + console.error(xhr.responseText); + console.error(status, error); + }); } - console.log('outer') - - - }).fail(function(xhr, status, error) { - console.error(xhr.responseText); - console.error(status, error); - }); + } else { + console.log('Missing parameter(s): dataId, branch_id, or client_id'); + } if (dataId == 1) { @@ -741,7 +751,7 @@ dataType: 'json', success: function(res) { - //console.log('client_policy_res', res) + console.log('client_policy_res', res) setTimeout(function() { $('.loader').fadeOut(); @@ -774,6 +784,7 @@ $('#policy_type_id').val(res.data.policy_type_id); $('#policy_PrimaryKey').val(res.data.id); + $('#insurer_policy_id').val(res.data.policy_id); $('#policy_no').val(res.data.policy_no); $('#start_date').val(rearrangeDateFormat(res.data.policy_start_date)); $('#end_date').val(rearrangeDateFormat(res.data.policy_end_date)); @@ -1305,8 +1316,6 @@ }); } - - if ($(this).val() == 3) { toastr.warning('Please Change the Policy Terms after Submit the Policy!', 'INFO'); } @@ -1440,54 +1449,58 @@ contentType: false, success: function(res) { - //console.log(res) + console.log(res) setTimeout(function() { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); }, 500); + + if(res.status == true){ - $('#insurer').val(res.data.insurer_branch_id + '-' + res.data.insurer_id) - .change(); - $('#tpa').val(res.data.tpa_branch_id + '-' + res.data.tpa_id).change(); - $('#policy_no').val(res.data.policy_no).change(); - $('#start_date').val(rearrangeDateFormat(res.data.policy_start_date)) - .change(); - $('#end_date').val(rearrangeDateFormat(res.data.policy_end_date)).change(); + $('#insurer').val(res.data.insurer_branch_id + '-' + res.data.insurer_id) + .change(); + $('#tpa').val(res.data.tpa_branch_id + '-' + res.data.tpa_id).change(); + $('#policy_no').val(res.data.policy_no).change(); + $('#start_date').val(rearrangeDateFormat(res.data.policy_start_date)) + .change(); + $('#end_date').val(rearrangeDateFormat(res.data.policy_end_date)).change(); - var policeOptionHTML = ''; - $policy_type_value = $('#policy_type').val(); - $.each(res.policy, function(index, item) { + var policeOptionHTML = ''; + $policy_type_value = $('#policy_type').val(); + $.each(res.policy, function(index, item) { - // //console.log(item); + // //console.log(item); - policeOptionHTML += ''; + policeOptionHTML += ''; - }); + }); - $('#policy').html(policeOptionHTML); + $('#policy').html(policeOptionHTML); - if (dataId == 3 || policy_type == 1) { + if (dataId == 3 || policy_type == 1) { - // //console.log('step 1') + // //console.log('step 1') + + setTimeout(function() { + // //console.log('step 2') + var $option = $('#policy').find('option[data-id="3"]'); + if ($option.length > 0) { + // //console.log('step 3') + $option.prop('selected', true).change(); + } else { + // //console.log('step 4'); + toastr.warning( + 'The insurer does not have a GMC-Parents policy.', + 'Warning'); + } + }, 1500); + } - setTimeout(function() { - // //console.log('step 2') - var $option = $('#policy').find('option[data-id="3"]'); - if ($option.length > 0) { - // //console.log('step 3') - $option.prop('selected', true).change(); - } else { - // //console.log('step 4'); - toastr.warning( - 'The insurer does not have a GMC-Parents policy.', - 'Warning'); - } - }, 1500); } }, From 8a4859afb67057c5791ed106a3a1bde17ef92016 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Wed, 26 Jun 2024 10:40:10 +0530 Subject: [PATCH 9/9] CHANGE_THE CASH_DEPOSITE_CREDIT_DEBIT_BASDED_ON_THE_CD_MASTER_ACC_NO : RV --- app/Controllers/EmpDataServiceController.php | 61 +++++++++++++++--- app/Controllers/EmployeeController.php | 66 +++++++++++--------- app/Helpers/DepositHelper.php | 20 +++--- app/Views/client_policy.php | 2 +- composer.json | 2 +- 5 files changed, 103 insertions(+), 48 deletions(-) diff --git a/app/Controllers/EmpDataServiceController.php b/app/Controllers/EmpDataServiceController.php index 3cb36091..96537b76 100644 --- a/app/Controllers/EmpDataServiceController.php +++ b/app/Controllers/EmpDataServiceController.php @@ -140,15 +140,30 @@ class EmpDataServiceController extends BaseController // Fetch employee data for export from the database $objects = $this->employeePolicyModel->getInceptionEmployeeDataForExportExcel($export_data); - $insurer_id = $this->clientPolicyModel->where('id', $export_data['client_policy_id'])->first(); - $cash_balance = $this->clientDepositModel->where('client_id', $export_data['client_id'])->where('insurer_id', $insurer_id['insurer_id'])->orderBy('id', 'DESC')->first(); + $policy_details = $this->clientPolicyModel->where('id', $export_data['client_policy_id'])->first(); - if($cash_balance == null){ + // dd($export_data, $policy_details['cd_ac_no']); + + if ($policy_details['cd_ac_no'] == null) { + // dd("The policy does not have a CD account number"); + $this->myLogger->logme('error', 'The policy does not have a CD account number.'); + return 5; + } + + $cash_balance = $this->clientDepositModel->where('cd_ac_no', $policy_details['cd_ac_no'])->orderBy('id', 'DESC')->first(); + + if ($cash_balance == null) { + + $balance = $this->CDMasterModel + ->where('client_id', $export_data['client_id']) + ->where('insurer_id', $policy_details['insurer_id']) + ->where('cd_ac_no', $policy_details['cd_ac_no']) + ->first(); - $balance = $this->CDMasterModel->where('client_id', $export_data['client_id'])->where('insurer_id', $insurer_id['insurer_id'])->orderBy('id', 'DESC')->first(); $cash_balance['balance'] = $balance['opening_bal']; } + // dd($cash_balance); // Calculate the total amount from the objects $totals = array_reduce($objects, function ($carry, $item) { @@ -158,9 +173,8 @@ class EmpDataServiceController extends BaseController $totals = round($totals, 2); 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; @@ -363,6 +377,26 @@ class EmpDataServiceController extends BaseController $ids = []; $objects = $this->employeePolicyModel->getSIEnhancementEmployeesDataForExportExcel($export_data); + $policy_details = $this->clientPolicyModel->where('id', $export_data['client_policy_id'])->first(); + + if ($policy_details['cd_ac_no'] == null) { + $this->myLogger->logme('error', 'The policy does not have a CD account number.'); + return 1; + } + + $cash_balance = $this->clientDepositModel->where('cd_ac_no', $policy_details['cd_ac_no'])->orderBy('id', 'DESC')->first(); + + if ($cash_balance == null) { + + $balance = $this->CDMasterModel + ->where('client_id', $export_data['client_id']) + ->where('insurer_id', $policy_details['insurer_id']) + ->where('cd_ac_no', $policy_details['cd_ac_no']) + ->first(); + + $cash_balance['balance'] = $balance['opening_bal']; + } + $totals = 0; foreach ($objects as $obj) { @@ -374,6 +408,14 @@ class EmpDataServiceController extends BaseController // echo '
';
         // print_r($ids); die;
 
+        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;
+            }
+        }
+
         $count = count($objects);
         $export_data['count'] = $count;
         $export_data['amount'] = $rounded_totals;
@@ -545,7 +587,7 @@ class EmpDataServiceController extends BaseController
     }
 
 
-
+    //not in use
     public function generateExcelForAdditionAndDependentAddition($export_data)
     {
         $ids = [];
@@ -628,7 +670,7 @@ class EmpDataServiceController extends BaseController
             }
         }
     }
-
+    //end not in use
 
     /**
      * The below functions are Imports data from an Excel file for :
@@ -2788,7 +2830,7 @@ class EmpDataServiceController extends BaseController
 
     //Endorsement Addition and Dependent Addition
 
-
+    //not in use
     public function AdditionAndDependentAddition($params)
     {
 
@@ -3179,6 +3221,7 @@ class EmpDataServiceController extends BaseController
 
     }
 
+    //end not in use
 
     /**
      * The below functions are Calculates and records cash deposits for employee policies at inception.
diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php
index c2447397..ae32b9a4 100644
--- a/app/Controllers/EmployeeController.php
+++ b/app/Controllers/EmployeeController.php
@@ -411,10 +411,15 @@ class EmployeeController extends AdminController
 
                 $return = $empDataServiceController->generateExcelForAdditionandInception($batch_data);
 
-                if ($return == 0) {
+                if ($return === 0) {
 
                     session()->setFlashdata('error', "Insufficient deposit amount.");
                     return redirect()->to(base_url('employee/upload'));
+
+                }else if($return === 5){
+
+                    session()->setFlashdata('error', "The policy does not have a CD account number.");
+                    return redirect()->to(base_url('employee/upload'));
                 }
 
                 if (!$return) {
@@ -442,10 +447,14 @@ class EmployeeController extends AdminController
 
                 $return = $empDataServiceController->generateExcelForSIEnhancement($batch_data);
 
-                if ($return == 0) {
+                if ($return === 0) {
 
                     session()->setFlashdata('error', "Insufficient deposit amount.");
                     return redirect()->to(base_url('employee/upload'));
+                }else if($return === 5){
+
+                    session()->setFlashdata('error', "The policy does not have a CD account number.");
+                    return redirect()->to(base_url('employee/upload'));
                 }
 
                 if (!$return) {
@@ -1059,33 +1068,34 @@ class EmployeeController extends AdminController
     public function viewECard()
     {
 
-        $this->loadLayout('ecard_template/default_ecard');
+        // $this->loadLayout('ecard_template/default_ecard');
         
-        // Load the session library if it's not autoloaded
-        // $session = \Config\Services::session();
-        
-        // Access session data
-        $sessionData = session()->get();
-        
-        // Check if session data exists and if expiration time is set
-        if (!empty($sessionData) && isset($sessionData['isLoggedIn']) && isset($sessionData['session_expiration'])) {
-            // Get the session expiration timestamp
-            $expirationTimestamp = $sessionData['session_expiration'];
-        
-            // Get the current timestamp
-            $currentTimestamp = time();
-        
-            // Check if the current time is greater than the expiration time
-            if ($currentTimestamp > $expirationTimestamp) {
-                // Session has expired
-                echo "Session has expired";
-            } else {
-                // Session is active
-                echo "Session is active";
-            }
-        } else {
-            // Session data is not set or session is not started
-            echo "Session is not started or data is not set";
+        $empDataServiceController = new EmpDataServiceController();
+        $file_name = generate_filename("TCS", 'inception', 'export', 'insurer', 'policy', 'branch');
+
+        $batch_data = [
+            'client_id' => 12,
+            'client_policy_id' => 12,
+            'client_branch_id' => 1,
+            'insurer_or_tpa' => 'insurer',
+            'event_type' => 'inception',
+            'actions' => 'export',
+            'file_name' => $file_name,
+        ];
+
+        $return = $empDataServiceController->generateExcelForAdditionandInception($batch_data);
+
+        if ($return == 0) {
+
+           dd('error', "Insufficient deposit amount.");
+
+        }else if($return == 1){
+
+            dd('error', "The policy does not have a CD account number.");
+        }
+
+        if (!$return) {
+            dd('error', "No data was found");
         }
         
     }
diff --git a/app/Helpers/DepositHelper.php b/app/Helpers/DepositHelper.php
index 7d3c713d..f6d14a7c 100644
--- a/app/Helpers/DepositHelper.php
+++ b/app/Helpers/DepositHelper.php
@@ -33,7 +33,7 @@ class DepositHelper
     public static function saveDeposit(array $data, int $loggedInUserID): array
     {
         // Retrieve the last known balance
-        $lastBalance = self::calculateLastBalance($data['client_id'], $data['insurer_id']);
+        $lastBalance = self::calculateLastBalance($data['client_id'], $data['insurer_id'], $data['cd_ac_no']);
 
         // Calculate the new balance based on the transaction type
         $newBalance = self::calculateBalance(
@@ -87,24 +87,26 @@ class DepositHelper
      *
      * @return float The last known balance.
      */
-    public static function calculateLastBalance(int $clientId, int $insurerId): float
+    public static function calculateLastBalance(int $clientId, int $insurerId, $cd_ac_no): float
     {
         $model = new ClientDepositModel();
 
-        $getLastBalanceQuery = "SELECT balance FROM cash_deposit WHERE client_id = ? AND insurer_id = ? ORDER BY created_at DESC LIMIT 1";
-        $getLastBalanceParams = [$clientId, $insurerId];
+        // $getLastBalanceQuery = "SELECT balance FROM cash_deposit WHERE client_id = ? AND insurer_id = ? ORDER BY created_at DESC LIMIT 1";
+        // $getLastBalanceParams = [$clientId, $insurerId];
 
-        $lastBalance = $model->query($getLastBalanceQuery, $getLastBalanceParams)->getRow()->balance;
+        $getLastBalanceQuery = "SELECT balance FROM cash_deposit WHERE cd_ac_no = ? ORDER BY created_at DESC LIMIT 1";
+        $getLastBalanceParams = [$cd_ac_no];
 
-        if(!$lastBalance){
+        $lastBalance = $model->query($getLastBalanceQuery, $getLastBalanceParams)->getRow()->balance ?? null;
+
+        if(empty($lastBalance) && $lastBalance == null){
 
             $cd_model = new ClientDepositModel();
 
-            $getLastBalanceQuery = "SELECT opening_bal FROM cd_master WHERE client_id = ? AND insurer_id = ? ORDER BY created_at DESC LIMIT 1";
-            $getLastBalanceParams = [$clientId, $insurerId];
+            $getLastBalanceQuery = "SELECT opening_bal FROM cd_master WHERE client_id = ? AND insurer_id = ? AND cd_ac_no = ? ORDER BY created_at DESC LIMIT 1";
+            $getLastBalanceParams = [$clientId, $insurerId, $cd_ac_no];
     
             $lastBalance = $cd_model->query($getLastBalanceQuery, $getLastBalanceParams)->getRow()->opening_bal ?? 0;
-    
         }
 
         return $lastBalance;
diff --git a/app/Views/client_policy.php b/app/Views/client_policy.php
index fd79a58b..611fadd3 100644
--- a/app/Views/client_policy.php
+++ b/app/Views/client_policy.php
@@ -264,7 +264,7 @@
                     
- + diff --git a/composer.json b/composer.json index 2dd9d301..9f2ec667 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "laminas/laminas-escaper": "^2.9", "php-amqplib/php-amqplib": "^2.8", "phpmailer/phpmailer": "^6.9", - "phpoffice/phpspreadsheet": "^2.0", + "phpoffice/phpspreadsheet": "^2.1", "psr/log": "^1.1", "slim/slim": "^4.13", "zircote/swagger-php": "^4.8"
Insurer PolicyClient Branch TPA DateEnrollment
Status
Enrollment Status Status Action
${item.insurer_short} - ${item.insurer_branch_name} ${item.policy_name} (${item.policy_type_name})${item.branch_name} ${tpaValue}${(item.policy_start_date)} /
${(item.policy_end_date)}
${(item.policy_start_date)} / ${(item.policy_end_date)} ${(enrollmentStatus)} ${checkDateStatus(item.policy_end_date, 1)} @@ -481,8 +483,9 @@
${item.insurer_short} - ${item.insurer_branch_name} ${item.policy_name} (${item.policy_type_name})${item.branch_name} ${tpaValue}${rearrangeDateFormat(item.policy_start_date)} /
${rearrangeDateFormat(item.policy_end_date)}
${rearrangeDateFormat(item.policy_start_date)} / ${rearrangeDateFormat(item.policy_end_date)} ${(enrollmentStatus)} ${checkDateStatus(item.policy_end_date, 1)} diff --git a/app/Views/client_rm.php b/app/Views/client_rm.php index a47280ee..73ad031c 100644 --- a/app/Views/client_rm.php +++ b/app/Views/client_rm.php @@ -16,7 +16,7 @@
- +
- + +
@@ -259,7 +260,6 @@ tpaValue = item.tpa_short + '-' + item.tpa_branch_code; } - policyTable += `
${item.insurer_short} - ${item.insurer_branch_name}
${item.insurer_short} - ${item.insurer_branch_name} ${item.policy_name} (${item.policy_type_name})${item.branch_name}${item.branch_name ? item.branch_name : ' - '} ${tpaValue} ${(item.policy_start_date)} / ${(item.policy_end_date)} ${(enrollmentStatus)}