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.117.145.41
// var $host_url =
// "http://" +
// window.location.host +
// "/" +
// window.location.pathname.split("/")[1] +
// "/app.php?a=";
function loadIntake() {
$.ajax({
type: "POST",
url: $host_url + "loadCollegeDetails",
async: false,
success: function(response) {
var { error_code, data, status } = JSON.parse(response);
console.log(data);
if (error_code == "0") {
$("#loadTab").load("intake.html", function() {
var degers = data;
// console.log(degers[0]["fcollcode"]);
var opt = "<option value = ''>All</option>";
for (var i = 0; i < degers.length; i++) {
opt += `<option value = '${degers[i]["fcollcode"]}'>${
degers[i]["fcollname"]
}</option>`;
}
$("#college").html(opt);
// if($('#college').val() == ''){
// $('#degtable').hide();
// }
});
} else {
alert("Please try after some time");
return;
}
}
});
}
var gcolldeg = [];
var gdegrees = [];
function addrow() {
gcolldeg.push({ fdegree: "", fintake: "" });
var str = `<table class="table table-bordered">
<thead>
<tr>
<div style="float: right;">
<button type="button" class="btn btn-primary waves-effect m-l-5" onclick="addrow()" style="margin-right: 15px; margin-bottom: 10px;">
Add
</button>
</div>
</tr>
<tr class="bg-cyan">
<th style = "text-align: center;">Sl. No.</th>
<th style = "text-align: center;">Degree</th>
<th style = "text-align: center;">Intake</th>
</tr>
</thead>
<tbody>`;
var opt = "<option value = ''>>>All<<</option>";
for (var j = 1; j < gdegrees.length; j++) {
opt += `<option id="degval" value = '${gdegrees[j]["fdegree"]}'>${
gdegrees[j]["fdescpn"]
}</option>`;
}
for (var i = 0; i < gcolldeg.length; i++) {
str += `<tr>
<td style = 'text-align: center;'>${i + 1}</td>
<td style = 'text-align: center;'><select id="${i}_degree" class="form-control" onchange="chageDegree(${i}, this)" >${opt}</select></td>
<td style = 'text-align: center;'><input class="form-control form-rounded" type="text" onchange="changeIntake(${i}, this)" size = "5" value="${
gcolldeg[i]["fintake"]
}" rounded id="${i}_deg" />
</td>
</tr>`;
}
$("#degtable").html(str);
for (var i = 0; i < gcolldeg.length; i++) {
$(`#${i}_degree`).val(gcolldeg[i]["fdegree"]);
}
}
function loadCollegeDegree() {
var college = $("#college").val();
var datastring = "&college=" + college;
$.blockUI({ message: "<img src='../img/Loading_icon.gif' border='0'>" });
$.ajax({
type: "POST",
url: $host_url + "loadCollegeDegree",
data: datastring,
success: function(response) {
$.unblockUI();
var { error_code, data, status } = JSON.parse(response);
console.log(data);
if (error_code == "0") {
// console.log(data);
var degers = data.deg;
var colldeg = data.colldeg;
gcolldeg = colldeg;
gdegrees = degers;
// console.log(degers);
var str = `<table class="table table-bordered">
<thead>
<tr>
<div style="float: right;">
<button type="button" class="btn btn-primary waves-effect m-l-5" onclick="addrow()" style="margin-right: 15px; margin-bottom: 10px;">
Add
</button>
</div>
</tr>
<tr class="bg-cyan">
<th style = "text-align: center;">Sl. No.</th>
<th style = "text-align: center;">Degree</th>
<th style = "text-align: center;">Intake</th>
</tr>
</thead>
<tbody>`;
if (data.fdeleted[0].fdeleted == "T") {
var opt = "<option value = 'All'>>>All<<</option>";
for (var j = 1; j < degers.length; j++) {
opt += `<option id="degval" value = '${degers[j]["fdegree"]}'>${
degers[j]["fdescpn"]
}</option>`;
}
var i = 0;
for (let deg of colldeg) {
str += `<tr>
<td style = 'text-align: center;'>${i + 1}</td>
<td style = 'text-align: center;'><select id="${i}_degree" class="form-control" onchange="chageDegree(${i}, this)" >${opt}</select></td>
<td ><input class="form-control form-rounded" style = 'text-align: center;' type="text" value='${
deg.fintake
}' onchange="changeIntake(${i}, this)" size = "5" rounded id="${i}_deg" />
</td>
</tr>`;
i++;
}
} else {
var opt = "<option value = 'All'>>>All<<</option>";
for (var j = 1; j < degers.length; j++) {
opt += `<option id="degval" value = '${degers[j]["fdegree"]}'>${
degers[j]["fdescpn"]
}</option>`;
}
var i = 0;
for (let deg of colldeg) {
str += `<tr>
<td style = 'text-align: center;'>${i + 1}</td>
<td style = 'text-align: center;'><select id="${i}_degree" class="form-control" onchange="chageDegree(${i}, this)" disabled >${opt}</select></td>
<td ><input class="form-control form-rounded" style = 'text-align: center;' type="text" value='${
deg.fintake
}' onchange="changeIntake(${i}, this)" size = "5" rounded id="${i}_deg" disabled />
</td>
</tr>`;
i++;
}
}
$("#degtable").html(str);
for (var i = 0; i < colldeg.length; i++) {
$(`#${i}_degree`).val(colldeg[i]["fdegree"]);
}
} else {
alert("Please try after some time");
return;
}
}
});
}
function chageDegree(i, obj) {
var colldeg = gcolldeg.map((el, j) => {
// console.log(el, j, i);
if (j == i) {
return { fdegree: $(obj).val(), fintake: el.fintake };
} else return el;
});
// console.log(colldeg);
gcolldeg = colldeg;
}
function changeIntake(i, obj) {
var colldeg = gcolldeg.map((el, j) => {
// console.log(el, j, i);
if (j == i) {
return { fdegree: el.fdegree, fintake: $(obj).val() };
} else return el;
});
// console.log(colldeg);
gcolldeg = colldeg;
}
// function changeIntake(i, )
// var i =[];
function saveColldeg() {
var colldeg = gcolldeg;
// console.log(colldeg);
// gcolldeg = [];
var datastring =
"fcollcode=" + $("#college").val() + "&colldeg=" + JSON.stringify(colldeg);
$.ajax({
type: "POST",
url: $host_url + "saveCollegeDegree",
async: false,
data: datastring,
success: function(response) {
// console.log(response);
var { error_code, data, status } = JSON.parse(response);
// console.log(data);
if (error_code == "0") {
alert("Updated Successfullyy");
loadIntake();
} else {
alert("Error While creting user");
}
}
});
}
|