795 lines
32 KiB
PHP
795 lines
32 KiB
PHP
<style>
|
||
|
||
option:disabled {
|
||
color: gray !important; /* Set text color to gray */
|
||
background-color: lightgray !important;}
|
||
|
||
</style>
|
||
|
||
<div class="tab-pane fade active show" id="general-q-tab">
|
||
<div class="row">
|
||
<div class="col-xl-12">
|
||
<div id="accordion1" class="mb-3">
|
||
<div class="card mb-1">
|
||
<h5 class="m-1">
|
||
<a id="toggleIcon1" class="text-dark float-right" data-toggle="collapse" href="#collapseTwo"
|
||
aria-expanded="true">
|
||
<i id="icon1" class="mdi mdi-chevron-down mr-1 text-primary" style="font-size: 28px;"></i>
|
||
</a>
|
||
</h5>
|
||
<div id="collapseTwo" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion1">
|
||
<div class="card-body">
|
||
<!-- <div class="text-center"> -->
|
||
<form class="parsley-examples" id="emp-upload-form"
|
||
action="<?php echo base_url().'employee/upload'?>" method="post">
|
||
<input type="hidden" name="<?= csrf_token() ?>" value="<?= csrf_hash() ?>"
|
||
id="csrf_token">
|
||
|
||
<div class="form-group">
|
||
|
||
<div class="form-row">
|
||
|
||
<div class="form-group col-md-4">
|
||
<label>Client</label> <br />
|
||
<select name="client_id" class="form-control" id="client_id" required>
|
||
<option value="0">Select</option>
|
||
</select>
|
||
</div>
|
||
|
||
<div class="form-group col-md-4">
|
||
<label>Policy</label> <br />
|
||
<select name="policy_id" class="form-control" id="policy_id" onchange="checkPolicyTermsAndRackRatesHasDefiend(event)">
|
||
<option value="0">Select</option>
|
||
</select>
|
||
</div>
|
||
|
||
<div class="form-group col-md-4">
|
||
<label>Event</label> <br />
|
||
<select name="upload-action-type" class="form-control"
|
||
id="upload-action-type" required>
|
||
<option value="">Select</option>
|
||
<?php
|
||
if(isset($actions) && count($actions))
|
||
{
|
||
foreach($actions as $key => $action)
|
||
{
|
||
echo "<option value=".$key.">".$action."</option>";
|
||
}
|
||
}
|
||
?>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
|
||
<hr>
|
||
|
||
<div class="form-row" id="file_upload">
|
||
|
||
<div class="form-group col-md-4">
|
||
<label>Upload file</label> [ <a id="excel_download"
|
||
data-toggle="tooltip" data-placement="top"
|
||
title="Download Sample Excel">Sample Excel</a> ]
|
||
<input type="file" name="emplist" id="emplist"
|
||
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-11">
|
||
<!-- Adjusted the width to 11 columns -->
|
||
<div class="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>
|
||
|
||
|
||
<div class="form-group col-md-2"
|
||
style="margin-top: 26px;position: relative;left: 65px;"> OR </div>
|
||
|
||
<div class="form-group col-md-4" style="margin-top: 18px;">
|
||
<a class="btn btn-primary waves-effect waves-light justify-content-end"
|
||
id="fetch_enrolled_data" data-toggle="modal"
|
||
data-target="#full-width-modal" title="Download Sample Excel">Featch
|
||
Enrolled Data</a>
|
||
</div>
|
||
|
||
|
||
</div>
|
||
|
||
</div>
|
||
|
||
</form>
|
||
<!-- </div> -->
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- end page title -->
|
||
<div class="row" id="file_list">
|
||
<?php include('file_list.php');?>
|
||
</div>
|
||
<!-- end row -->
|
||
|
||
</div>
|
||
|
||
|
||
<div id="full-width-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="fullWidthModalLabel"
|
||
aria-hidden="true">
|
||
<div class="modal-dialog modal-full-width">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<h4 class="modal-title" id="fullWidthModalLabel">Enrolled Employee List</h4>
|
||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||
</div>
|
||
<div class="modal-body" id="emp_data">
|
||
|
||
</div>
|
||
<div class="modal-footer">
|
||
<a id="fetch_btn" class="btn btn-primary">Initiate Emp Onboard</a>
|
||
</div>
|
||
</div><!-- /.modal-content -->
|
||
</div><!-- /.modal-dialog -->
|
||
</div><!-- /.modal -->
|
||
|
||
|
||
|
||
<!-- Center modal content -->
|
||
<div class="modal fade" id="file-err-modal" tabindex="-1" role="dialog" aria-hidden="true">
|
||
<div class="modal-dialog modal-dialog-centered">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<h4 class="modal-title" id="myCenterModalLabel">File Rejected Reason</h4>
|
||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||
</div>
|
||
<div class="modal-body">
|
||
|
||
</div>
|
||
</div>
|
||
</div><!-- /.modal-dialog -->
|
||
</div><!-- /.modal -->
|
||
|
||
|
||
<script>
|
||
$('#file_upload').hide();
|
||
|
||
$(document).ready(function() {
|
||
|
||
<?php if (session()->has('success1')): ?>
|
||
toastr.success('<?= session()->getFlashdata('success1') ?>', 'success');
|
||
<?php endif; ?>
|
||
// Initialize select2
|
||
$("#client_id").select2();
|
||
$("#policy_id").select2();
|
||
});
|
||
|
||
// Declare a global variable to store API response data
|
||
var clientPolicies = [];
|
||
|
||
$(document).ready(function() {
|
||
|
||
console.log("document loaded");
|
||
//fetchClientPolicies();
|
||
//for modal pop up
|
||
$('#file-err-modal').on('show.bs.modal', function(event) {
|
||
// console.log(event.relatedTarget);
|
||
var myVal = $(event.relatedTarget).data('err');
|
||
console.log(myVal);
|
||
var loader =
|
||
'<div style="text-align: center;"><img src="<?php echo base_url()?>public/assets/images/simple_loader.gif" height="50px" width="50px" ></div>';
|
||
$('#file-err-modal').find(".modal-body").html(loader);
|
||
var model_data = fetchFileError(myVal);
|
||
// console.log('data received.');
|
||
// console.log(model_data);
|
||
|
||
});
|
||
|
||
//for form submit
|
||
$("#emp-upload-form").submit(function(event) {
|
||
event.preventDefault(); // Prevent default form submission
|
||
console.log('submit called');
|
||
|
||
|
||
var isValid = $('#emp-upload-form').parsley().validate();
|
||
if (!isValid) {
|
||
console.log('Form is Empty', 'Warning');
|
||
return;
|
||
}
|
||
|
||
var action_item = $('#upload-action-type').val();
|
||
var policy_id = $('#policy_id').val();
|
||
console.log('action_item - ' + action_item);
|
||
if (action_item != 'correction' && policy_id == "") {
|
||
// $('#policy_id').attr('required', true);
|
||
// $('#policy_id').prop('title', 'plz choose policy');
|
||
// $('#policy_id').mouseover();
|
||
console.log('required');
|
||
// alert('please choose policy for this uploaing event ');
|
||
toastr.warning('please choose policy for this uploaing event', 'warning')
|
||
return false;
|
||
|
||
} else {
|
||
|
||
$('#policy_id').attr('required', false);
|
||
console.log('not required');
|
||
}
|
||
|
||
// Create FormData object
|
||
var formData = new FormData($(this)[0]);
|
||
for (var pair of formData.entries()) {
|
||
console.log(pair[0] + ', ' + pair[1]);
|
||
}
|
||
|
||
console.log(formData);
|
||
$('#emp_form_submit_button').prop('disabled', true);
|
||
$('#emp_form_submit_button').html(
|
||
'<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> Loading...'
|
||
);
|
||
// return false;
|
||
$.ajax({
|
||
url: $(this).attr("action"),
|
||
type: "POST",
|
||
data: formData,
|
||
processData: false, // Prevent jQuery from automatically processing the data
|
||
contentType: false, // Let jQuery handle the content type
|
||
headers: {
|
||
// "Content-Type":"multipart/form-data",
|
||
"X-Requested-With": "XMLHttpRequest"
|
||
},
|
||
success: function(response) {
|
||
// Request successful, handle response
|
||
$('#policy_id').attr('required', false);
|
||
console.log(response);
|
||
if (response.code === 200 && response.dataStatus === true && response
|
||
.data !== "") {
|
||
toastr.success(
|
||
'File upload successs, Data validation is in-progress',
|
||
'success');
|
||
window.location.reload(true);
|
||
} else if (response.code === 404 && response.dataStatus === false) {
|
||
console.error('no data found', response);
|
||
// alert(response.message);
|
||
toastr.error(response.message, 'Failed');
|
||
window.location.reload(true);
|
||
} else {
|
||
console.error('Something went wrong!');
|
||
// alert('Something went wrong! Try later');
|
||
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);
|
||
toastr.error('Something went wrong! Try later', 'Error');
|
||
window.location.reload(true);
|
||
}
|
||
});
|
||
}); //end
|
||
|
||
|
||
|
||
});
|
||
|
||
$(window).on("load", function() {
|
||
console.log("window loaded");
|
||
fetchClientPolicies();
|
||
});
|
||
|
||
|
||
function fetchClientPolicies() {
|
||
$('#loader').show();
|
||
var apiURL = '<?php echo base_url();?>' + 'util/clients-with-policies';
|
||
console.log('fetchClientPolicies');
|
||
console.log(apiURL);
|
||
$.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);
|
||
appendClients(clientPolicies);
|
||
} 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 fetchFileError(file_id) {
|
||
$('#loader').show();
|
||
var apiURL = '<?php echo base_url();?>' + 'util/get-file-error/' + file_id;
|
||
console.log('fetchFileError');
|
||
console.log(apiURL);
|
||
$.ajax({
|
||
url: apiURL,
|
||
method: 'GET',
|
||
headers: {
|
||
"X-Requested-With": "XMLHttpRequest"
|
||
},
|
||
success: function(response) {
|
||
|
||
$(this).find(".modal-body").html("");
|
||
if (response.code === 200 && response.dataStatus === true && response.data !== "") {
|
||
try {
|
||
console.log((JSON.parse(response.data)));
|
||
var file_error_data = (JSON.parse(response.data));
|
||
var file_error_html = "";
|
||
|
||
for (var key in file_error_data['error_summary']) {
|
||
// console.log(key);
|
||
var err_id = parseInt(key);
|
||
var err_count = file_error_data['error_summary'][key];
|
||
switch (err_id) {
|
||
case 1:
|
||
file_error_html +=
|
||
"<strong>Mandatory values missing</strong> <span class='badge badge-danger float-right'>" +
|
||
err_count + "</span>";
|
||
break;
|
||
case 2:
|
||
file_error_html +=
|
||
"<strong>Values not in expected format</strong> <span class='badge badge-danger float-right'>" +
|
||
err_count + "</span>";
|
||
break;
|
||
case 3:
|
||
file_error_html +=
|
||
"<strong>Field contains not allowed values</strong> <span class='badge badge-danger float-right'>" +
|
||
err_count + "</span>";
|
||
break;
|
||
case 4:
|
||
file_error_html +=
|
||
"<strong>Rule Conflict</strong> <span class='badge badge-danger float-right'>" +
|
||
err_count + "</span>";
|
||
break;
|
||
case 5:
|
||
file_error_html += "<strong>" + file_error_data['error_data'] + "</strong>";
|
||
break;
|
||
case 6:
|
||
file_error_html += "<strong>" + file_error_data['error_data'] + "</strong>";
|
||
break;
|
||
case 7:
|
||
file_error_html +=
|
||
"<strong>Duplicate entry in file</strong> <span class='badge badge-danger float-right'>" +
|
||
err_count + "</span>";
|
||
break;
|
||
case 8:
|
||
file_error_html += "to be config";
|
||
break;
|
||
case 9:
|
||
file_error_html +=
|
||
"<strong>Duplicate entry</strong> <span class='badge badge-danger float-right'>" +
|
||
err_count + "</span>";
|
||
break;
|
||
case 10:
|
||
file_error_html +=
|
||
"<strong>Duplicate entry in file</strong> <span class='badge badge-danger float-right'>" +
|
||
err_count + "</span>";
|
||
break;
|
||
case 11:
|
||
file_error_html +=
|
||
"<strong>Rule conflict: Dependents not allowed</strong> <span class='badge badge-danger float-right'>" +
|
||
err_count + "</span>";
|
||
break;
|
||
case 12:
|
||
file_error_html +=
|
||
"<strong>Rule conflict: Dependent count greater than allowed dependent count</strong> <span class='badge badge-danger float-right'>" +
|
||
err_count + "</span>";
|
||
break;
|
||
case 13:
|
||
file_error_html +=
|
||
"<strong>Rule conflict: Twofold relationship found within family</strong> <span class='badge badge-danger float-right'>" +
|
||
err_count + "</span>";
|
||
break;
|
||
|
||
default:
|
||
file_error_html += "";
|
||
break;
|
||
}
|
||
|
||
// console.log('file_error_html_1', file_error_html)
|
||
|
||
// file_error_html += (err_id == 1 ?
|
||
// "<strong>Mandatory values missing</strong> <span class='badge badge-danger float-right'>" +
|
||
// err_count + "</span>" : (err_id == 2 ?
|
||
// "<strong>Values not in expected format</strong> <span class='badge badge-danger float-right'>" +
|
||
// err_count + "</span>" : (err_id == 3 ?
|
||
// "<strong>Field contains not allowed values</strong> <span class='badge badge-danger float-right'>" +
|
||
// err_count + "</span>" : (err_id == 4 ?
|
||
// "<strong>Rule Conflict</strong> <span class='badge badge-danger float-right'>" +
|
||
// err_count + "</span>" : (err_id == 5 ? "<strong>" +
|
||
// file_error_data['error_data'] + "</strong>" : (err_id ==
|
||
// 6 ?
|
||
// "<strong>" + file_error_data['error_data'] +
|
||
// "</strong>" : ""))))));
|
||
file_error_html += '<br/>';
|
||
// // }
|
||
|
||
// console.log('file_error_html_2', file_error_html)
|
||
|
||
}
|
||
if (err_id != 5 && err_id != 6) {
|
||
file_error_html += (file_error_html != "" ?
|
||
"<a href ='<?php echo base_url()?>" +
|
||
"employee/excel_error/" + file_id +
|
||
"' target=_blank>click here to more details...</a>" : "");
|
||
}
|
||
|
||
// console.log(file_error_html);
|
||
$('#file-err-modal').find(".modal-body").html(file_error_html);
|
||
return file_error_html;
|
||
} 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 appendClients(data) {
|
||
$.each(data, function(index, item) {
|
||
$('#client_id').append($('<option>', {
|
||
value: item.id,
|
||
text: item.client_name
|
||
}));
|
||
});
|
||
}
|
||
|
||
function appendPolicies(data) {
|
||
$('#policy_id').empty();
|
||
$('#policy_id').append($('<option>', {
|
||
value: '',
|
||
text: 'Select'
|
||
}));
|
||
$.each(data, function(index, item) {
|
||
$('#policy_id').append($('<option>', {
|
||
value: item.id,
|
||
text: item.name + ' ('+ item.policy_type+')'
|
||
}));
|
||
});
|
||
}
|
||
|
||
$(document).ready(function() {
|
||
|
||
$('#client_id').on('change', function() {
|
||
var selectedClient = $(this).val();
|
||
|
||
console.log('selectedClient', selectedClient);
|
||
// $('#selectedOptionInfo').text('Selected option: ' + selectedOption);
|
||
|
||
// Check if the selected option exists in apiData
|
||
var foundPolicies = clientPolicies.find(function(item) {
|
||
return item.id === selectedClient;
|
||
});
|
||
console.log(foundPolicies.policies);
|
||
appendPolicies(foundPolicies.policies);
|
||
|
||
});
|
||
|
||
});
|
||
|
||
// Function to convert object to query parameters
|
||
function objectToQueryString(obj) {
|
||
return Object.keys(obj).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`).join('&');
|
||
}
|
||
|
||
function fetchEmpolyeeList(event) {
|
||
event.preventDefault(); // Prevent default action
|
||
|
||
var client_id = $('#client_id').val();
|
||
var policy_id = $('#policy_id').val();
|
||
console.log(client_id + '-' + policy_id);
|
||
if (client_id == '0' || policy_id == '0') {
|
||
toastr.warning('Please select values in both dropdowns.');
|
||
return;
|
||
}
|
||
|
||
var queryParams = {
|
||
client_id: client_id,
|
||
policy_id: policy_id
|
||
};
|
||
|
||
const queryString = objectToQueryString(queryParams);
|
||
const apiURL = $('#get-emp-list').attr('href') + "?" + queryString;
|
||
console.log(apiURL);
|
||
window.location.href = apiURL;
|
||
|
||
|
||
// var apiURL2 = $('#get-emp-list').attr('href'); // Get href attribute value
|
||
// console.log(apiURL);
|
||
// $.ajax({
|
||
// url: apiURL,
|
||
// method: 'GET',
|
||
// data: queryParams,
|
||
// success: function(response) {
|
||
// // Assuming response is a JSON array
|
||
// // displayDataTables(response);
|
||
// console.log(response);
|
||
// },
|
||
// error: function(xhr, status, error) {
|
||
// console.error('Error:', error);
|
||
// }
|
||
// });
|
||
}
|
||
|
||
//--------------------------------------------------------------------------------------
|
||
|
||
|
||
/**This function updates the download link based on the selected option in the dropdown menu. **/
|
||
$('#upload-action-type').change(function() {
|
||
|
||
var selectedValue = $(this).val();
|
||
if (selectedValue !== '') {
|
||
$('#file_upload').show();
|
||
var fullURL = '<?= base_url("util/download-excel/"); ?>' + selectedValue;
|
||
$('#excel_download').attr('href', fullURL);
|
||
} else {
|
||
$('#file_upload').hide();
|
||
$('#excel_download').removeAttr('href');
|
||
}
|
||
});
|
||
|
||
|
||
/** This function verifies if the download link (#excel_download) has its href attribute set,
|
||
** ensuring proper link configuration. **/
|
||
|
||
$('#excel_download').click(function() {
|
||
|
||
// Check if the element with ID "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.');
|
||
}
|
||
});
|
||
|
||
document.getElementById('toggleIcon1').addEventListener('click', function() {
|
||
var icon = document.getElementById('icon1');
|
||
icon.classList.toggle('mdi-chevron-down');
|
||
icon.classList.toggle('mdi-chevron-up');
|
||
});
|
||
|
||
|
||
$('#fetch_enrolled_data').click(function()
|
||
{
|
||
|
||
var policy_id = $('#policy_id').val();
|
||
var uri = '<?= base_url('util/init-Emp-onboard/') ?>' + policy_id;
|
||
console.log(policy_id);
|
||
console.log(uri);
|
||
$('#fetch_btn').attr('href', uri);
|
||
|
||
$('#emp_data').empty();
|
||
var client_id = $('#client_id').val();
|
||
var policy_id = $('#policy_id').val();
|
||
var action = $('#upload-action-type').val();
|
||
console.log(client_id + '-' + policy_id);
|
||
if (client_id == '0' || policy_id == '0') {
|
||
toastr.warning('please select the client and policy for this uploaing event', 'warning')
|
||
$('#full-width-modal').modal('hide');
|
||
return;
|
||
}
|
||
|
||
var queryParams = {
|
||
client_id: client_id,
|
||
policy_id: policy_id,
|
||
action: action
|
||
};
|
||
|
||
console.log('queryParams', queryParams)
|
||
const queryString = objectToQueryString(queryParams);
|
||
console.log('queryString', queryString)
|
||
|
||
$('.loader').fadeIn();
|
||
$('.loader-mask').fadeIn();
|
||
var uri = '<?= base_url('util/featch-emp-list')?>?' + queryString
|
||
console.log(uri)
|
||
|
||
$.ajax({
|
||
url: uri,
|
||
data: {
|
||
client_id: client_id,
|
||
policy_id: policy_id
|
||
},
|
||
type: "GET",
|
||
dataType: 'json',
|
||
processData: false,
|
||
contentType: false,
|
||
success: function(res) {
|
||
|
||
console.log(res);
|
||
|
||
if (res) {
|
||
setTimeout(function() {
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
}, 1000);
|
||
}
|
||
|
||
$('#emp_data').html(res.data);
|
||
},
|
||
error: function(xhr, status, error) {
|
||
console.error(xhr.responseText);
|
||
console.error(status, error);
|
||
setTimeout(function() {
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
toastr.warning('Something went wrong', 'Warning');
|
||
|
||
}, 1000);
|
||
}
|
||
});
|
||
|
||
})
|
||
|
||
$(document).ready(function() {
|
||
|
||
$('#policy_id').change(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);
|
||
$.ajax({
|
||
url: apiURL,
|
||
method: 'GET',
|
||
headers: {
|
||
"Content-Type": "application/json",
|
||
"X-Requested-With": "XMLHttpRequest"
|
||
},
|
||
success: function(response) {
|
||
|
||
console.log('responce data emp_count', response);
|
||
|
||
if (response.code === 200 && response.dataStatus === true && response.data !== "") {
|
||
try {
|
||
console.log(response.emp_count.length)
|
||
if(response.emp_count > 0){
|
||
|
||
var select = document.getElementById("upload-action-type");
|
||
for (var i = 0; i < select.options.length; i++) {
|
||
if (select.options[i].value === "inception") {
|
||
select.options[i].disabled = true;
|
||
break;
|
||
}
|
||
}
|
||
}else{
|
||
|
||
var select = document.getElementById("upload-action-type");
|
||
for (var i = 0; i < select.options.length; i++) {
|
||
if (select.options[i].value === "inception") {
|
||
select.options[i].disabled = false;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
|
||
} 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);
|
||
var select = document.getElementById("upload-action-type");
|
||
for (var i = 0; i < select.options.length; i++) {
|
||
if (select.options[i].value === "inception") {
|
||
select.options[i].disabled = false;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
});
|
||
|
||
})
|
||
|
||
})
|
||
|
||
|
||
function checkPolicyTermsAndRackRatesHasDefiend(event)
|
||
{
|
||
console.log(event.target.id);
|
||
var policy_id = (event.target.value);
|
||
console.log('checkPolicyTermsAndRackRatesHasDefiend called ' + policy_id);
|
||
var apiURL = '<?php echo base_url();?>' + 'util/has_policy_config_completed/' + policy_id;
|
||
console.log(apiURL);
|
||
|
||
$('.loader').fadeIn();
|
||
$('.loader-mask').fadeIn();
|
||
|
||
|
||
$.ajax({
|
||
url: apiURL,
|
||
method: 'GET',
|
||
headers: {
|
||
"Content-Type": "application/json",
|
||
"X-Requested-With": "XMLHttpRequest"
|
||
},
|
||
success: function(response) {
|
||
|
||
setTimeout(function() {
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
}, 1000);
|
||
|
||
console.log('check policy responce', response);
|
||
|
||
if (response.code === 200 && response.dataStatus === true && response.message !== null) {
|
||
toastr.error(response.message, 'Error');
|
||
$('#emp_form_submit_button').prop('disabled', true);
|
||
return false;
|
||
}
|
||
else if(response.code === 200 && response.dataStatus === true && response.message == null)
|
||
{
|
||
// toastr.error('Policy Terms or rack rate not defined!', 'Error');
|
||
$('#emp_form_submit_button').prop('disabled', false);
|
||
return true;
|
||
}
|
||
else
|
||
{
|
||
toastr.error('Policy Terms or rack rate not defined!', 'Error');
|
||
return false;
|
||
}
|
||
},
|
||
error: function(xhr, status, error) {
|
||
setTimeout(function() {
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
}, 1000);
|
||
toastr.error('Something went wrong! Try Later', 'Error');
|
||
console.error('Error fetching data from checkPolicyTermsAndRackRatesHasDefiend API:', error);
|
||
return false;
|
||
}
|
||
});
|
||
|
||
}
|
||
|
||
|
||
//---------------------------------------------------------------------------------------------------------
|
||
</script>
|