758 lines
28 KiB
PHP
758 lines
28 KiB
PHP
<style>
|
|
.table th,
|
|
.table td {
|
|
padding: 8px;
|
|
}
|
|
|
|
table.dataTable tbody td {
|
|
padding: 4px 4px !important;
|
|
}
|
|
|
|
.col-12 {
|
|
max-width: 98% !important;
|
|
}
|
|
|
|
.dataTables_filter {
|
|
position: absolute;
|
|
}
|
|
|
|
.highlight {
|
|
border: 2px solid red;
|
|
background-color: #ffe6e6;
|
|
}
|
|
|
|
.column-header {
|
|
margin-right: 10px;
|
|
}
|
|
|
|
.form-section {
|
|
border: 1px solid #ccc;
|
|
padding: 15px;
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.row-box {
|
|
border: 1px solid #ccc;
|
|
padding: 10px;
|
|
margin-bottom: 10px;
|
|
}
|
|
|
|
|
|
.custom-dropdown-menu {
|
|
display: none;
|
|
position: absolute;
|
|
background-color: #ffffff !important;
|
|
border: 1px solid rgba(0, 0, 0, 0.15);
|
|
border-radius: 0.25rem;
|
|
padding: 0.5rem 0;
|
|
min-width: 10rem;
|
|
z-index: 9999;
|
|
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
|
}
|
|
|
|
.custom-dropdown-menu .dropdown-item {
|
|
display: block !important;
|
|
width: 100% !important;
|
|
padding: 0.5rem 1rem !important;
|
|
color: #212529 !important;
|
|
text-decoration: none !important;
|
|
background-color: transparent !important;
|
|
}
|
|
|
|
.custom-dropdown-menu .dropdown-item:hover {
|
|
background-color: #f8f9fa !important;
|
|
color: #16181b !important;
|
|
cursor: pointer !important;
|
|
}
|
|
</style>
|
|
|
|
<?php
|
|
|
|
if (isset($selected_lead_type)) {
|
|
if ($selected_lead_type == 1) {
|
|
include('leads_form.php');
|
|
} else {
|
|
include('leads_non_eb.php');
|
|
}
|
|
}
|
|
|
|
?>
|
|
|
|
|
|
<script>
|
|
var client_list = ''; // local variable for storing the client branch list
|
|
var branch_list = ''; // local variable for storing the client branch list
|
|
var policy_list = ''; // local variable for storing the client policy list
|
|
var temp_client_id = 0;
|
|
var temp_branch_id = 0;
|
|
var selected_lead_form_type = <?= isset($selected_lead_type) ? $selected_lead_type : 0 ?>;
|
|
var fileIndex = 1; // Initialize index
|
|
|
|
|
|
// select2 document ready
|
|
$(document).ready(function() {
|
|
|
|
getClientAndBranchAndPolicy()
|
|
|
|
$('#client_id').select2();
|
|
$('#client_branch_id').select2();
|
|
$('#salse_person_id').select2({
|
|
placeholder: "Select Salse Person",
|
|
});
|
|
|
|
$('#policy_type_id').select2();
|
|
|
|
$("textarea.select2-search__field").attr('rows', '1');
|
|
$("textarea.select2-search__field").css('resize', 'none');
|
|
|
|
})
|
|
|
|
//--------------------------------------------------------------------------------------------------------
|
|
|
|
function hide_list_show_add() {
|
|
$('#leads_list').hide()
|
|
$('#lead_filter_div').hide()
|
|
$('#leads_form').show()
|
|
}
|
|
|
|
function show_list_hide_add() {
|
|
$('#leads_list').show()
|
|
$('#lead_filter_div').show()
|
|
$('#leads_form').hide()
|
|
}
|
|
|
|
function getClientAndBranchAndPolicy() {
|
|
|
|
console.log('getClientAndBranchAndPolicy function called')
|
|
|
|
$.ajax({
|
|
url: '<?= base_url("/util/getClientAndBranchAndPolicy") ?>',
|
|
type: "GET",
|
|
dataType: 'json',
|
|
success: function(res) {
|
|
|
|
console.log('getClientAndBranchAndPolicy', res);
|
|
if (res.status == true) {
|
|
client_list = res.client_data;
|
|
branch_list = res.branch_data;
|
|
policy_list = res.policy_data;
|
|
appendClients(res.client_data);
|
|
} else {
|
|
console.log('No data found');
|
|
}
|
|
|
|
},
|
|
error: function(xhr, status, error) {
|
|
console.error(xhr.responseText);
|
|
console.error(status, error);
|
|
}
|
|
});
|
|
}
|
|
|
|
function appendClients(data) {
|
|
$('#client_id').empty();
|
|
|
|
$('#client_id').append($('<option>', {
|
|
value: '',
|
|
text: 'Select Client'
|
|
}));
|
|
|
|
$.each(data, function(index, item) {
|
|
var option = $('<option>', {
|
|
value: item.id,
|
|
text: item.client_name,
|
|
'data-cn': item.client_name,
|
|
'data-ct': item.client_type,
|
|
class: (item.client_type == 1) ? 'group' : (item.client_type == 2) ? 'individual' : ''
|
|
});
|
|
|
|
$('#client_id').append(option);
|
|
});
|
|
|
|
}
|
|
|
|
function appendBranch(data) {
|
|
|
|
$('#client_branch_id').empty();
|
|
|
|
$('#client_branch_id').append($('<option>', {
|
|
value: '',
|
|
text: 'Select Branch'
|
|
}));
|
|
|
|
$.each(data, function(index, item) {
|
|
|
|
var option = $('<option>', {
|
|
value: item.id,
|
|
text: item.branch_name
|
|
});
|
|
$('#client_branch_id').append(option);
|
|
});
|
|
}
|
|
|
|
function appendRenewalPolicies(data) {
|
|
|
|
console.log('appendRenewalPolicies', data);
|
|
console.log('selected_lead_form_type', selected_lead_form_type);
|
|
|
|
$('#source_policy_id').empty();
|
|
|
|
$('#source_policy_id').append($('<option>', {
|
|
value: '',
|
|
text: 'Select Policy',
|
|
}));
|
|
|
|
$.each(data, function(index, item) {
|
|
let shouldAppend = false;
|
|
|
|
if (selected_lead_form_type == 1) {
|
|
shouldAppend = (item.allocg !== "Non-EB" && item.allocg !== "Marine");
|
|
} else if (selected_lead_form_type == 2) {
|
|
shouldAppend = (item.allocg === "Non-EB" || item.allocg === "Marine");
|
|
} else {
|
|
shouldAppend = true;
|
|
}
|
|
|
|
if (shouldAppend) {
|
|
const option = $('<option>', {
|
|
value: item.id,
|
|
text: item.policy_type + ' - ' + item.policy_no,
|
|
});
|
|
$('#source_policy_id').append(option);
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------------
|
|
|
|
$(document).ready(function() {
|
|
|
|
$('#client_id').change(function() {
|
|
|
|
let client_id = $(this).val();
|
|
console.log("client_id", client_id)
|
|
let client_type = $('#client_id option:selected').data('ct');
|
|
|
|
if (branch_list[client_id] != '' && branch_list[client_id] != null && client_id != '') {
|
|
console.log('branch_list', branch_list[client_id]);
|
|
let data = branch_list[client_id];
|
|
appendBranch(data);
|
|
} else {
|
|
if (temp_client_id == 0) {
|
|
console.log("Step 1: temp_client_id is 0 - No Branch Found for the selected Client");
|
|
console.log('second client_id', client_id);
|
|
if (client_id == null || client_id == 0) {
|
|
console.log("Step 2: client_id is null or 0 - Setting temp_client_id to 0");
|
|
temp_client_id = 0;
|
|
} else {
|
|
console.log("Step 3: client_id exists - Assigning temp_client_id = client_id");
|
|
temp_client_id = client_id;
|
|
toastr.warning("No Branch Found for the selected Client", 'Warning');
|
|
}
|
|
} else {
|
|
console.log("Step 4: temp_client_id is not 0 - Showing warning");
|
|
toastr.warning("No Branch Found for the selected Client", 'Warning');
|
|
}
|
|
}
|
|
|
|
})
|
|
|
|
$('#client_branch_id').change(function() {
|
|
|
|
let client_branch_id = $(this).val();
|
|
console.log('client_branch_id', client_branch_id);
|
|
|
|
if (policy_list[client_branch_id] != '' && policy_list[client_branch_id] != null &&
|
|
client_branch_id != '' && client_branch_id != null) {
|
|
console.log('policy_list', policy_list[client_branch_id]);
|
|
let data = policy_list[client_branch_id];
|
|
appendRenewalPolicies(data);
|
|
} else {
|
|
$('#source_policy_id').empty();
|
|
|
|
if (temp_branch_id == 0) {
|
|
console.log("Step 1: temp_branch_id is 0 - No Policies Found for the selected branch");
|
|
console.log('second client_branch_id', client_branch_id);
|
|
if (client_branch_id == null || client_branch_id == 0) {
|
|
console.log("Step 2: client_branch_id is null or 0 - Setting temp_branch_id to 0");
|
|
temp_branch_id = 0;
|
|
} else {
|
|
console.log("Step 3: v exists - Assigning temp_branch_id = client_branch_id");
|
|
temp_branch_id = client_id;
|
|
toastr.warning("No Policies Found for the selected Branch", 'Warning');
|
|
}
|
|
} else {
|
|
console.log("Step 4: temp_branch_id is not 0 - Showing warning");
|
|
toastr.warning("No Policies Found for the selected Branch", 'Warning');
|
|
}
|
|
}
|
|
|
|
})
|
|
});
|
|
|
|
//--------------------------------------------------------------------------------------------------------
|
|
|
|
// Salse team user list data
|
|
function selecSalsePerson(salse_person_ids) {
|
|
|
|
salse_person_ids = JSON.parse(salse_person_ids);
|
|
// Loop through each insurer-branch combination
|
|
$.each(salse_person_ids, function(index, value) {
|
|
// Use value in the format 'branch_id-insurer_id'
|
|
$('#salse_person_id option').each(function() {
|
|
if ($(this).val() === value) {
|
|
$(this).prop('selected', true); // Select the matching option
|
|
}
|
|
});
|
|
});
|
|
// Trigger change for plugins (like Select2)
|
|
$('#salse_person_id').trigger('change');
|
|
}
|
|
|
|
function validateInput(input, table, field){
|
|
|
|
let value = $(input).val();
|
|
let label = $(input).closest('.form-group').find('label').text().replace('*', '').trim();
|
|
|
|
let message = "Value is duplicate!";
|
|
if(label){
|
|
message = label + " already exists!";
|
|
}
|
|
|
|
checkDuplicateTableFieldValue(table, field, value, function(isDuplicate) {
|
|
if (isDuplicate) {
|
|
toastr.warning(message, 'WARNING');
|
|
$(input).val('')
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
// --------------------------------------------------------------------------------------------------------
|
|
|
|
function addFileField(increment) {
|
|
|
|
console.log('addFileField function called');
|
|
|
|
const container = document.getElementById(`multiFileAppendArea_${increment}`);
|
|
if (!container) return;
|
|
|
|
const div = document.createElement("div");
|
|
div.className = "form-row d-flex align-items-end";
|
|
div.setAttribute("id", `fileField_${fileIndex}`);
|
|
|
|
let isFirstField = container.childElementCount === 0; // Check if it's the first field
|
|
let placeholder = isFirstField ? 'First file must be Demography.' : '';
|
|
let accept = isFirstField ? '.xls,.xlsx' : '';
|
|
|
|
|
|
if(selected_lead_form_type != 1){
|
|
placeholder = '';
|
|
accept = '';
|
|
}
|
|
|
|
let sample_dwn_link = "";
|
|
if(selected_lead_form_type == 1 && isFirstField == 1){
|
|
sample_dwn_link = ' [ <a href="<?= base_url("util/download-excel/member_data"); ?>" id="excel_download" data-toggle="tooltip" data-placement="top" title="Download Sample Excel">Sample Excel</a> ]';
|
|
}
|
|
|
|
|
|
div.innerHTML = `
|
|
<div class="form-group col-md-5">
|
|
<label>Document Name ${sample_dwn_link}<span class="text-danger"></span></label>
|
|
<input type="text" class="form-control" name="docs_name_${increment}[]" placeholder="${placeholder}">
|
|
</div>
|
|
<div class="form-group col-md-5">
|
|
<label>File Upload<span class="text-danger"></span></label>
|
|
<input type="file" class="form-control" id="file_name_${fileIndex}" name="file_name_${increment}[]" accept="${accept}">
|
|
</div>
|
|
<div class="col-md-2" style="position: relative; bottom: 16px;">
|
|
<button type="button" class="btn btn-danger" onclick="removeFileField(${fileIndex})">x</button>
|
|
<button type="button" class="btn btn-primary" onclick="addFileField(${increment})">+</button>
|
|
</div>
|
|
`;
|
|
container.appendChild(div);
|
|
fileIndex++;
|
|
}
|
|
|
|
function removeFileField(index, lead_file_id = null) {
|
|
|
|
if(index == 1){
|
|
toastr.warning("You can't remove the first file field", 'WARNING');
|
|
return false;
|
|
}
|
|
|
|
if(lead_file_id != null) {
|
|
|
|
Swal.fire({
|
|
title: "Do you want to remove this file?",
|
|
// text: "Do you want Save this!",
|
|
icon: "warning",
|
|
showCancelButton: true,
|
|
confirmButtonColor: "#3085d6",
|
|
cancelButtonColor: "#d33",
|
|
confirmButtonText: "Yes, Procced!"
|
|
}).then((result) => {
|
|
|
|
if (result.isConfirmed) {
|
|
|
|
let url = '<?= base_url('util/removeMultiFile') ?>';
|
|
|
|
let requestData = {
|
|
lead_file_id: lead_file_id
|
|
};
|
|
|
|
$('.loader').fadeIn();
|
|
$('.loader-mask').fadeIn();
|
|
|
|
// Send AJAX request
|
|
sendAjaxRequestForGlobal(url, 'GET', requestData, function(response) {
|
|
console.log('Data fetched successfully:', response);
|
|
|
|
if (response.status == true) {
|
|
toastr.success(response.message, 'SUCCESS');
|
|
|
|
//remove the file field
|
|
const field = document.getElementById(`fileField_${index}`);
|
|
if(index != 1){
|
|
if (field) field.remove();
|
|
}
|
|
|
|
} else {
|
|
toastr.error(response.message, 'WARNING');
|
|
}
|
|
|
|
$('.loader').fadeOut();
|
|
$('.loader-mask').delay(350).fadeOut('slow');
|
|
|
|
}, function(xhr, status, error) {
|
|
$('.loader').fadeOut();
|
|
$('.loader-mask').delay(350).fadeOut('slow');
|
|
console.error('Error fetching data:', error);
|
|
console.error(xhr.responseText);
|
|
toastr.error('An error occurred while checking the CD amount.', 'ERROR');
|
|
});
|
|
|
|
}else{
|
|
return false;
|
|
}
|
|
|
|
});
|
|
|
|
}else{
|
|
const field = document.getElementById(`fileField_${index}`);
|
|
if(index != 1){
|
|
if (field) field.remove();
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
function showFileName(input, index) {
|
|
if (input.files.length > 0) {
|
|
document.getElementById(`file_name_display_${index}`).textContent = input.files[0].name;
|
|
} else {
|
|
document.getElementById(`file_name_display_${index}`).textContent = "No file chosen";
|
|
}
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
<?php if (isset($lead_edit_data)) { ?>
|
|
<script>
|
|
|
|
$(document).ready(async function () {
|
|
handleEbAndNonEbEdit(
|
|
<?= json_encode($lead_edit_data, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP) ?>
|
|
);
|
|
});
|
|
|
|
function handleEbAndNonEbEdit(data){
|
|
if(data.lead_form_type == 1){
|
|
dynamicLeadsDataForEdit(data)
|
|
}else{
|
|
dynamicNonEbLeadsDataForEdit(data)
|
|
}
|
|
}
|
|
|
|
function dynamicLeadsDataForEdit(data) {
|
|
try {
|
|
|
|
$('.loader').fadeIn();
|
|
$('.loader-mask').fadeIn();
|
|
|
|
console.log('########### THIS IS EB LEAD ###############')
|
|
|
|
console.log('Received data:', data);
|
|
let dataIncrement = 1;
|
|
fileIndex = data.lead_file_count + 1;
|
|
|
|
if (!data || typeof data !== 'object') {
|
|
console.error('Invalid data received for editing.');
|
|
return;
|
|
}
|
|
|
|
$('.btnDiv').hide();
|
|
$('#appendArea_' + dataIncrement).empty();
|
|
|
|
|
|
if (data.html) {
|
|
$('#appendArea_' + dataIncrement).append(data.html);
|
|
} else {
|
|
console.warn('HTML content missing in data.');
|
|
}
|
|
|
|
if (data.multi_file_html && data.multi_file_html != '') {
|
|
$('#multiFileAppendArea_' + dataIncrement).empty();
|
|
setTimeout(function(){
|
|
$('#multiFileAppendArea_' + dataIncrement).append(data.multi_file_html);
|
|
}, 2000)
|
|
} else {
|
|
console.warn('MULTI FILE HTML content missing in data.');
|
|
}
|
|
|
|
let policy_type_id = data.policy_type_id || null;
|
|
let lead_type = data.lead_type || null;
|
|
|
|
if ([1, 6, 7].includes(policy_type_id)) {
|
|
let newId = 'appendAreaForClaim_' + dataIncrement;
|
|
$('#appendAreaForClaim').attr('id', newId);
|
|
}
|
|
|
|
leadTypeBsedHideAndShow(lead_type);
|
|
|
|
$('.loader').fadeIn();
|
|
$('.loader-mask').fadeIn();
|
|
|
|
|
|
if (lead_type == 1) {
|
|
$('.claim-row').hide();
|
|
} else {
|
|
$('.claim-row').show();
|
|
if (policy_type_id == 1) {
|
|
$('.gpaClaimFileds').show();
|
|
$('.lifeClaimFields').hide();
|
|
} else if (policy_type_id === 6 || policy_type_id === 7) {
|
|
$('.gpaClaimFileds').hide();
|
|
$('.lifeClaimFields').show();
|
|
} else {
|
|
// updateRenewalFields(dataIncrement);
|
|
|
|
let incurred_claim_date_id = 'incurred_claim_date_' + dataIncrement;
|
|
// let premium_date_id = 'premium_date_' + dataIncrement;
|
|
|
|
if ($('#' + incurred_claim_date_id).length) {
|
|
flatpickr("#" + incurred_claim_date_id, {
|
|
dateFormat: "d/m/Y",
|
|
allowInput: false,
|
|
onChange: function (selectedDates) {
|
|
try {
|
|
let increment = this.input.id.split('_').pop();
|
|
let policyStartDate = $("#source_policy_start_date");
|
|
if (policyStartDate.val()) {
|
|
calculatePolicyRunDays(increment);
|
|
}
|
|
} catch (error) {
|
|
console.error('Error in incurred_claim_datepicker:', error);
|
|
}
|
|
}
|
|
});
|
|
} else {
|
|
console.warn(`Incurred claim date field #${incurred_claim_date_id} not found.`);
|
|
}
|
|
|
|
// if ($('#' + premium_date_id).length) {
|
|
// flatpickr("#" + premium_date_id, {
|
|
// dateFormat: "d/m/Y",
|
|
// allowInput: false
|
|
// });
|
|
// } else {
|
|
// console.warn(`Premium date field #${premium_date_id} not found.`);
|
|
// }
|
|
|
|
// console.log($('#proposed_insurer_' + dataIncrement).length);
|
|
$('#proposed_insurer_' + dataIncrement).select2();
|
|
$('#proposed_tpa_' + dataIncrement).select2();
|
|
}
|
|
}
|
|
|
|
hide_list_show_add();
|
|
|
|
$('#page_title').text('Edit Lead');
|
|
$('#leads_primarykey').val(data.id || '');
|
|
$('#policy_start_date').val(data.policy_end_date || '');
|
|
$('#lead_type').val(data.lead_type || '');
|
|
$('#issuer').val(data.issuer || '');
|
|
$('#client_type').val(data.client_type || '');
|
|
$('#client_name').val(data.client_name || '');
|
|
$('#client_short_name').val(data.client_short_name || '');
|
|
$('#entity_type_id').val(data.entity_type_id || '');
|
|
$('#lead_status').val(data.status || '');
|
|
$('#notes').val(data.notes || '');
|
|
|
|
setTimeout(() => {
|
|
$('#client_id').val(data.client_id || '').change();
|
|
setTimeout(() => {
|
|
$('#client_branch_id').val(data.client_branch_id || '').change();
|
|
setTimeout(() => {
|
|
$('#source_policy_id').val(data.source_policy_id || '');
|
|
$('#source_policy_end_date').val(data.source_policy_end_date || '');
|
|
$('#source_policy_start_date').val(data.source_policy_start_date || '');
|
|
$('#pan').val(data.pan || '');
|
|
$('#gst').val(data.gst || '');
|
|
$('#branch_name').val(data.branch_name || '');
|
|
$('#branch_code').val(data.branch_code || '');
|
|
$('#contact_person_name').val(data.contact_person_name || '');
|
|
$('#contact_person_mobile').val(data.contact_person_mobile || '');
|
|
$('#contact_person_email').val(data.contact_person_email || '');
|
|
$('#policy_type_id_1').val(data.policy_type_id || '').select2();
|
|
$('.loader').fadeOut();
|
|
$('.loader-mask').delay(350).fadeOut('slow');
|
|
}, 1000);
|
|
}, 1000);
|
|
}, 5000);
|
|
|
|
let insurer = (data.insurer_branch_id && data.insurer_id)
|
|
? `${data.insurer_branch_id}-${data.insurer_id}`
|
|
: '';
|
|
let tpa = (data.tpa_branch_id && data.tpa_id)
|
|
? `${data.tpa_branch_id}-${data.tpa_id}`
|
|
: '';
|
|
|
|
let proposed_insurer = (data.proposed_insurer_branch_id && data.proposed_insurer_id)
|
|
? `${data.proposed_insurer_branch_id}-${data.proposed_insurer_id}`
|
|
: '';
|
|
let proposed_tpa = (data.proposed_tpa_branch_id && data.proposed_tpa_id)
|
|
? `${data.proposed_tpa_branch_id}-${data.proposed_tpa_id}`
|
|
: '';
|
|
|
|
$('#insurer_1').val(insurer).select2();
|
|
$('#tpa_1').val(tpa).select2();
|
|
$('#policy_start_date_1').val(data.policy_start_date || '');
|
|
$('#policy_end_date_1').val(data.policy_end_date || '');
|
|
$('#file_name_display').text(`Upload File Name : ${data.file_name || 'N/A'}`);
|
|
|
|
if (data.salse_person_id) {
|
|
selecSalsePerson(data.salse_person_id);
|
|
}
|
|
} catch (error) {
|
|
console.error('Error in dynamicLeadsDataForEdit function:', error);
|
|
$('.loader').fadeOut();
|
|
$('.loader-mask').delay(350).fadeOut('slow');
|
|
}
|
|
}
|
|
|
|
function dynamicNonEbLeadsDataForEdit(data) {
|
|
try {
|
|
console.log('########### THIS IS NON EB LEAD ###############')
|
|
console.log('Received data:', data);
|
|
let dataIncrement = 1;
|
|
fileIndex = data.lead_file_count + 1;
|
|
|
|
if (!data || typeof data !== 'object') {
|
|
console.error('Invalid data received for editing.');
|
|
return;
|
|
}
|
|
|
|
$('#appendArea').empty();
|
|
$('#multiFileAppendArea_' + dataIncrement).empty();
|
|
|
|
|
|
if (data.html) {
|
|
$('#appendArea').append(data.html);
|
|
} else {
|
|
console.warn('HTML content missing in data.');
|
|
}
|
|
|
|
if (data.multi_file_html) {
|
|
console.log(data.multi_file_html);
|
|
setTimeout(function(){
|
|
$('#multiFileAppendArea_' + dataIncrement).append(data.multi_file_html);
|
|
}, 2000)
|
|
} else {
|
|
console.warn('MULTI FILE HTML content missing in data.');
|
|
}
|
|
|
|
let policy_type_id = data.policy_type_id || null;
|
|
let lead_type = data.lead_type || null;
|
|
|
|
leadTypeBsedHideAndShow(lead_type);
|
|
|
|
if(data.client_id == 0 || data.client_id == null){
|
|
temp_client_id = 0;
|
|
}else{
|
|
temp_client_id = data.client_id
|
|
}
|
|
|
|
|
|
$('#page_title').text('Edit Lead');
|
|
$('#leads_primarykey').val(data.id || '');
|
|
$('#policy_start_date').val(data.policy_end_date || '');
|
|
$('#lead_type').val(data.lead_type || '');
|
|
$('#issuer').val(data.issuer || '');
|
|
$('#client_type').val(data.client_type || '');
|
|
$('#client_name').val(data.client_name || '');
|
|
$('#client_short_name').val(data.client_short_name || '');
|
|
$('#entity_type_id').val(data.entity_type_id || '');
|
|
$('#lead_status').val(data.status || '');
|
|
$('#notes').val(data.notes || '');
|
|
|
|
setTimeout(() => {
|
|
$('#client_id').val(data.client_id || '').change();
|
|
setTimeout(() => {
|
|
$('#client_branch_id').val(data.client_branch_id || '').change();
|
|
setTimeout(() => {
|
|
$('#source_policy_id').val(data.source_policy_id || '');
|
|
$('#pan').val(data.pan || '');
|
|
$('#gst').val(data.gst || '');
|
|
$('#branch_name').val(data.branch_name || '');
|
|
$('#branch_code').val(data.branch_code || '');
|
|
$('#contact_person_name').val(data.contact_person_name || '');
|
|
$('#contact_person_mobile').val(data.contact_person_mobile || '');
|
|
$('#contact_person_email').val(data.contact_person_email || '');
|
|
$('#policy_type_id').val(data.policy_type_id || '').select2();
|
|
$('.loader').fadeOut();
|
|
$('.loader-mask').delay(350).fadeOut('slow');
|
|
}, 1000);
|
|
}, 1000);
|
|
}, 2000);
|
|
|
|
let insurer = (data.insurer_branch_id && data.insurer_id)
|
|
? `${data.insurer_branch_id}-${data.insurer_id}`
|
|
: '';
|
|
let tpa = (data.tpa_branch_id && data.tpa_id)
|
|
? `${data.tpa_branch_id}-${data.tpa_id}`
|
|
: '';
|
|
|
|
let proposed_insurer = (data.proposed_insurer_branch_id && data.proposed_insurer_id)
|
|
? `${data.proposed_insurer_branch_id}-${data.proposed_insurer_id}`
|
|
: '';
|
|
let proposed_tpa = (data.proposed_tpa_branch_id && data.proposed_tpa_id)
|
|
? `${data.proposed_tpa_branch_id}-${data.proposed_tpa_id}`
|
|
: '';
|
|
|
|
$('#insurer').val(insurer).select2();
|
|
$('#tpa').val(tpa).select2();
|
|
$('#policy_start_date').val(data.policy_start_date || '');
|
|
$('#policy_end_date').val(data.policy_end_date || '');
|
|
$('#file_name_display').text(`Upload File Name : ${data.file_name || 'N/A'}`);
|
|
|
|
if (data.salse_person_id) {
|
|
selecSalsePerson(data.salse_person_id);
|
|
}
|
|
|
|
let referenceDiv = document.getElementById('appendAreaForClaim');
|
|
referenceDiv.innerHTML = '';
|
|
referenceDiv.insertAdjacentHTML('beforeend', data.claims_details_html);
|
|
|
|
} catch (error) {
|
|
console.error('Error in dynamicLeadsDataForEdit function:', error);
|
|
}
|
|
}
|
|
|
|
</script>
|
|
<?php } ?>
|