272 lines
8.1 KiB
JavaScript
272 lines
8.1 KiB
JavaScript
|
|
// to check if report is selected or not before selecting the chart
|
|
function chartValidate() {
|
|
var id = $("#report_type").val();
|
|
if (id == '' || id == null) {
|
|
BootstrapDialog.alert("Please select the report first and this chart type will be applied to your selected report");
|
|
return;
|
|
}
|
|
}
|
|
|
|
// to show report panel
|
|
|
|
function showReportPanel() {
|
|
var getSelectedValue = document.querySelector('input[name="isYes"]:checked');
|
|
// alert(getSelectedValue.value);
|
|
var need = getSelectedValue.value;
|
|
$('#report_type').html(" ");
|
|
$('#report_type').append('<option value=""> </option>');
|
|
if (need === "PSR") {
|
|
$("#main-filter-container").show();
|
|
$.ajax({
|
|
type: 'post',
|
|
url: 'select_reports_accordingly.php',
|
|
data: {
|
|
need: need
|
|
},
|
|
dataType: 'json',
|
|
success: function (data) {
|
|
if (data != '' && data != null) {
|
|
$("#report_type").append(data);
|
|
}
|
|
},
|
|
error: function (data) {
|
|
BootstrapDialog.alert('Unable to fetch reports!!!!');
|
|
}
|
|
})
|
|
} else {
|
|
$.ajax({
|
|
type: 'post',
|
|
url: 'select_reports_accordingly.php',
|
|
data: {
|
|
need: need
|
|
},
|
|
dataType: 'json',
|
|
success: function (data) {
|
|
if (data != '' && data != null) {
|
|
// alert(data);
|
|
$("#report_type").append(data);
|
|
}
|
|
},
|
|
error: function (data) {
|
|
BootstrapDialog.alert('Unable to fetch reports!!!!');
|
|
}
|
|
})
|
|
$("#main-filter-container").show();
|
|
}
|
|
}
|
|
|
|
// to clean all options that are selected in filters
|
|
|
|
function cleanOptions(selected_tag) {
|
|
if (selected_tag == 'ohc_location') {
|
|
|
|
$("#report_div").css('display', 'none');
|
|
$("#patient_category").val("");
|
|
$('#patient_category').trigger('chosen:updated');
|
|
$("#dept").val("");
|
|
$('#dept').trigger('chosen:updated');
|
|
$("#emp_designation").val("");
|
|
$('#emp_designation').trigger('chosen:updated');
|
|
$("#emp_cadre").val("");
|
|
$('#emp_cadre').trigger('chosen:updated');
|
|
$("#employer_contractor").val("");
|
|
$('#employer_contractor').trigger('chosen:updated');
|
|
$("#gender").val("");
|
|
$('#gender').trigger('chosen:updated');
|
|
} else if (selected_tag == 'patient_category') {
|
|
// $("#mybtn").prop('disabled',true);
|
|
$("#report_div").css('display', 'none');
|
|
$("#dept").val("");
|
|
$('#dept').trigger('chosen:updated');
|
|
$("#emp_designation").val("");
|
|
$('#emp_designation').trigger('chosen:updated');
|
|
$("#emp_cadre").val("");
|
|
$('#emp_cadre').trigger('chosen:updated');
|
|
$("#employer_contractor").val("");
|
|
$('#employer_contractor').trigger('chosen:updated');
|
|
$("#gender").val("");
|
|
$('#gender').trigger('chosen:updated');
|
|
} else if (selected_tag == 'dept') {
|
|
// $("#mybtn").prop('disabled',true);
|
|
$("#report_div").css('display', 'none');
|
|
$("#emp_designation").val("");
|
|
$('#emp_designation').trigger('chosen:updated');
|
|
$("#emp_cadre").val("");
|
|
$('#emp_cadre').trigger('chosen:updated');
|
|
$("#employer_contractor").val("");
|
|
$('#employer_contractor').trigger('chosen:updated');
|
|
$("#gender").val("");
|
|
$('#gender').trigger('chosen:updated');
|
|
} else if (selected_tag == 'emp_designation') {
|
|
$("#report_div").css('display', 'none');
|
|
// $("#mybtn").prop('disabled',true);
|
|
$("#emp_cadre").val("");
|
|
$('#emp_cadre').trigger('chosen:updated');
|
|
$("#employer_contractor").val("");
|
|
$('#employer_contractor').trigger('chosen:updated');
|
|
$("#gender").val("");
|
|
$('#gender').trigger('chosen:updated');
|
|
} else if (selected_tag == 'emp_cadre') {
|
|
// $("#mybtn").prop('disabled',true);
|
|
$("#report_div").css('display', 'none');
|
|
$("#employer_contractor").val("");
|
|
$('#employer_contractor').trigger('chosen:updated');
|
|
$("#gender").val("");
|
|
$('#gender').trigger('chosen:updated');
|
|
} else if (selected_tag == 'employer_contractor') {
|
|
$("#report_div").css('display', 'none');
|
|
// $("#mybtn").prop('disabled',true);
|
|
$("#gender").val("");
|
|
$('#gender').trigger('chosen:updated');
|
|
} else if (selected_tag == 'gender') {
|
|
$("#report_div").css('display', 'none');
|
|
} else if (selected_tag == 'startDate') {
|
|
$("#report_div").css('display', 'none');
|
|
// $("#mybtn").prop('disabled',true);
|
|
// $("#report_type").val("");
|
|
// $('#report_type').trigger('chosen:updated');
|
|
} else if (selected_tag == 'endDate') {
|
|
$("#report_div").css('display', 'none');
|
|
// $("#mybtn").prop('disabled',true);
|
|
// $("#report_type").val("");
|
|
// $('#report_type').trigger('chosen:updated');
|
|
} else if (selected_tag == 'month') {
|
|
$("#report_div").css('display', 'none');
|
|
// $("#mybtn").prop('disabled',true);
|
|
// $("#report_type").val("");
|
|
// $('#report_type').trigger('chosen:updated');
|
|
} else if (selected_tag == 'year') {
|
|
$("#report_div").css('display', 'none');
|
|
// $("#mybtn").prop('disabled',true);
|
|
// $("#report_type").val("");
|
|
// $('#report_type').trigger('chosen:updated');
|
|
} else if (selected_tag == 'report_type') {
|
|
$("#report_div").css('display', 'none');
|
|
$("#ohc_location").val("");
|
|
$('#ohc_location').trigger('chosen:updated');
|
|
$("#patient_category").val("");
|
|
$('#patient_category').trigger('chosen:updated');
|
|
$("#dept").val("");
|
|
$('#dept').trigger('chosen:updated');
|
|
$("#emp_designation").val("");
|
|
$('#emp_designation').trigger('chosen:updated');
|
|
$("#emp_cadre").val("");
|
|
$('#emp_cadre').trigger('chosen:updated');
|
|
$("#employer_contractor").val("");
|
|
$('#employer_contractor').trigger('chosen:updated');
|
|
$("#gender").val("");
|
|
$('#gender').trigger('chosen:updated');
|
|
$("#patient").val("");
|
|
$("#patient").trigger('chosen:updated');
|
|
$("#year").val("");
|
|
$('#year').trigger('chosen:updated');
|
|
$("#month").val("");
|
|
$('#month').trigger('chosen:updated');
|
|
$("#startDate").val("");
|
|
$("#endDate").val("");
|
|
}
|
|
}
|
|
|
|
// to fetch data for report
|
|
function getShowingData() {
|
|
// to check chart type is selected or not
|
|
var idc = $("#choose_chart").val();
|
|
if(idc == '' || idc == null){
|
|
BootstrapDialog.alert("Please select the chart type to proceed");
|
|
return;
|
|
}
|
|
// alert($("#year :selected").length);
|
|
// to check year is selected or not
|
|
// if($("#year :selected").length <1){
|
|
// BootstrapDialog.alert("Please select the desired year from filters list to proceed");
|
|
// return;
|
|
// }
|
|
// removing all previous data to load report again or new report
|
|
$("#age_wise_emp_dist_table tr").remove();
|
|
$("#chart_div").html("");
|
|
$("#chart_div_2").html("");
|
|
var report_type = $("#report_type").val();
|
|
$.ajax({
|
|
url: 'select_report_details.php',
|
|
data: {
|
|
report_id: report_type
|
|
},
|
|
type: 'POST',
|
|
dataType: 'json',
|
|
success: function (data) {
|
|
if (report_type == data.report_id) {
|
|
eval(data.fun_name);
|
|
// $("#mybtn").prop('disabled', false);
|
|
}
|
|
},
|
|
error: function (data) {
|
|
BootstrapDialog.alert('Error Populating Reports Details');
|
|
return;
|
|
}
|
|
});
|
|
}
|
|
|
|
function enable() {
|
|
$("#report_div").css('display', 'none');
|
|
$("#mybtn").prop('disabled', false);
|
|
const root = document.querySelector(":root");
|
|
// $(".select2").after("<span style='color:red;font-style:italic'>posted by me</span>");
|
|
root.style.setProperty("--dis", "inline-block");
|
|
$(".close-choice").click(function () {
|
|
$("#report_type").val("");
|
|
$("#report_type").trigger("change");
|
|
root.style.setProperty("--dis", "none");
|
|
});
|
|
}
|
|
|
|
// to show filters according to selected report
|
|
function showFilterAccToReport() {
|
|
var report_id = $("#report_type").val();
|
|
// alert(report_id);
|
|
if (report_id != '' && report_id != null) {
|
|
$.ajax({
|
|
type: 'post',
|
|
url: 'select_filter_acc_to_report.php',
|
|
data: {
|
|
report_id: report_id
|
|
},
|
|
dataType: 'json',
|
|
success: function (data) {
|
|
if (data.filter_code != '' && data.filter_code != null) {
|
|
var filter_code = data.filter_code;
|
|
var filter = filter_code.split(', ');
|
|
for (var i = 0; i < filter.length; i++) {
|
|
// alert("#"+filter[i]);
|
|
$('#' + filter[i]).show();
|
|
}
|
|
}
|
|
},
|
|
error: function (data) {
|
|
alert('Unable to fetch filter list');
|
|
}
|
|
})
|
|
} else {
|
|
$.ajax({
|
|
type: 'post',
|
|
url: 'select_filter_acc_to_report.php',
|
|
data: {
|
|
report_id: report_id
|
|
},
|
|
dataType: 'json',
|
|
success: function (data) {
|
|
if (data != '' && data != null) {
|
|
for (var i = 0; i < data.length; i++) {
|
|
// alert("#"+data[i]);
|
|
$('#' + data[i]).hide();
|
|
}
|
|
}
|
|
},
|
|
error: function (data) {
|
|
alert('Unable to fetch filter list');
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|