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.58.77.244
function callSelectSubjType() {
$("#page_main_div").load("html_modules/SelectSubjType.html", function () {
// window.enable_proper_module = "SubjectType";
document.getElementById("display_module_name").innerHTML =
"Select Subject Type";
document.getElementById("module_name_for_save").value =
"Select Subject Type";
getDefaultHeadFooterLinks("Select Subject Type");
getDegreesubtypedet();
});
}
var subTypeArr = [];
function getDegreesubtypedet() {
$.ajax({
type: "GET",
url: $host_url + "getDegreesubtypedet",
success: function (response) {
var res = JSON.parse(response);
if (res.error_code == -1) {
alert(res.data);
return;
} else {
var option = `<option value=''>---Select---</option>`;
for (i = 0; i < res.data.length; i++) {
option += `<option value='${res.data[i].fdegree}'>${res.data[i].fdegree} - ${res.data[i].fdescpn}</option>`;
}
document.getElementById("degree").innerHTML = option;
}
},
});
}
// ViewSubjDet_SubType function
function ViewSubjDet_SubType() {
subTypeArr = [];
var degree = document.getElementById("degree").value;
var examno = document.getElementById("examno").value;
var type = document.getElementById("type").value;
if (degree == "") {
alert("Please select Degree");
return;
}
if (examno == "") {
alert("Please select Semister");
return;
}
$.ajax({
type: "GET",
data: "°ree=" + degree + "&examno=" + examno + "&type=" + type,
url: $host_url + "ViewSubjDet_SubType",
success: function (response) {
var res = JSON.parse(response);
if (res.error_code == -1) {
alert(res.data.msg);
document.getElementById("ShowSubjtype").innerHTML = tableHTML;
return;
} else {
subTypeArr.push(res.data.resultsubj);
var tableHTML = `
<div style="height: 300px; overflow: auto;">
<table class='tr_ventor_row' cellspacing='0' class='tr_ventor_row' cellpadding='0' border='0' style="padding-left: 40px;width:85%">
<th align="left" colspan="8" class="ui-jqgrid-titlebar ui-widget-header ui-corner-tl ui-corner-tr ui-helper" style="font-size: 12px; background-color: #fff; padding-left: 10px; height: 24px"></th>
<tr class="ui-state-default ui-jqgrid-hdiv">
<td style="padding: 2px; width:10px;border: 1px solid #4297d7; position: sticky; top: 0; background-color: #c5dbec; ">
<center>Sl.NO</center>
</td>
<td style="padding: 2px; width: 50px;border: 1px solid #4297d7; position: sticky; top: 0; background-color: #c5dbec;">
<center>Subj Code</center>
</td>
<td style="padding: 2px; width: 250px;border: 1px solid #4297d7; position: sticky; top: 0; background-color: #c5dbec; ">
<center>Subject Name</center>
</td>
<td style="padding: 2px; width: 50px; border: 1px solid #4297d7; position: sticky; top: 0; background-color: #c5dbec; ">
<center>Subject Type</center>
</td>
</tr>`;
for (var i = 0; i < res.data.resultsubj.length; i++) {
var rowId = "row_" + i;
var selectId = "SelectSubjtype_" + i;
tableHTML += `
<tr id="${rowId}">
<td align='center' style="border-bottom:1px solid #C5DBEC;border-left: 1px solid #C5DBEC; border-right:1px solid #C5DBEC; padding:2px;">
${i + 1}
</td>
<td align='center' style="border-bottom:1px solid #C5DBEC; border-right:1px solid #C5DBEC; padding:2px;">
${res.data.resultsubj[i].fsubcode}
</td>
<td align='left' style="border-bottom:1px solid #C5DBEC; border-right:1px solid #C5DBEC; padding:2px;">
${res.data.resultsubj[i].Fsubname}
</td>
<td align='center' style="border-bottom:1px solid #C5DBEC; border-right:1px solid #C5DBEC; padding:2px;">
<select
id="${selectId}"
style="width: 100%; height: 30px"
onchange="handlesubtype('${i}')"
value="${res.data.resultsubj[i].fsubtype}"
>`;
var optionValue = res.data.resultsubj[i].fsubtype;
tableHTML += `
<option value="${optionValue}">${optionValue}</option>`;
for (var j = 0; j < res.data.resulttype.length; j++) {
var resultTypeValue = res.data.resulttype[j].fsubtype;
// Check if the resultTypeValue is not equal to the optionValue (to avoid duplicate entries)
if (resultTypeValue !== optionValue) {
tableHTML += `
<option value="${resultTypeValue}">${resultTypeValue}</option>`;
}
}
tableHTML += `</select>
</td>
</tr>`;
}
tableHTML += `</table>
</div>`;
document.getElementById("ShowSubjtype").innerHTML = tableHTML;
}
},
});
}
function handlesubtype(index) {
subTypeArr[0][index]["fstatus"] = "T";
let value = $("#SelectSubjtype_" + index).val();
subTypeArr[0][index]["fsubtype"] = value;
}
function SaveSubjType() {
var degree = document.getElementById("degree").value;
var examno = document.getElementById("examno").value;
var type = document.getElementById("type").value;
// var tableRows = document.querySelectorAll(
// "#ShowSubjtype table tr:not(:first-child)"
// );
if (degree == "") {
alert("Please select Degree");
return;
}
if (examno == "") {
alert("Please select Semister");
return;
}
let dataToSave = [];
subTypeArr[0].forEach((ele) => {
if (ele.fstatus == "T") {
dataToSave.push(ele);
}
});
// var dataToSave = [];
// for (var i = 1; i < tableRows.length; i++) {
// var subjCode = tableRows[i].cells[1].textContent.trim();
// var subjName = tableRows[i].cells[2].textContent.trim();
// var selectId = `SelectSubjtype_${i - 1}`;
// var selectedTypeElement = document.getElementById(selectId);
// if (selectedTypeElement) {
// var selectedType = selectedTypeElement.value;
// dataToSave.push({
// subjCode: subjCode,
// subjName: subjName,
// selectedType: selectedType,
// });
// }
// }
// for (var i = 0; i < changedValues.length; i++) {
// var index = changedValues[i].index;
// var subjCode = res.data.resultsubj[index].fsubcode;
// var subjName = res.data.resultsubj[index].Fsubname;
// var selectedType = changedValues[i].value;
// dataToSave.push({
// subjCode: subjCode,
// subjName: subjName,
// selectedType: selectedType,
// });
// }
$.ajax({
type: "POST",
data: {
dataToSave: JSON.stringify(dataToSave),
degree: degree,
examno: examno,
type: type,
},
url: $host_url + "SaveSubjType",
success: function (response) {
var res = JSON.parse(response);
if (res.error_code == 0) {
alert("Subject Type Selected Successfully");
callSelectSubjType();
} else {
alert(res.data);
return;
}
},
});
}
function ClearSaveSubjType() {
callSelectSubjType();
}
|