diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php
index 77a6ba81..1c124a37 100644
--- a/app/Controllers/LeadsController.php
+++ b/app/Controllers/LeadsController.php
@@ -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'];
diff --git a/app/Controllers/TicketController.php b/app/Controllers/TicketController.php
index 005bebc4..5f790251 100644
--- a/app/Controllers/TicketController.php
+++ b/app/Controllers/TicketController.php
@@ -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;
diff --git a/app/Views/leads_form_handler.php b/app/Views/leads_form_handler.php
index 7d9a6006..cc06b807 100644
--- a/app/Views/leads_form_handler.php
+++ b/app/Views/leads_form_handler.php
@@ -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($('