From 0c6be0aaebadfd2338e2f698684a067fd372d9fa Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Thu, 9 May 2024 10:27:56 +0530 Subject: [PATCH 1/6] FIX_CLIENT_POLICY_EDIT_HIDE_AND_SHOW_ISSUE : RV --- app/Views/client_policy.php | 67 ++++++++++++++++++++++++++++--------- 1 file changed, 52 insertions(+), 15 deletions(-) diff --git a/app/Views/client_policy.php b/app/Views/client_policy.php index fb5cd99f..ff519275 100644 --- a/app/Views/client_policy.php +++ b/app/Views/client_policy.php @@ -549,26 +549,39 @@ // appendPolicyFormFields(2); // } - if (dataId == 3) { + if($('#policy_type').val() == 1){ - var displayStatus = $('#base_policy_id').css('display'); - $('#base_policy_id').show(); - $('#base_policy').prop('required', true); + console.log('step 1') - if (displayStatus === 'none') { - $('#base_policy').val('').change(); - } + if (dataId == 3) { - // $('#base_policy').find('option[data-id="3"]').hide(); + console.log('step 2') - } else { + var displayStatus = $('#base_policy_id').css('display'); + $('#base_policy_id').show(); + $('#base_policy').prop('required', true); - var displayStatus = $('#base_policy_id').css('display'); - $('#base_policy_id').hide(); - $('#base_policy').prop('required', false); + if (displayStatus === 'none') { + console.log('step 2.1') - if (displayStatus === 'none') { - $('#base_policy').val('').change(); + $('#base_policy').val('').change(); + } + + // $('#base_policy').find('option[data-id="3"]').hide(); + + } else { + + console.log('step 3') + + var displayStatus = $('#base_policy_id').css('display'); + $('#base_policy_id').hide(); + $('#base_policy').prop('required', false); + + if (displayStatus === 'none') { + console.log('step 3.1') + + $('#base_policy').val('').change(); + } } } @@ -648,7 +661,28 @@ $('#base_policy').prop('required', false); } + + if(res.data.is_addon == 1 && res.data.base_policy > 0){ + + // $("#insurer").next(".select2-container").css({ + // 'pointer-events': 'none', + // }); + // $('#select2-insurer-container').css({ + // 'background-color': '#ebebe0', + // }); + + // $("#tpa").next(".select2-container").css({ + // 'pointer-events': 'none', + // }); + // $('#select2-tpa-container').css({ + // 'background-color': '#ebebe0', + // }); + + } + + if (res.data.is_addon == 2 || res.data.is_addon == 3) { + $("#insurer").next(".select2-container").css({ 'pointer-events': 'none', }); @@ -693,14 +727,17 @@ $.each(res.client_policy_list, function(index, item) { OptionsHTML += ''; + 'selected="selected"' : '') + '>' + item.name + '( ' + item.policy_type + ' )'; }); $('#base_policy').html(OptionsHTML); setTimeout(function() { $('#policy').val(res.data.policy_id).change(); + $('#base_policy').val(res.data.base_policy); + $('#base_policy').change(); }, 3000); + }, error: function(xhr, status, error) { console.error(xhr.responseText); From 8d3ba5376cae360fb58b6f1dcc544b6fae7d4593 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Thu, 9 May 2024 12:12:01 +0530 Subject: [PATCH 2/6] FIX_INCEPTION_TYPE_CHANGE_1_SWITCH_OFF_2_SWITCH_ON : RV --- app/Controllers/EmpDataServiceController.php | 18 +++++++++++++++--- app/Views/client_policy.php | 2 +- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/app/Controllers/EmpDataServiceController.php b/app/Controllers/EmpDataServiceController.php index 5e1a1adb..123e741f 100644 --- a/app/Controllers/EmpDataServiceController.php +++ b/app/Controllers/EmpDataServiceController.php @@ -27,6 +27,7 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Reader\Xlsx; use PhpOffice\PhpSpreadsheet\IOFactory; use PhpOffice\PhpSpreadsheet\Reader\Exception as SpreadsheetReaderException; +use PhpParser\Node\Expr\Cast\Double; use function PHPUnit\Framework\returnSelf; @@ -108,16 +109,27 @@ class EmpDataServiceController extends BaseController { // Fetch employee data for export from the database $objects = $this->employeePolicyModel->getInceptionEmployeeDataForExportExcel($export_data); + + $insurer_id = $this->clientPolicyModel->where('id', $export_data['client_policy_id'])->first(); - // dd($objects); - + $cash_balance = $this->clientDepositModel->where('client_id',$export_data['client_id'] )->where('insurer_id', $insurer_id['insurer_id'])->orderBy('id', 'DESC')->first(); + + $totals = 0; foreach ($objects as $key => $value) { $totals += $value->total; } - + // dd((Double) $totals, $insurer_id['insurer_id'], (Double) $cash_balance['balance']); + + if((int) $totals < (int) $cash_balance['balance']){ + + dd($totals, $insurer_id['insurer_id'], $cash_balance['balance']); + } + + dd($totals); + // Log the count of exported data $count = count($objects); $export_data['count'] = $count; diff --git a/app/Views/client_policy.php b/app/Views/client_policy.php index ff519275..e9174cf8 100644 --- a/app/Views/client_policy.php +++ b/app/Views/client_policy.php @@ -634,7 +634,7 @@ $('#policy_status').val(checkDateStatus(res.data.policy_end_date)); $('#policy_status_field').show(); - if (res.data.inception_type == 1) { + if (res.data.inception_type == 2) { $('#inception_type').prop('checked', true); } else { $('#inception_type').prop('checked', false); From d7021c52109a95fb53e32228a4e249fac87169fb Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Thu, 9 May 2024 12:19:05 +0530 Subject: [PATCH 3/6] FIX_CHANGE_CONTROLLER : RV --- app/Controllers/ClientController.php | 4 ++-- app/Controllers/EmpDataServiceController.php | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 73d1cc0b..25d0064f 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -609,7 +609,7 @@ class ClientController extends AdminController $data['is_addon'] = $this->request->getPost('is_addon'); $data['base_policy'] = $this->request->getPost('base_policy'); $data['policy_status'] = 1; - $data['inception_type'] = $this->request->getPost('inception_type') ? 1 : 2; + $data['inception_type'] = $this->request->getPost('inception_type') ? 2 : 1; @@ -701,7 +701,7 @@ class ClientController extends AdminController $data['is_addon'] = $this->request->getPost('is_addon'); $data['base_policy'] = $this->request->getPost('base_policy'); $data['policy_status'] = 1; - $data['inception_type'] = $this->request->getPost('inception_type') ? 1 : 2; + $data['inception_type'] = $this->request->getPost('inception_type') ? 2 : 1; $policy_terms = $this->clientPolicyModel->where('id', $this->request->getPost('base_policy'))->first(); diff --git a/app/Controllers/EmpDataServiceController.php b/app/Controllers/EmpDataServiceController.php index 123e741f..f6871c13 100644 --- a/app/Controllers/EmpDataServiceController.php +++ b/app/Controllers/EmpDataServiceController.php @@ -123,12 +123,12 @@ class EmpDataServiceController extends BaseController // dd((Double) $totals, $insurer_id['insurer_id'], (Double) $cash_balance['balance']); - if((int) $totals < (int) $cash_balance['balance']){ + // if((int) $totals < (int) $cash_balance['balance']){ - dd($totals, $insurer_id['insurer_id'], $cash_balance['balance']); - } + // dd($totals, $insurer_id['insurer_id'], $cash_balance['balance']); + // } - dd($totals); + // dd($totals); // Log the count of exported data $count = count($objects); From 585d3bb9d9250f08b13017d6ad5360008cd558fc Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Thu, 9 May 2024 13:54:16 +0530 Subject: [PATCH 4/6] FIX_EXPORT_EXCEL_CHECK_CASH_DEPOSITE_AMT : RV --- app/Controllers/EmpDataServiceController.php | 9 +++------ app/Controllers/EmployeeController.php | 9 +++++++++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/Controllers/EmpDataServiceController.php b/app/Controllers/EmpDataServiceController.php index f6871c13..af0710f0 100644 --- a/app/Controllers/EmpDataServiceController.php +++ b/app/Controllers/EmpDataServiceController.php @@ -121,14 +121,11 @@ class EmpDataServiceController extends BaseController $totals += $value->total; } - // dd((Double) $totals, $insurer_id['insurer_id'], (Double) $cash_balance['balance']); + if((int) $cash_balance['balance'] < (int) $totals){ - // if((int) $totals < (int) $cash_balance['balance']){ + return 0; + } - // dd($totals, $insurer_id['insurer_id'], $cash_balance['balance']); - // } - - // dd($totals); // Log the count of exported data $count = count($objects); diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index ff465d78..b1b33241 100644 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -345,7 +345,15 @@ class EmployeeController extends AdminController if ($event_type == 'inception' || $event_type == 'addition' || $event_type == 'dependent_addition') { $return = $empDataServiceController->generateExcelForAdditionandInception($batch_data); + + if($return == 0){ + + session()->setFlashdata('error', "The insurer has an insufficient deposit amount."); + return redirect()->to(base_url('employee/upload')); + } + if (!$return) { + if ($insurer_or_tpa == 'tpa') { session()->setFlashdata('error', "No data was found for this action. The TPA ID has already been updated."); return redirect()->to(base_url('employee/upload')); @@ -353,6 +361,7 @@ class EmployeeController extends AdminController session()->setFlashdata('error', "No data was found for this action. The UHID has already been updated."); return redirect()->to(base_url('employee/upload')); } + } else { $this->myLogger->logme('error', 'Successfully exported Excel file in {data}.', ['data' => $event_type]); } From 188618718c5f596dd4ced52faec3df8dccda3f1d Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Thu, 9 May 2024 16:28:16 +0530 Subject: [PATCH 5/6] FIX_RACK_RATE_TYPE_6_AGE_ISSUE : RV --- app/Views/policy_grid.php | 115 ++++++++++++++++++++++++++++---------- 1 file changed, 86 insertions(+), 29 deletions(-) diff --git a/app/Views/policy_grid.php b/app/Views/policy_grid.php index 7a80de32..9b52fbbb 100644 --- a/app/Views/policy_grid.php +++ b/app/Views/policy_grid.php @@ -272,11 +272,11 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa
- +
- +
@@ -306,11 +306,11 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa
- +
- +
@@ -340,11 +340,11 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa
- +
- +
@@ -374,11 +374,11 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa
- +
- +
@@ -459,11 +459,11 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa
- +
- +
@@ -563,11 +563,11 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa
- +
- +
@@ -1041,13 +1041,13 @@ function appendGridtHtml(ui_type = false, data = false, ) {
- +
- +
@@ -1089,11 +1089,11 @@ function appendGridtHtml(ui_type = false, data = false, ) {
- +
- +
@@ -1118,11 +1118,11 @@ function appendGridtHtml(ui_type = false, data = false, ) {
- +
- +
@@ -1141,11 +1141,11 @@ function appendGridtHtml(ui_type = false, data = false, ) {
- +
- +
@@ -1169,11 +1169,11 @@ function appendGridtHtml(ui_type = false, data = false, ) {
- +
- +
@@ -1245,11 +1245,11 @@ function appendGridtHtml(ui_type = false, data = false, ) {
- +
- +
@@ -1332,11 +1332,11 @@ function appendGridtHtml(ui_type = false, data = false, ) {
- +
- +
@@ -1744,8 +1744,8 @@ function checkDuplicate() { if(selectedValue == 1){ - var siInputs = $('input[name="3_si[]"]'); - var premiumInputs = $('input[name="3_premium[]"]'); + var siInputs = $('input[name="gpa_sum_si[]"]'); + var premiumInputs = $('input[name="gpa_sum_premium[]"]'); var siValues = []; var premiumValues = []; @@ -1763,12 +1763,17 @@ function checkDuplicate() { for (var i = 0; i < siValues.length; i++) { for (var j = i + 1; j < siValues.length; j++) { - if (siValues[i] === siValues[j] && premiumValues[i] === premiumValues[j]) { + if (siValues[i] === siValues[j]) { siDuplicates = true; } } } + console.log('siValues', siValues); + console.log('premiumValues', premiumValues); + console.log('siDuplicates', siDuplicates); + console.log('premiumDuplicates', premiumDuplicates); + if (siDuplicates || premiumDuplicates) { toastr.warning('Duplicates found!', 'warning'); return true; @@ -1778,7 +1783,59 @@ function checkDuplicate() { }else if(selectedValue == 3){ + var siInputs = $('input[name="gpa_sum_si2[]"]'); + var premiumInputs = $('input[name="gpa_sum_premium2[]"]'); + var bandInputs = $('input[name="gpa_band[]"]'); + var siValues = []; + var premiumValues = []; + var bandValues = []; + var siDuplicates = false; + var premiumDuplicates = false; + var bandDuplicates = false; + + // Extract values from input arrays + siInputs.each(function() { + siValues.push($(this).val()); + }); + + premiumInputs.each(function() { + premiumValues.push($(this).val()); + }); + + bandInputs.each(function() { + bandValues.push($(this).val()); + }); + + for (var i = 0; i < siValues.length; i++) { + for (var j = i + 1; j < siValues.length; j++) { + if (siValues[i] === siValues[j]) { + siDuplicates = true; + } + } + } + + for (var i = 0; i < bandValues.length; i++) { + for (var j = i + 1; j < bandValues.length; j++) { + if (bandValues[i] === bandValues[j]) { + bandDuplicates = true; + } + } + } + + console.log('siValues', siValues); + console.log('premiumValues', premiumValues); + console.log('bandValues', bandValues); + console.log('siDuplicates', siDuplicates); + console.log('premiumDuplicates', premiumDuplicates); + console.log('bandDuplicates', bandDuplicates); + + if (siDuplicates || bandDuplicates || premiumDuplicates) { + toastr.warning('Duplicates found!', 'warning'); + return true; + } else { + return false; + } } } From 0de9e47609b75ba57a6016226535042f1cf52bc0 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Fri, 10 May 2024 08:43:34 +0530 Subject: [PATCH 6/6] CHANGE_POLICY_LIST_ADD_ENROLLMENT_STATUS_COLUNM_TO_OPEN_AND_CLOSE_ENRLMNT : RV --- app/Controllers/ClientController.php | 127 ++++++++++++++------------- app/Views/client_policy.php | 113 +++++++++++++++--------- 2 files changed, 136 insertions(+), 104 deletions(-) diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 25d0064f..5449dedb 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -1531,77 +1531,82 @@ class ClientController extends AdminController public function updateClientPolicyStatus() { - $client_policy_id = $this->request->getGet('client_policy_id'); - $record = $this->clientPolicyModel->where('id', $client_policy_id)->first(); - $message = 'Policy updated Successfully' ; - if($record['open_for_enrollment'] == 0){ - $open_for_enrollment_update_value = 1; - $message = 'Update Open Enrollment Successfully'; - }else if($record['open_for_enrollment'] == 1){ - $open_for_enrollment_update_value = 0; - $message = 'Update Open Enrollment Successfully'; - } - - $data = $this->policesModel->getPolicyPremium($record['policy_id']); - $pattern = '/gmc/i'; - $subject = $data[0]->policy_type; - if (preg_match($pattern, $subject)) { - $search_term = 'GMC'; - } else { - $search_term = 'GPA'; - } - - if($search_term === 'GPA'){ - $racRate = $this->policyPremium1Model->where(['client_id' => $record['client_id'], 'client_policy_id' => $client_policy_id, 'is_active' => 1])->countAllResults(); - }else if($search_term === 'GMC'){ - $racRate = $this->policyPremium2Model->where(['client_id' => $record['client_id'], 'client_policy_id' => $client_policy_id, 'is_active' => 1])->countAllResults(); - } - - $termsData = $this->clientPolicyModel->where(['id' => $client_policy_id, 'is_active' => 1])->first(); - if(empty($termsData['policy_terms'])){ - return $this->respond(['status' => false,'code' => 200,'message' => 'Please define policy terms '], 200); - } + $client_policy_id = $this->request->getGet('client_policy_id'); + $message = 'Policy updated Successfully'; - $termsData = json_decode($termsData['policy_terms']); + $record = $this->clientPolicyModel->where('id', $client_policy_id)->first(); - if (isset($termsData->sum_insured) && empty($termsData->sum_insured)) { - return $this->respond(['status' => false,'code' => 200,'message' => 'The Policy terms Sum Insured field is empty', 'data' => $record], 200); - } + if ($record['open_for_enrollment'] == 0) { + $open_for_enrollment_update_value = 1; + $message = 'Enrollment Opened Successfully'; + } else if ($record['open_for_enrollment'] == 1) { + $open_for_enrollment_update_value = 0; + $message = 'Enrollment Closed Successfully'; + } - if (isset($termsData->SumInsured) && empty($termsData->sum_insured)) { - return $this->respond(['status' => false,'code' => 200,'message' => 'The Policy terms Sum Insured field is empty'], 200); - } - - // Check if 'family_floater' key exists and has a value - if (isset($termsData->family_floater) && $termsData->family_floater == null) { - return $this->respond(['status' => false,'code' => 200,'message' => 'The Policy terms Family Floater field is empty'], 200); - } - - // Check if 'family_floaters' key exists and has a value - if (isset($termsData->family_floaters) && is_array($termsData->family_floaters) && count($termsData->family_floaters) <= 0) { - return $this->respond(['status' => false,'code' => 200,'message' => 'The Policy terms Family Members field is empty'], 200); - $familyFloatersCount = count($termsData->family_floaters); - } + $data = $this->policesModel->getPolicyPremium($record['policy_id']); + $pattern = '/gmc/i'; + $subject = $data[0]->policy_type; + if (preg_match($pattern, $subject)) { + $search_term = 'GMC'; + } else { + $search_term = 'GPA'; + } - if($racRate == 0){ + if ($search_term === 'GPA') { + $racRate = $this->policyPremium1Model->where(['client_id' => $record['client_id'], 'client_policy_id' => $client_policy_id, 'is_active' => 1])->countAllResults(); + } else if ($search_term === 'GMC') { + $racRate = $this->policyPremium2Model->where(['client_id' => $record['client_id'], 'client_policy_id' => $client_policy_id, 'is_active' => 1])->countAllResults(); + } - return $this->respond(['status' => false,'code' => 200,'message' => 'Please define policy premium'], 200); - } + $termsData = $this->clientPolicyModel->where(['id' => $client_policy_id, 'is_active' => 1])->first(); + if (empty($termsData['policy_terms'])) { + return $this->respond(['status' => false, 'code' => 200, 'message' => 'Please define policy terms '], 200); + } - $policy_status = $this->clientPolicyModel->where('id', $client_policy_id )->set('policy_status', 1)->update(); - $json_data =''; - $open_for_enrollment = $this->clientPolicyModel->where('id', $client_policy_id )->set('open_for_enrollment', $open_for_enrollment_update_value)->update(); - if ($open_for_enrollment) { - $open_for_enrollment_1 = $this->clientPolicyModel->where('id', $client_policy_id )->find(); - $open_for_enrollment_value = $open_for_enrollment_1[0]['open_for_enrollment']; - $client_policy_id_value = $client_policy_id; - $json_data = json_encode(['open_for_enrollment' => $open_for_enrollment_value, 'client_policy_id' => $client_policy_id_value]); - } + $termsData = json_decode($termsData['policy_terms']); - return $this->respond(['status' => true,'code' => 200, 'message' => $message, 'data' => $termsData, 'racRate' => $racRate, 'open_for_enrollment' => $json_data], 200); + if (isset($termsData->sum_insured) && empty($termsData->sum_insured)) { + 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)) { + return $this->respond(['status' => false, 'code' => 200, 'message' => 'The Policy terms Sum Insured field is empty'], 200); + } + + // Check if 'family_floater' key exists and has a value + if (isset($termsData->family_floater) && $termsData->family_floater == null) { + return $this->respond(['status' => false, 'code' => 200, 'message' => 'The Policy terms Family Floater field is empty'], 200); + } + + // Check if 'family_floaters' key exists and has a value + if (isset($termsData->family_floaters) && is_array($termsData->family_floaters) && count($termsData->family_floaters) <= 0) { + return $this->respond(['status' => false, 'code' => 200, 'message' => 'The Policy terms Family Members field is empty'], 200); + $familyFloatersCount = count($termsData->family_floaters); + } + + if ($racRate == 0) { + + return $this->respond(['status' => false, 'code' => 200, 'message' => 'Please define policy premium'], 200); + } + + // $policy_status = $this->clientPolicyModel->where('id', $client_policy_id )->set('policy_status', 1)->update(); + + $json_data = ''; + $open_for_enrollment = $this->clientPolicyModel->where('id', $client_policy_id)->set('open_for_enrollment', $open_for_enrollment_update_value)->update(); + if ($open_for_enrollment) { + $open_for_enrollment_1 = $this->clientPolicyModel->where('id', $client_policy_id)->find(); + $open_for_enrollment_value = $open_for_enrollment_1[0]['open_for_enrollment']; + $client_policy_id_value = $client_policy_id; + + $json_data = json_encode(['open_for_enrollment' => $open_for_enrollment_value, 'client_policy_id' => $client_policy_id_value]); + } + + + + return $this->respond(['status' => true, 'code' => 200, 'message' => $message, 'data' => $termsData, 'racRate' => $racRate, 'open_for_enrollment' => $json_data, 'client_policy_data' => $record], 200); } diff --git a/app/Views/client_policy.php b/app/Views/client_policy.php index e9174cf8..782c000d 100644 --- a/app/Views/client_policy.php +++ b/app/Views/client_policy.php @@ -14,6 +14,7 @@ Policy TPA Date + Enrollment Status Status Action @@ -246,8 +247,28 @@ } else { search_term = subject; // Set default value if neither 'GMC' nor 'GPA' exists } + // console.log('search_term :', search_term) + + var enrollmentStatus = ''; + if(item.inception_type == 1){ + + enrollmentStatus = 'N/A' + + }else if(item.inception_type == 2){ + + if(item.open_for_enrollment == 1){ + + enrollmentStatus = 'Open' + + + }else if(item.open_for_enrollment == 0){ + + enrollmentStatus = 'Closed' + + } + + } - console.log('search_term :', search_term) policyTable += ` @@ -255,6 +276,7 @@ ${item.policy_name} (${item.policy_type_name}) ${item.tpa_short} - ${item.tpa_branch_code} ${(item.policy_start_date)} / ${(item.policy_end_date)} + ${(enrollmentStatus)} ${checkDateStatus(item.policy_end_date, 1)} @@ -389,7 +402,27 @@ subject; // Set default value if neither 'GMC' nor 'GPA' exists } - console.log('search_term :', search_term) + // console.log('search_term :', search_term) + + var enrollmentStatus = ''; + if(item.inception_type == 1){ + + enrollmentStatus = 'N/A' + + }else if(item.inception_type == 2){ + + if(item.open_for_enrollment == 1){ + + enrollmentStatus = 'Open' + + + }else if(item.open_for_enrollment == 0){ + + enrollmentStatus = 'Closed' + + } + + } policyTable += ` @@ -397,6 +430,7 @@ ${item.policy_name} (${item.policy_type_name}) ${item.tpa_short} - ${item.tpa_branch_code} ${rearrangeDateFormat(item.policy_start_date)} - ${rearrangeDateFormat(item.policy_end_date)} + ${(enrollmentStatus)} ${checkDateStatus(item.policy_end_date, 1)} @@ -755,19 +780,23 @@ Swal.fire({ title: "Are you sure?", - text: "You need to approve this!", - icon: "warning", - showCancelButton: true, - confirmButtonColor: "#3085d6", - cancelButtonColor: "#d33", - confirmButtonText: "Yes" + text: "You need to approve this!", + icon: "info", + showCancelButton: true, + confirmButtonColor: "#3085d6", + confirmButtonText: "Yes", }).then((result) => { - if (result.isConfirmed) { - var client_policy_id = $(this).attr('data-id'); - var policy_id = $(this).attr('id'); - var client_id = $('#client_id_policy').val() - // console.log('client_policy_id', client_policy_id); + + if (result.isConfirmed) { + + var client_policy_id = $(this).attr('data-id'); + var policy_id = $(this).attr('id'); + var client_id = $('#client_id_policy').val() + + console.log('client_policy_id', client_policy_id) + console.log('policy_id', policy_id) + console.log('client_id', client_id) if (client_policy_id) { $('.loader').fadeIn(); @@ -781,30 +810,28 @@ client_policy_id: client_policy_id, }, success: function(res) { - console.log(res); + + console.log(res.client_policy_data); if (res) { if (res.open_for_enrollment) { var json_decode = JSON.parse(res.open_for_enrollment); var open_for_enrollment = json_decode.open_for_enrollment; var client_policy_id = json_decode.client_policy_id; + if (open_for_enrollment == 1) { - // console.log($('[data-id="' + client_policy_id + '"]'); + $('.btnOpenEnroll').each(function(index, element) { if ($(element).data('id') == client_policy_id) { - $(element).css({ - 'background-color': 'lightgrey', - }); - $(element).html('Open Enrollment'); + $(element).html('Open'); } }); + } else { + $('.btnOpenEnroll').each(function(index, element) { if ($(element).data('id') == client_policy_id) { - $(element).css({ - 'background-color': '', - }); - $(element).html('Open Enrollment'); + $(element).html('Closed'); } }); }