CHANGE_POLICY_LIST_ADD_ENROLLMENT_STATUS_COLUNM_TO_OPEN_AND_CLOSE_ENRLMNT : RV
This commit is contained in:
parent
188618718c
commit
0de9e47609
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
<th>Policy</th>
|
||||
<th>TPA</th>
|
||||
<th>Date</th>
|
||||
<th>Enrollment Status</th>
|
||||
<th>Status</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
@ -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 = '<a href="#" data-id="'+ item.id +'" id="' + item.policy_id + '" class="btnOpenEnroll" data-toggle="tooltip" data-placement="left" title="Click To Close Enrollment">Open</a>'
|
||||
|
||||
|
||||
}else if(item.open_for_enrollment == 0){
|
||||
|
||||
enrollmentStatus = '<a href="#" data-toggle="tooltip" data-placement="top" title="Click To Open Enrollment" data-id="'+ item.id +'" id="' + item.policy_id + '" class="btnOpenEnroll">Closed</a>'
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
console.log('search_term :', search_term)
|
||||
|
||||
policyTable += `
|
||||
<tr>
|
||||
@ -255,6 +276,7 @@
|
||||
<td>${item.policy_name} (${item.policy_type_name})</td>
|
||||
<td>${item.tpa_short} - ${item.tpa_branch_code}</td>
|
||||
<td>${(item.policy_start_date)} / ${(item.policy_end_date)}</td>
|
||||
<td style="text-align: center;">${(enrollmentStatus)}</td>
|
||||
<td>${checkDateStatus(item.policy_end_date, 1)}</td>
|
||||
<td>
|
||||
<div class="btn-group dropdown">
|
||||
@ -262,16 +284,7 @@
|
||||
<div class="dropdown-menu dropdown-menu-right">
|
||||
<a href="#" data-id="${item.id}" id="${item.policy_id}" class="dropdown-item btnPolicyEdit"><i class="mdi mdi-lead-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
|
||||
<a href="#" data-id="${item.id}" id="${search_term}" class="dropdown-item btnPolicyMaster" data-toggle="modal"><i class="mdi mdi-wrench mr-2 text-muted font-18 vertical-middle"></i>Terms</a>
|
||||
<a href="#" data-id="${item.id}" id="${search_term}"class="dropdown-item btnPolicyModel" data-toggle="modal" data-target="#bs-example-modal-lg"><i class="mdi mdi-book-open mr-2 text-muted font-18 vertical-middle"></i>Rack Rate</a>
|
||||
`;
|
||||
if (item.open_for_enrollment == 0) {
|
||||
policyTable +=
|
||||
`<a href="#" data-id="${item.id}" id="${item.policy_id}" class="dropdown-item btnOpenEnroll"><i class="mdi mdi-file-lock mr-2 text-muted font-18 vertical-middle"></i>Open Enrollment</a> `;
|
||||
} else {
|
||||
policyTable +=
|
||||
`<a href="#" data-id="${item.id}" id="${item.policy_id}" class="dropdown-item btnOpenEnroll" style="background-color: lightgrey;"><i class="mdi mdi-file-lock mr-2 text-muted font-18 vertical-middle" ></i>Open Enrollment</a> `;
|
||||
}
|
||||
policyTable += `
|
||||
<a href="#" data-id="${item.id}" id="${search_term}"class="dropdown-item btnPolicyModel" data-toggle="modal" data-target="#bs-example-modal-lg"><i class="mdi mdi-book-open mr-2 text-muted font-18 vertical-middle"></i>Rack Rate</a>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
@ -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 = '<a data-toggle="tooltip" data-placement="top" title="Click To Close Enrollment" href="#" data-id="'+ item.id +'" id="' + item.policy_id + '" class="btnOpenEnroll">Open</a>'
|
||||
|
||||
|
||||
}else if(item.open_for_enrollment == 0){
|
||||
|
||||
enrollmentStatus = '<a data-toggle="tooltip" data-placement="top" title="Click To Open Enrollment" href="#" data-id="'+ item.id +'" id="' + item.policy_id + '" class="btnOpenEnroll">Closed</a>'
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
policyTable += `
|
||||
<tr>
|
||||
@ -397,6 +430,7 @@
|
||||
<td>${item.policy_name} (${item.policy_type_name})</td>
|
||||
<td>${item.tpa_short} - ${item.tpa_branch_code}</td>
|
||||
<td>${rearrangeDateFormat(item.policy_start_date)} - ${rearrangeDateFormat(item.policy_end_date)}</td>
|
||||
<td style="text-align: center;">${(enrollmentStatus)}</td>
|
||||
<td>${checkDateStatus(item.policy_end_date, 1)}</td>
|
||||
<td>
|
||||
<div class="btn-group dropdown">
|
||||
@ -404,16 +438,7 @@
|
||||
<div class="dropdown-menu dropdown-menu-right">
|
||||
<a href="#" data-id="${item.id}" id="${item.policy_id}" class="dropdown-item btnPolicyEdit"><i class="mdi mdi-lead-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
|
||||
<a href="#" data-id="${item.id}" id="${search_term}" class="dropdown-item btnPolicyMaster" data-toggle="modal"><i class="mdi mdi-wrench mr-2 text-muted font-18 vertical-middle"></i>Terms</a>
|
||||
<a href="#" data-id="${item.id}" id="${search_term}"class="dropdown-item btnPolicyModel" data-toggle="modal" data-target="#bs-example-modal-lg"><i class="mdi mdi-book-open mr-2 text-muted font-18 vertical-middle"></i>Rack Rate</a>
|
||||
`;
|
||||
if (item.open_for_enrollment == 0) {
|
||||
policyTable +=
|
||||
`<a href="#" data-id="${item.id}" id="${item.policy_id}" class="dropdown-item btnOpenEnroll"><i class="mdi mdi-file-lock mr-2 text-muted font-18 vertical-middle"></i>Open Enrollment</a> `;
|
||||
} else {
|
||||
policyTable +=
|
||||
`<a href="#" data-id="${item.id}" id="${item.policy_id}" class="dropdown-item btnOpenEnroll" style="background-color: lightgrey;"><i class="mdi mdi-file-lock mr-2 text-muted font-18 vertical-middle" ></i>Open Enrollment</a> `;
|
||||
}
|
||||
policyTable += `
|
||||
<a href="#" data-id="${item.id}" id="${search_term}"class="dropdown-item btnPolicyModel" data-toggle="modal" data-target="#bs-example-modal-lg"><i class="mdi mdi-book-open mr-2 text-muted font-18 vertical-middle"></i>Rack Rate</a>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
@ -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('<i class="mdi mdi-file-lock mr-2 text-muted font-18 vertical-middle"></i>Open Enrollment');
|
||||
$(element).html('<a data-toggle="tooltip" data-placement="top" title="Click To Close Enrollment" href="#" data-id="' + res.client_policy_data.id + '" id="' + res.client_policy_data.policy_id + '" class="btnOpenEnroll">Open</a>');
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
|
||||
$('.btnOpenEnroll').each(function(index, element) {
|
||||
if ($(element).data('id') == client_policy_id) {
|
||||
$(element).css({
|
||||
'background-color': '',
|
||||
});
|
||||
$(element).html('<i class="mdi mdi-file-lock mr-2 text-muted font-18 vertical-middle"></i>Open Enrollment');
|
||||
$(element).html('<a data-toggle="tooltip" data-placement="top" title="Click To Open Enrollment" href="#" data-id="' + res.client_policy_data.id + '" id="' + res.client_policy_data.policy_id + '" class="btnOpenEnroll">Closed</a>');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user