CHANGE_LEAD_MODULE_WORKING : RV
This commit is contained in:
parent
0ad5e8d5cc
commit
ad2b8e9782
@ -169,6 +169,13 @@ class LeadsController extends BaseController
|
||||
{
|
||||
// print_r($data); die;
|
||||
$processedData = [];
|
||||
$uploadFilePath = WRITEPATH . 'uploads/lead_files/';
|
||||
|
||||
// Get all uploaded files for 'file_name[]'
|
||||
$files = $this->request->getFileMultiple('file_name');
|
||||
|
||||
// print_r($files); die;
|
||||
|
||||
foreach($data['policy_type_id'] as $index => $value){
|
||||
|
||||
|
||||
@ -215,7 +222,21 @@ class LeadsController extends BaseController
|
||||
}else{
|
||||
$policy_end_date = null;
|
||||
}
|
||||
|
||||
|
||||
if(!empty($data['incurred_claims_date'][$index])){
|
||||
$incurred_claims_date = change_date_format($data['incurred_claims_date'][$index], 'd/m/Y', 'Y-m-d');
|
||||
}else{
|
||||
$incurred_claims_date = null;
|
||||
}
|
||||
|
||||
if(!empty($data['premium_date'][$index])){
|
||||
$premium_date = change_date_format($data['premium_date'][$index], 'd/m/Y', 'Y-m-d');
|
||||
}else{
|
||||
$premium_date = null;
|
||||
}
|
||||
|
||||
$file_name = file_Upload($files[$index], $uploadFilePath);
|
||||
|
||||
$processedData[] = [
|
||||
'lead_type' => $data['lead_type'],
|
||||
'issuer' => $data['issuer'],
|
||||
@ -244,13 +265,36 @@ class LeadsController extends BaseController
|
||||
'policy_start_date' => $policy_start_date,
|
||||
'policy_end_date' => $policy_end_date,
|
||||
'no_of_lives' => $data['no_of_lives'][$index] ?? null,
|
||||
'claims' => $data['claims'][$index] ?? null,
|
||||
'incurred_claims' => $data['incurred_claims'][$index] ?? 0,
|
||||
'location' => $data['location'][$index] ?? null,
|
||||
'proposed_insurer_id' => $proposed_insurer_id ?? 0,
|
||||
'proposed_insurer_branch_id' => $proposed_insurer_branch_id ?? 0,
|
||||
'proposed_tpa_id' => $proposed_tpa_id ?? 0,
|
||||
'proposed_tpa_branch_id' => $proposed_tpa_branch_id ?? 0,
|
||||
|
||||
'renewal_emp_count' => $data['renewal_emp_count'][$index] ?? 0,
|
||||
'renewal_dept_count' => $data['renewal_dept_count'][$index] ?? 0,
|
||||
'renewal_no_of_lives' => $data['renewal_no_of_lives'][$index] ?? 0,
|
||||
'incept_emp_count' => $data['incept_emp_count'][$index] ?? 0,
|
||||
'incept_dept_count' => $data['incept_dept_count'][$index] ?? 0,
|
||||
'incept_no_of_lives' => $data['incept_no_of_lives'][$index] ?? 0,
|
||||
'exp_emp_count' => $data['exp_emp_count'][$index] ?? 0,
|
||||
'exp_dept_count' => $data['exp_dept_count'][$index] ?? 0,
|
||||
'exp_no_of_lives' => $data['exp_no_of_lives'][$index] ?? 0,
|
||||
|
||||
'incurred_claims_date' => $incurred_claims_date,
|
||||
'paid_claims' => $data['paid_claims'][$index] ?? 0,
|
||||
'outstanding_claims' => $data['outstanding_claims'][$index] ?? 0,
|
||||
'policy_run_days' => $data['policy_run_days'][$index] ?? 0,
|
||||
'premium_at_inception' => $data['premium_at_inception'][$index] ?? 0,
|
||||
'premium_date' => $premium_date,
|
||||
'earned_premium' => $data['earned_premium'][$index] ?? 0,
|
||||
'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,
|
||||
|
||||
'file_name' => $file_name,
|
||||
|
||||
'status' => $data['status'] ?? null,
|
||||
'notes' => $data['notes'] ?? null,
|
||||
];
|
||||
@ -332,13 +376,13 @@ class LeadsController extends BaseController
|
||||
|
||||
$data['rfq_data'] = $this->RFQModel
|
||||
->where('lead_id', $id)
|
||||
->where('type', $type)
|
||||
// ->where('type', $type)
|
||||
->where('is_active', 1)
|
||||
->first();
|
||||
|
||||
$data['rfq_count'] = $this->RFQModel
|
||||
->where('lead_id', $id)
|
||||
->where('type', 1)
|
||||
// ->where('type', 1)
|
||||
->where('is_active', 1)
|
||||
->countAllResults();
|
||||
|
||||
@ -352,7 +396,7 @@ class LeadsController extends BaseController
|
||||
|
||||
$data['lead_id'] = $id;
|
||||
$lead_data = $this->leadsModel
|
||||
->select('leads.*, policy_type.question_json')
|
||||
->select('leads.*, policy_type.question_json, policy_type.policy_type')
|
||||
->join('policy_type', 'leads.policy_type_id = policy_type.id')
|
||||
->where('leads.id', $id)
|
||||
->where('leads.is_active', 1)
|
||||
@ -376,6 +420,8 @@ class LeadsController extends BaseController
|
||||
}
|
||||
|
||||
public function createRFQ(){
|
||||
|
||||
// print_r($this->request->getPost('json')); die();
|
||||
|
||||
$data = $this->request->getPost();
|
||||
$lead_id = $data['lead_id'];
|
||||
@ -459,7 +505,8 @@ class LeadsController extends BaseController
|
||||
{
|
||||
$rfq_data = $this->RFQModel->getRFQTableDataWithLeadIDAndType($lead_id, $type);
|
||||
|
||||
// dd($rfq_data, $lead_id, $type);
|
||||
// dd($rfq_data, $lead_id, $type, $propsal_and_insurer);
|
||||
// print_r($propsal_and_insurer); die;
|
||||
|
||||
$lead_data = [
|
||||
'Insured' => $rfq_data['client_name'],
|
||||
@ -470,11 +517,13 @@ class LeadsController extends BaseController
|
||||
$data = json_decode($rfq_data['json'], true);
|
||||
|
||||
if($type == 2){
|
||||
$data = $this->convertJsonForQCR($data, 'stc');
|
||||
$data = $this->convertJsonForQCR($data, $type);
|
||||
if($propsal_and_insurer !== null){
|
||||
list($proposal_key, $insurer_key) = explode('-', $propsal_and_insurer, 2);
|
||||
$data = $this->transformProposelData($data, $proposal_key, $insurer_key);
|
||||
}
|
||||
}else if($type == 1){
|
||||
$data = $this->convertJsonForQCR($data, $type);
|
||||
}
|
||||
|
||||
$spreadsheet = new Spreadsheet();
|
||||
@ -687,11 +736,13 @@ class LeadsController extends BaseController
|
||||
//gather lead info
|
||||
$lead_data = $this->leadsModel
|
||||
->select('leads.*,policy_type.long_name,policy_type.policy_type,user_profiles.email as created_person_email')
|
||||
->join('policy_type', 'leads.policy_type_id = policy_type.id')
|
||||
->join('user_profiles', 'leads.created_by = user_profiles.id')
|
||||
->join('policy_type', 'leads.policy_type_id = policy_type.id', 'left')
|
||||
->join('user_profiles', 'leads.created_by = user_profiles.id', 'left')
|
||||
->where('leads.id', $lead_id)
|
||||
->first();
|
||||
|
||||
// print_r($lead_data ); die;
|
||||
|
||||
$cc_mails = [];
|
||||
|
||||
//get CC Mails
|
||||
@ -699,6 +750,7 @@ class LeadsController extends BaseController
|
||||
|
||||
$cc_data = isset($params['cc']) ? $params['cc'] : "";
|
||||
$param_cc_mail = json_decode($cc_data, true);
|
||||
|
||||
if (isset($param_cc_mail) && is_array($param_cc_mail) && count($param_cc_mail) > 0) {
|
||||
// Fetch user data where ID is in the param_cc_mail array
|
||||
$userData = $this->userModel
|
||||
@ -714,13 +766,13 @@ class LeadsController extends BaseController
|
||||
// print_r(json_encode($cc_mails)); die;
|
||||
|
||||
// If no emails were found, return an error response
|
||||
if (empty($cc_mails)) {
|
||||
return $this->respond(['status' => 'failed','code' => 400,'data' => '','message' => 'No valid CC mail addresses found!'], 200);
|
||||
}
|
||||
// if (empty($cc_mails)) {
|
||||
// return $this->respond(['status' => 'failed','code' => 400,'data' => '','message' => 'No valid CC mail addresses found!'], 200);
|
||||
// }
|
||||
|
||||
} else {
|
||||
// Handle case where param_cc_mail is not valid
|
||||
return $this->respond(['status' => 'failed','code' => 400,'data' => '','message' => 'CC mail not found!'], 200);
|
||||
// return $this->respond(['status' => 'failed','code' => 400,'data' => '','message' => 'CC mail not found!'], 200);
|
||||
}
|
||||
}
|
||||
|
||||
@ -793,7 +845,12 @@ class LeadsController extends BaseController
|
||||
|
||||
$data = [
|
||||
'proposel_data' => json_encode($lead_update_data),
|
||||
'status' => 'won'
|
||||
'status' => 'won',
|
||||
'placement_date' => change_date_format($params['placement_date'], 'd/m/Y', 'Y-m-d'),
|
||||
'utr_no' => $params['utr_no'],
|
||||
'premium_amount' => $params['premium_amount'],
|
||||
'total_amount' => $params['total_amount'],
|
||||
'cd_amount' => $params['cd_amount'],
|
||||
];
|
||||
|
||||
$this->leadsModel->where('id', $lead_id)->set($data)->update();
|
||||
@ -835,7 +892,7 @@ class LeadsController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
function transformProposelData($data, $proposel, $insurer){
|
||||
public function transformProposelData($data, $proposel, $insurer){
|
||||
|
||||
// print_r($data['premium_data']['data']); die;
|
||||
|
||||
@ -943,14 +1000,17 @@ class LeadsController extends BaseController
|
||||
|
||||
}
|
||||
|
||||
function convertJsonForQCR($json, $type)
|
||||
public function convertJsonForQCR($json, $type)
|
||||
{
|
||||
if ($json) {
|
||||
// Deep copy of JSON
|
||||
$first_json = json_decode(json_encode($json), true);
|
||||
|
||||
// dd($first_json);
|
||||
|
||||
// Column-wise Check: Remove headers and relevant data if qcr == 0
|
||||
foreach ($json['proposal_data']['over_all_column_data'] as $proposalKey => $proposalData) {
|
||||
|
||||
if ($proposalData['stc'] == 0 || $proposalData['stc'] === false) {
|
||||
// Remove matching parentHeader in headers
|
||||
foreach ($first_json['table_data']['headers'] as $index => $header) {
|
||||
@ -969,7 +1029,7 @@ class LeadsController extends BaseController
|
||||
// Remove proposalKey from over_all_column_data
|
||||
unset($first_json['proposal_data']['over_all_column_data'][$proposalKey]);
|
||||
|
||||
if($type == 'stc'){
|
||||
if($type == 2){
|
||||
// Remove proposalKey from premium_data
|
||||
unset($first_json['premium_data']['data'][$proposalKey]);
|
||||
}
|
||||
@ -996,7 +1056,7 @@ class LeadsController extends BaseController
|
||||
// Remove insurer from proposal's insurers array
|
||||
unset($first_json['proposal_data']['over_all_column_data'][$proposalKey]['insurers'][$insurerIndex]);
|
||||
|
||||
if($type == 'stc'){
|
||||
if($type == 2){
|
||||
unset($first_json['premium_data']['data'][$proposalKey][$insurer['display_name']]);
|
||||
}
|
||||
}
|
||||
@ -1302,4 +1362,11 @@ class LeadsController extends BaseController
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
public function transformMailContent()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@ -37,7 +37,7 @@ class LeadsModel extends Model
|
||||
'policy_start_date',
|
||||
'policy_end_date',
|
||||
'no_of_lives',
|
||||
'claims',
|
||||
'incurred_claims',
|
||||
'location',
|
||||
'proposed_insurer_id',
|
||||
'proposed_insurer_branch_id',
|
||||
@ -52,6 +52,34 @@ class LeadsModel extends Model
|
||||
'updated_by',
|
||||
'is_active',
|
||||
'is_client_created',
|
||||
|
||||
'renewal_emp_count',
|
||||
'renewal_dept_count',
|
||||
'renewal_no_of_lives',
|
||||
'incept_emp_count',
|
||||
'incept_dept_count',
|
||||
'incept_no_of_lives',
|
||||
'exp_emp_count',
|
||||
'exp_dept_count',
|
||||
'exp_no_of_lives',
|
||||
'file_name',
|
||||
|
||||
'incurred_claims_date',
|
||||
'paid_claims',
|
||||
'outstanding_claims',
|
||||
'policy_run_days',
|
||||
'premium_at_inception',
|
||||
'premium_date',
|
||||
'earned_premium',
|
||||
'annualised_claims',
|
||||
'incurred_claims_ratio',
|
||||
'earned_claims_ratio',
|
||||
|
||||
'placement_date',
|
||||
'utr_no',
|
||||
'premium_amount',
|
||||
'total_amount',
|
||||
'cd_amount',
|
||||
];
|
||||
|
||||
|
||||
|
||||
@ -76,7 +76,7 @@ class RFQModel extends Model
|
||||
->join('tpa', 'leads.tpa_id = tpa.id', 'left')
|
||||
->join('tpa_branch', 'leads.tpa_branch_id = tpa_branch.id', 'left')
|
||||
->where('rfq.lead_id', $lead_id)
|
||||
->where('rfq.type', $type)
|
||||
// ->where('rfq.type', $type)
|
||||
->where('rfq.is_active', 1)
|
||||
->first();
|
||||
|
||||
|
||||
@ -32,6 +32,7 @@
|
||||
color: white !important;
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<div class="row" id="leads_form" style="display:none;">
|
||||
@ -404,9 +405,33 @@ function getLeadsDataForEdit(input) {
|
||||
$('#policy_start_date_1').val(res.data.policy_start_date);
|
||||
$('#policy_end_date_1').val(res.data.policy_end_date);
|
||||
$('#no_of_lives').val(res.data.no_of_lives);
|
||||
$('#claims').val(res.data.claims);
|
||||
$('#incurred_claims').val(res.data.incurred_claims);
|
||||
$('#location').val(res.data.location);
|
||||
|
||||
let increment = 1;
|
||||
// Other fields, set dynamically based on increment
|
||||
$('#renewal_emp_count_' + increment).val(res.data.renewal_emp_count);
|
||||
$('#renewal_dept_count_' + increment).val(res.data.renewal_dept_count);
|
||||
$('#renewal_no_of_lives_' + increment).val(res.data.renewal_no_of_lives);
|
||||
$('#incept_emp_count_' + increment).val(res.data.incept_emp_count);
|
||||
$('#incept_dept_count_' + increment).val(res.data.incept_dept_count);
|
||||
$('#incept_no_of_lives_' + increment).val(res.data.incept_no_of_lives);
|
||||
$('#exp_emp_count_' + increment).val(res.data.exp_emp_count);
|
||||
$('#exp_dept_count_' + increment).val(res.data.exp_dept_count);
|
||||
$('#exp_no_of_lives_' + increment).val(res.data.exp_no_of_lives);
|
||||
|
||||
$('#incurred_claim_date_' + increment).val(res.data.incurred_claims_date);
|
||||
$('#paid_claims_' + increment).val(res.data.paid_claims);
|
||||
$('#outstanding_claims_' + increment).val(res.data.outstanding_claims);
|
||||
$('#policy_run_days_' + increment).val(res.data.policy_run_days);
|
||||
$('#premium_at_inception_' + increment).val(res.data.premium_at_inception);
|
||||
$('#premium_date_' + increment).val(res.data.premium_date);
|
||||
$('#earned_premium_' + increment).val(res.data.earned_premium);
|
||||
$('#annualised_claims_' + increment).val(res.data.annualised_claims);
|
||||
$('#incurred_claims_ratio_' + increment).val(res.data.incurred_claims_ratio);
|
||||
$('#earned_claims_ratio_' + increment).val(res.data.earned_claims_ratio);
|
||||
$('#file_name_display').text('Upload File Name : ' + res.data.file_name);
|
||||
|
||||
|
||||
if (res.data.salse_person_id) {
|
||||
selecSalsePerson(res.data.salse_person_id);
|
||||
@ -419,12 +444,36 @@ function getLeadsDataForEdit(input) {
|
||||
$('#freshDiv').hide();
|
||||
$('.proposed_div').show().find('select, input').attr('required', 'required');
|
||||
$('#policy_end_date, #policy_start_date, #claim').removeAttr('required');
|
||||
$('.freashDiv').show()
|
||||
$('.renewalDiv').hide()
|
||||
|
||||
$('.emp_title').text('No of Employees at Inception')
|
||||
$('.depnd_title').text(' No of Dependents at Inception')
|
||||
$('.total_title').text('Total Lives at Inception')
|
||||
|
||||
} else {
|
||||
$('#renewalDiv').find('select, input').removeAttr('required');
|
||||
$('#freshDiv').find('select, input').attr('required', 'required');
|
||||
$('#renewalDiv').hide();
|
||||
$('#freshDiv').show();
|
||||
$('.proposed_div').hide().find('select, input').removeAttr('required');
|
||||
|
||||
if(res.data.lead_type == 1){
|
||||
$('.freashDiv').hide()
|
||||
$('.renewalDiv').show()
|
||||
|
||||
$('.emp_title').text('No of Employees')
|
||||
$('.depnd_title').text('No of Dependents')
|
||||
$('.total_title').text('Total Lives')
|
||||
}else{
|
||||
$('.freashDiv').show()
|
||||
$('.renewalDiv').hide()
|
||||
|
||||
$('.emp_title').text('No of Employees at Inception')
|
||||
$('.depnd_title').text(' No of Dependents at Inception')
|
||||
$('.total_title').text('Total Lives at Inception')
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -576,7 +625,6 @@ function getPolicyData(client_policy_id, increment_count) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Salse team user list data
|
||||
function selecSalsePerson(salse_person_ids) {
|
||||
|
||||
@ -604,11 +652,29 @@ function addHTMLInput(check) {
|
||||
const newRow = document.createElement('div');
|
||||
newRow.className = 'form-row dynamic-form-row';
|
||||
|
||||
const newRow2 = document.createElement('div');
|
||||
newRow2.className = 'form-row dynamic-form-row freashDiv';
|
||||
|
||||
const newRow3 = document.createElement('div');
|
||||
newRow3.className = 'form-row dynamic-form-row';
|
||||
|
||||
const newRow4 = document.createElement('div');
|
||||
newRow4.className = 'form-row dynamic-form-row freashDiv';
|
||||
|
||||
const newRow5 = document.createElement('div');
|
||||
newRow5.className = 'form-row dynamic-form-row';
|
||||
|
||||
const newRow7 = document.createElement('div');
|
||||
newRow7.className = 'form-row dynamic-form-row';
|
||||
|
||||
const newRow8 = document.createElement('div');
|
||||
newRow8.className = 'form-row dynamic-form-row';
|
||||
|
||||
// Add an <hr> element
|
||||
const hrElement = document.createElement('hr');
|
||||
container.appendChild(hrElement);
|
||||
|
||||
// Set inner HTML with necessary input fields
|
||||
// Main div
|
||||
newRow.innerHTML += `
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
@ -656,28 +722,77 @@ function addHTMLInput(check) {
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="no_of_lives">No of Lives <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="no_of_lives" name="no_of_lives[]" placeholder="Enter Lives" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 proposed_div">
|
||||
<label for="policy_start_date_${increment}">Date of Commencement <span class="text-danger"></span></label>
|
||||
<input type="text" class="form-control policy_start_date" id="policy_start_date_${increment}" name="policy_start_date[]" placeholder="Enter DOC">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 proposed_div">
|
||||
<div class="form-group col-md-3">
|
||||
<label for="policy_end_date_${increment}">Date of Expiry <span class="text-danger"></span></label>
|
||||
<input type="text" class="form-control policy_end_date" id="policy_end_date_${increment}" name="policy_end_date[]" placeholder="Enter DOE">
|
||||
</div>
|
||||
`;
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="claims">Claims <span class="text-danger"></span></label>
|
||||
<input type="text" class="form-control" id="claims" name="claims[]" placeholder="Enter Claims">
|
||||
// Incured claim div
|
||||
newRow8.innerHTML += `
|
||||
|
||||
<div class="form-group col-md-3 freashDiv" style="display: none;">
|
||||
<label for="incurred_claim_date_${increment}">Incurred Claim Date<span class="text-danger"></span></label>
|
||||
<input type="text" class="form-control incurred_claim" id="incurred_claim_date_${increment}" name="incurred_claim_date[]" placeholder="Enter DOE">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<div class="form-group col-md-3 freashDiv" style="display: none;">
|
||||
<label for="paid_claims_${increment}">Paid Claims<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="paid_claims_${increment}" name="paid_claims[]" placeholder="Enter Paid Claims" oninput="incurredClaimSum(this)">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 freashDiv" style="display: none;">
|
||||
<label for="outstanding_claims_${increment}">Outstanding Claims<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="outstanding_claims_${increment}" name="outstanding_claims[]" placeholder="Enter Outstanding Claims" oninput="incurredClaimSum(this)">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 freashDiv" style="display: none;">
|
||||
<label for="incurred_claims_${increment}">Incurred Claim<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="incurred_claims_${increment}" name="incurred_claims[]" placeholder="Enter Incurred Claim" oninput="incurredClaimSum(this)">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 freashDiv" style="display: none;">
|
||||
<label for="policy_run_days_${increment}">Policy Run Days<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="policy_run_days_${increment}" name="policy_run_days[]" placeholder="Enter Policy Run Days" oninput="earnedPremiumCalc(this)">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 freashDiv" style="display: none;">
|
||||
<label for="premium_at_inception_${increment}">Premium Paid at Inception<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="premium_at_inception_${increment}" name="premium_at_inception[]" placeholder="Enter Premium Paid" oninput="earnedPremiumCalc(this)">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 freashDiv" style="display: none;">
|
||||
<label for="premium_date_${increment}">Premium Date<span class="text-danger"></span></label>
|
||||
<input type="text" class="form-control" id="premium_date_${increment}" name="premium_date[]" placeholder="Enter Premium Date">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 freashDiv" style="display: none;">
|
||||
<label for="earned_premium_${increment}">Earned Premium<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="earned_premium_${increment}" name="earned_premium[]" placeholder="Enter Earned Premium" oninput="incurredClaimSum(this)">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 freashDiv" style="display: none;">
|
||||
<label for="annualised_claims_${increment}">Annualised Claims<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="annualised_claims_${increment}" name="annualised_claims[]" placeholder="Enter Annualised Claims" >
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 freashDiv" style="display: none;">
|
||||
<label for="incurred_claims_ratio_${increment}">Incurred Claims Ratio<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="incurred_claims_ratio_${increment}" name="incurred_claims_ratio[]" placeholder="Enter Incurred Claims Ratio" >
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 freashDiv" style="display: none;">
|
||||
<label for="earned_claims_ratio_${increment}">Earned Claims Ratio<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="earned_claims_ratio_${increment}" name="earned_claims_ratio[]" placeholder="Enter Earned Claims Ratio" >
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 freashDiv">
|
||||
<label for="location">Location <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="location" name="location[]" placeholder="Enter Location" required>
|
||||
<input type="text" class="form-control" id="location" name="location[]" placeholder="Enter Location" >
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 proposed_div" style="display: none;">
|
||||
@ -708,13 +823,99 @@ function addHTMLInput(check) {
|
||||
</select>
|
||||
</div>
|
||||
|
||||
`;
|
||||
|
||||
//renewal div
|
||||
newRow2.innerHTML += `
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="renewal_emp_count_${increment}"> No of Employees at Renewal <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="renewal_emp_count_${increment}" name="renewal_emp_count[]" placeholder="Enter Lives" >
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="renewal_dept_count_${increment}"> No of Dependents at Renewal <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="renewal_dept_count_${increment}" name="renewal_dept_count[]" placeholder="Enter Lives" >
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="renewal_no_of_lives_${increment}"> Total Lives at Renewal <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="renewal_no_of_lives_${increment}" name="renewal_no_of_lives[]" placeholder="Enter Lives" >
|
||||
</div>
|
||||
`;
|
||||
|
||||
//inception div
|
||||
newRow3.innerHTML += `
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="incept_emp_count_${increment}" class="emp_title"> No of Employees at Inception <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="incept_emp_count_${increment}" name="incept_emp_count[]" placeholder="Enter Lives" >
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="incept_dept_count_${increment}" class="depnd_title"> No of Dependents at Inception <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="incept_dept_count_${increment}" name="incept_dept_count[]" placeholder="Enter Lives" >
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="incept_no_of_lives_${increment}" class="total_title"> Total Lives at Inception <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="incept_no_of_lives_${increment}" name="incept_no_of_lives[]" placeholder="Enter Lives" >
|
||||
</div>
|
||||
`;
|
||||
|
||||
//expiry div
|
||||
newRow4.innerHTML += `
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="exp_emp_count_${increment}"> No of Employees at Expiry <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="exp_emp_count_${increment}" name="exp_emp_count[]" placeholder="Enter Lives" >
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="exp_dept_count_${increment}"> No of Dependents at Expiry <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="exp_dept_count_${increment}" name="exp_dept_count[]" placeholder="Enter Lives" >
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="exp_no_of_lives_${increment}"> Total Lives at Expiry <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="exp_no_of_lives_${increment}" name="exp_no_of_lives[]" placeholder="Enter Lives" >
|
||||
</div>
|
||||
|
||||
`;
|
||||
|
||||
//file upload div
|
||||
newRow7.innerHTML += `
|
||||
<div class="form-group col-md-3">
|
||||
<label for="file_upload">File Upload<span class="text-danger">*</span></label>
|
||||
<input type="file" class="form-control" id="file_name" name="file_name[]" required>
|
||||
<span class="text-danger" id="file_name_display"></span>
|
||||
</div>
|
||||
`;
|
||||
|
||||
//button div
|
||||
newRow5.innerHTML += `
|
||||
|
||||
<div class="form-group col-md-12 btnDiv" style="position: relative;top: 28px;float: right;text-align: end;">
|
||||
<a class="btn btn-danger waves-effect waves-light" onclick="removeHTMLInput(this)">x</a>
|
||||
<a class="btn btn-primary waves-effect waves-light mr-1" onclick="addHTMLInput(1)">+</a>
|
||||
</div>
|
||||
`;
|
||||
|
||||
|
||||
|
||||
container.appendChild(newRow);
|
||||
container.appendChild(newRow8);
|
||||
|
||||
const hrElement2 = document.createElement('hr');
|
||||
container.appendChild(hrElement2);
|
||||
|
||||
container.appendChild(newRow3);
|
||||
container.appendChild(newRow2);
|
||||
container.appendChild(newRow4);
|
||||
|
||||
container.appendChild(newRow7);
|
||||
|
||||
container.appendChild(newRow5);
|
||||
|
||||
|
||||
var lead_type = $('#lead_type').val();
|
||||
@ -722,9 +923,32 @@ function addHTMLInput(check) {
|
||||
if (lead_type == 2) {
|
||||
// $('.proposed_div').show().find('select, input').attr('required', 'required');
|
||||
$('.proposed_div').show();
|
||||
$('.freashDiv').show()
|
||||
$('.renewalDiv').hide()
|
||||
|
||||
$('.emp_title').text('No of Employees at Inception')
|
||||
$('.depnd_title').text(' No of Dependents at Inception')
|
||||
$('.total_title').text('Total Lives at Inception')
|
||||
|
||||
|
||||
} else {
|
||||
// $('.proposed_div').hide().find('select, input').removeAttr('required');
|
||||
$('.proposed_div').hide()
|
||||
|
||||
if(lead_type == 1){
|
||||
$('.freashDiv').hide()
|
||||
$('.renewalDiv').show()
|
||||
$('.emp_title').text('No of Employees')
|
||||
$('.depnd_title').text('No of Dependents')
|
||||
$('.total_title').text('Total Lives')
|
||||
}else{
|
||||
$('.freashDiv').show()
|
||||
$('.renewalDiv').hide()
|
||||
$('.emp_title').text('No of Employees at Inception')
|
||||
$('.depnd_title').text(' No of Dependents at Inception')
|
||||
$('.total_title').text('Total Lives at Inception')
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Scroll the newly added select into view and focus on it
|
||||
@ -747,6 +971,24 @@ function addHTMLInput(check) {
|
||||
policy_end_date.setFullYear(policy_end_date.getFullYear() + 1);
|
||||
policy_end_date.setDate(policy_end_date.getDate() - 1); // Set end date to last day of selected year
|
||||
policy_end_datePicker.setDate(policy_end_date);
|
||||
|
||||
console.log('this object', this);
|
||||
console.log('id of this element:', this.element);
|
||||
console.log('id of this element:', this.element.id);
|
||||
|
||||
let increment = this.element.id.split('_').pop();
|
||||
console.log(increment); // Outputs: 1
|
||||
|
||||
|
||||
console.log('increment', increment);
|
||||
console.log('policy_start_datePicker selectedDates', selectedDates);
|
||||
console.log('policy_start_datePicker incurred_claim_', $("#incurred_claim_" + increment).val());
|
||||
|
||||
// Recalculate policy_run_days if incurred claim date is already selected
|
||||
if ($("#incurred_claim_date_" + increment).val()) {
|
||||
console.log('policy_start_datePicker selectedDates', selectedDates);
|
||||
calculatePolicyRunDays(increment);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -755,6 +997,34 @@ function addHTMLInput(check) {
|
||||
allowInput: false
|
||||
});
|
||||
|
||||
var incurred_claim_datepicker = flatpickr("#incurred_claim_date_" + increment, {
|
||||
dateFormat: "d/m/Y",
|
||||
allowInput: false,
|
||||
onChange: function(selectedDates) {
|
||||
|
||||
console.log('this object', this);
|
||||
console.log('id of this element:', this.id);
|
||||
|
||||
let increment = this.element.id.split('_').pop();
|
||||
console.log(increment); // Outputs: 1
|
||||
|
||||
console.log('selectedDates', selectedDates);
|
||||
console.log('policy_start_date_', $("#policy_start_date_" + increment).val());
|
||||
|
||||
// Recalculate policy_run_days if policy start date is already selected
|
||||
if ($("#policy_start_date_" + increment).val()) {
|
||||
|
||||
console.log('selectedDates', selectedDates);
|
||||
calculatePolicyRunDays(increment);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var premium_date_datepicker = flatpickr("#premium_date_" + increment, {
|
||||
dateFormat: "d/m/Y",
|
||||
allowInput: false
|
||||
});
|
||||
|
||||
$('#source_policy_id').on('change', function(){
|
||||
let client_policy_id = $(this).val();
|
||||
console.log('client_policy_id', client_policy_id)
|
||||
@ -790,6 +1060,97 @@ function removeHTMLInput(element)
|
||||
}
|
||||
}
|
||||
|
||||
function calculatePolicyRunDays(increment) {
|
||||
|
||||
console.log('calculatePolicyRunDays function called');
|
||||
|
||||
var policyStartDate = flatpickr.parseDate($("#policy_start_date_" + increment).val(), "d/m/Y");
|
||||
var incurredClaimDate = flatpickr.parseDate($("#incurred_claim_" + increment).val(), "d/m/Y");
|
||||
|
||||
console.log('policyStartDate', policyStartDate)
|
||||
console.log('incurredClaimDate', incurredClaimDate)
|
||||
|
||||
if (policyStartDate && incurredClaimDate) {
|
||||
var timeDiff = incurredClaimDate - policyStartDate; // Time difference in milliseconds
|
||||
console.log('timeDiff', timeDiff);
|
||||
var daysDiff = Math.ceil(timeDiff / (1000 * 60 * 60 * 24)); // Convert to days and add 1
|
||||
console.log('daysDiff', daysDiff);
|
||||
$("#policy_run_days_" + increment).val(daysDiff); // Set value in the policy_run_days_ input
|
||||
}
|
||||
}
|
||||
|
||||
function incurredClaimSum(input) {
|
||||
|
||||
let increment = input.id.split('_').pop(); // Extract the increment part
|
||||
console.log('increment', increment);
|
||||
|
||||
// Retrieve and convert the values to numbers, fallback to 0 if empty or invalid
|
||||
let paid_claims = Number($('#paid_claims_' + increment).val()) || 0;
|
||||
console.log('paid_claims', paid_claims);
|
||||
|
||||
let outstanding_claims = Number($('#outstanding_claims_' + increment).val()) || 0;
|
||||
console.log('outstanding_claims', outstanding_claims);
|
||||
|
||||
// Calculate the incurred claim
|
||||
let incurred_claims = paid_claims + outstanding_claims;
|
||||
console.log('incurred_claims', incurred_claims);
|
||||
|
||||
// Set the calculated value
|
||||
$('#incurred_claims_' + increment).val(incurred_claims);
|
||||
|
||||
// ------------------------------------------------------------------------------------------
|
||||
|
||||
let policy_run_days = Number($('#policy_run_days_' + increment).val()) || 0;
|
||||
console.log('policy_run_days', policy_run_days);
|
||||
|
||||
// Prevent division by zero in annualised claims calculation
|
||||
let annualised_claims = policy_run_days > 0 ? incurred_claims / policy_run_days * 365 : 0;
|
||||
console.log('annualised_claims', annualised_claims);
|
||||
|
||||
$('#annualised_claims_' + increment).val(annualised_claims);
|
||||
|
||||
// ------------------------------------------------------------------------------------------
|
||||
|
||||
// Prevent division by zero in incurred claim ratio calculation
|
||||
let incurred_claim_ratio = annualised_claims > 0 ? incurred_claims / annualised_claims : 0;
|
||||
console.log('incurred_claim_ratio', incurred_claim_ratio);
|
||||
|
||||
$('#incurred_claims_ratio_' + increment).val(incurred_claim_ratio);
|
||||
|
||||
// ------------------------------------------------------------------------------------------
|
||||
|
||||
let earned_premium = Number($('#earned_premium_' + increment).val()) || 0;
|
||||
console.log('earned_premium', earned_premium);
|
||||
|
||||
// Prevent division by zero in earned claims ratio calculation
|
||||
let earned_claims_ratio = earned_premium > 0 ? incurred_claims / earned_premium : 0;
|
||||
console.log('earned_claims_ratio', earned_claims_ratio);
|
||||
|
||||
$('#earned_claims_ratio_' + increment).val(earned_claims_ratio);
|
||||
}
|
||||
|
||||
|
||||
function earnedPremiumCalc(input) {
|
||||
|
||||
let increment = input.id.split('_').pop(); // Extract the increment part
|
||||
console.log('increment', increment);
|
||||
|
||||
// Retrieve and convert the values to numbers, fallback to 0 if empty or invalid
|
||||
let premium_at_inception = Number($('#premium_at_inception_' + increment).val()) || 0;
|
||||
console.log('premium_at_inception', premium_at_inception);
|
||||
|
||||
let policy_run_days = Number($('#policy_run_days_' + increment).val()) || 0;
|
||||
console.log('policy_run_days', policy_run_days);
|
||||
|
||||
// Prevent division by zero and calculate earned premium
|
||||
let earned_premium = policy_run_days > 0 ? premium_at_inception / policy_run_days : 0;
|
||||
console.log('earned_premium', earned_premium);
|
||||
|
||||
// Set the calculated value with two decimal places
|
||||
$('#earned_premium_' + increment).val(earned_premium.toFixed(2));
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------
|
||||
|
||||
$("#leads_form_id").submit(function(event) {
|
||||
@ -876,6 +1237,8 @@ $('#lead_type').change(function() {
|
||||
$('#policy_start_date').removeAttr('required');
|
||||
$('#claims').removeAttr('required');
|
||||
$('#freshDiv').hide();
|
||||
$('.freashDiv').show()
|
||||
$('.renewalDiv').hide()
|
||||
|
||||
$('#gst').val('');
|
||||
$('#pan').val('');
|
||||
@ -885,6 +1248,10 @@ $('#lead_type').change(function() {
|
||||
$('#contact_person_mobile').val('');
|
||||
$('#contact_person_email').val('');
|
||||
|
||||
$('.emp_title').text('No of Employees at Inception')
|
||||
$('.depnd_title').text(' No of Dependents at Inception')
|
||||
$('.total_title').text('Total Lives at Inception')
|
||||
|
||||
} else {
|
||||
|
||||
$('#renewalDiv').find('select, input').removeAttr('required');
|
||||
@ -905,6 +1272,23 @@ $('#lead_type').change(function() {
|
||||
$('#client_name').val('');
|
||||
$('#client_short_name').val('');
|
||||
$('#entity_type_id').val('');
|
||||
|
||||
if(value == 1){
|
||||
$('.freashDiv').hide()
|
||||
$('.renewalDiv').show()
|
||||
|
||||
$('.emp_title').text('No of Employees')
|
||||
$('.depnd_title').text('No of Dependents')
|
||||
$('.total_title').text('Total Lives')
|
||||
}else{
|
||||
$('.freashDiv').show()
|
||||
$('.renewalDiv').hide()
|
||||
|
||||
$('.emp_title').text('No of Employees at Inception')
|
||||
$('.depnd_title').text(' No of Dependents at Inception')
|
||||
$('.total_title').text('Total Lives at Inception')
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
@ -929,6 +1313,12 @@ function tpaChange(input, unique_id) {
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------
|
||||
|
||||
function sumOfLives(input){
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------
|
||||
|
||||
function getURLParamsForReport() {
|
||||
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
|
||||
@ -102,11 +102,11 @@ table.dataTable tbody td {
|
||||
<a href="<?= base_url('/rfq/list/').$row['id'] . '/' . 1; ?>" class="dropdown-item btnEdit" data-id="<?= $row['id']; ?>">
|
||||
<i class="mdi mdi-note-text mr-2 text-muted font-18 vertical-middle"></i>RFQ
|
||||
</a>
|
||||
<?php if($row['qcr_count'] > 0) { ?>
|
||||
<!-- <?php if($row['qcr_count'] > 0) { ?>
|
||||
<a href="<?= base_url('/rfq/list/').$row['id'] . '/' . 2; ?>" class="dropdown-item btnEdit" data-id="<?= $row['id']; ?>">
|
||||
<i class="mdi mdi-note-text mr-2 text-muted font-18 vertical-middle"></i>QCR
|
||||
</a>
|
||||
<?php } ?>
|
||||
<?php } ?> -->
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user