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 : 18.220.194.29


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

function load_page(file_name) {
	load_page_data(
		window.location.href.substr(window.location.href.lastIndexOf("/") + 1)
	);
	cncl_data();
	load_grid_data(20, 1);
}

function cncl_data() {
	$("#btn_addn").show();
	$("#btn_save").hide();
	$("#btn_cncl").hide();
	$("#page-container-main").show();
	$("#page-container-grid").show();
	$("#page-container-form").hide();
}

function clrs_data() {
	$("#btn_addn").hide();
	$("#btn_save").show();
	$("#btn_cncl").show();
	$("#page-container-main").hide();
	$("#page-container-grid").hide();
	$("#page-container-form").show();
	$(function () {
		$("#txtdocsdate").datepicker({ dateFormat: "dd/mm/yy" });
	});
	document.getElementById("txtdocsdate").value = "";
	document.getElementById("txtdocsdesc").value = "";
}

function load_grid_data(page_limt, page_numb) {
	$.ajax({
		type: "POST",
		url: "src/documents.php",
		data: {
			load_data: "grid_data",
			page_limt: page_limt,
            page_numb: page_numb,
			dept_code: document.getElementById("seldeptcode").value,
			docs_type: document.getElementById("seldocstype").value,
			docs_find: document.getElementById("txtdocsfind").value,
		},
		cache: false,
		beforeSend: function () {
			show_process();
		},
		success: function (data) {
			hide_process();
			$("#page-container-grid").html(data);
		},
		error: function (data) {
			hide_process();
			$("#page-container-grid").html("Error: " + data);
		},
	});
}

function load_page_limt(page_limt) {
	load_grid_data(page_limt, 1);
}

function addn_data() {
	clrs_data();
	document.getElementById("lblpagemode").innerHTML = "Add";
	document.getElementById("txtpagemode").value = "add";
    document.getElementById("txtdeptcode").focus();
    document.getElementById("txtdocsdate").value = get_today_date();
}

function edit_data(prim_data) {
	clrs_data();
	document.getElementById("lblpagemode").innerHTML = "Edit";
	document.getElementById("txtpagemode").value = "edit";
	document.getElementById("txtdeptcode").focus();
	$.ajax({
		type: "POST",
        url: "src/documents.php",
		data: {
			load_data: "disp_data",
			disp_code: prim_data,
		},
		cache: false,
		success: function (data) {
			var data = JSON.parse(data);
            document.getElementById("txtdocscode").value = data.fdocscode;
            document.getElementById("txtdeptcode").value = data.fdeptcode;
			document.getElementById("txtdocsdate").value = get_format_date(data.fdocsdate);
            document.getElementById("txtdocsdesc").value = data.fdocsdesc;
		},
		error: function (data) {
			$("#page-container-form").html("Error: " + data);
		},
	});
}

function dele_data(prim_data) {
	var r = confirm("Delete Record?");
	if (r == true) {
		$.ajax({
			type: "POST",
			url: "src/documents.php",
			data: {
				load_data: "dele_data",
				dele_code: prim_data,
			},
			success: function (data) {
				load_grid_data(20, 1);
			},
		});
	}
}


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

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

	if (document.getElementById("txtdocsdesc").value == "") {
		alert("Please enter docsdate description!");
		txtdocsdesc.focus();
		return false;
	}

	$.ajax({
		type: "POST",
		url: "src/documents.php",
		dataType: "json",
		data: {
			load_data: "save_data",
            page_mode: document.getElementById("txtpagemode").value,
            docs_code: document.getElementById("txtdocscode").value,
			dept_code: document.getElementById("txtdeptcode").value,
			docs_date: document.getElementById("txtdocsdate").value,
			docs_desc: document.getElementById("txtdocsdesc").value,
		},
		cache: false,
		success: function (data) {
			alert(data.mesg);
			if (data.stat != "F") {
				cncl_data();
				load_grid_data(20, 1);
			}
		},
		error: function (data) {
			$("#page-container-form").html("Error: " + data);
		},
	});
}