diff --git a/app/Controllers/EmpDataServiceController.php b/app/Controllers/EmpDataServiceController.php index 5c79e589..0e618c6f 100755 --- a/app/Controllers/EmpDataServiceController.php +++ b/app/Controllers/EmpDataServiceController.php @@ -1354,6 +1354,7 @@ class EmpDataServiceController extends BaseController $employee_data = $this->employeePolicyModel->getInceptionEmployeeDataForExportExcel($ref_data, 1); + // dd($employee_data, $excel_data); // ->select(' // employee_polices.id as emp_policy_id, @@ -1475,17 +1476,22 @@ class EmpDataServiceController extends BaseController } if ($insurer_or_tpa == 'tpa') { + if ($excel_data[$key][13] === null) { $missing_id[$key][] = [ 'row' => $key, - 'column' => 15, + 'column' => 13, + 'db_data' => "TPA ID is Must", + 'excel_data' => $excel_data[$key][13] ]; } } else if ($insurer_or_tpa == 'insurer') { if ($excel_data[$key][14] === null) { $missing_id[$key][] = [ 'row' => $key, - 'column' => 16, + 'column' => 14, + 'db_data' => "UHID or Risk ID is Must", + 'excel_data' => $excel_data[$key][14] ]; } } @@ -1591,6 +1597,7 @@ class EmpDataServiceController extends BaseController } if ($emp_value['gst'] != $excel_data[$key][16]) { + $errors[$key][] = [ 'row' => $key, 'column' => 16, @@ -1632,7 +1639,7 @@ class EmpDataServiceController extends BaseController $missing_id_count = count($missing_id); $json_missing_id = json_encode($missing_id); - // dd($error_count, $missing_id_count, $json_errors, $json_missing_id); + // dd($error_count, $missing_id_count, $json_errors, $json_missing_id, $employee_data, $excel_data); if ($missing_id_count > 0) { diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index eb2523f4..0733b1bc 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -194,11 +194,9 @@ class LeadsController extends BaseController foreach($data['policy_type_id'] as $index => $value){ - // Separate the insurer and insurer branch, handle missing or invalid data if (isset($data['insurer'][$index]) && strpos($data['insurer'][$index], '-') !== false) { list($insurer_branch_id, $insurer_id) = explode('-', $data['insurer'][$index]); - } else { $insurer_branch_id = 0; $insurer_id = 0; } @@ -210,7 +208,6 @@ class LeadsController extends BaseController $tpa_id = 0; } - // Separate the insurer and insurer branch, handle missing or invalid data if (isset($data['proposed_insurer'][$index]) && strpos($data['proposed_insurer'][$index], '-') !== false) { list($proposed_insurer_branch_id, $proposed_insurer_id) = explode('-', $data['proposed_insurer'][$index]); @@ -252,6 +249,11 @@ class LeadsController extends BaseController } $file_name = file_Upload($files[$index], $uploadFilePath); + + $last_3_years_claims = null; + if($value != 2){ + $last_3_years_claims = $data['finyear']; + } $processedData[] = [ 'lead_type' => $data['lead_type'], @@ -308,6 +310,9 @@ class LeadsController extends BaseController 'annualised_claims' => $data['annualised_claims'][$index] ?? 0, 'incurred_claims_ratio' => $data['incurred_claims_ratio'][$index] ?? 0, 'earned_claims_ratio' => $data['earned_claims_ratio'][$index] ?? 0, + 'total_si_at_incept' => $data['total_si_at_incept'][$index] ?? 0, + 'total_si_at_renewal' => $data['total_si_at_renewal'][$index] ?? 0, + 'fin_years_claims' => $last_3_years_claims, 'file_name' => $file_name, @@ -573,48 +578,71 @@ class LeadsController extends BaseController if($rfq_data['lead_type'] == 1){ - $lead_data = [ + if($rfq_data['policy_type_id'] == 2){ + $lead_data = [ - 'Insured' => $rfq_data['client_name'], - 'Policy Status' => $rfq_data['status'], + 'Insured' => $rfq_data['client_name'], + 'Policy Status' => $rfq_data['status'], - 'No of Employees' => $rfq_data['incept_emp_count'], - 'No of Dependents' => $rfq_data['incept_dept_count'], - 'Total Lives' => $rfq_data['incept_no_of_lives'], + 'No of Employees' => $rfq_data['incept_emp_count'], + 'No of Dependents' => $rfq_data['incept_dept_count'], + 'Total Lives' => $rfq_data['incept_no_of_lives'], - 'Period of Insurance ' => date('d/m/Y', strtotime($rfq_data['policy_start_date'])).' to '. date('d/m/Y', strtotime($rfq_data['policy_end_date'])), - 'Policy Run Days' => $rfq_data['policy_run_days'], - ]; + 'Period of Insurance ' => date('d/m/Y', strtotime($rfq_data['policy_start_date'])).' to '. date('d/m/Y', strtotime($rfq_data['policy_end_date'])), + 'Policy Run Days' => $rfq_data['policy_run_days'], + ]; + }else if($rfq_data['policy_type_id'] == 1){ + $lead_data = [ + 'Insured' => $rfq_data['client_name'], + 'No of Employees at Inception' => $rfq_data['incept_emp_count'], + 'Total Sum Insured at Inception ' => $rfq_data['total_si_at_incept'], + 'Policy Period' => date('d/m/Y', strtotime($rfq_data['policy_start_date'])).' to '. date('d/m/Y', strtotime($rfq_data['policy_end_date'])), + 'Policy Status' => $rfq_data['status'], + 'Existing Insurer' => $rfq_data['insurer_name'], + 'TPA ' => $rfq_data['tpa_name'], + ]; + } }else{ + if($rfq_data['policy_type_id'] == 2){ + $lead_data = [ - $lead_data = [ + 'Insured' => $rfq_data['client_name'], + 'Policy Status' => $rfq_data['status'], - 'Insured' => $rfq_data['client_name'], - 'Policy Status' => $rfq_data['status'], + 'No of Employees at Inception' => $rfq_data['incept_emp_count'], + 'No of Dependents at Inception' => $rfq_data['incept_dept_count'], + 'Total Lives at Inception ' => $rfq_data['incept_no_of_lives'], - 'No of Employees at Inception' => $rfq_data['incept_emp_count'], - 'No of Dependents at Inception' => $rfq_data['incept_dept_count'], - 'Total Lives at Inception ' => $rfq_data['incept_no_of_lives'], + 'No of Employees at Expiry' => $rfq_data['exp_emp_count'], + 'No of Dependents at Expiry' => $rfq_data['exp_dept_count'], + 'Total Lives at Expiry ' => $rfq_data['exp_no_of_lives'], - 'No of Employees at Expiry' => $rfq_data['exp_emp_count'], - 'No of Dependents at Expiry' => $rfq_data['exp_dept_count'], - 'Total Lives at Expiry ' => $rfq_data['exp_no_of_lives'], + 'No of Employees at Renewal' => $rfq_data['renewal_emp_count'], + 'No of Dependents at Renewal' => $rfq_data['renewal_dept_count'], + 'Total Lives at Renewal ' => $rfq_data['renewal_no_of_lives'], - 'No of Employees at Renewal' => $rfq_data['renewal_emp_count'], - 'No of Dependents at Renewal' => $rfq_data['renewal_dept_count'], - 'Total Lives at Renewal ' => $rfq_data['renewal_no_of_lives'], - - 'Period of Insurance ' => date('d/m/Y', strtotime($rfq_data['policy_start_date'])).' to '. date('d/m/Y', strtotime($rfq_data['policy_end_date'])), - 'Policy Run Days' => $rfq_data['policy_run_days'], - 'Inception Premium' => $rfq_data['premium_at_inception'], - 'Premium as on (Date - DD MM YYYY should be entered based on the claims dump report)' => $rfq_data['premium_date'], - 'Earned Premium' => $rfq_data['earned_premium'], - 'Incurred Claims as on (Date - DD MM YYYY should be entered based on the claims dump report)' => $rfq_data['incurred_claims_date'], - 'Annualised Claims' => $rfq_data['annualised_claims'], - 'Incurred Claims Ratio' => $rfq_data['incurred_claims_ratio'], - 'Earned Claims Ratio' => $rfq_data['earned_claims_ratio'], - ]; + 'Period of Insurance ' => date('d/m/Y', strtotime($rfq_data['policy_start_date'])).' to '. date('d/m/Y', strtotime($rfq_data['policy_end_date'])), + 'Policy Run Days' => $rfq_data['policy_run_days'], + 'Inception Premium' => $rfq_data['premium_at_inception'], + 'Premium as on (Date - DD MM YYYY should be entered based on the claims dump report)' => $rfq_data['premium_date'], + 'Earned Premium' => $rfq_data['earned_premium'], + 'Incurred Claims as on (Date - DD MM YYYY should be entered based on the claims dump report)' => $rfq_data['incurred_claims_date'], + 'Annualised Claims' => $rfq_data['annualised_claims'], + 'Incurred Claims Ratio' => $rfq_data['incurred_claims_ratio'], + 'Earned Claims Ratio' => $rfq_data['earned_claims_ratio'], + ]; + }else if($rfq_data['policy_type_id'] == 1){ + $lead_data = [ + 'Insured' => $rfq_data['client_name'], + 'No of Employees at Renewal' => $rfq_data['renewal_emp_count'], + 'Total Sum Insured at Renewal ' => $rfq_data['total_si_at_renewal'], + 'Policy Period' => date('d/m/Y', strtotime($rfq_data['policy_start_date'])).' to '. date('d/m/Y', strtotime($rfq_data['policy_end_date'])), + 'Policy Status' => $rfq_data['status'], + 'Existing Insurer' => $rfq_data['insurer_name'], + 'TPA ' => $rfq_data['tpa_name'], + ]; + } } $data = json_decode($rfq_data['json'], true); diff --git a/app/Models/LeadsModel.php b/app/Models/LeadsModel.php index c9cdccbb..5867a5d0 100644 --- a/app/Models/LeadsModel.php +++ b/app/Models/LeadsModel.php @@ -80,6 +80,10 @@ class LeadsModel extends Model 'premium_amount', 'total_amount', 'cd_amount', + + 'total_si_at_incept', + 'total_si_at_renewal', + 'fin_years_claims', ]; diff --git a/app/Views/leads_form.php b/app/Views/leads_form.php index 3cc264e6..10f6e264 100644 --- a/app/Views/leads_form.php +++ b/app/Views/leads_form.php @@ -384,7 +384,7 @@ function getLeadsDataForEdit(input) { $('#contact_person_name').val(res.data.contact_person_name); $('#contact_person_mobile').val(res.data.contact_person_mobile); $('#contact_person_email').val(res.data.contact_person_email); - + $('#policy_type_id_1').val(res.data.policy_type_id).change(); $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); }, 1000) @@ -397,7 +397,6 @@ function getLeadsDataForEdit(input) { var proposed_insurer = res.data.proposed_insurer_branch_id + '-' + res.data.proposed_insurer_id; var proposed_tpa = res.data.proposed_tpa_branch_id + '-' + res.data.proposed_tpa_id; - $('#policy_type_id_1').val(res.data.policy_type_id).change(); $('#insurer_1').val(insurer).select2(); $('#tpa_1').val(tpa).select2(); $('#proposed_insurer_1').val(proposed_insurer).select2(); @@ -433,6 +432,9 @@ function getLeadsDataForEdit(input) { $('#file_name_display').text('Upload File Name : ' + res.data.file_name); // $('#file_name').val(res.data.file_name); + $('#total_si_at_incept_' + increment).val(res.data.total_si_at_incept); + $('#total_si_at_renewal_' + increment).val(res.data.total_si_at_renewal); + if (res.data.salse_person_id) { selecSalsePerson(res.data.salse_person_id); @@ -477,6 +479,33 @@ function getLeadsDataForEdit(input) { } } + if(res.data.policy_type_id != 2){ + + $('.gpa_hide_div_'+increment).hide(); + $('.gpa_show_div_'+increment).show(); + $('.gpa_div_elements_'+increment).show(); + $('.emp_title').text('No of Employees at Inception'); + + let claimExperience = JSON.parse(res.data.fin_years_claims); + + claimExperience[0].finyear.forEach((data, index) => { + const year = document.querySelector(`#${["first", "second", "third"][index]}_year_${increment}`); + const claimAmount = document.querySelector(`#${["first", "second", "third"][index]}_claim_amount_${increment}`); + const claimStatus = document.querySelector(`#${["first", "second", "third"][index]}_claim_status_${increment}`); + const causeOfDeath = document.querySelector(`#${["first", "second", "third"][index]}_casue_of_death_${increment}`); + const deathDate = document.querySelector(`#${["first", "second", "third"][index]}_death_date_${increment}`); + + if (year) year.value = data.year; + if (claimAmount) claimAmount.value = data.claim_amount; + if (claimStatus) claimStatus.value = data.status; + if (causeOfDeath) causeOfDeath.value = data.cause_of_death; + if (deathDate) deathDate.value = data.death_date; + }); + + }else{ + $('.gpa_hide_div_'+increment).show(); + } + } else { console.log('No data found'); @@ -625,7 +654,6 @@ function getPolicyData(client_policy_id, increment_count) { } } - // Salse team user list data function selecSalsePerson(salse_person_ids) { @@ -671,6 +699,22 @@ function addHTMLInput(check) { const newRow8 = document.createElement('div'); newRow8.className = 'form-row dynamic-form-row'; + const newRow6 = document.createElement('div'); + newRow6.className = `form-row dynamic-form-row gpa_div_elements_${increment}`; + newRow6.style.display = 'none'; + + const newRow9 = document.createElement('div'); + newRow9.className = `form-row dynamic-form-row gpa_div_elements_${increment}`; + newRow9.style.display = 'none'; + + const newRow10 = document.createElement('div'); + newRow10.className = `form-row dynamic-form-row gpa_div_elements_${increment}`; + newRow10.style.display = 'none'; + + const newRow11 = document.createElement('div'); + newRow11.className = `form-row dynamic-form-row gpa_div_elements_${increment}`; + newRow11.style.display = 'none'; + // Add an