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 : 13.59.5.179
var tableArr = [];
function callSubDet() {
$("#page_main_div").load("../html_modules/subdetails.html", function () {
document.getElementById("display_module_name").innerHTML =
"Subject Details";
document.getElementById("module_name_for_save").value = "Subject Details";
getDefaultHeadFooterLinks("Subject Details");
});
loadDegree();
}
function loadDegree() {
$.blockUI({
message:
"<h1 class='h1' style='font-size:12px'><img src='img/ajax-loader.gif' border='0'></h1>",
});
$.ajax({
type: "GET",
url: $host_url + "getDegreeSubDetails",
success: function (res) {
let response = JSON.parse(res);
let deg = `<option>---Select---</option>`;
if (response.error_code == 0) {
for (var i in response.data) {
deg += `<option value='${response.data[i].FDEGREE}'>${response.data[i].FDEGREE} - ${response.data[i].FDESCPN}</option>`;
i++;
}
$("#degree").html(deg);
$.unblockUI();
} else {
alert("No data found");
$.unblockUI();
return;
}
},
});
}
function loadSemester() {
var degree = $("#degree").val();
$.blockUI({
message:
"<h1 class='h1' style='font-size:12px'><img src='img/ajax-loader.gif' border='0'></h1>",
});
$.ajax({
type: "GET",
url: $host_url + "getSemSubDetails" + "°ree=" + degree,
success: function (res) {
let response = JSON.parse(res);
let sem = `<option>---Select---</option>`;
if (response.error_code == 0) {
for (var i in response.data) {
sem += `<option value='${response.data[i].FEXAMNO}'>${response.data[i].FEXAMNO} - ${response.data[i].FEXAMNAME}</option>`;
i++;
}
$("#sem").html(sem);
$.unblockUI();
} else {
alert("No data found");
$.unblockUI();
return;
}
},
});
}
function loadSubject() {
var degree = $("#degree").val();
var sem = $("#sem").val();
$.blockUI({
message:
"<h1 class='h1' style='font-size:12px'><img src='img/ajax-loader.gif' border='0'></h1>",
});
$.ajax({
type: "GET",
url: $host_url + "getSubSubDetails" + "°ree=" + degree + "&sem=" + sem,
success: function (res) {
let response = JSON.parse(res);
let sub = `<option>---Select---</option>`;
if (response.error_code == 0) {
for (var i in response.data) {
sub += `<option value='${response.data[i].fcsubcode}'>${response.data[i].fcsubcode} - ${response.data[i].fsubname}</option>`;
i++;
}
$("#subject").html(sub);
$.unblockUI();
} else {
alert("No data found");
$.unblockUI();
return;
}
},
});
}
function getSubDetData() {
var degree = $("#degree").val();
var sem = $("#sem").val();
var sub = $("#subject").val();
if (degree == "---Select---" || degree == "" || degree == null) {
alert("Select Degree");
return;
}
if (sem == "---Select---" || sem == "" || sem == null) {
alert("Select Sem");
return;
}
if (sub == "---Select---" || sub == "" || sub == null) {
alert("Select Subject");
return;
}
let param = "°ree=" + degree + "&sem=" + sem + "&sub=" + sub;
$.blockUI({
message:
"<h1 class='h1' style='font-size:12px'><img src='img/ajax-loader.gif' border='0'></h1>",
});
$.ajax({
type: "POST",
url: $host_url + "getSubDetData",
data: param,
success: function (res) {
let response = JSON.parse(res);
if (response.error_code == 0) {
$("#getData").show();
let table = `<table align="center" width="100%" cellspacing="0" cellpadding="1" border="1" style="border-radius:5px">
<tr>
<th align="left" colspan="14" class="ui-jqgrid-titlebar ui-widget-header ui-corner-tl ui-corner-tr ui-helper"
style="font-size:12px; padding-left:6px; height:24px;">Subject Details</th>
</tr>
<tr class="ui-state-default ui-jqgrid-hdiv">
<th align="center" style="font-size:12px;
border-left:1px solid #C5DBEC;border-right:1px solid #C5DBEC;
border-bottom:1px solid #C5DBEC;">Sl. No.</th>
<th align="center" style="font-size:12px; padding:5px 5px;
border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;">Degree</th>
<th align="center" style="font-size:12px; padding:5px 5px;
border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;">Exam No.</th>
<th align="center" style="font-size:12px; padding:5px 5px;
border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;">Subject</th>
<th align="center" style="font-size:12px;
border-left:1px solid #C5DBEC;border-right:1px solid #C5DBEC;
border-bottom:1px solid #C5DBEC;">Element</th>
<th align="center" style="font-size:12px; padding:5px 5px;
border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;">Sub. Name</th>
<th align="center" style="font-size:12px;
border-left:1px solid #C5DBEC;border-right:1px solid #C5DBEC;
border-bottom:1px solid #C5DBEC;">Th./Pr.</th>
<th align="center" style="font-size:12px; padding:5px 5px;
border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;">Max Marks</th>
<th align="center" style="font-size:12px; padding:5px 5px;
border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;">Qn. No.</th>
<th align="center" style="font-size:12px; padding:5px 5px;
border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;">No. of Tests</th>
<th align="center" style="font-size:12px; padding:5px 5px;
border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;">U1 Max</th>
<th align="center" style="font-size:12px; padding:5px 5px;
border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;">U2 Max</th>
<th align="center" style="font-size:12px; padding:5px 5px;
border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;">Order</th>
<th align="center" style="font-size:12px; padding:5px 5px;
border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;">Action</th>
</tr>`;
for (var i = 0; i < response.data.length; i++) {
table += `<tr>
<td class="tbl_row_new" style="text-align:center !important; text-align:initial; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;">
${i + 1}
</td>
<td class="tbl_row_new" style="text-align:center !important; text-align:initial; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;">
${response.data[i].fdegree}
</td>
<td class="tbl_row_new" style="text-align:center !important; text-align:initial; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;">
${response.data[i].fexamno}
</td>
<td class="tbl_row_new" style="text-align:initial; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;">
${response.data[i].fcsubname}
</td>
<td class="tbl_row_new" style="text-align:center !important; text-align:initial; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;">
${response.data[i].fsubcode}
</td>
<td class="tbl_row_new" style="text-align:initial; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;">
${response.data[i].fsubname}
</td>
<td class="tbl_row_new" style="text-align:center; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;">
${response.data[i].ftheory}
</td>
<td class="tbl_row_new" style="text-align:center !important; text-align:initial; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;">
${response.data[i].fmaxmarks}
</td>
<td class="tbl_row_new" style="text-align:center !important; text-align:initial; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;">
${response.data[i].fqnno}
</td>
<td class="tbl_row_new" style="text-align:center !important; text-align:initial; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;">
${response.data[i].fnotest}
</td>
<td class="tbl_row_new" style="text-align:center !important; text-align:initial; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;">
${response.data[i].fu1max}
</td>
<td class="tbl_row_new" style="text-align:center !important; text-align:initial; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;">
${response.data[i].fu2max}
</td>
<td class="tbl_row_new" style="text-align:center !important; text-align:initial; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;">
${response.data[i].forder}
</td>
<td class="tbl_row_new" style="text-align:center !important; text-align:initial; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;display:flex">
<span
onclick="editSubDetData(
'${response.data[i].fdegree}',
'${response.data[i].fexamno}',
'${response.data[i].fcsubcode}',
'${response.data[i].fsubcode}',
'${response.data[i].fsubname}',
'${response.data[i].fmaxmarks}',
'${response.data[i].fqnno}',
'${response.data[i].fnotest}',
'${response.data[i].fu1max}',
'${response.data[i].fu2max}',
'${response.data[i].forder}',
'${response.data[i].ftheory}'
)"
style="
background-color: #008cba;
border: none;
color: white;
padding: 6px 10px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 13px;
cursor: pointer;
border-radius: 3px;">Edit</span>
<span
onclick="deleteSubDet(
'${response.data[i].fdegree}',
'${response.data[i].fexamno}',
'${response.data[i].fcsubcode}',
'${response.data[i].fsubcode}',
)"
style="
background-color: #FF0000;
border: none;
color: white;
padding: 6px 10px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 13px;
cursor: pointer;
margin-left:5px;
border-radius: 3px;">Delete</span>
</td>
</tr>`;
}
table += `</table>`;
$("#getData").html(table);
$.unblockUI();
} else {
alert(response.data.msg);
$("#getData").hide();
$.unblockUI();
return;
}
},
});
}
function addRow(table_body) {
var tabBody = document.getElementById(table_body),
first_tr = tabBody.firstElementChild;
tr_clone = first_tr.cloneNode(true);
tabBody.append(tr_clone);
clean_first_tr(tabBody.firstElementChild);
}
function clean_first_tr(first_tr) {
let children = first_tr.children;
children = Array.isArray(children) ? children : Object.values(children);
children.forEach((x) => {
if (x !== first_tr.lastElementChild) {
x.firstElementChild.value = "";
}
});
}
function onlyNumberKey(evt) {
var ASCIICode = evt.which ? evt.which : evt.keyCode;
if (ASCIICode > 31 && (ASCIICode < 48 || ASCIICode > 57)) return false;
return true;
}
function getElementsubDet() {
var degree = $("#degree").val();
var sem = $("#sem").val();
var sub = $("#subject").val();
var element = $("#element").val();
var params =
"degree=" + degree + "&sem=" + sem + "&sub=" + sub + "&element=" + element;
$.blockUI({
message:
"<h1 class='h1' style='font-size:12px'><img src='img/ajax-loader.gif' border='0'></h1>",
});
$.ajax({
type: "GET",
url: $host_url + "getElementsubDet",
data: params,
success: function (res) {
var response = JSON.parse(res);
if (response.error_code == 0) {
alert(response.data.msg);
$("#element").focus();
$.unblockUI();
return;
}
$.unblockUI();
},
});
$.unblockUI();
}
function editSubDetData(
degree,
examno,
fcsubcode,
fsubcode,
fsubname,
fmaxmarks,
fqnno,
fnotest,
fu1max,
fu2max,
order,
theory
) {
$("#tabdet").hide();
$("#editdata").show();
var tabledata = `<table align="center" width="100%" cellspacing="0" cellpadding="1" border="1" style="border-radius:5px">
<tr class="ui-state-default ui-jqgrid-hdiv">
<th align="center" style="width:50px; font-size:12px;
border-left:1px solid #C5DBEC;border-right:1px solid #C5DBEC;
border-bottom:1px solid #C5DBEC;">Element</th>
<th align="center" style="width:80px; font-size:12px; padding:5px 5px;
border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;">Sub. Name</th>
<th align="center" style="width:120px; font-size:12px; padding:5px 5px;
border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;">Th./Pr.</th>
<th align="center" style="width:70px; font-size:12px; padding:5px 5px;
border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;">Max. Marks</th>
<th align="center" style="width:60px; font-size:12px; padding:5px 5px;
border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;">Qn. No.</th>
<th align="center" style="width:50; font-size:12px; padding:5px 5px;
border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;">No. of Tests</th>
<th align="center" style="width:50px; font-size:12px; padding:5px 5px;
border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;">U1 Max</th>
<th align="center" style="width:50px; font-size:12px; padding:5px 5px;
border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;">U2 Max</th>
<th align="center" style="width:50px; font-size:12px; padding:5px 5px;
border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;">Order</th>
<th align="center" style="width:50px; font-size:12px; padding:5px 5px;
border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;">Action</th>
</tr>
<tr>
<td class="tbl_row_new" style="text-align:center !important; text-align:initial; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;">
<input type = 'text' id="element" maxlength="1" style="width: 70px; height: 25px" onkeypress="return onlyNumberKey(event)"></td>
<td class="tbl_row_new" style="text-align:center !important; text-align:initial; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;">
<input type = 'text' id="subname" style="width: 100px; height: 25px"></td>
<td class="tbl_row_new" style="text-align:center !important; text-align:initial; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;">
<select id="theory" style="width: 126px;height: 30px;">
<option value='T'>Theory</option>
<option value='F'>Practical</option>
</select></td>
<td class="tbl_row_new" style="text-align:center !important; text-align:initial; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;">
<input type = 'text' id="maxmarks" style="width: 68px; height: 25px"></td>
<td class="tbl_row_new" style="text-align:center !important; text-align:initial; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;">
<input type = 'text' id="qnno" style="width: 60px; height: 25px"></td>
<td class="tbl_row_new" style="text-align:center !important; text-align:initial; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;">
<input type = 'text' id="notest" style="width: 82px; height: 25px"></td>
<td class="tbl_row_new" style="text-align:center !important; text-align:initial; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;">
<input type = 'text' id="u1max" style="width: 50px; height: 25px"></td>
<td class="tbl_row_new" style="text-align:center !important; text-align:initial; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;">
<input type = 'text' id="u2max" style="width: 50px; height: 25px"></td>
<td class="tbl_row_new" style="text-align:center !important; text-align:initial; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;">
<input type = 'text' id="order" style="width: 50px; height: 25px"></td>
<td class="tbl_row_new" style="text-align:center !important; text-align:initial; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;">
<span
style="
background-color: #008cba;
border: none;
color: white;
padding: 7px 20px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 13px;
cursor: pointer;
border-radius:4px;
"
onclick="saveSubDetData()"
>Save</span></td>
</tr>
</table>`;
$("#editdata").html(tabledata);
$("#degree").val(degree);
$("#sem").val(examno);
$("#subject").val(fcsubcode);
$("#element").val(fsubcode);
$("#subname").val(fsubname);
$("#maxmarks").val(fmaxmarks);
$("#qnno").val(fqnno);
$("#notest").val(fnotest);
$("#u1max").val(fu1max);
$("#u2max").val(fu2max);
$("#order").val(order);
$("#theory").val(theory);
$("#element").prop("disabled", true);
$("#degree").prop("disabled", true);
$("#sem").prop("disabled", true);
$("#subject").prop("disabled", true);
}
function saveSubDetData() {
var degree = $("#degree").val();
var sem = $("#sem").val();
var sub = $("#subject").val();
var element = $("#element").val();
var subname = $("#subname").val();
var maxmarks = $("#maxmarks").val();
var qnno = $("#qnno").val();
var notest = $("#notest").val();
var u1max = $("#u1max").val();
var u2max = $("#u2max").val();
var order = $("#order").val();
var theory = $("#theory").val();
if (degree == "---Select---" || degree == "" || degree == null) {
alert("Select Degree");
return;
}
if (sem == "---Select---" || sem == "" || sem == null) {
alert("Select Sem");
return;
}
if (sub == "---Select---" || sub == "" || sub == null) {
alert("Select Subject");
return;
}
if (element == "") {
alert("Enter Element");
$("#element").focus();
return;
}
if (subname == "") {
alert("Enter Subject Name");
$("#subname").focus();
return;
}
if (maxmarks == "") {
alert("Enter Maximum Marks");
$("#maxmarks").focus();
return;
}
if (qnno == "") {
alert("Enter Question Number");
$("#qnno").focus();
return;
}
if (notest == "") {
alert("Enter Test Number");
$("#notest").focus();
return;
}
if (u1max == "") {
alert("Enter U1 Maximum Marks");
$("#u1max").focus();
return;
}
if (u2max == "") {
alert("Enter U2 Maximum Marks");
$("#u2max").focus();
return;
}
let param =
"degree=" +
degree +
"&sem=" +
sem +
"&sub=" +
sub +
"&element=" +
element +
"&subname=" +
subname +
"&maxmarks=" +
maxmarks +
"&qnno=" +
qnno +
"¬est=" +
notest +
"&u1max=" +
u1max +
"&u2max=" +
u2max +
"&order=" +
order +
"&theory=" +
theory;
$.blockUI({
message:
"<h1 class='h1' style='font-size:12px'><img src='img/ajax-loader.gif' border='0'></h1>",
});
$.ajax({
type: "POST",
url: $host_url + "saveSubDetData",
data: param,
success: function (res) {
let response = JSON.parse(res);
if (response.error_code == 0) {
alert(response.data.msg);
getSubDetData();
$("#editdata").hide();
$.unblockUI();
return;
} else {
alert(response.data.msg);
$.unblockUI();
return;
}
},
});
}
function deleteSubDet(degree, examno, fcsubcode, fsubcode) {
var text = "Are You Sure?";
var params =
"degree=" +
degree +
"&sem=" +
examno +
"&sub=" +
fcsubcode +
"&element=" +
fsubcode;
if (confirm(text) == true) {
$.blockUI({
message:
"<h1 class='h1' style='font-size:12px'><img src='img/ajax-loader.gif' border='0'></h1>",
});
$.ajax({
type: "POST",
url: $host_url + "deleteSubDet",
data: params,
success: function (res) {
let response = JSON.parse(res);
if (response.error_code == 0) {
alert(response.data.msg);
getSubDetData();
$.unblockUI();
return;
}
},
});
} else {
console.log("cancelled");
$.unblockUI();
return;
}
}
function addSubjectDet() {
var degree = $("#degree").val();
var sem = $("#sem").val();
var sub = $("#subject").val();
if (degree == "---Select---" || degree == "" || degree == null) {
alert("Select Degree");
return;
}
if (sem == "---Select---" || sem == "" || sem == null) {
alert("Select Sem");
return;
}
if (sub == "---Select---" || sub == "" || sub == null) {
alert("Select Subject");
return;
}
$("#editdata").hide();
$("#tabdet").show();
let j = tableArr.length;
getSubDetRow(j);
}
function getSubDetRow(j) {
let addRowDet = {
element: `<input type = 'text' id="element_${j}" maxlength="1" style="width: 70px; height: 25px" onkeypress="return onlyNumberKey(event)">`,
subname: `<input type = 'text' id="subname_${j}" style="width: 100px; height: 25px">`,
theory: `<select id="theory_${j}" style="width: 126px;height: 30px;">
<option value='T'>Theory</option>
<option value='F'>Practical</option>
</select>`,
maxmarks: `<input type = 'text' id="maxmarks_${j}" style="width: 68px; height: 25px">`,
qnno: `<input type = 'text' id="qnno_${j}" style="width: 60px; height: 25px">`,
notest: ` <input type = 'text' id="notest_${j}" style="width: 82px; height: 25px">`,
u1max: `<input type = 'text' id="u1max_${j}" style="width: 50px; height: 25px">`,
u2max: ` <input type = 'text' id="u2max_${j}" style="width: 50px; height: 25px">`,
order: `<input type = 'text' id="order_${j}" style="width: 50px; height: 25px" onblur="addSubjectDet()">`,
delete: `<span onclick="remove_tr(this, ${j})" style="background-color: #FF0000;border: none;color: white;padding: 6px 10px;text-align: center;text-decoration: none;display: inline-block;font-size: 13px;cursor: pointer;border-radius: 3px;">Delete</span>`,
};
if (
$(`#element_${j - 1}`).val() == "" ||
$(`#subname_${j - 1}`).val() == "" ||
$(`#maxmarks_${j - 1}`).val() == "" ||
$(`#qnno_${j - 1}`).val() == "" ||
$(`#notest_${j - 1}`).val() == "" ||
$(`#u1max_${j - 1}`).val() == "" ||
$(`#u2max_${j - 1}`).val() == "" ||
$(`#theory_${j - 1}`).val() == "" ||
$(`#order_${j - 1}`).val() == ""
) {
alert("Please fill all the details..!");
return;
}
tableArr.push(addRowDet);
var addrow = `<tr>
<td class="tbl_row_new" style="text-align:center !important; text-align:initial; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;">
${addRowDet.element}
</td>
<td class="tbl_row_new" style="text-align:initial !important; text-align:initial; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;">
${addRowDet.subname}
</td>
<td class="tbl_row_new" style="text-align:center !important; text-align:initial; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;">
${addRowDet.theory}
</td>
<td class="tbl_row_new" style="text-align:center !important; text-align:initial; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;">
${addRowDet.maxmarks}
</td>
<td class="tbl_row_new" style="text-align:center !important; text-align:initial; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;">
${addRowDet.qnno}
</td>
<td class="tbl_row_new" style="text-align:center !important; text-align:initial; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;">
${addRowDet.notest}
</td>
<td class="tbl_row_new" style="text-align:center !important; text-align:initial; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;">
${addRowDet.u1max}
</td>
<td class="tbl_row_new" style="text-align:center !important; text-align:initial; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;">
${addRowDet.u2max}
</td>
<td class="tbl_row_new" style="text-align:center !important; text-align:initial; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;">
${addRowDet.order}
</td>
<td class="tbl_row_new" style="text-align:center !important; text-align:initial; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;">
${addRowDet.delete}
</td>
</tr>`;
$("#tabledata").append(addrow);
$(`#element_${j}`).focus();
}
function remove_tr(This, index) {
if (index == 0) {
alert("cannot delete this");
} else {
delete tableArr[index];
This.closest("tr").remove();
}
}
function saveSubjectDet() {
var finalArr = [];
var degree = $("#degree").val();
var sem = $("#sem").val();
var sub = $("#subject").val();
var mmarks = $("#maxmarks").val();
for (var i = 0; i < tableArr.length; i++) {
if (tableArr[i] != undefined || $(`#element_${i}`).val() != "") {
var element = $(`#element_${i}`).val();
var subname = $(`#subname_${i}`).val();
var maxmarks = $(`#maxmarks_${i}`).val();
var qnno = $(`#qnno_${i}`).val();
var notest = $(`#notest_${i}`).val();
var u1max = $(`#u1max_${i}`).val();
var u2max = $(`#u2max_${i}`).val();
var theory = $(`#theory_${i}`).val();
var order = $(`#order_${i}`).val();
var input = {
element: element,
subname: subname,
maxmarks: maxmarks,
qnno: qnno,
notest: notest,
u1max: u1max,
u2max: u2max,
theory: theory,
order: order,
};
finalArr.push(input);
}
}
for (var j = finalArr.length - 1; j >= 0; j--) {
if (finalArr[j].element == undefined || finalArr[j].element == "") {
finalArr.splice(j, 1);
}
}
var j = tableArr.length;
if (
$(`#element_${j - 1}`).val() == "" ||
$(`#subname_${j - 1}`).val() == "" ||
$(`#maxmarks_${j - 1}`).val() == "" ||
$(`#qnno_${j - 1}`).val() == "" ||
$(`#notest_${j - 1}`).val() == "" ||
$(`#u1max_${j - 1}`).val() == "" ||
$(`#u2max_${j - 1}`).val() == "" ||
$(`#theory_${j - 1}`).val() == "" ||
$(`#order_${j - 1}`).val() == ""
) {
alert("Please fill all the details..!");
return;
}
for (var j = 0; j < finalArr.length - 1; j++) {
if (finalArr[j + 1].element == finalArr[j].element) {
alert("Duplicate Element Found");
return;
}
}
let total = 0;
for (var k = 0; k < finalArr.length; k++) {
total += parseInt(finalArr[k]["maxmarks"]);
}
if (
window.db !== "nmamit" &&
window.db !== "jssstu" &&
window.db !== "jssu"
) {
if (parseInt(total) != parseInt(mmarks)) {
alert("Element total maximum is not matching with subject maximum");
return;
}
}
$.blockUI({
message:
"<h1 class='h1' style='font-size:12px'><img src='img/ajax-loader.gif' border='0'></h1>",
});
$.ajax({
type: "POST",
data:
"&tdata=" +
JSON.stringify(finalArr) +
"°ree=" +
degree +
"&sem=" +
sem +
"&subject=" +
sub,
url: $host_url + "saveIASubDetData",
success: function (res) {
console.log();
let response = JSON.parse(res);
if (response.error_code == 0) {
alert(response.data.msg);
getSubDetData();
$.unblockUI();
return;
} else {
alert(response.data.msg);
$.unblockUI();
return;
}
},
});
}
function getMaximumMarks() {
let degree = $("#degree").val();
let sem = $("#sem").val();
let subject = $("#subject").val();
$.blockUI({
message:
"<h1 class='h1' style='font-size:12px'><img src='img/ajax-loader.gif' border='0'></h1>",
});
$.ajax({
type: "GET",
url: $host_url + "getSubDetMaxMarks",
data: "°ree=" + degree + "&sem=" + sem + "&subject=" + subject,
success: function (res) {
let response = JSON.parse(res);
console.log(response);
if (response.error_code === 0) {
$("#maxmarks").val(response.data.fvalmax);
$.unblockUI();
} else {
alert(res.data.msg);
$.unblockUI();
return;
}
},
});
}
|