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.135.205.102
Current Path : /var/www/html/oums/js/ |
| Current File : /var/www/html/oums/js/user_password.js |
function load_page() {
load_page_data(
window.location.href.substr(window.location.href.lastIndexOf("/") + 1)
);
clrs_data();
load_dept_data();
}
function clrs_data() {
document.getElementById("txtdeptcode").selectedIndex = 0;
document.getElementById("txtpswdcurr").value = "";
document.getElementById("txtpswdnew1").value = "";
document.getElementById("txtpswdnew2").value = "";
document.getElementById("txtpswdcurr").focus();
}
function load_dept_data() {
$.ajax({
type: "POST",
url: "src/user_password.php",
data: {
load_data: "dept_data",
},
cache: false,
beforeSend: function () {
show_process();
},
success: function (data) {
$("#txtdeptcode").html(data);
load_user_data($("#txtdeptcode").val());
hide_process();
},
error: function (data) {
$("#txtdeptcode").html("Error: " + data);
hide_process();
},
});
}
function load_user_data() {
$.ajax({
type: "POST",
url: "src/user_password.php",
data: {
load_data: "user_data",
dept_code: document.getElementById("txtdeptcode").value,
},
cache: false,
beforeSend: function () {
show_process();
},
success: function (data) {
$("#txtusercode").html(data);
hide_process();
},
error: function (data) {
$("#txtusercode").html("Error: " + data);
hide_process();
},
});
}
function save_data() {
if (document.getElementById("txtdeptcode").value == 0) {
alert("Please select client!");
document.getElementById("txtdeptcode").focus();
return false;
}
if (document.getElementById("txtusercode").value == 0) {
alert("Please select user!");
document.getElementById("txtusercode").focus();
return false;
}
if (document.getElementById("txtpswdcurr").value == "") {
alert("Please enter current password!");
document.getElementById("txtpswdcurr").focus();
return false;
}
if (document.getElementById("txtpswdnew1").value == "") {
alert("Please enter new password!");
document.getElementById("txtpswdnew1").focus();
return false;
}
if (document.getElementById("txtpswdnew2").value == "") {
alert("Please re-enter new password!");
document.getElementById("txtpswdnew2").focus();
return false;
}
if (
document.getElementById("txtusercode").value.toUpperCase() ==
document.getElementById("txtpswdnew1").value.toUpperCase()
) {
alert("New password cannot be same as user ID!");
document.getElementById("txtpswdnew1").focus();
return false;
}
if (
document.getElementById("txtpswdnew1").value !=
document.getElementById("txtpswdnew2").value
) {
alert("New password mismatch!");
document.getElementById("txtpswdnew2").focus();
return false;
}
$.ajax({
type: "POST",
url: "src/user_password.php",
dataType: "json",
data: {
load_data: "save_data",
user_code: document.getElementById("txtusercode").value,
pswd_curr: document.getElementById("txtpswdcurr").value,
pswd_new2: document.getElementById("txtpswdnew2").value,
},
cache: false,
beforeSend: function () {
show_process();
},
success: function (data) {
hide_process();
alert(data.mesg);
if (data.stat != "F") {
clrs_data();
}
},
});
}
function rset_data() {
if (document.getElementById("txtdeptcode").value == 0) {
alert("Please select client!");
document.getElementById("txtdeptcode").focus();
return false;
}
if (document.getElementById("txtusercode").value == 0) {
alert("Please select user!");
document.getElementById("txtusercode").focus();
return false;
}
$.ajax({
type: "POST",
url: "src/user_password.php",
dataType: "json",
data: {
load_data: "rset_data",
user_code: document.getElementById("txtusercode").value,
pswd_new2: document.getElementById("txtusercode").value,
},
cache: false,
beforeSend: function () {
show_process();
},
success: function (data) {
hide_process();
alert(data.mesg);
clrs_data();
},
});
}
|