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); $data = calculate_premium_new(family_data: $family, policy_terms: $policy_terms, slab_details: $slab_details, fileArr: $file, existing_units: $existing_units);
// dd($data); // dd($data);
$employee_data_group_by_family[$emp_id] = $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) { if ($res > 0) {
// $employee_insert_count++; $employee_insert_count++;
// } }
} }
// if ($employee_insert_count > 0) { if ($employee_insert_count > 0) {
// $this->fileModel->where('id', $file_id)->set(['status' => 'success', 'reason' => ''])->update(); $this->fileModel->where('id', $file_id)->set(['status' => 'success', 'reason' => ''])->update();
// $this->myLogger->logme("error", '{file_id} uploaded success', ['file_id' => $file_id]); $this->myLogger->logme("error", '{file_id} uploaded success', ['file_id' => $file_id]);
// } else { } else {
// $reason = json_encode([ $reason = json_encode([
// 'error_summary' => [5 => 1], 'error_summary' => [5 => 1],
// 'error_data' => "Rack rate configuration issue: Please check the slab rates configuration" 'error_data' => "Rack rate configuration issue: Please check the slab rates configuration"
// ], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); ], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
// $this->fileModel->where('id', $file_id)->set(['status' => 'failed', 'reason' => $reason])->update(); $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->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')); // $this->setPullNotification($this->getFileMetaDataByFileId($file_id, 'success'));
} else if (isset($params['client_policy_id'])) //handle data from enrollment to inception } 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); $data = $this->convertJsonForQCR($data, $type);
} // dd($data); } // dd($data);
$lead_data = [];
if ($rfq_data['lead_type'] == 1) { if ($rfq_data['lead_type'] == 1) {
if (in_array($rfq_data['policy_type_id'], [2, 3, 4, 5])) { 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'] ?? " - ", // 'TPA' => $rfq_data['tpa_name'] ?? " - ",
'Policy Type' => $this->leadType[$rfq_data['lead_type']] ?? "", '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 { } else {
@ -2277,6 +2284,11 @@ class LeadsController extends BaseController
// 'TPA' => $rfq_data['tpa_name'] ?? " - ", // 'TPA' => $rfq_data['tpa_name'] ?? " - ",
// 'Total Lives at Inception' => $rfq_data['total_lives_at_incept'], // '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; // print_r($lead_data); die;
@ -2312,6 +2324,9 @@ class LeadsController extends BaseController
$maxWidthA = 0; $maxWidthA = 0;
$maxWidthB = 0; $maxWidthB = 0;
// dd($lead_data);
if(! empty($lead_data)) {
foreach ($lead_data as $key => $value) { foreach ($lead_data as $key => $value) {
// Merge A:B for key and C:D for value // Merge A:B for key and C:D for value
@ -2346,6 +2361,7 @@ class LeadsController extends BaseController
$rowNumber++; $rowNumber++;
} }
}
// Set column width based on max content length (adjusted for padding) // Set column width based on max content length (adjusted for padding)
$sheet->getColumnDimension('A')->setWidth($maxWidthA * 1.2); $sheet->getColumnDimension('A')->setWidth($maxWidthA * 1.2);
@ -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}"); $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 // Apply permissions: sales team as editors
$salesTeam = $this->userModel // $salesTeam = $this->userModel
->select('user_profiles.email') // ->select('user_profiles.email')
->join('user_teams', 'user_profiles.id = user_teams.user_id') // ->join('user_teams', 'user_profiles.id = user_teams.user_id')
->where('user_teams.team_id', 5) // ->where('user_teams.team_id', 5)
->where('user_teams.is_active', 1) // ->where('user_teams.is_active', 1)
->where('user_profiles.is_active', 1) // ->where('user_profiles.is_active', 1)
->findAll(); // ->findAll();
$editorEmails = array_values(array_filter(array_unique(array_column($salesTeam, 'email')))); // $editorEmails = array_values(array_filter(array_unique(array_column($salesTeam, 'email'))));
// Decode rfq_qcr_viewers from lead and add as viewers // Decode rfq_qcr_viewers from lead and add as viewers
$viewerEmails = []; $editorEmails = [];
if (! empty($lead['rfq_qcr_viewers'])) { if (! empty($lead['rfq_qcr_viewers'])) {
$decoded = json_decode($lead['rfq_qcr_viewers'], true); $decoded = json_decode($lead['rfq_qcr_viewers'], true);
if (is_array($decoded)) { 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 { try {
$sheetLib->applyPermissions($newSheetId, [ $sheetLib->applyPermissions($newSheetId, [
'editors' => $editorEmails, '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) { } catch (\Throwable $e) {
$this->myLogger->logme('error', "QCR Sheet: failed to apply permissions | sheet_id={$newSheetId}, error=" . $e->getMessage()); $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}"); $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) // Apply same permissions as QCR (editors: sales team, viewers: rfq_qcr_viewers)
$salesTeam = $this->userModel // $salesTeam = $this->userModel
->select('user_profiles.email') // ->select('user_profiles.email')
->join('user_teams', 'user_profiles.id = user_teams.user_id') // ->join('user_teams', 'user_profiles.id = user_teams.user_id')
->where('user_teams.team_id', 5) // ->where('user_teams.team_id', 5)
->where('user_teams.is_active', 1) // ->where('user_teams.is_active', 1)
->where('user_profiles.is_active', 1) // ->where('user_profiles.is_active', 1)
->findAll(); // ->findAll();
$editorEmails = array_values(array_filter(array_unique(array_column($salesTeam, 'email')))); // $editorEmails = array_values(array_filter(array_unique(array_column($salesTeam, 'email'))));
$viewerEmails = []; $editorEmails = [];
if (! empty($lead_data['rfq_qcr_viewers'])) { if (! empty($lead_data['rfq_qcr_viewers'])) {
$decoded = json_decode($lead_data['rfq_qcr_viewers'], true); $decoded = json_decode($lead_data['rfq_qcr_viewers'], true);
if (is_array($decoded)) { 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 { try {
$sheetLib->applyPermissions($placementSheetId, [ $sheetLib->applyPermissions($placementSheetId, [
'editors' => $editorEmails, '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) { } catch (\Throwable $e) {
$this->myLogger->logme('error', "Placement Sheet: failed to apply permissions | sheet_id={$placementSheetId}, error=" . $e->getMessage()); $this->myLogger->logme('error', "Placement Sheet: failed to apply permissions | sheet_id={$placementSheetId}, error=" . $e->getMessage());
} }