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

This commit is contained in:
vadivelJ96 2025-10-28 16:24:22 +05:30
commit 8b6549117b
5 changed files with 145 additions and 28 deletions

View File

@ -1461,6 +1461,13 @@ class EmployeeMultiEventServiceController extends BaseController
$enrollment_keys = array_keys($enrollment_columns_to_check);
}
// for this condition to avoid 5,00,000 to 500000
if($current_column_action == 'SI'){
$row[3] = removeNumberFormatting($row[3]);
}else if(in_array($current_column_action, ['I','DA', 'MI', 'A'])){
$row[6] = removeNumberFormatting($row[6]);
}
//iterate each row for columns validations
foreach ($row as $col_key => $col) {
$is_mandatory = $columns_to_check[$keys[$col_key]]['is_mandatory'];
@ -1599,6 +1606,16 @@ class EmployeeMultiEventServiceController extends BaseController
$columns_to_check = $this->inception_excel_columns;
}
$current_column_action = null;
if($file['action'] == 'inception'){ $current_column_action = 'I'; }
else if($file['action'] == 'addition'){ $current_column_action = 'A'; }
else if($file['action'] == 'dependent_addition'){ $current_column_action = 'DA'; }
else if($file['action'] == 'deletion'){ $current_column_action = 'D'; }
else if($file['action'] == 'correction'){ $current_column_action = 'C'; }
else if($file['action'] == 'si_enhancement'){ $current_column_action = 'SI'; }
else if($file['action'] == 'enrollment'){ $current_column_action = 'I'; }
else if($file['action'] == 'missed_inception'){ $current_column_action = 'MI'; }
$columns_to_check = $this->syncColIndex($this->multievent_excel_columns, $columns_to_check);
// print_rr($columns_to_check);
@ -1626,7 +1643,7 @@ class EmployeeMultiEventServiceController extends BaseController
if (in_array($file['action'], ['inception', 'missed_inception', 'addition', 'dependent_addition', 'deletion', 'correction', 'si_enhancement', 'enrollment'])) // the below funcitons are only for I,DA,A
{
$employee_data_group_by_family = data_group_by_family($excel_data, 'excel', ($file['action'] == 'enrollment' ? 'enrollment' : ''));
$employee_data_group_by_family = data_group_by_family($excel_data, 'excel', ($file['action'] == 'enrollment' ? 'enrollment' : ''), $current_column_action);
// dd($employee_data_group_by_family);
$is_self_available_in_policy_terms = false;
if ($policy_details['policy_type_id'] == 3) // GMC parents
@ -1798,6 +1815,16 @@ class EmployeeMultiEventServiceController extends BaseController
$columns_to_check = $this->inception_excel_columns;
}
$current_column_action = null;
if($file['action'] == 'inception'){ $current_column_action = 'I'; }
else if($file['action'] == 'addition'){ $current_column_action = 'A'; }
else if($file['action'] == 'dependent_addition'){ $current_column_action = 'DA'; }
else if($file['action'] == 'deletion'){ $current_column_action = 'D'; }
else if($file['action'] == 'correction'){ $current_column_action = 'C'; }
else if($file['action'] == 'si_enhancement'){ $current_column_action = 'SI'; }
else if($file['action'] == 'enrollment'){ $current_column_action = 'I'; }
else if($file['action'] == 'missed_inception'){ $current_column_action = 'MI'; }
// get policy and rack details
$policy_terms = $this->clientPolicyModel->getPolicyDetails($file['client_id'], $file['policy_id']);
$policy_terms = (array) $policy_terms[0]; // convert obj to array
@ -1821,7 +1848,7 @@ class EmployeeMultiEventServiceController extends BaseController
//get existing units in the current branch
$existing_units = $this->clientBranchModel->getExisitingUnits(client_id: $file['client_id'], client_branch_id: $file['client_branch_id']);
$employee_data_group_by_family = data_group_by_family($excel_data);
$employee_data_group_by_family = data_group_by_family($excel_data, 'excel', '', $current_column_action);
// dd($employee_data_group_by_family);
foreach ($employee_data_group_by_family as $emp_id => $family) {
@ -2133,6 +2160,9 @@ class EmployeeMultiEventServiceController extends BaseController
if (check_row_is_empty_or_null($row)) {
break;
}
$row[3] = removeNumberFormatting($row[3]);
// echo '<br>START- ' . $row[2];
$employee = $this->employeeModel
->where('emp_code', $row[1])

View File

@ -910,6 +910,13 @@ class EmployeeServiceController extends AdminController
$enrollment_columns_to_check = $this->enrollment_excel_columns;
$enrollment_keys = array_keys($enrollment_columns_to_check);
}
// for this condition to avoid 5,00,000 to 500000
if($current_column_action == 'SI'){
$row[3] = removeNumberFormatting($row[3]);
}else if(in_array($current_column_action, ['I','DA', 'MI', 'A'])){
$row[6] = removeNumberFormatting($row[6]);
}
//iterate each row for columns validations
foreach ($row as $col_key => $col)
@ -1086,6 +1093,16 @@ class EmployeeServiceController extends AdminController
if($file['action'] == 'enrollment'){ $columns_to_check = $this->enrollment_excel_columns; }
if($file['action'] == 'missed_inception'){ $columns_to_check = $this->inception_excel_columns; }
$current_column_action = null;
if($file['action'] == 'inception'){ $current_column_action = 'I'; }
else if($file['action'] == 'addition'){ $current_column_action = 'A'; }
else if($file['action'] == 'dependent_addition'){ $current_column_action = 'DA'; }
else if($file['action'] == 'deletion'){ $current_column_action = 'D'; }
else if($file['action'] == 'correction'){ $current_column_action = 'C'; }
else if($file['action'] == 'si_enhancement'){ $current_column_action = 'SI'; }
else if($file['action'] == 'enrollment'){ $current_column_action = 'I'; }
else if($file['action'] == 'missed_inception'){ $current_column_action = 'MI'; }
// get policy and rack details
$policy_terms = $this->clientPolicyModel->getPolicyDetails($file['client_id'],$file['policy_id']);
$policy_details = (array)$policy_terms[0];
@ -1116,7 +1133,7 @@ class EmployeeServiceController extends AdminController
if(in_array($file['action'],['inception','missed_inception','addition','dependent_addition','deletion','correction','si_enhancement','enrollment']))// the below funcitons are only for I,DA,A
{
$employee_data_group_by_family = data_group_by_family($excel_data,'excel',($file['action'] == 'enrollment' ? 'enrollment' : ''));
$employee_data_group_by_family = data_group_by_family($excel_data,'excel',($file['action'] == 'enrollment' ? 'enrollment' : ''), $current_column_action);
// dd($employee_data_group_by_family);
$is_self_available_in_policy_terms = false;
if($policy_details['policy_type_id'] == 3) // GMC parents
@ -1321,6 +1338,16 @@ class EmployeeServiceController extends AdminController
if($file['action'] == 'si_enhancement'){ $columns_to_check = $this->si_enhance_excel_columns; }
if($file['action'] == 'missed_inception'){ $columns_to_check = $this->inception_excel_columns; }
$current_column_action = null;
if($file['action'] == 'inception'){ $current_column_action = 'I'; }
else if($file['action'] == 'addition'){ $current_column_action = 'A'; }
else if($file['action'] == 'dependent_addition'){ $current_column_action = 'DA'; }
else if($file['action'] == 'deletion'){ $current_column_action = 'D'; }
else if($file['action'] == 'correction'){ $current_column_action = 'C'; }
else if($file['action'] == 'si_enhancement'){ $current_column_action = 'SI'; }
else if($file['action'] == 'enrollment'){ $current_column_action = 'I'; }
else if($file['action'] == 'missed_inception'){ $current_column_action = 'MI'; }
// get policy and rack details
$policy_terms = $this->clientPolicyModel->getPolicyDetails($file['client_id'],$file['policy_id']);
$policy_terms = (array) $policy_terms[0];// convert obj to array
@ -1344,7 +1371,7 @@ class EmployeeServiceController extends AdminController
//get existing units in the current branch
$existing_units = $this->clientBranchModel->getExisitingUnits(client_id: $file['client_id'],client_branch_id: $file['client_branch_id']);
$employee_data_group_by_family = data_group_by_family($excel_data);
$employee_data_group_by_family = data_group_by_family($excel_data, 'excel', '', $current_column_action);
// dd($employee_data_group_by_family);
foreach ($employee_data_group_by_family as $emp_id => $family)
{
@ -1681,6 +1708,9 @@ class EmployeeServiceController extends AdminController
{
break;
}
$row[3] = removeNumberFormatting($row[3]);
// echo '<br>START- ' . $row[2];
$employee = $this->employeeModel
->where('emp_code', $row[1])

View File

@ -665,7 +665,10 @@ class LeadsController extends BaseController
if ($value['lead_form_type'] == 1) {
//for this push the job to the calculateMembersDemography() function
$job_details = new Jobs();
$r = Jobs::addJob(['job_name' => 'memberDataListExcelFileFormatValidation', 'payload' => [
// $r = Jobs::addJob(['job_name' => 'memberDataListExcelFileFormatValidation', 'payload' => [
// 'lead_id' => $insert,
// ]]);
$r = Jobs::addJob(['job_name' => 'calculateMembersDemography', 'payload' => [
'lead_id' => $insert,
]]);
}
@ -773,7 +776,7 @@ class LeadsController extends BaseController
$multi_file_data = [];
foreach ($files as $index => $value) {
$file_name = file_Upload($value, $uploadFilePath);
$file_name = file_Upload_for_lead($value, $uploadFilePath);
$multi_file_data[] = [
'file_name' => $file_name,
'docs_name' => $docs_names[$index],
@ -809,7 +812,10 @@ class LeadsController extends BaseController
if (!empty($lead_form_type) && $lead_form_type == 1 && $key == 0) {
//for this push the job to the calculateMembersDemography() function
$job_details = new Jobs();
$r = Jobs::addJob(['job_name' => 'memberDataListExcelFileFormatValidation', 'payload' => [
// $r = Jobs::addJob(['job_name' => 'memberDataListExcelFileFormatValidation', 'payload' => [
// 'lead_id' => $lead_id,
// ]]);
$r = Jobs::addJob(['job_name' => 'calculateMembersDemography', 'payload' => [
'lead_id' => $lead_id,
]]);
log_message('info', "calculateMembersDemography JOB PUSHED");
@ -1083,6 +1089,7 @@ class LeadsController extends BaseController
// 7. Define mail templates as constants or config
$mail_content = $this->getMailTemplate();
$placement_mail_content = $this->getMailTemplate('placement');
$subject = $this->getSubjectTemplate($lead_data);
// 8. Pre-calculate sum assured only for GPA
@ -1091,7 +1098,7 @@ class LeadsController extends BaseController
// 9. Transform mail content once
$data['mail_content'] = $this->transformMailContent($lead_data, $mail_content, $data['page_name']);
$data['subject'] = $this->transformMailContent($lead_data, $subject, $data['page_name']);
$data['placement_mail_content'] = $this->transformMailContent($lead_data, $mail_content, 'Placement');
$data['placement_mail_content'] = $this->transformMailContent($lead_data, $placement_mail_content, 'Placement');
$data['placement_subject'] = $this->transformMailContent($lead_data, $subject, 'Placement');
// 10. Combine related queries
@ -1144,24 +1151,43 @@ class LeadsController extends BaseController
}
// 13. Extract mail template to separate method for reusability
private function getMailTemplate()
{
return '
<p>Dear Sir,</p>
<p>Greetings From Nhance India!</p>
<p>Please find attached the {{RFQ_OR_QCR}} for <strong>{{POLICY_TYPE}}</strong> policy pertaining to <strong>{{CLIENT_NAME}}</strong>.</p>
<p>Kindly request you to share the competitive quotes at the earliest.</p>
<p>In case of any query, please feel free to contact us.</p>
<p>Thank You!</p><br>
<p>Best regards,</p>
private function getMailTemplate( $template_type = "" )
{
if($template_type == 'placement'){
return '
<p>Dear Sir,</p>
<p>Greetings From Nhance India!</p>
<p>Please find attached the {{RFQ_OR_QCR}} for <strong>{{POLICY_TYPE}}</strong> policy pertaining to <strong>{{CLIENT_NAME}}</strong>.</p>
<p>Kindly request you to issue the policy at the earliest.</p>
<p>In case of any query, please feel free to contact us.</p>
<p>Thank You!</p><br>
<p>Best regards,</p>
<div style="margin: 0; padding: 0; line-height: 1.2;">
<div>{{LOGGED_USER_NAME}}</div>
<div>Mobile: {{LOGGED_USER_MOBILE}}</div>
</div>
<div style="margin: 0; padding: 0; line-height: 1.2;">
<div>{{LOGGED_USER_NAME}}</div>
<div>Mobile: {{LOGGED_USER_MOBILE}}</div>
</div>
<img src="{{LOGO_PATH}}" alt="Nhance Logo" width="100" style="margin-top:10px;">
';
<img src="{{LOGO_PATH}}" alt="Nhance Logo" width="100" style="margin-top:10px;">
';
}else{
return '
<p>Dear Sir,</p>
<p>Greetings From Nhance India!</p>
<p>Please find attached the {{RFQ_OR_QCR}} for <strong>{{POLICY_TYPE}}</strong> policy pertaining to <strong>{{CLIENT_NAME}}</strong>.</p>
<p>Kindly request you to share the competitive quotes at the earliest.</p>
<p>In case of any query, please feel free to contact us.</p>
<p>Thank You!</p><br>
<p>Best regards,</p>
<div style="margin: 0; padding: 0; line-height: 1.2;">
<div>{{LOGGED_USER_NAME}}</div>
<div>Mobile: {{LOGGED_USER_MOBILE}}</div>
</div>
<img src="{{LOGO_PATH}}" alt="Nhance Logo" width="100" style="margin-top:10px;">
';
}
}
// 14. Extract subject template to separate method
@ -5268,10 +5294,10 @@ class LeadsController extends BaseController
'filePath' => $fullPath
];
} else {
log_message('warning', 'File name is empty for ID: ' . $id);
log_message('error', 'File name is empty for ID: ' . $id);
}
} else {
log_message('warning', 'File does not exist at path: ' . $fullPath);
log_message('error', 'File does not exist at path: ' . $fullPath);
}
} else {
log_message('warning', 'No active lead file found for ID: ' . $id . ' and lead_id: ' . $lead_id);

View File

@ -370,13 +370,24 @@ if (!function_exists('check_dob_diff')) {
}
if (!function_exists('data_group_by_family')) {
function data_group_by_family($emp_data, $data_source = 'excel', $action = '')
function data_group_by_family($emp_data, $data_source = 'excel', $action = '', $current_column_action = null)
{
$result = [];
// Kint::dump($emp_data);
foreach ($emp_data as $rkey => $row) {
if ($data_source == 'excel') {
if (!check_row_is_empty_or_null($row)) {
// for this condition to avoid 5,00,000 to 500000
if($current_column_action == 'SI'){
$row[3] = removeNumberFormatting($row[3]);
}else if(in_array($current_column_action, ['I','DA', 'MI', 'A'])){
$row[6] = removeNumberFormatting($row[6]);
}
if ($action == 'enrollment') //if action is enrollment transform current row into inception row, becoz we treat enrollment as inception
{
$row = transform_enrollment_row_to_inception_row($row);

View File

@ -65,6 +65,19 @@ if (!function_exists('file_Upload')) {
}
}
if (!function_exists('file_Upload_for_lead')) {
function file_Upload_for_lead($fileToUpload, $filepath)
{
if ($fileToUpload !== null && $fileToUpload->isValid() && !$fileToUpload->hasMoved()) {
$fileToUpload->move($filepath);
$fileName = $fileToUpload->getName();
return $fileName;
} else {
return "";
}
}
}
// if (!function_exists('multi_file_Upload')) {
// function multi_file_Upload($fileToUpload, $filepath)
// {
@ -866,3 +879,10 @@ if (!function_exists('getFileIfExists')) {
return file_exists(FCPATH . $path) ? base_url($path) : '';
}
}
if (!function_exists('removeNumberFormatting')) {
function removeNumberFormatting($number)
{
return (float) str_replace(',', '', trim($number));
}
}