CHANGE_NOTIFICATION_MAIL_ALLOW_NULL_ISSUE : AADHAVAN

This commit is contained in:
aadhavan valli 2024-05-16 12:25:33 +05:30
parent d0f6db8884
commit 5d20b696e9
4 changed files with 54 additions and 29 deletions

View File

@ -2063,10 +2063,12 @@ class EmpDataServiceController extends BaseController
$this->myLogger->logme('error', 'sendMailForDownloadingECard - inside try'); $this->myLogger->logme('error', 'sendMailForDownloadingECard - inside try');
$count = 0; $count = 0;
$counts = 0;
foreach ($ids as $key => $id) { foreach ($ids as $key => $id) {
$get_emp_email_and_other_details = $this->employeePolicyModel $get_emp_email_and_other_details = $this->employeePolicyModel
->select('employee_polices.client_policy_id, employees.emp_code, employees.email_corporate,employees.client_id as client_id, employees.name, employee_polices.rand_string, employee_polices.tpa_id') ->select('employee_polices.client_policy_id, employees.relationship, employees.emp_code, employees.email_corporate,employees.client_id as client_id, employees.name, employee_polices.rand_string, employee_polices.tpa_id')
->join('employees', 'employees.id = employee_polices.employee_id') ->join('employees', 'employees.id = employee_polices.employee_id')
->where('employees.emp_status', 'active') ->where('employees.emp_status', 'active')
->where('employees.is_active', '1') ->where('employees.is_active', '1')
@ -2091,12 +2093,18 @@ class EmpDataServiceController extends BaseController
$params['notification'] = $notification; $params['notification'] = $notification;
$params['notification'] = $notification; $params['notification'] = $notification;
$params['get_emp_email_and_other_details'] = $get_emp_email_and_other_details; $params['get_emp_email_and_other_details'] = $get_emp_email_and_other_details;
// $this->myLogger->logme('error', 'sendMailForDownloadingECard - Send Bulk Mail function end ',);
if (isset($get_emp_email_and_other_details['email_corporate']) && !empty($get_emp_email_and_other_details['email_corporate']) && $get_emp_email_and_other_details['relationship'] === 'Self') {
$wholeData[] = sendMailNotification::sendMailNotification('member_ecard_mail', $params); $wholeData[] = sendMailNotification::sendMailNotification('member_ecard_mail', $params);
$count++; $count++;
}
$counts++;
if ($count == 20 || $count == count($ids) - 1) { if ($count == 20 || $counts == count($ids) - 1) {
if(count($wholeData) > 0){
$this->myLogger->logme('error', 'sendMailForDownloadingECard - create a job to bulk mail',); $this->myLogger->logme('error', 'sendMailForDownloadingECard - create a job to bulk mail',);
@ -2104,6 +2112,9 @@ class EmpDataServiceController extends BaseController
$r = Jobs::addJob(['job_name' => 'bulk_mail', 'payload' => $wholeData]); $r = Jobs::addJob(['job_name' => 'bulk_mail', 'payload' => $wholeData]);
$wholeData = []; $wholeData = [];
$count = 0; $count = 0;
}
} }
$this->myLogger->logme('error', 'sendMailForDownloadingECard - Send Bulk Mail function end ',); $this->myLogger->logme('error', 'sendMailForDownloadingECard - Send Bulk Mail function end ',);

View File

@ -877,7 +877,7 @@ class EmployeeRestController extends AdminController
if (isset($notification) && $notification['enabled'] == 1) { if (isset($notification) && $notification['enabled'] == 1) {
//trigger //trigger
if ($dataToInsert[$a]['relationship'] == 'Self') { if ($dataToInsert[$a]['relationship'] == 'Self' && isset($dataToInsert[$a]['email_corporate']) && !empty($dataToInsert[$a]['email_corporate'])) {
$params['dataToInsert'] = $dataToInsert[$a]; $params['dataToInsert'] = $dataToInsert[$a];
$params['notification'] = $notification; $params['notification'] = $notification;
@ -887,14 +887,13 @@ class EmployeeRestController extends AdminController
$count++; $count++;
} }
if($count == 20 || $a == count($dataToInsert)-1){ if($count == 20 || $a == count($dataToInsert)-1){
if (count($wholeData) > 0) {
$job_details = new Jobs(); $job_details = new Jobs();
$r = Jobs::addJob(['job_name' => 'bulk_mail','payload' => $wholeData]); $r = Jobs::addJob(['job_name' => 'bulk_mail','payload' => $wholeData]);
// $wholeData[]= $r;
// Mailhelper::bulk_mail($wholeData);
$wholeData = []; $wholeData = [];
$count = 0; $count = 0;
} }
}
// if ($dataToInsert[$a]['email_corporate'] != null || $dataToInsert[$a]['email_corporate'] != '' && $dataToInsert[$a]['relationship'] == 'Self') { // if ($dataToInsert[$a]['email_corporate'] != null || $dataToInsert[$a]['email_corporate'] != '' && $dataToInsert[$a]['relationship'] == 'Self') {

View File

@ -147,12 +147,15 @@ class NotificationController extends AdminController
$count++; $count++;
$temp_whole_data[] = $value; $temp_whole_data[] = $value;
if($count == 20 || $whole_index == count($wholeData)-1 && $index == count($values)-1){ if($count == 20 || $whole_index == count($wholeData)-1 && $index == count($values)-1){
if (count($temp_whole_data) > 0) {
$job_details = new Jobs(); $job_details = new Jobs();
$r = Jobs::addJob(['job_name' => 'bulk_mail','payload' => $temp_whole_data]); $r = Jobs::addJob(['job_name' => 'bulk_mail','payload' => $temp_whole_data]);
$temp_whole_data = []; $temp_whole_data = [];
$count = 0; $count = 0;
} }
}
} }
} }
} }

View File

@ -58,21 +58,32 @@ class sendMailNotification
$emp_data = $EmployeeModel->where('client_id', $client_data['id'])->where('emp_code', $value['emp_code'])->where('is_active',1)->findAll(); $emp_data = $EmployeeModel->where('client_id', $client_data['id'])->where('emp_code', $value['emp_code'])->where('is_active',1)->findAll();
foreach ($emp_data as $key => $value) { if(count($emp_data) > 1){
$mail ='';
foreach ($emp_data as $key => $values) {
if ($value['relationship'] == 'Self') { if ($value['relationship'] == 'Self') {
$employee_name =$value['name']; $employee_name =$values['name'];
$mail_content = str_replace("[[member_name]]", $employee_name, $mail_content); $mail_content = str_replace("[[member_name]]", $employee_name, $mail_content);
$mail = $value['email_corporate']; $mail = $values['email_corporate'];
} }
} }
}else{
$mail ='';
}
}else{ }else{
$employee_name =$value['name']; $employee_name =$value['name'];
$mail_content = str_replace("[[member_name]]", $employee_name, $mail_content); $mail_content = str_replace("[[member_name]]", $employee_name, $mail_content);
$mail = $value['email_corporate']; $mail = $value['email_corporate'];
} }
if (isset($mail) && !empty($mail)) {
$wholeData[] = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails']]; $wholeData[] = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails']];
} }
}
if (count($wholeData) < 1) {
$wholeData = [];
}
return $wholeData; return $wholeData;
}else{ }else{
return "false"; return "false";
@ -194,8 +205,9 @@ class sendMailNotification
$mail_content = str_replace("[[member_summary]]", $table_content , $mail_content); $mail_content = str_replace("[[member_summary]]", $table_content , $mail_content);
// $mail = "aadhavanvalli@gmail.com"; // $mail = "aadhavanvalli@gmail.com";
// if (isset($mail) && !empty($mail)) {
$wholeData[] = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails']]; $wholeData[] = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails']];
// }
return $wholeData; return $wholeData;