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');
$count = 0;
$counts = 0;
foreach ($ids as $key => $id) {
$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')
->where('employees.emp_status', 'active')
->where('employees.is_active', '1')
@ -2091,19 +2093,28 @@ class EmpDataServiceController extends BaseController
$params['notification'] = $notification;
$params['notification'] = $notification;
$params['get_emp_email_and_other_details'] = $get_emp_email_and_other_details;
$wholeData[] = sendMailNotification::sendMailNotification('member_ecard_mail', $params);
// $this->myLogger->logme('error', 'sendMailForDownloadingECard - Send Bulk Mail function end ',);
$count++;
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);
$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',);
$job_details = new Jobs();
$r = Jobs::addJob(['job_name' => 'bulk_mail', 'payload' => $wholeData]);
$wholeData = [];
$count = 0;
}
$job_details = new Jobs();
$r = Jobs::addJob(['job_name' => 'bulk_mail', 'payload' => $wholeData]);
$wholeData = [];
$count = 0;
}
$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) {
//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['notification'] = $notification;
@ -887,13 +887,12 @@ class EmployeeRestController extends AdminController
$count++;
}
if($count == 20 || $a == count($dataToInsert)-1){
$job_details = new Jobs();
$r = Jobs::addJob(['job_name' => 'bulk_mail','payload' => $wholeData]);
// $wholeData[]= $r;
// Mailhelper::bulk_mail($wholeData);
$wholeData = [];
$count = 0;
if (count($wholeData) > 0) {
$job_details = new Jobs();
$r = Jobs::addJob(['job_name' => 'bulk_mail','payload' => $wholeData]);
$wholeData = [];
$count = 0;
}
}

View File

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

View File

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