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.85.111
function loadExamCntr() {
$('#loadtab').load('html_modules/examCntr.html?v=' + version, () => {
$("#loadColleges").hide();
loadUnivs('univname');
});
}
var examCntlist;
function displayCentres() {
var univcode = $("#univname").val();
var deggrp = $("#deggrp").val();
var parameters = "&univcode=" + univcode + "°grp=" + deggrp;
$.blockUI({ message: "<img src='images/Loading_icon.gif' border='0'>" });
$.ajax({
type: 'GET',
url: $host_url + 'getCentresForUpdation' + parameters,
success: function (response) {
$.unblockUI();
console.log(response);
if (response.error_code == 0) {
const { examcntr } = response.data;
examCntlist = examcntr;
const rgExamcntr = examcntr.map((el, i) => {
return (`
<tr>
<td>
${ i + 1}
</td>
<td class="fcollcode">
${ el.fcollcode}
</td>
<td>
${ el.fcollname}
</td>
<td>
<input type="text" name="fexamcodet" class="form-control"
value="${ el.fexamcodet}" id="${i}_fexamcodet"
onkeypress="return acceptNumbersOnlyForModule(event);"
onchange="validateCollcode( this );" maxlength = "4" />
</td>
<td>
<input type="text" name="fexamcodep" class="form-control"
value="${ el.fexamcodep}" id="${i}_fexamcodep"
onkeypress="return acceptNumbersOnlyForModule(event);"
onchange="validateCollcode( this );" maxlength = "4" />
</td>
</tr>
`);
});
$("#exmcntrbody").html(rgExamcntr);
$("#loadColleges").show();
}
}
});
}
function validateCollcode(el) {
let val = $(el).val();
if (val == '' || val.length < 4) {
alert("Infromation Should be entered")
$(el).focus();
return false;
}
let coll = examCntlist.filter((el, i) => {
if (el.fcollcode == val)
return el;
});
if (coll.length == 0) {
alert("invalid college code");
$(el).focus();
return false;
}
return true;
}
function saveCentres() {
const trs = $("#exmcntrbody > tr");
var reqArr = [];
var nofound = [];
const values = trs.map((i, el) => {
let item = {};
let collcode = $.trim($(el).find("td.fcollcode").html());
item.fcollcode = collcode;
let examcodet = $(el).find("td > input[name=fexamcodet]").val();
item.fexamcodet = examcodet;
let examcodep = $(el).find("td > input[name=fexamcodep]").val();
item.fexamcodep = examcodep;
let validt = examCntlist.filter((el1) => {
return el1.fcollcode === examcodet;
})
let validp = examCntlist.filter((el1) => {
return el1.fcollcode === examcodep;
})
if (validt.length == 0 || validp.length == 0)
nofound.push(collcode);
reqArr = [...reqArr, item];
return item;
});
console.log(nofound);
if (nofound.length !== 0) {
alert("Invalid Centre codes for colleges" + nofound.toString());
return;
}
const data = {
cntrlist: reqArr
};
var univcode = $("#univname").val();
var deggrp = $("#deggrp").val();
var parameters = "&univcode=" + univcode + "°grp=" + deggrp;
$.ajax({
type: 'POST',
url: $host_url + 'saveUpdatedCentres' + parameters,
dataType: 'json',
contentType: "application/json; charset=utf-8",
data: JSON.stringify(data),
success: function (response) {
$.unblockUI();
console.log(response);
if (response.error_code == 0) {
alert(response.data.msg);
displayCentres()
} else if (response.error_code == -1) {
alert(response.data.msg);
}
}
});
}
|