diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index b9eb75df..fe8eea4b 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -26,6 +26,7 @@ use App\Models\StateModel; use App\Models\PolicyGridModel; use App\Models\PolicyPremium1Model; use App\Models\PolicyPremium2Model; +use App\Models\EmployeeModel; class ClientController extends AdminController { @@ -50,6 +51,7 @@ class ClientController extends AdminController protected $policyGridModel; protected $policyPremium1Model; protected $policyPremium2Model; + protected $employeeModel; public function __construct() { @@ -72,7 +74,9 @@ class ClientController extends AdminController $this->tpaModel = new TPAModel(); $this->stateModel = new StateModel(); $this->policyGridModel = new PolicyGridModel(); - $this->policyPremium1Model = new PolicyPremium1Model(); + $this->policyPremium1Model = new PolicyPremium1Model(); + $this->policyPremium2Model = new PolicyPremium2Model(); + $this->employeeModel = new EmployeeModel(); } @@ -760,17 +764,26 @@ class ClientController extends AdminController } - public function getjson() + public function getterms() { $client_id = $this->request->getVar('client_id'); $policy_id = $this->request->getVar('policy_id'); - $record = $this->clientPolicyModel->where(['client_id' => $client_id, 'policy_id' => $policy_id])->first(); + $record = $this->clientPolicyModel->where(['client_id' => $client_id, 'policy_id' => $policy_id])->first(); + $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",$client_id) + ->where("employees.emp_status",'active') + ->countAllResults(); + if($emp_count = 0){ + $emp_count = true; + }else{ + $emp_count = false; + } if ($record) { - echo $record['policy_terms']; - + return $this->respond(['Status' => true,'code' => 200,'data' => $record['policy_terms'], 'count' => $emp_count], 200); } else { - echo "Record not found."; + return $this->respond(['Status' => false,'code' => 200,'message' => 'Record not found.', 'count' => $emp_count], 200); } } diff --git a/app/Views/client_policy.php b/app/Views/client_policy.php index b009aab1..e4608bcd 100644 --- a/app/Views/client_policy.php +++ b/app/Views/client_policy.php @@ -1,3 +1,13 @@ + +
@@ -13,6 +23,8 @@ Insurer Policy TPA + Date + Status Action @@ -71,13 +83,17 @@
-
+
- +
-
+
- + +
+
+ +
@@ -179,10 +195,12 @@ ${item.insurer_short} - ${item.insurer_branch_name} ${item.policy_name} ${item.tpa_short} - ${item.tpa_branch_code} + ${rearrangeDateFormat(item.policy_start_date)} - ${rearrangeDateFormat(item.policy_end_date)} + ${checkDateStatus(item.policy_end_date, 1)}    - - + + `; @@ -195,7 +213,7 @@ }); - //for form submit using AJAX + /******** for form submit using AJAX *******/ $("#policy_form").submit(function(event) { event.preventDefault(); @@ -238,18 +256,18 @@ } if(res){ - setTimeout(function() { - - $('.loader').fadeOut(); - $('.loader-mask').delay(350).fadeOut('slow'); - $('#add_form').hide(); - $('#table_list').show(); - $('.btnBack').hide(); - $('.btnAdd').show(); - var message = (policy_PrimaryKey === '') ? 'Policy Created successfully' : 'Policy Updated Successfully'; - toastr.success(message, 'Success'); - }, 1000); - } + setTimeout(function() { + + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + $('#add_form').hide(); + $('#table_list').show(); + $('.btnBack').hide(); + $('.btnAdd').show(); + var message = (policy_PrimaryKey === '') ? 'Policy Created successfully' : 'Policy Updated Successfully'; + toastr.success(message, 'Success'); + }, 1000); + } $('#policy_table tr').remove(); @@ -260,10 +278,12 @@ ${item.insurer_short} - ${item.insurer_branch_name} ${item.policy_name} ${item.tpa_short} - ${item.tpa_branch_code} + ${rearrangeDateFormat(item.policy_start_date)} - ${rearrangeDateFormat(item.policy_end_date)} + ${checkDateStatus(item.policy_end_date)}    + - `; @@ -308,13 +328,13 @@ var dataId = $(this).children('option:selected').attr('data-id'); console.log('dataId', dataId) $('#policy_type_id').val(dataId); - if(dataId == 1){ - appendPolicyFormFields(1); - }else if (dataId >= 1){ - appendPolicyFormFields(2); - } - console.log('second', $('#policy_type_id').val()); + // if(dataId == 1){ + // appendPolicyFormFields(1); + // }else if (dataId >= 1){ + // appendPolicyFormFields(2); + // } + }); @@ -354,6 +374,7 @@ $('#policy_PrimaryKey').val(res.data.id); $('#start_date').val(rearrangeDateFormat(res.data.policy_start_date)); $('#end_date').val(rearrangeDateFormat(res.data.policy_end_date)); + $('#policy_status').val(checkDateStatus(res.data.policy_end_date)); if(res.data.policy_type_id == 1){ appendPolicyFormFields(1, res.data); @@ -529,4 +550,78 @@ } } + function checkDateStatus(inputDate, bg = false) { + + var givenDate = new Date(inputDate); + var currentDate = new Date(); + + if(bg != false){ + if (givenDate < currentDate) { + return `Expired`; + } else { + return `Active`; + } + }else{ + if (givenDate < currentDate) { + return `Expired`; + } else { + return `Active`; + } + } + + } + + // Function to convert numbers into Indian numbering system + function convertToIndianNumberingSystem(number) { + // Define Indian numbering system + var suffixes = ["", "Thousand", "Lakh", "Crore"]; + + // Split the number into groups of 3 digits each + var numberChunks = []; + while (number > 0) { + numberChunks.push(number % 1000); + number = Math.floor(number / 1000); + } + + // Convert each chunk into words + var result = ""; + for (var i = 0; i < numberChunks.length; i++) { + if (numberChunks[i] !== 0) { + result = convertThreeDigitNumberToWords(numberChunks[i]) + " " + suffixes[i] + " " + result; + } + } + + return result.trim(); + } + + // Function to convert a three-digit number into words + function convertThreeDigitNumberToWords(num) { + var ones = ["", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine"]; + var tens = ["", "Ten", "Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety"]; + var teens = ["", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen"]; + + var words = ""; + + // Convert hundreds place + if (Math.floor(num / 100) > 0) { + words += ones[Math.floor(num / 100)] + " Hundred "; + num %= 100; + } + + // Convert tens and ones place + if (num >= 20) { + words += tens[Math.floor(num / 10)] + " "; + num %= 10; + } else if (num >= 11 && num <= 19) { + words += teens[num - 10] + " "; + num = 0; + } + + if (num > 0) { + words += ones[num] + " "; + } + + return words.trim(); + } + \ No newline at end of file diff --git a/app/Views/policy_gmc_terms.php b/app/Views/policy_gmc_terms.php index 658b9b06..7adaffcc 100644 --- a/app/Views/policy_gmc_terms.php +++ b/app/Views/policy_gmc_terms.php @@ -95,7 +95,7 @@
- Self + Self Spouse Child 1 Child 2 @@ -351,17 +351,12 @@ var policy_grid_id = $('#client_id').val(); var grid_html = ''; -$('#gmc_remove').hide(); -$('#btnGridSubmit').hide(); $('.close').click(function(){ $('#sum_insured').val(""); $('#familyfloater').val(""); $('#waiverofpreexistingdiseases').prop('checked', false); $('#maternitycoverage').val(""); - for (var i = 1; i <= 11; i++) { - $('#grid_' + i).remove(); - } }); @@ -501,438 +496,123 @@ $('body').on('click', '.btnPolicyMaster', function () { var client_id = $('#Client_id').val(); $('#client_policy_id').val(policy_id); + + var policy_type_id = $(this).attr('id'); + console.log('policy_type_id', typeof policy_type_id) - $('#policyGMCTerms').css('display', ''); - $('#police-tab').css('display', 'none'); - $('.nav.nav-pills.navtab-bg').css('display','none'); - $('.nav.nav-pills.navtab-bg').prev().css('display','none'); + if(policy_type_id >= '2'){ + + $('#policyGMCTerms').css('display', ''); + $('#police-tab').css('display', 'none'); + $('.nav.nav-pills.navtab-bg').css('display','none'); + $('.nav.nav-pills.navtab-bg').prev().css('display','none'); - $.ajax({ - url: '', - method: 'GET', - data: { policy_id : policy_id , client_id: client_id}, - success: function(response) { - if (response) { - let jsonObject = JSON.parse(response); - Object.keys(jsonObject).forEach(function(key) { - if (key.includes("special_condition_label") || key.includes("special_condition_input")) { - if (key.includes("special_condition_label")) { - for (let index = 0; index < jsonObject[key].length; index++) { - specialCondition(); - } - } - let elements = document.getElementsByName(`${key}[]`); - - if (elements) { - elements.forEach((element,index) => { - element.value = jsonObject[key][index]; - }); - } - } - - if (key.includes("family_floaters")) { - let checkboxes = document.querySelectorAll(`input[name="${key}[]"]`); - if (jsonObject[key]) { - jsonObject[key].forEach(element => { - let checkbox = $(`#${element}`); - if (checkbox.is(":checkbox")) { - checkbox.prop("checked", true); - } - }); - } - - } - - - let elements = document.getElementsByName(key); - if (elements && elements.length > 0) { - let element = elements[0]; // Assuming you want to update the first element with the name - - - if (element.tagName === 'INPUT' && (element.type === 'checkbox' || element.type === 'radio')) { - - if (element.type === 'checkbox') { - element.checked = jsonObject[key] === '1'; // Assuming jsonObject[key] is '1' or '0' for checkbox - } else if (element.type === 'radio') { - - if (element.value === jsonObject[key]) { - element.checked = element.value === jsonObject[key]; - - if(element.name === "family_floater") { - element.parentElement.nextElementSibling.style.display=''; - element.parentElement.parentElement.parentElement.nextElementSibling.style.display=''; - }else if(element.name === "waiverofpreexistingdiseases"){ - element.parentElement.parentElement.nextElementSibling.style.display=''; - element.parentElement.parentElement.nextElementSibling.nextElementSibling.style.display=''; - element.parentElement.parentElement.nextElementSibling.nextElementSibling.nextElementSibling.style.display=''; - element.parentElement.parentElement.nextElementSibling.nextElementSibling.nextElementSibling.nextElementSibling.style.display=''; - + $.ajax({ + url: '', + method: 'GET', + data: { policy_id : policy_id , client_id: client_id}, + success: function(response) { + if (response) { + let jsonObject = JSON.parse(response); + Object.keys(jsonObject).forEach(function(key) { + if (key.includes("special_condition_label") || key.includes("special_condition_input")) { + if (key.includes("special_condition_label")) { + for (let index = 0; index < jsonObject[key].length; index++) { + specialCondition(); } - + } + let elements = document.getElementsByName(`${key}[]`); - } else { - element.nextElementSibling.checked = element.value ; + if (elements) { + elements.forEach((element,index) => { + element.value = jsonObject[key][index]; + }); } } - }else if(key === "Wellness" || key === "additionalsicknessbenefit"){ - let wysiwygElement = element.previousElementSibling.querySelector('.jodit-wysiwyg'); + + if (key.includes("family_floaters")) { + let checkboxes = document.querySelectorAll(`input[name="${key}[]"]`); + if (jsonObject[key]) { + jsonObject[key].forEach(element => { + let checkbox = $(`#${element}`); + if (checkbox.is(":checkbox")) { + checkbox.prop("checked", true); + } + }); + } + + } - if (wysiwygElement) { - let pTag = wysiwygElement.querySelector('p'); // Find the

tag inside the wysiwyg element - if (pTag) { - // pTag.innerHTML = ''; // Clear the content inside the

tag - pTag.innerHTML = jsonObject[key]; // Add your new content inside the

tag + let elements = document.getElementsByName(key); + if (elements && elements.length > 0) { + let element = elements[0]; // Assuming you want to update the first element with the name + + + if (element.tagName === 'INPUT' && (element.type === 'checkbox' || element.type === 'radio')) { + + if (element.type === 'checkbox') { + element.checked = jsonObject[key] === '1'; // Assuming jsonObject[key] is '1' or '0' for checkbox + } else if (element.type === 'radio') { + + if (element.value === jsonObject[key]) { + element.checked = element.value === jsonObject[key]; + + if(element.name === "family_floater") { + element.parentElement.nextElementSibling.style.display=''; + element.parentElement.parentElement.parentElement.nextElementSibling.style.display=''; + }else if(element.name === "waiverofpreexistingdiseases"){ + element.parentElement.parentElement.nextElementSibling.style.display=''; + element.parentElement.parentElement.nextElementSibling.nextElementSibling.style.display=''; + element.parentElement.parentElement.nextElementSibling.nextElementSibling.nextElementSibling.style.display=''; + element.parentElement.parentElement.nextElementSibling.nextElementSibling.nextElementSibling.nextElementSibling.style.display=''; + + } + + + } else { + element.nextElementSibling.checked = element.value ; + } + } + }else if(key === "Wellness" || key === "additionalsicknessbenefit"){ + let wysiwygElement = element.previousElementSibling.querySelector('.jodit-wysiwyg'); + + + if (wysiwygElement) { + let pTag = wysiwygElement.querySelector('p'); // Find the

tag inside the wysiwyg element + if (pTag) { + // pTag.innerHTML = ''; // Clear the content inside the

tag + pTag.innerHTML = jsonObject[key]; // Add your new content inside the

tag + } + } + // console.log(jsonObject[key]); + }else { + element.value = jsonObject[key]; } } - // console.log(jsonObject[key]); - }else { - element.value = jsonObject[key]; - } + }); + } + + + $('.jodit-wysiwyg').each(function() { + $(this).click(); + }); + + + }, + + error: function(xhr, status, error) { + console.error('Error:', status, error); } }); + } - - $('.jodit-wysiwyg').each(function() { - $(this).click(); - }); - - -}, - - error: function(xhr, status, error) { - console.error('Error:', status, error); - } }); - // $.ajax({ - // url: '' , - // type: "GET", - // data: { policy_id: policy_id, client_id: client_id }, - // dataType: 'json', - // success: function (res) { - // console.log('responce :', res); - - // if (res.status === false) { - // toastr.error(res.status); - // return; - // } - // var policy_grid_id_value = ''; - // if (res.premiumData && res.premiumData.length > 0 && res.premiumData[0].policy_grid_id) { - // policy_grid_id_value = res.premiumData[0].policy_grid_id; - // } - - // $('#grid_content_input').empty(); - // var policeGridOptionHTML = ''; - // policeGridOptionHTML += ` `; - // $.each(res.data, function(index, item) { - // policeGridOptionHTML += ''; - // }); - // $('#grid').html(policeGridOptionHTML); - - - // console.log('Length', res.premiumData.length) - // if (res.premiumData && res.premiumData.length > 0) { - - // addGridHTML(false, res.premiumData[0], res.premiumData[0].policy_grid_id); - - // res.premiumData.shift(); - // console.log(res.premiumData) - // $.each(res.premiumData, function(index, item){ - // console.log('premiumData index :',index) - // appendGridtHtml(item.policy_grid_id, item); - // }); - - // } else { - // console.log("res.premiumData is undefined, null, or empty."); - // } - - // $('#bs-example-modal-sm').modal('show'); - // }, - // error: function (xhr, status, error) { - // console.error(xhr.responseText); - // console.error(status, error); - // } - // }); -}); - - -var Count = 1 -function appendGridtHtml(ui_type = false, data = false,) { - - var html = ''; - console.log('appendGridtHtml function called '); - // console.log('Grid Content',data) - console.log('UI TYPE :', ui_type); - Count++; - var container = document.getElementById('grid_content_input'); - - if(ui_type == '3'){ - - html = ` -

-
- - -
-
- - -
-
- - -
-
- `; - - }else if(ui_type == '4'){ - - - html =` -
-
- - -
-
- - -
-
- - -
-
- - -
-
`; - - }else if(ui_type == '5'){ - - - html = ` -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
`; - - }else if(ui_type == '6'){ - - html =` -
-
- - -
-
-
- - -
-
- - -
-
- - -
-
- - -
-
-
`; - - }else if(ui_type == '7'){ - - html = ` -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
`; - - }else if(ui_type == '8'){ - - html = ` -
-
- - -
-
- - -
-
- - -
-
- - -
-
`; - - }else if(ui_type == '9'){ - - html = ` -
-
- - -
-
- - -
-
- - -
-
- - -
-
`; - - }else if(ui_type == '10'){ - - html = ` -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
`; - - }else if(ui_type == '11'){ - - html = ` -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
`; - } - - - - - container.insertAdjacentHTML('beforeend', html); - $('#gmc_add_more').hide() - $('#gmc_remove').show() - // console.log('count 1',Count) - Count-- - // console.log('count 2',Count) - $('#gmc_add_more_'+Count).hide() - Count++ - // console.log('count 3',Count) - -} - -function removebutton(index, type) { - - if(index == 0){ - var inputs = document.querySelectorAll('#grid_'+ type +' input'); - inputs.forEach(function(input) { - input.value = ''; - }); - }else{ - - var element = document.getElementById('removeChild_'+ index); - var gridContentDiv = document.getElementById('grid_content_input'); - var count = gridContentDiv.childElementCount; - - if (element) { - element.remove(); - } - - if(count == 2){ - $('#gmc_add_more').show(); - } - - index--; - $('#gmc_add_more_'+index).show(); - } - -} - diff --git a/app/Views/policy_gpa_terms.php b/app/Views/policy_gpa_terms.php index 624cca84..2168552b 100644 --- a/app/Views/policy_gpa_terms.php +++ b/app/Views/policy_gpa_terms.php @@ -1,4 +1,3 @@ - -