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.116.49.143
Current Path : /var/www/html/ibm/js/ |
| Current File : /var/www/html/ibm/js/MainPage.js |
var $host_url =
window.location.protocol +
"//" +
window.location.host +
"/" +
window.location.pathname.split("/")[1] +
"/app.php?db=" +
window.location.pathname.split("/")[2] +
"&a=";
function loadMasters() {
var crmode = getCookie("curuniv");
$("#user").show();
$("#assigned").show();
$("#save").show();
if (getCookie("username") != "mvsadmin") {
$("#user").hide();
$("#assigned").hide();
$("#save").hide();
}
$("#masuser").html(getCookie("username"));
if (trim(crmode) != "") {
var urlarr = window.location.pathname.split("/");
var $url = "http://" + window.location.host + "/";
$hoststr = "";
for (var j = 1; j < urlarr.length - 1; j++) {
$hoststr += window.location.pathname.split("/")[j] + "/";
}
$host_url = $url + $hoststr + "app.php?cdb=" + crmode + "&a=";
}
$is_logged_user = isLoggedIn();
if ($is_logged_user == 0) {
loadappstatus();
} else {
alert("Please Login");
window.location.href = "index.html";
}
}
function isLoggedIn() {
var logedin;
$.ajax({
type: "POST",
async: false,
url: $host_url + "loggedinvalidate",
success: function isLoggedInResponce(responce) {
responce = eval("(" + responce + ")");
logedin = responce.error_code;
},
});
return logedin;
}
function logout() {
$.ajax({
type: "POST",
async: false,
url: $host_url + "logout",
});
window.location.href = "index.html";
}
function loadMcVerify() {
$("#loadtab").load("../mc-verify.html");
}
function loadappform() {
$("#loadtab").load("../appForm.html");
$.ajax({
type: "POST",
url: $host_url + "getdropdownmenuvalues",
success: function GetCMSDropDownMenuValuesResponce(responce) {
responce = eval("(" + responce + ")");
var serv_arr = responce.data["serv_type"];
var serv_title = "";
FillDropdownValues(serv_arr, "S2", serv_title);
var category = responce.data["category"];
var cat_title = "";
FillDropdownValues(category, "formcategory", cat_title);
var pay_arr = responce.data["pay_type"];
var pay_title = "";
FillDropdownValues(pay_arr, "S3", pay_title);
},
});
}
function showStudentDetails($responce) {
$responce = eval("(" + $responce + ")");
$("#idModal2").empty();
$("#idModal2").append($responce.data["html"]);
$("#idModal1").modal();
}
function loadappstatus() {
$("#loadtab").load("../appStatus.html");
$.ajax({
type: "POST",
url: $host_url + "getcmsdropdownmenuvalues",
success: function GetCMSDropDownMenuValuesResponce(responce) {
responce = eval("(" + responce + ")");
var serv_arr = responce.data["serv_type"];
var str = ``;
serv_arr.forEach((element) => {
str += `<option value = '${element["int_code"]}'>${element["val"]}</option>`;
});
$("#S4").html(str);
}
});
}
function downloadverifieddoc() {
console.log('hii');
$("#loadtab").load("downloadverifieddoc.html");
$.ajax({
type: "POST",
url: $host_url + "getcmsdropdownmenuvalues",
success: function GetCMSDropDownMenuValuesResponce(responce) {
responce = eval("(" + responce + ")");
console.log(responce);
var serv_arr = responce.data["serv_type"];
var str = ``;
serv_arr.forEach((element) => {
str += `<option value = '${element["int_code"]}'>${element["val"]}</option>`;
});
$("#S4").html(str);
}
});
}
function loadCreateUser() {
$("#loadtab").load("../createUser.html", function () {
$("#edit").hide();
$("#add").show();
$("#screen").val("add");
$.ajax({
type: "POST",
async: false,
url: $host_url + "loadDegGrp",
success: function loadDegGrpResponce(responce) {
responce = eval("(" + responce + ")");
var serv_arr = responce.data;
var opt = "<option value = 'All'>All</option>";
for (var i = 0; i < serv_arr.length; i++) {
opt += `<option value = '${serv_arr[i]["fdeggrp"]}'>${serv_arr[i]["fdeggrp"]}</option>`;
}
$("#deggrp").html(opt);
},
});
});
}
var deglen = 0;
function createUser() {
var usrname = $("#username").val();
var password = $("#password").val();
var mob = $("#mob").val();
var name = $("#name").val();
var deggrp = $("#deggrp").val();
if (usrname == "") {
alert("Fill user Name");
return;
}
if (mob == "") {
alert("Fill Mobile No.");
return;
}
if (name == "") {
alert("Fill user full name");
return;
}
if ($("#screen").val() == "add") {
if (password == "") {
alert("Fill password");
return;
}
}
var degs = "";
for (var i = 1; i < deglen; i++) {
if (document.getElementById(`${i}_deg`).checked == true) {
degs += $(`#${i}_deg`).val() + "*";
}
}
if (degs == "") {
alert("Please select atleast one degree");
return;
}
var datastring =
"&usrname=" +
usrname +
"&password=" +
encodeURIComponent(password) +
"°s=" +
degs +
"&mob=" +
mob +
"&name=" +
name +
"°grp=" +
deggrp +
"&screen=" +
$("#screen").val();
$.ajax({
type: "POST",
url: $host_url + "createUser",
data: datastring,
success: function ($responce) {
$responce = eval("(" + $responce + ")");
if ($responce.error_code == "0") {
alert("Updated Successfullyy");
loadCreateUser();
} else {
alert("Error While creting user");
}
},
});
}
function loadDegree() {
var deggrp = $("#deggrp").val();
var datastring = "°grp=" + deggrp;
//alert(datastring);
$.ajax({
type: "POST",
url: $host_url + "loadDegree",
async: false,
data: datastring,
success: function ($responce) {
$responce = eval("(" + $responce + ")");
if ($responce.error_code == "0") {
var degers = $responce.data;
deglen = degers.length;
var str = `<table class="table table-bordered">
<thead>
<tr>
<th style = "text-align: center;">Sl. No.</th>
<th style = "text-align: center;">Degree Code</th>
<th style = "text-align: center;">Degree Name</th>
<th style = "text-align: center;">Check Box</th>
</tr>
</thead>
<tbody>`;
for (var i = 1; i < degers.length; i++) {
str += `<tr>
<td style = 'text-align: center;'>${i}</td>
<td style = 'text-align: center;'>${degers[i]["FPROGCODE"]}</td>
<td>${degers[i]["fdescpn"]}</td>
<td> <input type="checkbox" id="${i}_deg" value = '${degers[i]["FPROGCODE"]}' autocomplete="off"/>
<label for="${i}_deg" style="font-size:10px !important;"> </label>
</td>
</tr>`;
}
$("#degtable").html(str);
} else {
alert("Please try after some time");
return;
}
},
});
}
function FillDropdownValues(arr, ele_name, def_title) {
// document.getElementById(ele_name).options.length = 0;
var op = new Option(" Select " + def_title, "#");
op.id = "999";
document.getElementById(ele_name).options.add(op);
if (ele_name == "S4") {
var op1 = new Option(" All " + def_title, "all");
op1.id = "00";
op1.selected = "selected";
document.getElementById(ele_name).options.add(op1);
}
jQuery.each(arr, function (k, v) {
var op = new Option(v["val"], v["int_code"]);
op.id = v["int_code"];
document.getElementById(ele_name).options.add(op);
});
}
function loadedit() {
$("#edit").show();
$("#add").hide();
var datastring = "";
$.ajax({
type: "POST",
async: false,
url: $host_url + "loadusers",
data: datastring,
success: function ($responce) {
$responce = eval("(" + $responce + ")");
if ($responce.error_code == "0") {
var users = $responce.data;
var str = `<table class="table table-bordered table-hover" style="width:90%">
<thead>
<tr>
<th style = "text-align: center;">Sl. No.</th>
<th style = "text-align: center;">User Name</th>
<th style = "text-align: center;">Mobile No.</th>
<th style = "text-align: center;">Edit</th>
<th style = "text-align: center;">Reset </br>Password</th>
<th style = "text-align: center;">Delete</th>
</tr>
</thead>
<tbody>`;
for (var i = 0; i < users.length; i++) {
str += `<tr>
<td style = 'text-align: center;'>${i + 1}</td>
<td style = 'text-align: center;'>${users[i]["name"]}</td>
<td>${users[i]["mob"]}</td>
<td>
<button
type="button"
class="btn btn-primary waves-effect m-l-5"
onclick="editUser('${users[i]["mob"]}','${users[i]["fdegree"]}','${
users[i]["name"]
}','${users[i]["fusername"]}','${users[i]["fdeggrp"]}')"
>
Edit
</button>
</td>
<td>
<button
type="button"
class="btn btn-primary waves-effect m-l-5"
onclick="reseteUser('${users[i]["mob"]}')"
>
Reset
</button>
</td>
<td>
<button
type="button"
class="btn btn-primary waves-effect m-l-5"
onclick="deleteUser('${users[i]["mob"]}')"
>
Delete
</button>
</td>
</tr>`;
}
$("#edittable").html(str);
} else {
alert("Please try after some time");
return;
}
},
});
}
function editUser(mob, degrees, name, username, deggrp) {
// loadCreateUser();
$("#loadtab").load("../createUser.html", function () {
$("#edit").hide();
$("#add").show();
$.ajax({
type: "POST",
async: false,
url: $host_url + "loadDegGrp",
success: function loadDegGrpResponce(responce) {
responce = eval("(" + responce + ")");
var serv_arr = responce.data;
var opt = "<option>-Select-</option>";
for (var i = 0; i < serv_arr.length; i++) {
opt += `<option value = '${serv_arr[i]["fdeggrp"]}'>${serv_arr[i]["fdeggrp"]}</option>`;
}
$("#deggrp").html(opt);
$("#name").val(name);
$("#username").val(username);
$("#deggrp").val(deggrp);
$("#mob").val(mob);
$("#screen").val("edit");
document.getElementById("password").disabled = true;
document.getElementById("mob").disabled = true;
loadDegree();
for (var i = 1; i < deglen; i++) {
var n = degrees.includes($(`#${i}_deg`).val() + "*");
if (n) {
document.getElementById(`${i}_deg`).checked = true;
}
}
},
});
});
}
function deleteUser(mob) {
$.ajax({
type: "POST",
url: $host_url + "deleteUser",
data: "mob=" + mob,
success: function ($responce) {
$responce = eval("(" + $responce + ")");
if ($responce.error_code == "0") {
alert("Updated Successfullyy");
loadCreateUser();
} else {
alert("Error While creting user");
}
},
});
}
function reseteUser(mob) {
$.ajax({
type: "POST",
url: $host_url + "reseteUser",
data: "mob=" + mob,
success: function ($responce) {
$responce = eval("(" + $responce + ")");
if ($responce.error_code == "0") {
alert("Updated Successfullyy");
loadCreateUser();
} else {
alert("Error While creting user");
}
},
});
}
function loadChangePassword() {
$("#loadtab").load("../changePassword.html");
}
function changePsw() {
if ($("#newpasswd").val() == "") {
alert("Enter New Password");
return;
}
if ($("#oldpsw").val() == "") {
alert("Enter Old Password");
return;
}
$.ajax({
type: "POST",
url: $host_url + "changePswd",
data:
"oldpasswd=" + $("#oldpsw").val() + "&newpasswd=" + $("#newpasswd").val(),
success: function ($responce) {
$responce = eval("(" + $responce + ")");
if ($responce.error_code == "0") {
alert($responce.data);
loadChangePassword();
return;
} else {
alert($responce.data);
loadChangePassword();
return;
}
},
});
}
function allowAlphaNumericSpace(e) {
var code = "charCode" in e ? e.charCode : e.keyCode;
if (
!(code > 47 && code < 58) && // numeric (0-9)
!(code > 64 && code < 91) && // upper alpha (A-Z)
!(code > 96 && code < 123)
) {
// lower alpha (a-z)
e.preventDefault();
}
}
function isNumberKey(evt) {
var charCode = evt.which ? evt.which : evt.keyCode;
if (charCode > 31 && (charCode < 48 || charCode > 57)) return false;
return true;
}
|