Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev

This commit is contained in:
sanjeev.p 2026-04-10 12:23:09 +05:30
commit 7869e4d0f6
5 changed files with 86 additions and 69 deletions

View File

@ -1450,24 +1450,24 @@ class EmployeeServiceController extends AdminController
$data = calculate_premium_new(family_data: $family, policy_terms: $policy_terms, slab_details: $slab_details, fileArr: $file, existing_units: $existing_units);
// dd($data);
$employee_data_group_by_family[$emp_id] = $data;
// $res = $this->employeesOnboardProcess(['familiy_data' => $data, 'file' => $file]);
$res = $this->employeesOnboardProcess(['familiy_data' => $data, 'file' => $file]);
// if ($res > 0) {
// $employee_insert_count++;
// }
if ($res > 0) {
$employee_insert_count++;
}
}
// if ($employee_insert_count > 0) {
// $this->fileModel->where('id', $file_id)->set(['status' => 'success', 'reason' => ''])->update();
// $this->myLogger->logme("error", '{file_id} uploaded success', ['file_id' => $file_id]);
// } else {
// $reason = json_encode([
// 'error_summary' => [5 => 1],
// 'error_data' => "Rack rate configuration issue: Please check the slab rates configuration"
// ], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
// $this->fileModel->where('id', $file_id)->set(['status' => 'failed', 'reason' => $reason])->update();
// $this->myLogger->logme("error", '{file_id} uploaded failed with reason: Rack rate configuration issue: Please check the slab rates configuration', ['file_id' => $file_id]);
// }
if ($employee_insert_count > 0) {
$this->fileModel->where('id', $file_id)->set(['status' => 'success', 'reason' => ''])->update();
$this->myLogger->logme("error", '{file_id} uploaded success', ['file_id' => $file_id]);
} else {
$reason = json_encode([
'error_summary' => [5 => 1],
'error_data' => "Rack rate configuration issue: Please check the slab rates configuration"
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
$this->fileModel->where('id', $file_id)->set(['status' => 'failed', 'reason' => $reason])->update();
$this->myLogger->logme("error", '{file_id} uploaded failed with reason: Rack rate configuration issue: Please check the slab rates configuration', ['file_id' => $file_id]);
}
// $this->setPullNotification($this->getFileMetaDataByFileId($file_id, 'success'));
} else if (isset($params['client_policy_id'])) //handle data from enrollment to inception

View File

@ -2164,6 +2164,7 @@ class LeadsController extends BaseController
$data = $this->convertJsonForQCR($data, $type);
} // dd($data);
$lead_data = [];
if ($rfq_data['lead_type'] == 1) {
if (in_array($rfq_data['policy_type_id'], [2, 3, 4, 5])) {
@ -2190,6 +2191,12 @@ class LeadsController extends BaseController
// 'TPA' => $rfq_data['tpa_name'] ?? " - ",
'Policy Type' => $this->leadType[$rfq_data['lead_type']] ?? "",
];
}else {
$lead_data = [
'Insured' => $rfq_data['client_name'],
'Policy Type' => $this->leadType[$rfq_data['lead_type']] ?? ""
];
}
} else {
@ -2277,6 +2284,11 @@ class LeadsController extends BaseController
// 'TPA' => $rfq_data['tpa_name'] ?? " - ",
// 'Total Lives at Inception' => $rfq_data['total_lives_at_incept'],
];
} else {
$lead_data = [
'Insured' => $rfq_data['client_name'],
'Policy Type' => $this->leadType[$rfq_data['lead_type']] ?? ""
];
}
}
// print_r($lead_data); die;
@ -2312,39 +2324,43 @@ class LeadsController extends BaseController
$maxWidthA = 0;
$maxWidthB = 0;
foreach ($lead_data as $key => $value) {
// dd($lead_data);
// Merge A:B for key and C:D for value
$mergeRangeKey = "A{$rowNumber}:B{$rowNumber}";
// $mergeRangeValue = "C{$rowNumber}";
$sheet->mergeCells($mergeRangeKey);
// $sheet->mergeCells($mergeRangeValue);
if(! empty($lead_data)) {
foreach ($lead_data as $key => $value) {
// Set values in merged cells
$sheet->setCellValue("A{$rowNumber}", $key);
$sheet->setCellValue("C{$rowNumber}", $value);
// Merge A:B for key and C:D for value
$mergeRangeKey = "A{$rowNumber}:B{$rowNumber}";
// $mergeRangeValue = "C{$rowNumber}";
$sheet->mergeCells($mergeRangeKey);
// $sheet->mergeCells($mergeRangeValue);
// // Apply styles for alignment and bold text in A:B
// $sheet->getStyle($mergeRangeKey)->applyFromArray([
// 'font' => ['bold' => true],
// 'alignment' => [
// 'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
// 'vertical' => \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER,
// ],
// ]);
// Set values in merged cells
$sheet->setCellValue("A{$rowNumber}", $key);
$sheet->setCellValue("C{$rowNumber}", $value);
// Apply bold style to B column if the key is "Insured"
if ($key == "Insured") {
$sheet->getStyle("C{$rowNumber}")->applyFromArray([
'font' => ['bold' => true],
]);
// // Apply styles for alignment and bold text in A:B
// $sheet->getStyle($mergeRangeKey)->applyFromArray([
// 'font' => ['bold' => true],
// 'alignment' => [
// 'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
// 'vertical' => \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER,
// ],
// ]);
// Apply bold style to B column if the key is "Insured"
if ($key == "Insured") {
$sheet->getStyle("C{$rowNumber}")->applyFromArray([
'font' => ['bold' => true],
]);
}
// Track max width needed for columns
$maxWidthA = max($maxWidthA, mb_strlen($key));
$maxWidthB = max($maxWidthB, mb_strlen($value));
$rowNumber++;
}
// Track max width needed for columns
$maxWidthA = max($maxWidthA, mb_strlen($key));
$maxWidthB = max($maxWidthB, mb_strlen($value));
$rowNumber++;
}
// Set column width based on max content length (adjusted for padding)
@ -5431,31 +5447,32 @@ class LeadsController extends BaseController
$this->myLogger->logme('error', "QCR Sheet: copied from RFQ sheet | lead_id={$leadId}, rfq_sheet_id={$rfqSheetId}, new_sheet_id={$newSheetId}");
// Apply permissions: sales team as editors
$salesTeam = $this->userModel
->select('user_profiles.email')
->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();
$editorEmails = array_values(array_filter(array_unique(array_column($salesTeam, 'email'))));
// $salesTeam = $this->userModel
// ->select('user_profiles.email')
// ->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();
// $editorEmails = array_values(array_filter(array_unique(array_column($salesTeam, 'email'))));
// Decode rfq_qcr_viewers from lead and add as viewers
$viewerEmails = [];
$editorEmails = [];
if (! empty($lead['rfq_qcr_viewers'])) {
$decoded = json_decode($lead['rfq_qcr_viewers'], true);
if (is_array($decoded)) {
$viewerEmails = array_values(array_filter(array_unique($decoded)));
$editorEmails = array_values(array_filter(array_unique($decoded)));
}
}
if (! empty($editorEmails) || ! empty($viewerEmails)) {
// !dd($editorEmails);
if (! empty($editorEmails)) {
try {
$sheetLib->applyPermissions($newSheetId, [
'editors' => $editorEmails,
'viewers' => $viewerEmails,
// 'viewers' => $viewerEmails,
]);
$this->myLogger->logme('error', "QCR Sheet: permissions applied | sheet_id={$newSheetId}, editors=" . count($editorEmails) . ", viewers=" . count($viewerEmails));
$this->myLogger->logme('error', "QCR Sheet: permissions applied | sheet_id={$newSheetId}, editors=" . count($editorEmails));
} catch (\Throwable $e) {
$this->myLogger->logme('error', "QCR Sheet: failed to apply permissions | sheet_id={$newSheetId}, error=" . $e->getMessage());
}
@ -5672,30 +5689,30 @@ class LeadsController extends BaseController
$this->myLogger->logme('error', "Placement Sheet: copied from QCR | lead_id={$leadId}, qcr_sheet_id={$qcrSheetId}, placement_sheet_id={$placementSheetId}");
// Apply same permissions as QCR (editors: sales team, viewers: rfq_qcr_viewers)
$salesTeam = $this->userModel
->select('user_profiles.email')
->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();
$editorEmails = array_values(array_filter(array_unique(array_column($salesTeam, 'email'))));
// $salesTeam = $this->userModel
// ->select('user_profiles.email')
// ->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();
// $editorEmails = array_values(array_filter(array_unique(array_column($salesTeam, 'email'))));
$viewerEmails = [];
$editorEmails = [];
if (! empty($lead_data['rfq_qcr_viewers'])) {
$decoded = json_decode($lead_data['rfq_qcr_viewers'], true);
if (is_array($decoded)) {
$viewerEmails = array_values(array_filter(array_unique($decoded)));
$editorEmails = array_values(array_filter(array_unique($decoded)));
}
}
if (! empty($editorEmails) || ! empty($viewerEmails)) {
if (! empty($editorEmails) ) {
try {
$sheetLib->applyPermissions($placementSheetId, [
'editors' => $editorEmails,
'viewers' => $viewerEmails,
// 'viewers' => $viewerEmails,
]);
$this->myLogger->logme('error', "Placement Sheet: permissions applied | sheet_id={$placementSheetId}, editors=" . count($editorEmails) . ", viewers=" . count($viewerEmails));
$this->myLogger->logme('error', "Placement Sheet: permissions applied | sheet_id={$placementSheetId}, editors=" . count($editorEmails));
} catch (\Throwable $e) {
$this->myLogger->logme('error', "Placement Sheet: failed to apply permissions | sheet_id={$placementSheetId}, error=" . $e->getMessage());
}