CHANGE_RFQ_NEW_CR : RV
This commit is contained in:
parent
e67f49fc5d
commit
84fb4e7971
@ -1994,9 +1994,22 @@ class ClientController extends AdminController
|
||||
|
||||
if ($id) {
|
||||
$client_policy_data = $this->clientPolicyModel->where(['id' => $id, 'is_active' => 1])->first();
|
||||
|
||||
$insurer_id = $client_policy_data['insurer_id'];
|
||||
$client_id = $client_policy_data['client_id'];
|
||||
|
||||
if (!empty($client_policy_data['policy_start_date'])) {
|
||||
$client_policy_data['source_policy_start_date'] = change_date_format($client_policy_data['policy_start_date'], 'Y-m-d', 'd/m/Y');
|
||||
} else {
|
||||
$client_policy_data['source_policy_start_date'] = null;
|
||||
}
|
||||
|
||||
if (!empty($client_policy_data['policy_end_date'])) {
|
||||
$client_policy_data['source_policy_end_date'] = change_date_format($client_policy_data['policy_end_date'], 'Y-m-d', 'd/m/Y');
|
||||
} else {
|
||||
$client_policy_data['source_policy_end_date'] = null;
|
||||
}
|
||||
|
||||
$polices = $this->policesModel
|
||||
->select('policies.*, policy_type.policy_type')
|
||||
->join('policy_type', 'policy_type.id = policies.policy_type_id')
|
||||
@ -2022,7 +2035,7 @@ class ClientController extends AdminController
|
||||
'policy' => $polices,
|
||||
'client_policy_list' => $client_policy_list,
|
||||
'end_date' => $newDate,
|
||||
'new_start_date' => date('d/m/Y', strtotime($client_policy_data['policy_end_date']))
|
||||
'new_start_date' => date('d/m/Y', strtotime($client_policy_data['policy_end_date'] . ' +1 day')),
|
||||
], 200);
|
||||
} else {
|
||||
return $this->respond(['status' => false, 'code' => 404, 'message' => 'no data found'], 200);
|
||||
@ -4740,8 +4753,7 @@ class ClientController extends AdminController
|
||||
// }
|
||||
|
||||
// $data = $this->leadsModel->where('leads.id', 125)->where('leads.is_active', 1)->first();
|
||||
// $RFQdata = $RFQModel->getRFQTableDataWithLeadIDAndType(125, 2);
|
||||
// // Kint::dump($RFQdata);
|
||||
// $RFQdata = $RFQModel->getRFQTableDataWithLeadIDAndType(145, 2);
|
||||
// $returnData = $LeadsController->getPlacementJson($data);
|
||||
// Kint::dump($returnData);
|
||||
// $policy_terms = $LeadsController->convertNonEbQCRJsonToPolicyTerms(json_decode($returnData, true));
|
||||
@ -4751,6 +4763,20 @@ class ClientController extends AdminController
|
||||
// $this->clientPolicyModel->where('id', 6050)->set('policy_terms', $policy_terms)->update();
|
||||
// dd($returnData);
|
||||
|
||||
// Kint::dump($RFQdata['json']);
|
||||
// $inputJson = json_decode($RFQdata['json'], true);
|
||||
// Kint::dump($inputJson);
|
||||
// // print_rr($inputJson['table_data']);
|
||||
// $sortedJson = $this->reorderProposalsByInsurerTotal($inputJson);
|
||||
|
||||
// // If you want to convert back to JSON string
|
||||
// $finalJson = json_encode($sortedJson, JSON_PRETTY_PRINT);
|
||||
|
||||
// // $RFQModel->insert(['lead_id' => 145, 'json' => $finalJson, 'type' => 1]);
|
||||
|
||||
// dd($finalJson);
|
||||
|
||||
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------
|
||||
@ -5456,6 +5482,207 @@ class ClientController extends AdminController
|
||||
$id = $InsurerModel->insert($insurerData);
|
||||
return $id;
|
||||
}
|
||||
|
||||
private function reorderProposalsByInsurerTotal(array $data): array {
|
||||
|
||||
Kint::dump($data);
|
||||
if (!isset($data['premium_data']['data'])) return $data;
|
||||
|
||||
$original = $data['premium_data']['data'];
|
||||
$proposals = [];
|
||||
$others = [];
|
||||
$emptyKeyData = [];
|
||||
|
||||
foreach ($original as $key => $value) {
|
||||
// Match only keys that look like 'Proposal X'
|
||||
if (preg_match('/^Proposal\s+\d+$/', $key)) {
|
||||
// Get the insurer entry (not 'Quote Asked')
|
||||
foreach ($value as $subKey => $subVal) {
|
||||
if ($subKey !== 'Quote Asked' && isset($subVal['Total'])) {
|
||||
$proposals[$key] = $value;
|
||||
break;
|
||||
}else{
|
||||
$proposals[$key] = $value;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
if ($key === '' && isset($value['']) && is_array($value[''])) {
|
||||
// Capture empty key to push it later
|
||||
$emptyKeyData[$key] = $value;
|
||||
}else{
|
||||
$others[$key] = $value;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// dd($proposals, $others, $emptyKeyData);
|
||||
// Sort proposals by their insurer's total
|
||||
uasort($proposals, function($a, $b) {
|
||||
$totalA = 0;
|
||||
$totalB = 0;
|
||||
|
||||
foreach ($a as $key => $val) {
|
||||
if ($key !== 'Quote Asked' && isset($val['Total'])) {
|
||||
$totalA = floatval($val['Total']);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($b as $key => $val) {
|
||||
if ($key !== 'Quote Asked' && isset($val['Total'])) {
|
||||
$totalB = floatval($val['Total']);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $totalA <=> $totalB;
|
||||
});
|
||||
|
||||
// Merge back the sorted proposals into the full structure
|
||||
$data['premium_data']['data'] = array_merge($others, $proposals, $emptyKeyData);
|
||||
$data = $this->reorderProposalDataByPremiumOrder($data);
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function reorderProposalDataByPremiumOrder(array $data): array {
|
||||
if (!isset($data['premium_data']['data'], $data['proposal_data']['over_all_column_data'])) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
$premiumProposals = array_keys($data['premium_data']['data']);
|
||||
$filteredProposals = [];
|
||||
|
||||
// Collect proposal keys that match the pattern "Proposal X"
|
||||
foreach ($premiumProposals as $key) {
|
||||
if (preg_match('/^Proposal\s+\d+$/', $key) && isset($data['proposal_data']['over_all_column_data'][$key])) {
|
||||
$filteredProposals[$key] = $data['proposal_data']['over_all_column_data'][$key];
|
||||
}
|
||||
}
|
||||
|
||||
// dd($premiumProposals, $filteredProposals);
|
||||
|
||||
$data['proposal_data']['over_all_column_data'] = $filteredProposals;
|
||||
$data = $this->reorderProposalInHeaderAndData($data);
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function reorderProposalInHeaderAndData(array $data): array {
|
||||
|
||||
// Kint::dump($data);
|
||||
$tableData = $data['table_data'];
|
||||
$sortedProposalOrder = $data['proposal_data']['over_all_column_data'];
|
||||
$headers = $tableData['headers'] ?? [];
|
||||
$dataRows = $tableData['data'] ?? [];
|
||||
|
||||
// Step 1: Separate static and proposal headers
|
||||
$staticHeaders = [];
|
||||
$proposalHeaders = [];
|
||||
$actionHeader = [];
|
||||
foreach ($headers as $header) {
|
||||
if (in_array($header['parentHeader'], array_keys($sortedProposalOrder))) {
|
||||
$proposalHeaders[$header['parentHeader']] = $header;
|
||||
} else {
|
||||
if($header['parentHeader'] == "Action"){
|
||||
$actionHeader[] = $header;
|
||||
}else{
|
||||
$staticHeaders[] = $header;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// dd($staticHeaders, $proposalHeaders, $sortedProposalOrder);
|
||||
|
||||
// Step 2: Reorder headers
|
||||
$reorderedHeaders = [];
|
||||
foreach ($sortedProposalOrder as $proposalKey => $proposalValue) {
|
||||
if (isset($proposalHeaders[$proposalKey])) {
|
||||
$reorderedHeaders[] = $proposalHeaders[$proposalKey];
|
||||
}
|
||||
}
|
||||
|
||||
// print_rr($reorderedHeaders); die;
|
||||
foreach ($reorderedHeaders as $key => &$value) {
|
||||
$value['parentHeader'] = 'Proposal ' . ($key + 1);
|
||||
}
|
||||
unset($value);
|
||||
|
||||
|
||||
$reorderedHeaders = array_merge($staticHeaders, $reorderedHeaders, $actionHeader);
|
||||
|
||||
|
||||
// Step 3: Reorder each row's `data` by matching parentth
|
||||
foreach ($dataRows as $dataRowIndex => &$row) {
|
||||
$staticData = [];
|
||||
$proposalData = [];
|
||||
$actionData = [];
|
||||
|
||||
foreach ($row['data'] as $entry) {
|
||||
if (in_array($entry['parentth'], array_keys($sortedProposalOrder))) {
|
||||
$proposalData[$entry['parentth']][] = $entry;
|
||||
} else {
|
||||
if($entry['parentth'] == "Action"){
|
||||
$actionData[] = $entry;
|
||||
}else{
|
||||
$staticData[] = $entry;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$reorderedProposalData = [];
|
||||
foreach ($sortedProposalOrder as $proposalKey => $proposalValue) {
|
||||
if (isset($proposalData[$proposalKey])) {
|
||||
foreach ($proposalData[$proposalKey] as $entry) {
|
||||
$reorderedProposalData[] = $entry;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$dubParTh = "";
|
||||
$increament = 0;
|
||||
foreach ($reorderedProposalData as $key => &$value) {
|
||||
|
||||
if($dubParTh == $value['parentth']){
|
||||
$value['parentth'] = 'Proposal ' . ($increament);
|
||||
}else{
|
||||
$dubParTh = $value['parentth'];
|
||||
$increament = $increament + 1;
|
||||
$value['parentth'] = 'Proposal ' . ($increament);
|
||||
}
|
||||
}
|
||||
unset($value);
|
||||
|
||||
$row['data'] = array_merge($staticData, $reorderedProposalData, $actionData);
|
||||
}
|
||||
|
||||
$data['table_data']['headers'] = $reorderedHeaders;
|
||||
$data['table_data']['data'] = $dataRows;
|
||||
|
||||
// dd('-----', $data);
|
||||
$renumberedArray = $this->renumberProposalKeys($data['proposal_data']['over_all_column_data']);
|
||||
$updatedDataSet = $this->renumberProposalKeys($data['premium_data']['data']);
|
||||
$data['proposal_data']['over_all_column_data'] = !empty($renumberedArray) ? $renumberedArray : $data['proposal_data']['over_all_column_data'];
|
||||
$data['premium_data']['data'] = !empty($updatedDataSet) ? $updatedDataSet : $data['premium_data']['data'];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function renumberProposalKeys(array $input): array {
|
||||
$result = [];
|
||||
$counter = 1;
|
||||
|
||||
foreach ($input as $key => $value) {
|
||||
if (strpos($key, 'Proposal') === 0) {
|
||||
$newKey = 'Proposal ' . $counter++;
|
||||
$result[$newKey] = $value;
|
||||
} else {
|
||||
$result[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -101,7 +101,7 @@ class LeadsController extends BaseController
|
||||
$this->leadType = [1 => 'Fresh', 2 => 'Renewal', 3 => 'Roll Over'];
|
||||
$this->buisnessType = [1 => 'Industrial', 2 => 'Non Industrial'];
|
||||
$this->leadsStatus = [
|
||||
'queued' => 'Queued',
|
||||
'queued' => 'In-Queued',
|
||||
'qcr_sent' => 'QCR sent',
|
||||
'lost' => 'Lost',
|
||||
'co_insurer_pending' => 'Co-Insurer Pending',
|
||||
@ -202,6 +202,7 @@ class LeadsController extends BaseController
|
||||
} else {
|
||||
$data = $this->prepareMultipleLeadData($data);
|
||||
}
|
||||
|
||||
// print_r($data); die;
|
||||
return $data;
|
||||
}
|
||||
@ -210,8 +211,8 @@ class LeadsController extends BaseController
|
||||
{
|
||||
// print_r($data); die;
|
||||
$index_plus_one = 1;
|
||||
$form_file_name = "file_name_".$index_plus_one;
|
||||
$form_docs_name = "docs_name_".$index_plus_one;
|
||||
$form_file_name = "file_name_" . $index_plus_one;
|
||||
$form_docs_name = "docs_name_" . $index_plus_one;
|
||||
$leads_file_primary_key = $data['leads_file_id'] ?? [];
|
||||
$files = $this->request->getFileMultiple($form_file_name);
|
||||
$multi_file_data = $this->uploadMultiFiles($files, $data[$form_docs_name], $leads_file_primary_key);
|
||||
@ -252,7 +253,7 @@ class LeadsController extends BaseController
|
||||
}
|
||||
|
||||
// $data['file_name'] = file_Upload($files, $uploadFilePath);
|
||||
$data['multi_file_data']= $multi_file_data ?? null;
|
||||
$data['multi_file_data'] = $multi_file_data ?? null;
|
||||
|
||||
$processcedData[] = $data;
|
||||
|
||||
@ -268,8 +269,8 @@ class LeadsController extends BaseController
|
||||
foreach ($data['policy_type_id'] as $index => $value) {
|
||||
|
||||
$index_plus_one = $index + 1;
|
||||
$form_file_name = "file_name_".$index_plus_one;
|
||||
$form_docs_name = "docs_name_".$index_plus_one;
|
||||
$form_file_name = "file_name_" . $index_plus_one;
|
||||
$form_docs_name = "docs_name_" . $index_plus_one;
|
||||
$leads_file_primary_key = $data['leads_file_id'] ?? [];
|
||||
$files = $this->request->getFileMultiple($form_file_name);
|
||||
$multi_file_data = $this->uploadMultiFiles($files, $data[$form_docs_name], $leads_file_primary_key);
|
||||
@ -323,10 +324,22 @@ class LeadsController extends BaseController
|
||||
$incurred_claims_date = null;
|
||||
}
|
||||
|
||||
if (!empty($data['premium_date'][$index])) {
|
||||
$premium_date = change_date_format($data['premium_date'][$index], 'd/m/Y', 'Y-m-d');
|
||||
// if (!empty($data['premium_date'][$index])) {
|
||||
// $premium_date = change_date_format($data['premium_date'][$index], 'd/m/Y', 'Y-m-d');
|
||||
// } else {
|
||||
// $premium_date = null;
|
||||
// }
|
||||
|
||||
if (!empty($data['source_policy_start_date'])) {
|
||||
$data['source_policy_start_date'] = change_date_format($data['source_policy_start_date'], 'd/m/Y', 'Y-m-d');
|
||||
} else {
|
||||
$premium_date = null;
|
||||
$data['source_policy_start_date'] = null;
|
||||
}
|
||||
|
||||
if (!empty($data['source_policy_end_date'])) {
|
||||
$data['source_policy_end_date'] = change_date_format($data['source_policy_end_date'], 'd/m/Y', 'Y-m-d');
|
||||
} else {
|
||||
$data['source_policy_end_date'] = null;
|
||||
}
|
||||
|
||||
// $file_name = file_Upload($files[$index], $uploadFilePath);
|
||||
@ -383,7 +396,7 @@ class LeadsController extends BaseController
|
||||
'outstanding_claims' => $data['outstanding_claims'][$index] ?? 0,
|
||||
'policy_run_days' => $data['policy_run_days'][$index] ?? 0,
|
||||
'premium_at_inception' => $data['premium_at_inception'][$index] ?? 0,
|
||||
'premium_date' => $premium_date,
|
||||
'premium_date' => $data['premium_date'][$index] ?? 0,
|
||||
'earned_premium' => $data['earned_premium'][$index] ?? 0,
|
||||
'annualised_claims' => $data['annualised_claims'][$index] ?? 0,
|
||||
'incurred_claims_ratio' => $data['incurred_claims_ratio'][$index] ?? 0,
|
||||
@ -400,6 +413,9 @@ class LeadsController extends BaseController
|
||||
|
||||
'lead_form_type' => $data['lead_form_type'] ?? 1,
|
||||
'custom_fields' => $data['custom_fields'] ?? null,
|
||||
|
||||
'source_policy_start_date' => $data['source_policy_start_date'] ?? null,
|
||||
'source_policy_end_date' => $data['source_policy_end_date'] ?? null,
|
||||
];
|
||||
}
|
||||
// print_r($processedData);die();
|
||||
@ -479,11 +495,11 @@ class LeadsController extends BaseController
|
||||
$data['incurred_claims_date'] = null;
|
||||
}
|
||||
|
||||
if (!empty($data['premium_date'])) {
|
||||
$data['premium_date'] = change_date_format($data['premium_date'], 'Y-m-d', 'd/m/Y');
|
||||
} else {
|
||||
$data['premium_date'] = null;
|
||||
}
|
||||
// if (!empty($data['premium_date'])) {
|
||||
// $data['premium_date'] = change_date_format($data['premium_date'], 'Y-m-d', 'd/m/Y');
|
||||
// } else {
|
||||
// $data['premium_date'] = null;
|
||||
// }
|
||||
|
||||
$data['multi_file_data'] = $this->leadFilesModel->where('lead_id', $id)->first() ?? null;
|
||||
|
||||
@ -538,26 +554,25 @@ class LeadsController extends BaseController
|
||||
}
|
||||
|
||||
public function insertMultiFilesData($data, $lead_id)
|
||||
{
|
||||
{
|
||||
// print_r($data); die;
|
||||
|
||||
if(!empty($data)){
|
||||
if (!empty($data)) {
|
||||
foreach ($data as $key => $value) {
|
||||
|
||||
if(!empty($value['id'])){
|
||||
if (!empty($value['id'])) {
|
||||
|
||||
$lead_file_data = [
|
||||
'lead_id' => $lead_id,
|
||||
'docs_name' => $value['docs_name'],
|
||||
];
|
||||
|
||||
if(!empty($value['file_name'])) {
|
||||
if (!empty($value['file_name'])) {
|
||||
$lead_file_data['file_name'] = $value['file_name'];
|
||||
}
|
||||
|
||||
$this->leadFilesModel->where('id', $value['id'])->set($lead_file_data)->update();
|
||||
|
||||
}else{
|
||||
} else {
|
||||
|
||||
$lead_file_data = [
|
||||
'lead_id' => $lead_id,
|
||||
@ -566,8 +581,8 @@ class LeadsController extends BaseController
|
||||
];
|
||||
$this->leadFilesModel->insert($lead_file_data);
|
||||
}
|
||||
|
||||
if($key == 0 && !empty($value['file_name'])) {
|
||||
|
||||
if ($key == 0 && !empty($value['file_name'])) {
|
||||
$this->leadsModel->where('id', $lead_id)->set('file_name', $value['file_name'])->update();
|
||||
}
|
||||
}
|
||||
@ -577,22 +592,16 @@ class LeadsController extends BaseController
|
||||
}
|
||||
|
||||
public function removeMultiFile()
|
||||
{
|
||||
{
|
||||
$id = $this->request->getGet('lead_file_id');
|
||||
if(!empty($id)){
|
||||
if (!empty($id)) {
|
||||
$this->leadFilesModel->where('id', $id)->set(['is_active' => 0])->update();
|
||||
return $this->respond(['status' => true, 'message' => 'File removed successfully'], 200);
|
||||
}else{
|
||||
} else {
|
||||
return $this->respond(['status' => false, 'message' => 'File could not be removed.'], 200);
|
||||
}
|
||||
}
|
||||
|
||||
public function updateLeadTableFields()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//--------RFQ-----------------------------------------------------------------------------------------------
|
||||
//--------RFQ-----------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
public function viewRFQ($id, $type = 1)
|
||||
@ -676,14 +685,14 @@ class LeadsController extends BaseController
|
||||
$data['occupancy'] = $this->occupancyModel->findAll();
|
||||
// dd($data['occupancy']);
|
||||
|
||||
if($lead_data['lead_type'] != 1 && $data['rfq_count'] == 0){
|
||||
if ($lead_data['lead_type'] != 1 && $data['rfq_count'] == 0) {
|
||||
$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'])){
|
||||
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["child_table_data"] = json_decode($data['question_json'], true)['child_table_data'];
|
||||
}
|
||||
|
||||
// $data['lead_register_data'] = json_decode($data['lead_data']['custom_fields']);
|
||||
@ -735,15 +744,24 @@ class LeadsController extends BaseController
|
||||
return $this->respond(['status' => false, 'message' => 'Lead ID is required'], 400);
|
||||
}
|
||||
|
||||
$inputJson = json_decode($data['json'], true);
|
||||
if (isset($inputJson['premium_data']) && !empty($inputJson['premium_data'])) {
|
||||
$sortedJson = $this->reorderProposalsByInsurerTotal($inputJson);
|
||||
$data['json'] = json_encode($sortedJson);
|
||||
}
|
||||
|
||||
|
||||
$data['type'] = 1;
|
||||
|
||||
// Deactivate existing RFQs for this lead and type
|
||||
$this->RFQModel
|
||||
->where('lead_id', $lead_id)
|
||||
->where('type', 1)
|
||||
->where('is_active', 1)
|
||||
->set('is_active', 0)
|
||||
->update();
|
||||
if (!isset($data['rfq_primaryKey']) && empty($data['rfq_primaryKey'])) {
|
||||
$this->RFQModel
|
||||
->where('lead_id', $lead_id)
|
||||
->where('type', 1)
|
||||
->where('is_active', 1)
|
||||
->set('is_active', 0)
|
||||
->update();
|
||||
}
|
||||
|
||||
// Handle registration_json
|
||||
if (empty($data['registration_json'])) {
|
||||
@ -759,20 +777,29 @@ class LeadsController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
// Insert new RFQ
|
||||
$insertId = $this->RFQModel->insert($data);
|
||||
// print_r($data); die;
|
||||
// $data['json'] = "";
|
||||
if (isset($data['rfq_primaryKey']) && !empty($data['rfq_primaryKey'])) {
|
||||
$this->RFQModel->update($data['rfq_primaryKey'], $data);
|
||||
$insertId = $data['rfq_primaryKey'];
|
||||
$affectedRows = db_connect()->affectedRows();
|
||||
} else {
|
||||
// Insert new RFQ
|
||||
$insertId = $this->RFQModel->insert($data);
|
||||
}
|
||||
|
||||
if ($insertId) {
|
||||
$message = ($data['submit_type'] ?? '') == 'QCR' ? 'QCR submitted successfully' : 'RFQ submitted successfully';
|
||||
$message = ($data['submit_type'] ?? '') == 'QCR' ? 'QCR saved successfully' : 'RFQ saved successfully';
|
||||
return $this->respond([
|
||||
'status' => true,
|
||||
'id' => $insertId,
|
||||
'message' => $message,
|
||||
'data' => $data
|
||||
'data' => $data,
|
||||
'affectedRows' => $affectedRows ?? null,
|
||||
], 200);
|
||||
}
|
||||
|
||||
$message = ($data['submit_type'] ?? '') == 'QCR' ? 'Failed to create QCR' : 'Failed to create RFQ';
|
||||
$message = ($data['submit_type'] ?? '') == 'QCR' ? 'Failed to save QCR' : 'Failed to save RFQ';
|
||||
return $this->respond([
|
||||
'status' => false,
|
||||
'id' => null,
|
||||
@ -805,6 +832,206 @@ class LeadsController extends BaseController
|
||||
}
|
||||
|
||||
|
||||
private function reorderProposalsByInsurerTotal(array $data): array
|
||||
{
|
||||
|
||||
if (!isset($data['premium_data']['data'])) return $data;
|
||||
|
||||
$original = $data['premium_data']['data'];
|
||||
$proposals = [];
|
||||
$others = [];
|
||||
$emptyKeyData = [];
|
||||
|
||||
foreach ($original as $key => $value) {
|
||||
// Match only keys that look like 'Proposal X'
|
||||
if (preg_match('/^Proposal\s+\d+$/', $key)) {
|
||||
// Get the insurer entry (not 'Quote Asked')
|
||||
foreach ($value as $subKey => $subVal) {
|
||||
if ($subKey !== 'Quote Asked' && isset($subVal['Total'])) {
|
||||
$proposals[$key] = $value;
|
||||
break;
|
||||
}else{
|
||||
$proposals[$key] = $value;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
if ($key === '' && isset($value['']) && is_array($value[''])) {
|
||||
// Capture empty key to push it later
|
||||
$emptyKeyData[$key] = $value;
|
||||
} else {
|
||||
$others[$key] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Sort proposals by their insurer's total
|
||||
uasort($proposals, function ($a, $b) {
|
||||
$totalA = 0;
|
||||
$totalB = 0;
|
||||
|
||||
foreach ($a as $key => $val) {
|
||||
if ($key !== 'Quote Asked' && isset($val['Total'])) {
|
||||
$totalA = floatval($val['Total']);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($b as $key => $val) {
|
||||
if ($key !== 'Quote Asked' && isset($val['Total'])) {
|
||||
$totalB = floatval($val['Total']);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $totalA <=> $totalB;
|
||||
});
|
||||
|
||||
// Merge back the sorted proposals into the full structure
|
||||
$data['premium_data']['data'] = array_merge($others, $proposals, $emptyKeyData);
|
||||
$data = $this->reorderProposalDataByPremiumOrder($data);
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function reorderProposalDataByPremiumOrder(array $data): array
|
||||
{
|
||||
if (!isset($data['premium_data']['data'], $data['proposal_data']['over_all_column_data'])) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
$premiumProposals = array_keys($data['premium_data']['data']);
|
||||
$filteredProposals = [];
|
||||
|
||||
// Collect proposal keys that match the pattern "Proposal X"
|
||||
foreach ($premiumProposals as $key) {
|
||||
if (preg_match('/^Proposal\s+\d+$/', $key) && isset($data['proposal_data']['over_all_column_data'][$key])) {
|
||||
$filteredProposals[$key] = $data['proposal_data']['over_all_column_data'][$key];
|
||||
}
|
||||
}
|
||||
|
||||
// dd($premiumProposals, $filteredProposals);
|
||||
|
||||
$data['proposal_data']['over_all_column_data'] = $filteredProposals;
|
||||
$data = $this->reorderProposalInHeaderAndData($data);
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function reorderProposalInHeaderAndData(array $data): array
|
||||
{
|
||||
$tableData = $data['table_data'];
|
||||
$sortedProposalOrder = $data['proposal_data']['over_all_column_data'];
|
||||
$headers = $tableData['headers'] ?? [];
|
||||
$dataRows = $tableData['data'] ?? [];
|
||||
|
||||
// Step 1: Separate static and proposal headers
|
||||
$staticHeaders = [];
|
||||
$proposalHeaders = [];
|
||||
$actionHeader = [];
|
||||
foreach ($headers as $header) {
|
||||
if (in_array($header['parentHeader'], array_keys($sortedProposalOrder))) {
|
||||
$proposalHeaders[$header['parentHeader']] = $header;
|
||||
} else {
|
||||
if ($header['parentHeader'] == "Action") {
|
||||
$actionHeader[] = $header;
|
||||
} else {
|
||||
$staticHeaders[] = $header;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// dd($staticHeaders, $proposalHeaders, $sortedProposalOrder);
|
||||
|
||||
// Step 2: Reorder headers
|
||||
$reorderedHeaders = [];
|
||||
foreach ($sortedProposalOrder as $proposalKey => $proposalValue) {
|
||||
if (isset($proposalHeaders[$proposalKey])) {
|
||||
$reorderedHeaders[] = $proposalHeaders[$proposalKey];
|
||||
}
|
||||
}
|
||||
|
||||
// print_rr($reorderedHeaders); die;
|
||||
foreach ($reorderedHeaders as $key => &$value) {
|
||||
$value['parentHeader'] = 'Proposal ' . ($key + 1);
|
||||
}
|
||||
unset($value);
|
||||
|
||||
|
||||
$reorderedHeaders = array_merge($staticHeaders, $reorderedHeaders, $actionHeader);
|
||||
|
||||
|
||||
// Step 3: Reorder each row's `data` by matching parentth
|
||||
foreach ($dataRows as $dataRowIndex => &$row) {
|
||||
$staticData = [];
|
||||
$proposalData = [];
|
||||
$actionData = [];
|
||||
|
||||
foreach ($row['data'] as $entry) {
|
||||
if (in_array($entry['parentth'], array_keys($sortedProposalOrder))) {
|
||||
$proposalData[$entry['parentth']][] = $entry;
|
||||
} else {
|
||||
if ($entry['parentth'] == "Action") {
|
||||
$actionData[] = $entry;
|
||||
} else {
|
||||
$staticData[] = $entry;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$reorderedProposalData = [];
|
||||
foreach ($sortedProposalOrder as $proposalKey => $proposalValue) {
|
||||
if (isset($proposalData[$proposalKey])) {
|
||||
foreach ($proposalData[$proposalKey] as $entry) {
|
||||
$reorderedProposalData[] = $entry;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$dubParTh = "";
|
||||
$increament = 0;
|
||||
foreach ($reorderedProposalData as $key => &$value) {
|
||||
|
||||
if ($dubParTh == $value['parentth']) {
|
||||
$value['parentth'] = 'Proposal ' . ($increament);
|
||||
} else {
|
||||
$dubParTh = $value['parentth'];
|
||||
$increament = $increament + 1;
|
||||
$value['parentth'] = 'Proposal ' . ($increament);
|
||||
}
|
||||
}
|
||||
unset($value);
|
||||
|
||||
$row['data'] = array_merge($staticData, $reorderedProposalData, $actionData);
|
||||
}
|
||||
|
||||
$data['table_data']['headers'] = $reorderedHeaders;
|
||||
$data['table_data']['data'] = $dataRows;
|
||||
|
||||
$renumberedArray = $this->renumberProposalKeys($data['proposal_data']['over_all_column_data']);
|
||||
$updatedDataSet = $this->renumberProposalKeys($data['premium_data']['data']);
|
||||
$data['proposal_data']['over_all_column_data'] = !empty($renumberedArray) ? $renumberedArray : $data['proposal_data']['over_all_column_data'];
|
||||
$data['premium_data']['data'] = !empty($updatedDataSet) ? $updatedDataSet : $data['premium_data']['data'];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function renumberProposalKeys(array $input): array
|
||||
{
|
||||
$result = [];
|
||||
$counter = 1;
|
||||
|
||||
foreach ($input as $key => $value) {
|
||||
if (strpos($key, 'Proposal') === 0) {
|
||||
$newKey = 'Proposal ' . $counter++;
|
||||
$result[$newKey] = $value;
|
||||
} else {
|
||||
$result[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
//-----RFQ and QCR EXPORT------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
@ -2394,16 +2621,15 @@ class LeadsController extends BaseController
|
||||
// }
|
||||
}
|
||||
|
||||
if($data['lead_form_type'] == 1){
|
||||
if ($data['lead_form_type'] == 1) {
|
||||
$client_policy_data['policy_terms'] = $this->preparePolicyTermsFromRFQ($data);
|
||||
}else{
|
||||
} else {
|
||||
|
||||
$placementJson = $this->getPlacementJson($data);
|
||||
if ($placementJson) {
|
||||
$client_policy_data['placement_json'] = $placementJson;
|
||||
$client_policy_data['policy_terms'] = $this->convertNonEbQCRJsonToPolicyTerms(json_decode($placementJson, true));
|
||||
}
|
||||
|
||||
}
|
||||
// print_r($client_policy_data); die;
|
||||
|
||||
@ -2542,12 +2768,11 @@ class LeadsController extends BaseController
|
||||
}
|
||||
|
||||
return json_encode($terms_array);
|
||||
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function featchClientPolicyFromLead($client_id, $branch_id, $lead_id)
|
||||
{
|
||||
$data = $this->leadsModel->where('leads.id', $lead_id)->where('leads.is_active', 1)->first();
|
||||
@ -2592,7 +2817,9 @@ class LeadsController extends BaseController
|
||||
return $this->transformNonEbProposelData(
|
||||
$jsonData,
|
||||
$proposel_data['proposel_name'] ?? '',
|
||||
$proposel_data['insurer_name'] ?? '', null, 1
|
||||
$proposel_data['insurer_name'] ?? '',
|
||||
null,
|
||||
1
|
||||
);
|
||||
}, $jsonArray);
|
||||
|
||||
@ -2612,7 +2839,7 @@ class LeadsController extends BaseController
|
||||
}
|
||||
unset($proposal); // Good practice after foreach by reference
|
||||
}
|
||||
|
||||
|
||||
|
||||
$placement_json_data[] = $proposalData;
|
||||
|
||||
@ -2721,7 +2948,7 @@ class LeadsController extends BaseController
|
||||
}
|
||||
|
||||
if (!empty($data['lead_edit_data'])) {
|
||||
foreach (['policy_start_date', 'policy_end_date', 'incurred_claims_date', 'premium_date'] as $dateField) {
|
||||
foreach (['policy_start_date', 'policy_end_date', 'source_policy_start_date', 'source_policy_end_date', 'incurred_claims_date'] as $dateField) {
|
||||
$data['lead_edit_data'][$dateField] = !empty($data['lead_edit_data'][$dateField])
|
||||
? change_date_format($data['lead_edit_data'][$dateField], 'Y-m-d', 'd/m/Y')
|
||||
: null;
|
||||
@ -2812,7 +3039,7 @@ class LeadsController extends BaseController
|
||||
$lead_data = array_merge(['Insured' => $rfq_data['client_name']], $lead_data);
|
||||
|
||||
$policy_registration_data = [];
|
||||
if(isset($rfq_data['registration_json']) && !empty($rfq_data['registration_json'])){
|
||||
if (isset($rfq_data['registration_json']) && !empty($rfq_data['registration_json'])) {
|
||||
$policy_registration_data = json_decode($rfq_data['registration_json'], true);
|
||||
}
|
||||
// dd($policy_registration_data);
|
||||
@ -2960,7 +3187,7 @@ class LeadsController extends BaseController
|
||||
]);
|
||||
|
||||
$rowNumber++;
|
||||
}else{
|
||||
} else {
|
||||
$sheet->mergeCells("A{$rowNumber}:B{$rowNumber}");
|
||||
$sheet->setCellValue("A{$rowNumber}", "Policy Type");
|
||||
$sheet->setCellValue("C{$rowNumber}", ucfirst($key) . " Policy");
|
||||
@ -3148,7 +3375,7 @@ class LeadsController extends BaseController
|
||||
$serial_no = 1;
|
||||
$maxColumnWidths = [];
|
||||
$RowSpanEnable = false;
|
||||
|
||||
|
||||
// Add table data rows
|
||||
foreach ($column_data as $dataRow) {
|
||||
|
||||
@ -3173,11 +3400,11 @@ class LeadsController extends BaseController
|
||||
$sheet->getStyle("{$columnLetter}{$mergeStart}:{$columnLetter}{$mergeEnd}")
|
||||
->getAlignment()->setVertical(\PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER);
|
||||
} else {
|
||||
if(!$hasPolicy && $key == 0){
|
||||
if (!$hasPolicy && $key == 0) {
|
||||
$RowSpanEnable = true;
|
||||
$columnLetter++;
|
||||
$sheet->setCellValue("{$columnLetter}{$rowNumber}", $cellData['display_content']);
|
||||
}else{
|
||||
} else {
|
||||
$sheet->setCellValue("{$columnLetter}{$rowNumber}", $cellData['display_content']);
|
||||
}
|
||||
}
|
||||
@ -3185,13 +3412,12 @@ class LeadsController extends BaseController
|
||||
if (!($key === 0 && !$hasPolicy)) {
|
||||
$columnLetter++;
|
||||
}
|
||||
|
||||
}
|
||||
$rowNumber++;
|
||||
$serial_no++;
|
||||
}
|
||||
|
||||
if($key == 0 && $RowSpanEnable == true){
|
||||
if ($key == 0 && $RowSpanEnable == true) {
|
||||
$columnLetter++;
|
||||
}
|
||||
|
||||
@ -3494,7 +3720,7 @@ class LeadsController extends BaseController
|
||||
return null;
|
||||
}
|
||||
|
||||
public function transformNonEbProposelData(&$data, $proposal, $insurer, $tableCount=null, $actionColumn = null)
|
||||
public function transformNonEbProposelData(&$data, $proposal, $insurer, $tableCount = null, $actionColumn = null)
|
||||
{
|
||||
// Kint::dump($data, $proposal, $insurer, $tableCount);
|
||||
|
||||
@ -3531,7 +3757,7 @@ class LeadsController extends BaseController
|
||||
// Update the original data's headers
|
||||
$data['table_data']['headers'] = $headerData;
|
||||
|
||||
if(!empty($actionColumn)){
|
||||
if (!empty($actionColumn)) {
|
||||
$data['table_data']['headers'][] = [
|
||||
'parentHeader' => "Action",
|
||||
'subHeaders' => ['-']
|
||||
@ -3563,8 +3789,8 @@ class LeadsController extends BaseController
|
||||
$filteredData[] = $item;
|
||||
}
|
||||
|
||||
if(!empty($actionColumn)){
|
||||
if($item['parentth'] === "Action"){
|
||||
if (!empty($actionColumn)) {
|
||||
if ($item['parentth'] === "Action") {
|
||||
$filteredData[] = $item;
|
||||
}
|
||||
}
|
||||
@ -3582,24 +3808,24 @@ class LeadsController extends BaseController
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getPreviousColumn($columnLetter, $decrement = 1)
|
||||
public function getPreviousColumn($columnLetter, $decrement = 1)
|
||||
{
|
||||
$colIndex = Coordinate::columnIndexFromString($columnLetter);
|
||||
$colIndex = max(1, $colIndex - $decrement); // ensure column index doesn't go below 1
|
||||
return Coordinate::stringFromColumnIndex($colIndex);
|
||||
}
|
||||
|
||||
|
||||
public function handleMultiFileAttachments($json_string, $lead_id)
|
||||
{
|
||||
{
|
||||
$attachments = [];
|
||||
|
||||
|
||||
if (!empty($json_string)) {
|
||||
$fileIds = json_decode($json_string, true);
|
||||
$lead_file_path = WRITEPATH . 'uploads/lead_files/';
|
||||
|
||||
|
||||
foreach ($fileIds as $id) {
|
||||
$lead_file = $this->leadFilesModel->where('lead_id', $lead_id)->where('id', $id)->where('is_active', 1)->first();
|
||||
|
||||
|
||||
if ($lead_file) {
|
||||
$attachments[] = [
|
||||
'fileName' => $lead_file['file_name'],
|
||||
@ -3608,8 +3834,7 @@ class LeadsController extends BaseController
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $attachments;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -87,6 +87,9 @@ class LeadsModel extends Model
|
||||
|
||||
'lead_form_type',
|
||||
'custom_fields',
|
||||
|
||||
'source_policy_start_date',
|
||||
'source_policy_end_date',
|
||||
];
|
||||
|
||||
|
||||
|
||||
@ -162,6 +162,16 @@
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 renewalFields" style="display: none;">
|
||||
<label for="source_policy_start_date">Source Policy Start Date<span class="text-danger"></span></label>
|
||||
<input type="text" class="form-control readonly-select" id="source_policy_start_date" name="source_policy_start_date" readonly>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 renewalFields" style="display: none;">
|
||||
<label for="source_policy_end_date">Source Policy End Date<span class="text-danger"></span></label>
|
||||
<input type="text" class="form-control" id="source_policy_end_date" name="source_policy_end_date" readonly>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="pan">PAN<span class="text-danger"></span></label>
|
||||
<input type="text" class="form-control" id="pan" placeholder="Enter PAN Number"
|
||||
@ -228,9 +238,9 @@
|
||||
<div class="form-row">
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="salse_person_id">Sales Person<span class="text-danger">*</span></label>
|
||||
<label for="salse_person_id">Salse Person<span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="salse_person_id" name="salse_person_id" multiple required>
|
||||
<option value="">Select Sales Person</option>
|
||||
<option value="">Select Salse Person</option>
|
||||
<?php if (isset($salse_team)) { ?>
|
||||
<?php foreach ($salse_team as $value) { ?>
|
||||
<option value="<?= $value['id']; ?>">
|
||||
@ -343,24 +353,24 @@
|
||||
1); // Set end date to last day of selected year
|
||||
policy_end_datePicker.setDate(policy_end_date);
|
||||
|
||||
console.log('this object', this);
|
||||
console.log('id of this element:', this.element);
|
||||
console.log('id of this element:', this.element.id);
|
||||
// console.log('this object', this);
|
||||
// console.log('id of this element:', this.element);
|
||||
// console.log('id of this element:', this.element.id);
|
||||
|
||||
let increment = this.element.id.split('_').pop();
|
||||
console.log(increment); // Outputs: 1
|
||||
// let increment = this.element.id.split('_').pop();
|
||||
// console.log(increment); // Outputs: 1
|
||||
|
||||
|
||||
console.log('increment', increment);
|
||||
console.log('policy_start_datePicker selectedDates', selectedDates);
|
||||
console.log('policy_start_datePicker incurred_claim_date_', $(
|
||||
"#incurred_claim_date_" + increment).val());
|
||||
// console.log('increment', increment);
|
||||
// console.log('policy_start_datePicker selectedDates', selectedDates);
|
||||
// console.log('policy_start_datePicker incurred_claim_date_', $(
|
||||
// "#incurred_claim_date_" + increment).val());
|
||||
|
||||
// Recalculate policy_run_days if incurred claim date is already selected
|
||||
if ($("#incurred_claim_date_" + increment).val()) {
|
||||
console.log('policy_start_datePicker selectedDates', selectedDates);
|
||||
calculatePolicyRunDays(increment);
|
||||
}
|
||||
// if ($("#incurred_claim_date_" + increment).val()) {
|
||||
// console.log('policy_start_datePicker selectedDates', selectedDates);
|
||||
// calculatePolicyRunDays(increment);
|
||||
// }
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -369,6 +379,11 @@
|
||||
dateFormat: "d/m/Y",
|
||||
allowInput: false
|
||||
});
|
||||
|
||||
document.getElementById('source_policy_start_date').readOnly = true;
|
||||
document.getElementById('source_policy_end_date').readOnly = true;
|
||||
|
||||
$('#source_policy_start_date, #source_policy_end_date').addClass('readonly-select');
|
||||
});
|
||||
|
||||
console.log('increment count for insurer and tpa ', increment);
|
||||
@ -453,7 +468,7 @@
|
||||
|
||||
updateRenewalFields(dataIncrement);
|
||||
let incurred_claim_date_id = 'incurred_claim_date_' + dataIncrement;
|
||||
let premium_date_id = 'premium_date_' + dataIncrement;
|
||||
// let premium_date_id = 'premium_date_' + dataIncrement;
|
||||
|
||||
var incurred_claim_datepicker = flatpickr("#" + incurred_claim_date_id, {
|
||||
dateFormat: "d/m/Y",
|
||||
@ -466,11 +481,7 @@
|
||||
let increment = this.input.id.split('_').pop();
|
||||
console.log('Extracted increment:', increment);
|
||||
|
||||
var policyStartDate = $("#policy_start_date_" + increment)
|
||||
.length ?
|
||||
$("#policy_start_date_" + increment) :
|
||||
$("#policy_start_date");
|
||||
|
||||
var policyStartDate = $("#source_policy_start_date");
|
||||
console.log('Selected Dates:', selectedDates);
|
||||
console.log('policy start date instance', policyStartDate)
|
||||
console.log('Policy Start Date:', policyStartDate.val());
|
||||
@ -482,10 +493,10 @@
|
||||
}
|
||||
});
|
||||
|
||||
var premium_date_datepicker = flatpickr("#" + premium_date_id, {
|
||||
dateFormat: "d/m/Y",
|
||||
allowInput: false
|
||||
});
|
||||
// var premium_date_datepicker = flatpickr("#" + premium_date_id, {
|
||||
// dateFormat: "d/m/Y",
|
||||
// allowInput: false
|
||||
// });
|
||||
|
||||
$('#proposed_insurer_' + dataIncrement).select2();
|
||||
$('#proposed_tpa_' + dataIncrement).select2();
|
||||
@ -651,6 +662,12 @@
|
||||
|
||||
if (res.status === true && res.data) {
|
||||
|
||||
console.log("res.data.source_policy_start_date", res.data.source_policy_start_date)
|
||||
console.log("res.data.source_policy_end_date", res.data.source_policy_end_date)
|
||||
|
||||
$('#source_policy_start_date').val(res.data.source_policy_start_date);
|
||||
$('#source_policy_end_date').val(res.data.source_policy_end_date);
|
||||
|
||||
for (let i = 1; i <= increment_count; i++) {
|
||||
|
||||
$(`#policy_type_id`).removeClass('readonly-select ').select2();
|
||||
@ -682,6 +699,7 @@
|
||||
$(`#proposed_tpa_${i}`).addClass('readonly-select ').select2('destroy');
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
console.warn('Invalid response:', res.message || 'Unknown error');
|
||||
// Reset fields if response is invalid
|
||||
@ -694,6 +712,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Hide loader
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
@ -787,7 +806,7 @@
|
||||
|
||||
updateRenewalFields(dataIncrement);
|
||||
let incurred_claim_date_id = 'incurred_claim_date_' + dataIncrement;
|
||||
let premium_date_id = 'premium_date_' + dataIncrement;
|
||||
// let premium_date_id = 'premium_date_' + dataIncrement;
|
||||
|
||||
var incurred_claim_datepicker = flatpickr("#" + incurred_claim_date_id, {
|
||||
dateFormat: "d/m/Y",
|
||||
@ -800,10 +819,7 @@
|
||||
let increment = this.input.id.split('_').pop();
|
||||
console.log('Extracted increment:', increment);
|
||||
|
||||
var policyStartDate = $("#policy_start_date_" + increment).length ?
|
||||
$("#policy_start_date_" + increment) :
|
||||
$("#policy_start_date");
|
||||
|
||||
var policyStartDate = $("#source_policy_start_date");
|
||||
console.log('Selected Dates:', selectedDates);
|
||||
console.log('policy start date instance', policyStartDate)
|
||||
console.log('Policy Start Date:', policyStartDate.val());
|
||||
@ -815,10 +831,10 @@
|
||||
}
|
||||
});
|
||||
|
||||
var premium_date_datepicker = flatpickr("#" + premium_date_id, {
|
||||
dateFormat: "d/m/Y",
|
||||
allowInput: false
|
||||
});
|
||||
// var premium_date_datepicker = flatpickr("#" + premium_date_id, {
|
||||
// dateFormat: "d/m/Y",
|
||||
// allowInput: false
|
||||
// });
|
||||
|
||||
$('#proposed_insurer_' + dataIncrement).select2();
|
||||
$('#proposed_tpa_' + dataIncrement).select2();
|
||||
@ -968,16 +984,16 @@
|
||||
console.log(increment); // Outputs: 1
|
||||
|
||||
|
||||
console.log('increment', increment);
|
||||
console.log('policy_start_datePicker selectedDates', selectedDates);
|
||||
console.log('policy_start_datePicker incurred_claim_date_', $("#incurred_claim_date_" +
|
||||
increment).val());
|
||||
// console.log('increment', increment);
|
||||
// console.log('policy_start_datePicker selectedDates', selectedDates);
|
||||
// console.log('policy_start_datePicker incurred_claim_date_', $("#incurred_claim_date_" +
|
||||
// increment).val());
|
||||
|
||||
// Recalculate policy_run_days if incurred claim date is already selected
|
||||
if ($("#incurred_claim_date_" + increment).val()) {
|
||||
console.log('policy_start_datePicker selectedDates', selectedDates);
|
||||
calculatePolicyRunDays(increment);
|
||||
}
|
||||
// if ($("#incurred_claim_date_" + increment).val()) {
|
||||
// console.log('policy_start_datePicker selectedDates', selectedDates);
|
||||
// calculatePolicyRunDays(increment);
|
||||
// }
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -1051,10 +1067,7 @@
|
||||
console.log('calculatePolicyRunDays function called');
|
||||
console.log('increment', increment);
|
||||
|
||||
var policyStartDate = $("#policy_start_date_" + increment).length ?
|
||||
$("#policy_start_date_" + increment) :
|
||||
$("#policy_start_date");
|
||||
|
||||
var policyStartDate = $("#source_policy_start_date");
|
||||
var policyStartDate = flatpickr.parseDate(policyStartDate.val(), "d/m/Y");
|
||||
var incurredClaimDate = flatpickr.parseDate($("#incurred_claim_date_" + increment).val(), "d/m/Y");
|
||||
|
||||
@ -1062,9 +1075,9 @@
|
||||
console.log('incurredClaimDate', incurredClaimDate)
|
||||
|
||||
if (policyStartDate && incurredClaimDate) {
|
||||
var timeDiff = (policyStartDate - incurredClaimDate) + 1; // Time difference in milliseconds
|
||||
var timeDiff = Math.abs(policyStartDate - incurredClaimDate); // Time difference in milliseconds
|
||||
console.log('timeDiff', timeDiff);
|
||||
var daysDiff = Math.ceil(timeDiff / (1000 * 60 * 60 * 24)); // Convert to days and add 1
|
||||
var daysDiff = Math.ceil(timeDiff / (1000 * 60 * 60 * 24) + 1); // Convert to days and add 1
|
||||
console.log('daysDiff', daysDiff);
|
||||
$("#policy_run_days_" + increment).val(daysDiff); // Set value in the policy_run_days_ input
|
||||
}
|
||||
@ -1104,7 +1117,8 @@
|
||||
// ------------------------------------------------------------------------------------------
|
||||
|
||||
// Prevent division by zero in incurred claim ratio calculation
|
||||
let incurred_claim_ratio = annualised_claims > 0 ? incurred_claims / annualised_claims : 0;
|
||||
let premium_as_on_date = Number($('#premium_date_' + increment).val()) || 0;
|
||||
let incurred_claim_ratio = annualised_claims > 0 ? annualised_claims / premium_as_on_date : 0;
|
||||
let incurred_claim_ratio_roundoff = Math.round(incurred_claim_ratio);
|
||||
console.log('incurred_claim_ratio', incurred_claim_ratio_roundoff);
|
||||
|
||||
@ -1116,7 +1130,7 @@
|
||||
console.log('earned_premium', earned_premium);
|
||||
|
||||
// Prevent division by zero in earned claims ratio calculation
|
||||
let earned_claims_ratio = earned_premium > 0 ? incurred_claims / earned_premium : 0;
|
||||
let earned_claims_ratio = earned_premium > 0 ? annualised_claims / earned_premium : 0;
|
||||
let earned_claims_ration_roundoff = Math.round(earned_claims_ratio);
|
||||
console.log('earned_claims_ratio', earned_claims_ratio);
|
||||
|
||||
@ -1128,6 +1142,8 @@
|
||||
let increment = input.id.split('_').pop(); // Extract the increment part
|
||||
console.log('increment', increment);
|
||||
|
||||
let premium_as_on_date = Number($('#premium_date_' + increment).val()) || 0;
|
||||
|
||||
// Retrieve and convert the values to numbers, fallback to 0 if empty or invalid
|
||||
let premium_at_inception = Number($('#premium_at_inception_' + increment).val()) || 0;
|
||||
console.log('premium_at_inception', premium_at_inception);
|
||||
@ -1136,7 +1152,7 @@
|
||||
console.log('policy_run_days', policy_run_days);
|
||||
|
||||
// Prevent division by zero and calculate earned premium
|
||||
let earned_premium = policy_run_days > 0 ? premium_at_inception / policy_run_days : 0;
|
||||
let earned_premium = premium_as_on_date > 0 ? (premium_as_on_date / 365) * 364 : 0;
|
||||
console.log('earned_premium', earned_premium);
|
||||
let earned_premium_roundoff = Math.round(earned_premium);
|
||||
// Set the calculated value with two decimal places
|
||||
@ -1513,7 +1529,7 @@
|
||||
$('.freshFields').find('select, input').attr('required', 'required');
|
||||
$('.freshFields').show();
|
||||
|
||||
$('.proposed_div').hide().find('select, input').removeAttr('required');
|
||||
// $('.proposed_div').hide().find('select, input').removeAttr('required');
|
||||
|
||||
if (resetValues) {
|
||||
|
||||
@ -1547,11 +1563,15 @@
|
||||
$('.renewalFields').show();
|
||||
$('.renewalFields').find('select, input').attr('required', 'required');
|
||||
|
||||
$('.proposed_div').show().find('select, input').attr('required', 'required');
|
||||
// $('.proposed_div').show().find('select, input').attr('required', 'required');
|
||||
|
||||
$('#policy_end_date').removeAttr('required');
|
||||
$('#policy_start_date').removeAttr('required');
|
||||
$('#claims').removeAttr('required');
|
||||
$('#source_policy_start_date').attr('readonly', 'readonly');
|
||||
$('#source_policy_end_date').attr('readonly', 'readonly');
|
||||
|
||||
console.log('readonly set', $('#source_policy_start_date').prop('readonly')); // should print true
|
||||
|
||||
if (resetValues) {
|
||||
|
||||
|
||||
@ -345,6 +345,11 @@ if (isset($selected_lead_type)) {
|
||||
let isFirstField = container.childElementCount === 0; // Check if it's the first field
|
||||
let placeholder = isFirstField ? 'First file must be Demography.' : '';
|
||||
let accept = isFirstField ? '.xls,.xlsx' : '';
|
||||
|
||||
if(selected_lead_form_type != 1){
|
||||
placeholder = '';
|
||||
accept = '';
|
||||
}
|
||||
|
||||
div.innerHTML = `
|
||||
<div class="form-group col-md-5">
|
||||
@ -452,10 +457,11 @@ if (isset($selected_lead_type)) {
|
||||
<?php if (isset($lead_edit_data)) { ?>
|
||||
<script>
|
||||
|
||||
setTimeout(function(){
|
||||
$(document).ready(async function () {
|
||||
handleEbAndNonEbEdit(
|
||||
<?= json_encode($lead_edit_data, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP) ?>);
|
||||
}, 2000)
|
||||
<?= json_encode($lead_edit_data, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP) ?>
|
||||
);
|
||||
});
|
||||
|
||||
function handleEbAndNonEbEdit(data){
|
||||
if(data.lead_form_type == 1){
|
||||
@ -467,6 +473,10 @@ if (isset($selected_lead_type)) {
|
||||
|
||||
function dynamicLeadsDataForEdit(data) {
|
||||
try {
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
|
||||
console.log('########### THIS IS EB LEAD ###############')
|
||||
|
||||
console.log('Received data:', data);
|
||||
@ -490,7 +500,6 @@ if (isset($selected_lead_type)) {
|
||||
|
||||
if (data.multi_file_html && data.multi_file_html != '') {
|
||||
$('#multiFileAppendArea_' + dataIncrement).empty();
|
||||
console.log(data.multi_file_html);
|
||||
setTimeout(function(){
|
||||
$('#multiFileAppendArea_' + dataIncrement).append(data.multi_file_html);
|
||||
}, 2000)
|
||||
@ -508,6 +517,10 @@ if (isset($selected_lead_type)) {
|
||||
|
||||
leadTypeBsedHideAndShow(lead_type);
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
|
||||
|
||||
if (lead_type == 1) {
|
||||
$('.claim-row').hide();
|
||||
} else {
|
||||
@ -519,10 +532,10 @@ if (isset($selected_lead_type)) {
|
||||
$('.gpaClaimFileds').hide();
|
||||
$('.lifeClaimFields').show();
|
||||
} else {
|
||||
updateRenewalFields(dataIncrement);
|
||||
// updateRenewalFields(dataIncrement);
|
||||
|
||||
let incurred_claim_date_id = 'incurred_claim_date_' + dataIncrement;
|
||||
let premium_date_id = 'premium_date_' + dataIncrement;
|
||||
// let premium_date_id = 'premium_date_' + dataIncrement;
|
||||
|
||||
if ($('#' + incurred_claim_date_id).length) {
|
||||
flatpickr("#" + incurred_claim_date_id, {
|
||||
@ -531,10 +544,7 @@ if (isset($selected_lead_type)) {
|
||||
onChange: function (selectedDates) {
|
||||
try {
|
||||
let increment = this.input.id.split('_').pop();
|
||||
let policyStartDate = $("#policy_start_date_" + increment).length
|
||||
? $("#policy_start_date_" + increment)
|
||||
: $("#policy_start_date");
|
||||
|
||||
let policyStartDate = $("#source_policy_start_date");
|
||||
if (policyStartDate.val()) {
|
||||
calculatePolicyRunDays(increment);
|
||||
}
|
||||
@ -547,15 +557,16 @@ if (isset($selected_lead_type)) {
|
||||
console.warn(`Incurred claim date field #${incurred_claim_date_id} not found.`);
|
||||
}
|
||||
|
||||
if ($('#' + premium_date_id).length) {
|
||||
flatpickr("#" + premium_date_id, {
|
||||
dateFormat: "d/m/Y",
|
||||
allowInput: false
|
||||
});
|
||||
} else {
|
||||
console.warn(`Premium date field #${premium_date_id} not found.`);
|
||||
}
|
||||
// if ($('#' + premium_date_id).length) {
|
||||
// flatpickr("#" + premium_date_id, {
|
||||
// dateFormat: "d/m/Y",
|
||||
// allowInput: false
|
||||
// });
|
||||
// } else {
|
||||
// console.warn(`Premium date field #${premium_date_id} not found.`);
|
||||
// }
|
||||
|
||||
// console.log($('#proposed_insurer_' + dataIncrement).length);
|
||||
$('#proposed_insurer_' + dataIncrement).select2();
|
||||
$('#proposed_tpa_' + dataIncrement).select2();
|
||||
}
|
||||
@ -581,6 +592,8 @@ if (isset($selected_lead_type)) {
|
||||
$('#client_branch_id').val(data.client_branch_id || '').change();
|
||||
setTimeout(() => {
|
||||
$('#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 || '');
|
||||
$('#pan').val(data.pan || '');
|
||||
$('#gst').val(data.gst || '');
|
||||
$('#branch_name').val(data.branch_name || '');
|
||||
@ -593,7 +606,7 @@ if (isset($selected_lead_type)) {
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
}, 1000);
|
||||
}, 1000);
|
||||
}, 1000);
|
||||
}, 5000);
|
||||
|
||||
let insurer = (data.insurer_branch_id && data.insurer_id)
|
||||
? `${data.insurer_branch_id}-${data.insurer_id}`
|
||||
@ -620,6 +633,8 @@ if (isset($selected_lead_type)) {
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error in dynamicLeadsDataForEdit function:', error);
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,80 +1,80 @@
|
||||
|
||||
<?php $increment = isset($lead_edit_data) ? "_1" : ''; ?>
|
||||
<hr>
|
||||
|
||||
<div class="form-row renewalCalculation">
|
||||
|
||||
<div class="form-group col-md-3 renewalFields" style="display: none;">
|
||||
<label for="incurred_claim_date">Incurred Claim Date<span class="text-danger"></span></label>
|
||||
<input value="<?= isset($lead_edit_data['incurred_claim_date']) ? $lead_edit_data['incurred_claim_date'] : '' ?>" type="text" class="form-control incurred_claim" id="incurred_claim_date"
|
||||
<input value="<?= isset($lead_edit_data['incurred_claims_date']) ? $lead_edit_data['incurred_claims_date'] : '' ?>" type="text" class="form-control incurred_claim" id="incurred_claim_date<?= $increment ?>"
|
||||
name="incurred_claim_date[]" placeholder="Enter DOE">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 renewalFields" style="display: none;">
|
||||
<label for="paid_claims">Paid Claims<span class="text-danger">*</span></label>
|
||||
<input value="<?= isset($lead_edit_data['paid_claims']) ? $lead_edit_data['paid_claims'] : '' ?>" type="text" class="form-control" id="paid_claims" name="paid_claims[]"
|
||||
<input value="<?= isset($lead_edit_data['paid_claims']) ? $lead_edit_data['paid_claims'] : '' ?>" type="text" class="form-control" id="paid_claims<?= $increment ?>" name="paid_claims[]"
|
||||
placeholder="Enter Paid Claims" oninput="incurredClaimSum(this)">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 renewalFields" style="display: none;">
|
||||
<label for="outstanding_claims">Outstanding Claims<span class="text-danger">*</span></label>
|
||||
<input value="<?= isset($lead_edit_data['outstanding_claims']) ? $lead_edit_data['outstanding_claims'] : '' ?>" type="text" class="form-control" id="outstanding_claims" name="outstanding_claims[]"
|
||||
<input value="<?= isset($lead_edit_data['outstanding_claims']) ? $lead_edit_data['outstanding_claims'] : '' ?>" type="text" class="form-control" id="outstanding_claims<?= $increment ?>" name="outstanding_claims[]"
|
||||
placeholder="Enter Outstanding Claims" oninput="incurredClaimSum(this)">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 renewalFields" style="display: none;">
|
||||
<label for="incurred_claims">Incurred Claim<span class="text-danger">*</span></label>
|
||||
<input value="<?= isset($lead_edit_data['incurred_claims']) ? $lead_edit_data['incurred_claims'] : '' ?>" type="text" class="form-control" id="incurred_claims" name="incurred_claims[]"
|
||||
<input value="<?= isset($lead_edit_data['incurred_claims']) ? $lead_edit_data['incurred_claims'] : '' ?>" type="text" class="form-control" id="incurred_claims<?= $increment ?>" name="incurred_claims[]"
|
||||
placeholder="Enter Incurred Claim" oninput="incurredClaimSum(this)">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 renewalFields" style="display: none;">
|
||||
<label for="policy_run_days">Policy Run Days<span class="text-danger">*</span></label>
|
||||
<input value="<?= isset($lead_edit_data['policy_run_days']) ? $lead_edit_data['policy_run_days'] : '' ?>" type="text" class="form-control" id="policy_run_days" name="policy_run_days[]"
|
||||
<input value="<?= isset($lead_edit_data['policy_run_days']) ? $lead_edit_data['policy_run_days'] : '' ?>" type="text" class="form-control" id="policy_run_days<?= $increment ?>" name="policy_run_days[]"
|
||||
placeholder="Enter Policy Run Days" oninput="earnedPremiumCalc(this)" onkeyup="incurredClaimSum(this)">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 renewalFields" style="display: none;">
|
||||
<label for="premium_at_inception">Premium Paid at Inception<span
|
||||
class="text-danger">*</span></label>
|
||||
<input value="<?= isset($lead_edit_data['premium_at_inception']) ? $lead_edit_data['premium_at_inception'] : '' ?>" type="text" class="form-control" id="premium_at_inception" name="premium_at_inception[]"
|
||||
<input value="<?= isset($lead_edit_data['premium_at_inception']) ? $lead_edit_data['premium_at_inception'] : '' ?>" type="text" class="form-control" id="premium_at_inception<?= $increment ?>" name="premium_at_inception[]"
|
||||
placeholder="Enter Premium Paid" oninput="earnedPremiumCalc(this)">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 renewalFields" style="display: none;">
|
||||
<label for="premium_date">Premium Date<span class="text-danger"></span></label>
|
||||
<input value="<?= isset($lead_edit_data['premium_date']) ? $lead_edit_data['premium_date'] : '' ?>" type="text" class="form-control" id="premium_date" name="premium_date[]"
|
||||
<label for="premium_date">Premium as on Date<span class="text-danger">*</span></label>
|
||||
<input value="<?= isset($lead_edit_data['premium_date']) ? $lead_edit_data['premium_date'] : '' ?>" type="text" class="form-control" id="premium_date<?= $increment ?>" name="premium_date[]"
|
||||
placeholder="Enter Premium Date">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 renewalFields" style="display: none;">
|
||||
<label for="earned_premium">Earned Premium<span class="text-danger">*</span></label>
|
||||
<input value="<?= isset($lead_edit_data['earned_premium']) ? $lead_edit_data['earned_premium'] : '' ?>" type="text" class="form-control" id="earned_premium" name="earned_premium[]"
|
||||
<input value="<?= isset($lead_edit_data['earned_premium']) ? $lead_edit_data['earned_premium'] : '' ?>" type="text" class="form-control" id="earned_premium<?= $increment ?>" name="earned_premium[]"
|
||||
placeholder="Enter Earned Premium" oninput="incurredClaimSum(this)">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 renewalFields" style="display: none;">
|
||||
<label for="annualised_claims">Annualised Claims<span class="text-danger">*</span></label>
|
||||
<input value="<?= isset($lead_edit_data['annualised_claims']) ? $lead_edit_data['annualised_claims'] : '' ?>" type="text" class="form-control" id="annualised_claims" name="annualised_claims[]"
|
||||
<input value="<?= isset($lead_edit_data['annualised_claims']) ? $lead_edit_data['annualised_claims'] : '' ?>" type="text" class="form-control" id="annualised_claims<?= $increment ?>" name="annualised_claims[]"
|
||||
placeholder="Enter Annualised Claims">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 renewalFields" style="display: none;">
|
||||
<label for="incurred_claims_ratio">Incurred Claims Ratio<span
|
||||
class="text-danger">*</span></label>
|
||||
<input value="<?= isset($lead_edit_data['incurred_claims_ratio']) ? $lead_edit_data['incurred_claims_ratio'] : '' ?>" type="text" class="form-control" id="incurred_claims_ratio"
|
||||
<input value="<?= isset($lead_edit_data['incurred_claims_ratio']) ? $lead_edit_data['incurred_claims_ratio'] : '' ?>" type="text" class="form-control" id="incurred_claims_ratio<?= $increment ?>"
|
||||
name="incurred_claims_ratio[]" placeholder="Enter Incurred Claims Ratio">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 renewalFields" style="display: none;">
|
||||
<label for="earned_claims_ratio">Earned Claims Ratio<span class="text-danger">*</span></label>
|
||||
<input value="<?= isset($lead_edit_data['earned_claims_ratio']) ? $lead_edit_data['earned_claims_ratio'] : '' ?>" type="text" class="form-control" id="earned_claims_ratio" name="earned_claims_ratio[]"
|
||||
<input value="<?= isset($lead_edit_data['earned_claims_ratio']) ? $lead_edit_data['earned_claims_ratio'] : '' ?>" type="text" class="form-control" id="earned_claims_ratio<?= $increment ?>" name="earned_claims_ratio[]"
|
||||
placeholder="Enter Earned Claims Ratio">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 renewalFields" style="display: none;">
|
||||
<!-- <div class="form-group col-md-3 renewalFields" style="display: none;">
|
||||
<label for="location">Location <span class="text-danger">*</span></label>
|
||||
<input value="<?= isset($lead_edit_data['location']) ? $lead_edit_data['location'] : '' ?>" type="text" class="form-control" id="location" name="location[]" placeholder="Enter Location">
|
||||
</div>
|
||||
<input value="<?php //echo isset($lead_edit_data['location']) ? $lead_edit_data['location'] : '' ?>" type="text" class="form-control" id="location" name="location[]" placeholder="Enter Location">
|
||||
</div> -->
|
||||
|
||||
<div class="form-group col-md-3 proposed_div" style="display: none;">
|
||||
<label for="proposed_insurer">Proposed Insurer <span class="text-danger"></span></label>
|
||||
|
||||
@ -233,6 +233,7 @@
|
||||
<button id="submitMail" class="btn btn-primary" onclick="checkTheTableDataChanged(3)">Send Insurer Mail</button>
|
||||
<button id="submitPlacement" class="btn btn-primary" onclick="checkTheTableDataChanged(6)">Placement</button>
|
||||
<input type="hidden" id="lead_id" name="lead_id" value="<?= isset($lead_id) ? $lead_id : '' ?>">
|
||||
<input type="hidden" id="rfq_primaryKey" name="rfq_primaryKey" value="<?= isset($rfq_data['id']) ? $rfq_data['id'] : '' ?>">
|
||||
<input type="hidden" id="qcr_count" value="<?= isset($qcr_count) ? $qcr_count : 0 ?>">
|
||||
<!-- <button id="openDialogBtn">Open Dialog</button> -->
|
||||
|
||||
@ -804,6 +805,13 @@
|
||||
|
||||
<script>
|
||||
|
||||
$(document).ready(function () {
|
||||
setInterval(function () {
|
||||
submitData(1);
|
||||
}, 15000);
|
||||
});
|
||||
|
||||
|
||||
const openDialogBtn = document.getElementById('openDialogBtn');
|
||||
const closeDialogBtn = document.getElementById('closeDialogBtn');
|
||||
|
||||
@ -5220,7 +5228,8 @@ function appendMultiFileData(data) {
|
||||
|
||||
<script>
|
||||
|
||||
async function submitData(json) {
|
||||
async function submitData(input) {
|
||||
|
||||
console.log(over_all_column_data);
|
||||
|
||||
try {
|
||||
@ -5235,6 +5244,7 @@ function appendMultiFileData(data) {
|
||||
// Create a FormData object
|
||||
const formData = new FormData();
|
||||
let lead_id = $('#lead_id').val();
|
||||
let rfq_primaryKey = $('#rfq_primaryKey').val();
|
||||
|
||||
let submit_type = "RFQ"
|
||||
if(RFQ_or_QCR == 2){submit_type = 'QCR'}
|
||||
@ -5243,6 +5253,10 @@ function appendMultiFileData(data) {
|
||||
formData.append('lead_id', lead_id);
|
||||
formData.append('submit_type', submit_type);
|
||||
|
||||
if(input == 1){
|
||||
formData.append('rfq_primaryKey', rfq_primaryKey);
|
||||
}
|
||||
|
||||
const postUrl = '<?= base_url('rfq/create')?>';
|
||||
console.log(postUrl);
|
||||
|
||||
@ -5258,11 +5272,14 @@ function appendMultiFileData(data) {
|
||||
|
||||
if (response.status == true) {
|
||||
toastr.success(response.message, 'SUCCESS');
|
||||
$('#rfq_primaryKey').val(response.id);
|
||||
} else {
|
||||
toastr.warning(response.message, 'WARNING');
|
||||
}
|
||||
|
||||
window.location.reload();
|
||||
if(input != 1){
|
||||
window.location.reload();
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error('An error occurred during the AJAX request:');
|
||||
|
||||
Loading…
Reference in New Issue
Block a user