Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev

This commit is contained in:
VENKATESHWARAN 2025-05-20 08:43:00 +05:30
commit 6d4366e60a
6 changed files with 313 additions and 134 deletions

View File

@ -241,8 +241,12 @@ class LeadsController extends BaseController
$form_file_name = "file_name_" . $index_plus_one; $form_file_name = "file_name_" . $index_plus_one;
$form_docs_name = "docs_name_" . $index_plus_one; $form_docs_name = "docs_name_" . $index_plus_one;
$leads_file_primary_key = $data['leads_file_id'] ?? []; $leads_file_primary_key = $data['leads_file_id'] ?? [];
$multi_file_data = [];
if(isset($data[$form_docs_name])){
$files = $this->request->getFileMultiple($form_file_name); $files = $this->request->getFileMultiple($form_file_name);
$multi_file_data = $this->uploadMultiFiles($files, $data[$form_docs_name], $leads_file_primary_key); $multi_file_data = $this->uploadMultiFiles($files, $data[$form_docs_name], $leads_file_primary_key);
}
// Separate the insurer and insurer branch, handle missing or invalid data // Separate the insurer and insurer branch, handle missing or invalid data
if (isset($data['insurer']) && strpos($data['insurer'], '-') !== false) { if (isset($data['insurer']) && strpos($data['insurer'], '-') !== false) {
@ -677,8 +681,10 @@ class LeadsController extends BaseController
if ($lead_data['lead_type'] != 1) { if ($lead_data['lead_type'] != 1) {
$client_policy_data = $this->clientPolicyModel->where('is_active', 1)->where('id', $lead_data['source_policy_id'])->first(); $client_policy_data = $this->clientPolicyModel->where('is_active', 1)->where('id', $lead_data['source_policy_id'])->first();
if (isset($client_policy_data)) {
$data['policy_terms'] = $client_policy_data['policy_terms']; $data['policy_terms'] = $client_policy_data['policy_terms'];
} }
}
$data['question_json'] = $lead_data['question_json']; $data['question_json'] = $lead_data['question_json'];
$data['page_name'] = $type == 2 ? 'QCR' : 'RFQ'; $data['page_name'] = $type == 2 ? 'QCR' : 'RFQ';
@ -736,8 +742,11 @@ class LeadsController extends BaseController
if ($lead_data['lead_type'] != 1 && $data['rfq_count'] == 0) { if ($lead_data['lead_type'] != 1 && $data['rfq_count'] == 0) {
$client_policy_data = $this->clientPolicyModel->where('is_active', 1)->where('id', $lead_data['source_policy_id'])->first(); $client_policy_data = $this->clientPolicyModel->where('is_active', 1)->where('id', $lead_data['source_policy_id'])->first();
if (isset($client_policy_data)) {
$data['rfq_data']['json'] = $client_policy_data['placement_json']; $data['rfq_data']['json'] = $client_policy_data['placement_json'];
} }
}
if (!empty($data['question_json'])) { if (!empty($data['question_json'])) {
$data['policies'] = json_decode($data['question_json'], true)['policies']; $data['policies'] = json_decode($data['question_json'], true)['policies'];

View File

@ -292,6 +292,7 @@ if (isset($selected_lead_type)) {
} else { } else {
$('#source_policy_id').empty(); $('#source_policy_id').empty();
// let lead_type = data.lead_type || null;
if (temp_branch_id == 0) { if (temp_branch_id == 0) {
console.log("Step 1: temp_branch_id is 0 - No Policies Found for the selected branch"); 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); console.log('second client_branch_id', client_branch_id);
@ -301,13 +302,19 @@ if (isset($selected_lead_type)) {
} else { } else {
console.log("Step 3: v exists - Assigning temp_branch_id = client_branch_id"); console.log("Step 3: v exists - Assigning temp_branch_id = client_branch_id");
temp_branch_id = client_id; temp_branch_id = client_id;
if (lead_type != 3) {
toastr.warning("No Policies Found for the selected Branch", 'Warning'); toastr.warning("No Policies Found for the selected Branch", 'Warning');
} }
}
} else { } else {
console.log("Step 4: temp_branch_id is not 0 - Showing warning"); console.log("Step 4: temp_branch_id is not 0 - Showing warning");
if (lead_type != 3) {
toastr.warning("No Policies Found for the selected Branch", 'Warning'); toastr.warning("No Policies Found for the selected Branch", 'Warning');
} }
} }
}
}) })
}); });
@ -331,24 +338,24 @@ if (isset($selected_lead_type)) {
$('#salse_person_id').trigger('change'); $('#salse_person_id').trigger('change');
} }
function validateInput(input, table, field){ // function validateInput(input, table, field){
let value = $(input).val(); // let value = $(input).val();
let label = $(input).closest('.form-group').find('label').text().replace('*', '').trim(); // let label = $(input).closest('.form-group').find('label').text().replace('*', '').trim();
let message = "Value is duplicate!"; // let message = "Value is duplicate!";
if(label){ // if(label){
message = label + " already exists!"; // message = label + " already exists!";
} // }
checkDuplicateTableFieldValue(table, field, value, function(isDuplicate) { // checkDuplicateTableFieldValue(table, field, value, function(isDuplicate) {
if (isDuplicate) { // if (isDuplicate) {
toastr.warning(message, 'WARNING'); // toastr.warning(message, 'WARNING');
$(input).val('') // $(input).val('')
} // }
}); // });
} // }
// -------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------
@ -485,6 +492,8 @@ if (isset($selected_lead_type)) {
<?php if (isset($lead_edit_data)) { ?> <?php if (isset($lead_edit_data)) { ?>
<script> <script>
var lead_type = "";
$(document).ready(async function () { $(document).ready(async function () {
$('.loader').fadeIn(); $('.loader').fadeIn();
@ -502,6 +511,7 @@ if (isset($selected_lead_type)) {
}); });
function handleEbAndNonEbEdit(data){ function handleEbAndNonEbEdit(data){
lead_type = data.lead_type || null;
if(data.lead_form_type == 1){ if(data.lead_form_type == 1){
dynamicLeadsDataForEdit(data) dynamicLeadsDataForEdit(data)
}else{ }else{
@ -610,38 +620,39 @@ if (isset($selected_lead_type)) {
} }
} }
if (lead_type == 3) { // if (lead_type == 3) {
$('#client_id').prepend($('<option>', { // $('#client_id').prepend($('<option>', {
value: 'add_client', // value: 'add_client',
text: '+ Add Client' // text: '+ Add Client'
})); // }));
console.log("trying to remove required "); // console.log("trying to remove required ");
$("#source_policy_id").prop("required",false); // $("#source_policy_id").prop("required",false);
$("#source_policy_id").closest("div") .find("label .text-danger").remove(); // $("#source_policy_id").closest("div") .find("label .text-danger").remove();
} else if (lead_type != 3) { // } else if (lead_type != 3) {
$("#source_policy_id").prop("required",true); // $("#source_policy_id").prop("required",true);
$("#source_policy_id").prop("required", true); // $("#source_policy_id").prop("required", true);
// Check if the asterisk doesn't already exist, then add it // // Check if the asterisk doesn't already exist, then add it
let $label = $("#source_policy_id") // let $label = $("#source_policy_id")
.closest("div") // .closest("div")
.find("label"); // .find("label");
if ($label.find(".text-danger").length === 0) { // if ($label.find(".text-danger").length === 0) {
$label.append(' <span class="text-danger">*</span>'); // $label.append(' <span class="text-danger">*</span>');
} // }
var addOption = $('#client_id option[value="add_client"]'); // var addOption = $('#client_id option[value="add_client"]');
if (addOption.length > 0) { // if (addOption.length > 0) {
addOption.remove(); // addOption.remove();
} // }
// console.log("rying to remove required and option removed from client")
} // }
hide_list_show_add(); hide_list_show_add();
@ -657,27 +668,33 @@ if (isset($selected_lead_type)) {
$('#lead_status').val(data.status || ''); $('#lead_status').val(data.status || '');
$('#notes').val(data.notes || ''); $('#notes').val(data.notes || '');
setTimeout(() => { // setTimeout(() => {
$('#client_id').val(data.client_id || '').change(); // $('#client_id').val(data.client_id || '').change();
setTimeout(() => { // setTimeout(() => {
$('#client_branch_id').val(data.client_branch_id || '').change(); // $('#client_branch_id').val(data.client_branch_id || '').change();
setTimeout(() => { // setTimeout(() => {
$('#source_policy_id').val(data.source_policy_id || ''); // $('#source_policy_id').val(data.source_policy_id || '');
$('#source_policy_end_date').val(data.source_policy_end_date || ''); // $('#source_policy_end_date').val(data.source_policy_end_date || '');
$('#source_policy_start_date').val(data.source_policy_start_date || ''); // $('#source_policy_start_date').val(data.source_policy_start_date || '');
$('#pan').val(data.pan || ''); // $('#pan').val(data.pan || '');
$('#gst').val(data.gst || ''); // $('#gst').val(data.gst || '');
$('#branch_name').val(data.branch_name || ''); // $('#branch_name').val(data.branch_name || '');
$('#branch_code').val(data.branch_code || ''); // $('#branch_code').val(data.branch_code || '');
$('#contact_person_name').val(data.contact_person_name || ''); // $('#contact_person_name').val(data.contact_person_name || '');
$('#contact_person_mobile').val(data.contact_person_mobile || ''); // $('#contact_person_mobile').val(data.contact_person_mobile || '');
$('#contact_person_email').val(data.contact_person_email || ''); // $('#contact_person_email').val(data.contact_person_email || '');
$('#policy_type_id_1').val(data.policy_type_id || '').select2(); // $('#policy_type_id_1').val(data.policy_type_id || '').select2();
$('.loader').fadeOut(); // $('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow'); // $('.loader-mask').delay(350).fadeOut('slow');
}, 1000); // }, 1000);
}, 1000); // }, 1000);
}, 5000); // }, 5000);
// setTimeout(() => {
populateForm(data);
// },5000);
let insurer = (data.insurer_branch_id && data.insurer_id) let insurer = (data.insurer_branch_id && data.insurer_id)
? `${data.insurer_branch_id}-${data.insurer_id}` ? `${data.insurer_branch_id}-${data.insurer_id}`
@ -732,10 +749,10 @@ if (isset($selected_lead_type)) {
} }
if (data.multi_file_html) { if (data.multi_file_html) {
console.log(data.multi_file_html); // console.log(data.multi_file_html);
setTimeout(function(){ setTimeout(function(){
$('#multiFileAppendArea_' + dataIncrement).append(data.multi_file_html); $('#multiFileAppendArea_' + dataIncrement).append(data.multi_file_html);
}, 2000) }, 1000)
} else { } else {
console.warn('MULTI FILE HTML content missing in data.'); console.warn('MULTI FILE HTML content missing in data.');
} }
@ -764,30 +781,33 @@ if (isset($selected_lead_type)) {
$('#lead_status').val(data.status || ''); $('#lead_status').val(data.status || '');
$('#notes').val(data.notes || ''); $('#notes').val(data.notes || '');
setTimeout(() => { // setTimeout(() => {
$('#client_id').val(data.client_id || '').change(); // $('#client_id').val(data.client_id || '').change();
setTimeout(() => { // setTimeout(() => {
$('#client_branch_id').val(data.client_branch_id || '').change(); // $('#client_branch_id').val(data.client_branch_id || '').change();
setTimeout(() => { // setTimeout(() => {
$('#source_policy_id').val(data.source_policy_id || ''); // $('#source_policy_id').val(data.source_policy_id || '');
$('#pan').val(data.pan || ''); // $('#pan').val(data.pan || '');
$('#gst').val(data.gst || ''); // $('#gst').val(data.gst || '');
$('#branch_name').val(data.branch_name || ''); // $('#branch_name').val(data.branch_name || '');
$('#branch_code').val(data.branch_code || ''); // $('#branch_code').val(data.branch_code || '');
$('#contact_person_name').val(data.contact_person_name || ''); // $('#contact_person_name').val(data.contact_person_name || '');
$('#contact_person_mobile').val(data.contact_person_mobile || ''); // $('#contact_person_mobile').val(data.contact_person_mobile || '');
$('#contact_person_email').val(data.contact_person_email || ''); // $('#contact_person_email').val(data.contact_person_email || '');
$('#policy_type_id').val(data.policy_type_id || '').select2(); // $('#policy_type_id').val(data.policy_type_id || '').select2();
$('.loader').fadeOut(); // $('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow'); // $('.loader-mask').delay(350).fadeOut('slow');
$(".loss_date").each(function () { // $(".loss_date").each(function () {
flatpickr(this, { // flatpickr(this, {
dateFormat: "d-m-Y", // dateFormat: "d-m-Y",
}); // });
}); // });
}, 1000); // }, 1000);
}, 1000); // }, 1000);
}, 2000); // }, 2000);
populateForm(data);
let insurer = (data.insurer_branch_id && data.insurer_id) let insurer = (data.insurer_branch_id && data.insurer_id)
? `${data.insurer_branch_id}-${data.insurer_id}` ? `${data.insurer_branch_id}-${data.insurer_id}`
@ -819,8 +839,35 @@ if (isset($selected_lead_type)) {
console.log("wdesfgefwregfefwregffeegf",data.lead_type); console.log("wdesfgefwregfefwregffeegf",data.lead_type);
var lead_type_value = data.lead_type; var lead_type_value = data.lead_type;
// alert(lead_type);
if (lead_type_value == 3) {
} catch (error) {
console.error('Error in dynamicLeadsDataForEdit function:', error);
}
}
function waitForDropdownValue(selector, value, callback, retries = 20) {
const trySet = () => {
const $el = $(selector);
if ($el.find(`option[value="${value}"]`).length > 0) {
$el.val(value).trigger('change');
callback();
} else if (retries > 0) {
setTimeout(() => trySet(selector, value, callback, retries - 1), 300);
} else {
console.warn(`Value ${value} not found for ${selector}`);
callback(); // Proceed anyway to avoid hanging
}
};
trySet();
}
function populateForm(data) {
let lead_type = data.lead_type || null;
waitForDropdownValue('#client_id', data.client_id || '', () => {
if (lead_type == 3) {
$('#client_id').prepend($('<option>', { $('#client_id').prepend($('<option>', {
value: 'add_client', value: 'add_client',
@ -832,7 +879,7 @@ if (isset($selected_lead_type)) {
$("#source_policy_id").closest("div") .find("label .text-danger").remove(); $("#source_policy_id").closest("div") .find("label .text-danger").remove();
} else if (lead_type_value != 3) { } else if (lead_type != 3) {
$("#source_policy_id").prop("required",true); $("#source_policy_id").prop("required",true);
$("#source_policy_id").prop("required", true); $("#source_policy_id").prop("required", true);
@ -850,13 +897,36 @@ if (isset($selected_lead_type)) {
addOption.remove(); addOption.remove();
} }
console.log("rying to remove required and option removed from client")
} }
waitForDropdownValue('#client_branch_id', data.client_branch_id || '', () => {
// Fill other fields once both dropdowns are ready
$('#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').val(data.policy_type_id || '').select2();
$('#policy_type_id_1').val(data.policy_type_id || '').select2();
} catch (error) { $('.loader').fadeOut();
console.error('Error in dynamicLeadsDataForEdit function:', error); $('.loader-mask').delay(350).fadeOut('slow');
} $(".loss_date").each(function () {
flatpickr(this, {
dateFormat: "d-m-Y",
});
});
});
});
} }
</script> </script>
<?php } ?> <?php } ?>

View File

@ -661,6 +661,13 @@
$('.renewalFields').show(); $('.renewalFields').show();
$('.renewalFields').find('select, input').attr('required', 'required'); $('.renewalFields').find('select, input').attr('required', 'required');
if (value == 3) {
$("#source_policy_id").removeAttr("required");
$("#source_policy_start_date").removeAttr("required");
$("#source_policy_end_date").removeAttr("required");
}
$('.proposed_div').show().find('select, input').attr('required', 'required'); $('.proposed_div').show().find('select, input').attr('required', 'required');
$('#policy_end_date').removeAttr('required'); $('#policy_end_date').removeAttr('required');

View File

@ -22,7 +22,7 @@
<div class="form-group col-md-12"> <div class="form-group col-md-12">
<label for="cost_center">PAN</label> <label for="cost_center">PAN</label>
<input type="text" class="form-control" id="pan" placeholder="Enter PAN No" name="pan" onchange="validateInput(this, 'clients', 'pan')"> <input type="text" class="form-control" id="pan" placeholder="Enter PAN No" name="pan" onchange="validateInputForClient(this, 'clients', 'pan')">
</div> </div>
</div> </div>
@ -39,7 +39,7 @@
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="cost_center">Mobile<span class="text-danger">*</span></label> <label for="cost_center">Mobile<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="phone" placeholder="Enter Mobile Number" maxlength="10" name="phone" <input type="text" class="form-control" id="phone" placeholder="Enter Mobile Number" maxlength="10" name="phone"
onkeypress="return onlyNumbers(event)" onchange="validateInput(this, 'clients', 'phone')"> onkeypress="return onlyNumbers(event)" onchange="validateInputForClient(this, 'clients', 'phone')">
</div> </div>
<div class="form-group col-md-12"> <div class="form-group col-md-12">
@ -48,7 +48,7 @@
</div> </div>
<div class="form-group col-md-12"> <div class="form-group col-md-12">
<label for="aadhar">Aadhar</label> <label for="aadhar">Aadhar</label>
<input type="text" class="form-control" id="aadhar" placeholder="Enter Aadher No" name="aadhar" maxlength="12" onchange="validateInput(this, 'clients', 'aadhar')"> <input type="text" class="form-control" id="aadhar" placeholder="Enter Aadher No" name="aadhar" maxlength="12" onchange="validateInputForClient(this, 'clients', 'aadhar')">
</div> </div>
</div> </div>
@ -96,7 +96,7 @@
<div class="form-group col-md-12"> <div class="form-group col-md-12">
<label for="gst">GST<span class="text-danger">*</span></label> <label for="gst">GST<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="gst" placeholder="Enter GST Number" onchange="validateInput(this, 'client_branch', 'gst')" <input type="text" class="form-control" id="gst" placeholder="Enter GST Number" oninput="validateInputForClient(this, 'client_branch', 'gst')"
data-parsley-error-message="Invalid GST Number. Example: 12ABCDE1234F5Z6" name="gst" data-parsley-trigger="change" data-parsley-pattern="^\d{2}[A-Z]{5}\d{4}[A-Z]{1}[A-Z\d]{1}[Z]{1}[A-Z\d]{1}$" required> data-parsley-error-message="Invalid GST Number. Example: 12ABCDE1234F5Z6" name="gst" data-parsley-trigger="change" data-parsley-pattern="^\d{2}[A-Z]{5}\d{4}[A-Z]{1}[A-Z\d]{1}[Z]{1}[A-Z\d]{1}$" required>
</div> </div>
@ -113,8 +113,52 @@
</div> </div>
<script> <script>
let isGSTValidating = false;
let isGSTValid = false;
function validateInputForClient(input, table, field) {
let value = $(input).val();
if (!value) return;
let label = $(input).closest('.form-group').find('label').text().replace('*', '').trim();
let message = label ? label + " already exists!" : "Value is duplicate!";
// Set validating state
isGSTValidating = true;
isGSTValid = false;
$('#hide_smbt_btn button').prop('disabled', true);
checkDuplicateTableFieldValue(table, field, value, function(isDuplicate) {
isGSTValidating = false;
if (isDuplicate) {
toastr.warning(message, 'WARNING');
$(input).val('');
isGSTValid = false;
} else {
isGSTValid = true;
}
});
$('#hide_smbt_btn button').prop('disabled', false);
}
$("#client_form").submit(function(event) { $("#client_form").submit(function(event) {
// alert("Function Called from Modal")
event.preventDefault();
// If GST is currently validating, wait for it to complete
if (isGSTValidating) {
toastr.info('Please wait while we validate your GST number...', 'Validating');
return;
}
// If GST validation failed, prevent submission
if ($('#gst').val() && !isGSTValid) {
toastr.warning('Please fix the GST number before submitting', 'Validation Error');
return;
}
let form_type = $(this).data('id') || 0; let form_type = $(this).data('id') || 0;
console.log('onsubmit event', this) console.log('onsubmit event', this)
@ -127,14 +171,30 @@
$('#aadhar').attr('data-parsley-required', 'false'); $('#aadhar').attr('data-parsley-required', 'false');
$('#aadhar').removeAttr('required'); $('#aadhar').removeAttr('required');
if($('#Owner_type').val() == 2){
$('#gst').removeAttr('required');
}
isClientFormSubmitting = true; isClientFormSubmitting = true;
var isValid = $('#client_form').parsley().validate(); var isValid = $('#client_form').parsley().validate();
if (!isValid) { if (!isValid) {
console.log('Form is Empty', 'Warning'); var emptyFieldIds = [];
$('#client_form').parsley().fields.forEach(function(field) {
if (!field.isValid()) {
var elem = field.$element;
var id = elem.attr('id') || elem.attr('name');
emptyFieldIds.push(id);
}
});
console.log('Empty/Invalid Fields:', emptyFieldIds);
return; return;
} }
form_action = '<?= base_url("util/createClientWithMinimalData"); ?>'; form_action = '<?= base_url("util/createClientWithMinimalData"); ?>';
$('.loader').fadeIn(); $('.loader').fadeIn();
@ -169,6 +229,10 @@
setTimeout(function(){ setTimeout(function(){
$('#client_id').val(res.client_id).change(); $('#client_id').val(res.client_id).change();
$('#client_id').prepend($('<option>', {
value: 'add_client',
text: '+ Add Client'
}));
setTimeout(function(){ setTimeout(function(){
$('#client_branch_id').val(res.branch_id).change(); $('#client_branch_id').val(res.branch_id).change();
// try { // try {
@ -181,7 +245,7 @@
}else{ }else{
toastr.error("Couldn't Add Client","Error"); console.log("Couldn't Add Client","Error");
} }
toastr.success(res.message, 'Success'); toastr.success(res.message, 'Success');
@ -201,7 +265,16 @@
$('#client_form').removeAttr('data-id'); $('#client_form').removeAttr('data-id');
// Load form data into #vehicle_form from localStorage // Load form data into #vehicle_form from localStorage
setFormDataFromLocalStorage("#vehicle_form", "vehicleFormData"); setFormDataFromLocalStorage("#vehicle_form", "vehicleFormData", res.client_id);
setTimeout(function(){
$('#owner').val(res.client_id).change();
$('#owner_branch').val(res.branch_id).change();
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}, 2000)
} }
isClientFormSubmitting = false; isClientFormSubmitting = false;

View File

@ -446,7 +446,7 @@
<span class="slider round" style="height: 27px;"></span> <span class="slider round" style="height: 27px;"></span>
</label> </label>
<label for="is_cd_reduce_from_bds" style="position: relative;top: 33px;left: 25px;"> Make Entry in CD &nbsp;&nbsp; <i class="fa fa-info-circle" data-toggle="tooltip" title="Enabling this will affect ( Credit/Debit ) the CD transaction. ( GMC, GPA, EDLI and GTLI, CD transaction from CRM )"></i> <label for="is_cd_reduce_from_bds" style="position: relative;top: 33px;left: 25px;"> Make Entry in CD &nbsp;&nbsp; <i class="fa fa-info-circle info-icon" data-toggle="tooltip" title="Enabling this will affect ( Credit/Debit ) the CD transaction. ( GMC, GPA, EDLI and GTLI, CD transaction from CRM )"></i>
</label> </label>
</div> </div>
@ -532,13 +532,13 @@
</div> </div>
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label for="installment">Installment</label> <label for="installment">Installment &nbsp; <i id="infoIcon" class="fas fa-info-circle info-icon" data-toggle="tooltip" title="Click for Installment details" style="margin-left: 5px;"></i></label>
<input id="installment" value="" type="text" class="form-control" name="installment"> <input id="installment" value="" type="text" class="form-control" name="installment">
</div> </div>
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label for="installment_data"> <label for="installment_data">
Installment Data <i id="infoIcon" class="fas fa-info-circle info-icon" title="Click for Installment details" style="margin-left: 5px;"></i> Installment Data
</label> </label>
<input id="installment_data" class="form-control" name="installment_data"> <input id="installment_data" class="form-control" name="installment_data">
</div> </div>
@ -1315,10 +1315,12 @@ $(document).ready(function(){
$('#name').prop('required', false); $('#name').prop('required', false);
$('#mobile').prop('required', false); $('#mobile').prop('required', false);
$('#gst').prop('required', false); $('#gst').prop('required', false);
$('#email').prop('required', false);
$('#dob').prop('required', true); $('#dob').prop('required', true);
$('#phone').prop('required', true); $('#phone').prop('required', true);
$('#email').prop('required', true); $('#email2').prop('required', true);
$('#aadhar').prop('required', true); $('#aadhar').prop('required', true);
} else { } else {
@ -1332,10 +1334,11 @@ $(document).ready(function(){
$('#name').prop('required', true); $('#name').prop('required', true);
$('#mobile').prop('required', true); $('#mobile').prop('required', true);
$('#gst').prop('required', true); $('#gst').prop('required', true);
$('#email').prop('required', true);
$('#dob').prop('required', false); $('#dob').prop('required', false);
$('#phone').prop('required', false); $('#phone').prop('required', false);
$('#email').prop('required', false); $('#email2').prop('required', false);
$('#aadhar').prop('required', false); $('#aadhar').prop('required', false);
} }

View File

@ -1,50 +1,67 @@
<?php <?php
$fileIndex = 1; // Initialize index $fileIndex = 1;
$increment = 1; // Example increment value $increment = 1;
?> ?>
<?php if (isset($lead_edit_data) && isset($lead_edit_data["multi_file_data"]) && !empty($lead_edit_data["multi_file_data"])) { <?php if (isset($lead_edit_data) && isset($lead_edit_data["multi_file_data"]) && !empty($lead_edit_data["multi_file_data"])) {
foreach ($lead_edit_data["multi_file_data"] as $index => $value) { foreach ($lead_edit_data["multi_file_data"] as $index => $value) {
$isFirstField = ($index === 0); // First file must be Demography $isFirstField = ($index === 0);
$placeholder = $isFirstField ? 'First file must be Demography.' : ''; $placeholder = $isFirstField ? 'First file must be Demography.' : '';
$accept = $isFirstField ? '.xls,.xlsx' : ''; $accept = $isFirstField ? '.xls,.xlsx' : '';
$index = $index + 1; $displayIndex = $index + 1;
?> ?>
<div class="form-row d-flex align-items-end" id="fileField_<?= $index ?>"> <div class="form-row d-flex align-items-end" id="fileField_<?= $displayIndex ?>">
<input type="hidden" name="leads_file_id[]" value="<?= htmlspecialchars($value['id']) ?>" id="file_id_<?= $displayIndex ?>">
<input type="hidden" name="leads_file_id[]"
value="<?= htmlspecialchars($value['id']) ?>" id="file_id_<?= $index ?>">
<!-- Document Name Input -->
<div class="form-group col-md-5"> <div class="form-group col-md-5">
<label>Document Name<span class="text-danger"></span></label> <label>Document Name</label>
<input type="text" class="form-control" name="docs_name_<?= $increment ?>[]" <input type="text" class="form-control" name="docs_name_<?= $increment ?>[]"
placeholder="<?= $placeholder ?>" placeholder="<?= $placeholder ?>"
value="<?= htmlspecialchars($value['docs_name']) ?>" id="docs_name_<?= $index ?>"> value="<?= htmlspecialchars($value['docs_name']) ?>" id="docs_name_<?= $displayIndex ?>">
</div> </div>
<!-- File Upload Input -->
<div class="form-group col-md-5"> <div class="form-group col-md-5">
<label> <label>
File Upload File Upload<br>
<span class="text-danger"></span><br> <small id="file_name_display_<?= $displayIndex ?>" class="text-muted">
<small id="file_name_display_<?= $index ?>" class="text-muted">
<?= !empty($value['file_name']) ? htmlspecialchars($value['file_name']) : 'No file chosen' ?> <?= !empty($value['file_name']) ? htmlspecialchars($value['file_name']) : 'No file chosen' ?>
</small> </small>
</label> </label>
<input type="file" class="form-control" id="file_name_<?= $displayIndex ?>"
<input type="file" class="form-control" id="file_name_<?= $index ?>"
name="file_name_<?= $increment ?>[]" accept="<?= $accept ?>" name="file_name_<?= $increment ?>[]" accept="<?= $accept ?>"
onchange="showFileName(this, <?= $index ?>)"> onchange="showFileName(this, <?= $displayIndex ?>)">
</div> </div>
<!-- Add/Remove Buttons -->
<div class="col-md-2" style="position: relative; bottom: 16px;"> <div class="col-md-2" style="position: relative; bottom: 16px;">
<button type="button" class="btn btn-danger" onclick="removeFileField(<?= $index ?>, <?= htmlspecialchars($value['id']) ?>)">x</button> <button type="button" class="btn btn-danger" onclick="removeFileField(<?= $displayIndex ?>, <?= htmlspecialchars($value['id']) ?>)">x</button>
<button type="button" class="btn btn-primary" onclick="addFileField(<?= $increment ?>)">+</button> <button type="button" class="btn btn-primary" onclick="addFileField(<?= $increment ?>)">+</button>
</div> </div>
</div> </div>
<?php } } ?> <?php } } else { ?>
<!-- Default field if no file data exists -->
<div class="form-row d-flex align-items-end" id="fileField_1">
<input type="hidden" name="leads_file_id[]" value="">
<div class="form-group col-md-5">
<label>Document Name</label>
<input type="text" class="form-control" name="docs_name_1[]"
placeholder="First file must be Demography." id="docs_name_1">
</div>
<div class="form-group col-md-5">
<label>
File Upload<br>
<small id="file_name_display_1" class="text-muted">No file chosen</small>
</label>
<input type="file" class="form-control" id="file_name_1"
name="file_name_1[]" accept=".xls,.xlsx" onchange="showFileName(this, 1)">
</div>
<div class="col-md-2" style="position: relative; bottom: 16px;">
<button type="button" class="btn btn-danger" onclick="removeFileField(1, '')">x</button>
<button type="button" class="btn btn-primary" onclick="addFileField(1)">+</button>
</div>
</div>
<?php } ?>