diff --git a/app/Config/Routes.php b/app/Config/Routes.php index a6472417..aba39a78 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -22,6 +22,10 @@ $routes->get("view", "EmployeeController::viewECard/$1"); $routes->get("smapletest", "ClientController::smapletest"); $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"); @@ -447,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 diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 7b8e9cf8..efcd633e 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -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; @@ -584,7 +601,7 @@ class ClientController extends AdminController $editData['client_policy'] = $clientPoliceData; $editData['client_policy']['role'] = get_role_id(); $editData['notification'] = $this->notificationModel->select('template_name,enabled')->where('client_id', $id)->findAll(); - $editData['placeHolders'] = ['member_name', 'nhance_logo', 'tpa_id', 'ecard_download_link', 'client_logo', 'policy_no', 'member_summary', 'app_link', 'post_enrollment_app_link', 'client_name']; + $editData['placeHolders'] = ['member_name', 'member_mobile', 'nhance_logo', 'tpa_id', 'ecard_download_link', 'client_logo', 'policy_no', 'member_summary', 'app_link', 'post_enrollment_app_link', 'client_name']; // dd($editData); echo view('layout/header', $headerData); @@ -1033,6 +1050,9 @@ class ClientController extends AdminController $data['cd_ac_no'] = $this->request->getPost('cd_ac_no'); $data['gst'] = $this->request->getPost('gst'); $data['disclaimer'] = $this->request->getPost('disclaimer'); + $data['is_member_modify_allowed'] = $this->request->getPost('is_member_modify_allowed') ? 1 : 0; + $data['enrolment_visibility'] = $this->request->getPost('enrolment_visibility') ? 1 : 0; + if ($policy_type_id == 1 || $policy_type_id == 2 || $policy_type_id == 6 || $policy_type_id == 7) { @@ -1059,7 +1079,8 @@ class ClientController extends AdminController if ($data['inception_type'] == 2) { $data['open_date'] = change_date_format($this->request->getPost('open_date'), 'd-m-Y', 'Y-m-d'); $data['close_date'] = change_date_format($this->request->getPost('close_date'), 'd-m-Y', 'Y-m-d'); - $data['reminder_date'] = change_date_format($this->request->getPost('reminder_date'), 'd-m-Y', 'Y-m-d'); + // $data['reminder_date'] = change_date_format($this->request->getPost('reminder_date'), 'd-m-Y', 'Y-m-d'); + $data['reminder_date'] = $this->request->getPost('reminder_date'); } else { $data['open_date'] = null; $data['closedate'] = null; @@ -1162,11 +1183,13 @@ class ClientController extends AdminController $data['disclaimer'] = $this->request->getPost('disclaimer'); $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['is_member_modify_allowed'] = $this->request->getPost('is_member_modify_allowed') ? 1 : 0; if ($data['inception_type'] == 2) { $data['open_date'] = change_date_format($this->request->getPost('open_date'), 'd-m-Y', 'Y-m-d'); $data['close_date'] = change_date_format($this->request->getPost('close_date'), 'd-m-Y', 'Y-m-d'); - $data['reminder_date'] = change_date_format($this->request->getPost('reminder_date'), 'd-m-Y', 'Y-m-d'); + // $data['reminder_date'] = change_date_format($this->request->getPost('reminder_date'), 'd-m-Y', 'Y-m-d'); + $data['reminder_date'] = $this->request->getPost('reminder_date'); } else { $data['open_date'] = null; $data['close_date'] = null; @@ -2936,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; } } @@ -3659,4 +3682,43 @@ class ClientController extends AdminController } } + public function updateRemainderDate() + { + // Connect to the database and fetch the data + $data = db_connect()->table('client_policy') + ->where("reminder_date IS NOT NULL AND reminder_date <> ''") + ->where('is_active', 1) + ->get() + ->getResultArray(); + + $days = []; + foreach ($data as $value) { + + $reminderDate = strtotime($value['reminder_date']); + if ($reminderDate) { + $date_of_date = date('d', $reminderDate); + $days[] = $date_of_date; + $days[] = $value['reminder_date']; + db_connect()->table('client_policy')->where('id', $value['id'])->set('reminder_date', $date_of_date)->update(); + } + } + + 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); + } + } diff --git a/app/Controllers/DashboardController.php b/app/Controllers/DashboardController.php index dfa0841a..1a8c8382 100755 --- a/app/Controllers/DashboardController.php +++ b/app/Controllers/DashboardController.php @@ -362,16 +362,14 @@ class DashboardController extends AdminController // dd($client_policy_data, $send_mail_for_manual_or_crone); $reminder_whole_mail = []; - + foreach ($client_policy_data as $client_policy) { - if(empty($send_mail_for_manual_or_crone)){ - - // echo '1'; + if (empty($send_mail_for_manual_or_crone)) { // Fetch client data $client_data = $this->clientModel->find($client_policy['client_id']); - + // Fetch notification settings $notification_data = $this->notificationModel ->where('client_id', $client_policy['client_id']) @@ -379,14 +377,14 @@ class DashboardController extends AdminController ->first(); // $this->myLogger->logme('error', 'Notification data fetched: ' . json_encode($notification_data)); - + // Check if notification should be sent if ($notification_data && $notification_data['enabled'] == 1 && !empty($notification_data['mail_content'])) { $this->myLogger->logme('error', 'Notification should be sent for client policy ID: ' . $client_policy['id']); - + // 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') @@ -395,18 +393,28 @@ class DashboardController extends AdminController ->where('employee_polices.is_active', 1) ->where('employees.relationship', 'Self') ->findAll(); - + + // dd($employees); + // Process each employee foreach ($employees as $employee) { - + if ($employee['emp_status'] == 'draft' && $employee['relationship'] == 'Self') { $this->myLogger->logme('error', 'Employee status and relationship check passed for employee ID: ' . $employee['id']); - + // Mail params $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); // $this->myLogger->logme('error', 'Mail sent result: ' . json_encode($mail_result)); @@ -414,66 +422,74 @@ class DashboardController extends AdminController } } } else { - $this->myLogger->logme('error', 'Notification not sent for client policy ID: ' . $client_policy['id']); + $this->myLogger->logme('error', 'Notification was not sent for Client Policy ID: ' . $client_policy['id']); + $this->myLogger->logme('error', 'Notification setup not found or not enabled'); } - } else { - // echo '2'; + $currentDate = date('d'); + $remainder_dates = explode(",", $client_policy['reminder_date']); - $currentDate = date('d-m-Y'); + foreach ($remainder_dates as $date) { - if($currentDate == date('d-m-Y', strtotime($client_policy['reminder_date']))){ + if ($currentDate == $date) { - // echo '3'; + $client_data = $this->clientModel->find($client_policy['client_id']); - $client_data = $this->clientModel->find($client_policy['client_id']); + // Fetch notification settings + $notification_data = $this->notificationModel + ->where('client_id', $client_policy['client_id']) + ->where('template_name', 'member_reminder_mail') + ->first(); - // Fetch notification settings - $notification_data = $this->notificationModel - ->where('client_id', $client_policy['client_id']) - ->where('template_name', 'member_reminder_mail') - ->first(); - - // Check if notification should be sent - if ($notification_data && $notification_data['enabled'] == 1 && !empty($notification_data['mail_content'])) { + // Check if notification should be sent + if ($notification_data && $notification_data['enabled'] == 1 && !empty($notification_data['mail_content'])) { - // echo '4'; + // echo '4'; - $this->myLogger->logme('error', 'Notification should be sent for client policy ID: ' . $client_policy['id']); - - // Fetch all employees related to the client policy - $employees = $this->employeePolicyModel - ->select('employees.*') - ->join('employees', 'employee_polices.employee_id = employees.id', 'left') - ->where('employee_polices.client_policy_id', $client_policy['id']) - ->where('employees.emp_status', 'draft') - ->where('employees.is_active', 1) - ->where('employee_polices.status', 'draft') - ->where('employee_polices.is_active', 1) - ->where('employees.relationship', 'Self') - ->findAll(); - - // Process each employee - foreach ($employees as $employee) { - - if ($employee['emp_status'] == 'draft' && $employee['relationship'] == 'Self') { - $this->myLogger->logme('error', 'Employee status and relationship check passed for employee ID: ' . $employee['id']); - - // Mail params - $params['emp_data'] = $employee; - $params['client_data'] = $client_data; - $params['notification_data'] = $notification_data; - - // Send the mail notification - $mail_result = sendMailNotification::sendMailNotification('member_reminder_mail', $params); - // $this->myLogger->logme('error', 'Mail sent result: ' . json_encode($mail_result)); - $reminder_whole_mail[] = $mail_result; + $this->myLogger->logme('error', 'Notification should be sent for client policy ID: ' . $client_policy['id']); + + // Fetch all employees related to the client policy + $employees = $this->employeePolicyModel + ->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') + ->where('employees.is_active', 1) + ->where('employee_polices.status', 'draft') + ->where('employee_polices.is_active', 1) + ->where('employees.relationship', 'Self') + ->findAll(); + + // Process each employee + foreach ($employees as $employee) { + + if ($employee['emp_status'] == 'draft' && $employee['relationship'] == 'Self') { + $this->myLogger->logme('error', 'Employee status and relationship check passed for employee ID: ' . $employee['id']); + + // Mail params + $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); + // $this->myLogger->logme('error', 'Mail sent result: ' . json_encode($mail_result)); + $reminder_whole_mail[] = $mail_result; + } } + } else { + // echo '5'; + $this->myLogger->logme('error', 'Notification not sent for client policy ID: ' . $client_policy['id']); } - } else { - // echo '5'; - $this->myLogger->logme('error', 'Notification not sent for client policy ID: ' . $client_policy['id']); } } } @@ -481,41 +497,22 @@ class DashboardController extends AdminController // dd($reminder_whole_mail); - // $this->myLogger->logme('error', 'Whole email, count: ' . $reminder_whole_mail); - // Process and queue bulk emails - $temp_whole_data = []; - $count = 0; - - foreach ($reminder_whole_mail as $whole_index => $values) { - foreach ($values as $index => $value) { - $temp_whole_data[] = $value; - $count++; - $this->myLogger->logme('error', 'Queueing email, count: ' . $count); - - if ($count == 20 || ($whole_index == count($reminder_whole_mail) - 1 && $index == count($values) - 1)) { - if (!empty($temp_whole_data)) { - Jobs::addJob(['job_name' => 'bulk_mail', 'payload' => $temp_whole_data]); - $this->myLogger->logme('error', 'Added bulk mail job: ' . json_encode($temp_whole_data)); - $temp_whole_data = []; - $count = 0; - } - } + if (!empty($reminder_whole_mail) && count($reminder_whole_mail) > 0) { + + $reminder_whole_mail = array_chunk($reminder_whole_mail, 20); + + foreach ($reminder_whole_mail as $key => $value) { + $job_details = new Jobs(); + $r = Jobs::addJob(['job_name' => 'bulk_mail', 'payload' => $value]); } } - - if (count($temp_whole_data) > 0) { - Jobs::addJob(['job_name' => 'bulk_mail', 'payload' => $temp_whole_data]); - $this->myLogger->logme('error', 'Added final bulk mail job: ' . json_encode($temp_whole_data)); + + if (count($reminder_whole_mail) > 0) { return true; - } - - if(count($reminder_whole_mail) > 0){ - return true; - }else{ + } else { return false; } - } public function sendManualReminder($client_id, $client_branch_id) @@ -545,7 +542,7 @@ class DashboardController extends AdminController } } - public function sendManualEcard($client_id, $client_branch_id, $policy_id) + public function sendManualEcard($client_id, $client_branch_id, $policy_id) { $this->myLogger->logme('error', "sendManualEcard called with client_id: {$client_id}, client_branch_id: {$client_branch_id}, policy id : {$policy_id}"); @@ -574,7 +571,8 @@ class DashboardController extends AdminController } - public function data_construct_for_bds($data){ + public function data_construct_for_bds($data) + { $groupedData = [ 'under_process' => [], diff --git a/app/Controllers/EmpDataServiceController.php b/app/Controllers/EmpDataServiceController.php index 9ae9e2d1..617eeda9 100755 --- a/app/Controllers/EmpDataServiceController.php +++ b/app/Controllers/EmpDataServiceController.php @@ -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, 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); diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index 9afb44b2..02c01d34 100755 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -1798,9 +1798,9 @@ class EmployeeController extends AdminController public function checkDeletionGetDataFunction() { // $batch_data = [ - // 'client_id' => 77, - // 'client_policy_id' => 203, - // 'client_branch_id' => 53, + // 'client_id' => 159, + // 'client_policy_id' => 336, + // 'client_branch_id' => 126, // ]; // $batch_data['insurer_or_tpa'] = 'insurer'; diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 9453a767..abb15d65 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -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)) diff --git a/app/Controllers/EmployeeServiceController.php b/app/Controllers/EmployeeServiceController.php index 1eb7322c..0d2cc5f9 100755 --- a/app/Controllers/EmployeeServiceController.php +++ b/app/Controllers/EmployeeServiceController.php @@ -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; -} + + + } } + +} \ No newline at end of file diff --git a/app/Helpers/sendMailNotification.php b/app/Helpers/sendMailNotification.php index fbc374a8..e6b6edf9 100755 --- a/app/Helpers/sendMailNotification.php +++ b/app/Helpers/sendMailNotification.php @@ -17,11 +17,13 @@ class sendMailNotification public static function sendMailNotification($action, $params) { $wholeData =[]; + if ($action == 'member_welcome_mail') { $dataToInsert = $params['dataToInsert']; $notification = $params['notification']; $client_data = $params['client_data']; + $common = $params['common']; $mailAttachmentModel = new MailAttachmentModel(); $attachment_data = $mailAttachmentModel @@ -42,6 +44,7 @@ class sendMailNotification $subject = $notification['subject']; $app_link = $_ENV['App_Url']; $employee_name =$dataToInsert['name']; + $employee_mobile_no =$dataToInsert['mobile']; $mail_content = $notification['mail_content']; $nhance_logo = $_ENV['NHANCE_LOGO']; $client_logo = base_url() . "public/uploads/logo/" . $client_data['client_logo']; @@ -49,11 +52,12 @@ class sendMailNotification $mail_content = str_replace("[[client_logo]]", "Client Logo", $mail_content); $mail_content = str_replace("[[nhance_logo]]", "Nhance Logo", $mail_content); $mail_content = str_replace("[[member_name]]", $employee_name, $mail_content); + $mail_content = str_replace("[[member_mobile]]", $employee_mobile_no, $mail_content); $mail_content = str_replace("[[client_name]]", $client_data['client_name'], $mail_content); $mail_content = str_replace("[[app_link]]", "Review Details", $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; @@ -64,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']; @@ -83,7 +88,9 @@ class sendMailNotification $mail =''; if ($emp_data['relationship'] == 'Self') { $employee_name =$emp_data['name']; + $employee_mobile_no =$emp_data['mobile']; $mail_content = str_replace("[[member_name]]", $employee_name, $mail_content); + $mail_content = str_replace("[[member_mobile]]", $employee_mobile_no, $mail_content); $mail = $emp_data['email_corporate']; } } @@ -93,12 +100,14 @@ class sendMailNotification }else{ $employee_name =$emp_data['name']; + $employee_mobile_no =$emp_data['mobile']; $mail_content = str_replace("[[member_name]]", $employee_name, $mail_content); + $mail_content = str_replace("[[member_mobile]]", $employee_mobile_no, $mail_content); $mail = $emp_data['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]; } }else{ @@ -111,7 +120,9 @@ class sendMailNotification foreach ($emp_data as $key => $values) { if ($value['relationship'] == 'Self') { $employee_name =$values['name']; + $employee_mobile_no =$values['mobile']; $mail_content = str_replace("[[member_name]]", $employee_name, $mail_content); + $mail_content = str_replace("[[member_mobile]]", $employee_mobile_no, $mail_content); $mail = $values['email_corporate']; } } @@ -120,11 +131,13 @@ class sendMailNotification } }else{ $employee_name =$value['name']; + $employee_mobile_no =$value['mobile']; $mail_content = str_replace("[[member_name]]", $employee_name, $mail_content); + $mail_content = str_replace("[[member_mobile]]", $employee_mobile_no, $mail_content); $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]; } } } @@ -146,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']; @@ -161,6 +175,7 @@ class sendMailNotification $app_link = $_ENV['App_Url']; $name = $get_emp_email_and_other_details['name']; + $employee_mobile_no = $get_emp_email_and_other_details['mobile']; $mail_content = $notification['mail_content']; $nhance_logo = $_ENV['NHANCE_LOGO']; @@ -175,12 +190,13 @@ class sendMailNotification $mail_content = str_replace("[[client_logo]]", "Client Logo", $mail_content); $mail_content = str_replace("[[member_name]]", $name, $mail_content); + $mail_content = str_replace("[[member_mobile]]", $employee_mobile_no, $mail_content); $mail_content = str_replace("[[app_link]]", "Review Details", $mail_content); $mail_content = str_replace("[[post_enrollment_app_link]]", "Review Details", $mail_content); // $mail_content = str_replace("[[tpa_id]]", $tpa_id, $mail_content); $mail_content = str_replace("[[ecard_download_link]]", "Download Insurance Card", $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; @@ -190,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(); @@ -226,6 +243,7 @@ class sendMailNotification $gst = 0; $Addon_list = []; $name = ''; + $employee_mobile_no = ''; $emp_code = ''; // echo '
';
@@ -233,7 +251,6 @@ class sendMailNotification
 
                 foreach ($array_list as $item) {
                     
-
                     if (count($item) != 0) {
 
                         $table_content .= '

Policy Type :'; @@ -258,6 +275,7 @@ class sendMailNotification $emp_code = '(' . $inner_item['emp_code'] . ')'; $mail = $inner_item['email_corporate']; $name = $inner_item['name']; + $employee_mobile_no = $inner_item['mobile']; } $si = ''; @@ -378,13 +396,14 @@ class sendMailNotification // print_r($table_content); die; $mail_content = str_replace("[[member_name]]", $name . ' (' . $emp_code . ')' , $mail_content); + $mail_content = str_replace("[[member_mobile]]", $employee_mobile_no, $mail_content); $mail_content = str_replace("[[member_summary]]", $table_content , $mail_content); // print_r($mail_content); die; // $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; @@ -395,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(); @@ -590,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; @@ -600,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(); @@ -798,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']]; } @@ -841,6 +862,7 @@ class sendMailNotification // print_r($attachments); die; $employee_name = 'John Doe'; + $mobile = 9080706050; $app_link = $_ENV['App_Url']; $nhance_logo = $_ENV['NHANCE_LOGO']; @@ -850,6 +872,7 @@ class sendMailNotification $mail_content = str_replace("[[client_logo]]", "Client Logo", $mail_content); $mail_content = str_replace("[[nhance_logo]]", "Nhance Logo", $mail_content); $mail_content = str_replace("[[member_name]]", $employee_name, $mail_content); + $mail_content = str_replace("[[member_mobile]]", $mobile, $mail_content); $mail_content = str_replace("[[client_name]]", $client_data['client_name'], $mail_content); $mail_content = str_replace("[[app_link]]", "Review Details", $mail_content); @@ -873,6 +896,7 @@ class sendMailNotification $app_link = $_ENV['App_Url']; $employee_name = 'John Doe'; + $mobile = 9080706050; $client_logo = base_url() . "public/uploads/logo/" . $client_data['client_logo']; @@ -880,6 +904,7 @@ class sendMailNotification $mail_content = str_replace("[[nhance_logo]]", "Nhance Logo", $mail_content); $mail_content = str_replace("[[client_logo]]", "Client Logo", $mail_content); $mail_content = str_replace("[[app_link]]", "Review Details", $mail_content); + $mail_content = str_replace("[[member_mobile]]", $mobile, $mail_content); if ((isset($notification_data) && $notification_data['enabled'] == 1)) { @@ -905,6 +930,7 @@ class sendMailNotification $link = generate_download_link($rand_string); $name = 'John Doe'; + $mobile = 9080706050; $nhance_logo = $_ENV['NHANCE_LOGO']; $app_link = $_ENV['App_Url']; @@ -916,6 +942,7 @@ class sendMailNotification $mail_content = str_replace("[[client_logo]]", "Client Logo", $mail_content); $mail_content = str_replace("[[member_name]]", $name, $mail_content); + $mail_content = str_replace("[[member_mobile]]", $mobile, $mail_content); $mail_content = str_replace("[[app_link]]", "Review Details", $mail_content); $mail_content = str_replace("[[post_enrollment_app_link]]", "Review Details", $mail_content); $mail_content = str_replace("[[ecard_download_link]]", "Download Insurance Card", $mail_content); @@ -937,7 +964,8 @@ class sendMailNotification 'premium' => 12000, 'gst' => 2160, 'rata_premimum' => 12000, - 'is_addon' => 2 + 'is_addon' => 2, + 'mobile' => 9080706050 ]; @@ -967,6 +995,7 @@ class sendMailNotification $gst = 0; $Addon_list = []; $name = $array_list['name']; + $mobile = $array_list['mobile']; $emp_code = ''; if (!empty($array_list)) { @@ -987,9 +1016,9 @@ class sendMailNotification $table_content .= ''; $table_content .= ''; $table_content .= 'Name'; - $table_content .= 'Relation'; - $table_content .= 'Date Of Birth'; - $table_content .= 'Sum Insured'; + $table_content .= 'Relation'; + $table_content .= 'Date Of Birth'; + $table_content .= 'Sum Insured'; // Only Display SI Topup and Dependent Addon if ($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) { @@ -1003,14 +1032,14 @@ class sendMailNotification // Table body with details $table_content .= ''; $table_content .= ''; - $table_content .= '' . $array_list['name'] . $emp_code . ''; - $table_content .= '' . $array_list['relationship'] . ''; - $table_content .= '' . \DateTime::createFromFormat('Y-m-d', $array_list['dob'])->format('d-m-Y') . ''; - $table_content .= '₹' . format_indian_number($array_list['basic_cover_si']) . ''; + $table_content .= '' . nl2br(wordwrap($array_list['name'] . $emp_code, 11, "\n", true)) . ''; + $table_content .= '' . $array_list['relationship'] . ''; + $table_content .= '' . \DateTime::createFromFormat('Y-m-d', $array_list['dob'])->format('d-m-Y') . ''; + $table_content .= '₹' . format_indian_number($array_list['basic_cover_si']) . ''; if ($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) { - $table_content .= '₹' . format_indian_number(round($array_list['premium'])) . ''; - $table_content .= '₹' . format_indian_number(round($array_list['gst'])) . ''; + $table_content .= '₹' . format_indian_number(round($array_list['premium'])) . ''; + $table_content .= '₹' . format_indian_number(round($array_list['gst'])) . ''; } $table_content .= ''; @@ -1039,10 +1068,10 @@ class sendMailNotification $table_content .= ''; $table_content .= ''; - $table_content .= 'Policy Name'; - $table_content .= 'Additional Premium'; - $table_content .= 'GST'; - $table_content .= 'Total'; + $table_content .= 'Policy Name'; + $table_content .= 'Additional Premium'; + $table_content .= 'GST'; + $table_content .= 'Total'; $table_content .= ''; $table_content .= ''; @@ -1050,16 +1079,16 @@ class sendMailNotification $total_addon = $Addon_list[0]['gst'] + $Addon_list[0]['addtional_premium']; $table_content .= ''; - $table_content .= '' . $Addon_list[0]['policy_name'] . ''; - $table_content .= '₹' . format_indian_number($Addon_list[0]['addtional_premium']) . ''; - $table_content .= '₹' . format_indian_number($Addon_list[0]['gst']) . ''; - $table_content .= '₹' . format_indian_number($total_addon) . ''; + $table_content .= '' . $Addon_list[0]['policy_name'] . ''; + $table_content .= '₹' . format_indian_number($Addon_list[0]['addtional_premium']) . ''; + $table_content .= '₹' . format_indian_number($Addon_list[0]['gst']) . ''; + $table_content .= '₹' . format_indian_number($total_addon) . ''; $table_content .= ''; $sum_total_words = numberToWords($total_addon); $table_content .= ''; $table_content .= 'Total'; - $table_content .= '₹' . format_indian_number($total_addon) . ''; + $table_content .= '₹' . format_indian_number($total_addon) . ''; $table_content .= ''; $table_content .= ''; $table_content .= '

'; @@ -1067,6 +1096,7 @@ class sendMailNotification } $mail_content = str_replace("[[member_name]]", $name . ' (' . $emp_code . ')' , $mail_content); + $mail_content = str_replace("[[member_mobile]]", $mobile, $mail_content); $mail_content = str_replace("[[member_summary]]", $table_content , $mail_content); @@ -1136,14 +1166,14 @@ class sendMailNotification $table_content .= ''; $table_content .= ''; $table_content .= 'Name'; - $table_content .= 'Relation'; - $table_content .= 'Date Of Birth'; - $table_content .= 'Sum Insured'; + $table_content .= 'Relation'; + $table_content .= 'Date Of Birth'; + $table_content .= 'Sum Insured'; // Only Display SI Topup and Dependent Addon if ($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) { - $table_content .= 'Premium'; - $table_content .= 'GST'; + $table_content .= 'Premium'; + $table_content .= 'GST'; } $table_content .= ''; @@ -1152,14 +1182,14 @@ class sendMailNotification // Table body with details $table_content .= ''; $table_content .= ''; - $table_content .= '' . $array_list['name'] . $emp_code . ''; - $table_content .= '' . $array_list['relationship'] . ''; - $table_content .= '' . \DateTime::createFromFormat('Y-m-d', $array_list['dob'])->format('d-m-Y') . ''; - $table_content .= '₹' . format_indian_number($array_list['basic_cover_si']) . ''; + $table_content .= '' . nl2br(wordwrap($array_list['name'] . $emp_code, 11, "\n", true)) . ''; + $table_content .= '' . $array_list['relationship'] . ''; + $table_content .= '' . \DateTime::createFromFormat('Y-m-d', $array_list['dob'])->format('d-m-Y') . ''; + $table_content .= '₹' . format_indian_number($array_list['basic_cover_si']) . ''; if ($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) { - $table_content .= '₹' . format_indian_number(round($array_list['premium'])) . ''; - $table_content .= '₹' . format_indian_number(round($array_list['gst'])) . ''; + $table_content .= '₹' . format_indian_number(round($array_list['premium'])) . ''; + $table_content .= '₹' . format_indian_number(round($array_list['gst'])) . ''; } $table_content .= ''; @@ -1188,10 +1218,10 @@ class sendMailNotification $table_content .= ''; $table_content .= ''; - $table_content .= 'Policy Name'; - $table_content .= 'Additional Premium'; - $table_content .= 'GST'; - $table_content .= 'Total'; + $table_content .= 'Policy Name'; + $table_content .= 'Additional Premium'; + $table_content .= 'GST'; + $table_content .= 'Total'; $table_content .= ''; $table_content .= ''; @@ -1199,17 +1229,17 @@ class sendMailNotification $total_addon = $Addon_list[0]['gst'] + $Addon_list[0]['addtional_premium']; $table_content .= ''; - $table_content .= '' . $Addon_list[0]['policy_name'] . ''; - $table_content .= '₹' . format_indian_number($Addon_list[0]['addtional_premium']) . ''; - $table_content .= '₹' . format_indian_number($Addon_list[0]['gst']) . ''; - $table_content .= '₹' . format_indian_number($total_addon) . ''; + $table_content .= '' . $Addon_list[0]['policy_name'] . ''; + $table_content .= '₹' . format_indian_number($Addon_list[0]['addtional_premium']) . ''; + $table_content .= '₹' . format_indian_number($Addon_list[0]['gst']) . ''; + $table_content .= '₹' . format_indian_number($total_addon) . ''; $table_content .= ''; $sum_total_words = numberToWords($total_addon); $table_content .= ''; $table_content .= 'Total'; - $table_content .= '₹' . format_indian_number($total_addon) . ''; - $table_content .= ''; + $table_content .= '₹' . format_indian_number($total_addon) . ''; + $table_content .= ''; $table_content .= ''; $table_content .= ''; } @@ -1228,7 +1258,7 @@ class sendMailNotification $array_list = [ 'policy_name' => 'Health Insurance Plan', 'emp_code' => 'E12345', - 'name' => 'John Doe', + 'name' => 'Ramakrishnaparamahamsar', 'relationship' => 'Self', 'dob' => '1985-05-15', 'basic_cover_si' => 500000, @@ -1284,14 +1314,14 @@ class sendMailNotification $table_content .= ''; $table_content .= ''; $table_content .= 'Name'; - $table_content .= 'Relation'; - $table_content .= 'Date Of Birth'; - $table_content .= 'Sum Insured'; + $table_content .= 'Relation'; + $table_content .= 'Date Of Birth'; + $table_content .= 'Sum Insured'; // Only Display SI Topup and Dependent Addon if ($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) { - $table_content .= 'Premium'; - $table_content .= 'GST'; + $table_content .= 'Premium'; + $table_content .= 'GST'; } $table_content .= ''; @@ -1300,14 +1330,14 @@ class sendMailNotification // Table body with details $table_content .= ''; $table_content .= ''; - $table_content .= '' . $array_list['name'] . $emp_code . ''; - $table_content .= '' . $array_list['relationship'] . ''; - $table_content .= '' . \DateTime::createFromFormat('Y-m-d', $array_list['dob'])->format('d-m-Y') . ''; - $table_content .= '₹' . format_indian_number($array_list['basic_cover_si']) . ''; + $table_content .= '' . nl2br(wordwrap($array_list['name'] . $emp_code, 11, "\n", true)) . ''; + $table_content .= '' . $array_list['relationship'] . ''; + $table_content .= '' . \DateTime::createFromFormat('Y-m-d', $array_list['dob'])->format('d-m-Y') . ''; + $table_content .= '₹' . format_indian_number($array_list['basic_cover_si']) . ''; if ($array_list['is_addon'] == 2 || $array_list['is_addon'] == 3) { - $table_content .= '₹' . format_indian_number(round($array_list['premium'])) . ''; - $table_content .= '₹' . format_indian_number(round($array_list['gst'])) . ''; + $table_content .= '₹' . format_indian_number(round($array_list['premium'])) . ''; + $table_content .= '₹' . format_indian_number(round($array_list['gst'])) . ''; } $table_content .= ''; @@ -1337,10 +1367,10 @@ class sendMailNotification $table_content .= ''; $table_content .= ''; - $table_content .= 'Policy Name'; - $table_content .= 'Additional Premium'; - $table_content .= 'GST'; - $table_content .= 'Total'; + $table_content .= 'Policy Name'; + $table_content .= 'Additional Premium'; + $table_content .= 'GST'; + $table_content .= 'Total'; $table_content .= ''; $table_content .= ''; @@ -1348,16 +1378,16 @@ class sendMailNotification $total_addon = $Addon_list[0]['gst'] + $Addon_list[0]['addtional_premium']; $table_content .= ''; - $table_content .= '' . $Addon_list[0]['policy_name'] . ''; - $table_content .= '₹' . format_indian_number($Addon_list[0]['addtional_premium']) . ''; - $table_content .= '₹' . format_indian_number($Addon_list[0]['gst']) . ''; - $table_content .= '₹' . format_indian_number($total_addon) . ''; + $table_content .= '' . $Addon_list[0]['policy_name'] . ''; + $table_content .= '₹' . format_indian_number($Addon_list[0]['addtional_premium']) . ''; + $table_content .= '₹' . format_indian_number($Addon_list[0]['gst']) . ''; + $table_content .= '₹' . format_indian_number($total_addon) . ''; $table_content .= ''; $sum_total_words = numberToWords($total_addon); $table_content .= ''; - $table_content .= 'Total'; - $table_content .= '₹' . format_indian_number($total_addon) . ''; + $table_content .= 'Total'; + $table_content .= '₹' . format_indian_number($total_addon) . ''; $table_content .= ''; $table_content .= ''; $table_content .= ''; diff --git a/app/Models/ClientPolicyModel.php b/app/Models/ClientPolicyModel.php index 1aa5bf2d..aac8cd01 100755 --- a/app/Models/ClientPolicyModel.php +++ b/app/Models/ClientPolicyModel.php @@ -51,6 +51,7 @@ class ClientPolicyModel extends Model "enrolment_visibility", "disclaimer", "is_active", + "is_member_modify_allowed", ]; public function getClientPolicyById($id){ diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php index abbba1e4..2d285bb6 100755 --- a/app/Models/EmployeePolicyModel.php +++ b/app/Models/EmployeePolicyModel.php @@ -32,6 +32,7 @@ class EmployeePolicyModel extends Model "updated_at", "rand_string", "is_active", + "claim_status", ]; // Callbacks @@ -617,6 +618,7 @@ class EmployeePolicyModel extends Model employee_polices.policy_end_date, employee_polices.premium, employee_polices.rata_premimum as pro_rata_premium, + employee_polices.claim_status, batch_data.emp_policy_id AS emp_policy_id, batch_data.bl AS batch_list_batch_code, @@ -629,9 +631,37 @@ class EmployeePolicyModel extends Model deletiondata.status, DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + '$add_one_day' AS no_of_days, - ROUND((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365, 2) AS pro_rata_premium, - ROUND(((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365) * 0.18, 2) AS gst, - ROUND(((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365) + (((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365) * 0.18), 2) AS total + + + CASE + WHEN employee_polices.claim_status = 0 THEN + ROUND((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365, 2) + ELSE + 0 + END AS pro_rata_premium, + + CASE + WHEN employee_polices.claim_status = 0 THEN + ROUND(((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365) * 0.18, 2) + ELSE + 0 + END AS gst, + + CASE + WHEN employee_polices.claim_status = 0 THEN + ROUND(((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365) + + (((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365) * 0.18), 2) + ELSE + 0 + END AS total, + + CASE + WHEN employee_polices.claim_status = 0 THEN + 'No claim' + ELSE + 'Claim' + END AS claim_status + FROM emp_endorsement a LEFT JOIN diff --git a/app/Views/client_policy.php b/app/Views/client_policy.php index a0bb84b5..fd4a01a5 100755 --- a/app/Views/client_policy.php +++ b/app/Views/client_policy.php @@ -37,12 +37,14 @@
+ +
@@ -56,7 +58,7 @@
- + @@ -77,7 +79,7 @@
@@ -301,11 +314,11 @@ allowInput: false }); - var reminderDatePicker = flatpickr("#reminder_date", { - dateFormat: "d-m-Y", - defaultDate: today, - allowInput: false - }); + // var reminderDatePicker = flatpickr("#reminder_date", { + // dateFormat: "d-m-Y", + // defaultDate: today, + // allowInput: false + // }); $('#add_form').hide(); @@ -784,13 +797,14 @@ $('#open_date').val(rearrangeDateFormat(res.data.open_date)); $('#end_date').val(rearrangeDateFormat(res.data.policy_end_date)); $('#close_date').val(rearrangeDateFormat(res.data.close_date)); - $('#reminder_date').val(rearrangeDateFormat(res.data.reminder_date)); + $('#reminder_date').val(res.data.reminder_date); $('#disclaimer').val(res.data.disclaimer); $('#gst_no').val(gst); $('#policy_status').val(checkDateStatus(res.data.policy_end_date)); $('#policy_status_field').show(); + //Open for enrollment yes or no if (res.data.inception_type == 2) { $('#inception_type').prop('checked', true); $('#open_date').parent().show(); @@ -805,13 +819,20 @@ $('.dateofdata').attr('required', false); } - + //Policy Visibility in Web App if (res.data.enrolment_visibility == 1) { $('#policy_visibility').prop('checked', true); } else { $('#policy_visibility').prop('checked', false); } + // Member Modify Data Enable or Disable + if (res.data.is_member_modify_allowed == 1) { + $('#is_member_modify_allowed').prop('checked', true); + } else { + $('#is_member_modify_allowed').prop('checked', false); + } + // if (res.data.is_addon != '1' && res.data.is_addon != '0') { // $('#base_policy_id').show(); diff --git a/app/Views/employee_list.php b/app/Views/employee_list.php index e0dd6a46..ebcc64e0 100755 --- a/app/Views/employee_list.php +++ b/app/Views/employee_list.php @@ -64,7 +64,7 @@ table.dataTable tbody td { $value) { ?> - + @@ -405,7 +405,7 @@ - + @@ -492,7 +492,7 @@