diff --git a/app/Config/Routes.php b/app/Config/Routes.php index aba39a78..9becf234 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -26,6 +26,7 @@ $routes->get("updateRemainderDate", "ClientController::updateRemainderDate"); $routes->get("sendCroneRemainderMail", "DashboardController::sendCroneRemainderMail"); $routes->get("sendextraparam", "ClientController::sendextraparam"); // $routes->post("iAgreeForAddOn", "EmployeeRestController::iAgreeForAddOn"); +// $routes->get("sendCroneRemainderMail", "DashboardController::sendCroneRemainderMail"); $routes->post("add_advertise_image", "AppContentManagementController::add_advertise_image"); $routes->get("add_image_index", "AppContentManagementController::add_image_index"); diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index efcd633e..64fad6e8 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -2442,11 +2442,11 @@ class ClientController extends AdminController $termsData = json_decode($termsData['policy_terms']); - if (isset($termsData->sum_insured) && empty($termsData->sum_insured)) { + if (isset($termsData->sum_insured) && $termsData->sum_insured == "" && $termsData->sum_insured == null) { return $this->respond(['status' => false, 'code' => 200, 'message' => 'The Policy terms Sum Insured field is empty', 'data' => $record], 200); } - if (isset($termsData->SumInsured) && empty($termsData->sum_insured)) { + if (isset($termsData->sumInsured2) && $termsData->sumInsured2 == "" && $termsData->sumInsured2 == null) { return $this->respond(['status' => false, 'code' => 200, 'message' => 'The Policy terms Sum Insured field is empty'], 200); } diff --git a/app/Controllers/DashboardController.php b/app/Controllers/DashboardController.php index 1a8c8382..12c43199 100755 --- a/app/Controllers/DashboardController.php +++ b/app/Controllers/DashboardController.php @@ -365,41 +365,81 @@ class DashboardController extends AdminController foreach ($client_policy_data as $client_policy) { - if (empty($send_mail_for_manual_or_crone)) { + // Fetch client data + $client_data = $this->clientModel->find($client_policy['client_id']); - // 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']) + ->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(); + if ($notification_data && $notification_data['enabled'] == 1 && !empty($notification_data['mail_content'])) { - // $this->myLogger->logme('error', 'Notification data fetched: ' . json_encode($notification_data)); + //manaual + if (empty($send_mail_for_manual_or_crone)) { - // Check if notification should be sent - if ($notification_data && $notification_data['enabled'] == 1 && !empty($notification_data['mail_content'])) { + // Check if notification should be sent $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(); + $employees = []; + if (in_array($client_policy['policy_type_id'], [2, 4]) || ($client_policy['policy_type_id'] == 3 && $client_policy['is_addon'] == 1)) { - // dd($employees); + // 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.is_active', 1) + ->where('employee_polices.is_active', 1) + ->where('employees.emp_status', 'draft') + ->where('employee_polices.status', 'draft') + ->where('employees.relationship', 'Self') + ->where("employees.email_corporate IS NOT NULL AND employees.email_corporate != ''") + ->findAll(); + + // dd($employees, 'first'); + + } else if (($client_policy['policy_type_id'] == 3 && $client_policy['is_addon'] == 3) || $client_policy['policy_type_id'] == 5) { + + $empDependentData = $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.is_active', 1) + ->where('employee_polices.is_active', 1) + ->where('employees.emp_status', 'draft') + ->where('employee_polices.status', 'draft') + ->where('employees.relationship !=', 'Self') + ->findAll(); + + $empCodes = array_column($empDependentData, 'emp_code'); + + // dd($empDependentData, $empCodes,'second'); + + if (!empty($empCodes)) { + + $empSelfData = $this->employeePolicyModel + ->select('employees.*, employee_polices.id as emp_policy_id') + ->join('employees', 'employee_polices.employee_id = employees.id', 'left') + ->whereIn('employees.emp_code', $empCodes) + ->where('employees.is_active', 1) + ->where('employee_polices.is_active', 1) + ->where('employees.relationship', 'Self') + ->where("employees.email_corporate IS NOT NULL AND employees.email_corporate != ''") + ->findAll(); + + $employees = array_merge($employees, $empSelfData); + } + } + + // dd($employees); // Process each employee - foreach ($employees as $employee) { + if (!empty($employees) && count($employees) > 0) { + + 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 @@ -407,8 +447,8 @@ class DashboardController extends AdminController $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_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'], @@ -421,50 +461,76 @@ class DashboardController extends AdminController $reminder_whole_mail[] = $mail_result; } } - } else { - $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 { - $currentDate = date('d'); - $remainder_dates = explode(",", $client_policy['reminder_date']); + } else { // crone - foreach ($remainder_dates as $date) { + if (!empty($client_policy['reminder_date'])) { - if ($currentDate == $date) { + $currentDate = date('d'); + $remainder_dates = explode(",", $client_policy['reminder_date']); - $client_data = $this->clientModel->find($client_policy['client_id']); + foreach ($remainder_dates as $date) { - // Fetch notification settings - $notification_data = $this->notificationModel - ->where('client_id', $client_policy['client_id']) - ->where('template_name', 'member_reminder_mail') - ->first(); + if ($currentDate == $date) { - // 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']); - // echo '4'; + // Fetch all employees related to the client policy + $employees = []; + if (in_array($client_policy['policy_type_id'], [2, 4]) || ($client_policy['policy_type_id'] == 3 && $client_policy['is_addon'] == 1)) { - $this->myLogger->logme('error', 'Notification should be sent for client policy ID: ' . $client_policy['id']); + $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.is_active', 1) + ->where('employee_polices.is_active', 1) + ->where('employees.emp_status', 'draft') + ->where('employee_polices.status', 'draft') + ->where('employees.relationship', 'Self') + ->where("employees.email_corporate IS NOT NULL AND employees.email_corporate != ''") + ->findAll(); - // 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(); + // dd($employees, 'first'); - // Process each employee - foreach ($employees as $employee) { + } else if (($client_policy['policy_type_id'] == 3 && $client_policy['is_addon'] == 3) || $client_policy['policy_type_id'] == 5) { + + $empDependentData = $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.is_active', 1) + ->where('employee_polices.is_active', 1) + ->where('employees.emp_status', 'draft') + ->where('employee_polices.status', 'draft') + ->where('employees.relationship !=', 'Self') + ->findAll(); + + $empCodes = array_column($empDependentData, 'emp_code'); + + // dd($empDependentData, $empCodes,'second'); + + if (!empty($empCodes)) { + + $empSelfData = $this->employeePolicyModel + ->select('employees.*, employee_polices.id as emp_policy_id') + ->join('employees', 'employee_polices.employee_id = employees.id', 'left') + ->whereIn('employees.emp_code', $empCodes) + ->where('employees.is_active', 1) + ->where('employee_polices.is_active', 1) + ->where('employees.relationship', 'Self') + ->where("employees.email_corporate IS NOT NULL AND employees.email_corporate != ''") + ->findAll(); + + $employees = array_merge($employees, $empSelfData); + } + } + + // 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 @@ -472,8 +538,8 @@ class DashboardController extends AdminController $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_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'], @@ -485,13 +551,19 @@ class DashboardController extends AdminController // $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 { + $this->myLogger->logme('error', "SEND REMAINDER CRONE --- Remainder date is empty()"); } } + + } else { + + $this->myLogger->logme('error', 'Notification setup not found or not enabled'); + $this->myLogger->logme('error', 'Notification was not sent for this Client ID: ' . $client_policy['client_id']); } } @@ -515,11 +587,11 @@ class DashboardController extends AdminController } } - public function sendManualReminder($client_id, $client_branch_id) + public function sendManualReminder($client_id, $client_branch_id, $client_policy_id = null) { $this->myLogger->logme('error', "sendManualRemainder called with client_id: {$client_id}, client_branch_id: {$client_branch_id}"); - $client_policy_data = $this->clientPolicyModel->getPolicyDetailsForRemainder($client_id, $client_branch_id); + $client_policy_data = $this->clientPolicyModel->getPolicyDetailsForRemainder($client_id, $client_branch_id, $client_policy_id); // print_r($client_policy_data); die; // print_r($this->clientPolicyModel->getLastQuery()); die; // $this->myLogger->logme('error', "Policy details fetched: " . json_encode($client_policy_data)); diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index 02c01d34..36650609 100755 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -711,16 +711,25 @@ class EmployeeController extends AdminController public function enrollmentClientList() { $data = []; - $client_list = $this->clientModel->findAll(); - $branch_list = $this->clientBranchModel->findAll(); + $client_list = $this->clientModel->where('clients.is_active', 1)->findAll(); + $branch_list = $this->clientBranchModel->where('client_branch.is_active', 1)->findAll(); + $policy_list = $this->clientPolicyModel + ->select('client_policy.*, policy_type.policy_type') + ->join('policy_type', 'client_policy.policy_type_id = policy_type.id') + ->where('client_policy.is_active', 1) + ->findAll(); + $data['client_list'] = $client_list; $data['branch_list'] = $branch_list; + $data['policy_list'] = $policy_list; // Get session data if available $data['selected_client_id'] = session()->get('client_id'); $data['selected_branch_id'] = session()->get('branch_id'); $data['selected_type'] = session()->get('type'); + // dd($data); + $this->myLogger->logme('error', 'list called'); return $this->loadLayout('enrollment_list', $data); diff --git a/app/Helpers/sendMailNotification.php b/app/Helpers/sendMailNotification.php index e6b6edf9..48402825 100755 --- a/app/Helpers/sendMailNotification.php +++ b/app/Helpers/sendMailNotification.php @@ -81,76 +81,18 @@ 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); - if ($emp_data && (isset($notification_data) && $notification_data['enabled'] == 1)) { - if(isset($emp_data['relationship'])){ - if ($emp_data['relationship'] == 'Self') { - if(count($emp_data) > 0){ - $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']; - } - } - }else{ - $mail =''; - } - - }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'], 'common' => $common]; - } + - }else{ - - foreach ($emp_data as $key => $value) { - if ($value['relationship'] != 'Self') { - $emp_data = $EmployeeModel->where('client_id', $client_data['id'])->where('emp_code', $value['emp_code'])->where('is_active',1)->findAll(); - if(count($emp_data) > 1){ - $mail =''; - 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']; - } - } - }else{ - $mail =''; - } - }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'], 'common' => $common]; - } - } - } + $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 (count($wholeData) < 1) { - $wholeData = []; - } + $wholeData = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails'], 'reply_to' => $client_data['reply_to'], 'common' => $common]; return $wholeData; - // }else{ - // return "false"; - // } } else if($action == 'member_ecard_mail'){ @@ -269,6 +211,8 @@ class sendMailNotification } //end of getting policy premium data + // dd($policy_premium_data); + $policy_name = $inner_item['policy_name']; if ($inner_item['relationship'] == 'Self') { @@ -282,11 +226,12 @@ class sendMailNotification $premium = ''; $gst_forself = ''; - if(checkFamilyFloaters($policy_premium_data, $client_policy_data, $inner_item)){ + // if(checkFamilyFloaters($policy_premium_data, $client_policy_data, $inner_item)){ + $si = '₹ ' .format_indian_number($inner_item['basic_cover_si']); $premium = '₹ ' .format_indian_number(round($inner_item['premium'])); $gst_forself = '₹ ' .format_indian_number(round($inner_item['gst'])); - } + // } $temp_data .= ''; $temp_data .= '' . $inner_item['name'] . ($inner_item['relationship'] == 'Self' ? ' (' . $inner_item['emp_code'] . ')' : '') . ''; diff --git a/app/Models/ClientPolicyModel.php b/app/Models/ClientPolicyModel.php index aac8cd01..7ed17d10 100755 --- a/app/Models/ClientPolicyModel.php +++ b/app/Models/ClientPolicyModel.php @@ -390,21 +390,26 @@ public function getCliendDataForExcelFileName($client_policy_id){ } //for this using in CRONE JOB -public function getPolicyDetailsForRemainder($client_id = null, $branch_id = null) +public function getPolicyDetailsForRemainder($client_id = null, $branch_id = null, $policy_id = null) { $builder = $this->table('client_policy') - ->where('client_policy.is_addon', 1) - ->where('client_policy.open_for_enrollment', 1) - ->where('client_policy.inception_type', 2) ->where('client_policy.is_active', 1) ->where('client_policy.policy_status', 1) - ->whereIn('client_policy.policy_type_id', [2, 3]); - + // ->where('client_policy.is_addon', 1) + // ->where('client_policy.inception_type', 2) + ->where('client_policy.open_for_enrollment', 1); + if ($client_id && $branch_id) { $builder->where('client_policy.client_id', $client_id) ->where('client_policy.client_branch_id', $branch_id); } + if(empty($policy_id)){ + $builder->whereIn('client_policy.policy_type_id', [2, 3, 4, 5]); + }else{ + $builder->where('client_policy.id', $policy_id); + } + return $builder->get()->getResultArray(); } diff --git a/app/Views/client_policy.php b/app/Views/client_policy.php index fd4a01a5..7a3b3911 100755 --- a/app/Views/client_policy.php +++ b/app/Views/client_policy.php @@ -175,14 +175,14 @@ -
+
@@ -827,11 +827,11 @@ } // 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_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') { @@ -1199,7 +1199,9 @@ } else if (input) { // console.log( 'input type step 2', typeof input); // Handle the case where input is a string - number = parseFloat(input.replace(/,/g, ''), 10); + // number = parseFloat(input.replace(/,/g, ''), 10); + number = parseFloat(String(input).replace(/,/g, ''), 10); + } else { // Handle the case where input is undefined or null number = NaN; // or handle as needed diff --git a/app/Views/enrollment_list.php b/app/Views/enrollment_list.php index edbdd473..d88a4619 100755 --- a/app/Views/enrollment_list.php +++ b/app/Views/enrollment_list.php @@ -17,7 +17,7 @@ /* background-color: #eb7a76; */ background-color: darkgrey; /* padding-bottom: 1px; */ - padding-top: 10px; + /* padding-top: 10px; */ } #tickets-table_filter { @@ -59,24 +59,31 @@
-
+
+
+ +
+
- +
-
+
-
+
- +
@@ -84,7 +91,7 @@
-
@@ -234,6 +241,7 @@