CHANGE_EXCEL : RV
This commit is contained in:
parent
b313309e00
commit
b794120ed3
@ -4711,6 +4711,10 @@ class ClientController extends AdminController
|
||||
// $empmodel = new EmployeeModel();
|
||||
// $data = $empmodel->getEmployeePolicy(348);
|
||||
// dd($data);
|
||||
|
||||
|
||||
// $LeadsController = new LeadsController();
|
||||
// $LeadsController->constructNonEbExcelToSaveTemp(92, 2, "Proposal 2-ICICIPRU-ICICI001");
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------
|
||||
|
||||
@ -2401,76 +2401,6 @@ class LeadsController extends BaseController
|
||||
$this->loadLayout('view_rfq_non_eb');
|
||||
}
|
||||
|
||||
// public function getLeadNonEB($type, $id = null)
|
||||
// {
|
||||
// // Set basic data
|
||||
// $data['issuer'] = $this->issuer;
|
||||
// $data['client_type'] = $this->clientType;
|
||||
// $data['lead_type'] = $this->leadType;
|
||||
// $data['lead_status'] = $this->leadsStatus;
|
||||
|
||||
// // Fetch policy types and entity data
|
||||
// $data['policy_type'] = $this->policyTypeModel->where('is_active', 1)->findAll();
|
||||
// $data['entity'] = $this->kycEntityTypeModel->where('is_active', 1)->findAll();
|
||||
|
||||
// // Fetch insurer and TPA branch data
|
||||
// $data['insurer'] = $this->insurerBranchModel->getInsurerBranchesWithInsurerNames();
|
||||
// $data['tpa'] = $this->tpaBranchModel->getTpaBranchesWithTpaNames();
|
||||
// // print_r($data['tpa']);die();
|
||||
// // Fetch sales team members who are active in team 5
|
||||
// $data['salse_team'] = $this->userModel
|
||||
// ->select('user_profiles.*')
|
||||
// ->join('user_teams', 'user_profiles.id = user_teams.user_id')
|
||||
// ->where('user_teams.team_id', 5)
|
||||
// ->where('user_teams.is_active', 1)
|
||||
// ->where('user_profiles.is_active', 1)
|
||||
// ->findAll();
|
||||
|
||||
// // dd($data);
|
||||
// $data['lastFiveYears'] = $this->getLastFiveFinancialYears();
|
||||
// $data['gpaClaimType'] = $this->claim_type_for_gpa;
|
||||
// $data['causeOfDeath'] = $this->cause_of_death;
|
||||
// $data['selected_lead_type'] = $type;
|
||||
|
||||
// if(!empty($id)){
|
||||
|
||||
// $data['lead_edit_data'] = $this->leadsModel->where('id', $id)->first();
|
||||
|
||||
// if (!empty($data['lead_edit_data'])) {
|
||||
// $data['lead_edit_data']['policy_start_date'] = !empty($data['lead_edit_data']['policy_start_date'])
|
||||
// ? change_date_format($data['lead_edit_data']['policy_start_date'], 'Y-m-d', 'd/m/Y')
|
||||
// : null;
|
||||
|
||||
// $data['lead_edit_data']['policy_end_date'] = !empty($data['lead_edit_data']['policy_end_date'])
|
||||
// ? change_date_format($data['lead_edit_data']['policy_end_date'], 'Y-m-d', 'd/m/Y')
|
||||
// : null;
|
||||
|
||||
// $data['lead_edit_data']['incurred_claims_date'] = !empty($data['lead_edit_data']['incurred_claims_date'])
|
||||
// ? change_date_format($data['lead_edit_data']['incurred_claims_date'], 'Y-m-d', 'd/m/Y')
|
||||
// : null;
|
||||
|
||||
// $data['lead_edit_data']['premium_date'] = !empty($data['lead_edit_data']['premium_date'])
|
||||
// ? change_date_format($data['lead_edit_data']['premium_date'], 'Y-m-d', 'd/m/Y')
|
||||
// : null;
|
||||
// } else {
|
||||
// $data['lead_edit_data'] = [];
|
||||
// }
|
||||
|
||||
// if (!empty($data['lead_edit_data']['fin_years_claims'])) {
|
||||
// $decoded = json_decode($data['lead_edit_data']['fin_years_claims'], true);
|
||||
// $data['lead_edit_data']['fin_years_claims_array'] = isset($decoded['finyear']) ? $decoded['finyear'] : [];
|
||||
// } else {
|
||||
// $data['lead_edit_data']['fin_years_claims_array'] = [];
|
||||
// }
|
||||
|
||||
// $data['lead_edit_data']['html'] = $this->generateViewPageHtml($data['lead_edit_data']['policy_type_id'], $data) ?? "";
|
||||
// }
|
||||
|
||||
// // dd($data);
|
||||
|
||||
// return $this->loadLayout('leads_form_handler', $data);
|
||||
// }
|
||||
|
||||
public function getLeadNonEB($type, $id = null)
|
||||
{
|
||||
// Set basic data
|
||||
@ -2586,7 +2516,15 @@ class LeadsController extends BaseController
|
||||
$lead_data = [];
|
||||
}
|
||||
$lead_data = array_merge(['Insured' => $rfq_data['client_name']], $lead_data);
|
||||
// dd($lead_data);
|
||||
|
||||
// if(!empty($rfq_data['fin_years_claims'])){
|
||||
// $claim_details = json_decode($rfq_data['fin_years_claims'], true) ?? [];
|
||||
// if(!empty($claim_details['finyear'])){
|
||||
// $lead_data['claim_details'] = $claim_details['finyear'];
|
||||
// }
|
||||
// Kint::dump($claim_details);
|
||||
// }
|
||||
|
||||
|
||||
$jsonData = json_decode($rfq_data['json'], true);
|
||||
$proposalData = end($jsonData);
|
||||
@ -2681,21 +2619,29 @@ class LeadsController extends BaseController
|
||||
|
||||
$rowNumber += 2;
|
||||
|
||||
// Kint::dump($jsonData);
|
||||
|
||||
foreach ($jsonData as $key => $data) {
|
||||
|
||||
// Kint::dump($data, 'First');
|
||||
|
||||
if ($type == 2) {
|
||||
$data = $this->convertNonEbJsonForQCR($data, $type, $proposalData);
|
||||
unset($data['proposalData']);
|
||||
|
||||
$data = $this->convertNonEbJsonForQCR($data, $type, $proposalData, $key);
|
||||
|
||||
// Kint::dump($data, 'Second');
|
||||
|
||||
if ($propsal_and_insurer !== null) {
|
||||
list($proposal_key, $insurer_key) = explode('-', $propsal_and_insurer, 2);
|
||||
$data = $this->transformProposelData($data, $proposal_key, $insurer_key);
|
||||
$data = $this->transformNonEbProposelData($data, $proposal_key, $insurer_key, $key);
|
||||
}
|
||||
unset($data['proposalData']);
|
||||
} else if ($type == 1) {
|
||||
$data = $this->convertNonEbJsonForQCR($data, $type, $proposalData);
|
||||
$data = $this->convertNonEbJsonForQCR($data, $type, $proposalData, $key);
|
||||
unset($data['proposalData']);
|
||||
}
|
||||
|
||||
// dd($data);
|
||||
// Add headers and subheaders
|
||||
$headers = $data['table_data']['headers'];
|
||||
// dd($headers);
|
||||
@ -2714,7 +2660,7 @@ class LeadsController extends BaseController
|
||||
$sheet->getColumnDimension($columnLetter)->setWidth(60);
|
||||
|
||||
|
||||
if ($header['parentHeader'] == '') {
|
||||
if ($header['parentHeader'] == 'Policy') {
|
||||
// $header['parentHeader'] = 'S.No.';
|
||||
$sheet->getColumnDimension('A')->setWidth(10);
|
||||
}
|
||||
@ -2728,7 +2674,7 @@ class LeadsController extends BaseController
|
||||
$sheet->getColumnDimension('D')->setWidth(35);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$startColumn = $columnLetter; // Start of the current header range
|
||||
$subHeaderCount = count($header['subHeaders']); // Number of subheaders for this parent header
|
||||
|
||||
@ -2808,7 +2754,7 @@ class LeadsController extends BaseController
|
||||
|
||||
if ($cellData['parentth'] == 'SNO') {
|
||||
$sheet->setCellValue("{$columnLetter}{$rowNumber}", $serial_no);
|
||||
} else if ($cellData['parentth'] == '') {
|
||||
} else if ($cellData['parentth'] == 'Policy') {
|
||||
$mergeStart = $rowNumber; // Start row for merging
|
||||
$mergeEnd = $rowNumber + ($cellData['rowspan'] - 1); // End row for merging
|
||||
|
||||
@ -2817,7 +2763,7 @@ class LeadsController extends BaseController
|
||||
$sheet->getStyle("{$columnLetter}{$mergeStart}:{$columnLetter}{$mergeEnd}")
|
||||
->getAlignment()->setVertical(\PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER);
|
||||
} else {
|
||||
$sheet->setCellValue("{$columnLetter}{$rowNumber}", $cellData['display_value']);
|
||||
$sheet->setCellValue("{$columnLetter}{$rowNumber}", $cellData['display_content']);
|
||||
}
|
||||
|
||||
$columnLetter++;
|
||||
@ -2885,6 +2831,7 @@ class LeadsController extends BaseController
|
||||
]);
|
||||
}
|
||||
|
||||
// dd($rowNumber);
|
||||
// Set filename
|
||||
$string = ($type == 2) ? 'QCR' : 'RFQ';
|
||||
$filename = "{$string}_{$rfq_data['client_short_name']}_{$rfq_data['policy_type']}_" . date('YmdHis') . '.xlsx';
|
||||
@ -2900,241 +2847,223 @@ class LeadsController extends BaseController
|
||||
];
|
||||
}
|
||||
|
||||
public function convertNonEbJsonForQCR($jsonArr, $type, $proposeldata)
|
||||
public function convertNonEbJsonForQCR($jsonArr, $type, $proposeldata, $indexOfTheTable)
|
||||
{
|
||||
|
||||
$first_json = $jsonArr;
|
||||
$first_json = array_merge($first_json, $proposeldata);
|
||||
|
||||
if($type == 2){
|
||||
|
||||
// Column-wise Check: Remove headers and relevant data if qcr == 0
|
||||
foreach ($first_json['proposal_data']['over_all_column_data'] as $proposalKey => $proposalData) {
|
||||
$first_json = $jsonArr;
|
||||
$first_json = array_merge($first_json, $proposeldata);
|
||||
|
||||
if (($proposalData['qcr'] == 0 || $proposalData['qcr'] === false) || ($proposalData['stc'] == 0 || $proposalData['stc'] === false)) {
|
||||
if ($type == 2) {
|
||||
|
||||
// Remove matching parentHeader in headers
|
||||
foreach ($first_json['table_data']['headers'] as $index => $header) {
|
||||
if ($header['parentHeader'] === $proposalKey) {
|
||||
unset($first_json['table_data']['headers'][$index]);
|
||||
// Column-wise Check: Remove headers and relevant data if qcr == 0
|
||||
foreach ($first_json['proposal_data']['over_all_column_data'] as $proposalKey => $proposalData) {
|
||||
|
||||
if ((isset($proposalData['qcr']) && isset($proposalData['stc'])) && ($proposalData['qcr'] == 0 || $proposalData['qcr'] === false) || ($proposalData['stc'] == 0 || $proposalData['stc'] === false)) {
|
||||
|
||||
// Remove matching parentHeader in headers
|
||||
foreach ($first_json['table_data']['headers'] as $index => $header) {
|
||||
if ($header['parentHeader'] === $proposalKey) {
|
||||
unset($first_json['table_data']['headers'][$index]);
|
||||
}
|
||||
}
|
||||
|
||||
// Remove data entries with matching parentth
|
||||
foreach ($first_json['table_data']['data'] as &$item) {
|
||||
$item['data'] = array_values(array_filter($item['data'], function ($entry) use ($proposalKey) {
|
||||
return $entry['parentth'] !== $proposalKey;
|
||||
}));
|
||||
}
|
||||
|
||||
// Remove proposalKey from over_all_column_data
|
||||
unset($first_json['proposal_data']['over_all_column_data'][$proposalKey]);
|
||||
|
||||
if ($type == 2) {
|
||||
// Remove proposalKey from premium_data
|
||||
unset($first_json['premium_data']['data'][$proposalKey]);
|
||||
}
|
||||
}
|
||||
|
||||
// Insurer Check: Remove subHeaders and relevant data for insurers with qcr == 0
|
||||
foreach ($proposalData['insurers'] as $insurerIndex => $insurer) {
|
||||
|
||||
$qcr = $insurer['qcr'] ?? null;
|
||||
$stc = $insurer['stc'] ?? null;
|
||||
|
||||
if (($qcr === 0 || $qcr === false) || ($stc === 0 || $stc === false)) {
|
||||
|
||||
foreach ($first_json['table_data']['headers'] as &$header) {
|
||||
if (isset($header['subHeaders'])) {
|
||||
$header['subHeaders'] = array_values(array_filter($header['subHeaders'], function ($sub) use ($insurer) {
|
||||
return $sub !== $insurer['display_name'];
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
// Remove data entries with matching parentth
|
||||
|
||||
foreach ($first_json['table_data']['data'] as &$item) {
|
||||
$item['data'] = array_values(array_filter($item['data'], function ($entry) use ($proposalKey) {
|
||||
return $entry['parentth'] !== $proposalKey;
|
||||
$item['data'] = array_values(array_filter($item['data'], function ($entry) use ($insurer) {
|
||||
return $entry['subth'] !== $insurer['display_name'];
|
||||
}));
|
||||
}
|
||||
|
||||
// Remove proposalKey from over_all_column_data
|
||||
unset($first_json['proposal_data']['over_all_column_data'][$proposalKey]);
|
||||
|
||||
if($type == 2){
|
||||
// Remove proposalKey from premium_data
|
||||
unset($first_json['premium_data']['data'][$proposalKey]);
|
||||
}
|
||||
}
|
||||
// Remove insurer from proposal's insurers array
|
||||
unset($first_json['proposal_data']['over_all_column_data'][$proposalKey]['insurers'][$insurerIndex]);
|
||||
|
||||
// Insurer Check: Remove subHeaders and relevant data for insurers with qcr == 0
|
||||
foreach ($proposalData['insurers'] as $insurerIndex => $insurer) {
|
||||
if (($insurer['qcr'] === 0 || $insurer['qcr'] === false) || ($insurer['stc'] === 0 || $insurer['stc'] === false) ) {
|
||||
foreach ($first_json['table_data']['headers'] as &$header) {
|
||||
if (isset($header['subHeaders'])) {
|
||||
$header['subHeaders'] = array_values(array_filter($header['subHeaders'], function ($sub) use ($insurer) {
|
||||
return $sub !== $insurer['display_name'];
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
foreach ($first_json['table_data']['data'] as &$item) {
|
||||
$item['data'] = array_values(array_filter($item['data'], function ($entry) use ($insurer) {
|
||||
return $entry['subth'] !== $insurer['display_name'];
|
||||
}));
|
||||
}
|
||||
|
||||
// Remove insurer from proposal's insurers array
|
||||
unset($first_json['proposal_data']['over_all_column_data'][$proposalKey]['insurers'][$insurerIndex]);
|
||||
|
||||
if($type == 2){
|
||||
unset($first_json['premium_data']['data'][$proposalKey][$insurer['display_name']]);
|
||||
}
|
||||
if ($type == 2) {
|
||||
unset($first_json['premium_data']['data'][$proposalKey][$insurer['display_name']]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Row-wise Check: Remove rows if qcr == 0 for actions
|
||||
foreach ($first_json['table_data']['data'] as $rowKey => $rowData) {
|
||||
foreach ($rowData['data'] as $data) {
|
||||
if (
|
||||
isset($data['parentth']) && $data['parentth'] === "Action" &&
|
||||
(
|
||||
(isset($data['input_value']['qcr']) && $data['input_value']['qcr'] == 0) ||
|
||||
(isset($data['input_value']['stc']) && $data['input_value']['stc'] == 0)
|
||||
)
|
||||
) {
|
||||
|
||||
unset($first_json['table_data']['data'][$rowKey]);
|
||||
break; // Stop checking other columns for this row
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Reindex arrays to maintain proper structure
|
||||
$first_json['table_data']['headers'] = array_values($first_json['table_data']['headers']);
|
||||
$first_json['table_data']['data'] = array_values($first_json['table_data']['data']);
|
||||
$first_json['proposal_data']['over_all_column_data'] = array_map(function ($proposal) {
|
||||
$proposal['insurers'] = array_values($proposal['insurers']);
|
||||
return $proposal;
|
||||
}, $first_json['proposal_data']['over_all_column_data']);
|
||||
|
||||
}else{
|
||||
|
||||
//remove insurer as Subheaders for RFQ
|
||||
foreach ($first_json['table_data']['headers'] as &$header) {
|
||||
// Ensure 'subHeaders' exists and is an array before filtering
|
||||
if (isset($header['subHeaders']) && is_array($header['subHeaders'])) {
|
||||
$header['subHeaders'] = array_filter($header['subHeaders'], function ($subHeader) {
|
||||
return in_array($subHeader, ['Quote asked', '-'], true);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//Remove insurer Row wise data for RFQ
|
||||
foreach ($first_json['table_data']['data'] as &$row) {
|
||||
|
||||
// Filter the inner data array
|
||||
$row['data'] = array_filter(
|
||||
$row['data'],
|
||||
function ($item) {
|
||||
return in_array($item['subth'], ['Quote asked', '-']);
|
||||
}
|
||||
);
|
||||
|
||||
$row['data'] = array_values($row['data']);
|
||||
}
|
||||
|
||||
// Ensure to unset the reference after the loop
|
||||
unset($row);
|
||||
|
||||
// Remove insurers from Proposal Data key for RFQ
|
||||
foreach ($proposeldata['proposal_data']['over_all_column_data'] as $key => &$proposal) {
|
||||
if (isset($proposal['insurers'])) {
|
||||
// Set the insurers array to empty
|
||||
$proposal['insurers'] = [];
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure to reset the reference
|
||||
unset($proposal);
|
||||
|
||||
}
|
||||
return $first_json;
|
||||
|
||||
// Row-wise Check: Remove rows if qcr == 0 for actions
|
||||
foreach ($first_json['table_data']['data'] as $rowKey => $rowData) {
|
||||
foreach ($rowData['data'] as $data) {
|
||||
|
||||
if ($indexOfTheTable == 0) {
|
||||
|
||||
if ($data['parentth'] == "Policy" && $data['input_value'] != "Checked") {
|
||||
unset($first_json['table_data']['data'][$rowKey]);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (
|
||||
isset($data['parentth'], $data['input_value']['qcr'], $data['input_value']['stc']) &&
|
||||
$data['parentth'] === "Action" &&
|
||||
($data['input_value']['qcr'] == 0 || $data['input_value']['stc'] == 0)
|
||||
) {
|
||||
unset($first_json['table_data']['data'][$rowKey]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Reindex arrays to maintain proper structure
|
||||
$first_json['table_data']['headers'] = array_values($first_json['table_data']['headers']);
|
||||
$first_json['table_data']['data'] = array_values($first_json['table_data']['data']);
|
||||
$first_json['proposal_data']['over_all_column_data'] = array_map(function ($proposal) {
|
||||
$proposal['insurers'] = array_values($proposal['insurers']);
|
||||
return $proposal;
|
||||
}, $first_json['proposal_data']['over_all_column_data']);
|
||||
} else {
|
||||
|
||||
//remove insurer as Subheaders for RFQ
|
||||
foreach ($first_json['table_data']['headers'] as &$header) {
|
||||
// Ensure 'subHeaders' exists and is an array before filtering
|
||||
if (isset($header['subHeaders']) && is_array($header['subHeaders'])) {
|
||||
$header['subHeaders'] = array_filter($header['subHeaders'], function ($subHeader) {
|
||||
return in_array($subHeader, ['Quote asked', '-'], true);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//Remove insurer Row wise data for RFQ
|
||||
foreach ($first_json['table_data']['data'] as &$row) {
|
||||
|
||||
// Filter the inner data array
|
||||
$row['data'] = array_filter(
|
||||
$row['data'],
|
||||
function ($item) {
|
||||
return in_array($item['subth'], ['Quote asked', '-']);
|
||||
}
|
||||
);
|
||||
|
||||
$row['data'] = array_values($row['data']);
|
||||
}
|
||||
|
||||
// Ensure to unset the reference after the loop
|
||||
unset($row);
|
||||
|
||||
// Remove insurers from Proposal Data key for RFQ
|
||||
foreach ($proposeldata['proposal_data']['over_all_column_data'] as $key => &$proposal) {
|
||||
if (isset($proposal['insurers'])) {
|
||||
// Set the insurers array to empty
|
||||
$proposal['insurers'] = [];
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure to reset the reference
|
||||
unset($proposal);
|
||||
}
|
||||
return $first_json;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function transformNonEbProposelData($data, $proposel, $insurer)
|
||||
public function transformNonEbProposelData(&$data, $proposal, $insurer, $tableCount)
|
||||
{
|
||||
// Kint::dump($data, $proposal, $insurer, $tableCount);
|
||||
|
||||
// print_r($data['premium_data']['data']); die;
|
||||
|
||||
// Initialize headers with defaults
|
||||
$headerData = [];
|
||||
|
||||
// Default headers: S. No and Particulars
|
||||
$defaultHeaders = [
|
||||
[
|
||||
'parentHeader' => 'Sno',
|
||||
'subHeaders' => ['-']
|
||||
],
|
||||
[
|
||||
'parentHeader' => 'Particulars',
|
||||
'subHeaders' => ['-']
|
||||
]
|
||||
// Add the first two default headers only once
|
||||
$headerData[] = [
|
||||
'parentHeader' => $data['table_data']['headers'][0]['parentHeader'],
|
||||
'subHeaders' => ['-']
|
||||
];
|
||||
$headerData[] = [
|
||||
'parentHeader' => $data['table_data']['headers'][1]['parentHeader'],
|
||||
'subHeaders' => ['-']
|
||||
];
|
||||
|
||||
// Add default headers to the result
|
||||
$headerData = array_merge($headerData, $defaultHeaders);
|
||||
$second_table_name = $data['table_data']['headers'][1]['parentHeader'] ?? "";
|
||||
|
||||
// Loop through the headers to find matching proposal and insurer
|
||||
foreach ($data['table_data']['headers'] as $header) {
|
||||
// Check if the parentHeader matches the target proposal
|
||||
if ($header['parentHeader'] === $proposel) {
|
||||
// Check if subHeaders contain the target insurer key
|
||||
if ($header['parentHeader'] === $proposal) {
|
||||
foreach ($header['subHeaders'] as $subHeader) {
|
||||
if ($subHeader === $insurer) {
|
||||
$headerData[] = [
|
||||
'parentHeader' => $header['parentHeader'],
|
||||
'subHeaders' => [
|
||||
'Quote asked', // Default value
|
||||
$subHeader // Matched insurer key
|
||||
]
|
||||
'subHeaders' => ['Quote asked', $subHeader]
|
||||
];
|
||||
break;
|
||||
break 2; // Exit both loops after match is found
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$columnData = [];
|
||||
// Update the original data's headers
|
||||
$data['table_data']['headers'] = $headerData;
|
||||
|
||||
foreach ($data['table_data']['data'] as $entry) {
|
||||
foreach ($data['table_data']['data'] as &$entry) {
|
||||
|
||||
$sno = $entry['SNO'];
|
||||
$items = $entry['items'];
|
||||
$row_id = $entry['row_id'];
|
||||
$dataEntry = $entry['data'];
|
||||
|
||||
$result = [
|
||||
"SNO" => $sno,
|
||||
"items" => $items,
|
||||
"items" => $row_id,
|
||||
"data" => []
|
||||
];
|
||||
$filteredData = [];
|
||||
|
||||
foreach ($dataEntry as $item) {
|
||||
foreach ($entry['data'] as $item) {
|
||||
|
||||
// Include Sno and Particulars by default
|
||||
if (in_array($item['parentth'], ['Sno', 'Particulars'])) {
|
||||
$result['data'][] = [
|
||||
"parentth" => $item['parentth'],
|
||||
"subth" => $item['subth'],
|
||||
"value" => $item['value'],
|
||||
"input_value" => $item['input_value'],
|
||||
"display_value" => $item['display_value'],
|
||||
"rowspan" => $item['rowspan'],
|
||||
];
|
||||
// Always include SNO and Particulars
|
||||
if (in_array($item['parentth'], ['S.NO', "Policy", "", 'Particulars', $second_table_name])) {
|
||||
$filteredData[] = $item;
|
||||
}
|
||||
|
||||
// Include Proposal with Quote Asked by default
|
||||
if ($item['parentth'] === $proposel && $item['subth'] === "Quote asked") {
|
||||
$result['data'][] = [
|
||||
"parentth" => $item['parentth'],
|
||||
"subth" => $item['subth'],
|
||||
"value" => $item['value'],
|
||||
"input_value" => $item['input_value'],
|
||||
"display_value" => $item['display_value'],
|
||||
"rowspan" => $item['rowspan'],
|
||||
];
|
||||
// Include Proposal with Quote Asked
|
||||
if ($item['parentth'] === $proposal && $item['subth'] === "Quote asked") {
|
||||
$filteredData[] = $item;
|
||||
}
|
||||
|
||||
// Example of including matching specific proposals and insurers
|
||||
if ($item['parentth'] === $proposel && $item['subth'] === $insurer) {
|
||||
$result['data'][] = [
|
||||
"parentth" => $item['parentth'],
|
||||
"subth" => $item['subth'],
|
||||
"value" => $item['value'],
|
||||
"input_value" => $item['input_value'],
|
||||
"display_value" => $item['display_value'],
|
||||
"rowspan" => $item['rowspan'],
|
||||
];
|
||||
// Include specific proposal and insurer
|
||||
if ($item['parentth'] === $proposal && $item['subth'] === $insurer) {
|
||||
$filteredData[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
// Add to the final result
|
||||
$columnData[] = $result;
|
||||
// Update the entry with filtered data
|
||||
$entry['SNO'] = $sno;
|
||||
$entry['items'] = $items;
|
||||
$entry['row_id'] = $row_id;
|
||||
$entry['data'] = $filteredData;
|
||||
}
|
||||
unset($entry);
|
||||
|
||||
// kint::dump($data);
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -83,7 +83,8 @@ if (isset($selected_lead_type)) {
|
||||
var client_list = ''; // local variable for storing the client branch list
|
||||
var branch_list = ''; // local variable for storing the client branch list
|
||||
var policy_list = ''; // local variable for storing the client policy list
|
||||
|
||||
var temp_client_id = 0;
|
||||
var temp_branch_id = 0;
|
||||
|
||||
// select2 document ready
|
||||
$(document).ready(function() {
|
||||
@ -222,7 +223,21 @@ if (isset($selected_lead_type)) {
|
||||
let data = branch_list[client_id];
|
||||
appendBranch(data);
|
||||
} else {
|
||||
toastr.warning("No Branch Found for the selected Client", 'Warning');
|
||||
if (temp_client_id == 0) {
|
||||
console.log("Step 1: temp_client_id is 0 - No Branch Found for the selected Client");
|
||||
console.log('second client_id', client_id);
|
||||
if (client_id == null || client_id == 0) {
|
||||
console.log("Step 2: client_id is null or 0 - Setting temp_client_id to 0");
|
||||
temp_client_id = 0;
|
||||
} else {
|
||||
console.log("Step 3: client_id exists - Assigning temp_client_id = client_id");
|
||||
temp_client_id = client_id;
|
||||
toastr.warning("No Branch Found for the selected Client", 'Warning');
|
||||
}
|
||||
} else {
|
||||
console.log("Step 4: temp_client_id is not 0 - Showing warning");
|
||||
toastr.warning("No Branch Found for the selected Client", 'Warning');
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
@ -230,6 +245,7 @@ if (isset($selected_lead_type)) {
|
||||
$('#client_branch_id').change(function() {
|
||||
|
||||
let client_branch_id = $(this).val();
|
||||
console.log('client_branch_id', client_branch_id);
|
||||
|
||||
if (policy_list[client_branch_id] != '' && policy_list[client_branch_id] != null &&
|
||||
client_branch_id != '' && client_branch_id != null) {
|
||||
@ -238,7 +254,22 @@ if (isset($selected_lead_type)) {
|
||||
appendRenewalPolicies(data);
|
||||
} else {
|
||||
$('#source_policy_id').empty();
|
||||
toastr.warning("No Policies Found for the selected Branch", 'Warning');
|
||||
|
||||
if (temp_branch_id == 0) {
|
||||
console.log("Step 1: temp_branch_id is 0 - No Policies Found for the selected branch");
|
||||
console.log('second client_branch_id', client_branch_id);
|
||||
if (client_branch_id == null || client_branch_id == 0) {
|
||||
console.log("Step 2: client_branch_id is null or 0 - Setting temp_branch_id to 0");
|
||||
temp_branch_id = 0;
|
||||
} else {
|
||||
console.log("Step 3: v exists - Assigning temp_branch_id = client_branch_id");
|
||||
temp_branch_id = client_id;
|
||||
toastr.warning("No Policies Found for the selected Branch", 'Warning');
|
||||
}
|
||||
} else {
|
||||
console.log("Step 4: temp_branch_id is not 0 - Showing warning");
|
||||
toastr.warning("No Policies Found for the selected Branch", 'Warning');
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
@ -453,6 +484,12 @@ if (isset($selected_lead_type)) {
|
||||
|
||||
leadTypeBsedHideAndShow(lead_type);
|
||||
|
||||
if(data.client_id == 0 || data.client_id == null){
|
||||
temp_client_id = 0;
|
||||
}else{
|
||||
temp_client_id = data.client_id
|
||||
}
|
||||
|
||||
|
||||
$('#page_title').text('Edit Lead');
|
||||
$('#leads_primarykey').val(data.id || '');
|
||||
|
||||
@ -354,9 +354,17 @@ hr.solid {
|
||||
|
||||
$(document).ready(function(){
|
||||
|
||||
var today = new Date();
|
||||
|
||||
var policy_start_datePicker = flatpickr("#policy_start_date", {
|
||||
dateFormat: "d/m/Y",
|
||||
allowInput: false
|
||||
allowInput: false,
|
||||
onChange: function(selectedDates, dateStr, instance) {
|
||||
var endDate = new Date(selectedDates[0]);
|
||||
endDate.setFullYear(endDate.getFullYear() + 1);
|
||||
endDate.setDate(endDate.getDate() - 1); // Set end date to last day of selected year
|
||||
policy_end_datePicker.setDate(endDate);
|
||||
}
|
||||
});
|
||||
var policy_end_datePicker = flatpickr("#policy_end_date", {
|
||||
dateFormat: "d/m/Y",
|
||||
@ -705,7 +713,22 @@ function getPolicyData(input) {
|
||||
$(`#policy_type_id`).val(res.data.policy_type_id).trigger('change');
|
||||
$(`#insurer`).val(insurer).trigger('change');
|
||||
$(`#tpa`).val(tpa).trigger('change');
|
||||
$('#policy_start_date').val(res.new_start_date);
|
||||
|
||||
if ($('#policy_start_date').hasClass('flatpickr-input')) {
|
||||
const fpInstance = $('#policy_start_date')[0]._flatpickr;
|
||||
if (fpInstance) {
|
||||
fpInstance.destroy(); // Remove Flatpickr instance
|
||||
}
|
||||
}
|
||||
|
||||
if ($('#policy_end_date').hasClass('flatpickr-input')) {
|
||||
const fpInstance = $('#policy_end_date')[0]._flatpickr;
|
||||
if (fpInstance) {
|
||||
fpInstance.destroy(); // Remove Flatpickr instance
|
||||
}
|
||||
}
|
||||
|
||||
$('#policy_start_date').val(res.new_start_date); // Set new value
|
||||
$('#policy_end_date').val(res.end_date);
|
||||
|
||||
|
||||
|
||||
@ -182,11 +182,11 @@
|
||||
<div class="row" style="margin-bottom: 1rem;margin-left: 0px;">
|
||||
<button class="btn btn-custom rfqbtn" id="addProposal" style="margin-right: 10px;">Add New Proposal</button>
|
||||
<button id="saveRFQ" onclick="saveRFQ()" class="btn btn-primary" style="margin-right: 10px;">Save RFQ</button>
|
||||
<button id="openQCR" onclick="openQCR()" class="btn btn-primary rfqbtn" style="margin-right: 20px;">Proceed to QCR</button>
|
||||
<a id="submitExcel" onclick="checkTheTableDataChanged(2)" class="btn btn-primary" style="margin-right: 10px;">Export Excel</a>
|
||||
<button id="submitInternalMail" class="btn btn-primary" style="margin-right: 10px;" onclick="checkTheTableDataChanged(4)">Send Internal Mail</button>
|
||||
<button id="submitMail" class="btn btn-primary" style="margin-right: 10px;" onclick="checkTheTableDataChanged(3)">Send Insurer Mail</button>
|
||||
<button id="submitPlacement" class="btn btn-primary qcrbtn" onclick="checkTheTableDataChanged(6)">Placement</button>
|
||||
<button id="openQCR" onclick="openQCR()" class="btn btn-primary rfqbtn actionBtns" style="margin-right: 20px;">Proceed to QCR</button>
|
||||
<a id="submitExcel" onclick="checkTheTableDataChanged(2)" class="btn btn-primary actionBtns" style="margin-right: 10px;">Export Excel</a>
|
||||
<button id="submitInternalMail" class="btn btn-primary actionBtns" style="margin-right: 10px;" onclick="checkTheTableDataChanged(4)">Send Internal Mail</button>
|
||||
<button id="submitMail" class="btn btn-primary actionBtns" style="margin-right: 10px;" onclick="checkTheTableDataChanged(3)">Send Insurer Mail</button>
|
||||
<button id="submitPlacement" class="btn btn-primary qcrbtn actionBtns" onclick="checkTheTableDataChanged(6)">Placement</button>
|
||||
</div>
|
||||
|
||||
|
||||
@ -391,6 +391,8 @@
|
||||
rfq_data = rfq_data ? JSON.parse(rfq_data) : {}; // Convert to object if not already
|
||||
|
||||
var rfq_or_qcr = 1;
|
||||
var proposalDataForDropDown = {};
|
||||
|
||||
var policyConfig = {
|
||||
1: ['Quote asked']
|
||||
};
|
||||
@ -414,8 +416,10 @@
|
||||
});
|
||||
var tableCount = 0;
|
||||
const policies = <?= json_encode($policies) ?>;
|
||||
console.log('policies', policies);
|
||||
|
||||
const child_table_data = <?= json_encode($child_table_data) ?>;
|
||||
console.log('child_table_data', child_table_data);
|
||||
|
||||
const policyOrder = [{
|
||||
'fire': {
|
||||
@ -1326,8 +1330,9 @@
|
||||
}
|
||||
|
||||
<td contenteditable="true">${tableData ? policy_question : policy.description}</td>
|
||||
|
||||
${Object.values(quotesConfig).flatMap(codes =>
|
||||
codes.map(() => `<td onblur="setValueForHiddenField(this,'${answer_type}')" onclick = "getAnswer('${tableID}','${rowID}')" contenteditable="true">${tableData ? (default_value === '-' ? `${default_value} <input type="hidden" value='${default_value}' />` : `${default_answer} <input type="hidden" value='${JSON.stringify(default_answers_array[0])}' />`)
|
||||
codes.map(() => `<td onblur="setValueForHiddenField(this,'${answer_type}')" onclick = "getAnswer('${tableID}','${rowID}')" contenteditable="true">${tableData ? (default_value === '-' ? `${default_value} <input type="hidden" value='${default_value}' />` : `${default_answer} <input type="hidden" value='${typeof(default_answers_array) == "object" ? JSON.stringify(default_answers_array[0]) : String(default_answer)}' />`)
|
||||
: policy.quote_asked}</td>`)
|
||||
).join('')}
|
||||
<td>
|
||||
@ -1470,10 +1475,13 @@
|
||||
const newUrl = segments.join("/"); // Rebuild the URL
|
||||
rfq_or_qcr = 1;
|
||||
history.pushState(null, "", newUrl); // Change the URL without reloading
|
||||
|
||||
if (rfq_data.length) {
|
||||
console.log("inside if conditoon");
|
||||
localStorage.setItem('allTablesJsonData', JSON.stringify(rfq_data));
|
||||
jsonToTables();
|
||||
proposalDataForDropDown = rfq_data[rfq_data.length - 1].proposal_data;
|
||||
console.log("proposalDataForDropDown", proposalDataForDropDown);
|
||||
// generateTable(document.getElementById('tablesContainer'));
|
||||
// console.log("polices Length ", policies.length);
|
||||
|
||||
@ -1936,9 +1944,17 @@
|
||||
success: function(response) {
|
||||
if (response.status == true) {
|
||||
toastr.success(response.message, "Success");
|
||||
console.log(rfq_data.length);
|
||||
|
||||
$('.actionBtns').show();
|
||||
if(rfq_or_qcr == 2){
|
||||
$("#openQCR").hide();
|
||||
}
|
||||
|
||||
// window.location.reload();
|
||||
} else {
|
||||
toastr.error(response.message, "Error");
|
||||
$('.actionBtns').hide();
|
||||
}
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
@ -2156,6 +2172,7 @@
|
||||
}
|
||||
|
||||
function openQCR() {
|
||||
|
||||
const url = window.location.pathname; // Get the path (e.g., "/nhance/rfq/list/75/1")
|
||||
const segments = url.split("/"); // Split by "/"
|
||||
segments[segments.length - 1] = "2"; // Change the last segment
|
||||
@ -2171,6 +2188,7 @@
|
||||
jsonToTables();
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
// $('#rfq_qcr_page_title').text('QCR');
|
||||
hideProposalOptionsForChild();
|
||||
showOrHideFieldsBasedOnRFQorQCR();
|
||||
}
|
||||
@ -2561,6 +2579,7 @@
|
||||
$(".rfqbtn").show();
|
||||
$(".qcrbtn").hide();
|
||||
$("#saveRFQ").css("margin-right", "10px");
|
||||
$('#rfq_qcr_page_title').text('RFQ');
|
||||
|
||||
} else if (rfq_or_qcr == 2) {
|
||||
$(".newInsurer").show();
|
||||
@ -2582,9 +2601,21 @@
|
||||
$(".rfqbtn").hide();
|
||||
$(".qcrbtn").show();
|
||||
$("#saveRFQ").css("margin-right", "20px");
|
||||
$('#rfq_qcr_page_title').text('QCR');
|
||||
|
||||
}
|
||||
|
||||
if(rfq_data.length){
|
||||
$('.actionBtns').show();
|
||||
if(rfq_or_qcr == 2){
|
||||
$("#openQCR").hide();
|
||||
$("#submitPlacement").show();
|
||||
}else{
|
||||
$("#submitPlacement").hide();
|
||||
}
|
||||
}else{
|
||||
$('.actionBtns').hide();
|
||||
}
|
||||
makeQuoteAskedColumnNonEditableorEditable();
|
||||
}
|
||||
|
||||
@ -2918,7 +2949,7 @@
|
||||
<!-- Export Excel and Mail Script -->
|
||||
<script>
|
||||
|
||||
var proposalDataForDropDown = {};
|
||||
var user_role_id = <?= get_role_id(); ?>;
|
||||
|
||||
const editorConfig = {
|
||||
buttons: [
|
||||
|
||||
Loading…
Reference in New Issue
Block a user