0xV3NOMx
Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64



Your IP : 3.129.73.6


Current Path : /var/www/html/oums/js/
Upload File :
Current File : /var/www/html/oums/js/expense_report.js

function load_page() {
	load_page_data(
		window.location.href.substr(window.location.href.lastIndexOf("/") + 1)
	);
	clrs_data();
	load_empl_data();
    load_head_desc();
}

function clrs_data() {
    $("#div-date-range").show();
    $("#div-mnth-range").hide();
    $("#div-year-range").hide();
	$("#page-container-grid").empty();

    $(function () {		$("#txtexpndat1").datepicker({ dateFormat: "dd/mm/yy" });	});
	$(function () {		$("#txtexpndat2").datepicker({ dateFormat: "dd/mm/yy" });	});
    document.getElementById("txtrepttype").focus();
    document.getElementById("txtrepttype").selectedIndex = 0;
	document.getElementById("txtexpndat1").value = get_today_date();
	document.getElementById("txtexpndat2").value = get_today_date();
	$("#txtseledate").val($("#txtseledate option:first").val());
    load_sele_date();
}

function load_rept_type(){
    if(document.getElementById("txtrepttype").value=="rep_stat_excl"){
        
        $("#div-clnt-code").hide();
        $("#div-head-type").hide();
        $("#div-head-desc").hide();
        $("#div-sele-date").hide();
        $("#div-date-range").hide();
        $("#div-mnth-range").show();
        $("#div-year-range").hide();
    }
    else{
        
        $("#div-clnt-code").show();
        $("#div-head-type").show();
        $("#div-head-desc").show();
        $("#div-sele-date").show();
        $("#div-date-range").show();
        $("#div-mnth-range").hide();
        $("#div-year-range").hide();
    }
}

function load_sele_date() {
	var date = new Date();

	dd = date.getDate();
	mm = date.getMonth();
	yy = date.getFullYear();

	var curr_date_strt = new Date();
	var curr_mnth_strt = new Date(yy, mm, 1);
	var curr_year_strt = new Date(yy, 0, 1);

	var prev_mnth_strt = new Date(yy, mm - 1, 1);
	var prev_mnth_last = new Date(yy, mm, 0);

	var prev_year_strt = new Date(yy - 1, 0, 1);
	var prev_year_last = new Date(yy, 0, 0);

	if (document.getElementById("txtseledate").value == "THIS_DATE") {
		$("#txtexpndat1").prop("disabled", true);
		$("#txtexpndat2").prop("disabled", true);
		$("#txtexpndat1").val($.datepicker.formatDate("dd/mm/yy", curr_date_strt));
		$("#txtexpndat2").val($.datepicker.formatDate("dd/mm/yy", curr_date_strt));
	}

	if (document.getElementById("txtseledate").value == "THIS_MNTH") {
		$("#txtexpndat1").prop("disabled", true);
		$("#txtexpndat2").prop("disabled", true);
		$("#txtexpndat1").val($.datepicker.formatDate("dd/mm/yy", curr_mnth_strt));
		$("#txtexpndat2").val($.datepicker.formatDate("dd/mm/yy", curr_date_strt));
	}

	if (document.getElementById("txtseledate").value == "PREV_MNTH") {
		$("#txtexpndat1").prop("disabled", true);
		$("#txtexpndat2").prop("disabled", true);
		$("#txtexpndat1").val($.datepicker.formatDate("dd/mm/yy", prev_mnth_strt));
		$("#txtexpndat2").val($.datepicker.formatDate("dd/mm/yy", prev_mnth_last));
	}

	if (document.getElementById("txtseledate").value == "THIS_YEAR") {
		$("#txtexpndat1").prop("disabled", true);
		$("#txtexpndat2").prop("disabled", true);
		$("#txtexpndat1").val($.datepicker.formatDate("dd/mm/yy", curr_year_strt));
		$("#txtexpndat2").val($.datepicker.formatDate("dd/mm/yy", curr_date_strt));
	}

	if (document.getElementById("txtseledate").value == "PREV_YEAR") {
		$("#txtexpndat1").prop("disabled", true);
		$("#txtexpndat2").prop("disabled", true);
		$("#txtexpndat1").val($.datepicker.formatDate("dd/mm/yy", prev_year_strt));
		$("#txtexpndat2").val($.datepicker.formatDate("dd/mm/yy", prev_year_last));
	}

	if (document.getElementById("txtseledate").value == "CUST_DATE") {
		$("#txtexpndat1").prop("disabled", false);
		$("#txtexpndat2").prop("disabled", false);
		$("#txtexpndat1").val($.datepicker.formatDate("dd/mm/yy", curr_date_strt));
		$("#txtexpndat2").val($.datepicker.formatDate("dd/mm/yy", curr_date_strt));
	}
}

function load_empl_data() {
	$.ajax({
		type: "POST",
		url: "src/expense_report.php",
		data: {
			load_data: "empl_data",
		},
		cache: false,
		success: function (data) {
            $("#txtemplcode").html(data);
            load_clnt_data();
			load_expn_mnth();
		},
	});
}

function load_clnt_data() {
	$.ajax({
		type: "POST",
		url: "src/expense_report.php",
		data: {
			load_data: "clnt_data",
			empl_code: document.getElementById("txtemplcode").value,
		},
		cache: false,
		success: function (data) {
			$("#txtclntcode").html(data);
		},
	});
}

function load_head_desc() {
	$.ajax({
		type: "POST",
		url: "src/expense_report.php",
		data: {
            load_data: "head_desc",
			acnt_type: document.getElementById("txtacnttype").value,
		},
		cache: false,
		success: function (data) {
			$("#txtheaddesc").html(data);
		},
	});
}

function load_expn_mnth() {
	$.ajax({
		type: "POST",
		url: "src/expense_report.php",
		data: {
            load_data: "expn_mnth",
			empl_code: document.getElementById("txtemplcode").value,
		},
		cache: false,
		success: function (data) {
			$("#txtexpnmnt1").html(data);
		},
	});
}

function rept_data() {
	if (document.getElementById("txtrepttype").value == "") {
		alert("Please select report type!");
		txtrepttype.focus();
		return false;
	}

	if (document.getElementById("txtrepttype").value == "rep_stat_excl") {        
        if (document.getElementById("txtemplcode").value == "") {
            alert("Please select employee!");
            txtemplcode.focus();
            return false;
        }

        if (document.getElementById("txtexpnmnt1").value == "") {
            alert("Please select expense month!");
            txtexpnmnt1.focus();
            return false;
        }

		expense_report_statement_excl();
    }

	if (document.getElementById("txtrepttype").value == "rep_stat_date") {
		expense_report_statement_date();
	}

	if (document.getElementById("txtrepttype").value == "rep_stat_mnth") {
		expense_report_statement_mnth();
	}

	if (document.getElementById("txtrepttype").value == "rep_stat_year") {
		expense_report_statement_year();
	}

	if (document.getElementById("txtrepttype").value == "rep_detl_date") {
		expense_report_details_date();
	}

	if (document.getElementById("txtrepttype").value == "rep_detl_mnth") {
		expense_report_details_mnth();
	}

	if (document.getElementById("txtrepttype").value == "rep_detl_clnt") {
		expense_report_details_clnt();
	}

	if (document.getElementById("txtrepttype").value == "rep_detl_head") {
		expense_report_details_head();
	}
}

function expense_report_statement_excl() {
	$host = "oums";
	$.ajax({
		type: "POST",
		url: "src/expense_report_statement_excel.php",
		dataType: "json",
		data: {
			empl_code: document.getElementById("txtemplcode").value,
			expn_mnth: document.getElementById("txtexpnmnt1").value,
			mnth_name: $("#txtexpnmnt1 option:selected").text(),
		},
		cache: false,
		beforeSend: function () {
			show_process();
		},
		success: function (data) {
			hide_process();
			if (data.stat != "F") {
				window.open("src/" + data.file,'_blank');
			} else {
				alert(data.mesg);
			}
		},
		error: function (data) {
			hide_process();
			//$('#page-container-grid').html('Error: '+data);
		},
	});
}

function expense_report_statement_date() {
	$host = "oums";
	$.ajax({
		type: "POST",
		url: "src/expense_report_statement_date.php",
		dataType: "json",
		data: {
			empl_code: document.getElementById("txtemplcode").value,
			acnt_type: document.getElementById("txtacnttype").value,
			expn_dat1: document.getElementById("txtexpndat1").value,
			expn_dat2: document.getElementById("txtexpndat2").value,
		},
		cache: false,
		beforeSend: function () {
			show_process();
		},
		success: function (data) {
			hide_process();
			if (data.stat != "F") {
				window.open("src/" + data.file,'_blank');
			} else {
				alert(data.mesg);
			}
		},
		error: function (data) {
			hide_process();
			//$('#page-container-grid').html('Error: '+data);
		},
	});
}

function expense_report_statement_mnth() {
	$host = "oums";
	$.ajax({
		type: "POST",
		url: "src/expense_report_statement_mnth.php",
		dataType: "json",
		data: {
			empl_code: document.getElementById("txtemplcode").value,
			acnt_type: document.getElementById("txtacnttype").value,
			expn_dat1: document.getElementById("txtexpndat1").value,
			expn_dat2: document.getElementById("txtexpndat2").value,
		},
		cache: false,
		beforeSend: function () {
			show_process();
		},
		success: function (data) {
			hide_process();
			if (data.stat != "F") {
				window.open("src/" + data.file,'_blank');
			} else {
				alert(data.mesg);
			}
		},
		error: function (data) {
			hide_process();
			//$('#page-container-grid').html('Error: '+data);
		},
	});
}

function expense_report_statement_year() {
	$host = "oums";
	$.ajax({
		type: "POST",
		url: "src/expense_report_statement_year.php",
		dataType: "json",
		data: {
			empl_code: document.getElementById("txtemplcode").value,
			acnt_type: document.getElementById("txtacnttype").value,
			expn_dat1: document.getElementById("txtexpndat1").value,
			expn_dat2: document.getElementById("txtexpndat2").value,
		},
		cache: false,
		beforeSend: function () {
			show_process();
		},
		success: function (data) {
			hide_process();
			if (data.stat != "F") {
				window.open("src/" + data.file,'_blank');
			} else {
				alert(data.mesg);
			}
		},
		error: function (data) {
			hide_process();
			//$('#page-container-grid').html('Error: '+data);
		},
	});
}

function expense_report_details_date() {
	$host = "oums";
	$.ajax({
		type: "POST",
		url: "src/expense_report_details_date.php",
		dataType: "json",
		data: {
			empl_code: document.getElementById("txtemplcode").value,
			expn_dat1: document.getElementById("txtexpndat1").value,
			expn_dat2: document.getElementById("txtexpndat2").value,
		},
		cache: false,
		beforeSend: function () {
			show_process();
		},
		success: function (data) {
			hide_process();
			if (data.stat != "F") {
				window.open("src/" + data.file,'_blank');
			} else {
				alert(data.mesg);
			}
			//$('#page-container-grid').html('Suc: '+data);
		},
		error: function (data) {
			$("#page-container-grid").html("Error: " + data);
		},
	});
}

function expense_report_details_mnth() {
	$host = "oums";
	$.ajax({
		type: "POST",
		url: "src/expense_report_details_mnth.php",
		dataType: "json",
		data: {
			empl_code: document.getElementById("txtemplcode").value,
			acnt_type: document.getElementById("txtacnttype").value,
			expn_dat1: document.getElementById("txtexpndat1").value,
			expn_dat2: document.getElementById("txtexpndat2").value,
		},
		cache: false,
		beforeSend: function () {
			show_process();
		},
		success: function (data) {
			hide_process();
			if (data.stat != "F") {
				window.open("src/" + data.file,'_blank');
			} else {
				alert(data.mesg);
			}
			//$('#page-container-grid').html('Suc: '+data);
		},
		error: function (data) {
			$("#page-container-grid").html("Error: " + data);
		},
	});
}