876 lines
36 KiB
PHP
Executable File
876 lines
36 KiB
PHP
Executable File
<style>
|
|
.select2-container .select2-selection--multiple .select2-selection__choice {
|
|
padding: 5px 7px 5px 0 !important;
|
|
color: #000000;
|
|
}
|
|
</style>
|
|
|
|
<div class="tab-pane fade" id="KYC-DOC-tab">
|
|
<div class="row">
|
|
<div class="col-xl-12">
|
|
<div id="accordion" class="mb-3">
|
|
<div class="card mb-1">
|
|
|
|
<h4 class="m-1">
|
|
<span>Filters</span>
|
|
<a id="toggleIcon" class="text-dark float-right" data-toggle="collapse" href="#collapseOne" aria-expanded="true">
|
|
<i id="icon" class="mdi mdi-chevron-down mr-1 text-primary" style="font-size: 28px;"></i>
|
|
</a>
|
|
</h4>
|
|
|
|
<!-- <label id="filterAccordion" class="m-1 d-flex justify-content-between align-items-center">
|
|
<span class="font-color-black">Filters</span>
|
|
<a id="toggleIcon" class="text-dark float-right" data-toggle="collapse" href="#collapseOne" aria-expanded="true">
|
|
<i id="icon" class="mdi mdi-chevron-down mr-1 text-primary" style="font-size: 28px;"></i>
|
|
</a>
|
|
</label> -->
|
|
|
|
<div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion">
|
|
<div class="card-body">
|
|
<!-- <div class="text-center"> -->
|
|
<form class="parsley-examples" id="import_export_excel_form" action="<?php echo base_url() . 'util/import-export' ?>" method="post" enctype="multipart/form-data">
|
|
<input type="hidden" name="<?= csrf_token() ?>" value="<?= csrf_hash() ?>" id="csrf_token">
|
|
<input type="hidden" id="event_type_data">
|
|
<div class="form-group">
|
|
<div class="form-row">
|
|
<div class="form-group col-md-4">
|
|
<label>Client<span class="text-danger">*</span></label> <br />
|
|
<select name="client_id" class="form-control" id="client" required>
|
|
<option value="">Select</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="form-group col-md-4">
|
|
<label>Branch</label> <br />
|
|
<select name="client_branch_id" class="form-control" id="client_branch_id" required>
|
|
<option value="0">Select</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="form-group col-md-4">
|
|
<label>Policy<span class="text-danger" id="policy_danger">*</span></label> <br />
|
|
<select name="client_policy_id" class="form-control" id="policy" onchange="checkPolicyTermsAndRackRatesHasDefiend(event); checkWellnessOnboardStatus(event);" required>
|
|
<option value="">Select</option>
|
|
</select>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
|
|
<div class="form- group col-md-4">
|
|
<label>Insurer/TPA Data<span class="text-danger">*</span></label> <br />
|
|
<select name="insurer_or_tpa" class="form-control" id="insurer_or_tpa" required>
|
|
<option value="">Select</option>
|
|
<?php
|
|
if (isset($insurer_or_tpa) && count($insurer_or_tpa)) {
|
|
foreach ($insurer_or_tpa as $key => $action) {
|
|
echo "<option value=" . $key . ">" . $action . "</option>";
|
|
}
|
|
}
|
|
?>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="form-group col-md-4">
|
|
<label>Action<span class="text-danger">*</span></label> <br />
|
|
<select name="action_type" class="form-control" id="action_type" required>
|
|
<option value="">Select</option>
|
|
<?php
|
|
if (isset($import_or_export) && count($import_or_export)) {
|
|
foreach ($import_or_export as $key => $action) {
|
|
echo "<option value=" . $key . ">" . $action . "</option>";
|
|
}
|
|
}
|
|
?>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="form-group col-md-4">
|
|
<label>Event<span class="text-danger">*</span></label> <br />
|
|
<select name="event_type" class="form-control" id="event_type" required>
|
|
<option value="">Select</option>
|
|
<?php
|
|
if (isset($events) && count($events)) {
|
|
foreach ($events as $key => $action) {
|
|
echo "<option value='$key'" . ($key == "si_enhancement" ? " class='si-enhancement-option'" : "") . ">$action</option>";
|
|
}
|
|
}
|
|
?>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-row policy_issue_date_row" style="display:none;">
|
|
<div class="form-group col-md-4">
|
|
<label id="policy_issue_date_label">Policy Issue Date</label> <br />
|
|
<input type="text" class="form-control" id="policy_issue_date" name="policy_issue_date"
|
|
placeholder="Enter Policy Issue Date">
|
|
</div>
|
|
</div>
|
|
|
|
<br>
|
|
<div class="form-row" id="import_excel_btn">
|
|
|
|
<div class="form-group col-md-3">
|
|
<label>Upload file</label> [ <a id="import_excel_download" data-toggle="tooltip" data-placement="top" title="Download Import Sample Excel" style="display: none;">Sample Excel</a> ]
|
|
<input type="file" name="import_file_data" id="import_file" accept=" application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel,application/vnd.oasis.opendocument.spreadsheet" required>
|
|
</div>
|
|
|
|
<div class="d-flex align-items-center justify-content-start" style="margin-top: 18px;">
|
|
<div class="form-group col-md-3">
|
|
<button id="emp_form_submit_button" type="submit" class="btn btn-primary waves-effect waves-light justify-content-end">Upload</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group col-md-4 fetch_tpa" style="margin-top: 30px;">
|
|
<a id="fetch_tpa_btn" class="btn btn-primary waves-effect waves-light justify-content-end" onclick="fetchTpaIdFromTpa(this)">Fetch TPA ID</a>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="form-row" id="export_excel_btn">
|
|
<div class="d-flex align-items-center justify-content-start" style="margin-top: 18px;">
|
|
<div class="form-group col-md-3">
|
|
<button id="emp_form_submit_button_2" type="submit" class="btn btn-primary waves-effect waves-light justify-content-end">Download</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="form-row" id="onboard_div" style="display:none;">
|
|
<a href="#"><span id="on_board_btn_txt" onclick="initiateWellnessOnboard(this)"></span></a>
|
|
</div>
|
|
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- end page title -->
|
|
<div class="row" id="file_list">
|
|
<?php include('batch_list.php'); ?>
|
|
</div>
|
|
<!-- end row -->
|
|
</div>
|
|
|
|
|
|
<script>
|
|
|
|
var client_id_param2 = 0;
|
|
var client_branch_id_param2 = 0;
|
|
var client_policy_param2 = 0;
|
|
|
|
$(document).ready(function() {
|
|
// Initialize select2
|
|
$("#client").select2();
|
|
$("#policy").select2();
|
|
$("#client_branch_id").select2();
|
|
|
|
});
|
|
|
|
$(document).ready(function() {
|
|
|
|
var policy_issue_datePicker = flatpickr("#policy_issue_date", {
|
|
dateFormat: "d/m/Y",
|
|
allowInput: false,
|
|
});
|
|
|
|
$('#insurer_or_tpa, #action_type').on('change', togglePolicyIssueDate);
|
|
});
|
|
|
|
$(document).ready(function() {
|
|
|
|
<?php if (session()->has('error')) : ?>
|
|
toastr.error('<?= session()->getFlashdata('error') ?>', 'Failed');
|
|
<?php endif; ?>
|
|
|
|
<?php if (session()->has('success')) : ?>
|
|
toastr.success('<?= session()->getFlashdata('success') ?>', 'success');
|
|
<?php endif; ?>
|
|
|
|
$('#import_excel_btn').hide();
|
|
$('#export_excel_btn').hide();
|
|
|
|
// for form submit
|
|
$("#import_export_excel_forms").submit(function(event) {
|
|
|
|
var action = "<?php echo base_url() . 'util/import-export' ?>"
|
|
// var action = $(this).attr("action");
|
|
event.preventDefault(); // Prevent default form submission
|
|
console.log('submit called');
|
|
|
|
var isValid = $('#import_export_excel_form').parsley().validate();
|
|
|
|
if (!isValid) {
|
|
console.log('Form is Empty', 'Warning');
|
|
return;
|
|
}
|
|
|
|
// Create FormData object
|
|
var formData = new FormData($(this)[0]);
|
|
for (var pair of formData.entries()) {
|
|
// console.log(pair[0] + ', ' + pair[1]);
|
|
}
|
|
|
|
$('.loader').fadeIn();
|
|
$('.loader-mask').fadeIn();
|
|
|
|
$.ajax({
|
|
url: action,
|
|
type: "POST",
|
|
data: formData,
|
|
processData: false, // Prevent jQuery from automatically processing the data
|
|
contentType: false, // Let jQuery handle the content type
|
|
success: function(response) {
|
|
|
|
// console.log(response);
|
|
if (response.code === 200 && response.status === true) {
|
|
|
|
$('.loader').fadeOut();
|
|
$('.loader-mask').delay(350).fadeOut('slow');
|
|
$$("#import_export_excel_form")[0].reset()
|
|
toastr.success('File Download successs', 'success');
|
|
|
|
} else if (response.code === 404 && response.status === false) {
|
|
|
|
console.error('no data found', response);
|
|
$('.loader').fadeOut();
|
|
$('.loader-mask').delay(350).fadeOut('slow');
|
|
$("#import_export_excel_form")[0].reset()
|
|
toastr.error(response.message, 'Failed');
|
|
|
|
} else {
|
|
console.error('Something went wrong!');
|
|
// toastr.error('Something went wrong! Try later', 'Error');
|
|
// window.location.reload(true);
|
|
}
|
|
},
|
|
error: function(xhr, status, error) {
|
|
// Request failed, handle error
|
|
console.error("Request failed:", status, error);
|
|
$('.loader').fadeOut();
|
|
$('.loader-mask').delay(350).fadeOut('slow');
|
|
$("#import_export_excel_form")[0].reset()
|
|
// toastr.error('Something went wrong! Try later', 'Error');
|
|
// window.location.reload(true);
|
|
}
|
|
});
|
|
}); //end
|
|
|
|
});
|
|
|
|
$(window).on("load", function() {
|
|
|
|
// Get the current page URL
|
|
const url = window.location.href;
|
|
|
|
// Create a new URL object
|
|
const urlObject = new URL(url);
|
|
|
|
// Use URLSearchParams to get the query parameters
|
|
const params = new URLSearchParams(urlObject.search);
|
|
|
|
// Get the value of 'client_id' and 'client_policy_id'
|
|
client_id_param2 = params.get('client_id');
|
|
client_policy_param2 = params.get('client_policy_id');
|
|
client_branch_id_param2 = params.get('client_branch_id');
|
|
actions = params.get('actions');
|
|
insurer_or_tpa = params.get('insurer_or_tpa');
|
|
event = params.get('event');
|
|
|
|
// console.log('client_id2:', client_id_param2);
|
|
// console.log('client_policy_id2:', client_policy_param2);
|
|
// console.log('actions:', actions);
|
|
// console.log('insurer_or_tpa:', insurer_or_tpa);
|
|
// console.log('event:', event);
|
|
|
|
if (inception_param != null) {
|
|
|
|
$('#action_type').val(actions).change()
|
|
$('#event_type').val(event).change()
|
|
$('#insurer_or_tpa').val(insurer_or_tpa).change()
|
|
|
|
var selectedValue = actions;
|
|
// console.log(selectedValue);
|
|
|
|
if (selectedValue == '') {
|
|
$('#import_excel_btn').hide();
|
|
$('#export_excel_btn').hide();
|
|
} else if (selectedValue == 'import') {
|
|
$('#import_file').prop('required', true);
|
|
$('#import_file').attr('name', 'import_file_data');
|
|
$('#import_excel_btn').show();
|
|
$('#export_excel_btn').hide();
|
|
} else if (selectedValue == 'export') {
|
|
$('#import_file').removeAttr('name');
|
|
$('#import_file').prop('required', false);
|
|
$('#import_excel_btn').hide();
|
|
$('#export_excel_btn').show();
|
|
}
|
|
}
|
|
|
|
});
|
|
|
|
// function fetchClientPolicies2() {
|
|
|
|
// $('#loader').show();
|
|
|
|
// var apiURL = '<?php echo base_url(); ?>' + 'util/clients-with-policies';
|
|
// $.ajax({
|
|
// url: apiURL,
|
|
// method: 'GET',
|
|
// headers: {
|
|
// "Content-Type": "application/json",
|
|
// "X-Requested-With": "XMLHttpRequest"
|
|
// },
|
|
// success: function(response) {
|
|
// // console.log(response.code);
|
|
// // console.log(response.dataStatus);
|
|
// // console.log(response.data);
|
|
// if (response.code === 200 && response.dataStatus === true && response.data !== "") {
|
|
// try {
|
|
// clientPolicies = (response.data);
|
|
// // console.log(clientPolicies);
|
|
|
|
|
|
// response.data.forEach(policy => {
|
|
// // console.log('policies', policy.policies);
|
|
// policy.policies.forEach(p => {
|
|
// clientPoliciesWithBranch2.policies.push(p);
|
|
// });
|
|
// });
|
|
|
|
|
|
// appendClients2(clientPolicies);
|
|
|
|
// setTimeout(function() {
|
|
// if (client_branch_id_param2 != null) {
|
|
// var foundPolicies = clientPolicies.find(function(item) {
|
|
// // console.log(typeof item.id)
|
|
// return item.id == client_id_param2;
|
|
// });
|
|
// appendBranch2(foundPolicies.branchs);
|
|
// }
|
|
// }, 500);
|
|
|
|
// setTimeout(function() {
|
|
// if (client_id_param2 != null) {
|
|
|
|
// var foundPolicies = clientPoliciesWithBranch2.policies.filter(function(item) {
|
|
// // console.log('item', item);
|
|
// return item.branch_id === client_branch_id_param2;
|
|
// });
|
|
|
|
|
|
// if (foundPolicies) {
|
|
// // console.log('foundPolicies', foundPolicies);
|
|
// appendPolicies2(foundPolicies);
|
|
// } else {
|
|
// console.log('No policies found for the selected client');
|
|
// }
|
|
// }
|
|
// }, 500);
|
|
|
|
// } catch (error) {
|
|
// console.error('Error parsing API response data:', error);
|
|
// }
|
|
// } else if (response.code === 404 && response.dataStatus === false) {
|
|
// console.error('no data found', response);
|
|
// } else {
|
|
// // console.error('Something went wrong!');
|
|
// }
|
|
// },
|
|
// error: function(xhr, status, error) {
|
|
// console.error('Error fetching data from API:', error);
|
|
// }
|
|
// });
|
|
|
|
// $('#loader').hide();
|
|
// }
|
|
|
|
function appendClients2(data) {
|
|
|
|
// console.log('client_id_param2', client_id_param2)
|
|
|
|
$.each(data, function(index, item) {
|
|
var option = $('<option>', {
|
|
value: item.id,
|
|
text: item.client_name
|
|
});
|
|
if (client_id_param2 == item.id) {
|
|
option.attr('selected', true);
|
|
}
|
|
$('#client').append(option);
|
|
});
|
|
}
|
|
|
|
function appendBranch2(data) {
|
|
|
|
// console.log(data)
|
|
|
|
$('#client_branch_id').empty();
|
|
$('#client_branch_id').append($('<option>', {
|
|
value: '0',
|
|
text: 'Select'
|
|
}));
|
|
$.each(data, function(index, item) {
|
|
var option = $('<option>', {
|
|
value: item.id,
|
|
text: item.branch_name
|
|
});
|
|
if (client_branch_id_param2 == item.id) {
|
|
option.attr('selected', true);
|
|
}
|
|
$('#client_branch_id').append(option);
|
|
});
|
|
}
|
|
|
|
function appendPolicies2(data) {
|
|
|
|
$('#policy').empty();
|
|
$('#policy').append($('<option>', {
|
|
value: '0',
|
|
text: 'Select'
|
|
}));
|
|
|
|
$.each(data, function(index, item) {
|
|
var option = $('<option>', {
|
|
value: item.id,
|
|
text:`${item.policy_type ?? ''} - ${item.policy_no ?? ''}` ,
|
|
'data-pno': item.policy_no ?? '',
|
|
'data-tid': item.tpa_id ?? ''
|
|
});
|
|
if (client_policy_param2 == item.id) {
|
|
option.attr('selected', true);
|
|
}
|
|
$('#policy').append(option);
|
|
});
|
|
}
|
|
|
|
// On change document ready functions
|
|
$(document).ready(function() {
|
|
|
|
$('#client').on('change', function() {
|
|
|
|
let client_id = $(this).val();
|
|
console.log('client_id', client_id);
|
|
|
|
if(branch_list != '') {
|
|
// console.log(branch_list[client_id]);
|
|
let data = branch_list[client_id];
|
|
appendBranch2(data);
|
|
}
|
|
|
|
});
|
|
|
|
$('#client_branch_id').on('change', function() {
|
|
|
|
let branch_id = $(this).val();
|
|
console.log("branch_id", branch_id);
|
|
|
|
if(policy_list != '' && branch_id != '') {
|
|
let data = policy_list[branch_id];
|
|
appendPolicies2(data);
|
|
}
|
|
});
|
|
|
|
$('#policy').on('change', function() {
|
|
|
|
var policy_value = $(this).val()
|
|
var insurer_or_tpa = $('insurer_or_tpa').val()
|
|
var action_type = $('action_type').val()
|
|
|
|
if(policy_value == 0 || insurer_or_tpa == 'tpa' || action_type == 'import'){
|
|
$("#event_type").removeAttr("multiple");
|
|
$("#event_type").attr("name", "event_type");
|
|
$("#event_type").select2('destroy');
|
|
}
|
|
})
|
|
|
|
/**This function updates the download link based on the selected option in the dropdown menu. **/
|
|
$('#event_type').on('change', function() {
|
|
|
|
var selectedValue = $(this).val();
|
|
if (selectedValue !== '') {
|
|
$('#import_excel_download').show();
|
|
var fullURL = '<?= base_url("util/download_import_excel/"); ?>' + selectedValue;
|
|
$('#import_excel_download').attr('href', fullURL);
|
|
} else {
|
|
$('#import_excel_download').hide();
|
|
$('#import_excel_download').removeAttr('href');
|
|
}
|
|
});
|
|
|
|
$('#event_type').on('change', function() {
|
|
|
|
var selectedVal = $(this).val();
|
|
var insurer_or_tpa = $('#insurer_or_tpa').val()
|
|
var action_type = $('#action_type').val()
|
|
|
|
console.log({tpa_api_sevice, selectedVal, insurer_or_tpa, action_type});
|
|
|
|
if (tpa_api_sevice == 0 || action_type == 'export' || insurer_or_tpa == "insurer" || (selectedVal == 'correction' || selectedVal == 'deletion' || selectedVal == 'si_enhancement')) {
|
|
$('.fetch_tpa').hide();
|
|
} else {
|
|
$('.fetch_tpa').show();
|
|
}
|
|
|
|
if (selectedVal === 'correction') {
|
|
$('#policy').prop('required', false);
|
|
$('#policy_danger').hide();
|
|
} else {
|
|
$('#policy').prop('required', true);
|
|
$('#policy_danger').show();
|
|
}
|
|
|
|
console.log('tpa_api_sevice', tpa_api_sevice);
|
|
console.log('tpa_api_sevice type', typeof tpa_api_sevice);
|
|
});
|
|
|
|
$('#action_type').on('change', function() {
|
|
|
|
var selectedValue = $(this).val();
|
|
var insurer_or_tpa = $('#insurer_or_tpa').val()
|
|
// console.log(selectedValue);
|
|
|
|
if (selectedValue == '') {
|
|
$('#import_excel_btn').hide();
|
|
$('#export_excel_btn').hide();
|
|
} else if (selectedValue == 'import') {
|
|
$('#import_file').prop('required', true);
|
|
$('#import_file').attr('name', 'import_file_data');
|
|
$('#import_excel_btn').show();
|
|
$('#export_excel_btn').hide();
|
|
} else if (selectedValue == 'export') {
|
|
$('#import_file').removeAttr('name');
|
|
$('#import_file').prop('required', false);
|
|
$('#import_excel_btn').hide();
|
|
$('#export_excel_btn').show();
|
|
}
|
|
|
|
if (tpa_api_sevice == 0 || selectedValue == 'export' || insurer_or_tpa == "insurer") {
|
|
$('.fetch_tpa').hide();
|
|
} else {
|
|
$('.fetch_tpa').show();
|
|
}
|
|
});
|
|
|
|
$('#insurer_or_tpa').on('change', function() {
|
|
|
|
var insurer_or_tpa = $(this).val()
|
|
var policy_value = $('#policy').val()
|
|
var event_type_data = $('#event_type_data').val();
|
|
var action_type = $('#action_type').val()
|
|
var event_string = $('#event_type').val();
|
|
|
|
console.log({tpa_api_sevice, insurer_or_tpa, policy_value, event_type_data, action_type, event_string});
|
|
|
|
if (tpa_api_sevice == 0 || action_type == 'export' || insurer_or_tpa == "insurer" || (event_string == 'correction' || event_string == 'deletion' || event_string == 'si_enhancement')) {
|
|
$('.fetch_tpa').hide();
|
|
} else {
|
|
$('.fetch_tpa').show();
|
|
}
|
|
|
|
// if(insurer_or_tpa == 'tpa' || event_type_data == 0){
|
|
if(insurer_or_tpa == 'tpa'){
|
|
|
|
$("#event_type").removeAttr("multiple");
|
|
$("#event_type").attr("name", "event_type");
|
|
$("#event_type").select2('destroy');
|
|
|
|
}else if(insurer_or_tpa == 'insurer' && action_type == 'import'){
|
|
|
|
$("#event_type").removeAttr("multiple");
|
|
$("#event_type").attr("name", "event_type");
|
|
$("#event_type").select2('destroy');
|
|
|
|
}else if(insurer_or_tpa == 'insurer' && action_type == 'export' && event_type_data == 1){
|
|
|
|
$("#event_type").attr("multiple", "multiple");
|
|
$("#event_type").attr("name", "event_type[]");
|
|
$("#event_type").select2();
|
|
|
|
}else if(insurer_or_tpa == 'insurer' && action_type == 'export' && event_type_data == 0){
|
|
|
|
$("#event_type").removeAttr("multiple");
|
|
$("#event_type").attr("name", "event_type");
|
|
$("#event_type").select2('destroy');
|
|
|
|
}else{
|
|
if(policy_value != 0){
|
|
$("#event_type").attr("multiple", "multiple");
|
|
$("#event_type").attr("name", "event_type[]");
|
|
$("#event_type").select2();
|
|
}
|
|
}
|
|
});
|
|
|
|
$('#action_type').on('change', function() {
|
|
|
|
var action_type = $(this).val()
|
|
var policy_value = $('#policy').val()
|
|
var insurer_or_tpa = $('#insurer_or_tpa').val()
|
|
var event_string = $('#event_type').val();
|
|
var event_type_data = $('#event_type_data').val();
|
|
|
|
console.log({tpa_api_sevice, action_type, policy_value, insurer_or_tpa, event_string, event_type_data})
|
|
|
|
if (tpa_api_sevice == 0 || action_type == 'export' || insurer_or_tpa == "insurer" || (event_string == 'correction' || event_string == 'deletion' || event_string == 'si_enhancement')) {
|
|
$('.fetch_tpa').hide();
|
|
} else {
|
|
$('.fetch_tpa').show();
|
|
}
|
|
|
|
if(action_type == 'import'){
|
|
|
|
$("#event_type").removeAttr("multiple");
|
|
$("#event_type").attr("name", "event_type");
|
|
$("#event_type").select2('destroy');
|
|
|
|
} else if(action_type == 'export' && insurer_or_tpa == 'tpa'){
|
|
|
|
$("#event_type").removeAttr("multiple");
|
|
$("#event_type").attr("name", "event_type");
|
|
$("#event_type").select2('destroy');
|
|
|
|
}else if(action_type == 'export' && insurer_or_tpa == 'insurer' && event_type_data == 1){
|
|
|
|
$("#event_type").attr("multiple", "multiple");
|
|
$("#event_type").attr("name", "event_type[]");
|
|
$("#event_type").select2();
|
|
|
|
}else if(action_type == 'export' && insurer_or_tpa == 'insurer' && event_type_data == 0){
|
|
|
|
$("#event_type").removeAttr("multiple");
|
|
$("#event_type").attr("name", "event_type");
|
|
$("#event_type").select2('destroy');
|
|
|
|
}else{
|
|
if(policy_value != 0){
|
|
$("#event_type").attr("multiple", "multiple");
|
|
$("#event_type").attr("name", "event_type[]");
|
|
$("#event_type").select2();
|
|
}
|
|
}
|
|
});
|
|
|
|
});
|
|
|
|
// Function to convert object to query parameters
|
|
function objectToQueryString2(obj) {
|
|
return Object.keys(obj).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`).join('&');
|
|
}
|
|
|
|
function fetchEmpolyeeList2(event) {
|
|
event.preventDefault(); // Prevent default action
|
|
|
|
var client_id = $('#client').val();
|
|
var policy_id = $('#policy').val();
|
|
// console.log(client_id + '-' + policy_id);
|
|
if (client_id == '0' || policy_id == '0') {
|
|
alert('Please select values in both dropdowns.');
|
|
return;
|
|
}
|
|
|
|
var queryParams = {
|
|
client_id: client_id,
|
|
policy_id: policy_id
|
|
};
|
|
|
|
const queryString = objectToQueryString2(queryParams);
|
|
const apiURL = $('#get-emp-list').attr('href') + "?" + queryString;
|
|
// console.log(apiURL);
|
|
window.location.href = apiURL;
|
|
|
|
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------
|
|
|
|
document.getElementById('toggleIcon').addEventListener('click', function() {
|
|
var icon = document.getElementById('icon');
|
|
icon.classList.toggle('mdi-chevron-down');
|
|
icon.classList.toggle('mdi-chevron-up');
|
|
});
|
|
|
|
//------------------------------------------------------------------------------------------------------
|
|
|
|
$('#import_excel_download').click(function() {
|
|
|
|
// Check if the element with ID "import_excel_download" has the href attribute set
|
|
if (!$(this).attr('href')) {
|
|
// If href attribute is not set, show an error message
|
|
toastr.warning('Please select an Action to download a sample Excel.', 'Warning');
|
|
} else {
|
|
// console.log('Download action triggered.');
|
|
}
|
|
});
|
|
|
|
//------------- CHECK CD BALANCE in SESSION -----------------------------------------------------------------------------------------
|
|
|
|
// Global variables
|
|
var submitInterval = null;
|
|
var messageShown = false; // Flag to prevent duplicate messages
|
|
|
|
//function for checking the session
|
|
function checkCDBalance() {
|
|
|
|
<?php if (session()->has('cd_balance')): ?>
|
|
var cdBalance = <?php echo json_encode(session()->get('cd_balance')); ?>;
|
|
var cdAmount = <?php echo json_encode(session()->get('cd_amount')); ?>;
|
|
var excel_file_amt = <?php echo json_encode(session()->get('excel_file_amt')); ?>;
|
|
|
|
console.log("cdBalance : ", cdBalance);
|
|
console.log("cdAmount : ", cdAmount);
|
|
console.log("excel_file_amt : ", excel_file_amt);
|
|
|
|
// Only show message once and if status is false
|
|
if (cdBalance === false && !messageShown) {
|
|
// toastr.warning('Insufficient CD Balance deducated. Please wait the file will be downloaded', 'WARNING');
|
|
var message1 = 'Insufficient CD Balance deducted. Please wait the file will be downloaded<br>' +
|
|
'<strong>CD Amount:</strong> ₹' + (cdAmount || 0) + '<br>' +
|
|
'<strong>Total Amount:</strong> ₹' + (excel_file_amt || 0);
|
|
|
|
toastr.warning(message1, 'WARNING', {
|
|
allowHtml: true,
|
|
timeOut: 10000,
|
|
extendedTimeOut: 3000
|
|
});
|
|
messageShown = true; // Prevent showing message again
|
|
stopInterval();
|
|
} else if (cdBalance === true) {
|
|
console.log("CD Balance is sufficient");
|
|
stopInterval();
|
|
}
|
|
|
|
<?php
|
|
session()->remove('cd_balance');
|
|
session()->remove('cd_amount');
|
|
session()->remove('excel_file_amt');
|
|
?>
|
|
|
|
<?php else: ?>
|
|
console.log("No cd_balance session found");
|
|
<?php endif; ?>
|
|
}
|
|
|
|
// Start the interval
|
|
function startInterval() {
|
|
if (!submitInterval) {
|
|
messageShown = false; // Reset message flag
|
|
submitInterval = setInterval(function() {
|
|
checkCDBalance();
|
|
}, 2000);
|
|
console.log("Checking CD balance started...");
|
|
}
|
|
}
|
|
|
|
// Stop the interval
|
|
function stopInterval() {
|
|
if (submitInterval) {
|
|
clearInterval(submitInterval);
|
|
submitInterval = null;
|
|
<?php
|
|
session()->remove('cd_balance');
|
|
session()->remove('cd_amount');
|
|
session()->remove('excel_file_amt');
|
|
?>
|
|
console.log("Interval stopped.");
|
|
}
|
|
}
|
|
|
|
// When click the button to start the interval
|
|
$(document).ready(function() {
|
|
$('#emp_form_submit_button_2').on('click', function() {
|
|
console.log("Submit button clicked, starting interval...");
|
|
startInterval();
|
|
});
|
|
});
|
|
|
|
//------------------------------------------------------------------------------------------------------
|
|
|
|
</script>
|
|
<script>
|
|
|
|
function togglePolicyIssueDate() {
|
|
let insurer = $('#insurer_or_tpa').val();
|
|
let action = $('#action_type').val();
|
|
if (insurer === 'insurer' && action === 'import') {
|
|
$('.policy_issue_date_row').show();
|
|
$('#policy_issue_date').attr('required', true);
|
|
$('#policy_issue_date_label').html('Policy Issue Date <span class="text-danger">*</span>');
|
|
} else {
|
|
$('.policy_issue_date_row').hide();
|
|
$('#policy_issue_date').removeAttr('required').val('');
|
|
$('#policy_issue_date_label').text('Policy Issue Date');
|
|
}
|
|
}
|
|
|
|
function fetchTpaIdFromTpa(){
|
|
let user_confirm = confirm('Are you sure you want to initiate the TPA fetch? This may take a while.');
|
|
if(!user_confirm)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
let event = $('#event_type').val();
|
|
let client_id = $('#client').val();
|
|
let branch_id = $('#client_branch_id').val();
|
|
let policy_id = $('#policy').val();
|
|
let tpa_id = $('#policy option:selected').data('tid');
|
|
let policy_no = $('#policy option:selected').data('pno');
|
|
|
|
let checks = [
|
|
{val: client_id, msg: 'Please select the client'},
|
|
{val: branch_id, msg: 'Please select the client branch'},
|
|
{val: policy_id, msg: 'Please select the policy'},
|
|
{val: event, msg: 'Please select the event'},
|
|
{val: tpa_id, msg: 'TPA id empty'},
|
|
{val: policy_no, msg: 'Policy No empty'},
|
|
];
|
|
|
|
for (let c of checks) {
|
|
if (!c.val || c.val == 0) {
|
|
toastr.warning(c.msg, 'WARNING');
|
|
return;
|
|
}
|
|
}
|
|
|
|
let url = '<?= base_url('getTPAID') ?>';
|
|
|
|
// Data to send in the AJAX request
|
|
let requestData = {
|
|
policy_no: policy_no,
|
|
tpa_id: tpa_id,
|
|
client_id: client_id,
|
|
client_branch_id: branch_id,
|
|
client_policy_id: policy_id,
|
|
};
|
|
|
|
// Send AJAX request
|
|
sendAjaxRequestForGlobal(url, 'POST', requestData, function(response) {
|
|
|
|
console.log('Data fetched successfully:', response);
|
|
|
|
if (response.status == true) {
|
|
toastr.success(response.message || 'Initiating successafully', 'SUCCESS');
|
|
} else {
|
|
toastr.error(response.message || 'Unable to fetch data', 'ERROR');
|
|
}
|
|
|
|
}, function(xhr, status, error) {
|
|
console.error('Error fetching data:', error);
|
|
console.error(xhr.responseText);
|
|
toastr.error('An error occurred while checking the CD amount.', 'ERROR');
|
|
});
|
|
|
|
|
|
}
|
|
|
|
</script>
|