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


Current Path : /proc/thread-self/root/var/www/html/reva/js/
Upload File :
Current File : //proc/thread-self/root/var/www/html/reva/js/uploadcopo.js

function callUploadCopo() {
  $("#page_main_div").load("html_modules/uploadcopo.html", function () {
    document.getElementById("display_module_name").innerHTML = "Upload COPO";
    document.getElementById("module_name_for_save").value = "Upload COPO";
    getDefaultHeadFooterLinks("Upload COPO");
  });
}

const getDegree = () => {
  const element = $("#element").val();
  $.ajax({
    type: "GET",
    url: $host_url + "getElementWiseDegree",
    data: "element=" + element,
    success: function (res) {
      let response = JSON.parse(res);
      if (response.error_code === 0) {
        let degOpt = "<option>---select---</option>";
        for (var i = 0; i < response.data.length; i++) {
          degOpt += `<option value='${response.data[i].fdegree}'>${response.data[i].fdescpn}</option>`;
        }
        $("#degree").html(degOpt);
      }
    },
  });
};

const getDegreeWiseExamno = () => {
  const element = $("#element").val();
  const degree = $("#degree").val();
  $.ajax({
    type: "GET",
    url: $host_url + "getDegreeWiseExamno",
    data: "element=" + element + "&degree=" + degree,
    success: function (res) {
      let response = JSON.parse(res);
      if (response.error_code === 0) {
        let examno = "<option>---select---</option>";
        for (var i = 0; i < response.data.length; i++) {
          examno += `<option value='${response.data[i].fexamno}'>${response.data[i].fexamname}</option>`;
        }
        $("#examno").html(examno);
      }
    },
  });
};

const getDegreeExamWiseSubject = () => {
  const element = $("#element").val();
  const degree = $("#degree").val();
  const examno = $("#examno").val();
  $.ajax({
    type: "GET",
    url: $host_url + "getDegreeExamWiseSubject",
    data: "element=" + element + "&degree=" + degree + "&examno=" + examno,
    success: function (res) {
      let response = JSON.parse(res);
      if (response.error_code === 0) {
        let subject = "<option>---select---</option>";
        for (var i = 0; i < response.data.length; i++) {
          subject += `<option value='${response.data[i].fqpcode}'>${response.data[i].fsubname}</option>`;
        }
        $("#qpcode").html(subject);
      }
    },
  });
};

function uploadCopoFile() {
  var element = $("#element").val();
  var degree = $("#degree").val();
  var examno = $("#examno").val();
  var subject = $("#qpcode").val();
  var file = document.getElementById("copo_file").files[0];

  console.log(element, degree, examno, subject, file);

  if (
    element === "" ||
    degree === "---select---" ||
    examno === "---select---" ||
    subject === "---select---" ||
    file === undefined
  ) {
    alert("All the fields are mandatory");
    return;
  }

  var form_Data = new FormData();
  form_Data.append("element", element);
  form_Data.append("degree", degree);
  form_Data.append("examno", examno);
  form_Data.append("subject", subject);
  form_Data.append("file", file);

  var xhr = new XMLHttpRequest();
  xhr.open("POST", $host_url + "uploadcopodoc", true);

  xhr.send(form_Data);
  xhr.onload = function () {
    let res = JSON.parse(xhr.response);
    if (res.error_code === 0) {
      alert(res.data);
    } else {
      alert(res.data);
      return;
    }
  };
}