FIX_POLICY_DORPDOWN : RV

This commit is contained in:
VENKATESHWARAN 2025-03-28 11:30:58 +05:30
parent 629abacbfd
commit 5aac785f21
3 changed files with 77 additions and 8 deletions

View File

@ -3675,6 +3675,7 @@ class ClientController extends AdminController
} }
} }
//Function for get all client, branch and policy data
public function getClientAndBranchAndPolicy() public function getClientAndBranchAndPolicy()
{ {
// ---------for client----------------------------------------------------------------------------- // ---------for client-----------------------------------------------------------------------------
@ -3725,6 +3726,7 @@ class ClientController extends AdminController
policy_type.iep, policy_type.iep,
policy_type.itp, policy_type.itp,
policy_type.bap, policy_type.bap,
policy_type.allocg,
DATE_FORMAT(client_policy.policy_start_date, '%d/%m/%Y') as policy_start_date, DATE_FORMAT(client_policy.policy_start_date, '%d/%m/%Y') as policy_start_date,
DATE_FORMAT(client_policy.policy_end_date, '%d/%m/%Y') as policy_end_date DATE_FORMAT(client_policy.policy_end_date, '%d/%m/%Y') as policy_end_date
") ")
@ -4739,9 +4741,14 @@ class ClientController extends AdminController
// $data = $this->leadsModel->where('leads.id', 125)->where('leads.is_active', 1)->first(); // $data = $this->leadsModel->where('leads.id', 125)->where('leads.is_active', 1)->first();
// $RFQdata = $RFQModel->getRFQTableDataWithLeadIDAndType(125, 2); // $RFQdata = $RFQModel->getRFQTableDataWithLeadIDAndType(125, 2);
// Kint::dump($RFQdata['json']); // // Kint::dump($RFQdata);
// $returnData = $LeadsController->getPlacementJson($data); // $returnData = $LeadsController->getPlacementJson($data);
// $this->clientPolicyModel->where('id', 6050)->set('placement_json', $returnData)->update(); // Kint::dump($returnData);
// $policy_terms = $LeadsController->convertNonEbQCRJsonToPolicyTerms(json_decode($returnData, true));
// Kint::dump($policy_terms);
// // $this->clientPolicyModel->where('id', 6050)->set('placement_json', $returnData)->update();
// $this->clientPolicyModel->where('id', 6050)->set('policy_terms', $policy_terms)->update();
// dd($returnData); // dd($returnData);
} }

View File

@ -2302,6 +2302,7 @@ class LeadsController extends BaseController
$placementJson = $this->getPlacementJson($data); $placementJson = $this->getPlacementJson($data);
if ($placementJson) { if ($placementJson) {
$client_policy_data['placement_json'] = $placementJson; $client_policy_data['placement_json'] = $placementJson;
$client_policy_data['policy_terms'] = $this->convertNonEbQCRJsonToPolicyTerms(json_decode($placementJson, true));
} }
} }
@ -2401,6 +2402,53 @@ class LeadsController extends BaseController
return json_encode($terms_array); return json_encode($terms_array);
} }
public function convertNonEbQCRJsonToPolicyTerms($allTableData)
{
if (!empty($allTableData)) {
array_pop($allTableData); // Remove the last item from the array
$terms_array = [];
foreach ($allTableData as $TableIndex => $tableGroup) {
if ($TableIndex == 0) {
continue;
}
foreach ($tableGroup['table_data']['data'] as $dataRow) {
$item = $dataRow['items'] ?? '';
foreach ($dataRow['data'] as $cellData) {
$parentth = $cellData['parentth'] ?? '';
$subth = $cellData['subth'] ?? '';
$value = $cellData['display_content'] ?? '';
// Skip unwanted keys
if (in_array($parentth, ['SNO', 'Particulars', 'Action']) || $subth === 'Quote Asked') {
continue;
}
// Skip if item matches parentth
if ($item === $parentth) {
continue;
}
// Set the value directly, overwriting with latest encountered
if (!empty($item) && !empty($value)) {
$terms_array[$item] = $value;
}
}
}
}
return json_encode($terms_array);
} else {
return null;
}
}
public function featchClientPolicyFromLead($client_id, $branch_id, $lead_id) public function featchClientPolicyFromLead($client_id, $branch_id, $lead_id)
{ {
$data = $this->leadsModel->where('leads.id', $lead_id)->where('leads.is_active', 1)->first(); $data = $this->leadsModel->where('leads.id', $lead_id)->where('leads.is_active', 1)->first();

View File

@ -85,6 +85,7 @@ if (isset($selected_lead_type)) {
var policy_list = ''; // local variable for storing the client policy list var policy_list = ''; // local variable for storing the client policy list
var temp_client_id = 0; var temp_client_id = 0;
var temp_branch_id = 0; var temp_branch_id = 0;
var selected_lead_form_type = <?= isset($selected_lead_type) ? $selected_lead_type : 0 ?>;
// select2 document ready // select2 document ready
$(document).ready(function() { $(document).ready(function() {
@ -188,7 +189,9 @@ if (isset($selected_lead_type)) {
} }
function appendRenewalPolicies(data) { function appendRenewalPolicies(data) {
console.log('appendRenewalPolicies', data); console.log('appendRenewalPolicies', data);
console.log('selected_lead_form_type', selected_lead_form_type);
$('#source_policy_id').empty(); $('#source_policy_id').empty();
@ -198,14 +201,25 @@ if (isset($selected_lead_type)) {
})); }));
$.each(data, function(index, item) { $.each(data, function(index, item) {
let shouldAppend = false;
var option = $('<option>', { if (selected_lead_form_type == 1) {
value: item.id, shouldAppend = (item.allocg !== "Non-EB" && item.allocg !== "Marine");
text: item.policy_type + '-' + item.policy_no, } else if (selected_lead_form_type == 2) {
}); shouldAppend = (item.allocg === "Non-EB" || item.allocg === "Marine");
} else {
shouldAppend = true;
}
$('#source_policy_id').append(option); if (shouldAppend) {
const option = $('<option>', {
value: item.id,
text: item.policy_type + ' - ' + item.policy_no,
});
$('#source_policy_id').append(option);
}
}); });
} }
//-------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------