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


Current Path : /var/www/html/pget/js/pg/
Upload File :
Current File : //var/www/html/pget/js/pg/admpg.js

var db = window.location.pathname.split("/")[2];

if (db == "rcub-admin") db = "rcub";
if (db == "dud-admin") db = "dud";

if (location.protocol != "https:") {
  var protocol = "http://";
} else {
  var protocol = "https://";
}

var $host_url =
  protocol +
  window.location.host +
  "/" +
  window.location.pathname.split("/")[1] +
  "/app.php?db=" +
  db +
  "&a=";

var $host_url1 =
  protocol +
  window.location.host +
  "/" +
  window.location.pathname.split("/")[1] +
  "/";

var $host_url2 =
  protocol +
  window.location.host +
  "/" +
  window.location.pathname.split("/")[1] +
  "/";
var $photo_url = "https://admission-certificates.s3.ap-south-1.amazonaws.com/";
var deg;

var gAppNo;

var fappno = "";

var photo_path = "";
var photo_filename;
var sign_filename;

function inArray(needle, haystack) {
  var length = haystack.length;
  for (var i = 0; i < length; i++) {
    if (haystack[i] == needle) return true;
  }
  return false;
}

function in_array(needle, haystack) {
  var length = haystack.length;
  for (var i = 0; i < length; i++) {
    if (haystack[i] == needle) return true;
  }
  return false;
}

var months = "";
function homeLink() {
  var r = confirm("Do You Want To Logout!");
  if (r == true) {
    window.location.href = "index.html";
  } else {
  }
}

function login1() {
  $.ajax({
    type: "POST",
    async: true,
    url: "../pgetadm/login.php",
    success: isLoggedInResponce,
  });
  function isLoggedInResponce($responce) {
    $responce = eval("(" + $responce + ")");
    if ($responce.error_code == 1) {
      alert("User not logged in");
      window.location.href = "pgindex.html";
    }
  }
}

function entApplication() {
  $("#loadTab").load("ent-application.html", function () {
    $("#statusDetl").addClass("hidden");
    var $demoMaskedInput = $(".daterange");
    //Date
    $demoMaskedInput
      .find(".date")
      .inputmask("dd/mm/yyyy", { placeholder: "__/__/____" });
    Dropzone.discover();

    loadPGAdm();
  });
}

var combcode = [];
var combsubject = [];
var optdegarry = [];
var lansub = [];
var nolan = [];
const loadPGAdm = () => {
  // $("#prevPGDet").hide();
  login1();
  $("#success_card").hide();
  $("#fbcuetype").hide();
  console.log($host_url);
  $.ajax({
    type: "POST",
    async: false,
    url: $host_url + "getFacultyDegree",
    success: (response) => {
      var { error_code, data, status } = JSON.parse(response);
      console.log(error_code);
      if (error_code == 0) {
        var fmobileno = data.fmobileno;
        combcode = data.combcode;
        combsubject = data.combsubs;
        nolan = data.nolan;
        // console.log(combcode,combsubject);
        $("#fmobileno").val(fmobileno);
        $("#fmobileno").prop("disabled", "disabled");
        var options;
        console.log(data.fappno);
        fappno = data.fappno;
        deg = data.degree;
        options += `<option value="">--Select--</option>`;
        deg.map((el, i) => {
          options += `<option value="${deg[i]["int_code"]}">${deg[i]["int_code"]} - ${deg[i]["val"]}</options>`;
        });
        $("#fdegree").html(options);
        var options = "";
        lanres = data.lanres;
        lansub = data.lanres;
        // options += `<option value="">--Select--</option>`;
        // lanres.map((el, i) => {
        //   options += `<option value="${lanres[i]["int_code"]}">${
        //     lanres[i]["val"]
        //   }</options>`;
        // });
        // $("#flang1").html(options);
        // $("#flang2").html(options);

        loadlansubjects();
        var options = "";
        prefdocvrfloc = data.prefdocvrfloc;
        options += `<option value="">--Select--</option>`;
        prefdocvrfloc.map((el, i) => {
          options += `<option value="${prefdocvrfloc[i]["fcollcode"]}">${prefdocvrfloc[i]["fcollname"]}</options>`;
        });
        $("#fdocloc").html(options);

        var year = "";
        var d = new Date();
        var n = d.getFullYear();
        for (var j = n; j > 1980; j--) {
          year += "<option value='" + j + "'>" + j + "</option>";
        }
        $("#fqyear").append(year);
        $("#fpgyear").append(year);

        var monthNames = [
          "January",
          "February",
          "March",
          "April",
          "May",
          "June",
          "July",
          "August",
          "September",
          "October",
          "November",
          "December",
        ];
        var months = monthNames
          .map((month) => {
            return "<option>" + month + "</option>";
          })
          .join("");
        $("#fqmonth").html(months);
        $("#fpgmonth").html(months);
        $.ajax({
          type: "GET",
          async: false,
          url: $host_url + "getCategory",
          success: (response) => {
            var { error_code, data, status } = JSON.parse(response);
            console.log(data);
            var options;

            if (error_code == 0) {
              cat = data.category;
              options += `<option value="">--Select--</option>`;
              cat.map((el, i) => {
                options += `<option value="${cat[i]["fcategory"]}">${cat[i]["fcategory"]}</options>`;
              });
            }
            $("#studphoto").hide();
            if (error_code == -1) {
              options += `<option>---Select---</option>
              <option value="">No Category Found</option>`;
            }
            $("#fcategory").html(options);
          },
        });
        if (data.fappno != "") loadSavedData(data.fappno);
      }
      if (error_code == "-2") {
        alert(data.msg);
        window.location.href = window.location.href;
        return;
      }
      if (error_code == -1) {
        alert("Something went wrong, Please Try after sometime.");
      }
    },
  });
};

function changePhoto() {
  $("#frmFileUpload").show();
  $("#studphoto").hide();
}

// function validateregno() {
//   var usn = $("#qulregno").val();
//   var yes = $("#vskub_1").is(":checked");
//   // console.log(yes);
//   if ($("#vskub_1").is(":checked")) {
//     // console.log('yes');
//     document.getElementById("fdegree").disabled = true;
//     document.getElementById("fcombcode").disabled = true;
//     document.getElementById("qulcollname").disabled = true;
//     document.getElementById("idUnvExam").disabled = true;
//     document.getElementById("fqclass").disabled = true;
//     document.getElementById("fqsecmarks").disabled = true;
//     document.getElementById("fqmaxmarks").disabled = true;
//     document.getElementById("fqpercentage").disabled = true;
//     document.getElementById("resStat").disabled = true;
//     // document.getElementById("flang1").disabled = true;
//     // document.getElementById("flang2").disabled = true;
//     // document.getElementById("flang1mm").disabled = true;
//     // document.getElementById("flang2mm").disabled = true;
//     // document.getElementById("flang1ms").disabled = true;
//     // document.getElementById("flang2ms").disabled = true;
//     // document.getElementById("flangttlms").disabled = true;
//     document.getElementById("qalsemdet").disabled = true;
//   } else if ($("#vskub_2").is(":checked")) {
//     document.getElementById("qulregno").disabled = false;
//     document.getElementById("fdegree").disabled = false;
//     document.getElementById("fcombcode").disabled = false;
//     document.getElementById("qulcollname").disabled = false;
//     document.getElementById("idUnvExam").disabled = false;
//     document.getElementById("fqclass").disabled = false;
//     document.getElementById("fqsecmarks").disabled = false;
//     document.getElementById("fqmaxmarks").disabled = false;
//     document.getElementById("resStat").disabled = false;
//     // document.getElementById("flang1").disabled = false;
//     // document.getElementById("flang2").disabled = false;
//     // document.getElementById("flang1mm").disabled = false;
//     // document.getElementById("flang2mm").disabled = false;
//     // document.getElementById("flang1ms").disabled = false;
//     // document.getElementById("flang2ms").disabled = false;
//     document.getElementById("qalsemdet").disabled = false;
//   }

//   if ($("#qulregno").val() != "" && $("#vskub_2").is(":checked") == false) {
//     $.ajax({
//       type: "POST",
//       url: $host_url + "validateregno",
//       data: "&usn=" + usn,
//       async: false,
//       success: function(response) {
//         var { error_code, data, status } = JSON.parse(response);
//         console.log(data);
//         if (!data.msg) {
//           var vkuprevdata = data.vkuprevdata[0];
//           console.log(vkuprevdata);
//           $("#fdegree").val(vkuprevdata.fdegree);
//           $("#fcombcode").val(vkuprevdata.fcombcode);
//           $("#qulcollname").val(vkuprevdata.fcollname);
//           $("#idUnvExam").val("VSKUB");
//           $("#fqclass").val(vkuprevdata.fclass);
//           $("#fqmaxmarks").val(vkuprevdata.ftotmax);
//           $("#fqsecmarks").val(vkuprevdata.ftotsec);
//           getPrevPercent();
//           if (vkuprevdata.fexamno == "C") {
//             $("#subsem3mm_1").val(vkuprevdata.ftotmax);
//             $("#subsem3mo_1").val(vkuprevdata.ftotsec);
//             gettoal("1");
//           }

//           // for(var i=0;i<=data.vkuprevdata;i++){

//           // }

//           // $("#fdegree").val() = vkuprevdata.fdescpn;
//           // $("#fdegree").val() = vkuprevdata.fdescpn;
//           // $("#fdegree").val() = vkuprevdata.fdescpn;
//           // $("#fdegree").val() = vkuprevdata.fdescpn;
//           // $("#fdegree").val() = vkuprevdata.fdescpn;
//         } else {
//           $("#fdegree").val("");
//           $("#fcombcode").val("");
//           $("#qulcollname").val("");
//           $("#idUnvExam").val("");
//           $("#fqclass").val("");
//           // $("#fqmaxmarks").val('');
//           // $("#fqsecmarks").val('');
//           alert("No data Found");
//         }
//       }
//     });
//   } else {
//     // $("#fdegree").val('') ;
//     //   $("#fcombcode").val('' );
//     //   $("#qulcollname").val('');
//     //   $("#idUnvExam").val("");
//     //   $("#fqclass").val('');
//     // $("#fqmaxmarks").val('');
//     // $("#fqsecmarks").val('');
//     // $("#fqpercentage").val('');
//   }
// }

var courseFee = 1;
//=============  Load Degrees To Course Preference Details ==============//
var selectedOpt = new Array();
var count = 0;
const loadfilteredDeg = (val) => {
  var value = val.value;
  var cat = $("#fcategory").val();
  var degree = $("#fdegree1").val();
  if (cat != "" && degree != "") {
    getFeestr();
  }

  if (!in_array(value, selectedOpt)) {
    if (val.selectedIndex <= 0) {
      count--;
      getFeestr();
    } else {
      selectedOpt.push(value);
      count++;
    }
  } else {
    alert("course already selected.");
    val.value = "";
    return;
  }
  console.log("cnt", count);
};

// var checkedValue = [];
//   $(function () {
//         $("#optdeg input[type=checkbox]").bind('click', function () {
//           if ($(this).is(':checked')) {
//               checkedValue.push($(this).val());
//               console.log(checkedValue);
//           }
//           else {
//               if ((index = checkedValue.indexOf($(this).val())) !== -1) {
//                   checkedValue.splice(index, 1);
//                   console.log(checkedValue);
//               }
//           }
//       });
//   });
//================= Load Fee Structure ================//
var arrlengthofdeg = "";
var totalFee = 0;
const getFeestr = (arrlength) => {
  var cat = $("#fcategory").val();
  var degree = $("#fdegree1").val();

  var value = $('input[name="fgender"]:checked').val();
  if (value == "T") cat = "SC";
  var karstudy = $('input[name="fkarstudy"]:checked').val();
  if (karstudy == "No") cat = "GM";
  if (cat != "" && degree != "") {
    $.ajax({
      type: "POST",
      url: $host_url + "getFees",
      data: "&fcatcode=" + cat + "&fdegree=" + degree,
      success: (response) => {
        var { error_code, data, status } = JSON.parse(response);
        var table = ``;
        // console.log(data);
        var feeData = data.feestr;
        if (error_code == 0) {
          courseFee = 1;
          // if ($("#fdegree1").val() != "") courseFee = courseFee + 1;
          totalFee = 0;
          if ($("#fdegree2").val() != "") courseFee = courseFee + 1;

          if ($("#fdegree3").val() != "") courseFee = courseFee + 1;

          if ($("#fdegree4").val() != "") courseFee = courseFee + 1;

          if ($("#fdegree5").val() != "") courseFee = courseFee + 1;

          if ($("#fdegree6").val() != "") courseFee = courseFee + 1;

          table = `
          <table class="table table-bordered table-hover" id='mainTable'>
          <thead style = 'height:40px;background-color: #184F76 !important;color: #fff;'>
            <tr>
              <th>    SL. No.   </th>
              <th>    Head Code   </th>
              <th>    Fee   </th>
            </tr>
          </thead>`;
          feeData.map((el, i) => {
            if (el.fheadcode == "01 ADDITIONAL COURSE FEE") {
              if (courseFee > 1) {
                table += `<tr class="tblRow" id="tblid">
              <td> ${i + 1} </td>
              <td id="fheadcode${i}"> ${el.fheadcode} </td>
              <td id="fmaxfee${i}"> ${el.fmaxfee * (courseFee - 1)} </td>
            </tr>`;
                totalFee += el.fmaxfee * (courseFee - 1);
              }
            } else {
              let addsubfee = 0;
              //let finefee = 0;
              console.log(data.feestr[0].fmaxfee);

              var db = window.location.pathname.split("/")[2];

              if (db == "dud" && el.fheadcode == "01 Entrance Test Fee") {
              } else {
                let appfee = data.feestr[0].fmaxfee * arrlength;
                data.feestr[0].fmaxfee = appfee;
              }

              var db = window.location.pathname.split("/")[2];

              if (db == "rcub") {
                // console.log("el.fheadcode: ", el.fheadcode);
                // console.log("data.feestr[1].fmaxfee ", data.feestr[1].fmaxfee);
                if (el.fheadcode == "02 Fine") {
                  let finefee =
                    Number(data.feestr[1].fmaxfee) * Number(arrlength);
                  data.feestr[1].fmaxfee = finefee;
                  console.log(finefee);
                  console.log(Number(arrlength));
                }
              }

              var db = window.location.pathname.split("/")[2];
              if (db == "dud") {
                console.log(arrlength);

                if (arrlength > 1) {
                  if (el.fheadcode == "02 Application Fee") {
                    console.log(el.fheadcode);
                    addsubfee =
                      Number(data.feestr[1].fmaxfee) +
                      Number(data.feestr[1].frepfee) * (Number(arrlength) - 1);
                    data.feestr[1].fmaxfee = addsubfee;
                  } else {
                    console.log(el.fmaxfee);
                    //  addsubfee = Number(data.feestr[1].fmaxfee);
                  }
                }
              }

              table += `<tr class="tblRow" id="tblid">
                <td> ${i + 1} </td>
                <td id="fheadcode${i}"> ${el.fheadcode} </td>
                <td id="fmaxfee${i}"> ${el.fmaxfee} </td>
                </tr>`;
              // getFeestr();
              arrlengthofdeg = arrlength;
              totalFee += Number(el.fmaxfee);
              // totalFee = totalFee * arrlength;
            }
          });

          table += `
        <tr>
          <td colspan="2" class="text-left">Total</td>
          <td id="ttlAmt" >${totalFee}</td>
        </tr>
        </table>`;
        }
        if (error_code == -1) {
          table = `<p>No Fee Sturcture found for the above selected Category and Preference 1.<p>`;
        }
        $("#FeeTbl").html(table);
      },
    });
  }
};

totfeeupdate = () => {
  var chkboxes = $("#optdeg input[type=checkbox]");
  var vals = "";
  var feearr = [];
  console.log(chkboxes.length);

  for (var i = 0, n = chkboxes.length; i < n; i++) {
    if (chkboxes[i].checked) {
      item = {};

      item["id"] = chkboxes[i].id;
      item["value"] = "Yes";
      feearr.push(item);
    } else {
    }
  }
  getFeestr(feearr.length);
  // totalFee = totalFee * feearr.length;
  // console.log(feearr);
  // console.log("ttt", totalFee);
  // $("#ttlAmt").html(totalFee);
};
const autoFillAddr = (obj) => {
  if ($(obj).is(":checked")) {
    $("#fcurradd1").val($("#fpermadd1").val());
    $("#fcurradd2").val($("#fpermadd2").val());
    $("#fcurradd3").val($("#fpermadd3").val());
    $("#fcurrdist").val($("#fpermdist").val());
    $("#fcurrpin").val($("#fpermpin").val());
    $("#fcurrstate").val($("#fpermstate").val());
  } else {
    $("#fcurradd1").val("");
    $("#fcurradd2").val("");
    $("#fcurradd3").val("");
    $("#fcurrdist").val("");
    $("#fcurrpin").val("");
    $("#fcurrstate").val("");
  }
};

/*$('input[name="fqutype"]').click(function() {
  if (
    $(this).attr("id") == "fqutype_2" ||
    $(this).attr("id") == "fqutype_3" ||
    $(this).attr("id") == "fqutype_4"
  ) {
    $("#OtherUniv").show();
  } else {
    $("#OtherUniv").hide();
  }
});*/

//=========== BCU Employee Type=============//
const showOpt = () => {
  if ($("#fbcue_1").is(":checked")) $("#fbcuetype").show();
  else {
    $('input[name="fbcuetype"]').val("");
    $("#fbcuetype").hide();
  }
};

//============= Check Results Awaited ==============//
// const checkResMarks = () => {
//   if ($("#resStat").is(":checked")) $("input[type=text].clr").val("");
// };

//========= Calculate Percentage ========//
const getPrevPercent = () => {
  if ($("#fqmaxmarks").val() == "") return;

  if ($("#fqsecmarks").val() == "") return;

  if (parseFloat($("#fqsecmarks").val()) > parseFloat($("#fqmaxmarks").val())) {
    alert("Maximum Marks less than Secured Marks");
    $("#fqmaxmarks").val("");
    $("#fqsecmarks").val("");
    return;
  }
  $("#fqpercentage").val(
    (
      (parseFloat($("#fqsecmarks").val()) * 100) /
      parseFloat($("#fqmaxmarks").val())
    ).toFixed(2)
  );
};

//============= Calculate Total MM =============//
const getlTotalMM = () => {
  var val1 = $("#flang1mm").val();
  var val2 = $("#flang2mm").val();
  if (val1 == "") val1 = 0;
  if (val2 == "") val2 = 0;

  ttlMM = parseInt(val1) + parseInt(val2);

  $("#flangttlmm").val(ttlMM);
};

//============= Calculate Total MS =============//
const getlTotalMS = () => {
  var val1 = $("#flang1ms").val();
  var val2 = $("#flang2ms").val();
  if (val1 == "") val1 = 0;
  if (val2 == "") val2 = 0;

  ttlMS = parseInt(val1) + parseInt(val2);
  $("#flangttlms").val(ttlMS);
};

const optTtlMM = () => {
  var val1 = $("#fopt1mm").val();
  var val2 = $("#fopt2mm").val();
  var val3 = $("#fopt3mm").val();
  var val4 = $("#fopt4mm").val();

  if (val1 == "") val1 = 0;
  if (val2 == "") val2 = 0;
  if (val3 == "") val3 = 0;
  if (val4 == "") val4 = 0;

  ttlMM = parseInt(val1) + parseInt(val2) + parseInt(val3) + parseInt(val4);
  $("#foptttlmm").val(ttlMM);
};

const optTtlMS = () => {
  var val1 = $("#fopt1ms").val();
  var val2 = $("#fopt2ms").val();
  var val3 = $("#fopt3ms").val();
  var val4 = $("#fopt4ms").val();

  if (val1 == "") val1 = 0;
  if (val2 == "") val2 = 0;
  if (val3 == "") val3 = 0;
  if (val4 == "") val4 = 0;

  ttlMM = parseInt(val1) + parseInt(val2) + parseInt(val3) + parseInt(val4);
  $("#foptttlms").val(ttlMM);
};

//================= Validate Values  ==============//
jsonObj = [];

var nonMandFields = [
  "adhar",
  "pmobileno",
  "income",
  "othUniv",
  "fqpercentage",
  "flangttlms",
  "flangttlmm",
  "flang2",
  "flang2mm",
  "flang2ms",
  "fopt2",
  "fopt2mm",
  "fopt2ms",
  "fopt3",
  "fopt3mm",
  "fopt3ms",
  "fopt4",
  "fopt4mm",
  "fopt4ms",
  "foptttlmm",
  "foptttlms",
  "flangttlms",
  "flangttlmm",
  "fpmregno",
  "fbcuetype",
  "OtherUniv",
  "fquniv",
  "fpgunivtype",
  "",
];
var feestr = {};
var privsub = [];
var finaloptdeg = [];
var privackd = [];
var lansub = [];

var gfilename;

function UploadDocument() {
  file_file = "fwrkexppath"; //file
  var file_name = $("#" + file_file).val();
  var file_size = $("#" + file_file)[0].files[0].size;
  var file_extn = file_name.split(".").pop();
  var file_extn = file_extn.toLowerCase();
  // if (file_extn == "xlsx") {

  // }
  // else {
  //   alert("XLSX files are allowed!");
  //   return false;
  // }

  if (file_size >= 1000000) {
    alert("Upload files with size less then 1MB!");
    return false;
  }

  var file_data = $("#" + file_file).prop("files")[0];
  var form_data = new FormData();
  form_data.append("file", file_data);
  console.log("fileeee", form_data, file_data, file_name);
  $.blockUI({
    message:
      "<h1 class='h1' style='font-size:12px'><img src='../images/ajax-loader.gif' border='0'></h1>",
  });
  $.ajax({
    type: "POST",
    url: "./upload_file.php",
    data: form_data,
    cache: false,
    contentType: false,
    processData: false,
    success: function (data) {
      $.unblockUI();
      console.log(data);
      gfilename = data;
    },
    error: function (data) {
      alert(data);
    },
  });
}

function savepgApplication() {
  console.log(arrlengthofdeg);
  jsonObj = [];
  var errcount = 0;
  var missing_fields = [];
  privsub = [];
  lansub = [];
  finaloptdeg = [];
  privackd = [];
  // var photo_path = $("#file").val();
  // if(arrlengthofdeg == 0){
  //   swal({
  //     title: `No Degree selected`,
  //     html: true,
  //     showCancelButton: false,
  //     confirmButtonColor: "#5495ff",
  //     confirmButtonText: "OK",
  //     closeOnConfirm: false,
  //   });
  //   return;
  // }
  if (nolan[$("#fdegree").val()] == "T") {
    nonMandFields = [
      "adhar",
      "pmobileno",
      "income",
      "othUniv",
      "fqpercentage",
      "flangttlms",
      "flangttlmm",
      "flang2",
      "flang2mm",
      "flang2ms",
      "fopt2",
      "fopt2mm",
      "fopt2ms",
      "fopt3",
      "fopt3mm",
      "fopt3ms",
      "fopt4",
      "fopt4mm",
      "fopt4ms",
      "foptttlmm",
      "foptttlms",
      "flangttlms",
      "flangttlmm",
      "fpmregno",
      "fbcuetype",
      "OtherUniv",
      "fquniv",
      "fpgunivtype",
      "",
      "lansem1mm_1",
      "lansem1mo_1",
      "lansem2mm_1",
      "lansem2mo_1",
      "lansem3mm_1",
      "lansem3mo_1",
      "lansem4mm_1",
      "lansem4mo_1",
      "lansem5mm_1",
      "lansem5mo_1",
      "lansem6mm_1",
      "lansem6mo_1",
      "lantotalmm_1",
      "lantotalmo_1",
      "lanpercentagemm_1",
      "lansem1mm_2",
      "lansem1mo_2",
      "lansem2mm_2",
      "lansem2mo_2",
      "lansem3mm_2",
      "lansem3mo_2",
      "lansem4mm_2",
      "lansem4mo_2",
      "lansem5mm_2",
      "lansem5mo_2",
      "lansem6mm_2",
      "lansem6mo_2",
      "lantotalmm_2",
      "lantotalmo_2",
      "lanpercentagemm_2",
    ];
  }

  if (photo_filename === undefined && photo_path == undefined) {
    $("#photo_err").addClass("hasError");
    missing_fields.push("Student Photo");
    errcount++;
  } else {
    $("#photo_err").removeClass("hasError");
    item = {};
    item["id"] = "photo_path";
    item["value"] = photo_filename;
    jsonObj.push(item);
  }

  //validate and read values of text and select boxes for Personal Details
  $("#idPerDet input[type=text],#idPerDet select").each(function () {
    if ($(this).val() == "" && !in_array($(this).attr("id"), nonMandFields)) {
      $(this).closest(".form-group").find(".fieldError").addClass("hasError");

      if ($(this).attr("name") != "") errcount++;
      missing_fields.push($(this).attr("name"));
    } else {
      $(this)
        .closest(".form-group")
        .find(".fieldError")
        .removeClass("hasError");
      item = {};
      item["id"] = $(this).attr("id");
      item["value"] = $(this).val();
      jsonObj.push(item);
    }
  });
  console.log(jsonObj);
  if (db == "rcub") {
    var radio_names = [
      "fgender",
      "fhk",
      "fselfsupsch",
      "foutstud",
      "funivstud",
      "fpdp",
      "fcof",
      "fcoh",
      "fgah",
      "fkanm",
      "fhandicap",
      "fsports",
      "fncc",
      "fdefence",
      "fnss",
      "fexservice",
      "fkanm",
      "fchilsuid",
      "fjks",
      "funikar",
    ];
  } else if (db == "dud") {
    var radio_names = [
      "fgender",
      "fhk",
      "foutstud",
      "funivstud",
      "fkanm",
      "fhandicap",
      "fsports",
      "fncc",
      "fscouts",
      "fdefence",
      "fnss",
      "fkanm",
      "funikar",
    ];
  } else {
    var radio_names = [
      "fgender",
      "fhk",
      "fselfsupsch",
      "funivstud",
      "fpdp",
      "fcof",
      "fgah",
      "fkanm",
      "fhandicap",
      "fsports",
      "fncc",
    ];
  }
  // resStat
  // var checkboxes = $("#quota input[type=checkbox]");
  var vals = "";
  // console.log(checkboxes);

  // for (var i = 0, n = checkboxes.length; i < n; i++) {
  //   if (checkboxes[i].checked) {
  //     item = {};

  //     item["id"] = checkboxes[i].id;
  //     item["value"] = "Yes";
  //     jsonObj.push(item);
  //   } else {
  //     item = {};

  //     item["id"] = checkboxes[i].id;
  //     item["value"] = "No";
  //     jsonObj.push(item);
  //   }
  // }

  if ($("#resStat").is(":checked")) {
    item = {};
    item["id"] = "fresstat";
    item["value"] = "Yes";
    jsonObj.push(item);
    $("#prevAcdMarks input[type=text]").each(function () {
      $("input[type=text].clr").val("");
      $(this)
        .closest(".form-group")
        .find(".fieldError")
        .removeClass("hasError");
      item = {};
      item["id"] = $(this).attr("id");
      item["value"] = $(this).val();
      jsonObj.push(item);
    });
  } else {
    item = {};
    item["id"] = "fresstat";
    item["value"] = "No";
    jsonObj.push(item);

    $(".reqMarks input[type=text]").each(function () {
      if ($(this).val() == "" && !in_array($(this).attr("id"), nonMandFields)) {
        $(this).closest(".form-group").find(".fieldError").addClass("hasError");
        if ($(this).attr("name") != "") errcount++;
        missing_fields.push($(this).attr("name"));
      } else {
        $(this)
          .closest(".form-group")
          .find(".fieldError")
          .removeClass("hasError");
        item = {};
        item["id"] = $(this).attr("id");
        item["value"] = $(this).val();
        jsonObj.push(item);
      }
    });
  }
  if ($("#fhkrdno").val()) {
    var fhkrdno = $("#fhkrdno").val();
    item = {};
    item["id"] = "fhkrdno";
    item["value"] = $("#fhkrdno").val();
    jsonObj.push(item);
  }
  // document.getElementById("vskub_2").checked;
  //======= validate 1st preference ==========//
  // if ($("#fdegree1").val() == null || $("#fdegree1").val() == "") {
  //   $("#pref1")
  //     .closest(".form-group")
  //     .find(".fieldError")
  //     .addClass("hasError");
  //   errcount++;
  //   missing_fields.push($(this).attr("name"));
  // } else {
  //   $("#subjectdet select").each(function() {
  //     $(this)
  //       .closest(".form-group")
  //       .find(".fieldError")
  //       .removeClass("hasError");
  //     item = {};
  //     item["id"] = $(this).attr("id");
  //     item["value"] = $(this).val();
  //     jsonObj.push(item);
  //   });
  // }

  $("#prevAcadDet input[type=text],#prevAcadDet select").each(function () {
    if ($(this).val() == "" && !in_array($(this).attr("id"), nonMandFields)) {
      $(this).closest(".form-group").find(".fieldError").addClass("hasError");
      errcount++;
      missing_fields.push($(this).attr("name"));
    } else {
      $(this)
        .closest(".form-group")
        .find(".fieldError")
        .removeClass("hasError");
      item = {};
      item["id"] = $(this).attr("id");
      item["value"] = $(this).val();
      jsonObj.push(item);
    }
  });

  $("#marksDet input[type=text],#prevAcadDet select").each(function () {
    console.log($(this).attr("id"));
    if ($(this).val() == "" && !in_array($(this).attr("id"), nonMandFields)) {
      $(this).closest(".form-group").find(".fieldError").addClass("hasError");
      errcount++;
      missing_fields.push($(this).attr("name"));
    } else {
      $(this)
        .closest(".form-group")
        .find(".fieldError")
        .removeClass("hasError");
      item = {};
      item["id"] = $(this).attr("id");
      item["value"] = $(this).val();
      jsonObj.push(item);
    }
  });

  if ($('input[id="fpgdegree_1"]').is(":checked")) {
    //radio_names.push("fpgunivtype");
    $("#prevPGDet input[type=text],#prevPGDet select").each(function () {
      if ($(this).val() == "" && !in_array($(this).attr("id"), nonMandFields)) {
        $(this).closest(".form-group").find(".fieldError").addClass("hasError");
        errcount++;
        missing_fields.push($(this).attr("name"));
      } else {
        $(this)
          .closest(".form-group")
          .find(".fieldError")
          .removeClass("hasError");
        item = {};
        item["id"] = $(this).attr("id");
        item["value"] = $(this).val();
        jsonObj.push(item);
      }
    });
  } else {
    $("#prevPGDet input[type=text],#prevPGDet select").each(function () {
      item = {};
      item["id"] = $(this).attr("id");
      item["value"] = $(this).val();
      jsonObj.push(item);
    });
  }

  //===== MBA Entrance Exam Name ======//
  if ($('input[id="fmngetexam_1"]').is(":checked")) {
    // radio_names.push("fpgunivtype");
    var entranceExm_Name = $("#fmngexamname").val();
    var entranceExm_Rnk = $("#fmngrank").val();

    console.log("entranceExm_Name", entranceExm_Name);
    //----- MBA Exam NAME -----//
    if (entranceExm_Name == "") {
      $("#mbaName_err")
        .closest(".form-group")
        .find(".fieldError")
        .addClass("hasError");
      errcount++;
      missing_fields.push("fmngexamname");
    } else {
      $("#mbaName_err")
        .closest(".form-group")
        .find(".fieldError")
        .removeClass("hasError");

      item = {};
      item["id"] = "fmngexamname";
      item["value"] = entranceExm_Name;
      jsonObj.push(item);
    }
    //----- MBA Rank -----//
    if (entranceExm_Rnk == "") {
      $("#mbaRnk_err")
        .closest(".form-group")
        .find(".fieldError")
        .addClass("hasError");
      errcount++;
      missing_fields.push("fmngrank");
    } else {
      $("#mbaRnk_err")
        .closest(".form-group")
        .find(".fieldError")
        .removeClass("hasError");
      item = {};
      item["id"] = "fmngrank";
      item["value"] = entranceExm_Rnk;
      jsonObj.push(item);
    }
  } else {
    var entranceExm_Name = $("#fmngexamname").val();
    var entranceExm_Rnk = $("#fmngrank").val();
    item = {};
    item["id"] = "fmngexamname";
    item["value"] = entranceExm_Name;
    jsonObj.push(item);

    item = {};
    item["id"] = "fmngrank";
    item["value"] = entranceExm_Rnk;
    jsonObj.push(item);
  }

  // if ($('input[id="fmbaentrace_1"]').is(":checked")) {
  var mbawrkExp = $("#fwrkexp").val();

  console.log("mbawrkExp", mbawrkExp);
  //----- MBA Exam NAME -----//
  if (mbawrkExp == "") {
    $("#mbawrk_err")
      .closest(".form-group")
      .find(".fieldError")
      .addClass("hasError");
    // errcount++;
    // missing_fields.push("mbawrkExp");
    console.log("mbawrkExp empty", mbawrkExp);
    item = {};
    item["id"] = "fwrkexp";
    item["value"] = mbawrkExp;
    jsonObj.push(item);
  } else {
    $("#mbawrk_err")
      .closest(".form-group")
      .find(".fieldError")
      .removeClass("hasError");
    item = {};
    item["id"] = "fwrkexp";
    item["value"] = mbawrkExp;
    jsonObj.push(item);
  }

  if (gfilename != "") {
    item = {};
    item["id"] = "fwrkexppath";
    item["value"] = gfilename;
    jsonObj.push(item);
  }
  // }

  for (var i = 0; i < radio_names.length; i++) {
    if (!$('input[name="' + radio_names[i] + '"]').is(":checked")) {
      console.log(radio_names[i] + " is not checked");
      if (radio_names[i] != "fbcuetype") {
        $('input[name="' + radio_names[i] + '"]')
          .closest(".form-group")
          .find(".fieldError")
          .addClass("hasError");
        errcount++;
        missing_fields.push(radio_names[i]);
      } else {
        value = $('input[name="' + radio_names[i] + '"]').val();
        item = {};
        item["id"] = radio_names[i];
        item["value"] = value;
        jsonObj.push(item);
      }
    } else {
      console.log(radio_names[i] + "is checked");
      $('input[name="' + radio_names[i] + '"]')
        .closest(".form-group")
        .find(".fieldError")
        .removeClass("hasError");
      value = $('input[name="' + radio_names[i] + '"]:checked').val();
      item = {};
      item["id"] = radio_names[i];
      item["value"] = value;
      jsonObj.push(item);
    }
  }

  var feestr1 = [];
  $("#mainTable tr.tblRow").each((i, el) => {
    var $tds = $(el).find("td");
    var feehead = $.trim($tds.eq(1).text());
    var fee = $.trim($tds.eq(2).text());
    var obj = {};
    obj.feehead = feehead;
    obj.fee = fee;
    feestr1.push(obj);
  });
  var obj = {};
  feestr.data = feestr1;

  item = {};
  item["id"] = "ftotfee";
  item["value"] = totalFee;
  jsonObj.push(item);

  item = {};
  item["id"] = "fdocloc";
  item["value"] = $("#fdocloc").val();
  jsonObj.push(item);

  var ressub = combsubject[`${$("#fdegree").val()}${$("#fcombcode").val()}`];
  if (ressub != undefined) {
    var res = ressub.split("*");

    var z = 1;
    for (var i = 0; i < res.length; i++) {
      var item = {};
      item["subcode"] = $(`#subcode_${z}`).val();
      item["subsem1mo"] = $(`#subsem1mo_${z}`).val();
      item["subsem1mm"] = $(`#subsem1mm_${z}`).val();
      item["subsem2mo"] = $(`#subsem2mo_${z}`).val();
      item["subsem2mm"] = $(`#subsem2mm_${z}`).val();
      item["subsem3mo"] = $(`#subsem3mo_${z}`).val();
      item["subsem3mm"] = $(`#subsem3mm_${z}`).val();
      item["subsem4mo"] = $(`#subsem4mo_${z}`).val();
      item["subsem4mm"] = $(`#subsem4mm_${z}`).val();
      item["subsem5mo"] = $(`#subsem5mo_${z}`).val();
      item["subsem5mm"] = $(`#subsem5mm_${z}`).val();
      item["subsem6mo"] = $(`#subsem6mo_${z}`).val();
      item["subsem6mm"] = $(`#subsem6mm_${z}`).val();
      item["subtotalmo"] = $(`#subtotalmo_${z}`).val();
      item["subtotalmm"] = $(`#subtotalmm_${z}`).val();
      item["subpercentagemm"] = $(`#subpercentagemm_${z}`).val();
      z++;
      privsub.push(item);
    }
  }

  if (optdegarry.length > 0) {
    for (let i = 1; i <= optdegarry.length; i++) {
      if ($('input[name="deg_' + i + '"]').is(":checked")) {
        var item = {};
        item["optdeg"] = $(`#h_optdeg_${i}`).val();
        finaloptdeg.push(item);
      }
    }
  }
  var z = 1;
  for (var i = 0; i < 2; i++) {
    var item = {};
    item["subcode"] = $(`#flan${z}`).val();
    item["lansem1mo"] = $(`#lansem1mo_${z}`).val();
    item["lansem1mm"] = $(`#lansem1mm_${z}`).val();
    item["lansem2mo"] = $(`#lansem2mo_${z}`).val();
    item["lansem2mm"] = $(`#lansem2mm_${z}`).val();
    item["lansem3mo"] = $(`#lansem3mo_${z}`).val();
    item["lansem3mm"] = $(`#lansem3mm_${z}`).val();
    item["lansem4mo"] = $(`#lansem4mo_${z}`).val();
    item["lansem4mm"] = $(`#lansem4mm_${z}`).val();
    item["lansem5mo"] = $(`#lansem5mo_${z}`).val();
    item["lansem5mm"] = $(`#lansem5mm_${z}`).val();
    item["lansem6mo"] = $(`#lansem6mo_${z}`).val();
    item["lansem6mm"] = $(`#lansem6mm_${z}`).val();
    item["lantotalmo"] = $(`#lantotalmo_${z}`).val();
    item["lantotalmm"] = $(`#lantotalmm_${z}`).val();
    item["lanpercentagemm"] = $(`#lanpercentagemm_${z}`).val();
    z++;
    lansub.push(item);
  }

  var item = {};
  item["fqpercentage"] = $("#fqpercentage").val();
  // item["flang1"] = $("#flang1").val();
  // item["flang2"] = $("#flang2").val();
  // item["flang1mm"] = $("#flang1mm").val();
  // item["flang2mm"] = $("#flang2mm").val();
  // item["flangttlmm"] = $("#flangttlmm").val();
  // item["flang1ms"] = $("#flang1ms").val();
  // item["flang2ms"] = $("#flang2ms").val();
  // item["flangttlms"] = $("#flangttlms").val();
  item["qulregno"] = $("#qulregno").val();
  item["idUnvExam"] = $("#idUnvExam").val();
  item["qulcollname"] = $("#qulcollname").val();
  item["fcombcode"] = $("#fcombcode").val();
  item["fdegree"] = $("#fdegree").val();

  item["1_sslc"] = $("#h_1_SSLC").val();
  item["2_ug"] = $("#h_2_UG").val();
  item["3_caste"] = $("#h_3_CASTE").val();
  item["4_hk"] = $("#h_4_HK").val();
  item["5_sqc"] = $("#h_5_SQC").val();

  privackd.push(item);

  $("#OtherInfo input[type=text],#OtherInfo textarea").each(function () {
    if ($(this).val() == "" && !in_array($(this).attr("id"), nonMandFields)) {
      $(this).closest(".form-group").find(".fieldError").addClass("hasError");
      errcount++;
      missing_fields.push($(this).attr("name"));
    } else {
      $(this)
        .closest(".form-group")
        .find(".fieldError")
        .removeClass("hasError");
      item = {};
      item["id"] = $(this).attr("id");
      item["value"] = $(this).val();
      jsonObj.push(item);
    }
  });

  console.log({ errcount, missing_fields, jsonObj });
  return errcount;
}

const savePGAdmDet = (finsub) => {
  var errorcount = savepgApplication();
  if (finsub == "T" && errorcount > 0) {
    swal({
      title: `Fill All the missing fields. Missing fields are highlighted in red color.`,
      html: true,
      showCancelButton: false,
      confirmButtonColor: "#5495ff",
      confirmButtonText: "OK",
      closeOnConfirm: false,
    });
    return;
  }
  console.log(fappno);

  $.ajax({
    type: "POST",
    url: $host_url + "pgsaveApplication",
    data:
      "fappno=" +
      fappno +
      "&final=" +
      finsub +
      "&feestr=" +
      JSON.stringify(feestr) +
      "&data=" +
      JSON.stringify(jsonObj) +
      "&privackd=" +
      JSON.stringify(privackd) +
      "&lansub=" +
      JSON.stringify(lansub) +
      "&privsub=" +
      JSON.stringify(privsub) +
      "&finaloptdeg=" +
      JSON.stringify(finaloptdeg),
    success: (response) => {
      var { error_code, data, status } = JSON.parse(response);
      var { message } = data;
      if (error_code === -1) {
        swal({
          title: data.message,
          html: true,
          showCancelButton: false,
          confirmButtonColor: "#5495ff",
          confirmButtonText: "OK",
          closeOnConfirm: false,
        });
      } else {
        var { app_no } = data;
        gAppNo = app_no;
        fappno = app_no;
        if (finsub == "T") {
          $("#sbmchallan").hide();
          // $("#makepayment").show();
          $("#dapp_no").append(app_no);

          $("#app_msg").append(message);
          $("#prefDet").hide();
          $("#docvrfloc_div").hide();
          $("#personal_det").hide();
          $("#basicDet").hide();
          $("#prevAcadDetCard").hide();
          $("#FeeDet").hide();
          $("#upload_doc_det").hide();
          $("#optdeg_det").hide();
          // $("#success_card").show();
          // makepayment(gAppNo, "026");
          var db = window.location.pathname.split("/")[2];
          if (db == "vskub") loadOptionEntry(finaloptdeg);
          else if (db == "rcub" || db == "dud") loadAppStatus();
        } else {
          swal({
            title: `Updated successfully. Unless the final submission is
                made application will not be submitted to the university.`,
            html: true,
            showCancelButton: false,
            confirmButtonColor: "#5495ff",
            confirmButtonText: "OK",
            closeOnConfirm: false,
          });
        }
      }
    },
  });
};

function loadcombination() {
  var degcomb = combcode[$("#fdegree").val()];
  console.log(nolan);
  var deglan = nolan[$("#fdegree").val()];
  if (deglan == "T") {
    $("#landiv").hide();
  } else {
    $("#landiv").show();
  }
  var options = "";
  options += `<option value="">--Select--</option>`;
  if (degcomb != undefined) {
    var res = degcomb.split("*");
    res.forEach((element) => {
      var value = element.split("-");
      options += `<option value="${value[0]}">${value[1]}</options>`;
    });
  }
  $("#fcombcode").html(options);
}

function loadotdeg(fappno) {
  var degcode = $("#fdegree").val();
  // console.log(degcode);
  var combcode = $("#fcombcode").val();
  var studtype = $("#fstudtype").val();
  if (degcode == "" || combcode == "") return;
  $.ajax({
    type: "POST",
    url: $host_url + "loadotdeg",
    data:
      "fappno=" +
      fappno +
      "&degcode=" +
      degcode +
      "&combcode=" +
      combcode +
      "&studtype=" +
      studtype,
    success: (response) => {
      var { error_code, data, status } = JSON.parse(response);
      console.log(data);
      var { msg } = data;
      if (error_code === -1) {
        swal({
          title: data.msg,
          html: true,
          showCancelButton: false,
          confirmButtonColor: "#5495ff",
          confirmButtonText: "OK",
          closeOnConfirm: false,
        });
      } else {
        var optdeg = data.optdeg;
        optdegarry = data.optdeg;
        var optdegtable = `<table class='table table-bordered table-upd' id="optdet">
            <thead>
            <tr class="bg-cyan">
            <td style="width :5%">Sl. No.</td>
            <td style="width : 40%;">Degree Name</td>
            <td style="width : 5%;">Select</td>
            </tr>
            </thead>
            <tbody>`;

        var i = 1;

        optdeg.forEach((element) => {
          optdegtable += `<tr>
            <td style="text-align: center;">${i}</td>
            <td id="doc_upload_1">${element.fdescpn}
             <input type = 'hidden' value = '${element.fdegree}' id = 'h_optdeg_${i}'>
            </td>
            <td style="text-align:center;"><input type = 'checkbox' style="text-align:center;" ${element.sddeg} value = '${element.fdegree}' id = 'deg_${i}' name = 'deg_${i}' onchange = totfeeupdate(this) >
            <label for="deg_${i}" style="font-size:10px !important;text-align:center; "></label>
            </td>`;
          // if(element.sddeg == '0')
          // {
          //   optdegtable += `<td><input type = 'checkbox' ${element.sddeg} value = '${element.fdegree}' id = 'deg_${i}'>
          //   <label for="deg_${i}" style="font-size:10px !important;"></label>
          //   </td>`;
          // }else
          // {
          //   optdegtable += `<td><input type = 'checkbox' value = '${element.fdegree}' checked id = 'deg_${i}'>
          //   <label for="deg_${i}" style="font-size:10px !important;"></label></td>`;
          // }
          optdegtable += `</tr>`;
          i++;
        });
        optdegtable += `</tbody></table>`;
        $("#optdeg").html(optdegtable);
      }
    },
  });
}

function loadcombsubjects() {
  var res = combsubject[`${$("#fdegree").val()}${$("#fcombcode").val()}`];

  var table = ` <thead>
  <tr class='bg-cyan'>
    <td class="qaltablefisrtrd">
      Sl.
    </td>
    <td class="qaltabletd" style="width: 200px;" rowspan="2">
      Subject
    </td>
    <td class="qaltabletd" colspan="2">
      Sem / Year I
    </td>
    <td class="qaltabletd" colspan="2">
      Sem / Year II
    </td>
    <td class="qaltabletd" colspan="2">
      Sem / Year III
    </td>
    <td class="qaltabletd" colspan="2">
      Sem / Year IV
    </td>
    <td class="qaltabletd" colspan="2">
      Sem / Year V
    </td>
    <td class="qaltabletd" colspan="2">
      Sem / Year VI
    </td>
    <td class="qaltabletd" colspan="2">
      Total Marks
    </td>
    <td class="qaltabletd" rowspan="2">
      % of Marks
    </td>
  </tr>
  <tr class='bg-cyan'>
    <td class="qaltablefisrtrd">
      No.
    </td>
    
    <td class="qaltabletd">
      Max
    </td>
    <td class="qaltabletd">
      Obt
    </td>
    <td class="qaltabletd">
      Max
    </td>
    <td class="qaltabletd">
      Obt
    </td>
    <td class="qaltabletd">
      Max
    </td>
    <td class="qaltabletd">
      Obt
    </td>
    <td class="qaltabletd">
      Max
    </td>
    <td class="qaltabletd">
      Obt
    </td>
    <td class="qaltabletd">
      Max
    </td>
    <td class="qaltabletd">
      Obt
    </td>
    <td class="qaltabletd">
      Max
    </td>
    <td class="qaltabletd">
      Obt
    </td>
    <td class="qaltabletd">
      Max
    </td>
    <td class="qaltabletd">
      Obt
    </td>
  </tr>
</thead>
<tbody>`;
  if (res != undefined) {
    var subdet = res.split("*");
    var i = 1;
    subdet.forEach((element) => {
      var value = element.split("-");
      table += `<tr id='${i}' class="ui-widget-content jqgrow">
        <td class='tbl_row_new tdfirst'>
          <centre>${i}. </centre>
        </td>
        <td class='tbl_row_new'>
          <input type="text" name="subsem1_${i}" id="subsem1_${i}"
            style="max-width: 200px !important;" disabled value = '${value[1]}'>
          <input type="hidden" name="subcode_${i}" id="subcode_${i}" value="${value[0]}">
        </td>
        <td class='tbl_row_new'>
          <input type="text" name="subsem1mm_${i}" maxlength="4"
            onkeypress="return acceptNumbersOnlyForModule(event);" id="subsem1mm_${i}"
            onchange="gettoal('${i}')">
        </td>
        <td class='tbl_row_new'>
          <input type="text" name="subsem1mo_${i}" maxlength="4"
            onkeypress="return acceptNumbersOnlyForModule(event);" onchange="gettoal('${i}')"
            id="subsem1mo_${i}">
        </td>
        <td class='tbl_row_new'>
          <input type="text" name="subsem2mm_${i}" maxlength="4"
            onkeypress="return acceptNumbersOnlyForModule(event);" id="subsem2mm_${i}"
            onchange="gettoal('${i}')">
        </td>
        <td class='tbl_row_new'>
          <input type="text" name="subsem2mo_${i}" maxlength="4"
            onkeypress="return acceptNumbersOnlyForModule(event);" id="subsem2mo_${i}"
            onchange="gettoal('${i}')">
        </td>
        <td class='tbl_row_new'>
          <input type="text" name="subsem3mm_1" maxlength="4"
            onkeypress="return acceptNumbersOnlyForModule(event);" id="subsem3mm_${i}"
            onchange="gettoal('${i}')">
        </td>
        <td class='tbl_row_new'>
          <input type="text" name="subsem3mo_${i}" maxlength="4"
            onkeypress="return acceptNumbersOnlyForModule(event);" id="subsem3mo_${i}"
            onchange="gettoal('${i}')">
        </td>
        <td class='tbl_row_new'>
          <input type="text" name="subsem4mm_${i}" maxlength="4"
            onkeypress="return acceptNumbersOnlyForModule(event);" id="subsem4mm_${i}"
            onchange="gettoal('${i}')">
        </td>
        <td class='tbl_row_new'>
          <input type="text" name="subsem4mo_${i}" maxlength="4"
            onkeypress="return acceptNumbersOnlyForModule(event);" id="subsem4mo_${i}"
            onchange="gettoal('${i}')">
        </td>
        <td class='tbl_row_new'>
          <input type="text" name="subsem5mm_${i}" maxlength="4"
            onkeypress="return acceptNumbersOnlyForModule(event);" id="subsem5mm_${i}"
            onchange="gettoal('${i}')">
        </td>
        <td class='tbl_row_new'>
          <input type="text" name="subsem5mo_${i}" maxlength="4"
            onkeypress="return acceptNumbersOnlyForModule(event);" id="subsem5mo_${i}"
            onchange="gettoal('${i}')">
        </td>
        <td class='tbl_row_new'>
          <input type="text" name="subsem6mm_${i}" maxlength="4"
            onkeypress="return acceptNumbersOnlyForModule(event);" id="subsem6mm_${i}"
            onchange="gettoal('${i}')">
        </td>
        <td class='tbl_row_new'>
          <input type="text" name="subsem6mo_${i}" maxlength="4"
            onkeypress="return acceptNumbersOnlyForModule(event);" id="subsem6mo_${i}"
            onchange="gettoal('${i}')">
        </td>
        <td class='tbl_row_new'>
          <input type="text" name="subtotalmm_${i}" maxlength="4" readonly
            onkeypress="return acceptNumbersOnlyForModule(event);" id="subtotalmm_${i}">
        </td>
        <td class='tbl_row_new'>
          <input type="text" name="subtotalmo_${i}" maxlength="4" readonly
            onkeypress="return acceptNumbersOnlyForModule(event);" id="subtotalmo_${i}">
        </td>
        <td class='tbl_row_new'>
          <input type="text" name="subpercentagemm_${i}" maxlength="5" readonly
            style="max-width: 70px" onkeypress="return acceptNumbersOnlyForModule(event);"
            id="subpercentagemm_${i}">
        </td>
      </tr>`;
      i++;
    });
    table += `</tbody>`;
    $("#qalsemdet").html(table);
  }
}

function gettoal(i) {
  var semmo1 = parseInt($("#subsem1mo_" + i).val());
  var semmm1 = parseInt($("#subsem1mm_" + i).val());

  if (semmo1 > semmm1 && !isNaN(semmm1)) {
    alert("sem 1 obtained marks is greater than the max. marks");
    $("#subsem1mm_" + i).val("");
    $("#subsem1mo_" + i).val("");
    $("#subsem1mo_" + i).focus();
    return;
  }

  var semmo2 = parseInt($("#subsem2mo_" + i).val());
  var semmm2 = parseInt($("#subsem2mm_" + i).val());

  if (semmo2 > semmm2 && !isNaN(semmm2)) {
    alert("sem 2 obtained marks is greater than the max. marks");
    $("#subsem2mm_" + i).val("");
    $("#subsem2mo_" + i).val("");
    $("#subsem2mo_" + i).focus();
    return;
  }

  var semmo3 = parseInt($("#subsem3mo_" + i).val());
  var semmm3 = parseInt($("#subsem3mm_" + i).val());

  if (semmo3 > semmm3 && !isNaN(semmm3)) {
    alert("sem 3 obtained marks is greater than the max. marks");
    $("#subsem3mm_" + i).val("");
    $("#subsem3mo_" + i).val("");
    $("#subsem3mo_" + i).focus();
    return;
  }

  var semmo4 = parseInt($("#subsem4mo_" + i).val());
  var semmm4 = parseInt($("#subsem4mm_" + i).val());

  if (semmo4 > semmm4 && !isNaN(semmm4)) {
    alert("sem 4 obtained marks is greater than the max. marks");
    $("#subsem4mm_" + i).val("");
    $("#subsem4mo_" + i).val("");
    $("#subsem4mo_" + i).focus();
    return;
  }

  var semmo5 = parseInt($("#subsem5mo_" + i).val());
  var semmm5 = parseInt($("#subsem5mm_" + i).val());

  if (semmo5 > semmm5 && !isNaN(semmm5)) {
    alert("sem 5 obtained marks is greater than the max. marks");
    $("#subsem5mm_" + i).val("");
    $("#subsem5mo_" + i).val("");
    $("#subsem5mo_" + i).focus();
    return;
  }

  var semmo6 = parseInt($("#subsem6mo_" + i).val());
  var semmm6 = parseInt($("#subsem6mm_" + i).val());

  if (semmo6 > semmm6 && !isNaN(semmm6)) {
    alert("sem 6 obtained marks is greater than the max. marks");
    $("#subsem6mm_" + i).val("");
    $("#subsem6mo_" + i).val("");
    $("#subsem6mo_" + i).focus();
    return;
  }

  var totobt = 0;
  var totmarks = 0;

  if (
    !isNaN(semmo1) &&
    !isNaN(semmo2) &&
    !isNaN(semmo3) &&
    !isNaN(semmo4) &&
    !isNaN(semmo5) &&
    !isNaN(semmo6)
  ) {
    totobt =
      parseInt(semmo1) +
      parseInt(semmo2) +
      parseInt(semmo3) +
      parseInt(semmo4) +
      parseInt(semmo5) +
      parseInt(semmo6);
    $("#subtotalmo_" + i).val(totobt);
  }

  if (
    !isNaN(semmm1) &&
    !isNaN(semmm2) &&
    !isNaN(semmm3) &&
    !isNaN(semmm4) &&
    !isNaN(semmm5) &&
    !isNaN(semmm6)
  ) {
    totmarks =
      parseInt(semmm1) +
      parseInt(semmm2) +
      parseInt(semmm3) +
      parseInt(semmm4) +
      parseInt(semmm5) +
      parseInt(semmm6);
    $("#subtotalmm_" + i).val(totmarks);
    var totpercetage = (parseInt(totobt) / parseInt(totmarks)) * 100;
    $("#subpercentagemm_" + i).val(Math.round(totpercetage * 100) / 100);
  }
}

function loadlansubjects(data) {
  //console.log(data);
  // data.forEach(element => {
  //   console.log(element);
  // });
  var table = ` <thead>
  <tr class='bg-cyan'>
    <td class="qaltablefisrtrd">
      Sl.
    </td>
    <td class="qaltabletd" style="width: 200px;" rowspan="2">
      Subject
    </td>
    <td class="qaltabletd" colspan="2">
      Sem / Year I
    </td>
    <td class="qaltabletd" colspan="2">
      Sem / Year II
    </td>
    <td class="qaltabletd" colspan="2">
      Sem / Year III
    </td>
    <td class="qaltabletd" colspan="2">
      Sem / Year IV
    </td>
    <td class="qaltabletd" colspan="2">
    Sem / Year V
  </td>
  <td class="qaltabletd" colspan="2">
    Sem / Year VI
  </td>
    <td class="qaltabletd" colspan="2">
      Total Marks
    </td>
    <td class="qaltabletd" rowspan="2">
      % of Marks
    </td>
  </tr>
  <tr class='bg-cyan'>
    <td class="qaltablefisrtrd">
      No.
    </td>
    
    <td class="qaltabletd">
      Max
    </td>
    <td class="qaltabletd">
      Obt
    </td>
    <td class="qaltabletd">
      Max
    </td>
    <td class="qaltabletd">
      Obt
    </td>
    <td class="qaltabletd">
      Max
    </td>
    <td class="qaltabletd">
      Obt
    </td>
    <td class="qaltabletd">
      Max
    </td>
    <td class="qaltabletd">
    Obt
  </td>
    <td class="qaltabletd">
      Max
    </td>
    <td class="qaltabletd">
    Obt
  </td>
  <td class="qaltabletd">
    Max
  </td>
    <td class="qaltabletd">
      Obt
    </td>
    <td class="qaltabletd">
      Max
    </td>
    <td class="qaltabletd">
      Obt
    </td>
  </tr>
</thead>
<tbody>`;
  var options = "";
  options += `<option value="">--Select--</option>`;
  lansub.map((el, i) => {
    options += `<option value="${lansub[i]["int_code"]}">${lansub[i]["val"]}</options>`;
  });

  var i = 1;
  for (var z = 0; z < 2; z++) {
    table += `<tr id='${i}' class="ui-widget-content jqgrow">
        <td class='tbl_row_new tdfirst'>
          <centre>${i}. </centre>
        </td>
        <td class='tbl_row_new'>
        <select class="form-control clr" id="flan${i}">
        ${options}
        </select>
        </td>
        <td class='tbl_row_new'>
          <input type="text" name="lansem1mm_${i}" maxlength="4"
            onkeypress="return acceptNumbersOnlyForModule(event);" id="lansem1mm_${i}"
            onchange="getlantoal('${i}')">
        </td>
        <td class='tbl_row_new'>
          <input type="text" name="lansem1mo_${i}" maxlength="4"
            onkeypress="return acceptNumbersOnlyForModule(event);" onchange="getlantoal('${i}')"
            id="lansem1mo_${i}">
        </td>
        <td class='tbl_row_new'>
          <input type="text" name="lansem2mm_${i}" maxlength="4"
            onkeypress="return acceptNumbersOnlyForModule(event);" id="lansem2mm_${i}"
            onchange="getlantoal('${i}')">
        </td>
        <td class='tbl_row_new'>
          <input type="text" name="lansem2mo_${i}" maxlength="4"
            onkeypress="return acceptNumbersOnlyForModule(event);" id="lansem2mo_${i}"
            onchange="getlantoal('${i}')">
        </td>
        <td class='tbl_row_new'>
          <input type="text" name="lansem3mm_1" maxlength="4"
            onkeypress="return acceptNumbersOnlyForModule(event);" id="lansem3mm_${i}"
            onchange="getlantoal('${i}')">
        </td>
        <td class='tbl_row_new'>
          <input type="text" name="lansem3mo_${i}" maxlength="4"
            onkeypress="return acceptNumbersOnlyForModule(event);" id="lansem3mo_${i}"
            onchange="getlantoal('${i}')">
        </td>
        <td class='tbl_row_new'>
          <input type="text" name="lansem4mm_${i}" maxlength="4"
            onkeypress="return acceptNumbersOnlyForModule(event);" id="lansem4mm_${i}"
            onchange="getlantoal('${i}')">
        </td>
        <td class='tbl_row_new'>
          <input type="text" name="lansem4mo_${i}" maxlength="4"
            onkeypress="return acceptNumbersOnlyForModule(event);" id="lansem4mo_${i}"
            onchange="getlantoal('${i}')">
        </td>
        <td class='tbl_row_new'>
          <input type="text" name="lansem5mm_${i}" maxlength="4"
            onkeypress="return acceptNumbersOnlyForModule(event);" id="lansem5mm_${i}"
            onchange="getlantoal('${i}')">
        </td>
        <td class='tbl_row_new'>
          <input type="text" name="lansem5mo_${i}" maxlength="4"
            onkeypress="return acceptNumbersOnlyForModule(event);" id="lansem5mo_${i}"
            onchange="getlantoal('${i}')">
        </td>
        <td class='tbl_row_new'>
          <input type="text" name="lansem6mm_${i}" maxlength="4"
            onkeypress="return acceptNumbersOnlyForModule(event);" id="lansem6mm_${i}"
            onchange="getlantoal('${i}')">
        </td>
        <td class='tbl_row_new'>
          <input type="text" name="lansem6mo_${i}" maxlength="4"
            onkeypress="return acceptNumbersOnlyForModule(event);" id="lansem6mo_${i}"
            onchange="getlantoal('${i}')">
        </td>
        <td class='tbl_row_new'>
          <input type="text" name="lantotalmm_${i}" maxlength="4" readonly
            onkeypress="return acceptNumbersOnlyForModule(event);" id="lantotalmm_${i}">
        </td>
        <td class='tbl_row_new'>
          <input type="text" name="lantotalmo_${i}" maxlength="4" readonly
            onkeypress="return acceptNumbersOnlyForModule(event);" id="lantotalmo_${i}">
        </td>
        <td class='tbl_row_new'>
          <input type="text" name="lanpercentagemm_${i}" maxlength="5" readonly
            style="max-width: 70px" onkeypress="return acceptNumbersOnlyForModule(event);"
            id="lanpercentagemm_${i}">
        </td>
      </tr>`;
    i++;
  }
  table += `</tbody>`;
  $("#lansemdet").html(table);
}

function getlantoal(i) {
  var semmo1 = parseInt($("#lansem1mo_" + i).val());
  var semmm1 = parseInt($("#lansem1mm_" + i).val());

  if (semmo1 > semmm1 && !isNaN(semmm1)) {
    alert("sem 1 obtained marks is greater than the max. marks");
    $("#lansem1mm_" + i).val("");
    $("#lansem1mo_" + i).val("");
    $("#lansem1mo_" + i).focus();
    return;
  }

  var semmo2 = parseInt($("#lansem2mo_" + i).val());
  var semmm2 = parseInt($("#lansem2mm_" + i).val());

  if (semmo2 > semmm2 && !isNaN(semmm2)) {
    alert("sem 2 obtained marks is greater than the max. marks");
    $("#lansem2mm_" + i).val("");
    $("#lansem2mo_" + i).val("");
    $("#lansem2mo_" + i).focus();
    return;
  }

  var semmo3 = parseInt($("#lansem3mo_" + i).val());
  var semmm3 = parseInt($("#lansem3mm_" + i).val());

  if (semmo3 > semmm3 && !isNaN(semmm3)) {
    alert("sem 3 obtained marks is greater than the max. marks");
    $("#lansem3mm_" + i).val("");
    $("#lansem3mo_" + i).val("");
    $("#lansem3mo_" + i).focus();
    return;
  }

  var semmo4 = parseInt($("#lansem4mo_" + i).val());
  var semmm4 = parseInt($("#lansem4mm_" + i).val());

  if (semmo4 > semmm4 && !isNaN(semmm4)) {
    alert("sem 4 obtained marks is greater than the max. marks");
    $("#lansem4mm_" + i).val("");
    $("#lansem4mo_" + i).val("");
    $("#lansem4mo_" + i).focus();
    return;
  }

  var semmo5 = parseInt($("#lansem5mo_" + i).val());
  var semmm5 = parseInt($("#lansem5mm_" + i).val());

  if (semmo5 > semmm5 && !isNaN(semmm5)) {
    alert("sem 5 obtained marks is greater than the max. marks");
    $("#lansem5mm_" + i).val("");
    $("#lansem5mo_" + i).val("");
    $("#lansem5mo_" + i).focus();
    return;
  }

  var semmo6 = parseInt($("#lansem6mo_" + i).val());
  var semmm6 = parseInt($("#lansem6mm_" + i).val());

  if (semmo6 > semmm6 && !isNaN(semmm6)) {
    alert("sem 6 obtained marks is greater than the max. marks");
    $("#lansem6mm_" + i).val("");
    $("#lansem6mo_" + i).val("");
    $("#lansem6mo_" + i).focus();
    return;
  }

  var totobt = 0;
  var totmarks = 0;

  if (
    !isNaN(semmo1) &&
    !isNaN(semmo2) &&
    !isNaN(semmo3) &&
    !isNaN(semmo4) &&
    !isNaN(semmo5) &&
    !isNaN(semmo6)
  ) {
    totobt =
      parseInt(semmo1) +
      parseInt(semmo2) +
      parseInt(semmo3) +
      parseInt(semmo4) +
      parseInt(semmo5) +
      parseInt(semmo6);
    $("#lantotalmo_" + i).val(totobt);
  }

  if (
    !isNaN(semmm1) &&
    !isNaN(semmm2) &&
    !isNaN(semmm3) &&
    !isNaN(semmm4) &&
    !isNaN(semmm5) &&
    !isNaN(semmm6)
  ) {
    totmarks =
      parseInt(semmm1) +
      parseInt(semmm2) +
      parseInt(semmm3) +
      parseInt(semmm4) +
      parseInt(semmm5) +
      parseInt(semmm6);
    $("#lantotalmm_" + i).val(totmarks);
    var totpercetage = (parseInt(totobt) / parseInt(totmarks)) * 100;
    $("#lanpercentagemm_" + i).val(Math.round(totpercetage * 100) / 100);
  }
}

function admissionfee() {
  console.log("kkk");
  $.ajax({
    type: "GET",
    url: $host_url + "admissionfeedetails",

    success: function (response) {
      var { error_code, data, status } = JSON.parse(response);

      // console.log(data["fpaystatus"]);
      // return;
      if (error_code == 0) {
        $("#loadTab").load("admfee.html", function () {
          var html = "";

          html += `<head>
                    <label for="Name" style="padding-top: 17px;"><b style="font-size:17px; padding-left: 10px;">Name</b></label>
                    <b style="padding-left: 141px; padding-right: 15px;">:</b>
                    <h style="font-size:17px;"> ${data["fname"]}</h><br>
                    <label for="Mobile"><b style="font-size:17px; padding-left: 10px;">Application Number</b></label>
                    <b style="padding-left: 19px; padding-right: 15px;">:</b>
                    <h style="font-size:17px;"> ${data["fappno"]}</h><br>
                    <label for="Date"><b style="font-size:17px; padding-left: 10px;">Category</b></label>
                    <b style="padding-left: 115px; padding-right: 15px;">:</b>
                    <h style="font-size:17px;"> ${data["fcategory"]}</h><br>
                    <label for="Date"><b style="font-size:17px; padding-left: 10px;">Reg. No.</b></label>
                    <b style="padding-left: 120px; padding-right: 15px;">:</b>
                    <h style="font-size:17px;"> ${data["fregno"]}</h><br>
                    <label for="Application"><b style="font-size:17px; padding-left: 10px;">College Name</b></label>
                    <b style="padding-left: 74px; padding-right: 15px;">:</b>
                    <h style="font-size:17px;" > ${data["fcollname"]}</h><br>
                    <label for="Status"><b style="font-size:17px; padding-left: 10px;">Degree</b></label>
                    <b style="padding-left: 129px; padding-right: 15px;">:</b>
                    <h style="font-size:17px;"> ${data["fdegree"]}</h><br>
                    <label for="Date"><b style="font-size:17px; padding-left: 10px;">Fee to be Paid</b></label>
                    <b style="padding-left: 70px; padding-right: 15px;">:</b>
                    <h style="font-size:17px;"> ${data["famount"]}</h><br>
                   
                    
                  </head>`;

          html += `</table>`;
          $("#admfee").html(html);

          var html1 = "";

          if (data["fpaymentstatus"] == "success") {
            html1 += `<button class="btn btn-primary btn-sm waves-effect font-16"
    onclick="admPrintApplication('${data["fallotno"]}')">
    Print Application
    </button>`;
          } else {
            html1 += `<button class="btn btn-primary btn-sm waves-effect font-16"
    onclick="admfeepayment('${data["fallotno"]}','${data["fregno"]}')">
    Make Payment
    </button>`;
          }

          html1 += `</table>`;
          $("#button").html(html1);
        });
      }
    },
  });
}

function admPrintApplication(appno) {
  window.open(
    $host_url +
      "admissionfeereport" +
      "&appno=" +
      appno ,
    "_blank"
  );
}


function admfeepayment(appno,fregno)
{
  window.location.href =
      "../Paytm/pgRedirect.php?productinfo=" + appno + "&funivcode=" + '023'+"&fregno="+fregno;
}