From 5d20b696e99a10f2747141f920c2cdb159c41f94 Mon Sep 17 00:00:00 2001 From: aadhavan valli Date: Thu, 16 May 2024 12:25:33 +0530 Subject: [PATCH 1/4] CHANGE_NOTIFICATION_MAIL_ALLOW_NULL_ISSUE : AADHAVAN --- app/Controllers/EmpDataServiceController.php | 29 ++++++++++++++------ app/Controllers/EmployeeRestController.php | 15 +++++----- app/Controllers/NotificationController.php | 11 +++++--- app/Helpers/sendMailNotification.php | 28 +++++++++++++------ 4 files changed, 54 insertions(+), 29 deletions(-) diff --git a/app/Controllers/EmpDataServiceController.php b/app/Controllers/EmpDataServiceController.php index 826c8a6b..fdaae901 100644 --- a/app/Controllers/EmpDataServiceController.php +++ b/app/Controllers/EmpDataServiceController.php @@ -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 ',); diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 79069da8..91c4b6b6 100644 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -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; + } } diff --git a/app/Controllers/NotificationController.php b/app/Controllers/NotificationController.php index e0a6280c..2c050523 100644 --- a/app/Controllers/NotificationController.php +++ b/app/Controllers/NotificationController.php @@ -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; + } + } } } diff --git a/app/Helpers/sendMailNotification.php b/app/Helpers/sendMailNotification.php index f93e79f6..cfc96b17 100644 --- a/app/Helpers/sendMailNotification.php +++ b/app/Helpers/sendMailNotification.php @@ -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; From 90eaba5b85e174387f6576983ee591b176e5fcd1 Mon Sep 17 00:00:00 2001 From: aadhavan valli Date: Thu, 16 May 2024 14:33:56 +0530 Subject: [PATCH 2/4] CHANGE_CLIENT_POLICY_POLICY_NO_TPA_NETWORK_HOSPITAL : AADHAVAN --- app/Controllers/ClientController.php | 3 +++ app/Controllers/MasterController.php | 2 ++ app/Models/ClientPolicyModel.php | 3 ++- app/Models/TPAModel.php | 1 + app/Views/client_policy.php | 16 +++++++++++++--- app/Views/tpa_basic_info.php | 21 +++++++++++++-------- writable/e_card_template/md_tpa.html | 0 writable/e_card_template/ttpanh.html | 0 8 files changed, 34 insertions(+), 12 deletions(-) create mode 100644 writable/e_card_template/md_tpa.html create mode 100644 writable/e_card_template/ttpanh.html diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 8b0c17ee..1984e5dc 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -653,6 +653,7 @@ class ClientController extends AdminController } + $data['policy_no'] = $this->request->getPost('policy_no'); $data['policy_start_date'] = change_date_format($this->request->getPost('policy_start_date'), 'd-m-Y', 'Y-m-d'); $data['policy_end_date'] = change_date_format($this->request->getPost('policy_end_date'), 'd-m-Y', 'Y-m-d'); $data['created_by'] = get_session_userid(); @@ -696,6 +697,7 @@ class ClientController extends AdminController $data['tpa_id'] = $tpaId; $data['policy_id'] = $this->request->getPost('policy_id'); $data['policy_type_id'] = $this->request->getPost('policy_type_id'); + $data['policy_no'] = $this->request->getPost('policy_no'); $data['policy_start_date'] = change_date_format($this->request->getPost('policy_start_date'), 'd-m-Y', 'Y-m-d'); $data['policy_end_date'] = change_date_format($this->request->getPost('policy_end_date'), 'd-m-Y', 'Y-m-d'); @@ -741,6 +743,7 @@ class ClientController extends AdminController // dd($data); $data['updated_by'] = get_session_userid(); + // print_r($data);die; $insert = $this->clientPolicyModel->update($id,$data); $lastQuery = $this->clientPolicyModel->getLastQuery(); diff --git a/app/Controllers/MasterController.php b/app/Controllers/MasterController.php index a2c011a2..b652d3eb 100644 --- a/app/Controllers/MasterController.php +++ b/app/Controllers/MasterController.php @@ -427,6 +427,7 @@ class MasterController extends AdminController $data['tpa_logo'] = $file_name; $data['front_card'] = $front_card_file_name; $data['back_card'] = $back_card_file_name; + $data['network_hospitals'] = $this->request->getPost('network_hospitals'); $insert = $this->tpaModel->insert($data); @@ -566,6 +567,7 @@ class MasterController extends AdminController $data['back_card'] = $back_card_file_name; } + $data['network_hospitals'] = $this->request->getPost('network_hospitals'); $update = $this->tpaModel->update($id,$data); diff --git a/app/Models/ClientPolicyModel.php b/app/Models/ClientPolicyModel.php index 291b13f9..4cdd36b5 100644 --- a/app/Models/ClientPolicyModel.php +++ b/app/Models/ClientPolicyModel.php @@ -40,7 +40,8 @@ class ClientPolicyModel extends Model "updated_by", "Is_active", "date_of_exit", - "reason_for_exit" + "reason_for_exit", + "policy_no" ]; public function getClientPolicyById($id){ diff --git a/app/Models/TPAModel.php b/app/Models/TPAModel.php index 215c734d..fe3f30cd 100644 --- a/app/Models/TPAModel.php +++ b/app/Models/TPAModel.php @@ -15,6 +15,7 @@ class TPAModel extends Model "front_card", "back_card", "tpa_logo", + "network_hospitals", "created_by", "updated_by", "is_active", diff --git a/app/Views/client_policy.php b/app/Views/client_policy.php index 8ee76ec5..d26b3f20 100644 --- a/app/Views/client_policy.php +++ b/app/Views/client_policy.php @@ -92,15 +92,19 @@