FEAT_PLACEMENT_JSON_CLIENT_POLICY : RV
This commit is contained in:
parent
37d17e47f1
commit
6f8f617222
@ -4713,7 +4713,8 @@ class ClientController extends AdminController
|
||||
// dd($data);
|
||||
|
||||
|
||||
// $LeadsController = new LeadsController();
|
||||
$LeadsController = new LeadsController();
|
||||
$RFQModel = new RFQModel();
|
||||
// $path = $LeadsController->constructNonEbExcelToSaveTemp(106, 2, "Proposal 2-ICICIPRU-ICICI001");
|
||||
// $filepath = $path['filePath'];
|
||||
|
||||
@ -4735,6 +4736,15 @@ class ClientController extends AdminController
|
||||
// } else {
|
||||
// echo "File does not exist.";
|
||||
// }
|
||||
|
||||
// $data = $this->leadsModel->where('leads.id', 115)->where('leads.is_active', 1)->first();
|
||||
// $RFQdata = $RFQModel->getRFQTableDataWithLeadIDAndType(115, 2);
|
||||
// Kint::dump($RFQdata['json']);
|
||||
// $returnData = $LeadsController->getPlacementJson($data);
|
||||
// $this->clientPolicyModel->where('id', 6050)->set('placement_json', $returnData)->update();
|
||||
// dd($returnData);
|
||||
|
||||
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------
|
||||
|
||||
@ -584,8 +584,17 @@ class LeadsController extends BaseController
|
||||
|
||||
$data['occupancy'] = $this->occupancyModel->findAll();
|
||||
// dd($data['occupancy']);
|
||||
$data['policies'] = json_decode($data['question_json'], true)['policies'];
|
||||
$data["child_table_data"] = json_decode($data['question_json'], true)['child_table_data'];
|
||||
|
||||
if($lead_data['lead_type'] == 2){
|
||||
$client_policy_data = $this->clientPolicyModel->where('is_active', 1)->where('id', $lead_data['source_policy_id'])->first();
|
||||
$data['rfq_data']['json'] = $client_policy_data['placement_json'];
|
||||
}
|
||||
|
||||
if(!empty($data['question_json'])){
|
||||
$data['policies'] = json_decode($data['question_json'], true)['policies'];
|
||||
$data["child_table_data"] = json_decode($data['question_json'], true)['child_table_data'];
|
||||
}
|
||||
|
||||
// $data['lead_register_data'] = json_decode($data['lead_data']['custom_fields']);
|
||||
// dd($data['lead_register_data']);
|
||||
$data['client_type'] = $this->clientType;
|
||||
@ -2272,8 +2281,6 @@ class LeadsController extends BaseController
|
||||
'policy_status' => 1,
|
||||
];
|
||||
|
||||
$terms = $this->preparePolicyTermsFromRFQ($data);
|
||||
|
||||
$policy_type_id = $data['policy_type_id'];
|
||||
if (in_array($policy_type_id, [1, 2, 6, 7])) {
|
||||
$client_policy_data['is_addon'] = 1; // Base Policy
|
||||
@ -2287,8 +2294,16 @@ class LeadsController extends BaseController
|
||||
// }
|
||||
}
|
||||
|
||||
$client_policy_data['policy_terms'] = $this->preparePolicyTermsFromRFQ($data);
|
||||
if($data['lead_form_type'] == 1){
|
||||
$client_policy_data['policy_terms'] = $this->preparePolicyTermsFromRFQ($data);
|
||||
}else{
|
||||
|
||||
$placementJson = $this->getPlacementJson($data);
|
||||
if ($placementJson) {
|
||||
$client_policy_data['placement_json'] = $placementJson;
|
||||
}
|
||||
|
||||
}
|
||||
// print_r($client_policy_data); die;
|
||||
|
||||
return $client_policy_data;
|
||||
@ -2298,7 +2313,7 @@ class LeadsController extends BaseController
|
||||
{
|
||||
$proposel_data = json_decode($data['proposel_data'], true);
|
||||
|
||||
$QCRData = $this->RFQModel->where('is_active', 1)->where('type', 2)->where('lead_id', $data['id'])->first();
|
||||
$QCRData = $this->RFQModel->where('is_active', 1)->where('lead_id', $data['id'])->first();
|
||||
|
||||
$JSON = json_decode($QCRData['json'], true);
|
||||
|
||||
@ -2405,6 +2420,40 @@ class LeadsController extends BaseController
|
||||
return $this->respond(['status' => false, 'message' => 'Failed to create policy', 'data' => $data], 200);
|
||||
}
|
||||
|
||||
public function getPlacementJson(array $data): ?string
|
||||
{
|
||||
$proposel_data = json_decode($data['proposel_data'], true);
|
||||
|
||||
$QCRData = $this->RFQModel
|
||||
->where('is_active', 1)
|
||||
->where('lead_id', $data['id'])
|
||||
->first();
|
||||
|
||||
if (!$QCRData || empty($QCRData['json'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$jsonArray = json_decode($QCRData['json'], true);
|
||||
$proposalData = array_pop($jsonArray); // Get last item and remove it from the array
|
||||
|
||||
if (empty($jsonArray)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$placement_json_data = array_map(function ($jsonData) use ($proposel_data) {
|
||||
return $this->transformNonEbProposelData(
|
||||
$jsonData,
|
||||
$proposel_data['proposel_name'] ?? '',
|
||||
$proposel_data['insurer_name'] ?? '', null, 1
|
||||
);
|
||||
}, $jsonArray);
|
||||
|
||||
$placement_json_data[] = $proposalData;
|
||||
|
||||
return json_encode($placement_json_data);
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
@ -3268,7 +3317,7 @@ class LeadsController extends BaseController
|
||||
return null;
|
||||
}
|
||||
|
||||
public function transformNonEbProposelData(&$data, $proposal, $insurer, $tableCount)
|
||||
public function transformNonEbProposelData(&$data, $proposal, $insurer, $tableCount=null, $actionColumn = null)
|
||||
{
|
||||
// Kint::dump($data, $proposal, $insurer, $tableCount);
|
||||
|
||||
@ -3305,6 +3354,13 @@ class LeadsController extends BaseController
|
||||
// Update the original data's headers
|
||||
$data['table_data']['headers'] = $headerData;
|
||||
|
||||
if(!empty($actionColumn)){
|
||||
$data['table_data']['headers'][] = [
|
||||
'parentHeader' => "Action",
|
||||
'subHeaders' => ['-']
|
||||
];
|
||||
}
|
||||
|
||||
foreach ($data['table_data']['data'] as &$entry) {
|
||||
|
||||
$sno = $entry['SNO'];
|
||||
@ -3329,6 +3385,12 @@ class LeadsController extends BaseController
|
||||
if ($item['parentth'] === $proposal && $item['subth'] === $insurer) {
|
||||
$filteredData[] = $item;
|
||||
}
|
||||
|
||||
if(!empty($actionColumn)){
|
||||
if($item['parentth'] === "Action"){
|
||||
$filteredData[] = $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update the entry with filtered data
|
||||
|
||||
@ -54,6 +54,7 @@ class ClientPolicyModel extends Model
|
||||
"is_member_modify_allowed",
|
||||
"cd_ac_pk",
|
||||
"is_lgbtq",
|
||||
"placement_json",
|
||||
];
|
||||
|
||||
// Callbacks
|
||||
|
||||
@ -294,6 +294,25 @@ if (isset($selected_lead_type)) {
|
||||
$('#salse_person_id').trigger('change');
|
||||
}
|
||||
|
||||
function validateInput(input, table, field){
|
||||
|
||||
let value = $(input).val();
|
||||
let label = $(input).closest('.form-group').find('label').text().replace('*', '').trim();
|
||||
|
||||
let message = "Value is duplicate!";
|
||||
if(label){
|
||||
message = label + " already exists!";
|
||||
}
|
||||
|
||||
checkDuplicateTableFieldValue(table, field, value, function(isDuplicate) {
|
||||
if (isDuplicate) {
|
||||
toastr.warning(message, 'WARNING');
|
||||
$(input).val('')
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user