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


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

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

function clrs_data() {
	$("#btn_save").hide();
	document.getElementById("txtmodecode").selectedIndex = 1;
	$("#page-container-grid").empty();
    txtusercode.focus();
}

function load_user_data() {
	$.ajax({
		type: "POST",
		url: "src/user_rights.php",
		data: {
			load_data: "user_data",
		},
		cache: false,
		success: function (data) {
			$("#txtusercode").html(data);
		},
		error: function (data) {
			$("#txtusercode").html("Error: " + data);
		},
	});
}

function load_menu_data() {
	$.ajax({
		type: "POST",
		url: "src/user_rights.php",
		data: {
			load_data: "menu_data",
		},
		cache: false,
		success: function (data) {
			$("#txtmodecode").html(data);
		},
		error: function (data) {
			$("#txtmodecode").html("Error: " + data);
		},
	});
}

function load_grid_data() {
	if (document.getElementById("txtusercode").value == 0) {
		alert("Please select user!");
		txtusercode.focus();
		return false;
	}

	if (document.getElementById("txtmodecode").value == 0) {
		alert("Please select main module!");
		txtmodecode.focus();
		return false;
	}

	$.ajax({
		type: "POST",
		url: "src/user_rights.php",
		data: {
			load_data: "disp_data",
			user_code: document.getElementById("txtusercode").value,
			mode_code: document.getElementById("txtmodecode").value,
		},
		cache: false,
		beforeSend: function () {
			show_process();
		},
		success: function (data) {
			hide_process();
			$("#page-container-grid").html(data);
			$("#btn_save").show();
		},
		error: function (data) {
			hide_process();
			$("#page-container-grid").html("Error: " + data);
		},
	});
}

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

	if (document.getElementById("txtmodecode").value == 0) {
		alert("Please select main module!");
		txtmodecode.focus();
		return false;
	}

	var rowcount = $("#menu_grid tr").length;
	if (rowcount == 0) {
		alert("No details to save!");
		cmdview.focus();
		return false;
	}

	var mode_code = [];
	var mode_code1 = document.getElementsByName("txtmodecode[]");

	var main_code = [];
	var main_code1 = document.getElementsByName("txtmaincode[]");

	var menu_code = [];
	var menu_code1 = document.getElementsByName("txtmenucode[]");

	var sele_menu = [];
	var sele_menu1 = document.getElementsByName("txtselemenu[]");

	var sele_addn = [];
	var sele_addn1 = document.getElementsByName("txtseleaddn[]");

	var sele_edit = [];
	var sele_edit1 = document.getElementsByName("txtseleedit[]");

	var sele_dele = [];
	var sele_dele1 = document.getElementsByName("txtseledele[]");

	var sele_view = [];
	var sele_view1 = document.getElementsByName("txtseleview[]");

	var totl_rows = $("#menu_grid tr").length - 1;
	for (var i = 0; i < totl_rows - 1; i++) {
		mode_code[i] = mode_code1[i].value;
		main_code[i] = main_code1[i].value;
		menu_code[i] = menu_code1[i].value;
		sele_menu[i] = sele_menu1[i].checked;
		sele_addn[i] = sele_addn1[i].checked;
		sele_edit[i] = sele_edit1[i].checked;
		sele_dele[i] = sele_dele1[i].checked;
		sele_view[i] = sele_view1[i].checked;
	}

	$.ajax({
		type: "POST",
		url: "src/user_rights.php",
		dataType: "json",
		data: {
			load_data: "save_data",
			user_code: document.getElementById("txtusercode").value,
			mode_code: mode_code,
			main_code: main_code,
			menu_code: menu_code,
			sele_menu: sele_menu,
			sele_addn: sele_addn,
			sele_edit: sele_edit,
			sele_dele: sele_dele,
			sele_view: sele_view,
		},
		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);
		},
	});
}

function select_menu() {
	$("#selectmenu").change(function () {
		$("input[name='txtselemenu[]']:checkbox").prop("checked", this.checked);
	});
}

function select_addn() {
	$("#selectaddn").change(function () {
		$("input[name='txtseleaddn[]']:checkbox").prop("checked", this.checked);
	});
}

function select_edit() {
	$("#selectedit").change(function () {
		$("input[name='txtseleedit[]']:checkbox").prop("checked", this.checked);
	});
}

function select_dele() {
	$("#selectdele").change(function () {
		$("input[name='txtseledele[]']:checkbox").prop("checked", this.checked);
	});
}

function select_view() {
	$("#selectview").change(function () {
		$("input[name='txtseleview[]']:checkbox").prop("checked", this.checked);
	});
}

function save_default() {
	if (document.getElementById("txtusercode").value == 0) {
		alert("Please select user!");
		txtusercode.focus();
		return false;
	}

	$.ajax({
		type: "POST",
		url: "src/user_rights.php",
		dataType: "json",
		data: {
			load_data: "save_defa",
			user_code: document.getElementById("txtusercode").value,
		},
		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);
		},
	});
}