FIX_PARENT_POLICY_WELCOME_MAIL_ISSE__AND_OPEN_CLOSE_DATE_FORMAT_ISSUE

This commit is contained in:
VENKATESHWARAN 2025-12-24 12:29:13 +05:30
parent 3a129f036d
commit a5dd2e76d9
2 changed files with 234 additions and 210 deletions

View File

@ -4623,7 +4623,7 @@ class ClientController extends AdminController
// $res = $employeeRestController->getExcelErrorData(['file_id' => 897]);
// $employeeRestController->employeesOnboardPreprocess(['file_id' => 644]);
// $employeeRestController->employeesOnboardProcess(['file_id' => 835]);
// $res = $employeeRestController->employeesEnrollmentInsert(['file_id' => 1137]);
// $res = $employeeRestController->employeesEnrollmentInsert(['file_id' => 1138]);
// $r = Jobs::addJob(['job_name' => 'employeesEnrollmentInsert','payload' => ['file_id' => 721]]);
// dd($res);

View File

@ -1987,16 +1987,14 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){
$file = $this->fileModel->find($file_id);
// dd($file);
$return = [];
if(!isset($file))
{
if (!isset($file)) {
//file not found in DB
return array('status' => false, 'msg' => 'file not found in DB');
}
$file_name_with_path = WRITEPATH . "/uploads/excel/" . $file['file_name'];
//check physical file
if(!file_exists($file_name_with_path))
{
if (!file_exists($file_name_with_path)) {
//file not found update status and reason
$message = "Physical file not found";
// echo $message;
@ -2034,18 +2032,15 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){
//get policy slab rates
// $slab_details = $this->policiesModel->getPolicySlabRatesForEmpOnboard($file['policy_id'],$file['client_id']);
// dd($slab_details);
foreach ($excel_data as $key => $row)
{
$parent_policy_mail_sended_emp_code = [];
foreach ($excel_data as $key => $row) {
$is_row_empty = check_row_is_empty_or_null($row);
if(!$is_row_empty)
{
if (!$is_row_empty) {
$value = [];
$policy_data = [];
$temp_unit = '';
if(empty($row[12]))
{
if (empty($row[12])) {
$temp_unit = $existing_units[0];
}
@ -2093,16 +2088,13 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){
unset($value['temp']);
//save employee table
// dd($employee['id']);
if($employee !== null)
{
if ($employee !== null) {
$value['updated_by'] = $file['created_by'];
$value['id'] = $employee['id'];
$value['emp_status'] = 'draft';
$log_message = 'Enrollment Update Employee - ' . $employee['name'] . '(' . $employee['emp_code'] . ') with PK ' . $employee['id'];
}
else
{
} else {
$value['emp_status'] = 'draft';
$value['created_by'] = $file['created_by'];
$log_message = 'Enrollment Insert Employee- ' . $value['name'] . '(' . $value['emp_code'] . ') with PK ';
@ -2110,9 +2102,10 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){
$value = ExcelSanitizeHelper::sanitizeArrayData($value);
$this->employeeModel->save($value);
if (isset($value['id']))
{ $emp_id = $value['id']; }
else { $emp_id = $this->employeeModel->getInsertID();
if (isset($value['id'])) {
$emp_id = $value['id'];
} else {
$emp_id = $this->employeeModel->getInsertID();
$log_message .= $emp_id;
}
@ -2124,8 +2117,7 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){
//save policy table
$employee_policy = $this->employeePolicyModel->checkExistingEmpPolicy(['employee_id' => $emp_id, 'client_policy_id' => $file['policy_id']]);
if(count($employee_policy))
{
if (count($employee_policy)) {
$policy_data['updated_by'] = $file['created_by'];
$policy_data['id'] = $employee_policy[0]['id'];
$policy_data['status'] = 'draft';
@ -2133,9 +2125,7 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){
$policy_data['file_id'] = isset($employee_policy[0]['file_id']) && $employee_policy[0]['file_id'] != '' ? $employee_policy[0]['file_id'] : $file_id;
$log_message = 'Update Employee Policy for ' . $value['name'] . '(' . $value['emp_code'] . ') with PK- ' . $employee_policy[0]['id'] . ' client policy ID ' . $employee_policy[0]['client_policy_id'] . ' with SI ' . $policy_data['basic_cover_si'];
// echo 'insert policy';
}
else
{
} else {
$policy_data['employee_id'] = $emp_id;
$policy_data['client_policy_id'] = $file['policy_id'];
$policy_data['created_by'] = $file['created_by'];
@ -2157,10 +2147,8 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){
//save email of self for send mail later
if (isset($notification) && $notification['enabled'] == 1 && $notification['mail_content'] != '')
{
if(strtolower($value['relationship']) == 'self' && $value['email_corporate'] != "")
{
if (isset($notification) && $notification['enabled'] == 1 && $notification['mail_content'] != '') {
if (strtolower($value['relationship']) == 'self' && $value['email_corporate'] != "") {
$params['dataToInsert'] = $value; //holds employee master data
$params['notification'] = $notification;
$params['client_data'] = $client_details;
@ -2177,6 +2165,42 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){
//store email and mail content via helper to send notification
$emp_emails[] = sendMailNotification::sendMailNotification('member_welcome_mail', $params);
} else if ($policy_details['policy_type_id'] == 3 && $policy_details['is_addon'] == 3 && !in_array($row[1], $parent_policy_mail_sended_emp_code)) {
$sefData = $this->employeeModel
->where('is_active', 1)
->whereIn('emp_status', ['draft', 'enrolled'])
->where('family_floater_key', 'self')
->where('emp_code', $row[1])
->where('client_id', $file['client_id'])
->where('client_branch_id', $file['client_branch_id'])
->where('email_corporate is not null')
->first();
if (!empty($sefData)) {
$value['email_corporate'] = $sefData['email_corporate'];
$value['name'] = $sefData['name'];
$value['mobile'] = $sefData['mobile'];
$params['dataToInsert'] = $value; //holds employee master data
$params['notification'] = $notification;
$params['client_data'] = $client_details;
$params['common'] = [
'client_id' => $file['client_id'],
'client_branch_id' => $file['client_branch_id'],
'client_policy_id' => $file['policy_id'],
'employee_policy_id' => $emp_policy_id ?? null,
'employee_id' => $emp_id,
'mail_type' => 'member_welcome_mail',
];
$params['enrollment_open_date'] = $file['enrollment_open_date'] ?? null;
$params['enrollment_close_date'] = $file['enrollment_close_date'] ?? null;
//store email and mail content via helper to send notification
$emp_emails[] = sendMailNotification::sendMailNotification('member_welcome_mail', $params);
$parent_policy_mail_sended_emp_code[] = $row[1];
}
}
}
} // endof if row is empty check