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 : 3.15.15.91


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

let totsubnew = '';
function subjectReg() {
  $("#page_main_div").load("../html_modules/subjReg.html", function () {
    getDefaultHeadFooterLinks("Subject Registration");
    getDegree();
  });
}

function getDegree() {
  $.ajax({
    type: "POST",
    url: $host_url + "getDegreeDetails",
    success: getDegreeDetailsSuccess,
  });
}

function getDegreeDetailsSuccess($responce) {
  $responce = eval("(" + $responce + ")");

  document.getElementById("degree").options.length = 0;
  var deg = $responce.data["degree"];

  $op = new Option("--Select--", "");
  document.getElementById("degree").options.add($op);
  for ($i = 0; $i < deg.length; $i++) {
    $op = new Option(deg[$i]["VALUE"], deg[$i]["internal_code"]);
    $op.id = deg[$i]["internal_code"];
    document.getElementById("degree").options.add($op);
  }
}

function getExamNo() {
  var degree = $("#degree").val();

  $.ajax({
    type: "POST",
    url: $host_url + "getExamNoDet",
    data: "&degree=" + degree,
    success: getExamNoSuccess,
  });
}

function getExamNoSuccess($responce) {
  $responce = eval("(" + $responce + ")");
  document.getElementById("degexam").options.length = 0;
  document.getElementById("section").options.length = 0;
  var deg = $responce.data["degexam"];
  var section = $responce.data["section"];
  //console.log(deg);
  $op = new Option("--Select--", "");
  document.getElementById("degexam").options.add($op);
  for ($i = 0; $i < deg.length; $i++) {
    $op = new Option(deg[$i]["VALUE"], deg[$i]["internal_code"]);
    $op.id = deg[$i]["internal_code"];
    document.getElementById("degexam").options.add($op);
  }

  $op = new Option("All", "All");
  document.getElementById("section").options.add($op);
  for ($i = 0; $i < section.length; $i++) {
    $op = new Option(section[$i]["VALUE"], section[$i]["internal_code"]);
    $op.id = section[$i]["internal_code"];
    document.getElementById("section").options.add($op);
  }
}

function displaySubjList() {
  var degree = document.getElementById("degree").value;
  var degexam = document.getElementById("degexam").value;
  var section = document.getElementById("section").value;

  if (degree == "") {
    alert("Please select Degree");
    return;
  }

  if (degexam == "") {
    alert("Please select Semister");
    return;
  }

  $.ajax({
    type: "POST",
    url: $host_url + "displaySubjList",
    data: "&degree=" + degree + "&degexam=" + degexam + "&section=" + section,
    success: displaySubjListSuccess,
  });
}

function displaySubjListSuccess($responce) {
  $responce = eval("(" + $responce + ")");
  $("#btc_default_reg_div").html("");
  $("#btc_default_reg_div").html($responce.data["tabledata"]);
  let mandsub = $responce.data["mandsub"];
  let totsub = $responce.data["totsub"];
  totsubnew = $responce.data["totsub"];
  mandsub.forEach((element) => {
    let subarry = element["subcode"];
    let subcodes = "";
    if (subarry != null) subcodes = subarry.split(",");
    let z = 0;
    for (let i = 1; i <= element["ftotsub"]; i++) {
      if (i > subcodes.length) {
      } else {
        let subcode = subcodes[z].split("-");
        $(`#${element["FREGNO"]}_${i}`).val(subcode[0]);
        $(`#o_${element["FREGNO"]}_${i}`).val(subcode[0]);
        if (subcode[1] == "F")
          document.getElementById(`${element["FREGNO"]}_${i}`).disabled = false;
        else
          document.getElementById(`${element["FREGNO"]}_${i}`).disabled = true;
      }
      z++;
    }
  });
}

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 saveSubRegData() {
  var degree = document.getElementById("degree").value;
  var degexam = document.getElementById("degexam").value;

  if (degree == "") {
    alert("Please select Degree");
    return;
  }

  if (degexam == "") {
    alert("Please select Semister");
    return;
  }

  let subarry = [];
  $("#showteachsub input[type=hidden]").each(function () {
    let id = $(this).attr("id");
 
    if ($(`#${id}`).val() == "U") {
      let sucodeid = $(this).attr("id").split("_");
      
      
     
      for(let i=1;i<=totsubnew;i++)
      {
        let sublen = {};
        sublen["regno"] = sucodeid[1];
        sublen["subcode"] = $(`#${sucodeid[1]}_${i}`).val();
        sublen["osubcode"] = '';
        subarry.push(sublen);
      }

      
      //sublen["osubcode"] = $(`#o_${sucodeid[1]}_${sucodeid[2]}`).val();
      //console.log(sublen);
      //subarry.push(sublen);
    }
  });

  $.ajax({
    type: "POST",
    url: $host_url + "saveSubRegData",
    data:
      `&degree=` +
      degree +
      `&degexam=` +
      degexam +
      `&subarry=` +
      JSON.stringify(subarry),
    success: saveStudSubIdentSuccess,
  });
}

function saveStudSubIdentSuccess($responce) {
  $responce = eval("(" + $responce + ")");
  alert($responce.data);
  callStudSubIdent();
  $("#btc_default_reg_div").html("");
  return;
}

function getupdate(id) {
  $(`#h_${id}`).val("U");
}

function gentReportSubj() {
  let degree = $("#degree").val();
  let degexam = $("#degexam").val();
  let section = $("#section").val();
  window.open(
    $host_url +
      "gentReportSubj&degree=" +
      degree +
      "&degexam=" +
      degexam +
      "&section=" +
      section
  );
}

function freezREgSub() {
  var degree = document.getElementById("degree").value;
  var degexam = document.getElementById("degexam").value;

  if (degree == "") {
    alert("Please select Degree");
    return;
  }

  if (degexam == "") {
    alert("Please select Semister");
    return;
  }

  let text = "Are you Sure You Want to Freeze?";
  if (confirm(text) == true) {
    $.ajax({
      type: "POST",
      url: $host_url + "freezSubRegData",
      data: `&degree=` + degree + `&degexam=` + degexam,
      success: freezSubRegDataSuccess,
    });
  } else {
  }
}

function freezSubRegDataSuccess($responce) {
  $responce = eval("(" + $responce + ")");
  alert($responce.data);
}