From 9411d5d29766f8ee0f69d39e0c66f42e37cb4890 Mon Sep 17 00:00:00 2001 From: aadhavan valli Date: Fri, 15 Mar 2024 11:13:04 +0530 Subject: [PATCH 01/18] CHANGE_POLICY_GRID : AADHAVAN --- app/Config/Routes.php | 2 +- app/Controllers/ClientController.php | 56 +- app/Controllers/EmployeeRestController.php | 3 +- app/Views/client_policy.php | 113 +++-- app/Views/policy_gmc_terms.php | 8 +- app/Views/policy_grid.php | 561 +++++++++------------ 6 files changed, 377 insertions(+), 366 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 06d67bd7..f1363b80 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -213,10 +213,10 @@ $routes->post("/employeeUpload", "EmployeeRestController::employeeUpload"); $routes->group("employeeRest", ["filter" => "authJWT"], function($routes){ + $routes->get("/relationshipList", "EmployeeRestController::relationshipList"); $routes->get("getEmployeeAndDependence", "EmployeeRestController::getEmployeeAndDependence"); $routes->post("editEmployeeAndDependence", "EmployeeRestController::editEmployeeAndDependence"); $routes->post("addEmployeeAndDependence", "EmployeeRestController::addEmployeeAndDependence"); - $routes->get("/relationshipList", "EmployeeRestController::relationshipList"); }); diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index ab1c21fc..8d8b8104 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -598,7 +598,13 @@ class ClientController extends AdminController $this->policyPremium1Model->where('client_id', $client_id)->where('client_policy_id', $client_policy_id)->set('is_active', 0)->update(); - $premiumData = $this->request->getPost('premium'); + if($si_or_bp == '1'){ + $premiumData = $this->request->getPost('sum_premium'); + + }else{ + $premiumData = $this->request->getPost('premium'); + } + for ($i = 0; $i < count($premiumData); $i++) { $data = [ 'client_id' => $client_id, @@ -607,17 +613,35 @@ class ClientController extends AdminController 'created_by' => get_session_userid(), ]; - if(is_array($this->request->getPost('si'))){ - $si = isset($this->request->getPost('si')[$i]) ? $this->request->getPost('si')[$i] : null; + if ($si_or_bp == '2') { + if(is_array($this->request->getPost('basic_si'))){ + $si = isset($this->request->getPost('basic_si')[$i]) ? $this->request->getPost('basic_si')[$i] : null; + }else{ + $si = $this->request->getPost('basic_si'); + } + } else { + if(is_array($this->request->getPost('si'))){ + $si = isset($this->request->getPost('si')[$i]) ? $this->request->getPost('si')[$i] : null; + }else{ + $si = $this->request->getPost('si'); + } + } + + + if($si_or_bp == '1'){ + if(is_array($this->request->getPost('sum_premium'))){ + $premium = isset($this->request->getPost('sum_premium')[$i]) ? $this->request->getPost('sum_premium')[$i] : null; + }else{ + $premium = $this->request->getPost('sum_premium'); + } }else{ - $si = $this->request->getPost('si'); + if(is_array($this->request->getPost('premium'))){ + $premium = isset($this->request->getPost('premium')[$i]) ? $this->request->getPost('premium')[$i] : null; + }else{ + $premium = $this->request->getPost('premium'); + } } - if(is_array($this->request->getPost('premium'))){ - $premium = isset($this->request->getPost('premium')[$i]) ? $this->request->getPost('premium')[$i] : null; - }else{ - $premium = $this->request->getPost('premium'); - } // $basic_gpa_premium = isset($basic_gpa_premium[$i]) ? $basic_gpa_premium[$i] : null; if ($si !== null) { $data['si'] = $si; @@ -626,17 +650,21 @@ class ClientController extends AdminController $data['premium'] = $premium; } - if ($multiplier !== null) { - $data['multiplier'] = $multiplier; + if($si_or_bp == 2){ + if ($premium_multiplier !== null) { + $data['multiplier'] = $premium_multiplier; + } + }else{ + if ($multiplier !== null) { + $data['multiplier'] = $multiplier; + } } if ($si_or_bp !== null) { $data['si_or_bp'] = $si_or_bp; } - if ($premium_multiplier !== null) { - $data['multiplier'] = $premium_multiplier; - } + if ($basic_multiplier !== null) { $data['basic_multiplier'] = $basic_multiplier; diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 8692e2df..87ada1ac 100644 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -180,8 +180,9 @@ class EmployeeRestController extends AdminController public function getEmployeePolicy() { - $id= 1; + // $id= 4; try { + $id = $this->request->getGet('id'); $keysToRemove = ["sum_insured","family_floater","corporatebuffer","family_floaters"]; $empPolicy = $this->employeeModel->getEmployeePolicy($id); diff --git a/app/Views/client_policy.php b/app/Views/client_policy.php index 3048d0ca..a9df6485 100644 --- a/app/Views/client_policy.php +++ b/app/Views/client_policy.php @@ -654,31 +654,31 @@ }; function convertNumberToWords(number) { - if (number === 0) { - return numberWords[number]; - } + if (number === 0) { + return numberWords[number]; + } - let word = ''; + let word = ''; - if (number >= 10000000) { - word += convertNumberToWords(Math.floor(number / 10000000)) + " Crore "; - number %= 10000000; - } + if (number >= 10000000) { + word += convertNumberToWords(Math.floor(number / 10000000)) + " Crore "; + number %= 10000000; + } - if (number >= 100000) { - word += convertNumberToWords(Math.floor(number / 100000)) + " Lakh "; - number %= 100000; - } + if (number >= 100000) { + word += convertNumberToWords(Math.floor(number / 100000)) + " Lakh "; + number %= 100000; + } - if (number >= 1000) { - word += convertNumberToWords(Math.floor(number / 1000)) + " Thousand "; - number %= 1000; - } + if (number >= 1000) { + word += convertNumberToWords(Math.floor(number / 1000)) + " Thousand "; + number %= 1000; + } - if (number >= 100) { - word += convertNumberToWords(Math.floor(number / 100)) + " Hundred "; - number %= 100; - } + if (number >= 100) { + word += convertNumberToWords(Math.floor(number / 100)) + " Hundred "; + number %= 100; + } if (number > 0) { if (word !== '') { @@ -708,22 +708,67 @@ function formatNumber(input, maxLength) { - maxLength=16; - let value = input.value.replace(/\D/g, ''); // Remove non-numeric characters - - // Limit the number of digits - value = value.slice(0, maxLength); - - // Format the number with commas using Indian numbering system - value = Number(value).toLocaleString('en-IN'); - input.value = value; + + maxLength=16; + let value = input.value.replace(/\D/g, ''); // Remove non-numeric characters + + // Limit the number of digits + value = value.slice(0, maxLength); + + // Format the number with commas using Indian numbering system + value = Number(value).toLocaleString('en-IN'); + input.value = value; - basicPayMultiple(input) - if (input.id == 'gpa_si') { - gpaSumInsureMultiplier(); - } + basicPayMultiple(input) + if (input.id == 'gpa_si') { + gpaSumInsureMultiplier(); + } - return ; + if(input.id == 'basic_pay'){ + var inputNumber = input.value; + if (inputNumber) { + var result = convertCommaNumberToWords(inputNumber); + $("#gpa_basic_pay_number_word").text(result); + } else { + $("#gpa_basic_pay_number_word").text(""); + } + }else if(input.id == 'basic_gpa_si'){ + var inputNumber = input.value; + if (inputNumber) { + var result = convertCommaNumberToWords(inputNumber); + $("#basic_gpa_si_number_word").text(result); + } else { + $("#basic_gpa_si_number_word").text(""); + } + }else if(input.id == 'basic_gpa_premium'){ + var inputNumber = input.value; + if (inputNumber) { + var result = convertCommaNumberToWords(inputNumber); + $("#basic_gpa_premium_number_word").text(result); + } else { + $("#basic_gpa_premium_number_word").text(""); + } + }else if(input.id == 'gpa_si'){ + var inputNumber = input.value; + if (inputNumber) { + var result = convertCommaNumberToWords(inputNumber); + $("#gpa_sum_si_number_word").text(result); + } else { + $("#gpa_sum_si_number_word").text(""); + } + }else if(input.id == 'gpa_premium'){ + var inputNumber = input.value; + if (inputNumber) { + var result = convertCommaNumberToWords(inputNumber); + $("#gpa_sum_premium_number_word").text(result); + } else { + $("#gpa_sum_premium_number_word").text(""); + } + } + + return ; + // } + } \ No newline at end of file diff --git a/app/Views/policy_gmc_terms.php b/app/Views/policy_gmc_terms.php index d0f182a1..e03b3e9d 100644 --- a/app/Views/policy_gmc_terms.php +++ b/app/Views/policy_gmc_terms.php @@ -465,9 +465,7 @@
-
- Days -
+
@@ -477,9 +475,7 @@
-
- Days -
+
diff --git a/app/Views/policy_grid.php b/app/Views/policy_grid.php index a86cdd40..4c76b77e 100644 --- a/app/Views/policy_grid.php +++ b/app/Views/policy_grid.php @@ -58,11 +58,8 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp=false){ $('#grid_content_input').empty(); - // console.log ($('#Client_id').val()); - - var grid_container = document.getElementById('grid_content_input'); var dataIdValue = '' if(event === false){ @@ -82,18 +79,70 @@ } grid_html = ` -
+
-
-
-
-
+
`; } else if(dataIdValue == '2'){ @@ -414,107 +463,31 @@ $('#btnGridSubmit').hide(); } + + + grid_container.insertAdjacentHTML('beforeend', grid_html); $('#gpa_sum_insured').hide(); $('#btnGridSubmit').show(); - - $('#si_or_bp').change(function(){ - var selectedValue = $(this).val(); - - - - si_or_bp_two(selectedValue); - - }); - - if(data !== false && data.si){ - console.log('show'); - $('#gpa_sum_insured').show(); - $('#si_or_bp').val("1"); - }else{ - $('#si_or_bp').val("2"); - } - - $("#gpa_si").on("keyup", function() { - var inputNumber = $(this).val(); - if (inputNumber) { - var result = convertCommaNumberToWords(inputNumber); - $("#gpa_si_number_word").text(result); - } else { - $("#gpa_si_number_word").text(""); - } + $('#si_or_bp').val(si_or_bp); + setTimeout(() => { + $('#si_or_bp').trigger('change'); + }, 300); - }); - - $("#basic_gpa_premium").on("keyup", function() { - var inputNumber = $(this).val(); - if (inputNumber) { - var result = convertCommaNumberToWords(inputNumber); - $("#gpa_premium_number_word").text(result); - } else { - $("#gpa_premium_number_word").text(""); - } - }); - $("#sum_insured").on("keyup", function() { - var inputNumber = $(this).val(); - if (inputNumber) { - var result = convertCommaNumberToWords(inputNumber); - $("#sum_insured_number_word").text(result); - } else { - $("#sum_insured_number_word").text(""); - } - }); + - $("#premium").on("keyup", function() { - var inputNumber = $(this).val(); - if (inputNumber) { - var result = convertCommaNumberToWords(inputNumber); - $("#premium_number_word").text(result); - } else { - $("#premium_number_word").text(""); - } - }); - - - if (si_or_bp == '1') { - si_or_bp_two(si_or_bp); - }else if(si_or_bp == '2'){ - si_or_bp_two(si_or_bp); - } - - if (si_or_bp == '2') { - - console.log("data line-> 490", data); - $('#si_or_bp').val(si_or_bp); - $('#basic_multiplier').val(data.basic_multiplier); - $('#basic_pay').val(data.basic_pay); - $('#premium_multiplier').val(data.multiplier); - $('#basic_gpa_si').val(data.si); - $('#basic_gpa_premium').val(data.premium); - }else if (si_or_bp == '1') { - console.log("start"); - console.log(data); - $('#si_or_bp').val(si_or_bp); - $('#multiplier').val(data.multiplier); - $('#gpa_si').val(data.si); - $('#basic_gpa_premium').val(data.premium); - } - + }; $("#GridForm").submit(function(event) { var check = checkDuplicate(); - - console.log("check....."); - console.log(check); - event.preventDefault(); @@ -551,7 +524,7 @@ contentType: false, success: function(res) { - console.log(res); + console.log("Response",res); if (res.status === false) { toastr.error('Policy Dose Not Create', 'Error'); @@ -602,6 +575,7 @@ data: { client_policy_id: client_policy_id}, dataType: 'json', success: function (res) { + console.log('res',res); $('#nameOfThePolicy').html(' - ' + res.policy_name); $('#grid_emp_count').val(res.count); @@ -623,14 +597,20 @@ }); $('#grid').html(policeGridOptionHTML); - + var si_or_bp_value = ''; if (res.premiumData && res.premiumData.length > 0) { - addGridHTML(false, res.premiumData[0], res.premiumData[0].policy_grid_id, res.premiumData[0].si_or_bp); + if(res.premiumData[0].si_or_bp){ + si_or_bp_value = res.premiumData[0].si_or_bp; + } + + addGridHTML(false, res.premiumData[0], res.premiumData[0].policy_grid_id, si_or_bp_value); + + res.premiumData.shift(); $.each(res.premiumData, function(index, item){ if (item.si_or_bp == '1') { - appendGridtHtml('1_1_1_1', item); + appendGridtHtml('1', item); }else{ appendGridtHtml(item.policy_grid_id, item); } @@ -643,19 +623,23 @@ $('#bs-example-modal-lg').modal('show'); - $("#gpa_si").trigger("keyup"); - $("#basic_gpa_premium").trigger("keyup"); + // $("#gpa_si").trigger("keyup"); + // $("#basic_gpa_premium").trigger("keyup"); + + // $("#sum_insured").trigger("keyup"); + // $("#premium").trigger("keyup"); - $("#sum_insured").trigger("keyup"); - $("#premium").trigger("keyup"); - - $("input[name='si[]']").trigger("keyup"); - $("input[name='premium[]']").trigger("keyup") + // $('#basic_pay').trigger('keyup'); + // $("input[name='si[]']").trigger("keyup"); + // $("input[name='premium[]']").trigger("keyup") setTimeout(function() { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); }, 1000); + + $('#basic_gpa_si').trigger('keyup'); + }, error: function (xhr, status, error) { console.error(xhr.responseText); @@ -674,6 +658,8 @@ var grid_id=$(this)[0].value; var client_policy_id =$('#client_policy_id')[0].value; + + $('.loader').fadeIn(); $('.loader-mask').fadeIn(); @@ -683,8 +669,6 @@ data: { client_policy_id: client_policy_id}, dataType: 'json', success: function (res) { - appendGridtHtml('1_2'); - appendGridtHtml('1_2_1'); console.log('responce :', res); setTimeout(function() { @@ -692,7 +676,6 @@ $('.loader-mask').delay(350).fadeOut('slow'); }, 1000); if (res.premiumData.length > 0 && res.premiumData[0].policy_grid_id === grid_id) { - console.log("heelo"); $('#nameOfThePolicy').html(' - ' + res.policy_name); $('#grid_emp_count').val(res.count); @@ -714,43 +697,35 @@ policeGridOptionHTML += ''; }); // $('#grid').html(policeGridOptionHTML); - + var si_or_bp_value = ''; if (res.premiumData && res.premiumData.length > 0) { + + if(res.premiumData[0].si_or_bp){ + si_or_bp_value = res.premiumData[0].si_or_bp; - addGridHTML(false, res.premiumData[0], res.premiumData[0].policy_grid_id, res.premiumData[0].si_or_bp); + $('#si_or_bp').val(si_or_bp_value); + + } + + + + addGridHTML(false, res.premiumData[0], res.premiumData[0].policy_grid_id, si_or_bp_value); res.premiumData.shift(); $.each(res.premiumData, function(index, item){ - // console.log('premiumData index :',index) - // appendGridtHtml(item.policy_grid_id, item); - if (item.si_or_bp == '1') { - appendGridtHtml('1_1_1_1', item); - }else{ appendGridtHtml(item.policy_grid_id, item); - } }); } else { console.log("res.premiumData is undefined, null, or empty."); - } + } + }else if(res.data[0].policy_type == "GPA"){ + $('#si_or_bp').val('2'); - $('#bs-example-modal-lg').modal('show'); - $("#gpa_si").trigger("keyup"); - $("#basic_gpa_premium").trigger("keyup"); - - $("#sum_insured").trigger("keyup"); - $("#premium").trigger("keyup"); - - $("input[name='si[]']").trigger("keyup"); - $("input[name='premium[]']").trigger("keyup"); - }else{ - if($('#si_or_bp').val() == 2){ - addGridHTML(false, false, grid_id,) - } - // console.log("novkfdmmk"); - addGridHTML(false, false, grid_id) + setTimeout(() => { + $('#si_or_bp').trigger('change') + }, 300); } - // console.log("hello"); }, error: function (xhr, status, error) { console.error(xhr.responseText); @@ -764,7 +739,6 @@ }); }) - var Count = 1 function appendGridtHtml(ui_type = false, data = false,) { @@ -773,66 +747,29 @@ Count++; var container = document.getElementById('grid_content_input'); - - if(ui_type == '1_1' || ui_type == '1_1_1' || ui_type == '1_1_1_1') + if(ui_type == '1') { - if (ui_type == '1_1_1' || ui_type == '1_1_1_1') { - html=`
- - -
-
-
- - -
- -
-
- - -
`; - // return html; - }else{ - html =`
- - -
- `; - - // return html; - } - } - else if(ui_type == '1_2' || ui_type == '1_2_1') - { - if (ui_type == '1_2_1') { - html=`
- - -
-
-
- - -
-
-
- - -
- + html = `
+
+ + +
+
+
+ + +
+ +
+
+ + +
`; - }else{ - html =`
- - -
-
- - -
- `; - } + } + else if(ui_type == '1_2' ) + { + } else if(ui_type == '3'){ @@ -1072,77 +1009,14 @@ } - if (ui_type == '1_1' || ui_type == '1_1_1' || ui_type == '1_2' || ui_type == '1_2_1' || ui_type == '1_1_1_1') { - if(ui_type == '1_1'){ - $('#si_or_bp_1').empty().append(html); - $('#si_or_bp_1_1').empty(); - $('#gmc_add_more').hide() - $('#gmc_remove').show() - Count-- - $('#gmc_add_more_'+Count).hide() - Count++ - }else if(ui_type == '1_1_1'){ - $('#si_or_bp_2').empty().append(html); - $('#gmc_add_more').hide() - $('#gmc_remove').show() - Count-- - $('#gmc_add_more_'+Count).hide() - Count++ - }else if(ui_type == '1_2'){ - - $('#si_or_bp_1').empty(); - $('#si_or_bp_1_1').empty().append(html); - $('#gmc_add_more').hide() - $('#gmc_remove').show() - Count-- - $('#gmc_add_more_'+Count).hide() - Count++ - }else if(ui_type == '1_2_1'){ - $('#si_or_bp_2').empty().append(html); - $('#gmc_add_more').hide() - $('#gmc_remove').show() - Count-- - $('#gmc_add_more_'+Count).hide() - Count++ - }else if(ui_type == '1_1_1_1'){ - $('#si_or_bp_2').append(html); - $('#gmc_add_more').hide() - $('#gmc_remove').show() - Count-- - $('#gmc_add_more_'+Count).hide() - Count++ - - - console.log("data", data); - - if(data){ - $('input[name="premium[]"]').length; - $('input[name="premium[]"]').each(function(index) { - if (index === $('input[name="premium[]"]').length - 1) { - console.log("data.premium",data.premium); - $(this).val(data.premium); - // console.log("This ", $(this)[0].val(data.premium)); - // var basicGpaPremiumValue = $(this).val(); - - // if (basicGpaPremiumValue !== "" && basicGpaPremiumValue !== null) { - // console.log("Value of basic_gpa_premium[]: " + basicGpaPremiumValue); - // } else { - // console.log("basic_gpa_premium[] value is empty or null"); - // } - } - }); - } - - } - - }else{ + container.insertAdjacentHTML('beforeend', html); $('#gmc_add_more').hide(); $('#gmc_remove').show(); Count-- $('#gmc_add_more_'+Count).hide() Count++ - } + @@ -1185,7 +1059,6 @@ } - function checkDuplicate() { // console.log($('#grid')[0].value); @@ -1208,11 +1081,9 @@ premiumValues.push($(this).val()); }); - console.log("Checking for duplicates..."); for (var i = 0; i < siValues.length; i++) { for (var j = i + 1; j < siValues.length; j++) { if (siValues[i] === siValues[j] && premiumValues[i] === premiumValues[j]) { - console.log('Duplicate values found in si[] at indices', i, 'and', j); siDuplicates = true; } } @@ -1220,10 +1091,8 @@ if (siDuplicates || premiumDuplicates) { toastr.warning('Duplicates found!', 'warning'); - console.log('Duplicates found'); return true; } else { - console.log('No duplicates found'); return false; } }else if($('#grid')[0].value === '4'){ @@ -1244,12 +1113,10 @@ ageToValues.push($(this).val()); }); - console.log("Checking for duplicates..."); for (var i = 0; i < ageFromValues.length; i++) { for (var j = i + 1; j < ageFromValues.length; j++) { // Check for duplicates between age_from[] and age_to[] if (ageFromValues[i] === ageFromValues[j] && ageToValues[i] === ageToValues[j]) { - console.log('Duplicate values found in age_from[] and age_to[] at indices', i, 'and', j); ageDuplicates = true; } } @@ -1257,10 +1124,8 @@ if (ageDuplicates) { toastr.warning('Duplicates found!', 'warning'); - console.log('Duplicates found'); return true; } else { - console.log('No duplicates found'); return false; } @@ -1297,10 +1162,8 @@ if (siDuplicates || ageDuplicates) { toastr.warning('Duplicates found!', 'warning'); - console.log('Duplicates found'); return true; } else { - console.log('No duplicates found'); return false; } }else if($('#grid')[0].value === '6'){ @@ -1320,12 +1183,10 @@ ageToValues.push($(this).val()); }); - console.log("Checking for duplicates..."); for (var i = 0; i < ageFromValues.length; i++) { for (var j = i + 1; j < ageFromValues.length; j++) { // Check for duplicates between age_from[] and age_to[] if (ageFromValues[i] === ageFromValues[j] && ageToValues[i] === ageToValues[j]) { - console.log('Duplicate values found in age_from[] and age_to[] at indices', i, 'and', j); ageDuplicates = true; } } @@ -1333,10 +1194,8 @@ if (ageDuplicates) { toastr.warning('Duplicates found!', 'warning'); - console.log('Duplicates found'); return true; } else { - console.log('No duplicates found'); return false; } }else if($('#grid')[0].value === '7'){ @@ -1372,10 +1231,8 @@ if (siDuplicates || ageDuplicates) { toastr.warning('Duplicates found!', 'warning'); - console.log('Duplicates found'); return true; } else { - console.log('No duplicates found'); return false; } }else if($('#grid')[0].value === '10'){ @@ -1412,10 +1269,8 @@ if (siDuplicates || ageDuplicates) { toastr.warning('Duplicates found!', 'warning'); - console.log('Duplicates found'); return true; } else { - console.log('No duplicates found'); return false; } }else if($('#grid')[0].value === '8'){ @@ -1435,12 +1290,10 @@ gradeValues.push($(this).val()); }); - console.log("Checking for duplicates..."); for (var i = 0; i < siValues.length; i++) { for (var j = i + 1; j < siValues.length; j++) { // Check for duplicates between si[] and grade[] if (siValues[i] === siValues[j] && gradeValues[i] === gradeValues[j]) { - console.log('Duplicate values found in si[] and grade[] at indices', i, 'and', j); duplicatesFound = true; } } @@ -1448,10 +1301,8 @@ if (duplicatesFound) { toastr.warning('Duplicates found!', 'warning'); - console.log('Duplicates found'); return true; } else { - console.log('No duplicates found'); return false; } }else if($('#grid')[0].value === '9'){ @@ -1471,12 +1322,10 @@ gradeValues.push($(this).val()); }); - console.log("Checking for duplicates..."); for (var i = 0; i < siValues.length; i++) { for (var j = i + 1; j < siValues.length; j++) { // Check for duplicates between si[] and grade[] if (siValues[i] === siValues[j] && gradeValues[i] === gradeValues[j]) { - console.log('Duplicate values found in si[] and grade[] at indices', i, 'and', j); duplicatesFound = true; } } @@ -1484,10 +1333,8 @@ if (duplicatesFound) { toastr.warning('Duplicates found!', 'warning'); - console.log('Duplicates found'); return true; } else { - console.log('No duplicates found'); return false; } }else if ($('#grid')[0].value === '11') { @@ -1513,46 +1360,25 @@ maxSiValues.push($(this).val()); }); - console.log("Checking for duplicates..."); for (var i = 0; i < siValues.length; i++) { for (var j = i + 1; j < siValues.length; j++) { - console.log(maxSiValues); - console.log("maxSiValues[i] ", maxSiValues[i] ); - console.log("maxSiValues[j]", maxSiValues[j]); + // console.log(maxSiValues); + // console.log("maxSiValues[i] ", maxSiValues[i] ); + // console.log("maxSiValues[j]", maxSiValues[j]); if (siValues[i] === siValues[j] && gradeValues[i] === gradeValues[j] && maxSiValues[i] === maxSiValues[j]) { - console.log('Duplicate values found in si[], grade[], and max_si[] at indices', i, 'and', j); duplicatesFound = true; } } } if (duplicatesFound) { - console.log('Duplicates found'); toastr.warning('Duplicates found!', 'warning'); return true; } else { - console.log('No duplicates found'); return false; } } } - - - \ No newline at end of file From 755b1fc3531b1b0db4e996b0f14342634e7a32d1 Mon Sep 17 00:00:00 2001 From: aadhavan valli Date: Fri, 15 Mar 2024 18:10:44 +0530 Subject: [PATCH 02/18] CHANGE_EMPLOYEE_REST_API :AADHAVAN --- app/Config/Routes.php | 3 +- app/Controllers/EmployeeRestController.php | 207 +++++++++++++++------ app/Models/EmployeeModel.php | 9 + app/Models/EmployeePolicyModel.php | 9 + app/Views/policy_grid.php | 72 +++---- 5 files changed, 208 insertions(+), 92 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index f1363b80..41afa3d2 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -211,9 +211,10 @@ $routes->post("/editEmployeeProfile", "EmployeeRestController::editEmployeeProfi $routes->get("/getEmployeePolicy", "EmployeeRestController::getEmployeePolicy"); $routes->post("/employeeUpload", "EmployeeRestController::employeeUpload"); +$routes->get("getEmployeeAndDependence", "EmployeeRestController::getEmployeeAndDependence"); $routes->group("employeeRest", ["filter" => "authJWT"], function($routes){ - $routes->get("/relationshipList", "EmployeeRestController::relationshipList"); + $routes->get("relationshipList", "EmployeeRestController::relationshipList"); $routes->get("getEmployeeAndDependence", "EmployeeRestController::getEmployeeAndDependence"); $routes->post("editEmployeeAndDependence", "EmployeeRestController::editEmployeeAndDependence"); $routes->post("addEmployeeAndDependence", "EmployeeRestController::addEmployeeAndDependence"); diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 87ada1ac..9f2d3574 100644 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -13,8 +13,13 @@ use App\Models\EmployeePolicyModel; use App\Models\ClientModel; use App\Models\PolicesModel; use App\Models\RelationshipModel; +use App\Models\FileModel; +use PhpOffice\PhpSpreadsheet\Spreadsheet; +use PhpOffice\PhpSpreadsheet\Writer\Xlsx; +use PhpOffice\PhpSpreadsheet\IOFactory; + use CodeIgniter\API\ResponseTrait; use Illuminate\Http\Request; @@ -42,6 +47,7 @@ class EmployeeRestController extends AdminController $this->clientModel = new ClientModel(); $this->policesModel = new PolicesModel(); $this->relationshipModel = new RelationshipModel(); + $this->fileModel= new FileModel(); } @@ -144,26 +150,28 @@ class EmployeeRestController extends AdminController try { $data = $this->request->getJSON(); - if ($data) { - $updatedCount = 0; + $Count = 0; foreach ($data as $item) { - $extractData['name'] = $item->name; - $extractData['emp_code']= $item->emp_code; - $extractData['email_corporate']=$item->email_corporate; - $extractData['relationship_code']=$item->relationship_code; - $extractData['mobile']=$item->mobile; - $extractData['gender']=$item->gender; - $extractData['dob']=$item->dob; - $extractData['client_id']=$item->client_id; - // print_r($extractData);die(); - $employee = $this->employeeModel->insert($extractData); - if ($employee) { - $updatedCount++; - } + if (isset($item->id)) { + //update old data + $id = $item->id; + $employee = $this->employeeModel->update($id, (array)$item); + if ($employee) { + $Count++; + } + }else{ + //create new data + $employee = $this->employeeModel->insert($item); + if ($employee) { + $Count++; + } + + } + } - if ($updatedCount > 0) { + if ($Count > 0) { $result = []; return $this->respond(['status' => 'success','code' => 200,'data' => $result], 200); } else { @@ -233,51 +241,132 @@ class EmployeeRestController extends AdminController public function employeeUpload() { - if ($this->request->getFile('file')) { - // Load PHPExcel library - require_once APPPATH . 'third_party/PHPExcel/PHPExcel.php'; - - // Load the uploaded file - $file = $this->request->getFile('file'); - - // Load file into PHPExcel - $inputFileType = PHPExcel_IOFactory::identify($file->getPathname()); - $objReader = PHPExcel_IOFactory::createReader($inputFileType); - $objPHPExcel = $objReader->load($file->getPathname()); - - // Get the active sheet - $sheet = $objPHPExcel->getActiveSheet(); - - // Get the highest row number - $highestRow = $sheet->getHighestRow(); - - // Assuming your data starts from the second row (after headers) - for ($row = 2; $row <= $highestRow; $row++) { - // Get cell values - $name = $sheet->getCellByColumnAndRow(0, $row)->getValue(); - $email = $sheet->getCellByColumnAndRow(1, $row)->getValue(); - // Assuming you have more columns, adjust indexes accordingly - - // Store data into database (Example using CodeIgniter's database methods) - $data = array( - 'name' => $name, - 'email' => $email, - // Add more fields as necessary - ); - // Insert data into the database table - $this->db->insert('employees', $data); - } - - // Optionally, you can delete the uploaded file after processing - unlink($file->getPathname()); - - // Optionally, you can redirect the user to a success page - redirect('employee/success'); - } else { - // Handle case when no file was uploaded - echo 'No file uploaded!'; + + $file = $this->request->getFile('file'); + $client_id = $this->request->getPost('client_id'); + $policy_id = $this->request->getPost('policy_id'); + + + $is_moved = $file->move(WRITEPATH . 'uploads/import_excel'); + $filename = $file->getName(); + + $file_name_with_path = WRITEPATH."/uploads/import_excel/".$filename; + + //check the file exist or not + if(!file_exists($file_name_with_path)) + { + session()->setFlashdata('error', 'File not found'); + return redirect()->to(base_url('employee/upload')); } + + // Load the Excel file + $spreadsheet = IOFactory::load($file_name_with_path); + + // Get the active sheet + $sheet = $spreadsheet->getActiveSheet(); + + // Get the highest row and column numbers + $highestRow = $sheet->getHighestRow(); + $highestColumn = $sheet->getHighestColumn(); + + $data = []; + + // Iterate through each row + for ($row = 1; $row <= $highestRow; $row++) { + // Initialize the row data array + $rowData = []; + + // Iterate through each column in the row + for ($col = 'A'; $col <= $highestColumn; $col++) { + // Get the cell value + $value = $sheet->getCell($col . $row)->getValue(); + + // Add the cell value to the row data array + $rowData[] = $value; + } + + // Add the row data to the main data array + $data[] = $rowData; + } + + $extractData['file_name']= $filename; + $extractData['client_id']= $client_id; + $extractData['status']= 'success'; + $extractData['policy_id']= $policy_id; + $extractData['action']= 'enrollment'; + + // $extractData['created_by']=set_session_context('Employee'); + + $file_data =$this->fileModel->insert($extractData); + + // print_r(count($data)); + $extra = []; + for ($i = 0; $i < count($data); $i++) { + if ($i == 0) { + // Loop through the first row to extract keys + for ($j = 0; $j < count($data[$i]); $j++) { + $extra[$data[$i][$j]] = []; // Initialize keys with empty array + } + } else { + // Loop through subsequent rows + for ($j = 0; $j < count($data[$i]); $j++) { + // Append values to corresponding keys in $extra + if (isset($extra[$data[0][$j]])) { + // Make sure the key exists in the $extra array + $extra[$data[0][$j]][] = $data[$i][$j]; + } + } + } + } + + $dataToInsert = []; + foreach ($extra['id'] as $index => $id) { + $record = [ + // 'id' => $id, + 'emp_code' => $extra['emp_code'][$index], + 'name' => $extra['name'][$index], + // Check if the 'doj' key exists before accessing it + 'doj' => isset($extra['doj'][$index]) ? $extra['doj'][$index] : null, + 'gender' => $extra['gender'][$index], + 'relationship' => $extra['relationship'][$index], + 'dob' => $extra['dob'][$index], + 'email' => $extra['Email'][$index], + ]; + $dataToInsert[] = $record; + } + + // print_r($dataToInsert);die(); + + for ($a=0; $a employeeModel->insert($dataToInsert[$a]); + + $employee = $this->employeeModel->checkExistingEmpEntrollment($dataToInsert[$a]); + + // print_r($employee);die; + if (count($employee)) { + // $dataToInsert['id'] = $employee['id']; + $this->employeeModel->update($dataToInsert[$a], ['id' => $employee['id']]); + die(); + }else{ + + } + } + + + + + + // $query = $this->employeePolicyModel->getLastQuery(); + // echo $query . "
"; + // Return the array containing data from the Excel file + // return $data; + + + } diff --git a/app/Models/EmployeeModel.php b/app/Models/EmployeeModel.php index 7dd55c43..4e880bd2 100644 --- a/app/Models/EmployeeModel.php +++ b/app/Models/EmployeeModel.php @@ -45,4 +45,13 @@ class EmployeeModel extends Model ->getResult(); } + + + + // for EMP rest API process do not change + public function checkExistingEmpEntrollment($arr) + { + return $this->where('emp_code',$arr['emp_code'])->where('name',$arr['name'])->first(); + } + } diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php index 6bbaeafb..8424ab3c 100644 --- a/app/Models/EmployeePolicyModel.php +++ b/app/Models/EmployeePolicyModel.php @@ -180,5 +180,14 @@ class EmployeePolicyModel extends Model } + + //for emp onboard do not change + public function checkExistingEmpPolicy($arr) + { + return $this->where('employee_id',$arr['employee_id']) + ->where('client_policy_id',$arr['client_policy_id']) + ->find(); + } + //------------------------------------------------------------------ } diff --git a/app/Views/policy_grid.php b/app/Views/policy_grid.php index 4c76b77e..0734c5e4 100644 --- a/app/Views/policy_grid.php +++ b/app/Views/policy_grid.php @@ -629,16 +629,26 @@ // $("#sum_insured").trigger("keyup"); // $("#premium").trigger("keyup"); - // $('#basic_pay').trigger('keyup'); + $('#basic_pay').trigger('keyup'); + + $('input[name="si[]"]').each(function() { + $(this).trigger('keyup'); + }); + + + + $('input[name="premium[]"]').each(function() { + $(this).trigger('keyup'); + }); + // $("input[name='si[]']").trigger("keyup"); // $("input[name='premium[]']").trigger("keyup") setTimeout(function() { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); - }, 1000); + }, 1000);si - $('#basic_gpa_si').trigger('keyup'); }, error: function (xhr, status, error) { @@ -1061,8 +1071,6 @@ function checkDuplicate() { - // console.log($('#grid')[0].value); - if ($('#grid')[0].value === '3') { var siInputs = $('input[name="si[]"]'); var premiumInputs = $('input[name="premium[]"]'); @@ -1504,17 +1512,17 @@ - $("#gpa_si").on("keyup", function() { - var inputNumber = $(this).val(); - if (inputNumber) { - var result = convertCommaNumberToWords(inputNumber); - $("#gpa_si_number_word").text(result); - } else { - $("#gpa_si_number_word").text(""); - } + // $("#gpa_si").on("keyup", function() { + // var inputNumber = $(this).val(); + // if (inputNumber) { + // var result = convertCommaNumberToWords(inputNumber); + // $("#gpa_si_number_word").text(result); + // } else { + // $("#gpa_si_number_word").text(""); + // } - }); + // }); // $("#basic_gpa_premium").on("keyup", function() { // var inputNumber = $(this).val(); @@ -1527,26 +1535,26 @@ // }); - $("#sum_insured").on("keyup", function() { - var inputNumber = $(this).val(); - if (inputNumber) { - var result = convertCommaNumberToWords(inputNumber); - $("#sum_insured_number_word").text(result); - } else { - $("#sum_insured_number_word").text(""); - } - }); + // $("#sum_insured").on("keyup", function() { + // var inputNumber = $(this).val(); + // if (inputNumber) { + // var result = convertCommaNumberToWords(inputNumber); + // $("#sum_insured_number_word").text(result); + // } else { + // $("#sum_insured_number_word").text(""); + // } + // }); - $("#premium").on("keyup", function() { - var inputNumber = $(this).val(); - if (inputNumber) { - var result = convertCommaNumberToWords(inputNumber); - $("#premium_number_word").text(result); - } else { - $("#premium_number_word").text(""); - } - }); + // $("#premium").on("keyup", function() { + // var inputNumber = $(this).val(); + // if (inputNumber) { + // var result = convertCommaNumberToWords(inputNumber); + // $("#premium_number_word").text(result); + // } else { + // $("#premium_number_word").text(""); + // } + // }); From 55f1fd88f5b23b0fc7e9fe763e30f9573cc2f0a7 Mon Sep 17 00:00:00 2001 From: bitbucket Date: Sat, 16 Mar 2024 11:02:05 +0530 Subject: [PATCH 03/18] CHANGE_polictlistApiForEmpLogin:GWM --- app/Config/Routes.php | 4 +++- app/Controllers/EmployeeRestController.php | 6 +++++- app/Models/EmployeeModel.php | 2 +- app/Models/PolicesModel.php | 5 +++-- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 41afa3d2..1c832e4b 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -208,7 +208,7 @@ $routes->group("/api", ["filter" => "authJWT"], function($routes){ $routes->get("/getEmployeeProfile", "EmployeeRestController::getEmployeeProfile/$1"); $routes->post("/editEmployeeProfile", "EmployeeRestController::editEmployeeProfile"); -$routes->get("/getEmployeePolicy", "EmployeeRestController::getEmployeePolicy"); + $routes->post("/employeeUpload", "EmployeeRestController::employeeUpload"); $routes->get("getEmployeeAndDependence", "EmployeeRestController::getEmployeeAndDependence"); @@ -218,6 +218,8 @@ $routes->group("employeeRest", ["filter" => "authJWT"], function($routes){ $routes->get("getEmployeeAndDependence", "EmployeeRestController::getEmployeeAndDependence"); $routes->post("editEmployeeAndDependence", "EmployeeRestController::editEmployeeAndDependence"); $routes->post("addEmployeeAndDependence", "EmployeeRestController::addEmployeeAndDependence"); + + $routes->get("getEmployeePolicy", "EmployeeRestController::getEmployeePolicy"); }); diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 9f2d3574..48db23f7 100644 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -198,6 +198,7 @@ class EmployeeRestController extends AdminController $result = []; foreach ($empPolicy as $array) { + $decodedArray = json_decode($array->Policy_Terms); $refusingData = (object) array_diff_key((array) $decodedArray, array_flip($keysToRemove)); @@ -208,7 +209,10 @@ class EmployeeRestController extends AdminController // $array->Policy_Terms = json_encode($refusingData); $array->Policy_Terms = $refusingData; - + $getSlabAndGridData = $this->policesModel->getPolicySlabRatesForEmpOnboard($array->ClientPolicyId,$array->ClientId); + $array->SlabRates = $getSlabAndGridData['slab_rates']; + $array->GridMaster = $getSlabAndGridData['grid_master']; + $result[] = $array; } return $this->respond(['status' => 'success','code' => 200,'data' => $result], 200); diff --git a/app/Models/EmployeeModel.php b/app/Models/EmployeeModel.php index 4e880bd2..52382dc1 100644 --- a/app/Models/EmployeeModel.php +++ b/app/Models/EmployeeModel.php @@ -37,7 +37,7 @@ class EmployeeModel extends Model { return $this->db->table('employee_polices') - ->select(' policies.name as Policy_Name , client_policy.policy_terms as Policy_Terms, client_policy.client_id as ClientId, client_policy.policy_id as PolicyId, client_policy.open_for_enrollment as OpenForEnrollment') // Select all columns from both tables + ->select(' policies.name as Policy_Name , client_policy.policy_terms as Policy_Terms, client_policy.client_id as ClientId, client_policy.policy_id as PolicyId,client_policy.id as ClientPolicyId, client_policy.open_for_enrollment as OpenForEnrollment') // Select all columns from both tables ->join('client_policy', 'client_policy.id = employee_polices.client_policy_id') ->join('policies', 'policies.id = client_policy.policy_id') ->where('employee_polices.employee_id', $id) diff --git a/app/Models/PolicesModel.php b/app/Models/PolicesModel.php index 074575f3..96e5e8f1 100644 --- a/app/Models/PolicesModel.php +++ b/app/Models/PolicesModel.php @@ -36,12 +36,13 @@ class PolicesModel extends Model $premium_slab_data = null; $policyPremium1Model = new policyPremium1Model(); - $premium_slab_data = $policyPremium1Model->where(['client_id' => $client_id, 'client_policy_id' => $policy_id, 'is_active' => 1])->findAll(); - if((isset($premium_slab_data))) + + if((!count($premium_slab_data))) { $policyPremium2Model = new policyPremium2Model(); $premium_slab_data = $policyPremium2Model->where(['client_id' => $client_id, 'client_policy_id' => $policy_id, 'is_active' => 1])->findAll(); + } $grid_id = $premium_slab_data[0]['policy_grid_id']; $policyGridModel = new policyGridModel(); From 29fb6e4eb6985893c4348e9dd4e56ec7fd1cfd59 Mon Sep 17 00:00:00 2001 From: bitbucket Date: Sat, 16 Mar 2024 12:29:17 +0530 Subject: [PATCH 04/18] ChangesPoilcyApi:GWM --- app/Controllers/EmployeeRestController.php | 51 +++++++++++++++++----- app/Models/PolicesModel.php | 3 +- 2 files changed, 42 insertions(+), 12 deletions(-) diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 48db23f7..e8ef9517 100644 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -189,11 +189,12 @@ class EmployeeRestController extends AdminController public function getEmployeePolicy() { // $id= 4; - try { + // try { $id = $this->request->getGet('id'); - $keysToRemove = ["sum_insured","family_floater","corporatebuffer","family_floaters"]; + $keysToRemove = ["removable_keys"]; $empPolicy = $this->employeeModel->getEmployeePolicy($id); + // dd($empPolicy); if ($empPolicy) { $result = []; @@ -202,16 +203,44 @@ class EmployeeRestController extends AdminController $decodedArray = json_decode($array->Policy_Terms); $refusingData = (object) array_diff_key((array) $decodedArray, array_flip($keysToRemove)); - // $client_id =$array->ClientId; - // $policy_id =$array->PolicyId; - - // $rackRate = $this->policesModel->getPolicySlabRatesForEmpOnboard($policy_id, $client_id); - - // $array->Policy_Terms = json_encode($refusingData); + $array->Policy_Terms = $refusingData; $getSlabAndGridData = $this->policesModel->getPolicySlabRatesForEmpOnboard($array->ClientPolicyId,$array->ClientId); $array->SlabRates = $getSlabAndGridData['slab_rates']; $array->GridMaster = $getSlabAndGridData['grid_master']; + + if($getSlabAndGridData['grid_master']['policy_type'] == "GPA"){ + $default_si = $array->Policy_Terms->sumInsured2; + $index = -1; + foreach ($array->SlabRates as $key => $value) { + if ($value['si'] == $default_si) { + $index = $key; + break; + } + } + if ($index >= 0) { + $element =$array->SlabRates[$index]; + array_splice($array->SlabRates, $index, 1); + array_unshift($array->SlabRates, $element); + } + + }else if($getSlabAndGridData['grid_master']['policy_type'] == "GMC"){ + + // re-arranging order of si + $default_si = $array->Policy_Terms->sum_insured; + $index = -1; + foreach ($array->SlabRates as $key => $value) { + if ($value['si'] == $default_si) { + $index = $key; + break; + } + } + if ($index >= 0) { + $element =$array->SlabRates[$index]; + array_splice($array->SlabRates, $index, 1); + array_unshift($array->SlabRates, $element); + } + } $result[] = $array; } @@ -219,9 +248,9 @@ class EmployeeRestController extends AdminController }else{ return $this->respond(['status' => 'failed','code' => 404,'data' => []], 404); } - } catch (\Exception $e) { - return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500); - } + // } catch (\Exception $e) { + // return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500); + // } } diff --git a/app/Models/PolicesModel.php b/app/Models/PolicesModel.php index 96e5e8f1..9aa5811f 100644 --- a/app/Models/PolicesModel.php +++ b/app/Models/PolicesModel.php @@ -1,7 +1,8 @@ Date: Sat, 16 Mar 2024 13:46:51 +0530 Subject: [PATCH 05/18] ModelnameSmallcase:GWM --- app/Models/PolicesModel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Models/PolicesModel.php b/app/Models/PolicesModel.php index 9aa5811f..a33d1880 100644 --- a/app/Models/PolicesModel.php +++ b/app/Models/PolicesModel.php @@ -1,8 +1,8 @@ where(['client_id' => $client_id, 'client_policy_id' => $policy_id, 'is_active' => 1])->findAll(); if((!count($premium_slab_data))) { - $policyPremium2Model = new policyPremium2Model(); + $policyPremium2Model = new PolicyPremium2Model(); $premium_slab_data = $policyPremium2Model->where(['client_id' => $client_id, 'client_policy_id' => $policy_id, 'is_active' => 1])->findAll(); } From 409dd470d461d4e955342caec664d05ba13185e5 Mon Sep 17 00:00:00 2001 From: bitbucket Date: Mon, 18 Mar 2024 15:14:16 +0530 Subject: [PATCH 06/18] CHANGES-IN-RESTAPI:GWM --- app/Config/Routes.php | 8 +- app/Controllers/EmployeeRestController.php | 97 +++++++++++++++++-- .../RestAuthenticationController.php | 65 +++++++++++++ app/Models/EmployeePolicyModel.php | 13 +++ app/Models/LevelContactModel.php | 1 + app/Models/PolicesModel.php | 3 +- 6 files changed, 179 insertions(+), 8 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 1c832e4b..43a4813a 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -195,9 +195,12 @@ $routes->cli('processjob', 'JobWorker::processJob'); -// $routes->get("/api", "RestAuthenticationController::index"); +//Employee login api's $routes->post("/employeeRest/verifyEmployeeNumber", "RestAuthenticationController::verifyEmployeeWithMobileNumber"); $routes->post("/employeeRest/getVerifiedUserData", "RestAuthenticationController::getVerifiedUserData"); +//HR login api's +$routes->post("/employeeRest/verifyHrWithMobileNumber", "RestAuthenticationController::verifyHrWithMobileNumber"); +$routes->post("/employeeRest/getVerifiedHrData", "RestAuthenticationController::getVerifiedHrData"); $routes->group("/api", ["filter" => "authJWT"], function($routes){ $routes->post("logined", "RestAuthenticationController::logined"); @@ -220,6 +223,9 @@ $routes->group("employeeRest", ["filter" => "authJWT"], function($routes){ $routes->post("addEmployeeAndDependence", "EmployeeRestController::addEmployeeAndDependence"); $routes->get("getEmployeePolicy", "EmployeeRestController::getEmployeePolicy"); + $routes->post("createOrUpdateEmployeePolicySiAmount", "EmployeeRestController::createOrUpdateEmployeePolicySiAmount"); + $routes->get("deleteDependence", "EmployeeRestController::deleteDependence"); + $routes->get("getEmployeeAndDependenceByClientId", "EmployeeRestController::getEmployeeAndDependenceByClientId"); }); diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index e8ef9517..19c4c5b3 100644 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -69,7 +69,7 @@ class EmployeeRestController extends AdminController } catch (\Throwable $th) { return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500); } - } + } public function editEmployeeProfile() @@ -185,11 +185,65 @@ class EmployeeRestController extends AdminController } + public function deleteDependence() + { + try { + $delete = $this->employeeModel->where('id', $this->request->getGet('id'))->delete(); + + if ($delete) { + return $this->respond(['status' => 'success','code' => 200,'data' =>[] ], 200); + } else { + return $this->respond(['status' => 'failed','code' => 404,'data' => [] ], 404); + } + + } catch (\Exception $e) { + return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500); + } + + } + + + public function getEmployeeAndDependenceByClientId() + { + try { + $empData = $this->employeeModel + ->where('client_id', $this->request->getGet('client_id')) + ->where('relationship', 'self') + ->orderBy('id') + ->findAll(); + + $result = []; + + foreach ($empData as $employee) { + $employeeDependence = $this->employeeModel + ->where('emp_code', $employee['emp_code']) + ->where('relationship !=', 'self') + ->findAll(); + + // Use object notation to access properties and set 'dependence' + $employee['dependence'] = $employeeDependence ?: []; + + $result[] = $employee; + } + + // You probably meant to check $result, not $data + if ($result) { + return $this->respond(['status' => 'success', 'code' => 200, 'data' => $result], 200); + } else { + return $this->respond(['status' => 'failed', 'code' => 404, 'data' => []], 404); + } + + + } catch (\Exception $e) { + return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500); + } + + } + public function getEmployeePolicy() { - // $id= 4; - // try { + try { $id = $this->request->getGet('id'); $keysToRemove = ["removable_keys"]; @@ -248,9 +302,40 @@ class EmployeeRestController extends AdminController }else{ return $this->respond(['status' => 'failed','code' => 404,'data' => []], 404); } - // } catch (\Exception $e) { - // return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500); - // } + } catch (\Exception $e) { + return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500); + } + } + + public function createOrUpdateEmployeePolicySiAmount() + { + + try { + $requestData = $this->request->getJSON(); + + + $checkIfExist = $this->employeePolicyModel->where('employee_id', $requestData['employee_id']) + ->where('client_policy_id', $requestData['client_policy_id']) + ->findAll(); + // dd($checkIfExist); + if ($checkIfExist) { + + $empPolicy = $this->employeePolicyModel->updateSiAndPremium($requestData['client_policy_id'], $requestData['employee_id'], $requestData['basic_cover_si']); + + }else{ + + $data['employee_id']= $requestData['employee_id']; + $data['client_policy_id']= $requestData['client_policy_id']; + $data['basic_cover_si']= $requestData['basic_cover_si']; + + $this->employeePolicyModel->insert($data); + } + + return $this->respond(['status' => 'success','code' => 200,'data' => []], 200); + + } catch (\Exception $e) { + return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500); + } } diff --git a/app/Controllers/RestAuthenticationController.php b/app/Controllers/RestAuthenticationController.php index ac43c791..721e71a9 100644 --- a/app/Controllers/RestAuthenticationController.php +++ b/app/Controllers/RestAuthenticationController.php @@ -20,6 +20,7 @@ use CodeIgniter\API\ResponseTrait; use App\Models\EmployeeModel; use App\Models\AuthHistoryModel; +use App\Models\LevelContactModel; use Firebase\JWT\JWT; // require_once('../vendor/autoload.php'); @@ -33,6 +34,7 @@ class RestAuthenticationController extends AdminController protected $myLogger; protected $employeeModel; protected $authHistoryModel; + protected $hrModel; public function __construct() @@ -42,6 +44,7 @@ class RestAuthenticationController extends AdminController $this->employeeModel = new EmployeeModel(); $this->authHistoryModel = new AuthHistoryModel(); + $this->hrModel = new LevelContactModel(); } @@ -121,6 +124,68 @@ class RestAuthenticationController extends AdminController } } + public function verifyHrWithMobileNumber() + { + try { + $mobile_number = $this->request->getJSON()->mobile_number; + $randomNumber = rand(100000, 999999); + + $HrData = $this->hrModel->where('mobile', $mobile_number)->where('contact_type', 'client')->first(); + + if ($HrData) { + $id= $HrData["id"]; + $otp = $this->hrModel->where('id', $id)->set('otp', $randomNumber)->update(); + $result = ['user_verification' => true , 'otp'=>$randomNumber]; + return $this->respond(['status' => 'success','code' => 200,'data' => $result],200); + } else { + $result = ['user_verification' => false]; + return $this->respond(['status' => 'failed','code' => 404,'data' => $result],404); + + } + } catch (\Throwable $th) { + return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500); + } + } + + + public function getVerifiedHrData() + { + try { + $mobile_number = $this->request->getJSON()->mobile_number; + $otp = $this->request->getJSON()->otp; + + $hrData = $this->hrModel->where('mobile', $mobile_number)->first(); + if ($hrData && $otp == $hrData["otp"]) { + $auth = HttpRequestHelper::getRequestInfo(); + if ($auth) { + $data = [ + 'user_id' => $hrData['id'], + 'user_type' => 'hr', + 'ip' => $auth['ip'], + 'platform' => $auth['platform'], + 'broswer' => $auth['browser'], + ]; + + $authdata= $this->authHistoryModel->insert($data); + + } + $otp_null = $this->hrModel->where('id', $hrData["id"])->set('otp', null)->update(); + + $hrData = $this->hrModel ->select('level_contacts.* , client_branch.client_id as client_id') + ->join('client_branch', 'level_contacts.ref_id = client_branch.id', 'left') + ->where('level_contacts.mobile', $mobile_number ) + ->find(); + + $result = JWTToken::encode($hrData); + return $this->respond(['status' => 'success','code' => 200,'data' => $result],200); + } else { + return $this->respond(['status' => 'failed','code' => 404,'data' => "No data"],404); + } + } catch (\Exception $e) { + return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()],500); + } + } + public function employeeLogout() diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php index 8424ab3c..530d8543 100644 --- a/app/Models/EmployeePolicyModel.php +++ b/app/Models/EmployeePolicyModel.php @@ -189,5 +189,18 @@ class EmployeePolicyModel extends Model ->find(); } + + public function updateSiAndPremium( $client_policy_id, $employee_id,$basic_cover_si) + { + + + $query = "UPDATE employee_polices + SET employee_polices.basic_cover_si = '{$basic_cover_si}' + WHERE employee_polices.employee_id = '{$employee_id}' + AND employee_polices.client_policy_id = '{$client_policy_id}'"; + + $this->query($query); + } + //------------------------------------------------------------------ } diff --git a/app/Models/LevelContactModel.php b/app/Models/LevelContactModel.php index 635d3652..79a8f15a 100644 --- a/app/Models/LevelContactModel.php +++ b/app/Models/LevelContactModel.php @@ -20,6 +20,7 @@ class LevelContactModel extends Model "designation", "created_by", "updated_by", + "otp", "is_active", ]; diff --git a/app/Models/PolicesModel.php b/app/Models/PolicesModel.php index a33d1880..70724d71 100644 --- a/app/Models/PolicesModel.php +++ b/app/Models/PolicesModel.php @@ -3,6 +3,7 @@ namespace App\Models; use App\Models\PolicyPremium1Model; use App\Models\PolicyPremium2Model; +use App\Models\PolicyGridModel; use CodeIgniter\Model; class PolicesModel extends Model @@ -46,7 +47,7 @@ class PolicesModel extends Model } $grid_id = $premium_slab_data[0]['policy_grid_id']; - $policyGridModel = new policyGridModel(); + $policyGridModel = new PolicyGridModel(); $results = $policyGridModel->find($grid_id); return ['slab_rates' => $premium_slab_data,'grid_master' => $results]; } From f601bb5cd5b5d59f4ab3b65bc4c454e10ba5f243 Mon Sep 17 00:00:00 2001 From: aadhavan valli Date: Mon, 18 Mar 2024 19:39:39 +0530 Subject: [PATCH 07/18] FEATURE_EMPLOYEE_FILE_UPLOAD_MAIL_HELPER : AADHAVAN --- app/Config/Email.php | 14 +- app/Config/Routes.php | 1 + app/Controllers/ClientController.php | 337 +++++++++--------- app/Controllers/EmployeeRestController.php | 113 +++--- app/Helpers/MailHelper.php | 44 +++ app/Views/client_policy.php | 102 +++--- app/Views/policy_gpa_terms.php | 15 +- app/Views/policy_grid.php | 388 +++++++++------------ composer.json | 1 + 9 files changed, 544 insertions(+), 471 deletions(-) create mode 100644 app/Helpers/MailHelper.php diff --git a/app/Config/Email.php b/app/Config/Email.php index 4dce650b..b6ac8865 100644 --- a/app/Config/Email.php +++ b/app/Config/Email.php @@ -18,7 +18,7 @@ class Email extends BaseConfig /** * The mail sending protocol: mail, sendmail, smtp */ - public string $protocol = 'mail'; + public string $protocol = 'smtp'; /** * The server path to Sendmail. @@ -28,22 +28,22 @@ class Email extends BaseConfig /** * SMTP Server Hostname */ - public string $SMTPHost = ''; + public string $SMTPHost = 'mail.venbait.in'; /** * SMTP Username */ - public string $SMTPUser = ''; + public string $SMTPUser = 'bbone@venbait.in'; /** * SMTP Password */ - public string $SMTPPass = ''; + public string $SMTPPass = 'xk!L(N_-R#};'; /** * SMTP Port */ - public int $SMTPPort = 25; + public int $SMTPPort = 465; /** * SMTP Timeout (in seconds) @@ -62,7 +62,7 @@ class Email extends BaseConfig * to the server. 'ssl' means implicit SSL. Connection on port * 465 should set this to ''. */ - public string $SMTPCrypto = 'tls'; + public string $SMTPCrypto = 'ssl'; /** * Enable word-wrap @@ -77,7 +77,7 @@ class Email extends BaseConfig /** * Type of mail, either 'text' or 'html' */ - public string $mailType = 'text'; + public string $mailType = 'html'; /** * Character set (utf-8, iso-8859-1, etc.) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 41afa3d2..3d703e43 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -220,5 +220,6 @@ $routes->group("employeeRest", ["filter" => "authJWT"], function($routes){ $routes->post("addEmployeeAndDependence", "EmployeeRestController::addEmployeeAndDependence"); }); +$routes->post("sendEmail", "EmployeeRestController::send_email"); diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 8d8b8104..87f633fa 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -583,175 +583,194 @@ class ClientController extends AdminController public function createClientPolicyPremium() { - // print_r($this->request->getPost());die(); - $policy_type = $this->request->getPost('policy_type'); - $client_id = $this->request->getPost('client_id'); - $client_policy_id = $this->request->getPost('client_policy_id'); - $policy_grid_id = $this->request->getPost('policy_grid_id'); - $multiplier = $this->request->getPost('multiplier'); - $si_or_bp = $this->request->getPost('si_or_bp'); - $basic_multiplier = $this->request->getPost('basic_multiplier'); - $premium_multiplier =$this->request->getPost('premium_multiplier'); - $basic_pay = $this->request->getPost('basic_pay'); + try { + $policy_type = $this->request->getPost('policy_type'); + $client_id = $this->request->getPost('client_id'); + $client_policy_id = $this->request->getPost('client_policy_id'); + $policy_grid_id = $this->request->getPost('policy_grid_id'); + $si_or_bp = $this->request->getPost('si_or_bp'); + $basic_multiplier = str_replace(',', '', $this->request->getPost('basic_multiplier')); + $premium_multiplier = str_replace(',', '', $this->request->getPost('premium_multiplier')); + $multiplier = str_replace(',', '', $this->request->getPost('multiplier')); + $basic_pay = str_replace(',', '', $this->request->getPost('basic_pay')); + + $data=[]; + $data['client_id'] = $client_id; + $data['client_policy_id'] = $client_policy_id; + $data['policy_grid_id'] = $policy_grid_id; + - if($policy_type !== null && $policy_type !== ''){ + $premium = []; - $this->policyPremium1Model->where('client_id', $client_id)->where('client_policy_id', $client_policy_id)->set('is_active', 0)->update(); - - if($si_or_bp == '1'){ - $premiumData = $this->request->getPost('sum_premium'); - - }else{ - $premiumData = $this->request->getPost('premium'); + if ($policy_grid_id == '1' || $policy_grid_id == '2') { + $this->policyPremium1Model->where('client_id', $client_id)->where('client_policy_id', $client_policy_id)->set('is_active', 0)->update(); + } else { + $this->policyPremium2Model->where('client_id', $client_id)->where('client_policy_id', $client_policy_id)->set('is_active', 0)->update(); } + - for ($i = 0; $i < count($premiumData); $i++) { - $data = [ - 'client_id' => $client_id, - 'client_policy_id' => $client_policy_id, - 'policy_grid_id' => $policy_grid_id, - 'created_by' => get_session_userid(), - ]; - - if ($si_or_bp == '2') { - if(is_array($this->request->getPost('basic_si'))){ - $si = isset($this->request->getPost('basic_si')[$i]) ? $this->request->getPost('basic_si')[$i] : null; - }else{ - $si = $this->request->getPost('basic_si'); - } - } else { - if(is_array($this->request->getPost('si'))){ - $si = isset($this->request->getPost('si')[$i]) ? $this->request->getPost('si')[$i] : null; - }else{ - $si = $this->request->getPost('si'); - } - } - - - if($si_or_bp == '1'){ - if(is_array($this->request->getPost('sum_premium'))){ - $premium = isset($this->request->getPost('sum_premium')[$i]) ? $this->request->getPost('sum_premium')[$i] : null; - }else{ - $premium = $this->request->getPost('sum_premium'); - } - }else{ - if(is_array($this->request->getPost('premium'))){ - $premium = isset($this->request->getPost('premium')[$i]) ? $this->request->getPost('premium')[$i] : null; - }else{ - $premium = $this->request->getPost('premium'); - } - } - - // $basic_gpa_premium = isset($basic_gpa_premium[$i]) ? $basic_gpa_premium[$i] : null; - if ($si !== null) { - $data['si'] = $si; - } - if ($premium !== null) { - $data['premium'] = $premium; - } - - if($si_or_bp == 2){ - if ($premium_multiplier !== null) { - $data['multiplier'] = $premium_multiplier; - } - }else{ - if ($multiplier !== null) { + if($policy_grid_id == '1'){ + if ($si_or_bp == '1') { + $premium=str_replace(',', '', $this->request->getPost('gpa_sum_premium[]')); + $sum_insure=str_replace(',', '', $this->request->getPost('gpa_sum_si[]')); + $multiplier=$this->request->getPost('gpa_sum_multiplier'); + for ($i=0; $i < count($premium) ; $i++) { + $data['si'] = $sum_insure[$i]; + $data['premium'] = $premium[$i]; $data['multiplier'] = $multiplier; + $data['si_or_bp'] = $this->request->getPost('si_or_bp'); + + $policyPremium= $this->policyPremium1Model->insert($data); } - } - - if ($si_or_bp !== null) { - $data['si_or_bp'] = $si_or_bp; - } + } else { + $data['premium'] = str_replace(',', '', $this->request->getPost('gpa_basic_premium')); + $data['si'] = str_replace(',', '', $this->request->getPost('gpa_basic_si')); + $data['basic_multiplier'] = str_replace(',', '', $this->request->getPost('basic_multiplier')); + $data['multiplier'] = $this->request->getPost('premium_multiplier'); + $data['basic_pay'] = str_replace(',', '', $this->request->getPost('basic_pay')); + $data['si_or_bp'] = $this->request->getPost('si_or_bp'); - + $policyPremium= $this->policyPremium1Model->insert($data); + } + $data = $this->request->getPost(); + $insert = true; + }else if($policy_grid_id == '2'){ + $data['premium'] = str_replace(',', '', $this->request->getPost('gpa_premium')); + $data['si'] = str_replace(',', '', $this->request->getPost('gpa_si')); - if ($basic_multiplier !== null) { - $data['basic_multiplier'] = $basic_multiplier; + $policyPremium= $this->policyPremium1Model->insert($data); + + $data = $this->request->getPost(); + $insert = true; + }else if($policy_grid_id == '3'){ + $premium=$this->request->getPost('3_premium[]'); + $sum_insure =$this->request->getPost('3_si[]'); + for ($i=0; $i < count($premium) ; $i++) { + $data['premium'] = str_replace(',', '',$premium[$i]); + $data['si'] = str_replace(',', '', $sum_insure[$i]); + $dataa= $this->policyPremium2Model->insert($data); } - - if ($basic_pay !== null) { - $data['basic_pay'] = $basic_pay; + $data = $this->request->getPost(); + $insert = true; + }else if($policy_grid_id == '4'){ + $premium=$this->request->getPost('4_premium[]'); + $sum_insure =$this->request->getPost('4_si'); + $age_from =$this->request->getPost('4_age_from[]'); + $age_to =$this->request->getPost('4_age_to[]'); + for ($i=0; $i < count($premium) ; $i++) { + $data['premium'] = str_replace(',', '',$premium[$i]); + $data['si'] = str_replace(',', '', $sum_insure); + $data['age_from'] = $age_from[$i]; + $data['age_to'] = $age_to[$i]; + $dataa= $this->policyPremium2Model->insert($data); } - - $this->policyPremium1Model->insert($data); + $data = $this->request->getPost(); + $insert = true; + }else if($policy_grid_id == '5'){ + $premium=$this->request->getPost('5_premium[]'); + $sum_insure =$this->request->getPost('5_si[]'); + $age_from =$this->request->getPost('5_age_from[]'); + $age_to =$this->request->getPost('5_age_to[]'); + for ($i=0; $i < count($premium) ; $i++) { + $data['premium'] = str_replace(',', '',$premium[$i]); + $data['si'] = str_replace(',', '', $sum_insure[$i]); + $data['age_from'] = $age_from[$i]; + $data['age_to'] = $age_to[$i]; + $dataa= $this->policyPremium2Model->insert($data); + } + $data = $this->request->getPost(); + $insert = true; + }else if($policy_grid_id == '6'){ + $premium=$this->request->getPost('6_premium[]'); + $sum_insure =$this->request->getPost('6_si[]'); + $age_from =$this->request->getPost('6_age_from[]'); + $age_to =$this->request->getPost('6_age_to[]'); + for ($i=0; $i < count($premium) ; $i++) { + $data['premium'] = str_replace(',', '',$premium[$i]); + $data['si'] = str_replace(',', '', $sum_insure[$i]); + $data['age_from'] = $age_from[$i]; + $data['age_to'] = $age_to[$i]; + $dataa= $this->policyPremium2Model->insert($data); + } + $data = $this->request->getPost(); + $insert = true; + }else if($policy_grid_id == '7'){ + $premium=$this->request->getPost('7_premium[]'); + $sum_insure =$this->request->getPost('7_si[]'); + $age_from =$this->request->getPost('7_age_from[]'); + $age_to =$this->request->getPost('7_age_to[]'); + for ($i=0; $i < count($premium) ; $i++) { + $data['premium'] = str_replace(',', '',$premium[$i]); + $data['si'] = str_replace(',', '', $sum_insure[$i]); + $data['age_from'] = $age_from[$i]; + $data['age_to'] = $age_to[$i]; + $dataa= $this->policyPremium2Model->insert($data); + } + $data = $this->request->getPost(); + $insert = true; + }else if($policy_grid_id == '8'){ + $premium=$this->request->getPost('8_premium[]'); + $sum_insure =$this->request->getPost('8_si[]'); + $grade =$this->request->getPost('8_grade[]'); + for ($i=0; $i < count($premium) ; $i++) { + $data['premium'] = str_replace(',', '',$premium[$i]); + $data['si'] = str_replace(',', '', $sum_insure[$i]); + $data['grade'] = $grade[$i]; + $dataa= $this->policyPremium2Model->insert($data); + } + $data = $this->request->getPost(); + $insert = true; + }else if($policy_grid_id == '9'){ + $premium=$this->request->getPost('9_premium[]'); + $sum_insure =$this->request->getPost('9_si[]'); + $grade =$this->request->getPost('9_grade[]'); + for ($i=0; $i < count($premium) ; $i++) { + $data['premium'] = str_replace(',', '',$premium[$i]); + $data['si'] = str_replace(',', '', $sum_insure[$i]); + $data['grade'] = $grade[$i]; + $dataa= $this->policyPremium2Model->insert($data); + } + $data = $this->request->getPost(); + $insert = true; + }else if($policy_grid_id == '10'){ + $premium=$this->request->getPost('10_premium[]'); + $sum_insure =$this->request->getPost('10_si[]'); + $age_from =$this->request->getPost('10_age_from[]'); + $age_to =$this->request->getPost('10_age_to[]'); + for ($i=0; $i < count($premium) ; $i++) { + $data['premium'] = str_replace(',', '',$premium[$i]); + $data['si'] = str_replace(',', '', $sum_insure[$i]); + $data['age_from'] = $age_from[$i]; + $data['age_to'] = $age_to[$i]; + $policyPremium= $this->policyPremium2Model->insert($data); + } + $data = $this->request->getPost(); + $insert = true; + }else if($policy_grid_id == '11'){ + $premium=$this->request->getPost('11_premium[]'); + $sum_insure =$this->request->getPost('11_si[]'); + $grade =$this->request->getPost('11_grade[]'); + $max_sum_insure =$this->request->getPost('11_max_si[]'); + for ($i=0; $i < count($premium) ; $i++) { + $data['premium'] = str_replace(',', '',$premium[$i]); + $data['si'] = str_replace(',', '', $sum_insure[$i]); + $data['grade'] = $grade[$i]; + $data['max_si'] = $max_sum_insure[$i]; + $dataa= $this->policyPremium2Model->insert($data); + } + $data = $this->request->getPost(); + $insert = true; } - $data = $this->request->getPost(); - $insert = true; if($insert){ return $this->respond(['status' => true,'code' => 200,'data' => $data], 200); - }else{ + }else{ return $this->respond(['status' => false,'code' => 404, 'data' => $data,'message' => 'no data found'], 200); - - } - // print_r($data); - // die(); - // $data['created_by'] = get_session_userid(); - // $this->policyPremium1Model->where('client_id', $client_id)->where('client_policy_id', $client_policy_id)->set('is_active', 0)->update(); - // $insert = $this->policyPremium1Model->insert($data); - }else{ - - $this->policyPremium2Model->where('client_id', $client_id)->where('client_policy_id', $client_policy_id)->set('is_active', 0)->update(); - $premiumData = $this->request->getPost('premium'); - for ($i = 0; $i < count($premiumData); $i++) { - - $data = [ - 'client_id' => $client_id, - 'client_policy_id' => $client_policy_id, - 'policy_grid_id' => $policy_grid_id, - 'created_by' => get_session_userid(), - - ]; - - if(is_array($this->request->getPost('si'))){ - $si = isset($this->request->getPost('si')[$i]) ? $this->request->getPost('si')[$i] : null; - }else{ - $si = $this->request->getPost('si'); - } - $age_from = isset($this->request->getPost('age_from')[$i]) ? $this->request->getPost('age_from')[$i] : null; - $age_to = isset($this->request->getPost('age_to')[$i]) ? $this->request->getPost('age_to')[$i] : null; - $premium = isset($premiumData[$i]) ? $premiumData[$i] : null; - $grade = isset($this->request->getPost('grade')[$i]) ? $this->request->getPost('grade')[$i] : null; - $max_si = isset($this->request->getPost('max_si')[$i]) ? $this->request->getPost('max_si')[$i] : null; - - if ($si !== null) { - $data['si'] = $si; - } - - if ($age_from !== null) { - $data['age_from'] = $age_from; - } - - if ($age_to !== null) { - $data['age_to'] = $age_to; - } - - if ($premium !== null) { - $data['premium'] = $premium; - } - - if ($max_si !== null) { - $data['max_si'] = $max_si; - } - - if ($grade !== null) { - $data['grade'] = $grade; - } - - $this->policyPremium2Model->insert($data); - } - $data = $this->request->getPost(); - $insert = true; - } - - if($insert){ - return $this->respond(['status' => true,'code' => 200,'data' => $data], 200); - }else{ - return $this->respond(['status' => false,'code' => 404, 'data' => $data,'message' => 'no data found'], 200); - - } - + } + } catch (Exception $e) { + // Handle exceptions here + echo 'Error: ' . $e->getMessage(); + } } @@ -844,14 +863,12 @@ class ClientController extends AdminController }else{ $premiumData = $this->policyPremium2Model->where(['client_id' => $record['client_id'], 'client_policy_id' => $client_policy_id, 'is_active' => 1])->findAll(); } - - // echo '
';
         // print_r($results);
         // print_r($data[0]->policy_type); die;
                     // echo "hello";
-            // print_r($premiumData);
-        return $this->respond(['status' => true,'code' => 200,'data' => $results, 'premiumData' => $premiumData, 'count' => $emp_count, 'policy_name' => $policy_name], 200);
+            // return json_encode($premiumData);
+        return $this->respond(['status' => true,'code' => 200,'data' => $results, 'premiumData' => json_encode($premiumData), 'count' => $emp_count, 'policy_name' => $policy_name], 200);
 
     }
 
@@ -862,6 +879,7 @@ class ClientController extends AdminController
             
             $this->myLogger->logme('error','Terms CREATE function called');
             
+
             /*** Client Policy Table Primary Key(ID) ***/
             $client_policy_id = $this->request->getPost("client_policy_id");
 
@@ -870,6 +888,9 @@ class ClientController extends AdminController
                 $data['corporatebuffer'] = $this->request->getPost("corporatebuffer");
                 $data['family_floaters'] = $this->request->getPost("family_floaters") ?? [];                
 
+                if (!in_array("self", $data['family_floaters'])) {
+                    array_unshift($data['family_floaters'], "self");
+                }
             $data['waiverofpreexistingdiseases']   =$this->request->getPost("waiverofpreexistingdiseases");
             if ($data['waiverofpreexistingdiseases'] == 1) {
                 $data['maternitycoverage']   =$this->request->getPost("maternitycoverage");
diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php
index 9f2d3574..56b8d097 100644
--- a/app/Controllers/EmployeeRestController.php
+++ b/app/Controllers/EmployeeRestController.php
@@ -2,6 +2,8 @@
 
 namespace App\Controllers;
 
+use App\Helpers\MailHelper;
+
 use CodeIgniter\HTTP\IncomingRequest;
 use CodeIgniter\HTTP\RequestInterface;
 use CodeIgniter\HTTP\ResponseInterface;
@@ -14,6 +16,7 @@ use App\Models\ClientModel;
 use App\Models\PolicesModel;
 use App\Models\RelationshipModel;
 use App\Models\FileModel;
+use App\Models\ClientPolicyModel;
 
 
 use PhpOffice\PhpSpreadsheet\Spreadsheet;
@@ -36,6 +39,7 @@ class EmployeeRestController extends AdminController
     protected $fileModel;
     protected $policesModel;
     protected $relationshipModel;
+    protected $clientPolicyModel;
 
     public function __construct()
     {
@@ -48,6 +52,7 @@ class EmployeeRestController extends AdminController
         $this->policesModel = new PolicesModel();
         $this->relationshipModel = new RelationshipModel();
         $this->fileModel= new FileModel();
+        $this->clientPolicyModel= new ClientPolicyModel();
     }
 
   
@@ -144,7 +149,7 @@ class EmployeeRestController extends AdminController
         
     }
 
-
+    
     public function addEmployeeAndDependence()
     {
         try {
@@ -220,7 +225,7 @@ class EmployeeRestController extends AdminController
         }
     }
 
-
+    // Get the RelationShip list
     public function relationshipList()
     {
         try {
@@ -238,18 +243,15 @@ class EmployeeRestController extends AdminController
         }
     }
 
-
+    // Upload the Sheet Data in DB
     public function employeeUpload()
     {
-
         $file = $this->request->getFile('file');
         $client_id = $this->request->getPost('client_id');
         $policy_id = $this->request->getPost('policy_id');
 
-
         $is_moved = $file->move(WRITEPATH . 'uploads/import_excel');
         $filename = $file->getName();
-
         $file_name_with_path = WRITEPATH."/uploads/import_excel/".$filename;
 
         //check the file exist or not
@@ -258,7 +260,6 @@ class EmployeeRestController extends AdminController
             session()->setFlashdata('error', 'File not found');
             return redirect()->to(base_url('employee/upload'));
         }
-
         // Load the Excel file
         $spreadsheet = IOFactory::load($file_name_with_path);
 
@@ -289,17 +290,16 @@ class EmployeeRestController extends AdminController
             $data[] = $rowData;
         }
 
+        
         $extractData['file_name']= $filename;
         $extractData['client_id']= $client_id;
         $extractData['status']= 'success';
         $extractData['policy_id']= $policy_id;
         $extractData['action']= 'enrollment';
-
         //  $extractData['created_by']=set_session_context('Employee');
 
         $file_data =$this->fileModel->insert($extractData);
 
-        // print_r(count($data));
         $extra = [];
         for ($i = 0; $i < count($data); $i++) {
             if ($i == 0) {
@@ -318,57 +318,90 @@ class EmployeeRestController extends AdminController
                 }
             }
         }
-
+        // print_r("Extra", $extra);die;
         $dataToInsert = [];
+        $basic_cover_si= [];
         foreach ($extra['id'] as $index => $id) {
             $record = [
                 // 'id' => $id,
-                'emp_code' => $extra['emp_code'][$index],
+                'emp_code' => isset($extra['emp_code'][$index]) ? $extra['emp_code'][$index] : 0,
                 'name' => $extra['name'][$index],
                 // Check if the 'doj' key exists before accessing it
                 'doj' => isset($extra['doj'][$index]) ? $extra['doj'][$index] : null,
                 'gender' => $extra['gender'][$index],
                 'relationship' => $extra['relationship'][$index],
                 'dob' => $extra['dob'][$index],
-                'email' => $extra['Email'][$index],
+                'email_personal' => $extra['Email'][$index],
+                'client_id' => $client_id,
             ];
+            $record2 = [
+                'basic_cover_si' => isset($extra['sum_insure'][$index]) ? $extra['sum_insure'][$index] : 0,
+            ];
+
             $dataToInsert[] = $record;
+            $basic_cover_si[]= $record2;
         }
-
-                // print_r($dataToInsert);die();
-
-                for ($a=0; $a employeeModel->insert($dataToInsert[$a]);
-
-                     $employee = $this->employeeModel->checkExistingEmpEntrollment($dataToInsert[$a]);
-
-                    // print_r($employee);die;
-                     if (count($employee)) {
-                        // $dataToInsert['id'] = $employee['id'];
-                        $this->employeeModel->update($dataToInsert[$a], ['id' => $employee['id']]);
-                        die();
+        // print_r("dataToInsert", $dataToInsert);die;
+        for ($a=0; $a employeeModel->checkExistingEmpEntrollment($dataToInsert[$a]);
+                    $emp_id =0;
+                    if ($employee) {
+                        $emp_id =$employee['id'];
+                        $id =$emp_id;
+                        $result = $this->employeeModel->update($id, $dataToInsert[$a]);
+                        if ($result) {
+                            $log_message = 'Update Employee - '.$employee['name'].'('.$employee['emp_code'].') with PK '.$employee['id'];
+                            $this->myLogger->logme('error',('Update - ' . $employee['id'].' - '. $employee['emp_code'] .' - '.$employee['name']));
+                        }
                     }else{
+                        $result = $this->employeeModel->insert($dataToInsert[$a]);
+                        $emp_id =$result;
+                        if ($result) {
+                            $emp = $this->employeeModel->where('id', $result)->get()->getResult();
 
-                     }
-                }
-        
-        
-
-
-
-        
-        // $query = $this->employeePolicyModel->getLastQuery();
-        // echo $query . "
"; - // Return the array containing data from the Excel file - // return $data; + $policy_name = $this->employeePolicyModel->where('employee_id', $result)->get()->getResult();; + + + $log_message = 'Insert Employee- '.$dataToInsert[$a]['name'] .'('.$dataToInsert[$a]['emp_code'] .') with PK '; + $this->myLogger->logme('error',('Insert - ' . $dataToInsert[$a]['emp_code'] .' - '. $dataToInsert[$a]['name'])); + } + } + $emp_policy_data =[ + 'employee_id'=>$emp_id, + 'client_policy_id'=>$policy_id, + 'status'=> 'draft', + 'basic_cover_si'=> $basic_cover_si[$a] + ]; + + $employee_policy = $this->employeePolicyModel->checkExistingEmpPolicy(['employee_id' => $emp_id,'client_policy_id' => $policy_id]); + if ($employee_policy) { + foreach ($employee_policy as $existing_policy) { + $this->employeePolicyModel->update($existing_policy['id'], $emp_policy_data); + } + } else { + $emp_policy = $this->employeePolicyModel->insert($emp_policy_data); + } + //trigger + // print_r($dataToInsert[$a]['email_personal']);die; + $policy = $this->clientPolicyModel->where('id', $policy_id)->first(); + $policy_name = $this->policesModel->where('id', $policy['policy_id'])->first(); + $mail = $dataToInsert[$a]['email_personal']; + $subject = 'Welcome, Employee Benefit Program Enrolment'; + $message = 'Dear ' . $dataToInsert[$a]['name'] . ",
We are glad to welcome you to the employee benefit program ," .$policy_name['name'] ."offered by your employer,


Click on the link below to review your personal and family details:
Review Details" ; + $return_log = MailHelper::send_email($mail,$subject, $message); + + // $a = json_decode( $return_log); + + // print_r($a);die; + // $this->myLogger->logme($return_log,''); + } } + } \ No newline at end of file diff --git a/app/Helpers/MailHelper.php b/app/Helpers/MailHelper.php new file mode 100644 index 00000000..6da40441 --- /dev/null +++ b/app/Helpers/MailHelper.php @@ -0,0 +1,44 @@ +setFrom('bbone@venbait.in', 'Venkat'); + + $email->setTo($emaill); + + $email->setSubject($subject); + $email->setMessage($message); + + if ($email->send()) { + return json_encode(['status' => 'success','code' => 200, 'message'=>'Email Sent Successfully...','data' => $emaill,],200); + } else { + return json_encode(['status' => 'failed','code' => 404,'message'=>'Email Sent Failed...','data' => $emaill ],404); + } + + } catch (Exception $e) { + return json_encode(['status' => 'failed','code' => 500,'data' => $e],500); + } + } + + + function logme($message, $email) { + // Your logging logic here + // For example, writing to a log file + file_put_contents('path/to/log/file.txt', $message . "\n", FILE_APPEND); + } +} +?> \ No newline at end of file diff --git a/app/Views/client_policy.php b/app/Views/client_policy.php index a9df6485..7e7dde33 100644 --- a/app/Views/client_policy.php +++ b/app/Views/client_policy.php @@ -694,9 +694,21 @@ } function convertCommaNumberToWords(input) { - // console.log(input); - const number = parseInt(input.replace(/,/g, ''), 10); - return convertNumberToWords(number); + let number; + if (input instanceof HTMLElement) { + const inputValue = input.value; + number = parseInt(inputValue.replace(/,/g, ''), 10); + var convert_word_value = convertNumberToWords(number); + + if (input.nextElementSibling !== null) { + input.nextElementSibling.textContent = convert_word_value; + } + } else { + number = parseInt(input.replace(/,/g, ''), 10); + } + var convert_word_value = convertNumberToWords(number); + + return convert_word_value; } function onlyNumbers(event){ @@ -709,6 +721,7 @@ function formatNumber(input, maxLength) { + // console.log("input", input); maxLength=16; let value = input.value.replace(/\D/g, ''); // Remove non-numeric characters @@ -723,48 +736,49 @@ if (input.id == 'gpa_si') { gpaSumInsureMultiplier(); } + convertCommaNumberToWords(input); - if(input.id == 'basic_pay'){ - var inputNumber = input.value; - if (inputNumber) { - var result = convertCommaNumberToWords(inputNumber); - $("#gpa_basic_pay_number_word").text(result); - } else { - $("#gpa_basic_pay_number_word").text(""); - } - }else if(input.id == 'basic_gpa_si'){ - var inputNumber = input.value; - if (inputNumber) { - var result = convertCommaNumberToWords(inputNumber); - $("#basic_gpa_si_number_word").text(result); - } else { - $("#basic_gpa_si_number_word").text(""); - } - }else if(input.id == 'basic_gpa_premium'){ - var inputNumber = input.value; - if (inputNumber) { - var result = convertCommaNumberToWords(inputNumber); - $("#basic_gpa_premium_number_word").text(result); - } else { - $("#basic_gpa_premium_number_word").text(""); - } - }else if(input.id == 'gpa_si'){ - var inputNumber = input.value; - if (inputNumber) { - var result = convertCommaNumberToWords(inputNumber); - $("#gpa_sum_si_number_word").text(result); - } else { - $("#gpa_sum_si_number_word").text(""); - } - }else if(input.id == 'gpa_premium'){ - var inputNumber = input.value; - if (inputNumber) { - var result = convertCommaNumberToWords(inputNumber); - $("#gpa_sum_premium_number_word").text(result); - } else { - $("#gpa_sum_premium_number_word").text(""); - } - } + // if(input.id == 'basic_pay'){ + // var inputNumber = input.value; + // if (inputNumber) { + // var result = convertCommaNumberToWords(inputNumber); + // $("#gpa_basic_pay_number_word").text(result); + // } else { + // $("#gpa_basic_pay_number_word").text(""); + // } + // }else if(input.id == 'basic_gpa_si'){ + // var inputNumber = input.value; + // if (inputNumber) { + // var result = convertCommaNumberToWords(inputNumber); + // $("#basic_gpa_si_number_word").text(result); + // } else { + // $("#basic_gpa_si_number_word").text(""); + // } + // }else if(input.id == 'basic_gpa_premium'){ + // var inputNumber = input.value; + // if (inputNumber) { + // var result = convertCommaNumberToWords(inputNumber); + // $("#basic_gpa_premium_number_word").text(result); + // } else { + // $("#basic_gpa_premium_number_word").text(""); + // } + // }else if(input.id == 'gpa_si'){ + // var inputNumber = input.value; + // if (inputNumber) { + // var result = convertCommaNumberToWords(inputNumber); + // $("#gpa_sum_si_number_word").text(result); + // } else { + // $("#gpa_sum_si_number_word").text(""); + // } + // }else if(input.id == 'gpa_premium'){ + // var inputNumber = input.value; + // if (inputNumber) { + // var result = convertCommaNumberToWords(inputNumber); + // $("#gpa_sum_premium_number_word").text(result); + // } else { + // $("#gpa_sum_premium_number_word").text(""); + // } + // } return ; // } diff --git a/app/Views/policy_gpa_terms.php b/app/Views/policy_gpa_terms.php index eabdb8bd..a3745720 100644 --- a/app/Views/policy_gpa_terms.php +++ b/app/Views/policy_gpa_terms.php @@ -417,6 +417,10 @@ return; } + setTimeout(function() { + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + }, 1000); }, error: function(xhr, status, error) { console.error(xhr.responseText); @@ -466,7 +470,11 @@ data: {client_policy_id: client_policy_id}, success: function(res) { - console.log(res) + console.log(res); + setTimeout(function() { + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + }, 1000); $('#nameOfThePolicyInGPA').html(' - ' + res.policy_name.name); if(res.count){ @@ -533,10 +541,7 @@ $("#sumInsured2").trigger("keyup"); $("#totalSumInsured").trigger("keyup"); - setTimeout(function() { - $('.loader').fadeOut(); - $('.loader-mask').delay(350).fadeOut('slow'); - }, 1000); + }, error: function(xhr, status, error) { diff --git a/app/Views/policy_grid.php b/app/Views/policy_grid.php index 0734c5e4..4d95a66c 100644 --- a/app/Views/policy_grid.php +++ b/app/Views/policy_grid.php @@ -92,17 +92,17 @@
- +
- +
- +
@@ -132,12 +132,12 @@
- +
- +
@@ -155,12 +155,12 @@
- +
- +
`; @@ -176,12 +176,12 @@
- +
- +
@@ -196,26 +196,25 @@ for (var i = 1; i <= 11; i++) { $('#grid_' + i).remove(); } - grid_html = `
-
+
- +
- +
- +
- +
@@ -236,20 +235,20 @@
- +
- +
- +
- +
@@ -267,30 +266,30 @@ grid_html = `
-
+ +
- +
-
-
-
+
+
- +
-
+
- +
- +
-
+
`; } else if(dataIdValue == '7'){ @@ -304,20 +303,20 @@
- +
- +
- +
- +
@@ -339,16 +338,16 @@
- +
- +
- +
@@ -368,16 +367,16 @@
- +
- +
- +
@@ -397,20 +396,20 @@
- +
- +
- +
- +
@@ -430,21 +429,21 @@
- +
- +
- +
- +
@@ -467,6 +466,14 @@ grid_container.insertAdjacentHTML('beforeend', grid_html); + + if(dataIdValue == '1'){ + $('#gpa_sum_si').trigger('keyup'); + // $('input[name="gpa_sum_si[]"]').each(function() { + // console.log($(this)); + // $(this).trigger('keyup'); + // }); + } $('#gpa_sum_insured').hide(); $('#btnGridSubmit').show(); @@ -474,13 +481,6 @@ setTimeout(() => { $('#si_or_bp').trigger('change'); }, 300); - - - - - - - }; @@ -575,7 +575,16 @@ data: { client_policy_id: client_policy_id}, dataType: 'json', success: function (res) { + setTimeout(function() { + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + }, 1000); console.log('res',res); + var temp_for_premiumData = JSON.parse(res.premiumData); + + res.premiumData= JSON.parse(res.premiumData); + + $('#nameOfThePolicy').html(' - ' + res.policy_name); $('#grid_emp_count').val(res.count); @@ -606,7 +615,6 @@ addGridHTML(false, res.premiumData[0], res.premiumData[0].policy_grid_id, si_or_bp_value); - res.premiumData.shift(); $.each(res.premiumData, function(index, item){ if (item.si_or_bp == '1') { @@ -623,33 +631,29 @@ $('#bs-example-modal-lg').modal('show'); - // $("#gpa_si").trigger("keyup"); - // $("#basic_gpa_premium").trigger("keyup"); - - // $("#sum_insured").trigger("keyup"); - // $("#premium").trigger("keyup"); - + $("#gpa_si").trigger("keyup"); + $("#gpa_premium").trigger("keyup"); $('#basic_pay').trigger('keyup'); + $('#4_si').trigger('keyup'); - $('input[name="si[]"]').each(function() { + $('input[name="gpa_sum_si[]"]').each(function() { $(this).trigger('keyup'); }); - - - $('input[name="premium[]"]').each(function() { + $('input[name="gpa_sum_premium[]"]').each(function() { $(this).trigger('keyup'); }); - // $("input[name='si[]']").trigger("keyup"); - // $("input[name='premium[]']").trigger("keyup") - - setTimeout(function() { - $('.loader').fadeOut(); - $('.loader-mask').delay(350).fadeOut('slow'); - }, 1000);si - + var id_for_trigger =temp_for_premiumData[0].policy_grid_id; + $(`input[name="${id_for_trigger}_si[]"]`).each(function() { + console.log($(this)); + $(this).trigger('keyup'); + }); + $(`input[name="${id_for_trigger}_premium[]"]`).each(function() { + console.log($(this)); + $(this).trigger('keyup'); + }); }, error: function (xhr, status, error) { console.error(xhr.responseText); @@ -762,12 +766,12 @@ html = `
- +
- +
@@ -787,12 +791,12 @@
- +
- +
@@ -809,15 +813,15 @@
- +
- +
- +
@@ -833,20 +837,20 @@
- +
- +
- +
- +
@@ -859,29 +863,28 @@ html =`
-
+ +
- +
-
-
-
- - -
-
- - -
-
- - -
-
-
- - -
+
+
+ + +
+
+ + +
+
+ + +
+
+
+ +
`; @@ -891,20 +894,20 @@
- +
- +
- +
- +
@@ -919,16 +922,16 @@
- +
- +
- +
@@ -943,16 +946,16 @@
- +
- +
- +
@@ -967,20 +970,20 @@
- +
- +
- +
- +
@@ -995,21 +998,21 @@
- +
- +
- +
- +
@@ -1072,8 +1075,8 @@ function checkDuplicate() { if ($('#grid')[0].value === '3') { - var siInputs = $('input[name="si[]"]'); - var premiumInputs = $('input[name="premium[]"]'); + var siInputs = $('input[name="3_si[]"]'); + var premiumInputs = $('input[name="3_premium[]"]'); var siValues = []; var premiumValues = []; @@ -1105,8 +1108,8 @@ } }else if($('#grid')[0].value === '4'){ - var ageFrom = $('input[name="age_from[]"]'); - var ageTo = $('input[name="age_to[]"]'); + var ageFrom = $('input[name="4_age_from[]"]'); + var ageTo = $('input[name="4_age_to[]"]'); var ageFromValues = []; var ageToValues = []; @@ -1138,9 +1141,9 @@ } }else if ($('#grid')[0].value === '5') { - var si = $('input[name="si[]"]'); - var ageFrom = $('input[name="age_from[]"]'); - var ageTo = $('input[name="age_to[]"]'); + var si = $('input[name="5_si[]"]'); + var ageFrom = $('input[name="5_age_from[]"]'); + var ageTo = $('input[name="5_age_to[]"]'); var si_array = []; var ageFrom_array = []; @@ -1175,8 +1178,8 @@ return false; } }else if($('#grid')[0].value === '6'){ - var ageFrom = $('input[name="age_from[]"]'); - var ageTo = $('input[name="age_to[]"]'); + var ageFrom = $('input[name="6_age_from[]"]'); + var ageTo = $('input[name="6_age_to[]"]'); var ageFromValues = []; var ageToValues = []; @@ -1207,9 +1210,9 @@ return false; } }else if($('#grid')[0].value === '7'){ - var si = $('input[name="si[]"]'); - var ageFrom = $('input[name="age_from[]"]'); - var ageTo = $('input[name="age_to[]"]'); + var si = $('input[name="7_si[]"]'); + var ageFrom = $('input[name="7_age_from[]"]'); + var ageTo = $('input[name="7_age_to[]"]'); var si_array = []; var ageFrom_array = []; @@ -1244,9 +1247,9 @@ return false; } }else if($('#grid')[0].value === '10'){ - var si = $('input[name="si[]"]'); - var ageFrom = $('input[name="age_from[]"]'); - var ageTo = $('input[name="age_to[]"]'); + var si = $('input[name="10_si[]"]'); + var ageFrom = $('input[name="10_age_from[]"]'); + var ageTo = $('input[name="10_age_to[]"]'); var si_array = []; var ageFrom_array = []; @@ -1282,8 +1285,8 @@ return false; } }else if($('#grid')[0].value === '8'){ - var siInputs = $('input[name="si[]"]'); - var gradeInputs = $('input[name="grade[]"]'); + var siInputs = $('input[name="8_si[]"]'); + var gradeInputs = $('input[name="8_grade[]"]'); var siValues = []; var gradeValues = []; @@ -1314,8 +1317,8 @@ return false; } }else if($('#grid')[0].value === '9'){ - var siInputs = $('input[name="si[]"]'); - var gradeInputs = $('input[name="grade[]"]'); + var siInputs = $('input[name="9_si[]"]'); + var gradeInputs = $('input[name="9_grade[]"]'); var siValues = []; var gradeValues = []; @@ -1346,9 +1349,9 @@ return false; } }else if ($('#grid')[0].value === '11') { - var siInputs = $('input[name="si[]"]'); - var gradeInputs = $('input[name="grade[]"]'); - var maxSiInputs = $('input[name="max_si[]"]'); + var siInputs = $('input[name="11_si[]"]'); + var gradeInputs = $('input[name="11_grade[]"]'); + var maxSiInputs = $('input[name="11_max_si[]"]'); var siValues = []; var gradeValues = []; @@ -1393,47 +1396,46 @@ { var multi = $('#basic_multiplier')[0].value.replace(/,/g, '') * input.value.replace(/,/g, ''); - $('#basic_gpa_si').val(multi).trigger('keyup'); + $('#gpa_basic_si').val(multi).trigger('keyup'); - var multi_2 = $('#basic_gpa_si')[0].value.replace(/,/g, '') * $('#premium_multiplier')[0].value.replace(/,/g, ''); + var multi_2 = $('#gpa_basic_si')[0].value.replace(/,/g, '') * $('#premium_multiplier')[0].value.replace(/,/g, ''); - $('#basic_gpa_premium').val(multi_2).trigger('keyup'); + $('#gpa_basic_premium').val(multi_2).trigger('keyup'); }else if(input.id == 'basic_multiplier') { var multi =input.value * $('#basic_pay')[0].value.replace(/,/g, ''); - $('#basic_gpa_si').val(multi).trigger('keyup'); + $('#gpa_basic_si').val(multi).trigger('keyup'); - var multi_2 = $('#basic_gpa_si')[0].value.replace(/,/g, '') * $('#premium_multiplier')[0].value.replace(/,/g, ''); + var multi_2 = $('#gpa_basic_si')[0].value.replace(/,/g, '') * $('#premium_multiplier')[0].value.replace(/,/g, ''); - $('#basic_gpa_premium').val(multi_2).trigger('keyup'); + $('#gpa_basic_premium').val(multi_2).trigger('keyup'); }else if(input.id == 'premium_multiplier') { - var multi = input.value.replace(/,/g, '') * $('#basic_gpa_si')[0].value.replace(/,/g, ''); + var multi = input.value.replace(/,/g, '') * $('#gpa_basic_si')[0].value.replace(/,/g, ''); - $('#basic_gpa_premium').val(multi).trigger('keyup'); - }else if(input.id == 'basic_gpa_si') + $('#gpa_basic_premium').val(multi).trigger('keyup'); + }else if(input.id == 'gpa_basic_si') { var multi = input.value.replace(/,/g, '') * $('#premium_multiplier')[0].value.replace(/,/g, ''); - $('#basic_gpa_premium').val(multi).trigger('keyup'); + $('#gpa_basic_premium').val(multi).trigger('keyup'); } } function gpaSumInsureMultiplier() { - - var element = $('#multiplier')[0]; - var sumInsured = $('input[name="si[]"]'); + var element = $('#gpa_sum_multiplier')[0]; + var sumInsured = $('input[name="gpa_sum_si[]"]'); if ($('#si_or_bp').val() == 2) { var premium = $('input[name="premium[]"]'); } else { - var premium = $('input[name="sum_premium[]"]'); + var premium = $('input[name="gpa_sum_premium[]"]'); } sumInsured.each(function(index) { @@ -1460,15 +1462,15 @@ $('#si_or_bp_sum_insure').css({'display':'none'}); $('#si_or_bp_basic_pay').css({'display':''}); - $('#multiplier').removeAttr('required'); - $('#gpa_si').removeAttr('required'); - $('#gpa_premium').removeAttr('required'); + $('#gpa_sum_multiplier').removeAttr('required'); + $('#gpa_sum_si').removeAttr('required'); + $('#gpa_sum_premium').removeAttr('required'); $('#basic_multiplier').attr('required', true); $('#premium_multiplier').attr('required', true); $('#basic_pay').attr('required', true); - $('#basic_gpa_si').attr('required', true); - $('#basic_gpa_premium').attr('required', true); + $('#gpa_basic_si').attr('required', true); + $('#gpa_basic_premium').attr('required', true); var gridContentInput = $('#grid_content_input'); @@ -1487,13 +1489,13 @@ $('#basic_multiplier').removeAttr('required'); $('#premium_multiplier').removeAttr('required'); $('#basic_pay').removeAttr('required'); - $('#basic_gpa_si').removeAttr('required'); - $('#basic_gpa_premium').removeAttr('required'); + $('#gpa_basic_si').removeAttr('required'); + $('#gpa_basic_premium').removeAttr('required'); - $('#multiplier').attr('required', true); - $('#gpa_si').attr('required', true); - $('#gpa_premium').attr('required', true); + $('#gpa_sum_multiplier').attr('required', true); + $('#gpa_sum_si').attr('required', true); + $('#gpa_sum_premium').attr('required', true); var gridContentInput = $('#grid_content_input'); @@ -1510,52 +1512,4 @@ } - - - // $("#gpa_si").on("keyup", function() { - // var inputNumber = $(this).val(); - // if (inputNumber) { - // var result = convertCommaNumberToWords(inputNumber); - // $("#gpa_si_number_word").text(result); - // } else { - // $("#gpa_si_number_word").text(""); - // } - - - // }); - - // $("#basic_gpa_premium").on("keyup", function() { - // var inputNumber = $(this).val(); - // if (inputNumber) { - // var result = convertCommaNumberToWords(inputNumber); - // $("#gpa_premium_number_word").text(result); - // } else { - // $("#gpa_premium_number_word").text(""); - // } - // }); - - - // $("#sum_insured").on("keyup", function() { - // var inputNumber = $(this).val(); - // if (inputNumber) { - // var result = convertCommaNumberToWords(inputNumber); - // $("#sum_insured_number_word").text(result); - // } else { - // $("#sum_insured_number_word").text(""); - // } - // }); - - - // $("#premium").on("keyup", function() { - // var inputNumber = $(this).val(); - // if (inputNumber) { - // var result = convertCommaNumberToWords(inputNumber); - // $("#premium_number_word").text(result); - // } else { - // $("#premium_number_word").text(""); - // } - // }); - - - \ No newline at end of file diff --git a/composer.json b/composer.json index d49707b4..12d029a0 100644 --- a/composer.json +++ b/composer.json @@ -17,6 +17,7 @@ "firebase/php-jwt": "^6.10", "google/apiclient": "^2.15.0", "laminas/laminas-escaper": "^2.9", + "phpmailer/phpmailer": "^6.9", "phpoffice/phpspreadsheet": "^2.0", "psr/log": "^1.1", "slim/slim": "^4.13" From d43e2ca101b31f64440cfb09ff9cf8055ee945a4 Mon Sep 17 00:00:00 2001 From: bitbucket Date: Mon, 18 Mar 2024 19:45:05 +0530 Subject: [PATCH 08/18] GWM --- app/Config/Routes.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 2c879a72..74688631 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -212,11 +212,12 @@ $routes->get("/getEmployeeProfile", "EmployeeRestController::getEmployeeProfile/ $routes->post("/editEmployeeProfile", "EmployeeRestController::editEmployeeProfile"); -$routes->post("/employeeUpload", "EmployeeRestController::employeeUpload"); -$routes->get("getEmployeeAndDependence", "EmployeeRestController::getEmployeeAndDependence"); + + $routes->group("employeeRest", ["filter" => "authJWT"], function($routes){ + $routes->post("employeeUpload", "EmployeeRestController::employeeUpload"); $routes->get("relationshipList", "EmployeeRestController::relationshipList"); $routes->get("getEmployeeAndDependence", "EmployeeRestController::getEmployeeAndDependence"); $routes->post("editEmployeeAndDependence", "EmployeeRestController::editEmployeeAndDependence"); From 62eec1f44c3caf44bae0c82425a45d4f5758b501 Mon Sep 17 00:00:00 2001 From: bitbucket Date: Mon, 18 Mar 2024 20:09:46 +0530 Subject: [PATCH 09/18] GWM:CHANGE-IN-REST-API --- app/Config/Routes.php | 1 + app/Controllers/EmployeeRestController.php | 24 +++++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 74688631..45cf2568 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -227,6 +227,7 @@ $routes->group("employeeRest", ["filter" => "authJWT"], function($routes){ $routes->post("createOrUpdateEmployeePolicySiAmount", "EmployeeRestController::createOrUpdateEmployeePolicySiAmount"); $routes->get("deleteDependence", "EmployeeRestController::deleteDependence"); $routes->get("getEmployeeAndDependenceByClientId", "EmployeeRestController::getEmployeeAndDependenceByClientId"); + $routes->get("getClientPolicy", "EmployeeRestController::getClientPolicy"); }); $routes->post("sendEmail", "EmployeeRestController::send_email"); diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 0f9e82f1..44a17c02 100644 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -52,7 +52,7 @@ class EmployeeRestController extends AdminController $this->policesModel = new PolicesModel(); $this->relationshipModel = new RelationshipModel(); $this->fileModel= new FileModel(); - $this->clientPolicyModel= new ClientPolicyModel(); + $this->clientPolicyModel = new ClientPolicyModel(); } @@ -245,6 +245,28 @@ class EmployeeRestController extends AdminController } + public function getClientPolicy() + { + try { + $ClientPolicyData = $this->clientPolicyModel->select('client_policy.id as client_policy_id , client_policy.client_id as client_id,, policies.id as policy_id, policies.name as policy_name') + ->join('policies', 'client_policy.policy_id = policies.id', 'left') + ->where('client_policy.client_id', $this->request->getGet('client_id') ) + ->findAll(); + + // You probably meant to check $result, not $data + if ($ClientPolicyData) { + return $this->respond(['status' => 'success', 'code' => 200, 'data' => $ClientPolicyData], 200); + } else { + return $this->respond(['status' => 'failed', 'code' => 404, 'data' => []], 404); + } + + + } catch (\Exception $e) { + return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500); + } + + } + public function getEmployeePolicy() { From f99c0ca5e2a14f25594990780f21a74077ecc953 Mon Sep 17 00:00:00 2001 From: bitbucket Date: Tue, 19 Mar 2024 11:39:08 +0530 Subject: [PATCH 10/18] CHANGES-in-restApi:GWM --- app/Config/Routes.php | 2 +- app/Controllers/EmployeeRestController.php | 35 +++++++++---------- .../RestAuthenticationController.php | 2 +- 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 45cf2568..cce60574 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -213,7 +213,7 @@ $routes->post("/editEmployeeProfile", "EmployeeRestController::editEmployeeProfi - +$routes->get("getClientPolicy", "EmployeeRestController::getClientPolicy"); $routes->group("employeeRest", ["filter" => "authJWT"], function($routes){ diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 44a17c02..139d39cd 100644 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -211,29 +211,28 @@ class EmployeeRestController extends AdminController public function getEmployeeAndDependenceByClientId() { try { - $empData = $this->employeeModel - ->where('client_id', $this->request->getGet('client_id')) - ->where('relationship', 'self') - ->orderBy('id') - ->findAll(); + + $empData = $this->employeeModel->where('client_id', $this->request->getGet('client_id')) + ->where('relationship !=', null) + ->orderBy('emp_code')->orderBy('id')->findAll(); - $result = []; + // $result = []; - foreach ($empData as $employee) { - $employeeDependence = $this->employeeModel - ->where('emp_code', $employee['emp_code']) - ->where('relationship !=', 'self') - ->findAll(); + // foreach ($empData as $employee) { + // $employeeDependence = $this->employeeModel + // ->where('emp_code', $employee['emp_code']) + // ->where('relationship !=', 'self') + // ->findAll(); - // Use object notation to access properties and set 'dependence' - $employee['dependence'] = $employeeDependence ?: []; + // // Use object notation to access properties and set 'dependence' + // $employee['dependence'] = $employeeDependence ?: []; - $result[] = $employee; - } + // $result[] = $employee; + // } // You probably meant to check $result, not $data - if ($result) { - return $this->respond(['status' => 'success', 'code' => 200, 'data' => $result], 200); + if ($empData) { + return $this->respond(['status' => 'success', 'code' => 200, 'data' => $empData], 200); } else { return $this->respond(['status' => 'failed', 'code' => 404, 'data' => []], 404); } @@ -248,7 +247,7 @@ class EmployeeRestController extends AdminController public function getClientPolicy() { try { - $ClientPolicyData = $this->clientPolicyModel->select('client_policy.id as client_policy_id , client_policy.client_id as client_id,, policies.id as policy_id, policies.name as policy_name') + $ClientPolicyData = $this->clientPolicyModel->select('client_policy.id as client_policy_id , client_policy.client_id as client_id, policies.id as policy_id,policies.policy_type_id as policy_type_id, policies.name as policy_name') ->join('policies', 'client_policy.policy_id = policies.id', 'left') ->where('client_policy.client_id', $this->request->getGet('client_id') ) ->findAll(); diff --git a/app/Controllers/RestAuthenticationController.php b/app/Controllers/RestAuthenticationController.php index 721e71a9..d3a3c111 100644 --- a/app/Controllers/RestAuthenticationController.php +++ b/app/Controllers/RestAuthenticationController.php @@ -176,7 +176,7 @@ class RestAuthenticationController extends AdminController ->where('level_contacts.mobile', $mobile_number ) ->find(); - $result = JWTToken::encode($hrData); + $result = JWTToken::encode($hrData['0']); return $this->respond(['status' => 'success','code' => 200,'data' => $result],200); } else { return $this->respond(['status' => 'failed','code' => 404,'data' => "No data"],404); From 5dfaba9c28c3f05e1d579d1b720b9cfc0ba424b8 Mon Sep 17 00:00:00 2001 From: aadhavan valli Date: Tue, 19 Mar 2024 11:39:18 +0530 Subject: [PATCH 11/18] CHANGE_EMPLOYEE_REST_CONTROLLER_FILE_UPLOAD_LOG : AADHAVAN --- app/Config/Email.php | 12 +++++++++++- app/Controllers/EmployeeRestController.php | 7 ++----- app/Helpers/MailHelper.php | 2 +- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/app/Config/Email.php b/app/Config/Email.php index b6ac8865..f7e3ae01 100644 --- a/app/Config/Email.php +++ b/app/Config/Email.php @@ -48,7 +48,7 @@ class Email extends BaseConfig /** * SMTP Timeout (in seconds) */ - public int $SMTPTimeout = 5; + public int $SMTPTimeout = 1000; /** * Enable persistent SMTP connections @@ -118,4 +118,14 @@ class Email extends BaseConfig * Enable notify message from server */ public bool $DSN = false; + + + + /** + * SMTP Debugging level. Set to 0 to disable debugging. + * Set to 1 to output server connection status only. + * Set to 2 for more detailed debugging output. + * Set to 3 for maximum debugging output. + */ + public int $SMTPDebug = 2; } diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 0f9e82f1..60823e71 100644 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -512,12 +512,9 @@ class EmployeeRestController extends AdminController $subject = 'Welcome, Employee Benefit Program Enrolment'; $message = 'Dear ' . $dataToInsert[$a]['name'] . ",
We are glad to welcome you to the employee benefit program ," .$policy_name['name'] ."offered by your employer,


Click on the link below to review your personal and family details:
Review Details" ; $return_log = MailHelper::send_email($mail,$subject, $message); - - // $a = json_decode( $return_log); - - // print_r($a);die; - // $this->myLogger->logme($return_log,''); + $return_log = json_decode($return_log); + $this->myLogger->logme('info', "Email Status : {mail_status}, Sender Email:{email}", ['mail_status' => $return_log->status, 'email'=> $return_log->data]); } } diff --git a/app/Helpers/MailHelper.php b/app/Helpers/MailHelper.php index 6da40441..fd56e4f5 100644 --- a/app/Helpers/MailHelper.php +++ b/app/Helpers/MailHelper.php @@ -30,7 +30,7 @@ class MailHelper } } catch (Exception $e) { - return json_encode(['status' => 'failed','code' => 500,'data' => $e],500); + return json_encode(['status' => 'failed','code' => 500,'data' => $emaill],500); } } From 39374c0b4b9f90bc76c02cf57ffc2dfe4d6c3a09 Mon Sep 17 00:00:00 2001 From: bitbucket Date: Tue, 19 Mar 2024 19:57:20 +0530 Subject: [PATCH 12/18] CHANGES-IN-GETPOLICYAPI:GWM --- app/Config/Routes.php | 2 +- app/Controllers/EmployeeRestController.php | 70 ++++++++++++------- .../RestAuthenticationController.php | 3 +- 3 files changed, 46 insertions(+), 29 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index cce60574..45cf2568 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -213,7 +213,7 @@ $routes->post("/editEmployeeProfile", "EmployeeRestController::editEmployeeProfi -$routes->get("getClientPolicy", "EmployeeRestController::getClientPolicy"); + $routes->group("employeeRest", ["filter" => "authJWT"], function($routes){ diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 36eddb23..1d9d8088 100644 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -193,6 +193,8 @@ class EmployeeRestController extends AdminController public function deleteDependence() { try { + if($this->request->getGet('id')) + { $delete = $this->employeeModel->where('id', $this->request->getGet('id'))->delete(); if ($delete) { @@ -200,6 +202,10 @@ class EmployeeRestController extends AdminController } else { return $this->respond(['status' => 'failed','code' => 404,'data' => [] ], 404); } + }else{ + return $this->respond(['status' => 'failed','code' => 404,'data' => [] ], 404); + } + } catch (\Exception $e) { return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500); @@ -211,31 +217,15 @@ class EmployeeRestController extends AdminController public function getEmployeeAndDependenceByClientId() { try { - - $empData = $this->employeeModel->where('client_id', $this->request->getGet('client_id')) - ->where('relationship !=', null) - ->orderBy('emp_code')->orderBy('id')->findAll(); - - // $result = []; - - // foreach ($empData as $employee) { - // $employeeDependence = $this->employeeModel - // ->where('emp_code', $employee['emp_code']) - // ->where('relationship !=', 'self') - // ->findAll(); - - // // Use object notation to access properties and set 'dependence' - // $employee['dependence'] = $employeeDependence ?: []; - - // $result[] = $employee; - // } - - // You probably meant to check $result, not $data - if ($empData) { - return $this->respond(['status' => 'success', 'code' => 200, 'data' => $empData], 200); - } else { - return $this->respond(['status' => 'failed', 'code' => 404, 'data' => []], 404); - } + $empData = $this->employeePolicyModel->getEmployeePolicy( $this->request->getGet('client_id'), $this->request->getGet('client_policy_id')); + // $empData = $this->employeeModel->where('client_id', $this->request->getGet('client_id')) + // ->where('relationship !=', null) + + if ($empData) { + return $this->respond(['status' => 'success', 'code' => 200, 'data' => $empData], 200); + } else { + return $this->respond(['status' => 'failed', 'code' => 404, 'data' => []], 404); + } } catch (\Exception $e) { @@ -251,10 +241,12 @@ class EmployeeRestController extends AdminController ->join('policies', 'client_policy.policy_id = policies.id', 'left') ->where('client_policy.client_id', $this->request->getGet('client_id') ) ->findAll(); - + + $result[] = $ClientPolicyData[0]; + $result[] = $ClientPolicyData[2]; // You probably meant to check $result, not $data if ($ClientPolicyData) { - return $this->respond(['status' => 'success', 'code' => 200, 'data' => $ClientPolicyData], 200); + return $this->respond(['status' => 'success', 'code' => 200, 'data' => $result], 200); } else { return $this->respond(['status' => 'failed', 'code' => 404, 'data' => []], 404); } @@ -271,9 +263,12 @@ class EmployeeRestController extends AdminController { try { $id = $this->request->getGet('id'); + $emp_code = $this->request->getGet('emp_code'); + $keysToRemove = ["removable_keys"]; $empPolicy = $this->employeeModel->getEmployeePolicy($id); + $empData = $this->employeeModel->where('emp_code',$emp_code)->findAll(); // dd($empPolicy); if ($empPolicy) { @@ -320,6 +315,27 @@ class EmployeeRestController extends AdminController array_splice($array->SlabRates, $index, 1); array_unshift($array->SlabRates, $element); } + + //map family floates array to employee and dependent + $familyFloates = $array->Policy_Terms->family_floaters; + $data = []; + foreach ($familyFloates as $familyFloatesValue) { + $dependent = preg_replace('/\d/', '', $familyFloatesValue); + if(count($empData)){ + foreach ($empData as $key => $value) { + if ($value['family_floater_key'] === $dependent) { + $temp['family_floater_key'] = $familyFloatesValue; + $temp['label'] = $value['relationship']; + $temp['name'] = $value['name']; + array_push($data,$temp); + unset($empData[$key]); + break; + } + } + } + } + $array->mapped_family_floaters = $data; + } $result[] = $array; diff --git a/app/Controllers/RestAuthenticationController.php b/app/Controllers/RestAuthenticationController.php index d3a3c111..61ef2ff6 100644 --- a/app/Controllers/RestAuthenticationController.php +++ b/app/Controllers/RestAuthenticationController.php @@ -70,6 +70,7 @@ class RestAuthenticationController extends AdminController try { $mobile_number = $this->request->getJSON()->mobile_number; $randomNumber = rand(100000, 999999); + $randomNumber = 123456; $employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first(); @@ -129,7 +130,7 @@ class RestAuthenticationController extends AdminController try { $mobile_number = $this->request->getJSON()->mobile_number; $randomNumber = rand(100000, 999999); - + $randomNumber = 123456; $HrData = $this->hrModel->where('mobile', $mobile_number)->where('contact_type', 'client')->first(); if ($HrData) { From 2f96dd8d472d632ad6763c171237b9e5ce98af23 Mon Sep 17 00:00:00 2001 From: aadhavan valli Date: Tue, 19 Mar 2024 20:08:34 +0530 Subject: [PATCH 13/18] MODEL_FILE : AADHAVAN --- app/Models/EmployeeModel.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Models/EmployeeModel.php b/app/Models/EmployeeModel.php index 52382dc1..41c42a52 100644 --- a/app/Models/EmployeeModel.php +++ b/app/Models/EmployeeModel.php @@ -24,6 +24,7 @@ class EmployeeModel extends Model "gender", "dob", "otp", + "family_floater_key", "emp_status", "created_by", "updated_by", From bcb83b85bf1367401bab8933132c0c11090783d1 Mon Sep 17 00:00:00 2001 From: bitbucket Date: Tue, 19 Mar 2024 21:45:04 +0530 Subject: [PATCH 14/18] GWM:CHANGES-IN-EMP-POLICY-API --- app/Controllers/EmployeeModel.php | 57 ++++++++++++++++++++++ app/Controllers/EmployeeRestController.php | 14 ++++++ 2 files changed, 71 insertions(+) create mode 100644 app/Controllers/EmployeeModel.php diff --git a/app/Controllers/EmployeeModel.php b/app/Controllers/EmployeeModel.php new file mode 100644 index 00000000..52382dc1 --- /dev/null +++ b/app/Controllers/EmployeeModel.php @@ -0,0 +1,57 @@ +db->table('employee_polices') + ->select(' policies.name as Policy_Name , client_policy.policy_terms as Policy_Terms, client_policy.client_id as ClientId, client_policy.policy_id as PolicyId,client_policy.id as ClientPolicyId, client_policy.open_for_enrollment as OpenForEnrollment') // Select all columns from both tables + ->join('client_policy', 'client_policy.id = employee_polices.client_policy_id') + ->join('policies', 'policies.id = client_policy.policy_id') + ->where('employee_polices.employee_id', $id) + ->get() + ->getResult(); + } + + + + + // for EMP rest API process do not change + public function checkExistingEmpEntrollment($arr) + { + return $this->where('emp_code',$arr['emp_code'])->where('name',$arr['name'])->first(); + } + +} diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 1d9d8088..cdeca663 100644 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -161,12 +161,14 @@ class EmployeeRestController extends AdminController if (isset($item->id)) { //update old data $id = $item->id; + $item->family_floater_key = $this->RelationshipMap($item->relationship); $employee = $this->employeeModel->update($id, (array)$item); if ($employee) { $Count++; } }else{ //create new data + $item->family_floater_key = $this->RelationshipMap($item->relationship); $employee = $this->employeeModel->insert($item); if ($employee) { $Count++; @@ -190,6 +192,18 @@ class EmployeeRestController extends AdminController } + public function RelationshipMap($value){ + + if ($value === 'Mother' || $value === 'Father') { + return 'parent'; + } else if($value === 'Son' || $value === 'Daughter'){ + return 'child'; + }else if($value === 'Father in Law' || $value === 'Mother in Law'){ + return 'parent_in_law'; + }else if($value === 'Spouse'){ + return 'spouse'; + } + } public function deleteDependence() { try { From 32ba40df89a407b504a69a1eb74243ca1544fb3e Mon Sep 17 00:00:00 2001 From: bitbucket Date: Tue, 19 Mar 2024 23:48:21 +0530 Subject: [PATCH 15/18] CHANGES-INDATE-CONVERTION:GWM --- app/Controllers/EmployeeRestController.php | 44 ++++++++++++++++++---- 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index cdeca663..4c543e4a 100644 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -105,14 +105,20 @@ class EmployeeRestController extends AdminController try { $emp_code = $this->request->getGet('emp_code'); if ($emp_code) { - $employee = $this->employeeModel->where('emp_code', $emp_code) - ->findAll(); - - $result = $employee; - return $this->respond(['status' => 'success','code' => 200,'data' => $result],200); + $employee = $this->employeeModel->where('emp_code', $emp_code)->findAll(); + $dateConverter = function($item) { + if ($item['dob'] !== '0000-00-00') { + $dateTime = \DateTime::createFromFormat('Y-m-d', $item['dob']); + $item['dob'] = $dateTime->format('d-m-Y'); + } + return $item; + }; + $employee = array_map($dateConverter, $employee); + return $this->respond(['status' => 'success','code' => 200,'data' => $employee],200); + } else { - $result = "No Match's"; - return $this->respond(['status' => 'failed','code' => 404,'data' => $result],404); + + return $this->respond(['status' => 'failed','code' => 404,'data' => []],404); } } catch (\Throwable $th) { return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500); @@ -129,6 +135,7 @@ class EmployeeRestController extends AdminController $updatedCount = 0; foreach ($data as $item) { $id = $item->id; + $item->dob = $this->convertDateFormat($item->dob); $employee = $this->employeeModel->update($id, (array)$item); if ($employee) { $updatedCount++; @@ -162,6 +169,7 @@ class EmployeeRestController extends AdminController //update old data $id = $item->id; $item->family_floater_key = $this->RelationshipMap($item->relationship); + $item->dob = $this->convertDateFormat($item->dob); $employee = $this->employeeModel->update($id, (array)$item); if ($employee) { $Count++; @@ -169,6 +177,7 @@ class EmployeeRestController extends AdminController }else{ //create new data $item->family_floater_key = $this->RelationshipMap($item->relationship); + $item->dob = $this->convertDateFormat($item->dob); $employee = $this->employeeModel->insert($item); if ($employee) { $Count++; @@ -204,6 +213,21 @@ class EmployeeRestController extends AdminController return 'spouse'; } } + + private function convertDateFormat($dateString) + { + // Attempt to create a DateTime object from the provided date string + $dateTime = \DateTime::createFromFormat('d-m-Y', $dateString); + + // Check if the conversion was successful and the date string is in the format dd-mm-yyyy + if ($dateTime instanceof \DateTime) { + // Format the date to yyyy-mm-dd + return $dateTime->format('Y-m-d'); + } else { + // If the date string is not in the format dd-mm-yyyy, return null + return null; + } + } public function deleteDependence() { try { @@ -283,7 +307,6 @@ class EmployeeRestController extends AdminController $empPolicy = $this->employeeModel->getEmployeePolicy($id); $empData = $this->employeeModel->where('emp_code',$emp_code)->findAll(); - // dd($empPolicy); if ($empPolicy) { $result = []; @@ -338,9 +361,14 @@ class EmployeeRestController extends AdminController if(count($empData)){ foreach ($empData as $key => $value) { if ($value['family_floater_key'] === $dependent) { + $employee_policy = $this->employeePolicyModel->where('employee_id',$value['id'])->where('client_policy_id',$array->ClientPolicyId)->get()->getRow(); $temp['family_floater_key'] = $familyFloatesValue; $temp['label'] = $value['relationship']; $temp['name'] = $value['name']; + $temp['employee_id'] = $value['id']; + $temp['basic_cover_si'] = isset($employee_policy->basic_cover_si) ? $employee_policy->basic_cover_si : null; + $temp['client_policy_id'] = $array->ClientPolicyId; + array_push($data,$temp); unset($empData[$key]); break; From e09b7199b8cd5b32804ec24d3a6a0df7e5765b29 Mon Sep 17 00:00:00 2001 From: aadhavan valli Date: Tue, 19 Mar 2024 23:51:24 +0530 Subject: [PATCH 16/18] CHANGE_EMPLOYEE_REST_FILE_UPLOAD_MAIL : AADHAVAN --- app/Config/Filters.php | 2 +- app/Config/Routes.php | 6 +- app/Controllers/EmployeeRestController.php | 143 +++++++++++++++------ app/Controllers/Home.php | 2 +- app/Controllers/JobWorker.php | 38 +++++- app/Helpers/MailHelper.php | 15 +-- app/Models/EmployeeModel.php | 1 + app/Views/mail_welcome.php | 23 ++++ composer.json | 1 + public/assets/images/Nhance-Logo-Final.png | Bin 0 -> 4069 bytes 10 files changed, 173 insertions(+), 58 deletions(-) create mode 100644 app/Views/mail_welcome.php create mode 100644 public/assets/images/Nhance-Logo-Final.png diff --git a/app/Config/Filters.php b/app/Config/Filters.php index 4f16d072..40324597 100644 --- a/app/Config/Filters.php +++ b/app/Config/Filters.php @@ -44,7 +44,7 @@ class Filters extends BaseConfig */ public array $globals = [ 'before' => [ - 'HttpRequestLog' => ['except' => 'processjob'], + 'HttpRequestLog' => ['except' => 'cli/*'], // 'csrf', // 'invalidchars', ], diff --git a/app/Config/Routes.php b/app/Config/Routes.php index cce60574..ed5af8ac 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -6,7 +6,7 @@ use CodeIgniter\Router\RouteCollection; * @var RouteCollection $routes */ // $routes->get('/', 'LoginController::index'); -$routes->get('/test', 'Home::test'); +$routes->get('/test', 'Home::index'); $routes->get('/login', 'LoginController::index');///auth/google $routes->get('/logout', 'LoginController::logout'); $routes->get('/oauth2callback', 'LoginController::receiveGoogleOAuthResponse'); @@ -191,7 +191,8 @@ $routes->group("/util", ["filter" => "authMVC"], function($routes){ $routes->post("import-export", "EmployeeController::importExport"); }); -$routes->cli('processjob', 'JobWorker::processJob'); +$routes->cli('cli/processjob', 'JobWorker::processJob'); +$routes->cli('cli/processjobs', 'JobWorker::processJobs'); @@ -215,6 +216,7 @@ $routes->post("/editEmployeeProfile", "EmployeeRestController::editEmployeeProfi $routes->get("getClientPolicy", "EmployeeRestController::getClientPolicy"); +$routes->post("employeeUpload", "EmployeeRestController::employeeUpload"); $routes->group("employeeRest", ["filter" => "authJWT"], function($routes){ $routes->post("employeeUpload", "EmployeeRestController::employeeUpload"); diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 36eddb23..e46b0f93 100644 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -18,6 +18,9 @@ use App\Models\RelationshipModel; use App\Models\FileModel; use App\Models\ClientPolicyModel; +use App\Controllers\Jobs ; +use App\Controllers\JobWorker ; + use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Writer\Xlsx; @@ -411,26 +414,31 @@ class EmployeeRestController extends AdminController $highestRow = $sheet->getHighestRow(); $highestColumn = $sheet->getHighestColumn(); - $data = []; + $highestRowAndColumn = $sheet->getHighestRowAndColumn(); + $data = $sheet->rangeToArray('A1:' . $highestRowAndColumn['column'] . $highestRowAndColumn['row']); + // print_r($excel_data);die(); + // $data = []; + // $data[] =$excel_data; + // print_r($data);die; // Iterate through each row - for ($row = 1; $row <= $highestRow; $row++) { - // Initialize the row data array - $rowData = []; + // for ($row = 1; $row <= $highestRow; $row++) { + // // Initialize the row data array + // $rowData = []; - // Iterate through each column in the row - for ($col = 'A'; $col <= $highestColumn; $col++) { - // Get the cell value - $value = $sheet->getCell($col . $row)->getValue(); - - // Add the cell value to the row data array - $rowData[] = $value; - } - - // Add the row data to the main data array - $data[] = $rowData; - } + // // Iterate through each column in the row + // for ($col = 'A'; $col <= $highestColumn; $col++) { + // // Get the cell value + // $value = $sheet->getCell($col . $row)->getValue(); + // // print_r($value); + // // Add the cell value to the row data array + // $rowData[] = $value; + // } + // // Add the row data to the main data array + // $data[] = $rowData; + // } + // print_r($data);die; $extractData['file_name']= $filename; $extractData['client_id']= $client_id; @@ -442,6 +450,10 @@ class EmployeeRestController extends AdminController $file_data =$this->fileModel->insert($extractData); $extra = []; + //this change the column name into index number + for ($i = 0; $i < count($data[0]); $i++) { + $data[0][$i] = $i; + } for ($i = 0; $i < count($data); $i++) { if ($i == 0) { // Loop through the first row to extract keys @@ -462,27 +474,64 @@ class EmployeeRestController extends AdminController // print_r("Extra", $extra);die; $dataToInsert = []; $basic_cover_si= []; - foreach ($extra['id'] as $index => $id) { - $record = [ - // 'id' => $id, - 'emp_code' => isset($extra['emp_code'][$index]) ? $extra['emp_code'][$index] : 0, - 'name' => $extra['name'][$index], - // Check if the 'doj' key exists before accessing it - 'doj' => isset($extra['doj'][$index]) ? $extra['doj'][$index] : null, - 'gender' => $extra['gender'][$index], - 'relationship' => $extra['relationship'][$index], - 'dob' => $extra['dob'][$index], - 'email_personal' => $extra['Email'][$index], - 'client_id' => $client_id, - ]; - $record2 = [ - 'basic_cover_si' => isset($extra['sum_insure'][$index]) ? $extra['sum_insure'][$index] : 0, - ]; + // print_r($extra);die; + foreach ($extra['0'] as $index => $id) { + $relation =''; + if ($extra['5'][$index] === 'Mother' || $extra['5'][$index] === 'Father') { + $relation = 'parent'; + } else if($extra['5'][$index] === 'Son' || $extra['5'][$index] === 'Daughter'){ + $relation = 'child'; + }else if($extra['5'][$index] === 'Father in Law' || $extra['5'][$index] === 'Mother in Law'){ + $relation = 'parent_in_law'; + }else if($extra['5'][$index] === 'Spouse'){ + $relation = 'spouse'; + }else{ + $relation = 'self'; + } + + // Simplified formatDate function - $dataToInsert[] = $record; - $basic_cover_si[]= $record2; + + // Assigning formatted dates + // print_r($extra['3']);die; + $doj = $extra['3'][$index] ; + $dob = $extra['6'][$index] ; + + + // Change date format for $doj + $doj_new_format = date('Y-m-d', strtotime($doj)); // $doj_new_format will be "2001-02-12" + + // Change date format for $dob + $dob_new_format = date('Y-m-d', strtotime($dob)); + + // Your existing code here + + $emp_code =isset($extra['1'][$index]) ? $extra['1'][$index] : 0; + $name = $extra['2'][$index]; + + if($emp_code != 0 && $name != '' || $name != null){ + $record = [ + // 'id' => $id, + 'emp_code' => $emp_code, + 'name' => $name, + // Check if the 'doj' key exists before accessing it + 'doj' => $doj_new_format, + 'gender' => $extra['4'][$index], + 'relationship' => $extra['5'][$index], + 'family_floater_key' => $relation, + 'dob' => $dob_new_format, + 'email_corporate' => $extra['7'][$index], + 'mobile'=> $extra['8'][$index], + 'client_id' => $client_id, + + ]; + $record2 = [ + 'basic_cover_si' => isset($extra['9'][$index]) ? $extra['9'][$index] : 0, + ]; + $dataToInsert[] = $record; + $basic_cover_si[]= $record2; + } } - // print_r("dataToInsert", $dataToInsert);die; for ($a=0; $a employeeModel->checkExistingEmpEntrollment($dataToInsert[$a]); @@ -496,6 +545,7 @@ class EmployeeRestController extends AdminController $this->myLogger->logme('error',('Update - ' . $employee['id'].' - '. $employee['emp_code'] .' - '.$employee['name'])); } }else{ + $result = $this->employeeModel->insert($dataToInsert[$a]); $emp_id =$result; if ($result) { @@ -529,13 +579,24 @@ class EmployeeRestController extends AdminController // print_r($dataToInsert[$a]['email_personal']);die; $policy = $this->clientPolicyModel->where('id', $policy_id)->first(); $policy_name = $this->policesModel->where('id', $policy['policy_id'])->first(); - $mail = $dataToInsert[$a]['email_personal']; + $mail = $dataToInsert[$a]['email_corporate']; $subject = 'Welcome, Employee Benefit Program Enrolment'; - $message = 'Dear ' . $dataToInsert[$a]['name'] . ",
We are glad to welcome you to the employee benefit program ," .$policy_name['name'] ."offered by your employer,


Click on the link below to review your personal and family details:
Review Details" ; - $return_log = MailHelper::send_email($mail,$subject, $message); - $return_log = json_decode($return_log); - - $this->myLogger->logme('info', "Email Status : {mail_status}, Sender Email:{email}", ['mail_status' => $return_log->status, 'email'=> $return_log->data]); + // $message = 'Dear ' . $dataToInsert[$a]['name'] . ",
We are glad to welcome you to the employee benefit program ," .$policy_name['name'] ."offered by your employer,


Click on the link below to review your personal and family details:
Review Details" ; + $data['employee_name']=$dataToInsert[$a]['name']; + $data['policy_name']=$policy_name['name']; + + $message = view('mail_welcome', $data); + if ($dataToInsert[$a]['email_corporate'] != null || $dataToInsert[$a]['email_corporate'] != '' && $dataToInsert[$a]['relationship'] == 'Self') { + $job_details = new Jobs(); + $r = Jobs::addJob(['job_name' => 'send_email','payload' => ['mail' => $mail, 'subject' => $subject,'message'=> $message]]); + } + + // print_r($r);//die(); + // $jobWorker = new JobWorker(); + //JobWorker::processJob($r); + // $return_log = MailHelper::send_email($mail,$subject, $message); + // $return_log = json_decode($return_log); + // $this->myLogger->logme('info', "Email Status : {mail_status}, Sender Email:{email}", ['mail_status' => $return_log->status, 'email'=> $return_log->data]); } } diff --git a/app/Controllers/Home.php b/app/Controllers/Home.php index 9280fa95..9f76bf77 100644 --- a/app/Controllers/Home.php +++ b/app/Controllers/Home.php @@ -6,7 +6,7 @@ class Home extends PublicController { public function index(): string { - return view('welcome_message'); + return view('mail_welcome'); } public function test() diff --git a/app/Controllers/JobWorker.php b/app/Controllers/JobWorker.php index f3a2ab2a..964d365a 100644 --- a/app/Controllers/JobWorker.php +++ b/app/Controllers/JobWorker.php @@ -14,7 +14,7 @@ class JobWorker extends AdminController * Constructs the class */ - private static $event_class_mapping = ['add' => ['type' => 'HC','handler' => 'App\\Helpers\\HttpRequestHelper'], 'sub' => ['type' => 'CC','handler' => 'App\\Controllers\\Jobs\SubJob'],'fancy_date_time_format' => [ 'type' => 'HF','handler' => 'fancy_date_time_format'],'addNumber' => ['type' => 'HC','handler' => 'App\\Model\\HttpRequestHelper'],'excelFileFormatValidation' => ['type' => 'CC','handler' => 'App\\Controllers\\EmployeeServiceController'],'excelFileDataValidation' => ['type' => 'CC','handler' => 'App\\Controllers\\EmployeeServiceController'],'employeeOnboard' => ['type' => 'CC','handler' => 'App\\Controllers\\EmployeeServiceController']]; + private static $event_class_mapping = ['add' => ['type' => 'HC','handler' => 'App\\Helpers\\HttpRequestHelper'], 'sub' => ['type' => 'CC','handler' => 'App\\Controllers\\Jobs\SubJob'],'fancy_date_time_format' => [ 'type' => 'HF','handler' => 'fancy_date_time_format'],'addNumber' => ['type' => 'HC','handler' => 'App\\Model\\HttpRequestHelper'],'excelFileFormatValidation' => ['type' => 'CC','handler' => 'App\\Controllers\\EmployeeServiceController'],'excelFileDataValidation' => ['type' => 'CC','handler' => 'App\\Controllers\\EmployeeServiceController'],'employeeOnboard' => ['type' => 'CC','handler' => 'App\\Controllers\\EmployeeServiceController'],'send_email' => ['type' => 'HC','handler' => 'App\\Helpers\\MailHelper']]; public function __construct() { // echo 'HiC';//die(); @@ -27,12 +27,39 @@ class JobWorker extends AdminController // } } + public static function processJobs(array $jobdata = []) + { + // echo 'listen';//die(); + $query = " + SELECT id, name, payload, uuid + FROM jobs + WHERE status=? + ORDER BY created_dt ASC"; + $where_condition = [self::STATUS_QUEUED]; + $db = \Config\Database::connect(); + $jobs = $db->query($query, $where_condition)->getResult(); + + if(count($jobs)) + { + // echo count($jobs); + // print_r($jobs);die; + foreach($jobs as $key => $job) + { + // echo $job->id.' - '.$job->name; + //sleep(1); + + SELF::processjob(['id' => $job->id,'uuid' => $job->uuid]); + } + } + } /** * process jobs */ public static function processJob(array $jobdata = []) { - // echo 'listen';//die(); + // print_r($jobdata); + // echo 'listen'; + // die(); $query = " SELECT id, name, payload, uuid FROM jobs @@ -61,7 +88,9 @@ class JobWorker extends AdminController echo "\nProcessing job id - " . $job->id . "\n"; echo "Job name - " . $job->name . "\n"; - + // print_r(SELF::$event_class_mapping); + // echo array_key_exists($job->name,SELF::$event_class_mapping) ? 'mapped' : 'notmapped'; + // die(); try { $start = microtime(true); @@ -69,7 +98,7 @@ class JobWorker extends AdminController $job_status = self::STATUS_RUNNING; $db->query("UPDATE jobs SET status=? WHERE id=? AND uuid=?", [$job_status, $job->id,$job->uuid]); - if (!array_key_exists($job->name,SeLf::$event_class_mapping)) + if (!array_key_exists($job->name,SELF::$event_class_mapping)) { throw new \RuntimeException('Job ' . $job->name . ' handler not registered'); } @@ -145,6 +174,7 @@ class JobWorker extends AdminController // echo "Job $job->id $job_status. Response - $response \n"; echo "Job $job->id $job_status \n"; + return true; } else { diff --git a/app/Helpers/MailHelper.php b/app/Helpers/MailHelper.php index fd56e4f5..9709de46 100644 --- a/app/Helpers/MailHelper.php +++ b/app/Helpers/MailHelper.php @@ -12,11 +12,15 @@ use PHPMailer\PHPMailer\Exception; class MailHelper { - static function send_email($emaill, $subject, $message) + public static function send_email($params) { + $emaill = $params['mail']; + $subject = $params['subject']; + $message = $params['message']; try { $email = \Config\Services::email(); - $email->setFrom('bbone@venbait.in', 'Venkat'); + $email->setMailType('html'); + $email->setFrom('bbone@venbait.in', 'Nhance'); $email->setTo($emaill); @@ -33,12 +37,5 @@ class MailHelper return json_encode(['status' => 'failed','code' => 500,'data' => $emaill],500); } } - - - function logme($message, $email) { - // Your logging logic here - // For example, writing to a log file - file_put_contents('path/to/log/file.txt', $message . "\n", FILE_APPEND); - } } ?> \ No newline at end of file diff --git a/app/Models/EmployeeModel.php b/app/Models/EmployeeModel.php index 41c42a52..09eeb13d 100644 --- a/app/Models/EmployeeModel.php +++ b/app/Models/EmployeeModel.php @@ -23,6 +23,7 @@ class EmployeeModel extends Model "mobile", "gender", "dob", + "doj", "otp", "family_floater_key", "emp_status", diff --git a/app/Views/mail_welcome.php b/app/Views/mail_welcome.php new file mode 100644 index 00000000..9ebdd64b --- /dev/null +++ b/app/Views/mail_welcome.php @@ -0,0 +1,23 @@ + + + + + + +
+ +
+
+ Dear, +

We are glad to welcome you to the employee benefit program, offered by your employer.

+
+ +
+
+ + + diff --git a/composer.json b/composer.json index 12d029a0..e0f50cfa 100644 --- a/composer.json +++ b/composer.json @@ -17,6 +17,7 @@ "firebase/php-jwt": "^6.10", "google/apiclient": "^2.15.0", "laminas/laminas-escaper": "^2.9", + "php-amqplib/php-amqplib": "^2.8", "phpmailer/phpmailer": "^6.9", "phpoffice/phpspreadsheet": "^2.0", "psr/log": "^1.1", diff --git a/public/assets/images/Nhance-Logo-Final.png b/public/assets/images/Nhance-Logo-Final.png new file mode 100644 index 0000000000000000000000000000000000000000..0d331b6844d5e4a205d94f90b8f999ba00b5041d GIT binary patch literal 4069 zcmVt`RVhW4sjMv=N^&GhPhjm62rg4e z+pW_GcJh5Gt*uPTB4*E-At{2yWo7{IBIEx)>{{f2I2g>Cb3XtmP@uqr0qg(kp!poY zckrY6f$x6;-rk3;Ef2&?ebiF2fbEros0f!{D-SDi<#oyC3cW@JG4J#(#-W)>`HjGq5LN^~#=+s%7}Do|h&u#`t~Sb{cx4G#ev=Hb?_LV*Gg4C)Lm;lROh z6CMIM{22-qcwp$N-0)8Q6jp`9<}MT{P+;nyE1@NXW2s>30tKcGlA#&gfG!HAE>K|V zAQ{^CT`+-Q>XWBXpg@7Cz?}H+U%xwt#>p8;o8JLtK!aIX4uhM;-s z;IUQnU>eY)aTpb(F@tBx0)I75PK}tFRCac^0_*EnV2Jmdk1vpc9M$n(Fj)NU!Ovd* zgZON>5b#sjd{*oK`Lel$+uOJJ`Kk!fMV?0Yij2*0BlFvDGR>fq*>0=&+uy{}FbJZB za}V$RJac*oM>sD&(gXeyUW5K^<26H4YrFFTf)+OyT82T)(Wdn((tT;Z?AY;QuHX%D zoU5&x3weV!WJYVMOCN( zsL0r5Ye!p+qXL(#=HwpPFpu15b~BzYT(g~8CMIL18*>24^EVo{+Q9|TVk_cD^da-U z8x0$#9&8mC{eET(mzdz-L@zy-#^=J!1XhJMztp0KHkT~t;Sa)Arsts9 z%x`n)!Zg$=%_3qJ8}foFZM4p5W2TKTcc2iWO)W-XMkkh#SJ0HH$)S^TF~=0cLG`~L zJA%xEyqO0E=t&AKiiIrf<@}*r?KTc(?m?HSiMCtFODabpRtt{L6idt0ZT|&)j$mvz zau*c~l#MqbheI{;JEDgc@>mfwKO;lM8d4jZ1!yiBubjkjy^V%*6JJwWM3yusr+)UB znj2)3ksWu?{7jj;9PXgAL|D)Ub$EFEfD5PAJ@)WfoZ+G4#dadKCF$WGFGTpJoP1r< zWQ4C{%wVNvqIPKknKCx$!Nnin2H$^z&f`USbXLS?`a(0*oSIWQm6-bF(F#~|7y1qp zR4osiH=kjb5XnTtUS_VW+9rEnNlE}dRF#OtC$adhLe6(!GH^tUJ1V>;CE%n|i*0E6 z#ANl*Z%HlJlgt=R>Fh;3OHX`Hn>LvuoaqQaY2Ix;tM@+WOX%zG|Frae`jTZp18w9Z%~( zY6-5H_C_@M(bCuQRp)AyE@BRndOdB%#ALMC^H3?RYoai|1Dk6rN@1~$XZu2W>tKk^ zzJxAW{(uU>sK3_|GWE*hV62yzx^cXN-|MSslBr=TCAG}ZITJbU?30ujehJk=3#Ej$ zYLq=EewR^er+e=w<4Fr26YWF`<~Bdgxc2JqKL~=82d)slLBZ)-dmzU=0191~Ze1wE65*dA!t0^zNJJY_;f~ z#IqPwx$U8$$khDudj0pc#iRe6_dnf20vpGmm&DP#xbSfPqP1Z2hX>GJfz8ll7-H^o zoanldr*&8rrd_(({JQ%9f*44~xvtvtR=HgFId|bVw{B>M(~)~fppEmd1AkKj5z}_) z$i$(rxuSLP^5_ambC;kBnx8PUgc3A>+n@uI#+xzgO03&g9*VByMw0#C9NLg2!>MiV zM9-EYGp9|MsZ{#&m*5m*^Cf1z{_pzZpt?+i(r#!1vJt|KZVFxBmF)^|r0)zlcG_AQLcYu1JGp{2X-9x*Mf~ z^4ay^4cd{BkZP|Bs^G)YoN}@=q=!HWDJ_0&%*?cL3~Y!>4GuV}SR+hLQkH(qhzQCW z3NrQY4&OfEfa>NrL8_x_nyO%GgZpJ=qgF@U8k`HZ>N7YUWNt_c-qCe#s`WJY;YZK{ znl+=)n=_`~F%~|uC&II=a#V)=6Yt+8;6>g8zfWXVp{4v zYS;QIApMwBzfBxo`*3vh(_n?x!r|NPcbktC4xXjBoTgSK@F74*F7Jb+B z6Zp(gqU%c*y{Yw!fiSwDHBDUzEfF{SinR~5wGoX`vjq`bMJaI^@PHFjn@BEFXE=tz zj*bE<*TTWib(BtK>b&0due6Iu9<5leS9|>e4{Mj{Wu}-aF+2xA_N|56r4S51f^^ zI{>j8CC<_KA_kpSPS1h|z3&yxjYcoQ#vJNChtc&x9(HLb*TD>~FafCCH$ey)H3?*4 z-qFpq?QYCZ55&~|-0NZI5r)g$j>VTDFNsKn_$Dyl2u48#8qzE5gk0w-%|Xnjb{YsN z7MKnUJ9nw*g(5;`6>MEbR*YkVY1hvvY^_y|m^vcioEEH*)VVRW0kZPOCsj8I5BV!6 z=p4JpSf%q+!*FBPhT^N11|eeKMnx~4E+hAlEkhGpl%Zp!21PSEV`bA{)I%rY~D zKDa_TpisU1C&Gpz+}`$`W5&{%u@5ji@RUbdW2%*AB~>%h?wgIIHb;hZlS5DfRM4a5 zP!lbk^J8d2(e)$<<}}{_&_p!QrZy>VxbJ#WgNFbvdRr%r za>E=VK4be3S3>uYy6edUd4;Wt>cn|yIx0!#P*X$JSS#SpgIPh6?Kuo8Z&ht+M5&j( zL>>|{Ne4Ay=+nj3QiWAJvLw+78qE&6Y0TqcXaX^{X@i6Z)5?h1$wQcCN~WSpmiJpM zvV^cbHP(r8OQU|nK?l^}1=C8cQ&5NbyVPa*=%q$7irag><6~$7mDh3KP< zfj)}zH8PP4{d?wLiO2%u1|^EOdm(h~Azcor!|u~Wj7ODWy_XF3UtH%q;vHBm?ii$q zdV_D&7_Wrxff^(j*HUZtb)G6HrYTa_NuhRyfIg=;DDcn>vWUyJRT+PJVCqPca6rao zp9?8zlt&#=|1Ie-uYbo5=su7(-wb$d9&^@H8r55MR-Xd+6 zT&VCHg$E~XJ=rVF>uv;i4!vQKTJz`>3oAAzm_~3`)3hbCf)^^Cd-%xe@Q72h0~;m^ ze6}0U0;b7iBy1X~<>?W8l zX(}s(ZaR}?Xo6|k<;*6W;O=hP_Es0f4C9y19%Kp8P*Sr`SsIWjIFQs6i8M)5=@Hor zZ}JRHFsaZA>zp|Y7?;!$3v&Y9RmDQjc*FW=)yC4uKz8b^E03QHQ+sjE8mEJyO^P{6 zl^K=LkgmaE5`>!FSUS6ICk}+J!8p1r|l*iyfc5p?JL|Sb|(8d-akNcJ{ zf~d-d2dXWIm<}O1*)-}Z%t$Y5Xj$i4%)yuoM(|zGLdo>OmROYTyUDJp@j?$YiM6XT3Yd2}1?XPGlwbKtYML+-m01jnXNoGw=04e|g00;m8 X000000Mb*F00000NkvXXu0mjfbUfZE literal 0 HcmV?d00001 From 62b47ab0a5e7a8a4ed38370b7be4707b02dde72a Mon Sep 17 00:00:00 2001 From: bitbucket Date: Wed, 20 Mar 2024 10:16:48 +0530 Subject: [PATCH 17/18] CHANGES-IN-EMP-POLICY-API : GWM --- app/Config/Routes.php | 2 +- app/Controllers/EmployeeRestController.php | 56 ++++++++++++++++++---- app/Models/EmployeePolicyModel.php | 3 +- 3 files changed, 50 insertions(+), 11 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 45cf2568..b74bb60d 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -214,7 +214,7 @@ $routes->post("/editEmployeeProfile", "EmployeeRestController::editEmployeeProfi - +// $routes->get("getEmployeePolicy", "EmployeeRestController::getEmployeePolicy"); $routes->group("employeeRest", ["filter" => "authJWT"], function($routes){ $routes->post("employeeUpload", "EmployeeRestController::employeeUpload"); diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 4c543e4a..81dbf7a0 100644 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -306,6 +306,7 @@ class EmployeeRestController extends AdminController $keysToRemove = ["removable_keys"]; $empPolicy = $this->employeeModel->getEmployeePolicy($id); + $empData = $this->employeeModel->where('emp_code',$emp_code)->findAll(); if ($empPolicy) { @@ -336,10 +337,35 @@ class EmployeeRestController extends AdminController array_unshift($array->SlabRates, $element); } + $employee_policy = $this->employeePolicyModel->where('employee_id',$id)->where('client_policy_id',$array->ClientPolicyId)->get()->getRow(); + if($employee_policy){ + $gpaSI['family_floater_key'] = 'self'; + $gpaSI['label'] = 'Self'; + $gpaSI['employee_id'] = $employee_policy->employee_id; + $gpaSI['basic_cover_si'] = isset($employee_policy->basic_cover_si) ? $employee_policy->basic_cover_si : null; + $gpaSI['premium'] = isset($employee_policy->premium) ? $employee_policy->premium : null; + $gpaSI['client_policy_id'] = $array->ClientPolicyId; + + $array->mapped_family_floaters = $gpaSI; + }else{ + $gpaSI['family_floater_key'] = 'self'; + $gpaSI['label'] = 'Self'; + $gpaSI['employee_id'] = $id; + $gpaSI['basic_cover_si'] = null; + $gpaSI['premium'] = null; + $gpaSI['client_policy_id'] = $array->ClientPolicyId; + + $array->mapped_family_floaters = $gpaSI; + } + }else if($getSlabAndGridData['grid_master']['policy_type'] == "GMC"){ // re-arranging order of si $default_si = $array->Policy_Terms->sum_insured; + // Filter the array using the callback function + $getPremium = array_filter($array->SlabRates , function ($value) use ($default_si) { return $value['si'] == $default_si; } ); + $default_premium = $getPremium[0]['premium']; + $index = -1; foreach ($array->SlabRates as $key => $value) { if ($value['si'] == $default_si) { @@ -367,8 +393,8 @@ class EmployeeRestController extends AdminController $temp['name'] = $value['name']; $temp['employee_id'] = $value['id']; $temp['basic_cover_si'] = isset($employee_policy->basic_cover_si) ? $employee_policy->basic_cover_si : null; - $temp['client_policy_id'] = $array->ClientPolicyId; - + $temp['premium'] = isset($employee_policy->premium) ? $employee_policy->premium : null; + $temp['client_policy_id'] = $array->ClientPolicyId; array_push($data,$temp); unset($empData[$key]); break; @@ -378,6 +404,15 @@ class EmployeeRestController extends AdminController } $array->mapped_family_floaters = $data; + $temp2=[]; + foreach ($array->SlabRates as $key => $value) { + $value['additional_premium'] = $value['premium'] - $default_premium; + array_push($temp2,$value); + } + $array->SlabRates = $temp2; + + + } $result[] = $array; @@ -399,24 +434,27 @@ class EmployeeRestController extends AdminController try { $requestData = $this->request->getJSON(); + foreach ($requestData as $key => $value) { - $checkIfExist = $this->employeePolicyModel->where('employee_id', $requestData['employee_id']) - ->where('client_policy_id', $requestData['client_policy_id']) + + $checkIfExist = $this->employeePolicyModel->where('employee_id', $value->employee_id) + ->where('client_policy_id', $value->client_policy_id) ->findAll(); // dd($checkIfExist); if ($checkIfExist) { - $empPolicy = $this->employeePolicyModel->updateSiAndPremium($requestData['client_policy_id'], $requestData['employee_id'], $requestData['basic_cover_si']); + $empPolicy = $this->employeePolicyModel->updateSiAndPremium($value->client_policy_id, $value->employee_id, $value->basic_cover_si,$value->premium); }else{ - $data['employee_id']= $requestData['employee_id']; - $data['client_policy_id']= $requestData['client_policy_id']; - $data['basic_cover_si']= $requestData['basic_cover_si']; + $data['employee_id']= $value->employee_id; + $data['client_policy_id']= $value->client_policy_id; + $data['basic_cover_si']= $value->basic_cover_si; + $data['premium']= $value->premium; $this->employeePolicyModel->insert($data); } - + } return $this->respond(['status' => 'success','code' => 200,'data' => []], 200); } catch (\Exception $e) { diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php index 530d8543..f69379b6 100644 --- a/app/Models/EmployeePolicyModel.php +++ b/app/Models/EmployeePolicyModel.php @@ -190,12 +190,13 @@ class EmployeePolicyModel extends Model } - public function updateSiAndPremium( $client_policy_id, $employee_id,$basic_cover_si) + public function updateSiAndPremium( $client_policy_id, $employee_id,$basic_cover_si,$premium) { $query = "UPDATE employee_polices SET employee_polices.basic_cover_si = '{$basic_cover_si}' + , employee_polices.premium = '{$premium}' WHERE employee_polices.employee_id = '{$employee_id}' AND employee_polices.client_policy_id = '{$client_policy_id}'"; From d08cb10e0941964ac19ebc6e14e0901839fc0896 Mon Sep 17 00:00:00 2001 From: aadhavan valli Date: Wed, 20 Mar 2024 16:13:51 +0530 Subject: [PATCH 18/18] CHANGE_EMPLOYEE_REST_FILE_UPLOAD_EMP_STATUS_KEY : AADHAVAN --- app/Controllers/ClientController.php | 24 +++++++++++++-- app/Controllers/EmployeeRestController.php | 35 ++++++++++++---------- app/Views/policy_gmc_terms.php | 5 +++- app/Views/policy_gpa_terms.php | 4 +-- 4 files changed, 48 insertions(+), 20 deletions(-) diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 87f633fa..392f362e 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -834,6 +834,8 @@ class ClientController extends AdminController $client_policy_id = $this->request->getGet('client_policy_id'); $record = $this->clientPolicyModel->where('id', $client_policy_id)->first(); + $family_floater=json_decode($record['policy_terms'])->family_floater; + $emp_count = $this->employeeModel ->join('client_policy cp',"employees.client_id = cp.client_id") ->join('employee_polices ep',"cp.id = ep.client_policy_id AND employees.id = ep.employee_id") ->where("employees.client_id",$record['client_id']) @@ -864,11 +866,29 @@ class ClientController extends AdminController $premiumData = $this->policyPremium2Model->where(['client_id' => $record['client_id'], 'client_policy_id' => $client_policy_id, 'is_active' => 1])->findAll(); } // echo '
';
-        // print_r($results);
+        // echo $family_floater;
+        $resultss = [];
+        if ($family_floater == 1) {
+
+            foreach ($results as $index => $record) {
+                if ($index == '8' || $index == '7') {
+                     // Clearing the $results array
+                    $resultss[$index] = $record; 
+                }
+            }
+        }else{
+            foreach ($results as $index => $record) {
+                if ($index == '0' || $index == '1' || $index == '2' || $index == '3' || $index == '4' || $index == '5' || $index == '6') {
+                    // Clearing the $results array
+                   $resultss[$index] = $record; 
+               }
+            }
+        }
+
         // print_r($data[0]->policy_type); die;
                     // echo "hello";
             // return json_encode($premiumData);
-        return $this->respond(['status' => true,'code' => 200,'data' => $results, 'premiumData' => json_encode($premiumData), 'count' => $emp_count, 'policy_name' => $policy_name], 200);
+        return $this->respond(['status' => true,'code' => 200,'data' => $resultss, 'premiumData' => json_encode($premiumData), 'count' => $emp_count, 'policy_name' => $policy_name,], 200);
 
     }
 
diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php
index cb0cc648..dd0f951b 100644
--- a/app/Controllers/EmployeeRestController.php
+++ b/app/Controllers/EmployeeRestController.php
@@ -567,6 +567,8 @@ class EmployeeRestController extends AdminController
             $emp_code =isset($extra['1'][$index]) ? $extra['1'][$index] : 0;
             $name = $extra['2'][$index];
 
+            // print_r("--" . $emp_code. "---");
+            // print_r( $emp_code != 0 );
             if($emp_code != 0 && $name != '' || $name != null){
                 $record = [
                     // 'id' => $id,
@@ -575,12 +577,13 @@ class EmployeeRestController extends AdminController
                     // Check if the 'doj' key exists before accessing it
                     'doj' => $doj_new_format,
                     'gender' => $extra['4'][$index],
-                    'relationship' => $extra['5'][$index],
+                    'relationship' => ucfirst($extra['5'][$index]),
                     'family_floater_key' => $relation,
                     'dob' => $dob_new_format,
                     'email_corporate' => $extra['7'][$index],
                     'mobile'=> $extra['8'][$index],
                     'client_id' => $client_id,
+                    'emp_status'=>'draft'
                     
                 ];
                 $record2 = [
@@ -594,6 +597,7 @@ class EmployeeRestController extends AdminController
         { 
                     $employee = $this->employeeModel->checkExistingEmpEntrollment($dataToInsert[$a]);
                     $emp_id =0;
+
                     if ($employee) {
                         $emp_id =$employee['id'];
                         $id =$emp_id;
@@ -603,17 +607,18 @@ class EmployeeRestController extends AdminController
                             $this->myLogger->logme('error',('Update - ' . $employee['id'].' - '. $employee['emp_code'] .' - '.$employee['name']));
                         }
                     }else{
-                        
-                        $result = $this->employeeModel->insert($dataToInsert[$a]);
-                        $emp_id =$result;
-                        if ($result) {
-                            $emp = $this->employeeModel->where('id', $result)->get()->getResult();
+                        if ($dataToInsert[$a]['emp_code'] != 0) {
+                            $result = $this->employeeModel->insert($dataToInsert[$a]);
+                            $emp_id =$result;
+                            if ($result) {
+                                $emp = $this->employeeModel->where('id', $result)->get()->getResult();
 
-                            $policy_name = $this->employeePolicyModel->where('employee_id', $result)->get()->getResult();;
-                            
-                            
-                            $log_message = 'Insert Employee- '.$dataToInsert[$a]['name'] .'('.$dataToInsert[$a]['emp_code'] .') with PK ';
-                            $this->myLogger->logme('error',('Insert - ' .  $dataToInsert[$a]['emp_code'] .' - '. $dataToInsert[$a]['name']));
+                                $policy_name = $this->employeePolicyModel->where('employee_id', $result)->get()->getResult();;
+                                
+                                
+                                $log_message = 'Insert Employee- '.$dataToInsert[$a]['name'] .'('.$dataToInsert[$a]['emp_code'] .') with PK ';
+                                $this->myLogger->logme('error',('Insert - ' .  $dataToInsert[$a]['emp_code'] .' - '. $dataToInsert[$a]['name']));
+                            }
                         }
                     }
                     $emp_policy_data =[
@@ -644,10 +649,10 @@ class EmployeeRestController extends AdminController
             $data['policy_name']=$policy_name['name'];
             
             $message = view('mail_welcome', $data);
-            if ($dataToInsert[$a]['email_corporate'] != null || $dataToInsert[$a]['email_corporate'] != ''  &&  $dataToInsert[$a]['relationship'] == 'Self') {
-                $job_details  = new Jobs();
-                $r = Jobs::addJob(['job_name' => 'send_email','payload' => ['mail' => $mail, 'subject' => $subject,'message'=> $message]]);    
-            }
+            // if ($dataToInsert[$a]['email_corporate'] != null || $dataToInsert[$a]['email_corporate'] != ''  &&  $dataToInsert[$a]['relationship'] == 'Self') {
+            //     $job_details  = new Jobs();
+            //     $r = Jobs::addJob(['job_name' => 'send_email','payload' => ['mail' => $mail, 'subject' => $subject,'message'=> $message]]);    
+            // }
           
             // print_r($r);//die();
             // $jobWorker = new JobWorker();
diff --git a/app/Views/policy_gmc_terms.php b/app/Views/policy_gmc_terms.php
index e03b3e9d..c1582a88 100644
--- a/app/Views/policy_gmc_terms.php
+++ b/app/Views/policy_gmc_terms.php
@@ -626,6 +626,8 @@ var grid_html = '';
 
 
         var gmc_policy_type_id = $(this).attr('id');
+        
+
         if(gmc_policy_type_id >= '2'){
 
             $('#policyGMCTerms').css('display', '');
@@ -640,11 +642,12 @@ var grid_html = '';
                 method: 'GET',
                 data: {client_policy_id: client_policy_id}, 
                 success: function(response) {
+                    console.log('response',response);
+
                     setTimeout(function() {
                         $('.loader').fadeOut();
                         $('.loader-mask').delay(350).fadeOut('slow');
                     }, 1000);
-                    console.log(response);
                     $('#nameOfThePolicyInGMC').html(' - ' + response.policy_name.name);
                     $('gmc_emp_count').val(response.count);
 
diff --git a/app/Views/policy_gpa_terms.php b/app/Views/policy_gpa_terms.php
index a3745720..c448e10e 100644
--- a/app/Views/policy_gpa_terms.php
+++ b/app/Views/policy_gpa_terms.php
@@ -446,12 +446,12 @@
     $('body').on('click', '.btnPolicyMaster', function () {
 
         var client_policy_id = $(this).data('id');
-        console.log('client_policy_id :' ,client_policy_id);
+        // console.log('client_policy_id :' ,client_policy_id);
 
         $('#gpa_client_policy_id').val(client_policy_id);
 
         var gpa_policy_type_id = $(this).attr('id');
-        console.log('gpa_policy_type_id', gpa_policy_type_id)
+        // console.log('gpa_policy_type_id', gpa_policy_type_id)
 
         if(gpa_policy_type_id == '1'){