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.223.158.29
Current Path : /var/www/oasis/js/ |
| Current File : /var/www/oasis/js/createClass.js |
function createclassattend() {
$("#page_main_div").load(
"../html_modules/createclassattend.html?",
function () {
document.getElementById("display_module_name").innerHTML =
"Add Students to Class";
document.getElementById("module_name_for_save").value =
"Add Students to Class";
getDefaultHeadFooterLinks("Add Students to Class");
}
);
loadteachnameadd();
// loadclassname();
loaddegreecreateclass();
}
function loadteachnameadd() {
$.blockUI({
message:
"<h1 class='h1' style='font-size:12px'><img src='img/ajax-loader.gif' border='0'></h1>",
});
$.ajax({
type: "POST",
url: $host_url + "loadteachname",
//async: false,
success: function (response) {
var res = JSON.parse(response);
var teachnameoptions = "";
if (res.data.length > 1) {
//console.log("indise");
//$("#teachname").prop("disabled", true);
} else {
//$("#teachname").prop("disabled", false);
}
//if (res.data.length > 1)
teachnameoptions = "<option value=''>---Select Teacher---</option>";
for (var i = 0; i < res.data.length; i++) {
teachnameoptions += `<option value='${res.data[i].teachcode}'>${res.data[i].teachcode} - ${res.data[i].teachname}</option>`;
}
// console.log("ccc", teachnameoptions);
$("#teachname").html(teachnameoptions);
$.unblockUI();
//changeclassname();
},
});
}
function changeclassname() {
var techcode = document.getElementById("teachname").value;
console.log(techcode);
if (techcode == "") {
return;
}
$.ajax({
type: "POST",
data: "&techcode=" + techcode,
url: $host_url + "loadclassname",
success: function (response) {
var res = JSON.parse(response);
console.log(res);
var classnameoption = "<option value=''>---Select Class Name---</option>";
for (var i = 0; i < res.data.length; i++) {
classnameoption += `<option value='${res.data[i].fclassid}'>${res.data[i].fclassname} - ${res.data[i].fclassid}</option>`;
}
$("#classnameoptions").html(classnameoption);
},
});
}
// function loadclassname() {
// $.ajax({
// type: "GET",
// url: $host_url + "loadclassname",
// success: function (response) {
// var res = JSON.parse(response);
// var classnameoptions =
// "<option value=''>---Select Class Name---</option>";
// for (var i = 0; i < res.data.length; i++) {
// classnameoptions += `<option value='${res.data[i].fclassname}-${res.data[i].fclassid}'>${res.data[i].fclassname} - ${res.data[i].fclassid}</option>`;
// }
// $("#classnameoptions").html(classnameoptions);
// },
// });
// }
function loaddegreecreateclass() {
$.ajax({
type: "GET",
//async: false,
url: $host_url + "loaddegreecreateclass",
success: function (response) {
var res = JSON.parse(response);
var degreeOptions = "<option value=''>---Select Degree---</option>";
for (var i = 0; i < res.data.length; i++) {
degreeOptions += `<option value='${res.data[i].fdegree}'>${res.data[i].fdegree} - ${res.data[i].fdescpn}</option>`;
}
$("#degoptions").html(degreeOptions);
},
});
}
function loadsemattend() {
var degree = document.getElementById("degoptions").value;
var mode = document.getElementById("mode").value;
$.ajax({
type: "GET",
data: "°ree=" + degree + "&mode=" + mode,
url: $host_url + "loadsemcreateclass",
success: function (response) {
var res = JSON.parse(response);
var semOptions = "<option value=''>---Select Semester---</option>";
for (var i = 0; i < res.data.length; i++) {
semOptions += `<option value='${res.data[i].fexamno}'>${res.data[i].fexamno} - ${res.data[i].fexamname}</option>`;
}
$("#semoptions").html(semOptions);
},
});
}
function loadsubjectattend() {
var degree = $("#degoptions").val();
var sem = $("#semoptions").val();
$.ajax({
type: "GET",
data: "°ree=" + degree + "&sem=" + sem,
url: $host_url + "loadssubcreateclass",
success: function (response) {
var res = JSON.parse(response);
console.log(res.data.sub[0].fsubcode);
var suboptions = "<option value=''>---Select Subject---</option>";
for (var i = 0; i < res.data.sub.length; i++) {
suboptions += `<option value='${res.data.sub[i].fsubcode}'>${res.data.sub[i].fsubcode} - ${res.data.sub[i].fsubname}</option>`;
}
var secoptions = "<option value='All'>---All---</option>";
for (var i = 0; i < res.data.sec.length; i++) {
secoptions += `<option value='${res.data.sec[i].fsection}'>${res.data.sec[i].fsection}</option>`;
}
$("#suboptions").html(suboptions);
$("#section").html(secoptions);
},
});
}
function loadteachattend() {
$.ajax({
type: "GET",
url: $host_url + "loadteachercreateclass",
success: function (response) {
var res = JSON.parse(response);
console.log(res.data);
var teachoptions = "<option value=''>---Select Teacher---</option>";
for (var i = 0; i < res.data.length; i++) {
teachoptions += `<option value='${res.data[i].fteachcode}'>${res.data[i].fteachcode} - ${res.data[i].fteachname}</option>`;
}
$("#teachoptions").html(teachoptions);
},
});
}
function viewclassname() {
var degree = $("#degoptions").val();
var sem = $("#semoptions").val();
var sub = $("#suboptions").val();
var classname = $("#classname").val();
var teachcode = $("#teachname").val();
var parameters =
"°ree=" +
degree +
"&sem=" +
sem +
"&sub=" +
sub +
"&classname=" +
classname +
"&teachcode=" +
teachcode;
$.ajax({
type: "GET",
data: parameters,
url: $host_url + "loadclassname",
success: function (response) {
var res = JSON.parse(response);
console.log(res.error_code);
if (res.error_code == 0) {
$("#classname").val(res.data.fclassname);
$("#classname").prop("disabled", true);
} else {
$("#classname").prop("disabled", false);
}
},
});
}
function viewcreateclass() {
var degree = $("#degoptions").val();
var sem = $("#semoptions").val();
var mode = $("#mode").val();
var sub = $("#suboptions").val();
var _classname = $("#classnameoptions").val();
var teachcode = $("#teachname").val();
var section = $("#section").val();
// console.log(_classname);
if (degree == "") {
alert("Select Degree");
$("#degoptions").focus();
return;
}
if (sem == "") {
alert("Select Semester");
$("#semoptions").focus();
return;
}
if (sub == "") {
alert("Select Subject");
$("#sub").focus();
return;
}
if (_classname == "") {
alert("Select Class");
$("#classnameoptions").focus();
return;
}
if (section == "") {
alert("Select Section");
$("#section").focus();
return;
}
var split = _classname.split("-");
var parameters =
"°ree=" +
degree +
"&sem=" +
sem +
"&sub=" +
sub +
"&fclassid=" +
_classname +
"&teachcode=" +
teachcode +
"§ion=" +
section +
"&mode=" +
mode;
$.ajax({
type: "GET",
data: parameters,
url: $host_url + "viewcreateclass",
success: function (response) {
var encode = JSON.parse(response);
var table = `<table align="center" width="100%" cellspacing="0" cellpadding="1" border="1" style="border-radius:5px">
<thead>
<tr>
<th align="left" colspan="7" class="ui-jqgrid-titlebar ui-widget-header ui-corner-tl ui-corner-tr ui-helper"
style="font-size:12px; padding-left:6px; height:24px;">Create Class</th>
</tr>
<tr class="ui-state-default ui-jqgrid-hdiv">
<td align="center" style="width:30px; font-size:12px;
border-left:1px solid #C5DBEC;border-right:1px solid #C5DBEC;
border-bottom:1px solid #C5DBEC;">SLNO.</td>
<td align="center" style="width:85px; font-size:12px;
border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;">USN</td>
<td align="center" style="width:355px; font-size:12px; padding:5px 5px;
border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;">Name</td>
<td align="center" style="width:155px; font-size:12px; padding:5px 5px;
border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;">Action<br/>
<input type="checkbox" onclick="toggle(this);" />
</td>
</tr>
</thead> <tbody>`;
var slno = 1;
var checked = "";
if (encode.error_code == 0) {
for (var i = 0; i < encode.data.length; i++) {
if (encode.data[i].fstatus == "T") {
checked = "checked";
} else {
checked = "";
}
table += `<tr class="ui-widget-content jqgrow">
<td class="tbl_row_new" style="border-left:1px solid #C5DBEC; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;text-align:center;">${slno++}</td>
<td class="tbl_row_new" style="text-align:initial;border-right:1px solid #C5DBEC; padding:2px; font-size:12px;text-align:center;">${
encode.data[i].fregno
}</td>
<td class="tbl_row_new" style="text-align:initial; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;">${
encode.data[i].fname
}</td>
<td id = "present" class="tbl_row_new" style="text-align:center; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;">
<input onclick="changecheckbox('${
encode.data[i].fregno
}')" type="checkbox" ${checked} id="classid_${
encode.data[i].fregno
}" >
<input type="hidden" id="updated_${encode.data[i].fregno}" value="I">
</td>`;
table += `</tr>`;
}
table += `</tbody></table>`;
}
$("#createview").html(table);
},
});
}
function toggle(source) {
var checkboxes = document.querySelectorAll('input[type="checkbox"]');
for (var i = 0; i < checkboxes.length; i++) {
if (checkboxes[i] != source) {
let idvalue = checkboxes[i].id.split("_");
document.getElementById(`updated_${idvalue[1]}`).value = "U";
checkboxes[i].checked = source.checked;
}
}
}
function changecheckbox(fregno) {
let reg = fregno;
document.getElementById(`updated_${reg}`).value = "U";
}
function saveClassCreate() {
var degree = $("#degoptions").val();
var sem = $("#semoptions").val();
var sub = $("#suboptions").val();
var mode = $("#mode").val();
var fclassname = $("#classnameoptions").val();
var teachcode = $("#teachname").val();
// var split = fclassname.split("-");
var section = $("#section").val();
var convertedIntoArray = [];
$("#createview tbody tr").each(function () {
var rowDataArray = {};
var actualData = $(this).find("td");
let i = 0;
if (actualData.length > 0) {
let regno = "";
actualData.each(function () {
if (i == 1) {
regno = $(this).text();
}
if (i == 3) {
if (document.getElementById("updated_" + regno).value == "U") {
if ($(`#classid_${regno}`).is(":checked"))
rowDataArray["classid"] = "T";
else rowDataArray["classid"] = "F";
rowDataArray["regno"] = regno;
convertedIntoArray.push(rowDataArray);
}
}
i++;
});
}
});
var parameters =
"°ree=" +
degree +
"&sem=" +
sem +
"&sub=" +
sub +
"&fclassid=" +
fclassname +
"&teachcode=" +
teachcode +
"&data=" +
JSON.stringify(convertedIntoArray) +
"§ion=" +
section +
"&mode=" +
mode;
$.ajax({
type: "POST",
data: parameters,
url: $host_url + "savecreateclass",
success: function (response) {
var res = JSON.parse(response);
if (res.error_code == 0) {
alert(res.data.msg);
createclassattend();
} else {
alert(res.data.msg);
return;
}
},
});
}
function viewStuds() {
$("#page_main_div").load("../html_modules/viewStuds.html?", function () {
document.getElementById("display_module_name").innerHTML =
"Add Students to Class";
document.getElementById("module_name_for_save").value =
"Add Students to Class";
getDefaultHeadFooterLinks("Add Students to Class");
});
viewStudstab();
}
function viewStudstab() {
$.ajax({
type: "POST",
url: $host_url + "viewStuds",
success: function (response) {
var encode = JSON.parse(response);
var table = `<table align="center" width="100%" cellspacing="0" cellpadding="1" border="1" style="border-radius:5px">
<thead style="position:sticky;top:0">
<tr class="ui-state-default ui-jqgrid-hdiv">
<td align="center" style="width:30px; font-size:12px;
border-left:1px solid #C5DBEC;border-right:1px solid #C5DBEC;
border-bottom:1px solid #C5DBEC;">SLNO.</td>
<td align="center" style="width:300px; font-size:12px;
border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;">Teacher Name</td>
<td align="center" style="width:90px; font-size:12px; padding:5px 5px;
border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;">Class ID</td>
<td align="center" style="width:230px; font-size:12px; padding:5px 5px;
border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;">Class Name<br/>
</td>
<td align="center" style="width:70px; font-size:12px; padding:5px 5px;
border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;">No. of Students<br/>
</td>
</td>
<td align="center" style="width:200px; font-size:12px; padding:5px 5px;
border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;">Action<br/>
</td>
</tr>
</thead> <tbody>`;
var slno = 1;
var checked = "";
if (encode.error_code == 0) {
for (var i = 0; i < encode.data.length; i++) {
if (encode.data[i].fstatus == "T") {
checked = "checked";
} else {
checked = "";
}
table += `<tr class="ui-widget-content jqgrow">
<td class="tbl_row_new" style="border-left:1px solid #C5DBEC; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;text-align:center;">${slno++}</td>
<td class="tbl_row_new" style="text-align:initial;border-right:1px solid #C5DBEC; padding:2px; font-size:12px;text-align:left;">${
encode.data[i].fteachcode
} - ${encode.data[i].fteachname}</td>
<td class="tbl_row_new" style="text-align:initial;text-align:center; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;">${
encode.data[i].fclassid
}</td>
<td id = "present" class="tbl_row_new" style="text-align:left; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;">
${encode.data[i].fclassname}</td>
<td id = "present" class="tbl_row_new" style="text-align:center; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;">
${encode.data[i].count}</td>
<td class="tbl_row_new" style="text-align:initial;text-align:center; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;">
<span
style="
background-color: #008cba;
border: none;
color: white;
padding: 5px 20px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 12px;
cursor: pointer;
"
onclick="viewAddClass('${encode.data[i].fclassid}','${
encode.data[i].fteachcode
}')"
>View</span>
<span
style="
background-color: #008cba;
border: none;
color: white;
padding: 5px 20px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 12px;
cursor: pointer;
"
onclick="getReportClassStud('${encode.data[i].fclassid}','${
encode.data[i].fteachcode
}', '${encode.data[i].fclassname}')"
>Report</span>
</td>`;
table += `</tr>`;
}
table += `</tbody></table>`;
}
$("#cnttab").html(table);
},
});
}
function viewAddClass(fclassid, techcode) {
let parameters = "&fclassid=" + fclassid + "&techcode=" + techcode;
$.ajax({
type: "POST",
data: parameters,
url: $host_url + "viewAddClassstuds",
success: function (response) {
var encode = JSON.parse(response);
if (encode.error_code == 0) {
$("#cnttab").hide();
var table = `<table align="center" width="100%" cellspacing="0" cellpadding="1" border="1" style="border-radius:5px">
<thead>
<tr class="ui-state-default ui-jqgrid-hdiv">
<td align="center" style="width:30px; font-size:12px;
border-left:1px solid #C5DBEC;border-right:1px solid #C5DBEC;
border-bottom:1px solid #C5DBEC;">SLNO.</td>
<td align="center" style="width:120px; font-size:12px;
border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;">Class ID</td>
<td align="center" style="width:90px; font-size:12px; padding:5px 5px;
border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;">Reg No.</td>
<td align="center" style="width:330px; font-size:12px; padding:5px 5px;
border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;">Student Name<br/>
</td>
</tr>
</thead> <tbody>`;
var slno = 1;
var checked = "";
for (var i = 0; i < encode.data.length; i++) {
table += `<tr class="ui-widget-content jqgrow">
<td class="tbl_row_new" style="border-left:1px solid #C5DBEC; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;text-align:center;">${slno++}</td>
<td class="tbl_row_new" style="text-align:initial;text-align:center;border-right:1px solid #C5DBEC; padding:2px; font-size:12px;">${
encode.data[i].fclassid
}</td>
<td class="tbl_row_new" style="text-align:initial;text-align:center; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;">${
encode.data[i].fregno
}</td>
<td id = "present" class="tbl_row_new" style="text-align:left; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;">
${encode.data[i].fname}</td>`;
table += `</tr>`;
}
table += `</tbody></table>`;
$("#detailtab").html(table);
}
},
});
}
function getReportClassStud(classId, teachCode, className) {
parameters =
"&classid=" +
classId +
"&teachcode=" +
teachCode +
"&classname=" +
className;
window.open($host_url + "getReportClassStud" + parameters);
}
|