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.137.170.38
Current Path : /var/www/html/oums/js/ |
| Current File : /var/www/html/oums/js/user_setup.js |
var curr_fold_name = window.location.pathname.substring(0, window.location.pathname.lastIndexOf('/'));
var curr_fold_path = document.URL.substr(0, document.URL.lastIndexOf('/'));
function load_page() {
load_page_data(
window.location.href.substr(window.location.href.lastIndexOf("/") + 1)
);
cncl_data();
}
function cncl_data() {
$("#btn_addn").show();
$("#btn_save").hide();
$("#btn_cncl").hide();
$("#page-container-main").show();
$("#page-container-grid").show();
$("#page-container-form").hide();
load_grid_data(20, 1);
}
function clrs_data() {
$("#btn_addn").hide();
$("#btn_save").show();
$("#btn_cncl").show();
$("#page-container-main").hide();
$("#page-container-grid").hide();
$("#page-container-form").show();
document.getElementById("txtemplcode").value = "";
document.getElementById("txtusertype").value = "0";
document.getElementById("txtusercode").value = "";
document.getElementById("imgemplphot").src = "img-empl/blank.png";
}
function load_grid_data(page_limt, page_numb) {
$.ajax({
type: "POST",
url: "src/user_setup.php",
data: {
load_data: "grid_data",
page_limt: page_limt,
page_numb: page_numb,
dept_code: document.getElementById("seldeptcode").value,
empl_stat: document.getElementById("selemplstat").value,
user_type: document.getElementById("selusertype").value,
find_data: document.getElementById("txtemplfind").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_data_grid(page_limt, 1);
}
function edit_data(prim_data) {
clrs_data();
document.getElementById("lblpagemode").innerHTML = "Edit";
document.getElementById("txtpagemode").value = "edit";
load_user_type();
$.ajax({
type: "POST",
url: "src/user_setup.php",
data: {
load_data: "disp_data",
empl_code: prim_data,
},
cache: false,
beforeSend: function () {
show_process();
},
success: function (data) {
var data = JSON.parse(data);
if (data.femplphot == "") {
document.getElementById("imgemplphot").src = "img-empl/blank.png";
} else {
document.getElementById("imgemplphot").src = "img-empl/" + data.femplphot;
}
$.ajax({
url: curr_fold_path + "/img-empl/" + data.femplphot,
type: "HEAD",
error: function () {
document.getElementById("imgemplphot").src = "img-empl/blank.png";
},
success: function () {
document.getElementById("imgemplphot").src = "img-empl/" + data.femplphot;
},
});
document.getElementById("txtemplcode").value = data.femplcode;
document.getElementById("txtemplname").value = data.femplname;
document.getElementById("txtdeptcode").value = data.fdeptcode;
document.getElementById("txtdeptname").value = data.fdeptname;
document.getElementById("txtempldesn").value = data.fempldesn;
document.getElementById("txtempltype").value = data.fempltype;
document.getElementById("txtemplmobl").value = data.femplmobl;
document.getElementById("txtusercode").value = data.fusercode;
if (data.fusercode != "") {
document.getElementById("txtusercode").disabled = true;
document.getElementById("txtusertype").focus();
document.getElementById("txtusertype").value = data.fusertype;
} else {
document.getElementById("txtusercode").disabled = false;
document.getElementById("txtusertype").focus();
document.getElementById("txtusertype").value = "0";
}
hide_process();
},
error: function (data) {
hide_process();
$("#page-container-form").html("Error: " + data);
},
});
}
function save_data() {
if (document.getElementById("txtusercode").value == "") {
alert("Please enter user id!");
txtusercode.focus();
return false;
}
if (document.getElementById("txtusertype").value == 0) {
alert("Please select user type!");
txtusertype.focus();
return false;
}
$.ajax({
type: "POST",
url: "src/user_setup.php",
dataType: "json",
data: {
load_data: "save_data",
dept_code: document.getElementById("txtdeptcode").value,
empl_code: document.getElementById("txtemplcode").value,
empl_name: document.getElementById("txtemplname").value,
empl_mobl: document.getElementById("txtemplmobl").value,
user_type: document.getElementById("txtusertype").value,
user_code: document.getElementById("txtusercode").value,
},
cache: false,
success: function (data) {
alert(data.mesg);
if (data.stat != "0") {
cncl_data();
load_grid_data(20, 1);
}
},
error: function (data) {
$("#page-container-form").html("Error: " + data);
},
});
}
function load_user_type() {
$.ajax({
type: "POST",
url: "src/user_setup.php",
data: {
load_data: "user_type",
},
cache: false,
success: function (data) {
$("#txtusertype").html(data);
},
});
}
function blck_user(prim_data) {
var r = confirm("Block User?");
if (r == true) {
$.ajax({
type: "POST",
url: "src/user_setup.php",
data: {
load_data: "blck_user",
dele_code: prim_data,
},
success: function (data) {
load_grid_data(20, 1);
},
});
}
}
function open_user(prim_data) {
var r = confirm("UnBlock User?");
if (r == true) {
$.ajax({
type: "POST",
url: "src/user_setup.php",
data: {
load_data: "open_user",
dele_code: prim_data,
},
success: function (data) {
load_grid_data(20, 1);
},
});
}
}
function load_dept_data() {
$.ajax({
type: "POST",
url: "src/employees.php",
data: {
load_data: "dept_data",
},
cache: false,
success: function (data) {
$("#txtdeptcode").html(data);
},
});
}
function load_desn_data() {
$.ajax({
type: "POST",
url: "src/employees.php",
data: {
load_data: "desn_data",
},
cache: false,
success: function (data) {
$("#txtdesnname").html(data);
},
});
}
|