FIX_CLIENT_ISSUES : RV

This commit is contained in:
VENKATESHWARAN 2025-05-26 08:51:26 +05:30
parent 8f5fc52d9f
commit 5e8adfc72d
5 changed files with 124 additions and 34 deletions

View File

@ -1215,7 +1215,7 @@ class LeadsController extends BaseController
'Total Lives' => $rfq_data['incept_no_of_lives'],
'Period of Insurance ' => !empty($rfq_data['policy_start_date']) && !empty($rfq_data['policy_end_date']) ? date('d/m/Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d/m/Y', strtotime($rfq_data['policy_end_date'])) : "To be decided",
'Policy Run Days' => $rfq_data['policy_run_days'],
// 'Policy Run Days' => $rfq_data['policy_run_days'],
];
} else if ($rfq_data['policy_type_id'] == 1) {
$lead_data = [
@ -2163,6 +2163,13 @@ class LeadsController extends BaseController
$mail_subject = $params['subject'];
$attachment_file_ids = $params['selected_attachment_files'];
$from_mail = getenv('email.fromEmail');
if(in_array($recipient_type ,['placement', 'insurer', 'internal'])){
$from_mail = "im@nhanceindia.in";
}else if(in_array($recipient_type, ['client'])){
$from_mail = "bs@nhanceindia.in";
}
$result_data = [];
// dd($recipient_mail);
if ($recipient_type == 'insurer' && (!is_array($recipient_mail) || count($recipient_mail) == 0)) {
@ -2348,7 +2355,7 @@ class LeadsController extends BaseController
$string = implode(", ", $cc_mails);
$bcc_string = implode(", ", $bcc_mails);
$res = MailHelper::send_email(['mail' => $recipient['email'], 'cc' => $string, 'subject' => $subject, 'message' => $message, 'attachments' => $attachments, 'reply_to' => $reply_to, 'bcc' => $bcc_string]);
$res = MailHelper::send_email(['from_mail' => $from_mail, 'mail' => $recipient['email'], 'cc' => $string, 'subject' => $subject, 'message' => $message, 'attachments' => $attachments, 'reply_to' => $reply_to, 'bcc' => $bcc_string]);
// !dd($res);
$result_data[] = ['mail' => $recipient['email'], 'status' => $res];
}
@ -4102,32 +4109,63 @@ class LeadsController extends BaseController
public function handleMultiFileAttachments($json_string, $lead_id)
{
log_message('error', 'handleMultiFileAttachments called with lead_id: ' . $lead_id);
$attachments = [];
if (!empty($json_string)) {
log_message('error', 'json_string is not empty');
$fileIds = json_decode($json_string, true);
log_message('error', 'Decoded fileIds: ' . print_r($fileIds, true));
$lead_file_path = WRITEPATH . 'uploads/lead_files/';
log_message('error', 'Lead file path: ' . $lead_file_path);
foreach ($fileIds as $id) {
$lead_file = $this->leadFilesModel->where('lead_id', $lead_id)->where('id', $id)->where('is_active', 1)->first();
log_message('error', 'Processing file ID: ' . $id);
$lead_file = $this->leadFilesModel
->where('lead_id', $lead_id)
->where('id', $id)
->where('is_active', 1)
->first();
if ($lead_file) {
log_message('error', 'Found lead file: ' . print_r($lead_file, true));
$fullPath = $lead_file_path . $lead_file['file_name'];
log_message('error', 'Full file path: ' . $fullPath);
if (file_exists($fullPath) && !empty($fileName)) {
$attachments[] = [
'fileName' => $lead_file['file_name'],
'filePath' => $fullPath
];
if (file_exists($fullPath)) {
log_message('error', 'File exists at path: ' . $fullPath);
if (!empty($lead_file['file_name'])) {
log_message('error', 'File name is not empty: ' . $lead_file['file_name']);
$attachments[] = [
'fileName' => $lead_file['file_name'],
'filePath' => $fullPath
];
} else {
log_message('warning', 'File name is empty for ID: ' . $id);
}
} else {
log_message('warning', 'File does not exist at path: ' . $fullPath);
}
} else {
log_message('warning', 'No active lead file found for ID: ' . $id . ' and lead_id: ' . $lead_id);
}
}
} else {
log_message('error', 'json_string is empty');
}
log_message('error', 'Attachments prepared: ' . print_r($attachments, true));
return $attachments;
}
public function handleMemberDataGPATotalSumInsurerFromExcel($params)
{
$lead_id = $params['lead_id'];

View File

@ -1575,14 +1575,21 @@ class TicketController extends BaseController
$statusMapping = json_decode($incoming_form_values['extra_fields_array_for_validate']);
foreach ($statusMapping as $status => $requiredFields) {
// Ensure requiredFields is an array
if (!is_array($requiredFields)) {
$requiredFields = [$requiredFields];
}
// Check if all required fields exist and are not empty in the incoming form values
$allFieldsMatched = true;
foreach ($requiredFields as $field) {
if(in_array($field, ['approved_description'])){
continue;
}
if (!isset($incoming_form_values[$field]) || empty($incoming_form_values[$field])) {
$allFieldsMatched = false;
break;

View File

@ -848,18 +848,25 @@ if (isset($selected_lead_type)) {
}
function waitForDropdownValue(selector, value, callback, retries = 20) {
const trySet = () => {
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
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);
setTimeout(trySet, 300); // retry without re-passing arguments
retries--;
} else {
console.warn(`Value ${value} not found for ${selector}`);
callback(); // Proceed anyway to avoid hanging
}
};
trySet();
}
@ -868,40 +875,35 @@ if (isset($selected_lead_type)) {
let lead_type = data.lead_type || null;
waitForDropdownValue('#client_id', data.client_id || '', () => {
if (lead_type == 3) {
$('#client_id').prepend($('<option>', {
value: 'add_client',
text: '+ Add Client'
}));
// Add "+ Add Client" option if not already present
if ($('#client_id option[value="add_client"]').length === 0) {
$('#client_id').prepend($('<option>', {
value: 'add_client',
text: '+ Add Client'
}));
}
console.log("trying to remove required ");
$("#source_policy_id").prop("required",false);
$("#source_policy_id").closest("div") .find("label .text-danger").remove();
console.log("Trying to remove 'required' attribute and asterisk");
$("#source_policy_id").prop("required", false);
$("#source_policy_id").closest("div").find("label .text-danger").remove();
} else if (lead_type != 3) {
$("#source_policy_id").prop("required",true);
} else {
$("#source_policy_id").prop("required", true);
// Check if the asterisk doesn't already exist, then add it
let $label = $("#source_policy_id")
.closest("div")
.find("label");
// Add asterisk if not present
let $label = $("#source_policy_id").closest("div").find("label");
if ($label.find(".text-danger").length === 0) {
$label.append(' <span class="text-danger">*</span>');
}
var addOption = $('#client_id option[value="add_client"]');
if (addOption.length > 0) {
addOption.remove();
}
console.log("rying to remove required and option removed from client")
// Remove "+ Add Client" option if exists
$('#client_id option[value="add_client"]').remove();
console.log("Set 'required' for source_policy_id and removed add_client option if present");
}
waitForDropdownValue('#client_branch_id', data.client_branch_id || '', () => {
// Fill other fields once both dropdowns are ready
// Fill other form fields
$('#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 || '');
@ -917,9 +919,10 @@ if (isset($selected_lead_type)) {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
$(".loss_date").each(function () {
flatpickr(this, {
dateFormat: "d-m-Y",
dateFormat: "d-m-Y"
});
});
});

View File

@ -480,6 +480,7 @@
var doa = flatpickr("#doa", {
dateFormat: "d/m/Y",
allowInput: false,
maxDate: "today",
onChange: function(selectedDates) {
let selectedDOA = selectedDates[0]; // Get selected DOA date
dod.set("minDate", selectedDOA); // Set DOD minDate to DOA
@ -488,35 +489,43 @@
var dod = flatpickr("#dod", {
dateFormat: "d/m/Y",
allowInput: false
allowInput: false,
maxDate: "today"
});
flatpickr("#raised_date", {
dateFormat: "d/m/Y",
maxDate: "today",
allowInput: false
});
flatpickr("#registration_date", {
dateFormat: "d/m/Y",
maxDate: "today",
allowInput: false
});
flatpickr("#query_received_date", {
dateFormat: "d/m/Y",
maxDate: "today",
allowInput: false
});
flatpickr("#denial_date", {
dateFormat: "d/m/Y",
maxDate: "today",
allowInput: false
});
flatpickr("#approved_date", {
dateFormat: "d/m/Y",
maxDate: "today",
allowInput: false
});
flatpickr("#settled_date", {
dateFormat: "d/m/Y",
maxDate: "today",
allowInput: false
});
flatpickr("#pay_initiate_date", {
dateFormat: "d/m/Y",
maxDate: "today",
allowInput: false
});
@ -633,6 +642,29 @@
$field.prop('required', true);
}
}
let extrafieldsArray = $('#extra_fields_array_for_validate').val();
try {
extrafieldsArray = JSON.parse(extrafieldsArray);
// Keep only the entry for the current claim_status_id
extrafieldsArray = {
[selectedVal]: extrafieldsArray[selectedVal]
};
console.log('Filtered extrafieldsArray:', extrafieldsArray);
extrafieldsArray = JSON.stringify(extrafieldsArray);
console.log('Filtered extrafieldsArray string:', extrafieldsArray);
$('#extra_fields_array_for_validate').val(extrafieldsArray);
} catch (error) {
console.error("Invalid JSON format in extra_fields_array_for_validate:", error);
return;
}
});
function claimStatusFieldChanges(fields) {
@ -1080,6 +1112,7 @@
console.log("doa not found, initializing");
doa = flatpickr("#doa", {
dateFormat: "d/m/Y",
maxDate: "today",
allowInput: false,
onChange: function(selectedDates) {
let selectedDOA = selectedDates[0]; // Get selected DOA date
@ -1089,6 +1122,7 @@
});
var dod = flatpickr("#dod", {
dateFormat: "d/m/Y",
maxDate: "today",
allowInput: false
});
} else {

View File

@ -364,21 +364,25 @@
$("#emp_client_policy").select2();
date_of_join = flatpickr("#date_of_join", {
dateFormat: "d/m/Y",
maxDate: "today",
allowInput: false
});
dob = flatpickr("#dob", {
dateFormat: "d/m/Y",
maxDate: "today",
allowInput: false
});
var date_of_incep = flatpickr("#date_of_incep", {
dateFormat: "d/m/Y",
maxDate: "today",
allowInput: false
});
date_of_accident = flatpickr("#date_of_accident", {
dateFormat: "d/m/Y",
maxDate: "today",
allowInput: false,
onChange: function(selectedDates) {
let selectedDOA = selectedDates[0]; // Get selected DOA date
@ -389,20 +393,24 @@
date_of_death = flatpickr("#date_of_death", {
dateFormat: "d/m/Y",
maxDate: "today",
allowInput: false
});
date_of_intimat = flatpickr("#date_of_intimat", {
dateFormat: "d/m/Y",
maxDate: "today",
allowInput: false
});
flatpickr("#approved_date", {
dateFormat: "d/m/Y",
maxDate: "today",
allowInput: false
});
flatpickr("#settled_date", {
dateFormat: "d/m/Y",
maxDate: "today",
allowInput: false
});