CHANGE_OPEN_FOR_ENROLLMENT_TO_SET_CONFORMATION_ALERT_AND_UPDATE_1_AND_0 : RV

This commit is contained in:
VENKATESHWARAN 2024-04-27 10:43:18 +05:30
parent e17fd43594
commit e09d8f4d14
3 changed files with 881 additions and 852 deletions

View File

@ -1457,7 +1457,14 @@ class ClientController extends AdminController
$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';
@ -1508,7 +1515,7 @@ class ClientController extends AdminController
$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', 1)->update();
$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'];
@ -1517,9 +1524,7 @@ class ClientController extends AdminController
$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' => 'Policy Status Updated Successfully', 'data' => $termsData, 'racRate' => $racRate, 'open_for_enrollment' => $json_data], 200);
return $this->respond(['status' => true,'code' => 200, 'message' => $message, 'data' => $termsData, 'racRate' => $racRate, 'open_for_enrollment' => $json_data], 200);
}

View File

@ -2,8 +2,7 @@
<div class="row float-right" style="padding-bottom: 10px; position: relative;right: 13px;">
<button type="button" id="BtnAdd" class="btn btn-primary waves-effect waves-light btnAdd btn-sm"><span
class="fa fa-plus-square" aria-hidden="true" style="padding: 5px 10px;"></span>Add Policy</button>
<button type="button" id="BtnAdd" class="btn btn-primary waves-effect waves-light btnAdd btn-sm"><span class="fa fa-plus-square" aria-hidden="true" style="padding: 5px 10px;"></span>Add Policy</button>
</div>
<div class="table-responsive" id="table_list">
@ -29,9 +28,7 @@
<div class="card-body">
<div class="row float-right" style="position: relative; bottom: 20px; right: 13px;">
<button type="button" id="btnPolicyBack"
class="btn btn-primary waves-effect waves-light btn-sm btnBack btn-sm"><span class="fa fa-list"
aria-hidden="true" style="padding: 5px 10px;"></span>Back To List</button>
<button type="button" id="btnPolicyBack" class="btn btn-primary waves-effect waves-light btn-sm btnBack btn-sm"><span class="fa fa-list" aria-hidden="true" style="padding: 5px 10px;"></span>Back To List</button>
</div>
<hr>
@ -41,8 +38,7 @@
<input type="hidden" name="PrimaryKey" id="policy_PrimaryKey" />
<input type="hidden" id="policy_form_action" />
<input type="hidden" name="policy_type_id" id="policy_type_id" />
<input type="hidden" name="client_id" id="client_id_policy"
value="<?= isset($client['id']) ? $client['id'] : '' ?>" />
<input type="hidden" name="client_id" id="client_id_policy" value="<?= isset($client['id']) ? $client['id'] : '' ?>" />
<div class="form-group">
<div class="form-row">
@ -50,7 +46,7 @@
<label for="email"> Policy Type<span class="text-danger">*</span></label>
<select class="form-control" id="policy_type" name="is_addon" required>
<option value="0">Select Policy Type</option>
<?php foreach($policy_type as $key => $value) { ?>
<?php foreach ($policy_type as $key => $value) { ?>
<option value="<?= $key ?>"><?= $value ?></option>
<?php } ?>
</select>
@ -70,8 +66,8 @@
<label for="email">Insurer<span class="text-danger">*</span></label>
<select class="form-control" id="insurer" name="insurer" required>
<option value="">Select Insurer</option>
<?php foreach($insurer as $value) { ?>
<option value="<?= $value['id'] . '-' . $value['insurer_id']?>">
<?php foreach ($insurer as $value) { ?>
<option value="<?= $value['id'] . '-' . $value['insurer_id'] ?>">
<?= $value['insurer_name'] . '-' . $value['branch_code'] ?></option>
<?php } ?>
</select>
@ -86,8 +82,8 @@
<label for="mobile">TPA<span class="text-danger">*</span></label>
<select class="form-control" id="tpa" name="tpa" required>
<option value="">Select TPA</option>
<?php foreach($tpa as $value) { ?>
<option value="<?= $value['id']. '-' . $value['tpa_id'] ?>">
<?php foreach ($tpa as $value) { ?>
<option value="<?= $value['id'] . '-' . $value['tpa_id'] ?>">
<?= $value['tpa_short_name'] . '-' . $value['branch_code'] ?></option>
<?php } ?>
</select>
@ -96,20 +92,16 @@
<div class="form-row" id="second" style="display: none;">
<div class="form-group col-md-4">
<label for="policy_start_date">Policy Start Date<span
class="text-danger">*</span></label>
<input value="" type="text" class="form-control" placeholder="Enter Start Date "
name="policy_start_date" id="start_date" required>
<label for="policy_start_date">Policy Start Date<span class="text-danger">*</span></label>
<input value="" type="text" class="form-control" placeholder="Enter Start Date " name="policy_start_date" id="start_date" required>
</div>
<div class="form-group col-md-4">
<label for="policy_end_date">Policy End Date<span class="text-danger">*</span></label>
<input value="" type="text" class="form-control" placeholder="Enter End Date "
name="policy_end_date" id="end_date" required>
<input value="" type="text" class="form-control" placeholder="Enter End Date " name="policy_end_date" id="end_date" required>
</div>
<div class="form-group col-md-4" id="policy_status_field">
<label for="policy_status">Policy Status</label>
<input value="" type="text" class="form-control" placeholder="Policy Status"
id="policy_status" readonly>
<input value="" type="text" class="form-control" placeholder="Policy Status" id="policy_status" readonly>
</div>
</div>
@ -118,10 +110,8 @@
</div>
<div class="form-group text-right m-b-0">
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1"
id="btnSubmit">Submit</button>
<button type="button" class="btn btn-secondary waves-effect btnBack"
id="btnBack">Cancel</button>
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1" id="btnSubmit">Submit</button>
<button type="button" class="btn btn-secondary waves-effect btnBack" id="btnBack">Cancel</button>
</div>
</form>
</div>
@ -135,18 +125,18 @@
<?php include('policy_gpa_terms.php'); ?>
<script>
var policy_PrimaryKey = $('#client_id_policy').val();
var policy_client = $('#policy_PrimaryKey').val();
var policy_PrimaryKey = $('#client_id_policy').val();
var policy_client = $('#policy_PrimaryKey').val();
$(document).ready(function() {
$(document).ready(function() {
// Initialize select2
$("#insurer").select2();
$("#policy").select2();
$("#tpa").select2();
$("#base_policy").select2();
});
});
$(document).ready(function() {
$(document).ready(function() {
$('#policy_status_field').hide()
@ -265,9 +255,10 @@ $(document).ready(function() {
`<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="pointer-events:none; background-color: lightgrey;"><i class="mdi mdi-file-lock mr-2 text-muted font-18 vertical-middle" ></i>Open Enrollment</a> `;
`<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 += ` </div>
policyTable += `
</div>
</div>
</td>
</tr>
@ -283,10 +274,10 @@ $(document).ready(function() {
searching: false
});
});
});
/******** for form submit using AJAX *******/
$("#policy_form").submit(function(event) {
/******** for form submit using AJAX *******/
$("#policy_form").submit(function(event) {
event.preventDefault();
@ -378,7 +369,15 @@ $("#policy_form").submit(function(event) {
<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>
<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>
`;
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 += `
</div>
</div>
</td>
@ -409,9 +408,9 @@ $("#policy_form").submit(function(event) {
}, 1000);
}
});
});
});
$(document).ready(function() {
$(document).ready(function() {
/********* To get th POLICY base on Insurer *******/
$('#insurer').change(function() {
var id = $(this).val();
@ -433,13 +432,13 @@ $(document).ready(function() {
item.id +
'">' + item.name + '</option>';
}
}else if($policy_type_value == 2){
if (item.policy_type_id == 4 ) {
} else if ($policy_type_value == 2) {
if (item.policy_type_id == 4) {
OptionsHTML += '<option data-id="' + item.policy_type_id + '" value="' +
item.id +
'">' + item.name + '</option>';
}
}else{
} else {
OptionsHTML += '<option data-id="' + item.policy_type_id + '" value="' +
item.id +
'">' + item.name + '</option>';
@ -452,9 +451,9 @@ $(document).ready(function() {
console.error(status, error);
});
});
});
});
$(document).ready(function() {
$(document).ready(function() {
/********* set the Policy_Type_id for Form Submit *******/
$('#policy').change(function() {
@ -480,10 +479,10 @@ $(document).ready(function() {
// }
});
});
});
// get the client policy data for edit
$('body').on('click', '.btnPolicyEdit', function() {
// get the client policy data for edit
$('body').on('click', '.btnPolicyEdit', function() {
var policy_form_action = '';
var policy_id = $(this).attr('data-id');
@ -577,16 +576,25 @@ $('body').on('click', '.btnPolicyEdit', function() {
}, 1000);
}
});
});
});
$('body').on('click', '.btnOpenEnroll', function() {
$('body').on('click', '.btnOpenEnroll', function() {
Swal.fire({
title: "Are you sure?",
text: "You need to approve this!",
icon: "warning",
showCancelButton: true,
confirmButtonColor: "#3085d6",
cancelButtonColor: "#d33",
confirmButtonText: "Yes, delete it!"
}).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 (client_policy_id) {
@ -595,13 +603,14 @@ $('body').on('click', '.btnOpenEnroll', function() {
}
$.ajax({
url: '<?php echo base_url('util/update-policy-status');?>',
url: '<?php echo base_url('util/update-policy-status'); ?>',
type: 'GET',
data: {
client_policy_id: client_policy_id,
},
success: function(res) {
console.log(res);
if (res) {
if (res.open_for_enrollment) {
var json_decode = JSON.parse(res.open_for_enrollment);
@ -613,8 +622,17 @@ $('body').on('click', '.btnOpenEnroll', function() {
if ($(element).data('id') == client_policy_id) {
$(element).css({
'background-color': 'lightgrey',
'pointer-events': 'none'
});
$(element).html('<i class="mdi mdi-file-lock mr-2 text-muted font-18 vertical-middle"></i>Open Enrollment');
}
});
} 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');
}
});
}
@ -648,9 +666,13 @@ $('body').on('click', '.btnOpenEnroll', function() {
}
});
});
}
function appendPolicyFormFields(policy_type, data = false) {
});
});
function appendPolicyFormFields(policy_type, data = false) {
var html = '';
var container = document.getElementById('policy_fields');
@ -788,11 +810,11 @@ function appendPolicyFormFields(policy_type, data = false) {
})
}
}
//for date convert to indian formate like this 'yyyy-mm-dd' to this 'dd-mm-yyyy'
function rearrangeDateFormat(inputDate) {
//for date convert to indian formate like this 'yyyy-mm-dd' to this 'dd-mm-yyyy'
function rearrangeDateFormat(inputDate) {
if (inputDate !== null) {
var dateComponents = inputDate.split("-");
@ -801,9 +823,9 @@ function rearrangeDateFormat(inputDate) {
} else {
return '00-00-0000';
}
}
}
function checkDateStatus(inputDate, bg = false) {
function checkDateStatus(inputDate, bg = false) {
var givenDate = new Date(inputDate);
var currentDate = new Date();
@ -822,9 +844,9 @@ function checkDateStatus(inputDate, bg = false) {
}
}
}
}
const numberWords = {
const numberWords = {
0: "Zero",
1: "One",
2: "Two",
@ -853,9 +875,9 @@ const numberWords = {
70: "Seventy",
80: "Eighty",
90: "Ninety"
};
};
function convertNumberToWords(number) {
function convertNumberToWords(number) {
if (number === 0) {
return numberWords[number];
}
@ -893,9 +915,9 @@ function convertNumberToWords(number) {
}
}
return word.trim();
}
}
function convertCommaNumberToWords(input) {
function convertCommaNumberToWords(input) {
let number;
if (input instanceof HTMLElement) {
const inputValue = input.value;
@ -911,17 +933,17 @@ function convertCommaNumberToWords(input) {
var convert_word_value = convertNumberToWords(number);
return convert_word_value;
}
}
function onlyNumbers(event) {
function onlyNumbers(event) {
var charcode;
charcode = event.which || event.keyCode;
if (charcode >= 48 && charcode <= 57) return true;
return false;
}
}
function formatNumber(input, maxLength) {
function formatNumber(input, maxLength) {
// console.log("input", input);
maxLength = 16;
@ -989,15 +1011,15 @@ function formatNumber(input, maxLength) {
return;
// }
}
}
function removeClientPolicy(element) {
function removeClientPolicy(element) {
console.log(element);
}
}
$('#policy_type').change(function() {
$('#policy_type').change(function() {
$('#insurer').val('').change();
$('#tpa').val('').change();
@ -1005,7 +1027,7 @@ $('#policy_type').change(function() {
$('#end_date').val('');
$('#base_policy').val('0');
if($(this).val() == 3){
if ($(this).val() == 3) {
toastr.warning('Please Change the Policy Terms after Submit the Policy!', 'warning');
}
@ -1016,7 +1038,7 @@ $('#policy_type').change(function() {
$('#first').show();
$('#second').show();
} else if ($(this).val() == '0'){
} else if ($(this).val() == '0') {
$('#first').hide();
$('#second').hide();
@ -1024,17 +1046,17 @@ $('#policy_type').change(function() {
$('#base_policy').prop('required', false);
} else if ($(this).val() == '1'){
} else if ($(this).val() == '1') {
$('#first').show();
$('#second').show();
$('#base_policy_id').hide();
$('#base_policy').prop('required', false);
}
})
})
function fetchClientPolicyList() {
function fetchClientPolicyList() {
var client_id = $('#client_id_policy').val()
@ -1044,7 +1066,7 @@ function fetchClientPolicyList() {
dataType: 'json',
success: function(res) {
console.log('one',res)
console.log('one', res)
setTimeout(function() {
$('.loader').fadeOut();
@ -1074,10 +1096,10 @@ function fetchClientPolicyList() {
}
});
}
}
$(document).ready(function(){
$(document).ready(function() {
$('#base_policy').change(function() {
@ -1091,8 +1113,8 @@ $(document).ready(function(){
};
const queryString = objectToQueryString(queryParams);
// var uri = '<?= base_url('util/fetch-policy-for-policy-type')?>?' + queryString
var uri = '<?= base_url('client/policy/list/')?>' + client_policy_id
// var uri = '<?= base_url('util/fetch-policy-for-policy-type') ?>?' + queryString
var uri = '<?= base_url('client/policy/list/') ?>' + client_policy_id
// console.log('uri', uri)
// console.log('queryString', queryString)
@ -1149,10 +1171,9 @@ $(document).ready(function(){
}
});
});
})
})
function objectToQueryString(obj) {
function objectToQueryString(obj) {
return Object.keys(obj).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`).join('&');
}
}
</script>

View File

@ -665,6 +665,9 @@ $(document).ready(function() {
var selectedpolicy = $(this).val();
console.log('selectedpolicy',selectedpolicy)
$('#upload-action-type').val('').change();
$('#file_upload').hide();
$('#excel_download').removeAttr('href');
var apiURL = '<?php echo base_url();?>' + 'util/fetch-emp-count/' + selectedpolicy;
console.log(apiURL);
@ -729,5 +732,5 @@ $(document).ready(function() {
})
//--------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------
</script>