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.118.144.239
Current Path : /var/www/html/oums/js/ |
| Current File : /var/www/html/oums/js/user_departments.js |
function load_page() {
load_page_data(
window.location.href.substr(window.location.href.lastIndexOf("/") + 1)
);
clrs_data();
load_user_data();
load_dept_type();
}
function clrs_data() {
$("#btn_save").hide();
$("#page-container-grid").empty();
txtusercode.focus();
}
function load_user_data() {
$.ajax({
type: "POST",
url: "src/user_departments.php",
data: {
load_data: "user_data",
},
cache: false,
success: function (data) {
$("#txtusercode").html(data);
},
error: function (data) {
$("#txtusercode").html("Error: " + data);
},
});
}
function load_dept_type() {
$.ajax({
type: "POST",
url: "src/user_departments.php",
data: {
load_data: "dept_type",
},
cache: false,
success: function (data) {
$("#txtdepttype").html(data);
},
error: function (data) {
$("#txtdepttype").html("Error: " + data);
},
});
}
function load_grid_data() {
if (document.getElementById("txtusercode").value == 0) {
alert("Please select user!");
txtusercode.focus();
return false;
}
$.ajax({
type: "POST",
url: "src/user_departments.php",
data: {
load_data: "disp_data",
user_code: document.getElementById("txtusercode").value,
dept_type: document.getElementById("txtdepttype").value,
dept_stat: document.getElementById("txtdeptstat").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;
}
var rowcount = $("#menu_grid tr").length;
if (rowcount == 0) {
alert("No details to save!");
return false;
}
var user_dept = [];
var user_dept1 = document.getElementsByName("txtuserdept[]");
var sele_stat = [];
var sele_stat1 = document.getElementsByName("chkselestat[]");
var totl_rows = $("#menu_grid tr").length - 1;
for (var i = 0; i < totl_rows; i++) {
user_dept[i] = user_dept1[i].value;
sele_stat[i] = sele_stat1[i].checked;
}
$.ajax({
type: "POST",
url: "src/user_departments.php",
dataType: "json",
data: {
load_data: "save_data",
user_code: document.getElementById("txtusercode").value,
user_dept: user_dept,
sele_stat: sele_stat,
},
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_stat() {
$("#selectstat").change(function () {
$("input[name='chkselestat[]']:checkbox").prop("checked", this.checked);
});
}
|