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


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

var $host_url =
  "http://" +
  window.location.host +
  "/" +
  window.location.pathname.split("/")[1] +
  "/" +
  window.location.pathname.split("/")[2] +
  "/app.php?a=";

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

var deg;

var gAppNo;

var fappno = "";

var photo_path = "";

var months = "";
function homeLink() {
  var r = confirm("Do You Want To Logout!");
  if (r == true) {
    window.location.href = "pgindex.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";
    }
  }
}

const loadPGAdm = () => {
  // $("#prevPGDet").hide();
  login1();
  $("#success_card").hide();
  $("#fbcuetype").hide();

  $.ajax({
    type: "POST",
    async: false,
    url: $host_url + "getFacultyDegree",
    success: response => {
      var { error_code, data, status } = JSON.parse(response);
      if (error_code == 0) {
        var fmobileno = data.fmobileno;
        var fpaystatus = data.fpaystatus;

        var disable_fields = [
          "fkarstudy_1",
          "fkarstudy_2",
          "radio_1",
          "radio_2",
          "radio_3",
          "fcategory",
          "fdegree1",
          "fdegree2",
          "fdegree3",
          "fdegree4",
          "fdegree5",
          "fdegree6"
        ];

        if (fpaystatus == "success") {
          console.log(fpaystatus);
          for (let i = 0; i < disable_fields.length; i++) {
            console.log(disable_fields[i]);
            $(`#${disable_fields[i]}`).prop("disabled", "disabled");
          }
        }

        $("#fmobileno").val(fmobileno);
        $("#fmobileno").prop("disabled", "disabled");
        var options;
        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>`;
        });
        $("#fdegree1").html(options);
        $("#fdegree2").html(options);
        $("#fdegree3").html(options);
        $("#fdegree4").html(options);
        $("#fdegree5").html(options);
        $("#fdegree6").html(options);
        var year = "";
        for (var j = 2019; 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);
            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>`;
              });
            }

            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 == -1) {
        alert("Something went wrong, Please Try after sometime.");
      }
    }
  });
};

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

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);
};

//================= Load Fee Structure ================//
var totalFee = 0;
const getFeestr = () => {
  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 = ``;
        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);
                console.log(totalFee);
              }
            } else {
              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>`;
              totalFee += Number(el.fmaxfee);
              console.log("ttt", totalFee);
            }
          });
          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);
      }
    });
  }
};

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 = [];
const 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"
];
var feestr = {};

function savepgApplication() {
  jsonObj = [];
  var errcount = 0;
  var missing_fields = [];
  // var photo_path = $("#file").val();

  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");
      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);
    }
  });
  var radio_names = [
    "fgender",
    "fbpl",
    "fogirl",
    "fkarstudy",
    "fkashmir",
    "fhk",
    "fjk",
    "frural",
    "fkannada",
    "fbcue",
    "fbcuetype",
    "fpumat",
    "fqutype",
    "fpubio",
    "fpgdegree"
  ];

  // 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 = {};
      console.log(checkboxes[i].id);
      item["id"] = checkboxes[i].id;
      item["value"] = "Yes";
      jsonObj.push(item);
    } else {
      item = {};
      console.log(checkboxes[i].id);
      item["id"] = checkboxes[i].id;
      item["value"] = "No";
      jsonObj.push(item);
    }
  }
  // radio_names.map((el, i) => {
  //   if (!$('input[name="' + radio_names[i] + '"]').is(":checked")) {
  //     $('input[name="' + radio_names[i] + '"]')
  //       .closest(".form-group")
  //       .find(".fieldError")
  //       .addClass("hasError");
  //     // errcount++;
  //     missing_fields.push(radio_names[i]);
  //     item = {};
  //     item["id"] = radio_names[i];
  //     item["value"] = "NO";
  //     jsonObj.push(item);
  //   } else {
  //     $('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.toUpperCase();
  //     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");
        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("fdegree1", $("#fdegree1").val());
  //======= 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);
    });
  }
  //======= validate all preferences ==========//
  // $("#fdegree1").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);
  //   }
  // });

  $("#prevAcadDet input[type=text]:enabled,#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);
      }
    }
  );

  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);
    });
  }

  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);

  $("#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;
  }

  $.ajax({
    type: "POST",
    url: $host_url + "pgsaveApplication",
    data:
      "fappno=" +
      fappno +
      "&final=" +
      finsub +
      "&feestr=" +
      JSON.stringify(feestr) +
      "&data=" +
      JSON.stringify(jsonObj),
    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();
          $("#personal_det").hide();
          $("#basicDet").hide();
          $("#prevAcadDetCard").hide();
          $("#FeeDet").hide();
          $("#success_card").show();
          makepayment(gAppNo, "041");
        } 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
          });
        }
      }
    }
  });
};