FEAT_ADD_COMMON_PARAM_FOR_SEND_MAIL_FUNCTION : RV

This commit is contained in:
VENKATESHWARAN 2024-12-02 18:08:35 +05:30
parent fb4b24cc79
commit 4e450451f3
8 changed files with 401 additions and 277 deletions

View File

@ -24,6 +24,8 @@ $routes->get("testMailAttachments", "ClientController::testMailAttachments");
$routes->get("updatePolicyTermsKey", "ClientController::updatePolicyTermsKey");
$routes->get("updateRemainderDate", "ClientController::updateRemainderDate");
$routes->get("sendCroneRemainderMail", "DashboardController::sendCroneRemainderMail");
$routes->get("sendextraparam", "ClientController::sendextraparam");
// $routes->post("iAgreeForAddOn", "EmployeeRestController::iAgreeForAddOn");
$routes->post("add_advertise_image", "AppContentManagementController::add_advertise_image");
$routes->get("add_image_index", "AppContentManagementController::add_image_index");
@ -449,6 +451,7 @@ $routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) {
$routes->get("sendPushNotification", "EmployeeRestController::sendPushNotification");
$routes->post("sendEmail", "EmployeeRestController::send_email");
// $routes->post("employeeUpload", "EmployeeRestController::employeeUpload");
// Ticketing System

View File

@ -181,7 +181,7 @@ class ClientController extends AdminController
print_rr($attachments);
}
public function testingForReviewMail($client_id = 77, $emp_code = 'MGL-004', $mail_active = 0) //this function for only tsesting some logics not use for business logic
public function testingForReviewMail($client_id = 77, $emp_code = 'EMP001-K1', $mail_active = 0) //this function for only tsesting some logics not use for business logic
{
$client_policy_ids = $this->employeeModel
@ -209,6 +209,13 @@ class ClientController extends AdminController
if (!is_null($client_policy_id) && is_array($client_policy_id))
{
$empData = $this->employeeModel->where('emp_code', $emp_code )->where('client_id', $client_id ) ->where('is_active', 1 )->findAll();
$filteredEmpData = array_filter($empData, fn($item) => $item['relationship'] === 'Self');
// dd($filteredEmpData);
$array_list = [];
foreach ($client_policy_id as $key => $value)
{
@ -230,6 +237,14 @@ class ClientController extends AdminController
$params ['emp_code'] = $emp_code;
$params ['client_id'] = $client_id;
$params ['notification'] = $notification;
$params['common'] = [
'client_id' => $filteredEmpData[0]['client_id'],
'client_branch_id' => $filteredEmpData[0]['client_branch_id'],
'client_policy_id' => null,
'employee_policy_id' => null,
'employee_id' => $filteredEmpData[0]['id'],
'mail_type' => 'member_review_and_summary_mail',
];
// dd($params);
@ -243,6 +258,7 @@ class ClientController extends AdminController
if (isset($wholeData[0])) {
$params['common']['mail_type'] = 'account_maneger_summary_mail';
$account_manager_wholeData =sendMailNotification::sendMailNotification('account_maneger_summary_mail', $params);
// print_r($account_manager_wholeData); die;
@ -261,6 +277,7 @@ class ClientController extends AdminController
$this->myLogger->logme("error", 'Account Manager Mail Configuration not Enable for this client');
}
$params['common']['mail_type'] = 'client_hr_summary_mail';
$client_hr_wholeData =sendMailNotification::sendMailNotification('client_hr_summary_mail', $params);
// print_r($client_hr_wholeData); die;
@ -2942,15 +2959,15 @@ class ClientController extends AdminController
$multi_si = [];
if (isset($JSON->sum_insured) && !empty($JSON->sum_insured)) {
if (isset($JSON->sum_insured) && $JSON->sum_insured != "" && $JSON->sum_insured != null) {
$multi_si[] = $JSON->sum_insured;
} elseif (isset($JSON->sumInsured2) && !empty($JSON->sumInsured2)) {
} elseif (isset($JSON->sumInsured2) && $JSON->sumInsured2 != "" && $JSON->sumInsured2 != null) {
$multi_si[] = $JSON->sumInsured2;
}
if (isset($JSON->multiple_sum_insured) && is_array($JSON->multiple_sum_insured)) {
foreach ($JSON->multiple_sum_insured as $msi) {
if (!empty($msi)) {
if ($msi != "" && $msi != null) {
$multi_si[] = $msi;
}
}
@ -3688,5 +3705,20 @@ class ClientController extends AdminController
dd($days);
}
public function sendextraparam(){
$employeeRestController = new EmployeeServiceController();
$employeeRestController->employeesEnrollmentInsert(['file_id' => 683]);
// $dashBoardController = new DashboardController();
// $client_policy_data = $this->clientPolicyModel->getPolicyDetailsForRemainder($client_id=159, $client_branch_id=126);
// $dashBoardController->sendRemainderMail($client_policy_data);
// $EmpDataServiceController = new EmpDataServiceController();
// $emp_data = $this->employeePolicyModel->getEmployeePolicyForEcard(12);
// $ids = array_column($emp_data, 'id');
// $EmpDataServiceController->sendMailForDownloadingECard($ids);
}
}

View File

@ -384,7 +384,7 @@ class DashboardController extends AdminController
// Fetch all employees related to the client policy
$employees = $this->employeePolicyModel
->select('employees.*')
->select('employees.*, employee_polices.id as emp_policy_id')
->join('employees', 'employee_polices.employee_id = employees.id', 'left')
->where('employee_polices.client_policy_id', $client_policy['id'])
->where('employees.emp_status', 'draft')
@ -394,6 +394,8 @@ class DashboardController extends AdminController
->where('employees.relationship', 'Self')
->findAll();
// dd($employees);
// Process each employee
foreach ($employees as $employee) {
@ -404,6 +406,14 @@ class DashboardController extends AdminController
$params['emp_data'] = $employee;
$params['client_data'] = $client_data;
$params['notification_data'] = $notification_data;
$params['common'] = [
'client_id' => $client_policy['client_id'],
'client_branch_id' => $client_policy['client_branch_id'],
'client_policy_id' => $client_policy['id'],
'employee_policy_id' => $employee['emp_policy_id'],
'employee_id' => $employee['id'],
'mail_type' => 'member_reminder_mail',
];
// Send the mail notification
$mail_result = sendMailNotification::sendMailNotification('member_reminder_mail', $params);
@ -441,7 +451,7 @@ class DashboardController extends AdminController
// Fetch all employees related to the client policy
$employees = $this->employeePolicyModel
->select('employees.*')
->select('employees.*, employee_polices.id as emp_policy_id')
->join('employees', 'employee_polices.employee_id = employees.id', 'left')
->where('employee_polices.client_policy_id', $client_policy['id'])
->where('employees.emp_status', 'draft')
@ -461,6 +471,14 @@ class DashboardController extends AdminController
$params['emp_data'] = $employee;
$params['client_data'] = $client_data;
$params['notification_data'] = $notification_data;
$params['common'] = [
'client_id' => $client_policy['client_id'],
'client_branch_id' => $client_policy['client_branch_id'],
'client_policy_id' => $client_policy['id'],
'employee_policy_id' => $employee['emp_policy_id'],
'employee_id' => $employee['id'],
'mail_type' => 'member_reminder_mail',
];
// Send the mail notification
$mail_result = sendMailNotification::sendMailNotification('member_reminder_mail', $params);

View File

@ -4319,7 +4319,15 @@ class EmpDataServiceController extends BaseController
$temp_id = $ids[0];
$get_client_info = $this->employeePolicyModel
->select('employee_polices.client_policy_id, employees.emp_code, employees.email_corporate, employees.client_id, employees.name, employee_polices.rand_string, employee_polices.tpa_id')
->select('
employee_polices.client_policy_id,
employees.emp_code,
employees.email_corporate,
employees.client_id,
employees.name,
employee_polices.rand_string,
employee_polices.tpa_id'
)
->join('employees', 'employees.id = employee_polices.employee_id')
->where('employees.emp_status', 'active')
->where('employees.is_active', '1')
@ -4350,10 +4358,26 @@ class EmpDataServiceController extends BaseController
$count = 0;
$processedCount = 0;
$wholeData = [];
// $wholeMailData = [];
foreach ($ids as $id) {
$emp_details = $this->employeePolicyModel
->select('employee_polices.client_policy_id, employees.relationship, employees.emp_code, employees.email_corporate, employees.client_id, employees.name, employees.mobile, employee_polices.rand_string, employee_polices.tpa_id')
->select('
employees.id as emp_id,
employees.client_id,
employees.client_branch_id,
employees.relationship,
employees.emp_code,
employees.email_corporate,
employees.name,
employees.mobile,
employee_polices.id as emp_policy_id,
employee_polices.client_policy_id,
employee_polices.rand_string,
employee_polices.tpa_id
')
->join('employees', 'employees.id = employee_polices.employee_id')
->where('employees.emp_status', 'active')
->where('employees.is_active', '1')
@ -4373,7 +4397,18 @@ class EmpDataServiceController extends BaseController
'client_data' => $client_data,
'get_emp_email_and_other_details' => $emp_details,
];
$params['common'] = [
'client_id' => $emp_details['client_id'],
'client_branch_id' => $emp_details['client_branch_id'],
'client_policy_id' => $emp_details['client_policy_id'],
'employee_policy_id' => $emp_details['emp_policy_id'],
'employee_id' => $emp_details['emp_id'],
'mail_type' => 'member_ecard_mail',
];
$wholeData[] = sendMailNotification::sendMailNotification('member_ecard_mail', $params);
// $wholeMailData[] = sendMailNotification::sendMailNotification('member_ecard_mail', $params);
$count++;
}
$processedCount++;
@ -4396,6 +4431,8 @@ class EmpDataServiceController extends BaseController
}
}
}
// dd($wholeMailData);
$this->myLogger->logme('error', 'sendMailForDownloadingECard - Email processing completed');
return true;
@ -4406,7 +4443,6 @@ class EmpDataServiceController extends BaseController
}
}
public function readExcelFileToArray($path)
{
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($path);

View File

@ -693,9 +693,12 @@ class EmployeeRestController extends AdminController
$token = $jwtParts[2];
$decodedPayload = json_decode(base64_decode(explode('.', $token)[1]), true);
// get the employee id from token
$employee_id = $decodedPayload['id'];
// $employee_id = 1;
$client_policy = $this->clientPolicyModel->where('id', $policy_id)->where('client_id', $client_id)->where('client_branch_id', $client_branch_id)->first();
if ($client_policy) {
$policy = $this->policesModel->where('id', $client_policy['policy_id'])->first();
@ -940,14 +943,16 @@ class EmployeeRestController extends AdminController
];
$employee_policy = $this->employeePolicyModel->checkExistingEmpPolicy(['employee_id' => $emp_id,'client_policy_id' => $policy_id]);
// print_r($employee_policy); die;
if ($employee_policy) {
foreach ($employee_policy as $existing_policy) {
$emp_policy_data['id']= $existing_policy['id'];
$emp_policy_data['updated_at'] = $formatted_date_time;
$this->employeePolicyModel->save($emp_policy_data);
}
$emp_policy_id = $employee_policy[0]['id'];
} else {
$emp_policy = $this->employeePolicyModel->insert($emp_policy_data);
$emp_policy_id = $this->employeePolicyModel->insert($emp_policy_data);
}
if (isset($notification) && $notification['enabled'] == 1 && !empty($notification['mail_content'])) {
@ -959,6 +964,14 @@ class EmployeeRestController extends AdminController
$params['dataToInsert'] = $dataToInsert[$a];
$params['notification'] = $notification;
$params['client_data'] = $client_data;
$params['common'] = [
'client_id' => $client_id,
'client_branch_id' => $client_branch_id,
'client_policy_id' => $policy_id,
'employee_policy_id' => $emp_policy_id ?? null,
'employee_id' => $emp_id,
'mail_type' => 'member_welcome_mail',
];
$wholeData[] = sendMailNotification::sendMailNotification('member_welcome_mail', $params);
$count++;
@ -979,6 +992,8 @@ class EmployeeRestController extends AdminController
}
}
// print_r($wholeData); die;
// for bulk mail queue job push
if (!empty($wholeData) && count($wholeData) > 0) {
@ -1931,6 +1946,9 @@ class EmployeeRestController extends AdminController
$empData = $this->employeeModel->where('emp_code', $emp_code )->where('client_id', $client_id ) ->where('is_active', 1 )->findAll();
//for mail common parameter
$filteredEmpData = array_filter($empData, fn($item) => $item['relationship'] === 'Self');
if (!is_null($client_policy_id) && is_array($client_policy_id))
{
$array_list = [];
@ -1966,6 +1984,15 @@ class EmployeeRestController extends AdminController
$params ['emp_code'] = $emp_code;
$params ['client_id'] = $client_id;
$params ['notification'] = $notification;
$params['common'] = [
'client_id' => $filteredEmpData[0]['client_id'],
'client_branch_id' => $filteredEmpData[0]['client_branch_id'],
'client_policy_id' => null,
'employee_policy_id' => null,
'employee_id' => $filteredEmpData[0]['id'],
'mail_type' => 'member_review_and_summary_mail',
];
// print_r($params);die;
$wholeData =sendMailNotification::sendMailNotification('member_review_and_summary_mail', $params);
$mail_send_return = MailHelper::send_email($wholeData[0]);
@ -1973,6 +2000,7 @@ class EmployeeRestController extends AdminController
if (isset($wholeData[0])) {
$params['common']['mail_type'] = 'account_maneger_summary_mail';
$account_manager_wholeData =sendMailNotification::sendMailNotification('account_maneger_summary_mail', $params);
if($account_manager_wholeData != null && $account_manager_wholeData != '' && count($account_manager_wholeData))
@ -1985,6 +2013,7 @@ class EmployeeRestController extends AdminController
$this->myLogger->logme("error", 'Account Manager Mail Configuration not Enable for this client');
}
$params['common']['mail_type'] = 'client_hr_summary_mail';
$client_hr_wholeData =sendMailNotification::sendMailNotification('client_hr_summary_mail', $params);
if($client_hr_wholeData != null && $client_hr_wholeData != '' &&count($client_hr_wholeData))

View File

@ -1879,7 +1879,7 @@ class EmployeeServiceController extends AdminController
// ---------------------------------------------------------------------------------
public function getFileMetaDataByFileId($file_id, $status = 'success'){
public function getFileMetaDataByFileId($file_id, $status = 'success'){
$data = $this->fileModel
->select('files.*, clients.client_name, clients.short_name, policy_type.policy_type as policy_name,client_branch.branch_code')
@ -1932,273 +1932,270 @@ class EmployeeServiceController extends AdminController
public function employeesEnrollmentInsert($params)
{
helper('excel_util_helper');
//get file name
$file_id = $params['file_id'];
$file = $this->fileModel->find($file_id);
// dd($file);
$return = [];
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))
{
//file not found update status and reason
$message = "Physical file not found";
// echo $message;
$this->myLogger->logme('error',($message . ' for file id ' . $file_id));
$this->fileModel->where('id', $file_id)->set(['status' => 'failed','reason' => json_encode(['error_summary' => array_count_values([5]),'error_data' => $message])])->update();
return array('error_summary' => [5], 'error_data' => $message);
}
helper('excel_util_helper');
//get file name
$file_id = $params['file_id'];
$file = $this->fileModel->find($file_id);
// dd($file);
$return = [];
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'];
//get excel data
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($file_name_with_path);
$sheet = $spreadsheet->getActiveSheet();
$highestRowAndColumn = $sheet->getHighestRowAndColumn();
$result = ['error_type' => 2,'error_summary' => [], 'error_data' => [] ];
$columns_to_check = $this->enrollment_excel_columns;
$keys = array_keys($columns_to_check);
$allowedHighestColumn = end($columns_to_check);
$excel_data = $sheet->rangeToArray('A1:' . $allowedHighestColumn['col_cell_name'] . $highestRowAndColumn['row']);
// print_r($keys);die();
//get existing units in the current branch
$existing_units = $this->clientBranchModel->getExisitingUnits(client_id: $file['client_id'],client_branch_id: $file['client_branch_id']);
//remove header
unset($excel_data[0]);
// dd($excel_data);
$emp_emails = [];
//check physical file
if (!file_exists($file_name_with_path)) {
//file not found update status and reason
$message = "Physical file not found";
// echo $message;
$this->myLogger->logme('error', ($message . ' for file id ' . $file_id));
$this->fileModel->where('id', $file_id)->set(['status' => 'failed', 'reason' => json_encode(['error_summary' => array_count_values([5]), 'error_data' => $message])])->update();
return array('error_summary' => [5], 'error_data' => $message);
}
//check is welcome notification enabled
$notification = $this->notificationModel->where('client_id',$file['client_id'])->where('template_name','member_welcome_mail')->first();
// dd($notification);
$client_details = $this->clientModel->where('id', $file['client_id'])->first();
//get excel data
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($file_name_with_path);
$sheet = $spreadsheet->getActiveSheet();
$emp_emails = []; // Initialize an empty array to store employee email.
$highestRowAndColumn = $sheet->getHighestRowAndColumn();
$result = ['error_type' => 2, 'error_summary' => [], 'error_data' => []];
$columns_to_check = $this->enrollment_excel_columns;
$keys = array_keys($columns_to_check);
$allowedHighestColumn = end($columns_to_check);
$excel_data = $sheet->rangeToArray('A1:' . $allowedHighestColumn['col_cell_name'] . $highestRowAndColumn['row']);
// print_r($keys);die();
//get existing units in the current branch
$existing_units = $this->clientBranchModel->getExisitingUnits(client_id: $file['client_id'], client_branch_id: $file['client_branch_id']);
//remove header
unset($excel_data[0]);
// dd($excel_data);
$emp_emails = [];
foreach ($excel_data as $key => $row)
{
$is_row_empty = check_row_is_empty_or_null($row);
if(!$is_row_empty)
{
$value = [];
$policy_data = [];
$temp_unit = '';
if(empty($row[12]))
{
$temp_unit = $existing_units[0];
}
$value['emp_code'] = $row[1];
$value['name'] = $row[2];
$value['doj'] = (!empty($row[3]) ? convert_string_to_date($row[3],'Y-m-d'): null);
$value['gender'] = $row[4];
$value['relationship'] = ucfirst(trim($row[5]));
$value['dob'] = convert_string_to_date($row[6],'Y-m-d');
$value['email_corporate'] = $row[7];
$value['mobile'] = $row[8];
$value['band'] = $row[10];
$value['basic_pay'] = $row[11];
$value['unit'] = $temp_unit;
$value['family_floater_key'] = null;
$value['client_id'] = $file['client_id'];
$value['client_branch_id'] = $file['client_branch_id'];
$value['file_id'] = $file_id;
//check is welcome notification enabled
$notification = $this->notificationModel->where('client_id', $file['client_id'])->where('template_name', 'member_welcome_mail')->first();
// dd($notification);
$client_details = $this->clientModel->where('id', $file['client_id'])->first();
// dd($excel_data);
$emp_emails = []; // Initialize an empty array to store employee email.
foreach ($excel_data as $key => $row) {
$is_row_empty = check_row_is_empty_or_null($row);
if (!$is_row_empty) {
$value = [];
$policy_data = [];
$temp_unit = '';
if (empty($row[12])) {
$temp_unit = $existing_units[0];
}
$value['emp_code'] = $row[1];
$value['name'] = $row[2];
$value['doj'] = (!empty($row[3]) ? convert_string_to_date($row[3], 'Y-m-d') : null);
$value['gender'] = $row[4];
$value['relationship'] = ucfirst(trim($row[5]));
$value['dob'] = convert_string_to_date($row[6], 'Y-m-d');
$value['email_corporate'] = $row[7];
$value['mobile'] = $row[8];
$value['band'] = $row[10];
$value['basic_pay'] = $row[11];
$value['unit'] = $temp_unit;
$value['family_floater_key'] = null;
$value['client_id'] = $file['client_id'];
$value['client_branch_id'] = $file['client_branch_id'];
$value['file_id'] = $file_id;
$value['temp']['emp_id'] = null; // dummy value for using exisitng funciton in model
if (strtolower(trim($value['relationship'])) === 'mother' || strtolower(trim($value['relationship'])) === 'father') {
$relation = 'parent';
} else if(strtolower(trim($value['relationship'])) === 'son' || strtolower(trim($value['relationship'])) === 'daughter'){
$relation = 'child';
}else if(strtolower(trim($value['relationship'])) === 'father in law' || strtolower(trim($value['relationship'])) === 'mother in law'){
$relation = 'parent_in_law';
}else if(strtolower(trim($value['relationship'])) === 'spouse'){
$relation = 'spouse';
}else{
$relation = 'self';
}
$value['family_floater_key'] = $relation;
$relation = 'parent';
} else if (strtolower(trim($value['relationship'])) === 'son' || strtolower(trim($value['relationship'])) === 'daughter') {
$relation = 'child';
} else if (strtolower(trim($value['relationship'])) === 'father in law' || strtolower(trim($value['relationship'])) === 'mother in law') {
$relation = 'parent_in_law';
} else if (strtolower(trim($value['relationship'])) === 'spouse') {
$relation = 'spouse';
} else {
$relation = 'self';
}
$value['family_floater_key'] = $relation;
$policy_data['basic_cover_si'] = $row[9];
$policy_data['date_coverage'] = $row[13];
$policy_data['basic_cover_si'] = $row[9];
$policy_data['date_coverage'] = $row[13];
$policy_data['client_policy_id'] = $file['policy_id'];
$employee = $this->employeeModel->checkExistingEmployee($value, $file['client_branch_id']);
unset($value['temp']);
//save employee table
// dd($employee['id']);
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 {
$value['emp_status'] = 'draft';
$value['created_by'] = $file['created_by'];
$log_message = 'Enrollment Insert Employee- ' . $value['name'] . '(' . $value['emp_code'] . ') with PK ';
}
$this->employeeModel->save($value);
if (isset($value['id'])) {
$emp_id = $value['id'];
} else {
$emp_id = $this->employeeModel->getInsertID();
$log_message .= $emp_id;
}
// $emp_id = $this->employeeModel->getInsertID();
// if($emp_id != 0){ $log_message .= $emp_id; }
// else{ $emp_id = $employee['id']; }
$this->myLogger->logme('error', $log_message);
//save policy table
$employee_policy = $this->employeePolicyModel->checkExistingEmpPolicy(['employee_id' => $emp_id, 'client_policy_id' => $file['policy_id']]);
if (count($employee_policy)) {
$policy_data['updated_by'] = $file['created_by'];
$policy_data['id'] = $employee_policy[0]['id'];
$policy_data['status'] = 'draft';
$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 {
$policy_data['employee_id'] = $emp_id;
$policy_data['client_policy_id'] = $file['policy_id'];
$policy_data['created_by'] = $file['created_by'];
$policy_data['status'] = 'draft';
$log_message = 'Insert Employee Policy for ' . $value['name'] . '(' . $value['emp_code'] . ') - client policy id -' . $file['policy_id'] . ' - with SI ' . $policy_data['basic_cover_si'];
// echo 'update policy';
}
$this->employeePolicyModel->save($policy_data);
// $emp_policy_id = $this->employeePolicyModel->getInsertID();
$emp_policy_id = isset($policy_data['id']) ? $policy_data['id'] : $this->employeePolicyModel->getInsertID();
$this->myLogger->logme('error', $log_message);
//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'] != "") {
$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',
];
//store email and mail content via helper to send notification
$emp_emails[] = sendMailNotification::sendMailNotification('member_welcome_mail', $params);
// Kint::dump($emp_emails);
// Kint::dump($key.'-'.count($excel_data));
// if mail count is 20 send bulk mail and reset emp_emails variable
// if (count($emp_emails) == 20 || $key == count($excel_data) ) {
// $job_details = new Jobs();
// $r = Jobs::addJob(['job_name' => 'bulk_mail','payload' => $emp_emails]);
// // echo 'Mail triggered';
// $emp_emails = [];
// }
}
$value['family_floater_key'] = $relation;
$policy_data['basic_cover_si'] = $row[9];
$policy_data['date_coverage'] = $row[13];
$policy_data['client_policy_id'] = $file['policy_id'];
$employee = $this->employeeModel->checkExistingEmployee($value, $file['client_branch_id']);
unset($value['temp']);
//save employee table
// dd($employee['id']);
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 {
$value['emp_status'] = 'draft';
$value['created_by'] = $file['created_by'];
$log_message = 'Enrollment Insert Employee- ' . $value['name'] . '(' . $value['emp_code'] . ') with PK ';
}
$this->employeeModel->save($value);
if (isset($value['id'])) {
$emp_id = $value['id'];
} else {
$emp_id = $this->employeeModel->getInsertID();
$log_message .= $emp_id;
}
// $emp_id = $this->employeeModel->getInsertID();
// if($emp_id != 0){ $log_message .= $emp_id; }
// else{ $emp_id = $employee['id']; }
$this->myLogger->logme('error', $log_message);
//save policy table
$employee_policy = $this->employeePolicyModel->checkExistingEmpPolicy(['employee_id' => $emp_id, 'client_policy_id' => $file['policy_id']]);
if (count($employee_policy)) {
$policy_data['updated_by'] = $file['created_by'];
$policy_data['id'] = $employee_policy[0]['id'];
$policy_data['status'] = 'draft';
$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 {
$policy_data['employee_id'] = $emp_id;
$policy_data['client_policy_id'] = $file['policy_id'];
$policy_data['created_by'] = $file['created_by'];
$policy_data['status'] = 'draft';
$log_message = 'Insert Employee Policy for ' . $value['name'] . '(' . $value['emp_code'] . ') - client policy id -' . $file['policy_id'] . ' - with SI ' . $policy_data['basic_cover_si'];
// echo 'update policy';
}
$employee = $this->employeeModel->checkExistingEmployee($value,$file['client_branch_id']);
unset($value['temp']);
//save employee table
// dd($employee['id']);
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'];
$this->employeePolicyModel->save($policy_data);
$emp_policy_id = $this->employeePolicyModel->getInsertID();
$this->myLogger->logme('error', $log_message);
//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'] != "") {
$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',
];
//store email and mail content via helper to send notification
$emp_emails[] = sendMailNotification::sendMailNotification('member_welcome_mail', $params);
// Kint::dump($emp_emails);
// Kint::dump($key.'-'.count($excel_data));
// if mail count is 20 send bulk mail and reset emp_emails variable
// if (count($emp_emails) == 20 || $key == count($excel_data)) {
// $job_details = new Jobs();
// $r = Jobs::addJob(['job_name' => 'bulk_mail', 'payload' => $emp_emails]);
// // echo 'Mail triggered';
// $emp_emails = [];
// }
}
else
{
$value['emp_status'] = 'draft';
$value['created_by'] = $file['created_by'];
$log_message = 'Enrollment Insert Employee- '.$value['name'] .'('.$value['emp_code'] .') with PK ';
}
$this->employeeModel->save($value);
if (isset($value['id']))
{ $emp_id = $value['id']; }
else { $emp_id = $this->employeeModel->getInsertID();
$log_message .= $emp_id;
}
// $emp_id = $this->employeeModel->getInsertID();
// if($emp_id != 0){ $log_message .= $emp_id; }
// else{ $emp_id = $employee['id']; }
$this->myLogger->logme('error',$log_message);
//save policy table
$employee_policy = $this->employeePolicyModel->checkExistingEmpPolicy(['employee_id' => $emp_id,'client_policy_id' => $file['policy_id']]);
if(count($employee_policy))
{
$policy_data['updated_by'] = $file['created_by'];
$policy_data['id'] = $employee_policy[0]['id'];
$policy_data['status'] = 'draft';
$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
{
$policy_data['employee_id'] = $emp_id;
$policy_data['client_policy_id'] = $file['policy_id'];
$policy_data['created_by'] = $file['created_by'];
$policy_data['status'] = 'draft';
$log_message = 'Insert Employee Policy for '. $value['name'].'('. $value['emp_code'].') - client policy id -'. $file['policy_id'].' - with SI '.$policy_data['basic_cover_si'];
// echo 'update policy';
}
$this->employeePolicyModel->save($policy_data);
$emp_policy_id = $this->employeePolicyModel->getInsertID();
$this->myLogger->logme('error',$log_message);
//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'] != "")
{
$params['dataToInsert'] = $value; //holds employee master data
$params['notification'] = $notification;
$params['client_data'] = $client_details;
//store email and mail content via helper to send notification
$emp_emails[] = sendMailNotification::sendMailNotification('member_welcome_mail', $params);
// Kint::dump($emp_emails);
// Kint::dump($key.'-'.count($excel_data));
// if mail count is 20 send bulk mail and reset emp_emails variable
// if (count($emp_emails) == 20 || $key == count($excel_data) ) {
// $job_details = new Jobs();
// $r = Jobs::addJob(['job_name' => 'bulk_mail','payload' => $emp_emails]);
// // echo 'Mail triggered';
// $emp_emails = [];
// }
}
$value['family_floater_key'] = $relation;
$policy_data['basic_cover_si'] = $row[9];
$policy_data['date_coverage'] = $row[13];
$policy_data['client_policy_id'] = $file['policy_id'];
$employee = $this->employeeModel->checkExistingEmployee($value,$file['client_branch_id']);
unset($value['temp']);
//save employee table
// dd($employee['id']);
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
{
$value['emp_status'] = 'draft';
$value['created_by'] = $file['created_by'];
$log_message = 'Enrollment Insert Employee- '.$value['name'] .'('.$value['emp_code'] .') with PK ';
}
$this->employeeModel->save($value);
if (isset($value['id']))
{ $emp_id = $value['id']; }
else { $emp_id = $this->employeeModel->getInsertID();
$log_message .= $emp_id;
}
// $emp_id = $this->employeeModel->getInsertID();
// if($emp_id != 0){ $log_message .= $emp_id; }
// else{ $emp_id = $employee['id']; }
$this->myLogger->logme('error',$log_message);
//save policy table
$employee_policy = $this->employeePolicyModel->checkExistingEmpPolicy(['employee_id' => $emp_id,'client_policy_id' => $file['policy_id']]);
if(count($employee_policy))
{
$policy_data['updated_by'] = $file['created_by'];
$policy_data['id'] = $employee_policy[0]['id'];
$policy_data['status'] = 'draft';
$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
{
$policy_data['employee_id'] = $emp_id;
$policy_data['client_policy_id'] = $file['policy_id'];
$policy_data['created_by'] = $file['created_by'];
$policy_data['status'] = 'draft';
$log_message = 'Insert Employee Policy for '. $value['name'].'('. $value['emp_code'].') - client policy id -'. $file['policy_id'].' - with SI '.$policy_data['basic_cover_si'];
// echo 'update policy';
}
$this->employeePolicyModel->save($policy_data);
$emp_policy_id = $this->employeePolicyModel->getInsertID();
$this->myLogger->logme('error',$log_message);
//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'] != "")
{
$params['dataToInsert'] = $value; //holds employee master data
$params['notification'] = $notification;
$params['client_data'] = $client_details;
//store email and mail content via helper to send notification
$emp_emails[] = sendMailNotification::sendMailNotification('member_welcome_mail', $params);
// Kint::dump($emp_emails);
// Kint::dump($key.'-'.count($excel_data));
// if mail count is 20 send bulk mail and reset emp_emails variable
if (count($emp_emails) == 20 || $key == count($excel_data) ) {
$job_details = new Jobs();
$r = Jobs::addJob(['job_name' => 'bulk_mail','payload' => $emp_emails]);
// echo 'Mail triggered';
$emp_emails = [];
}
}
}
}// endof if row is empty check
}
} // endof if row is empty check
} //end of for loop
// dd($emp_emails);
// for bulk mail queue job push
if (!empty($emp_emails) && count($emp_emails) > 0) {
@ -2211,13 +2208,17 @@ public function employeesEnrollmentInsert($params)
}
}
$this->fileModel->where('id', $file_id)->set(['status' => 'success','reason' => ''])->update();
$this->myLogger->logme("error",'{file_id} uploaded success',['file_id' => $file_id]);
$this->fileModel->where('id', $file_id)->set(['status' => 'success', 'reason' => ''])->update();
$this->myLogger->logme("error", '{file_id} uploaded success', ['file_id' => $file_id]);
$this->setPullNotification($this->getFileMetaDataByFileId($file_id,'success'));
$this->setPullNotification($this->getFileMetaDataByFileId($file_id, 'success'));
return true;
}
}
}
}

View File

@ -23,6 +23,7 @@ class sendMailNotification
$dataToInsert = $params['dataToInsert'];
$notification = $params['notification'];
$client_data = $params['client_data'];
$common = $params['common'];
$mailAttachmentModel = new MailAttachmentModel();
$attachment_data = $mailAttachmentModel
@ -56,7 +57,7 @@ class sendMailNotification
$mail_content = str_replace("[[app_link]]", "<a href='$app_link'>Review Details</a>", $mail_content);
if ($dataToInsert['relationship'] == 'Self' && $mail != null || $mail != '') {
$wholeData = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content,'bcc'=> $client_data['common_mails'], 'reply_to' => $client_data['reply_to'], 'attachments' => $attachments];
$wholeData = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content,'bcc'=> $client_data['common_mails'], 'reply_to' => $client_data['reply_to'], 'attachments' => $attachments, 'common' => $common];
}
return $wholeData;
@ -67,6 +68,7 @@ class sendMailNotification
$emp_data = $params['emp_data'];
$notification_data = $params['notification_data'];
$client_data = $params['client_data'];
$common = $params['common'];
$subject = $notification_data['subject'];
$app_link = $_ENV['App_Url'];
@ -105,7 +107,7 @@ class sendMailNotification
}
if (isset($mail) && !empty($mail)) {
$wholeData[] = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails'], 'reply_to' => $client_data['reply_to']];
$wholeData[] = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails'], 'reply_to' => $client_data['reply_to'], 'common' => $common];
}
}else{
@ -135,7 +137,7 @@ class sendMailNotification
$mail = $value['email_corporate'];
}
if (isset($mail) && !empty($mail)) {
$wholeData[] = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails'], 'reply_to' => $client_data['reply_to']];
$wholeData[] = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails'], 'reply_to' => $client_data['reply_to'], 'common' => $common];
}
}
}
@ -157,6 +159,7 @@ class sendMailNotification
$rand_string = $params['rand_string'];
$client_data = $params['client_data'];
$tpa_id = $params['tpa_id'];
$common = $params['common'];
$mail_content = $notification['mail_content'];
@ -193,7 +196,7 @@ class sendMailNotification
// $mail_content = str_replace("[[tpa_id]]", $tpa_id, $mail_content);
$mail_content = str_replace("[[ecard_download_link]]", "<a href='$link/1'>Download Insurance Card</a>", $mail_content);
$mail_content = str_replace("[[client_name]]", $client_data['client_name'], $mail_content);
$wholeData = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content,'bcc'=> $client_data['common_mails'], 'reply_to' => $client_data['reply_to']];
$wholeData = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content,'bcc'=> $client_data['common_mails'], 'reply_to' => $client_data['reply_to'], 'common' => $common];
return $wholeData;
@ -203,6 +206,7 @@ class sendMailNotification
$client_policy_id = $params['client_policy_id'];
$emp_code = $params['emp_code'];
$client_id = $params['client_id'];
$common = $params['common'];
$clientModel = new ClientModel();
$notificationModel = new NotificationModel();
@ -247,7 +251,6 @@ class sendMailNotification
foreach ($array_list as $item) {
if (count($item) != 0) {
$table_content .= '<div style="text-align: left; font-size: 12px;"><div style="text-align:left;"><h4>Policy Type :';
@ -400,7 +403,7 @@ class sendMailNotification
// $mail = "aadhavanvalli@gmail.com";
// if (isset($mail) && !empty($mail)) {
$wholeData[] = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails'], 'reply_to' => $client_data['reply_to']];
$wholeData[] = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails'], 'reply_to' => $client_data['reply_to'], 'common' => $common];
// }
return $wholeData;
@ -411,6 +414,7 @@ class sendMailNotification
$client_id = $params['client_id'];
$client_policy_id = $params['client_policy_id'];
$common = $params['common'];
$clientModel = new ClientModel();
$notificationModel = new NotificationModel();
@ -606,7 +610,7 @@ class sendMailNotification
$full_name = $value['first_name'] .' ' .$value['last_name'];
$mail_content = str_replace("[[member_name]]", $full_name , $mail_content);
$wholeData[] = ['mail' => $value['email'], 'subject' => $subject,'message'=> $mail_content, 'reply_to' => $client_data['reply_to']];
$wholeData[] = ['mail' => $value['email'], 'subject' => $subject,'message'=> $mail_content, 'reply_to' => $client_data['reply_to'], 'common' => $common];
// $wholeData[] = ['mail' => $value['email'], 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails']];
}
return $wholeData;
@ -616,6 +620,7 @@ class sendMailNotification
$client_id = $params['client_id'];
$client_policy_id = $params['client_policy_id'];
$common = $params['common'];
$clientModel = new ClientModel();
$clientPolicyModel = new ClientPolicyModel();
@ -814,7 +819,7 @@ class sendMailNotification
$mail_array = array_map('trim', $mail_array);
$wholeData = [];
foreach ($mail_array as $key => $value) {
$wholeData[] = ['mail' => $value, 'subject' => $subject,'message'=> $mail_content, 'reply_to' => $client_data['reply_to']];
$wholeData[] = ['mail' => $value, 'subject' => $subject,'message'=> $mail_content, 'reply_to' => $client_data['reply_to'], 'common' => $common];
// $wholeData[] = ['mail' => $value, 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails']];
}

View File

@ -64,7 +64,7 @@ table.dataTable tbody td {
<?php foreach($status as $key => $value) { ?>
<option value="<?= $key ?>"
<?php
if ((!isset($getData) || count($getData['status']) > 0) && $key == 'active') {
if ((!isset($getData) || in_array('active', $getData['status'])) && $key == 'active') {
echo 'selected';
}
?>>