From fc10f71680b3b1927030464726a95dd1ee1f6a19 Mon Sep 17 00:00:00 2001 From: Venkatesh Date: Sat, 18 Apr 2026 11:40:35 +0530 Subject: [PATCH] FIX_LEAD_TO_OPPRTUTITIES_AND_MEDIASSIST_CLAIMS_STATUS_MAPPING --- app/Controllers/LeadsController.php | 4 ++-- app/Controllers/MediAssistApiController.php | 6 ++--- app/Views/leads_form.php | 3 +++ app/Views/leads_form_handler.php | 10 +++++--- app/Views/leads_non_eb.php | 26 ++++++++++++--------- 5 files changed, 30 insertions(+), 19 deletions(-) diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index b6f5f35f..765afe8f 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -4774,7 +4774,7 @@ class LeadsController extends BaseController // 🔹 Client Details (Single Row) $data['actual_lead_client_details'] = $this->leadModel - ->select('sales_actual_leads.company_name, clients.short_name, sales_actual_leads.email, sales_actual_leads.phone, sales_actual_leads.address, sales_actual_leads.website, sales_actual_leads.gst_number, sales_actual_leads.status, sales_actual_leads.assigned_to') + ->select('sales_actual_leads.company_name, clients.short_name, clients.client_type, sales_actual_leads.email, sales_actual_leads.phone, sales_actual_leads.address, sales_actual_leads.website, sales_actual_leads.gst_number, sales_actual_leads.status, sales_actual_leads.assigned_to') ->join('clients', 'clients.id = sales_actual_leads.client_id', 'left') ->where('sales_actual_leads.lead_id', $actual_lead_id) ->first(); // first row only @@ -5527,7 +5527,7 @@ class LeadsController extends BaseController * * @param string $recipientType insurer|client|internal */ - protected function downloadFileFromGoogleSheet(array $lead_data, string $recipientType = 'insurer'): array + protected function downloadFileFromGoogleSheet(array $lead_data, string $recipientType = 'insurer'): ?array { try { $leadId = (int) ($lead_data['id'] ?? 0); diff --git a/app/Controllers/MediAssistApiController.php b/app/Controllers/MediAssistApiController.php index 3a70329b..e553b989 100644 --- a/app/Controllers/MediAssistApiController.php +++ b/app/Controllers/MediAssistApiController.php @@ -596,7 +596,7 @@ class MediAssistApiController extends BaseController "Confirmation Awaited" => 4, "Information Awaited Reminder" => 4, "Information Awaited Final Reminder" => 4, - "Insurer Concurrence Awaited" => 6, + "Insurer Concurrence Awaited" => 7, "Closed" => 12, "Physical Documents Awaited" => 9, @@ -944,7 +944,7 @@ class MediAssistApiController extends BaseController "Confirmation Awaited" => 4, "Information Awaited Reminder" => 4, "Information Awaited Final Reminder" => 4, - "Insurer Concurrence Awaited" => 6, + "Insurer Concurrence Awaited" => 7, "Closed" => 12, "Physical Documents Awaited" => 9, @@ -1191,7 +1191,7 @@ class MediAssistApiController extends BaseController "Confirmation Awaited" => 4, "Information Awaited Reminder" => 4, "Information Awaited Final Reminder" => 4, - "Insurer Concurrence Awaited" => 6, + "Insurer Concurrence Awaited" => 7, "Closed" => 12, "Physical Documents Awaited" => 9, diff --git a/app/Views/leads_form.php b/app/Views/leads_form.php index af7fbeff..c4b3e57a 100644 --- a/app/Views/leads_form.php +++ b/app/Views/leads_form.php @@ -2516,6 +2516,9 @@ $('#client_name').val(actualLeadClientName); $('#gst').val(actual_lead_client_details.gst_number || ''); + if (actual_lead_client_details.client_type !== undefined && actual_lead_client_details.client_type !== null && actual_lead_client_details.client_type !== '') { + $('#client_type').val(String(actual_lead_client_details.client_type)); + } // existingShortName = actual_lead_client_details.short_name || ''; // if (existingShortName) { diff --git a/app/Views/leads_form_handler.php b/app/Views/leads_form_handler.php index 1e984f08..6665a52a 100644 --- a/app/Views/leads_form_handler.php +++ b/app/Views/leads_form_handler.php @@ -525,9 +525,13 @@ if (isset($selected_lead_type)) { } if(client_type == ""){ - toastr.warning('Please select the client type', 'Warning'); - $('#client_short_name').val('') - return; + var aid = $('#actual_lead_id').val(); + if (!aid || aid === '0') { + toastr.warning('Please select the client type', 'Warning'); + $('#client_short_name').val(''); + return; + } + // Actual-lead autofill: short name may be set before client type is chosen; do not clear it. } let value = $(input).val(); diff --git a/app/Views/leads_non_eb.php b/app/Views/leads_non_eb.php index 3fdbc536..7ee7ca64 100644 --- a/app/Views/leads_non_eb.php +++ b/app/Views/leads_non_eb.php @@ -853,8 +853,10 @@ var pageBackButton = '" class="topbar-icon $('#client_name').val(actualLeadClientName); $('#gst').val(actual_lead_client_details.gst_number || ''); - // existingShortName = actual_lead_client_details.short_name || ''; - // if (existingShortName) { - // // ── Short name EXISTS — just populate and validate ──────── - // $('#client_short_name').val(existingShortName); - // // validateInput($('#client_short_name')[0], 'clients', 'short_name'); - - // } else {} - // Auto-generate short name from company name - // Use a small delay to ensure DOM is ready + if (actual_lead_client_details.client_type !== undefined && actual_lead_client_details.client_type !== null && actual_lead_client_details.client_type !== '') { + $('#client_type').val(String(actual_lead_client_details.client_type)); + } + let existingShortName = actual_lead_client_details.short_name || ''; + if (existingShortName) { + // Prefer persisted short name while editing. + actualLeadShortName = existingShortName; + $('#client_short_name').val(existingShortName); + } else { + // Fallback: generate only when short name is unavailable. setTimeout(function () { let baseName = actual_lead_client_details.company_name .trim() @@ -1377,6 +1380,7 @@ var pageBackButton = '