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.149.234.78


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

function load_page() {
	load_page_data(
		window.location.href.substr(window.location.href.lastIndexOf("/") + 1)
	);
	clrs_data();
	load_dept_data();
	document.getElementById("txtattndate").value = get_today_date();
}

function clrs_data() {
	$("#btn_save").hide();
	$(function () {
		$("#txtattndate").datepicker({ dateFormat: "dd/mm/yy" });
	});
	document.getElementById("selattnmark").selectedIndex = 0;
	document.getElementById("seldeptcode").focus();
	$("#page-container-grid").empty();
}

function load_dept_data() {
	var load_data = "dept_detl";
	$.ajax({
		type: "POST",
		url: "src/attendance.php",
		data: "load_data=" + load_data,
		cache: false,
		beforeSend: function () {
			show_process();
		},
		success: function (data) {
			$("#seldeptcode").html(data);
			load_mark_detl($("#seldeptcode").val());
			hide_process();
		},
		error: function (html) {
			$("#seldeptcode").html("Error: " + data);
		},
	});
}

function load_mark_detl() {
	var load_data = "mark_detl";
	dept_code = document.getElementById("seldeptcode").value;
	$.ajax({
		type: "POST",
		url: "src/attendance.php",
		data: {
			load_data: load_data,
			dept_code: dept_code,
		},
		cache: false,
		beforeSend: function () {
			show_process();
		},
		success: function (data) {
			$("#selattnmark").html(data);
			hide_process();
		},
		error: function (html) {
			$("#selattnmark").html("Error: " + data);
		},
	});
}

function view_data() {
	if (document.getElementById("seldeptcode").value == 0) {
		alert("Please select department!");
		seldeptcode.focus();
		return false;
	}

	if (document.getElementById("txtattndate").value == "") {
		alert("Please enter date!");
		txtattndate.focus();
		return false;
	}

	load_data = "view_data";
	dept_code = document.getElementById("seldeptcode").value;
	attn_date = document.getElementById("txtattndate").value;
	attn_mark = document.getElementById("selattnmark").value;

	$.ajax({
		type: "POST",
		url: "src/attendance.php",
		data: {
			load_data: load_data,
			dept_code: dept_code,
			attn_date: attn_date,
			attn_mark: attn_mark,
		},
		cache: false,
		beforeSend: function () {
			show_process();
		},
		success: function (data) {
			$("#page-container-grid").html(data);
			$("#btn_save").show();
			hide_process();
		},
		error: function (data) {
			hide_process();
			$("#page-container-grid").html("Error: " + data);
		},
	});
}

function display_values(r) {
	var row_index = r.parentNode.parentNode.rowIndex;
	var arr_index = row_index - 1;
	var attn_stat1 = document.getElementsByName("txtattnstat[]");
	var attn_stat2 = attn_stat1[arr_index].value;

	fields = attn_stat2.split("*");

	dept_code = fields[1];

	logi_time = fields[2];
	logi_time = logi_time.replace("00:00:00", "0");

	logo_time = fields[3];
	logo_time = logo_time.replace("00:00:00", "0");

	trvl_amnt = fields[4];

	var xlogi_time = document.getElementsByName("txtlogitime[]");
	xlogi_time[arr_index].value = logi_time;

	var xlogo_time = document.getElementsByName("txtlogotime[]");
	//xlogo_time[arr_index].value=logo_time;

	var xtrvl_amnt = document.getElementsByName("txttrvlamnt[]");
	xtrvl_amnt[arr_index].value = trvl_amnt;
}

//Validate row
function validate_row(r) {
	var row_index = r.parentNode.parentNode.rowIndex;
	var arr_index = row_index - 1;

	//Validate for expense head selection
	var xstat_val1 = document.getElementsByName("txtattnstat[]");
	var xlogi_val1 = document.getElementsByName("txtlogitime[]");
	var xlogo_val1 = document.getElementsByName("txtlogotime[]");
	var xtrvl_val1 = document.getElementsByName("txttrvlamnt[]");
	var xover_val1 = document.getElementsByName("txtovertime[]");
	var xcode_val1 = document.getElementsByName("txtcodepack[]");

	var xstat_val2 = xstat_val1[arr_index].value;

	var xattn_flds = xstat_val2.split("*");

	var ldept_code = xattn_flds[0];
	var lattn_stat = xattn_flds[1];
	var llogi_time = xattn_flds[2];
	var llogi_time = llogi_time.replace("00:00:00", "0");
	var llogo_time = xattn_flds[3];
	var llogo_time = llogo_time.replace("00:00:00", "0");

	var xlogi_time = xlogi_val1[arr_index].value;
	var xlogo_time = xlogo_val1[arr_index].value;

	if (lattn_stat == "0") {
		alert("Please select attendance status!");
		xstat_val1[arr_index].focus();
		return false;
	}

	if (lattn_stat == "CD") {
		var xcode_pack = document.getElementsByName("txtcodepack[]");
		if (xcode_pack[arr_index].value == 0) {
			alert("Please enter no of coding packets!");
			xcode_pack[arr_index].focus();
			return false;
		}
	}

	if (llogi_time != 0 && xlogi_time == 0) {
		alert("Please select login time!");
		xlogi_val1[arr_index].focus();
		return false;
	}
	if (llogi_time == 0) {
		xlogi_val1[arr_index].value = 0;
		xlogo_val1[arr_index].value = 0;
		xtrvl_val1[arr_index].value = "0.00";
		xover_val1[arr_index].value = 0;
		xcode_val1[arr_index].value = 0;
	}
}

function save_data() {
	if (document.getElementById("seldeptcode").value == 0) {
		alert("Please select department!");
		seldeptcode.focus();
		return false;
	}

	if (document.getElementById("txtattndate").value == "") {
		alert("Please enter attendance date!");
		txtattndate.focus();
		return false;
	}

	var rowcount = $("#table_attn tr").length;
	if (rowcount == 0) {
		alert("Please edit the details!");
		cmdview.focus();
		return false;
	}

	xattn_stat = document.getElementsByName("txtattnstat[]");
	for (var i = 0; i < xattn_stat.length; i++) {
		if (xattn_stat[i].value == "0") {
			alert("Please select attendance status!");
			xattn_stat[i].focus();
			return false;
		}
	}

	var totl_rows = $("#table_attn tr").length - 1;

	var dept_code = [];
	var dept_code1 = document.getElementsByName("txtdeptcode[]");

	var empl_code = [];
	var empl_code1 = document.getElementsByName("txtemplcode[]");

	var attn_stat = [];
	var attn_stat1 = document.getElementsByName("txtattnstat[]");

	var logi_time = [];
	var logi_time1 = document.getElementsByName("txtlogitime[]");

	var logo_time = [];
	var logo_time1 = document.getElementsByName("txtlogotime[]");

	var trvl_amnt = [];
	var trvl_amnt1 = document.getElementsByName("txttrvlamnt[]");

	var over_time = [];
	var over_time1 = document.getElementsByName("txtovertime[]");

	var code_pack = [];
	var code_pack1 = document.getElementsByName("txtcodepack[]");

	var attn_remk = [];
	var attn_remk1 = document.getElementsByName("txtattnremk[]");

	for (var i = 0; i < totl_rows; i++) {
		dept_code[i] = dept_code1[i].value;
		empl_code[i] = empl_code1[i].value;
		attn_stat[i] = attn_stat1[i].value;
		logi_time[i] = logi_time1[i].value;
		logo_time[i] = logo_time1[i].value;
		trvl_amnt[i] = trvl_amnt1[i].value;
		over_time[i] = over_time1[i].value;
		code_pack[i] = code_pack1[i].value;
		attn_remk[i] = attn_remk1[i].value;
	}

	$.ajax({
		type: "POST",
		url: "src/attendance.php",
		dataType: "json",
		data: {
			load_data: "save_data",
			attn_date: document.getElementById("txtattndate").value,
			dept_code: dept_code,
			empl_code: empl_code,
			attn_stat: attn_stat,
			logi_time: logi_time,
			logo_time: logo_time,
			trvl_amnt: trvl_amnt,
			over_time: over_time,
			code_pack: code_pack,
			attn_remk: attn_remk,
		},
		cache: false,
		beforeSend: function () {
			show_process();
		},
		success: function (data) {
			hide_process();
			clrs_data();
			alert(data.mesg);
		},
		error: function (data) {
			hide_process();
			$("#page-container-grid").html("Error: " + data);
		},
	});
}