0xV3NOMx
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.118.28.31


Current Path : /var/www/oasis/js/
Upload File :
Current File : /var/www/oasis/js/copomaxmarksentry.js

var qpcnt;
var tablecnt;
var qno;

function loadcopomaxmarks() {
  // console.log('hi');
  $("#page_main_div").load("../html_modules/copomaxmarks.html", function () {
    document.getElementById("display_module_name").innerHTML =
      "CO PO Mark Entry Subjectwise";
    document.getElementById("module_name_for_save").value =
      "CO PO Mark Entry Subjectwise";
    getDefaultHeadFooterLinks("CO PO Mark Entry Subjectwise");
  });
  loadmarksdegree();
}

function loadmarksdegree() {
  var element = document.getElementById("element").value;

  $.ajax({
    type: "GET",
    url: $host_url + "loadmarksdeg",
    data: "element=" + element,
    success: function (response) {
      var res = JSON.parse(response);
      console.log(res);
      var marksdegree = `<option value = "">----Select----</option>`;
      for (var i = 0; i < res.data.length; i++) {
        marksdegree += `<option value = ${res.data[i].fdegree}>${res.data[i].fdegree} - ${res.data[i].fdescpn}</option>`;
      }
      $("#marksdegree").html(marksdegree);
    },
  });
}

function loadmarksexamno() {
  var deg = document.getElementById("marksdegree").value;

  $.ajax({
    type: "GET",
    data: "degree=" + deg,
    url: $host_url + "loadmarksexamno",
    success: function (response) {
      var res = JSON.parse(response);
      //   console.log(res);
      //   return;
      var examno = `<option value = "">----Select----</option>`;
      for (var i = 0; i < res.data.length; i++) {
        examno += `<option value = ${res.data[i].fexamno}>${res.data[i].fexamname}</option>`;
      }
      $("#marksexamno").html(examno);
    },
  });
}

function loadmarksqpcode() {
  var deg = document.getElementById("marksdegree").value;
  var examno = document.getElementById("marksexamno").value;
  var element = document.getElementById("element").value;

  $.ajax({
    type: "GET",
    data: "degree=" + deg + "&examno=" + examno + "&element=" + element,
    url: $host_url + "loadmarksqpcode",
    success: function (response) {
      var res = JSON.parse(response);
      var qpcode = `<option value = "">----Select----</option>`;
      for (var i = 0; i < res.data.length; i++) {
        qpcode += `<option value = ${res.data[i].fqpcode}>${res.data[i].fqpcode}-${res.data[i].fsubname}</option>`;
      }
      $("#marksqpcode").html(qpcode);
    },
  });
}

function viewMarksEntryTab() {
  var deg = document.getElementById("marksdegree").value;
  var examno = document.getElementById("marksexamno").value;
  var qpcode = document.getElementById("marksqpcode").value;

  if (deg == "") {
    alert("Select Degree");
    return;
  }

  if (examno == "") {
    alert("Select Semister");
    return;
  }

  if (qpcode == "") {
    alert("Select Subject");
    return;
  }

  $.ajax({
    type: "GET",
    data: "degree=" + deg + "&examno=" + examno + "&qpcode=" + qpcode,
    url: $host_url + "viewmarksentry",
    success: function (response) {
      var res = JSON.parse(response);
      $("#marksentrytab").html(res.data["tabledata"]);
      qpcnt = res.data["qpcnt"];
      tablecnt = res.data["tablecnt"];
      qno = res.data["qno"];
    },
  });
}

function SaveCopoMarkEntry() {
  var slno = 1;
  var maxmarks = "";
  var finarr = [];

  var deg = document.getElementById("marksdegree").value;
  var examno = document.getElementById("marksexamno").value;
  var qpcode = document.getElementById("marksqpcode").value;

  if (deg == "") {
    alert("Select Degree");
    return;
  }

  if (examno == "") {
    alert("Select Semister");
    return;
  }

  if (qpcode == "") {
    alert("Select Subject");
    return;
  }

  for (var z = 0; z <= tablecnt; z++) {
    let regno = $(`#${slno}hregno`).val();
    let totmarks = $(`#${slno}totmarks`).html();
    let upd = $(`#${slno}hcregno`).val();
    let arr = [];

    if (upd == "U") {
      for (var i = 0; i < qpcnt; i++) {
        let arr1 = {};
        maxmarks = $(`#${slno}_qp_${i}`).val();
        qp = $(`#${slno}_hqp_${i}`).val();

        arr1["maxmarks"] = maxmarks;
        arr1["qp"] = qp;
        arr1["regno"] = regno;
        arr1["totmarks"] = totmarks;
        arr.push(arr1);
      }
      finarr.push(arr);
    }
    slno++;
  }
  $.ajax({
    type: "POST",
    url: $host_url + "SaveCopoMarkEntry",
    data:
      `&deg=` +
      deg +
      `&examno=` +
      examno +
      `&qpcode=` +
      qpcode +
      `&submarks=` +
      JSON.stringify(finarr),
    success: SaveCopoMarkEntrySuccess,
  });
}

function SaveCopoMarkEntrySuccess(response) {
  var res = JSON.parse(response);
  alert(res.data);
  loadcopomaxmarks();
}

function getregupd(x) {
  let idval = x.id;
  let myArray = idval.split("_");
  $(`#${myArray[0]}hcregno`).val("U");
}

function valmaxmarks(valmax) {
  let idval = valmax.id;
  let value = valmax.value;
  let myArray = idval.split("_");

  $(`#${myArray[0]}hcregno`).val("U");

  if (parseInt(value) > parseInt($(`#${myArray[2]}qnmax`).val())) {
    alert("Please Enter Valid Marks");
    $(`#${idval}`).val("");
    document.getElementById(`${idval}`).focus();
    return;
  }

  let totqp = $(`#${myArray[0]}totqp`).val();
  let totmarks = 0;
  for (let i = 0; i < totqp; i++) {
    if (
      $(`#${myArray[0]}_qp_${i}`).val() != "" &&
      $(`#${myArray[0]}_qp_${i}`).val() != "-1"
    )
      totmarks =
        parseInt(totmarks) + parseInt($(`#${myArray[0]}_qp_${i}`).val());
  }

  $(`#${myArray[0]}totmarks`).html(totmarks);
}