From 5865d9770ad3540ee6ee2f323c96e1ae279d6b1c Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Wed, 15 May 2024 16:24:57 +0530 Subject: [PATCH 1/2] FIX_SENDMAIL_NOTIFICATION_ISSUE : RV --- app/Controllers/EmpDataServiceController.php | 244 +++++++++++++++---- app/Controllers/EmployeeController.php | 8 +- app/Controllers/JobWorker.php | 2 + app/Views/client_basic_info.php | 8 +- writable/e_card_template/default.html | 119 +++++++++ 5 files changed, 329 insertions(+), 52 deletions(-) create mode 100644 writable/e_card_template/default.html diff --git a/app/Controllers/EmpDataServiceController.php b/app/Controllers/EmpDataServiceController.php index 728d81b8..826c8a6b 100644 --- a/app/Controllers/EmpDataServiceController.php +++ b/app/Controllers/EmpDataServiceController.php @@ -563,7 +563,12 @@ class EmpDataServiceController extends BaseController public function importInceptionFileValidation($params) { + $this->myLogger->logme('info', 'importInceptionFileValidation called'); + $file_id = $params['file_id']; + + $this->myLogger->logme('error', 'importInceptionFileValidation batch file table primary id : {data}', ['data' => $file_id]); + $file = $this->batchFileModel->where('id', $file_id)->first(); $client_id = $file['client_id']; $client_policy_id = $file['client_policy_id']; @@ -631,6 +636,7 @@ class EmpDataServiceController extends BaseController ]; $this->batchFileModel->where('id', $file_id)->set($data)->update(); + $this->myLogger->logme('error', 'importInceptionFileValidation TPAID already updated'); return 3; @@ -641,14 +647,22 @@ class EmpDataServiceController extends BaseController ]; $this->batchFileModel->where('id', $file_id)->set($data)->update(); + $this->myLogger->logme('error', 'importInceptionFileValidation UHID already updated'); return 5; } + + $this->myLogger->logme('error', 'importInceptionFileValidation UHID or TPAID already updated or the uploadedfile is not correct'); + } $excel_data_count = count($excel_data); $emp_data_count = count($employee_data); + $this->myLogger->logme('error', 'importInceptionFileValidation excel file count : {data}', ['data' => $excel_data_count]); + $this->myLogger->logme('error', 'importInceptionFileValidation database count : {data}', ['data' => $emp_data_count]); + + // dd($excel_data_count, $emp_data_count); $difference = $emp_data_count - $excel_data_count; @@ -657,9 +671,11 @@ class EmpDataServiceController extends BaseController $status = 'in-progress-partially'; $partially_updated_data = 'Expected : ' . $emp_data_count . ', ' . 'Updated : ' . $excel_data_count . ', ' . 'difference : ' . $difference; + $this->myLogger->logme('error', 'importInceptionFileValidation excel file count partially : {data}', ['data' => $partially_updated_data]); } + if ($emp_data_count < $excel_data_count) { $data = [ @@ -667,6 +683,8 @@ class EmpDataServiceController extends BaseController ]; $this->batchFileModel->where('id', $file_id)->set($data)->update(); + $this->myLogger->logme('error', 'importInceptionFileValidation excel file count ( {excel} ) exceeds db count ( {db} )', ['db' => $emp_data_count, 'excel' => $excel_data_count]); + return 6; } @@ -905,6 +923,8 @@ class EmpDataServiceController extends BaseController $job_details = new Jobs(); $r = Jobs::addJob(['job_name' => 'importInceptionUpdateTPAandUHID','payload' => ['file_id' => $file_id]]); + // $this->importInceptionUpdateTPAandUHID(['file_id' => $file_id]); + } } @@ -913,6 +933,8 @@ class EmpDataServiceController extends BaseController public function importInceptionUpdateTPAandUHID($params) { + $this->myLogger->logme('error', 'importInceptionUpdateTPAandUHID called'); + $file_id = $params['file_id']; $file = $this->batchFileModel->find($file_id); if (!$file) { @@ -921,6 +943,8 @@ class EmpDataServiceController extends BaseController ]; $this->batchFileModel->where('id', $file_id)->set($data)->update(); + $this->myLogger->logme('error', 'importInceptionUpdateTPAandUHID the Physical file not found - file id : {data}', ['data' => $file_id]); + return 0; // Return error code if file not found } @@ -929,13 +953,16 @@ class EmpDataServiceController extends BaseController $insurer_or_tpa = $file['insurer_or_tpa']; $status = $file['status']; $batch_code = $file['batch_code']; + $user_id = $file['created_by']; $status_val = 'success'; - if($status == 'in-progress-partially'){ + if ($status == 'in-progress-partially') { $status_val = 'partially success'; } - + + $this->myLogger->logme('error', 'importInceptionUpdateTPAandUHID file name : {data}', ['data'=> $file['file_name']]); + $file_name_with_path = WRITEPATH . "/uploads/import_excel/" . $file['file_name']; $excel_data = $this->readExcelFileToArray($file_name_with_path); @@ -943,6 +970,7 @@ class EmpDataServiceController extends BaseController array_pop($excel_data); // Remove footer row $totals = 0; + $empty_emp_tpa_uh_ids = []; $emp_count = count($excel_data); $db = \Config\Database::connect(); @@ -956,15 +984,43 @@ class EmpDataServiceController extends BaseController $totals += $amount; + + // Execute the query + $query = $db->table('employee_polices'); + $query->select('employee_polices.id'); + $query->join('employees', 'employees.id = employee_polices.employee_id'); + $query->where('employee_polices.client_policy_id', $client_policy_id); + $query->where('employees.client_id', $client_id); + $query->where('employees.name', $name); + $query->where('employees.emp_code', $emp_code); + if ($file['insurer_or_tpa'] == 'tpa') { + + $query->where('(employee_polices.tpa_id IS NULL OR employee_polices.tpa_id = "")'); + } else if ($file['insurer_or_tpa'] == 'insurer') { + + $query->where('(employee_polices.uhid IS NULL OR employee_polices.uhid = "")'); + } + $query->where('employee_polices.is_active', 1); + $query->limit(1); + + // Get the result + $result = $query->get()->getRowArray(); + if (isset($result['id']) && $result['id'] !== null) { + $empty_emp_tpa_uh_ids[] = $result['id']; + } + + + $sql = " UPDATE employee_polices JOIN employees ON employees.id = employee_polices.employee_id SET tpa_id = ? WHERE employees.name = ? AND employees.emp_code = ? + AND employee_polices.client_policy_id = ? AND (employee_polices.tpa_id IS NULL OR employee_polices.tpa_id = '')"; - $params = [$tpa_id, $name, $emp_code]; + $params = [$tpa_id, $name, $emp_code, $client_policy_id]; $db->query($sql, $params); @@ -975,9 +1031,10 @@ class EmpDataServiceController extends BaseController SET employee_polices.uhid = ? WHERE employees.name = ? AND employees.emp_code = ? + AND employee_polices.client_policy_id = ? AND (employee_polices.uhid IS NULL OR employee_polices.uhid = '')"; - $params = [$uhid, $name, $emp_code]; + $params = [$uhid, $name, $emp_code, $client_policy_id]; $db->query($sql, $params); } @@ -988,6 +1045,50 @@ class EmpDataServiceController extends BaseController 'amount' => $totals, ]); + + $this->myLogger->logme('error', 'importInceptionUpdateTPAandUHID employee count : {data}', ['data'=> $emp_count]); + $this->myLogger->logme('error', 'importInceptionUpdateTPAandUHID batch file status : {data}', ['data'=> $status_val]); + $this->myLogger->logme('error', 'importInceptionUpdateTPAandUHID total amount for cash deposite : {data}', ['data'=> $totals]); + + + if ($file['insurer_or_tpa'] == 'tpa') { + + $this->myLogger->logme('error', 'importInceptionUpdateTPAandUHID set cashDepositCalculationForInception and sendMailForDownloadingECard in JOB QUEUE'); + + $policy_name = $this->getPolicyNameUsingClientPolicyId($client_policy_id); + $depositeData = [ + 'employeeIds' => $empty_emp_tpa_uh_ids, + 'client_id' => $client_id, + 'client_policy_id' => $client_policy_id, + 'count' => $emp_count, + 'event' => $file['event_type'], + 'policy_name' => $policy_name['policy_name'], + 'user_id' => $user_id, + ]; + + + + $job_details = new Jobs(); + $r = Jobs::addJob(['job_name' => 'cashDepositCalculationForInception','payload' => [ + 'employeeIds' => $empty_emp_tpa_uh_ids, + 'client_id' => $client_id, + 'client_policy_id' => $client_policy_id, + 'count' => $emp_count, + 'event' => $file['event_type'], + 'policy_name' => $policy_name['policy_name'], + 'user_id' => $user_id, + ]]); + + + $job_details = new Jobs(); + $r = Jobs::addJob(['job_name' => 'sendMailForDownloadingECard','payload' => $empty_emp_tpa_uh_ids]); + + // $this->cashDepositCalculationForInception($depositeData); + // $this->sendMailForDownloadingECard($empty_emp_tpa_uh_ids); + + + } + return 1; } @@ -1600,6 +1701,11 @@ class EmpDataServiceController extends BaseController $insurer_id = $this->clientPolicyModel->where('id', $arrayData['client_policy_id'])->first(); $description = 'The following amount of Rs. ' . $amount->total_sum . '/- has been debited for the ' . $arrayData['count'] . ' employees at ' . remove_underscore_capitalize_first_letter($arrayData['event']) . ' to ' . remove_underscore_capitalize_first_letter($arrayData['policy_name']) . '.'; + + if(get_session_userid() == null){ + + } + $data = [ 'amount' => $amount->total_sum ?? 0, @@ -1608,10 +1714,10 @@ class EmpDataServiceController extends BaseController 'insurer_id' => $insurer_id['insurer_id'], 'description' => $description, 'transaction_type' => 'Debit', - 'updated_by' => get_session_userid(), + 'updated_by' => $arrayData['user_id'], 'is_active' => 1, ]; - $response = DepositHelper::saveDeposit($data, get_session_userid()); + $response = DepositHelper::saveDeposit($data, $arrayData['user_id']); return true; // print_r($response); // $query = $this->employeePolicyModel->getLastQuery(); @@ -1934,55 +2040,93 @@ class EmpDataServiceController extends BaseController public function sendMailForDownloadingECard(array $ids) { - try { - $count = 0; - - foreach ($ids as $key => $id) { + $this->myLogger->logme('error', 'sendMailForDownloadingECard - function called'); + if (count($ids) > 0) { - $get_emp_email_and_other_details = $this->employeePolicyModel - ->select('employee_polices.client_policy_id, employees.emp_code, employees.email_corporate,employees.client_id as client_id, employees.name, employee_polices.rand_string, employee_polices.tpa_id') - ->join('employees', 'employees.id = employee_polices.employee_id') - ->where('employees.emp_status', 'active') - ->where('employees.is_active', '1') - ->where('employee_polices.status', 'active') - ->where('employee_polices.is_active', '1') - ->where('employee_polices.id', $id)->first(); - - // echo "
";
-                    // print_r($notification);
-                    // die;
-                $client_data = $this->clientModel->where('id',$get_emp_email_and_other_details['client_id'])->first();
-                
-                $notification = $this->notificationModel->where('client_id',$get_emp_email_and_other_details['client_id'])->where('template_name','member_ecard_mail')->first();
-                if ($get_emp_email_and_other_details != null && $get_emp_email_and_other_details != "" && $notification['enabled'] == 1) {
-                    $rand_string =  $get_emp_email_and_other_details['rand_string'];
-                    $tpa_id =  $get_emp_email_and_other_details['tpa_id'];
-                    
-                    $params['rand_string'] = $rand_string;
-                    $params['tpa_id'] = $tpa_id;
-                    $params['notification'] = $notification;
-                    $params['client_data'] = $client_data;
-                    $params['notification'] = $notification;
-                    $params['notification'] = $notification;
-                    $params['get_emp_email_and_other_details'] = $get_emp_email_and_other_details;
-                    $wholeData = sendMailNotification::sendMailNotification('member_ecard_mail', $params);
-                    
-                    $count++;
+            $temp_id = $ids[0];
+
+            $get_client_info_for_notification = $this->employeePolicyModel
+                ->select('employee_polices.client_policy_id, employees.emp_code, employees.email_corporate,employees.client_id as client_id, employees.name, employee_polices.rand_string, employee_polices.tpa_id')
+                ->join('employees', 'employees.id = employee_polices.employee_id')
+                ->where('employees.emp_status', 'active')
+                ->where('employees.is_active', '1')
+                ->where('employee_polices.status', 'active')
+                ->where('employee_polices.is_active', '1')
+                ->where('employee_polices.id', $ids[0])->first();
+
+            $client_data = $this->clientModel->where('id', $get_client_info_for_notification['client_id'])->first();
+            $notification = $this->notificationModel->where('client_id', $get_client_info_for_notification['client_id'])->where('template_name', 'member_ecard_mail')->first();
+
+            if ($notification != null && !empty($notification) && $notification['enabled'] == 1) {
+
+                try {
+
+                    $this->myLogger->logme('error', 'sendMailForDownloadingECard - inside try');
+                    $count = 0;
+                    foreach ($ids as $key => $id) {
+
+                        $get_emp_email_and_other_details = $this->employeePolicyModel
+                            ->select('employee_polices.client_policy_id, employees.emp_code, employees.email_corporate,employees.client_id as client_id, employees.name, employee_polices.rand_string, employee_polices.tpa_id')
+                            ->join('employees', 'employees.id = employee_polices.employee_id')
+                            ->where('employees.emp_status', 'active')
+                            ->where('employees.is_active', '1')
+                            ->where('employee_polices.status', 'active')
+                            ->where('employee_polices.is_active', '1')
+                            ->where('employee_polices.id', $id)->first();
+
+                        $this->myLogger->logme('error', 'sendMailForDownloadingECard - emp_policy_id : {id}', ['id' => $id]);
+
+                        if ($get_emp_email_and_other_details != null && !empty($get_emp_email_and_other_details)) {
+
+                            $this->myLogger->logme('error', 'sendMailForDownloadingECard - Send Bulk Mail function inside if condition ',);
 
 
-                    if($count == 20 || $count == count($ids)-1){
-                        $job_details  = new Jobs();
-                        $r = Jobs::addJob(['job_name' => 'bulk_mail','payload' => $wholeData]); 
-                        $wholeData = [];
-                        $count = 0;
-                    }    
+                            $rand_string =  $get_emp_email_and_other_details['rand_string'];
+                            $tpa_id =  $get_emp_email_and_other_details['tpa_id'];
+
+                            $params['rand_string'] = $rand_string;
+                            $params['tpa_id'] = $tpa_id;
+                            $params['notification'] = $notification;
+                            $params['client_data'] = $client_data;
+                            $params['notification'] = $notification;
+                            $params['notification'] = $notification;
+                            $params['get_emp_email_and_other_details'] = $get_emp_email_and_other_details;
+                            $wholeData[] = sendMailNotification::sendMailNotification('member_ecard_mail', $params);
+
+                            $count++;
+
+
+                            if ($count == 20 || $count == count($ids) - 1) {
+
+                                $this->myLogger->logme('error', 'sendMailForDownloadingECard - create a job to bulk mail',);
+
+                                $job_details  = new Jobs();
+                                $r = Jobs::addJob(['job_name' => 'bulk_mail', 'payload' => $wholeData]);
+                                $wholeData = [];
+                                $count = 0;
+                            }
+
+                            $this->myLogger->logme('error', 'sendMailForDownloadingECard - Send Bulk Mail function end ',);
+                        }
+                    }
+                    return true; // Email(s) sent successfully
+
+                } catch (\Exception $e) {
+
+                    // Log the error
+                    $this->myLogger->logme('error', 'sendMailForDownloadingECard : inside catch');
+                    $this->myLogger->logme('error', 'Error occurred while sending email: ' . $e->getMessage());
+                    return false; // Email(s) sending failed
                 }
+            } else {
+
+                $this->myLogger->logme('error', 'sendMailForDownloadingECard - the client notification setup not created or not enabled the E-Card Notification');
+                return false;
             }
-            return true; // Email(s) sent successfully
-        } catch (\Exception $e) {
-            // Log the error
-            $this->myLogger->log('error', 'Error occurred while sending email: ' . $e->getMessage());
-            return false; // Email(s) sending failed
+        } else {
+
+            $this->myLogger->logme('error', 'sendMailForDownloadingECard - employee_policy_ids are empty');
+            return false;
         }
     }
 
diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php
index 2409f694..5692668a 100644
--- a/app/Controllers/EmployeeController.php
+++ b/app/Controllers/EmployeeController.php
@@ -421,7 +421,7 @@ class EmployeeController extends AdminController
         
                 $return = 1;
 
-                // $return = $empDataServiceController->importExcelDataForInception($batch_data);
+                // $return = $empDataServiceController->importInceptionFileValidation(['file_id' => $file_id]);
 
                 if ($return == 1) {
                     session()->setFlashdata('success', 'Data updated successfully. File is being validated.');
@@ -855,11 +855,15 @@ class EmployeeController extends AdminController
 
             // $data['data'] = $this->employeePolicyModel->getECardDataUsingMd5($client_policy_id, $emp_code);
             $data = $this->employeePolicyModel->getECardDataUsingMd5($client_policy_id, $emp_code);
+            
+            // dd($data);
 
             $template_data_path =  WRITEPATH . 'e_card_template/';
             $tpa_short_name = strtolower(str_replace(' ', '_', $get_emp_code_and_client_policy_id['short_name'])) . '.html';
             $final_path =  $template_data_path . $tpa_short_name;
 
+            // dd($template_data_path, $tpa_short_name, $final_path);
+
             if (!file_exists($final_path)) {
 
                 $data['message'] = 'Record Not Found';
@@ -868,6 +872,7 @@ class EmployeeController extends AdminController
 
             $tmplt_data = file_get_contents($final_path);
 
+            // dd($tmplt_data);
 
             $html = ""; // Initialize the HTML variable
             foreach ($data as $key => $value) {
@@ -892,6 +897,7 @@ class EmployeeController extends AdminController
                     '{EMP_ID}' =>$value['emp_code'],
                     '{CORPORATE_NAME}' =>$value['client_name'],
                     '{AGE}' =>$value['emp_age'],
+                    '{TPA_NAME}' =>$value['emp_age'],
                 ];
                 
                 // Replace placeholders with values in HTML content
diff --git a/app/Controllers/JobWorker.php b/app/Controllers/JobWorker.php
index 9ae90d51..8d81699f 100644
--- a/app/Controllers/JobWorker.php
+++ b/app/Controllers/JobWorker.php
@@ -18,6 +18,8 @@ class JobWorker extends AdminController
         'add' => ['type' => 'HC', 'handler' => 'App\\Helpers\\HttpRequestHelper'], 'sub' =>  ['type' => 'CC', 'handler' => 'App\\Controllers\\Jobs\SubJob'], 'fancy_date_time_format' => ['type' => 'HF', 'handler' => 'fancy_date_time_format'], 'addNumber' => ['type' => 'HC', 'handler' => 'App\\Model\\HttpRequestHelper'], 'excelFileFormatValidation' => ['type' => 'CC', 'handler' => 'App\\Controllers\\EmployeeServiceController'], 'excelFileDataValidation' => ['type' => 'CC', 'handler' => 'App\\Controllers\\EmployeeServiceController'], 'employeesOnboardPreprocess' => ['type' => 'CC', 'handler' => 'App\\Controllers\\EmployeeServiceController'], 'employeeDisembark' => ['type' => 'CC', 'handler' => 'App\\Controllers\\EmployeeServiceController'], 'employeesSIEnhanceProcess' => ['type' => 'CC', 'handler' => 'App\\Controllers\\EmployeeServiceController'], 'employeesCorrectionProcess' => ['type' => 'CC', 'handler' => 'App\\Controllers\\EmployeeServiceController'], 'send_email' => ['type' => 'HC', 'handler' => 'App\\Helpers\\MailHelper'], 'bulk_mail' => ['type' => 'HC', 'handler' => 'App\\Helpers\\MailHelper'], 'insertBatchList' => ['type' => 'CC', 'handler' => 'App\\Controllers\\EmpDataServiceController'],
         'importInceptionFileValidation' => ['type' => 'CC', 'handler' => 'App\\Controllers\\EmpDataServiceController'],
         'importInceptionUpdateTPAandUHID' => ['type' => 'CC', 'handler' => 'App\\Controllers\\EmpDataServiceController'],
+        'cashDepositCalculationForInception' => ['type' => 'CC', 'handler' => 'App\\Controllers\\EmpDataServiceController'],
+        'sendMailForDownloadingECard' => ['type' => 'CC', 'handler' => 'App\\Controllers\\EmpDataServiceController'],
     ];
     public function __construct()
     {
diff --git a/app/Views/client_basic_info.php b/app/Views/client_basic_info.php
index 68749f6f..1fc76c70 100644
--- a/app/Views/client_basic_info.php
+++ b/app/Views/client_basic_info.php
@@ -263,6 +263,13 @@ input:checked + .slider:before {
                 success: function(res) {
 
                     console.log(res);
+                    console.log($('#general_PrimaryKey').val());
+
+                    if($('#general_PrimaryKey').val() == ""){
+
+                        window.location.href = '' + res.data.id;
+                    }
+
 
                     if(res){
                         setTimeout(function() {
@@ -300,7 +307,6 @@ input:checked + .slider:before {
 
 
                     var client_id_for_file = res.data.id;
-                    console.log()
 
                     if(PrimaryKey === ''){
                         $.ajax({
diff --git a/writable/e_card_template/default.html b/writable/e_card_template/default.html
new file mode 100644
index 00000000..f0aac7c3
--- /dev/null
+++ b/writable/e_card_template/default.html
@@ -0,0 +1,119 @@
+
+
+    
+ +
+ +
+
+
THE NEW + INDIA ASSURANCE CO.LTD.
GOOD HEALTH MEDICLAIM + POLICY
+
+ + + + + + + + + + + + + + + + + + + + + + +
MDID : {TPA_ID}
{NAME}
Certificate No : {UHID}
Sex : {GENDER} Date of Birth : {DOB} +
{SELF_NAME}
Valid form :{POLICY_DATE}
+
+ +
+
The card is for identification purpose only
+ + + + + + + +
General & Claim Enquiry HelplineCashless Enquiry helpline
+ + + + + + + + + +
Toll Free : 1800-209-7777
Email : + citibank_chennai@mdindia.com
Toll Free : 1800-209-7800
Email: + authorisation@mdindia.com
+
CITI MDIndia branch contact
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
CenterPh.No/Fax.No.CenterPh.No/Fax.No.
Chennai9381819401Delhi9310596976
Chennai9381819501Mumbai9320373542
Hyderabad9390838023Pune9371644536
Bangalore9341555665Kolkata9333441389
+
+
+
TERMS AND CONDITIONS
+
    +
  1. Pre authorisation is compulsary from tpa prior to planned admission within 24hours for + emergencies.
  2. +
  3. Admission for Investigation/Evaluation Not covered.
  4. +
  5. All terms and conditions of the policy would be applicable
  6. +
  7. cashless hospitalisation in network hospitals can be obtained in conjunction with this card.an + authorisation letter issued by tpa and photo identification and such as Voters ID,Driver + Licence,Passport,etc.
  8. +
+
+
+
+ + + From c509399f919c0f822d458d10b61fcbe818d54f10 Mon Sep 17 00:00:00 2001 From: aadhavan valli Date: Wed, 15 May 2024 16:28:22 +0530 Subject: [PATCH 2/2] CHANGE_NOTIFICATION_CHECKS_GMS_EDIT_AGE_ISSUE : AADHAVAN --- app/Controllers/ClientController.php | 24 +++++----- app/Controllers/EmpDataServiceController.php | 47 ++++++++++---------- app/Controllers/EmployeeRestController.php | 42 +++++++++-------- app/Helpers/MailHelper.php | 2 - app/Views/client_onboarding.php | 14 +++--- app/Views/notification.php | 26 ++++++----- app/Views/policy_gmc_terms.php | 24 ++++++++-- 7 files changed, 102 insertions(+), 77 deletions(-) diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index a6cd25ce..8b0c17ee 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -168,6 +168,8 @@ class ClientController extends AdminController // echo "
";
         // print_r($data); die;
+        $data['placeHolders'] = ['member_name','nhance_logo','tpa_id','ecard_download_link', 'client_logo', 'policy_no', 'member_summary', 'app_link', 'client_name'];
+
 
         echo view('layout/header', $headerData);
         echo view('client_onboarding', $data);
@@ -1241,19 +1243,19 @@ class ClientController extends AdminController
             $client_policy_id = $this->request->getPost("client_policy_id");
 
             $data['sum_insured']   =str_replace(',', '',$this->request->getPost("sum_insured"));
-            $data['family_floater']   =$this->request->getPost("family_floater");
-            $data['corporatebuffer'] = $this->request->getPost("corporatebuffer");
+            $data['family_floater']   =$this->request->getPost("family_floater") ? $this->request->getPost("family_floater") : 0;
+            $data['corporatebuffer'] = $this->request->getPost("corporatebuffer") ? $this->request->getPost("corporatebuffer") : 0;
             $data['family_floaters'] = $this->request->getPost("family_floaters") ?? [];        
             
             // print_r($this->request->getPost());die;
-            $data['age_ratio']['self']['min'] = $this->request->getPost("self_min_age");
-            $data['age_ratio']['self']['max'] = $this->request->getPost("self_max_age");
-            $data['age_ratio']['spouse']['min'] = $this->request->getPost("spouse_min_age");
-            $data['age_ratio']['spouse']['max'] = $this->request->getPost("spouse_max_age");
-            $data['age_ratio']['child']['min'] = $this->request->getPost("child_min_age");
-            $data['age_ratio']['child']['max'] = $this->request->getPost("child_max_age");
-            $data['age_ratio']['elders']['min'] = $this->request->getPost("other_member_min_age");
-            $data['age_ratio']['elders']['max'] = $this->request->getPost("other_member_max_age");
+            $data['age_ratio']['self']['min'] =  $this->request->getPost("self_min_age") ? $this->request->getPost("self_min_age") :0;
+            $data['age_ratio']['self']['max'] = $this->request->getPost("self_max_age") ? $this->request->getPost("self_max_age") : 0;
+            $data['age_ratio']['spouse']['min'] = $this->request->getPost("spouse_min_age") ? $this->request->getPost("spouse_min_age") : 0;
+            $data['age_ratio']['spouse']['max'] = $this->request->getPost("spouse_max_age") ? $this->request->getPost("spouse_max_age") : 0;
+            $data['age_ratio']['child']['min'] = $this->request->getPost("child_min_age") ? $this->request->getPost("child_min_age") : 0;
+            $data['age_ratio']['child']['max'] = $this->request->getPost("child_max_age") ? $this->request->getPost("child_max_age") : 0;
+            $data['age_ratio']['elders']['min'] = $this->request->getPost("other_member_min_age") ? $this->request->getPost("other_member_min_age") :0;
+            $data['age_ratio']['elders']['max'] = $this->request->getPost("other_member_min_age") ? $this->request->getPost("other_member_min_age") : 0;
 
 
 
@@ -1327,7 +1329,7 @@ class ClientController extends AdminController
                         }
                     }
 
-                    $data['family_floaters']['elders_count'] =$this->request->getPost("member_count");
+                    $data['family_floaters']['elders_count'] =$this->request->getPost("member_count") ? $this->request->getPost("member_count") : 0;
 
             $data['waiverofpreexistingdiseases']   =$this->request->getPost("waiverofpreexistingdiseases");
             if ($data['waiverofpreexistingdiseases'] == 1) {
diff --git a/app/Controllers/EmpDataServiceController.php b/app/Controllers/EmpDataServiceController.php
index 728d81b8..7b5a599f 100644
--- a/app/Controllers/EmpDataServiceController.php
+++ b/app/Controllers/EmpDataServiceController.php
@@ -1954,29 +1954,30 @@ class EmpDataServiceController extends BaseController
                 $client_data = $this->clientModel->where('id',$get_emp_email_and_other_details['client_id'])->first();
                 
                 $notification = $this->notificationModel->where('client_id',$get_emp_email_and_other_details['client_id'])->where('template_name','member_ecard_mail')->first();
-                if ($get_emp_email_and_other_details != null && $get_emp_email_and_other_details != "" && $notification['enabled'] == 1) {
-                    $rand_string =  $get_emp_email_and_other_details['rand_string'];
-                    $tpa_id =  $get_emp_email_and_other_details['tpa_id'];
-                    
-                    $params['rand_string'] = $rand_string;
-                    $params['tpa_id'] = $tpa_id;
-                    $params['notification'] = $notification;
-                    $params['client_data'] = $client_data;
-                    $params['notification'] = $notification;
-                    $params['notification'] = $notification;
-                    $params['get_emp_email_and_other_details'] = $get_emp_email_and_other_details;
-                    $wholeData = sendMailNotification::sendMailNotification('member_ecard_mail', $params);
-                    
-                    $count++;
-
-
-                    if($count == 20 || $count == count($ids)-1){
-                        $job_details  = new Jobs();
-                        $r = Jobs::addJob(['job_name' => 'bulk_mail','payload' => $wholeData]); 
-                        $wholeData = [];
-                        $count = 0;
-                    }    
-                }
+                    if ($get_emp_email_and_other_details != null && $get_emp_email_and_other_details != "" && $notification['enabled'] == 1) {
+                        $rand_string =  $get_emp_email_and_other_details['rand_string'];
+                        $tpa_id =  $get_emp_email_and_other_details['tpa_id'];
+                        
+                        $params['rand_string'] = $rand_string;
+                        $params['tpa_id'] = $tpa_id;
+                        $params['notification'] = $notification;
+                        $params['client_data'] = $client_data;
+                        $params['notification'] = $notification;
+                        $params['notification'] = $notification;
+                        $params['get_emp_email_and_other_details'] = $get_emp_email_and_other_details;
+                        $wholeData = sendMailNotification::sendMailNotification('member_ecard_mail', $params);
+                        
+                        $count++;
+    
+    
+                        if($count == 20 || $count == count($ids)-1){
+                            $job_details  = new Jobs();
+                            $r = Jobs::addJob(['job_name' => 'bulk_mail','payload' => $wholeData]); 
+                            $wholeData = [];
+                            $count = 0;
+                        }    
+                    }
+                
             }
             return true; // Email(s) sent successfully
         } catch (\Exception $e) {
diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php
index 3c8a145d..1fa06237 100644
--- a/app/Controllers/EmployeeRestController.php
+++ b/app/Controllers/EmployeeRestController.php
@@ -618,7 +618,6 @@ class EmployeeRestController extends AdminController
 
             $client_data = $this->clientModel->where('id', $client_id)->first();
 
-            $notification = $this->notificationModel->where('client_id',$client_id)->where('template_name','member_welcome_mail')->first();
 
             $jwt = $this->request->getHeader('Authorization');
             $jwtParts = explode(' ', $jwt);
@@ -874,8 +873,9 @@ class EmployeeRestController extends AdminController
                         $emp_policy = $this->employeePolicyModel->insert($emp_policy_data);
                     }
 
+                    $notification = $this->notificationModel->where('client_id',$client_id)->where('template_name','member_welcome_mail')->first();
 
-                    if ($notification['enabled'] == 1) {
+                    if (isset($notification) && $notification['enabled'] == 1) {
                         //trigger
                         if ($dataToInsert[$a]['relationship'] == 'Self') {
                             
@@ -900,7 +900,6 @@ class EmployeeRestController extends AdminController
                         // if ($dataToInsert[$a]['email_corporate'] != null || $dataToInsert[$a]['email_corporate'] != ''  &&  $dataToInsert[$a]['relationship'] == 'Self') {
                         
                     }
-                
                 }
             return $this->respond(['status' => 'success', 'code' => 200, 'message' => "Success" ], 200);
             }else{
@@ -1650,26 +1649,33 @@ public function iAgreeForAddOn()
             $find = $this->employeeModel->getEmpFamilybyEmpCode(client_policy_id: $value,emp_code: $emp_code,client_id: $client_id,emp_status:['draft','enrolled'],policy_status:['draft','enrolled']);
             $array_list[] = $find;
         }
-        $params ['array_list'] = $array_list;
-        $params ['client_policy_id'] = $client_policy_id;
-        $params ['emp_code'] = $emp_code;
-        $params ['client_id'] = $client_id;
-        $wholeData =sendMailNotification::sendMailNotification('member_review_and_summary_mail', $params);
 
-        MailHelper::send_email($wholeData[0]);
+        $notification = $this->notificationModel->where('client_id' ,$client_id)->where('template_name', 'member_review_and_summary_mail')->first();
 
-        if (isset($wholeData[0])) {
-            
-            $account_manager_wholeData =sendMailNotification::sendMailNotification('account_maneger_summary_mail', $params);
 
-            foreach ($account_manager_wholeData as $key => $value) {
-                MailHelper::send_email($value);
-            }
+        if (isset($notification) && $notification['enabled'] == 1) {
+            $params ['array_list'] = $array_list;
+            $params ['client_policy_id'] = $client_policy_id;
+            $params ['emp_code'] = $emp_code;
+            $params ['client_id'] = $client_id;
+            $params ['notification'] = $notification;
 
-            $client_hr_wholeData =sendMailNotification::sendMailNotification('client_hr_summary_mail', $params);
+            $wholeData =sendMailNotification::sendMailNotification('member_review_and_summary_mail', $params);
+            MailHelper::send_email($wholeData[0]);
 
-            foreach ($client_hr_wholeData as $key => $value) {
-                MailHelper::send_email($value);
+            if (isset($wholeData[0])) {
+                
+                $account_manager_wholeData =sendMailNotification::sendMailNotification('account_maneger_summary_mail', $params);
+
+                foreach ($account_manager_wholeData as $key => $value) {
+                    MailHelper::send_email($value);
+                }
+
+                $client_hr_wholeData =sendMailNotification::sendMailNotification('client_hr_summary_mail', $params);
+
+                foreach ($client_hr_wholeData as $key => $value) {
+                    MailHelper::send_email($value);
+                }
             }
         }
 
diff --git a/app/Helpers/MailHelper.php b/app/Helpers/MailHelper.php
index 55d17264..da8d2624 100644
--- a/app/Helpers/MailHelper.php
+++ b/app/Helpers/MailHelper.php
@@ -58,7 +58,6 @@ class MailHelper
         }  
     }
 
-
     public static function bulk_mail(array $mails = [])
     {
         // print_r();die;
@@ -78,6 +77,5 @@ class MailHelper
        }
     }
 
-
 }
 ?>
\ No newline at end of file
diff --git a/app/Views/client_onboarding.php b/app/Views/client_onboarding.php
index 5ae22d1a..9ff286b9 100644
--- a/app/Views/client_onboarding.php
+++ b/app/Views/client_onboarding.php
@@ -201,11 +201,11 @@ body {
         
 
         if(check_client_id[0].value == '' || check_client_id[0].value == null || check_client_id[0].value == 0){
-            $('#btnBranchAdd').hide();
+            $('#notification-tab').hide();
             toastr.warning('Please Add the Client!', 'warning',{timeOut: 2000});
         }else{
-            if ($('#btnBranchBack')[0].style.display == 'none') {
-                $('#btnBranchAdd').show();
+            if ($('#notification-tab')[0].style.display == 'none') {
+                $('#notification-tab').show();
             }
         }
         
@@ -236,10 +236,10 @@ body {
         client_branch_contact();
     });
 
-    // document.getElementById("notification_tab").addEventListener("click", function(event) {
-    //     event.preventDefault();
-    //     client_notification();
-    // });
+    document.getElementById("notification_tab").addEventListener("click", function(event) {
+        event.preventDefault();
+        client_notification();
+    });
     
 
 
diff --git a/app/Views/notification.php b/app/Views/notification.php
index 99a03358..124094f5 100644
--- a/app/Views/notification.php
+++ b/app/Views/notification.php
@@ -25,6 +25,7 @@
             $member_review_and_summary_mail = 0;
             $account_maneger_summary_mail = 0;
             $client_hr_summary_mail = 0;
+            if(isset($notification)){
             foreach($notification as $value){
                 
                 if ($value['template_name'] == 'member_welcome_mail') {
@@ -50,6 +51,7 @@
                 if ($value['template_name'] == 'client_hr_summary_mail') {
                     $client_hr_summary_mail = $value['enabled'];
                 }
+            }
             }
              ?>

@@ -57,15 +59,15 @@
- +
- +
-
+
-
- +
+
-
+
-
+
-
+
-
+
@@ -293,7 +295,7 @@
-
Min Age:
+
Min Age:
Max Age:
Spouse: -
Min Age:
+
Min Age:
Max Age:
@@ -686,8 +686,8 @@ if (!$('#self').prop('checked')) { - $('#self_min_age').removeAttr('name') - $('#self_max_age').removeAttr('name') + $('#self_min_age').removeAttr('name'); + $('#self_max_age').removeAttr('name'); } if (!$('#spouse').prop('checked')) { @@ -1040,6 +1040,9 @@ if ($('#spouse').prop('checked')) { $('.spouse-age').css('display',''); + $('#spouse_min_age').val(18); + $('#spouse_max_age').val(60); + } else { $('.spouse-age').css('display','none'); } @@ -1253,6 +1256,12 @@ $('#spouse').change(function () { if ($(this).prop('checked')) { $('.spouse-age').css('display',''); + if($('#spouse_min_age').val() < 0 || $('#spouse_min_age').val() == '' ){ + $('#spouse_min_age').val(18); + } + if($('#spouse_max_age').val() < 0 || $('#spouse_max_age').val() == '' ){ + $('#spouse_max_age').val(60); + } }else{ $('.spouse-age').css('display','none'); } @@ -1262,6 +1271,13 @@ $('#children').change(function () { if ($(this).val() != 0) { $('.child-age').css('display',''); + + if($('#child_min_age').val() < 0 || $('#child_min_age').val() == '' ){ + $('#child_min_age').val(0); + } + if($('#child_max_age').val() < 0 || $('#child_max_age').val() == '' ){ + $('#child_max_age').val(25); + } }else{ $('.child-age').css('display','none'); }