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


Current Path : /var/www/html/studentportal_wait/js_old/
Upload File :
Current File : //var/www/html/studentportal_wait/js_old/MainPage.js

var UNIVNAME, UNIVCODE, FNAME, FREGNO,FDEGREE;
var $host_url = `http://${window.location.host}/${
  window.location.pathname.split("/")[1]
}/app.php?a=`;

function acceptNumbersOnlyForModule(evt) {
  var charCode;
  if (window.event) charCode = window.event.keyCode;
  //if IE
  else charCode = evt.which; //if firefox
  if (charCode > 31 && (charCode < 48 || charCode > 57)) return false;
  return true;
}

function charKeydown(evt) {
  var charCode;
  if (window.event) charCode = window.event.keyCode;
  //for IE
  else charCode = evt.which; //for firefox
  if (charCode == 32)
    //for &lt;space&gt; symbol
    return true;
  if (charCode > 31 && charCode < 65)
    //for characters before 'A' in ASCII Table
    return false;
  if (charCode > 90 && charCode < 97)
    //for characters between 'Z' and 'a' in ASCII Table
    return false;
  if (charCode > 122)
    //for characters beyond 'z' in ASCII Table
    return false;
  return true;
}

function loadMaster() {
  loadProfile();
  //loadExamApplication();
  $.ajax({
    type: "post",
    url: "src/login.php",
    //data:parameters,
    success: function(response) {
      var { status, FUNIVNAME, menu } = JSON.parse(response);
      ({ UNIVCODE } = JSON.parse(response));
      // if (status === "loggedin") {
      // UNIVNAME = FUNIVNAME;
      //   console.log(menu);
      //   var menuhtml = "";

      //   for (let i = 0; i < menu.length; i++) {
      //     menuhtml += `<li ${i == 0 ? 'class = "active p-t-20"' : ""} id="${
      //       menu[i].fmenuid
      //     }" class="listStyl">
      //       <a style="cursor: pointer;" onclick="${menu[i].fclickfuctn}">
      //           <i class="material-icons" style="color: #fff">${
      //             menu[i].ficon
      //           }</i>
      //           <span style="color: #fff">${menu[i].fdispname}</span>
      //       </a>
      //   </li>`;
      //   }

      //   // $("#loadmenu").html(menuhtml);

      //   $("#loadmenu li").click(function() {
      //     // remove classes from all
      //     $("li").removeClass("active");
      //     // add class to the one we clicked
      //     $(this).addClass("active");

      //     $("body").removeClass("overlay-open");
      //     $(".overlay").css("display", "none");
      //   });

      //   // if (UNIVCODE == '001') {
      //   //   $('.open-button').hide();
      //   // }

      //   $("#nav-header").html(UNIVCODE + " - " + UNIVNAME.toLowerCase());
      //   $("#nav-header").css("text-transform", "capitalize");

      //   if (UNIVCODE == "041" || UNIVCODE == "042" || UNIVCODE == "023") {
      //     swal({
      //       title: "Mobile App Available",
      //       text: `<p style="text-align: justify;font-size:16px !important;font-weight:700;">
      //       <b>All examination related alerts will be sent through app notifications in future. Download the app immediately.</b>
      //       </p><br/>
      //       <a href="https://play.google.com/store/apps/details?id=com.uniclare&hl=en_SG"><img style="width:100px;height:35px" src="images/playstore.png" /></a>
      //               <a href="https://itunes.apple.com/us/app/uniclare/id1463149594?mt=8"> <img style="width:100px;height:50px" src="images/App_store.svg"/></a>`,
      //       html: true
      //     });
      //   } else if (UNIVCODE == "001") {
      //   } else {
      //     swal({
      //       title: "DISCLAIMER",
      //       text: `<p style="text-align: justify;font-size:16px !important;font-weight:700;">
      //               For student’s convenience, as of now, we are providing these facilities for free.</p><br>
      //               <p style="text-align: justify;font-size:16px !important;font-weight:700;">
      //               Our aim is to ensure that students get all the
      //               services from the university at their finger tips
      //               and thus have more time for their academic activities</p>`,
      //       html: true
      //     });
      //   }
      // } else {
      //   alert("Please login");
      //   window.location.href = "index.html";
      // }
    }
  });
}

$(function() {
  initLoading();
});
function initLoading() {
  $('[data-toggle="cardloading"]').on("click", function() {
    var effect = $(this).data("loadingEffect");
    var color = $.AdminBSB.options.colors[$(this).data("loadingColor")];

    var $loading = $(this)
      .parents(".card")
      .waitMe({
        effect: effect,
        text: "Loading...",
        bg: "rgba(255,255,255,0.90)",
        color: color
      });

    setTimeout(function() {
      //Loading hide
      $loading.waitMe("hide");
    }, 3200);
  });
}

function signOut() {
  swal(
    {
      title: "Are you sure about logout?",
      type: "warning",
      showCancelButton: true,
      confirmButtonColor: "#DD6B55",
      confirmButtonText: "Logout",
      closeOnConfirm: false
    },
    function() {
      $.ajax({
        type: "post",
        url: "src/logout.php",
        //data:parameters,
        success: function(response) {
          if (response === "logout") {
            window.location.href = "index.html";
          }
        }
      });
      //swal("Deleted!", "Your imaginary file has been deleted.", "success");
    }
  );
}

//var myTimer = setInterval(autoSignOut, 900000);

function autoSignOut() {
  swal(
    {
      title: "Your Session has been expired login again.",
      type: "warning",
      showCancelButton: false,
      confirmButtonColor: "#DD6B55",
      confirmButtonText: "OK",
      closeOnClickOutside: false,
      allowEscapeKey: false,
      closeOnConfirm: false
    },
    function() {
      $.ajax({
        type: "post",
        url: "src/logout.php",
        //data:parameters,
        success: function(response) {
          if (response === "logout") {
            window.location.href = "index.html";
          }
        }
      });
      //swal("Deleted!", "Your imaginary file has been deleted.", "success");
    }
  );
}

function loadApp() {
  loadProfile();

  $.ajax({
    type: "post",
    url: "src/getMenus.php",
    success: function(response) {
      var { status, menu, UNIVCODE, FUNIVNAME } = JSON.parse(response);
      console.log("res", menu, FUNIVNAME);

      UNIVCODE = UNIVCODE;
      if (status === "loggedin") {
        UNIVNAME = FUNIVNAME;

        var menuhtml = `
        <ul class="nav navbar-nav">        
        `;

        menu.forEach((el, i) => {
          // console.log("obj",el,i);

          if (el.children != undefined && el.children.length > 0) {
            menuhtml += `<li ${i == 0 ? 'class = "active p-t-20"' : ""} id="${
              el.fmenuid
            }">
          <a href="javascript:void(0);" class="menu-toggle" >
          <i class="material-icons" style="color: #fff">${el.icon}</i>
          <span style="color: #fff">${el.name}</span></a>

          <ul class="ml-menu" >
          <li ${i == 0 ? 'class = "active "' : ""} id="${el.fmenuid}">
          <a onclick="${el.url}"style="cursor: pointer;" >
          <i class="material-icons" style="color: #fff">${el.icon}</i>
          <span style="color: #fff">${el.name}</span></a>
          </li>
          `;
            //onclick="${el.url}" style="background-image: linear-gradient(to right,#133c55, #3683dc);"

            el.children.map((item, i) => {
              // console.log("children",item)
              menuhtml += `            
            <li ${i == 0 ? 'class = "active"' : ""} id="${item.fmenuid}">
            <a style="cursor: pointer;" onclick="${item.url}">
            <i class="material-icons" style="color: #fff">${item.icon}</i>
            <span style="color: #fff">${item.name}</span></a>
        </li>`;
            });
            menuhtml += `</ul>`;
          } else {
            menuhtml += `
        <li ${i == 0 ? 'class = "active p-t-20"' : ""} id="${el.fmenuid}">
          <a style="cursor: pointer;" onclick="${el.url}">
              <i class="material-icons" style="color: #fff">${el.icon}</i>
              <span style="color: #fff">${el.name}</span>
          </a></li>`;
          }
          // menuhtml += `</li>`;
        });
        menuhtml += `</ul>`;
        // console.log("menuListtt",menuhtml);

        $("#loadmenu").html(menuhtml);

        $("#loadmenu li").click(function() {
          // remove classes from all
          $("li").removeClass("active");
          // add class to the one we clicked
          $(this).addClass("active");

          $("body").removeClass("overlay-open");
          $(".overlay").css("display", "none");
        });

        if (UNIVCODE == "001") {
          $(".open-button").hide();
        }
        //==== toggle dropdown ====//
        (function() {
          $(".menu-toggle").on("click", function(e) {
            var $this = $(this);
            var $content = $this.next();

            if ($($this.parents("ul")[0]).hasClass("list")) {
              var $not = $(e.target).hasClass("menu-toggle")
                ? e.target
                : $(e.target).parents(".menu-toggle");

              $.each(
                $(".menu-toggle.toggled")
                  .not($not)
                  .next(),
                function(i, val) {
                  if ($(val).is(":visible")) {
                    $(val)
                      .prev()
                      .toggleClass("toggled");
                    $(val).slideUp();
                  }
                }
              );
            }

            $this.toggleClass("toggled");
            $content.slideToggle(320);
          });
        })();

        $("#nav-header").html(UNIVCODE + " - " + FUNIVNAME.toLowerCase());
        $("#nav-header").css("text-transform", "capitalize");

        if (UNIVCODE == "041" || UNIVCODE == "042" || UNIVCODE == "023") {
          swal({
            title: "Mobile App Available",
            text: `<p style="text-align: justify;font-size:16px !important;font-weight:700;">
            <b>All examination related alerts will be sent through app notifications in future. Download the app immediately.</b>
            </p><br/>
            <a href="https://play.google.com/store/apps/details?id=com.uniclare&hl=en_SG"><img style="width:100px;height:35px" src="images/playstore.png" /></a>
                    <a href="https://itunes.apple.com/us/app/uniclare/id1463149594?mt=8"> <img style="width:100px;height:50px" src="images/App_store.svg"/></a>`,
            html: true
          });
        } else if (UNIVCODE == "001") {
        } else {
          swal({
            title: "DISCLAIMER",
            text: `<p style="text-align: justify;font-size:16px !important;font-weight:700;">
                    For student’s convenience, as of now, we are providing these facilities for free.</p><br>
                    <p style="text-align: justify;font-size:16px !important;font-weight:700;">
                    Our aim is to ensure that students get all the 
                    services from the university at their finger tips 
                    and thus have more time for their academic activities</p>`,
            html: true
          });
        }
      } else {
        alert("Please login");
        window.location.href = "index.html";
      }
    }
  });
}
var photopath;
function loadProfile() {
  $.blockUI({ message: "<img src='images/Loading_icon.gif' border='0'>" });
  $.ajax({
    type: "post",
    url: "src/profile.php",
    //data:parameters,
    success: function(response) {
      $.unblockUI();
      response = JSON.parse(response);
      if (response.status === "success") {
        FNAME = response.fname;
        FREGNO = response.strRegno;
        FDEGREE = response.fdegree;
        $("#loadtab").load(
          "html_modules/profile.html?v=" + version,
          function() {
            /*$('#studinfo').html(`<tr>
              <td width="17%"><b>Student Name</b></td><td width="2%"> : </td><td width="35%"> ${ response.fname }</td>
              <td width="17%"><b>Register number</b> </td><td width="2%"> : </td><td> ${ response.strRegno.toUpperCase() } </td>
          </tr>
          <tr>
              <td><b>Mobile Number</b></td><td width="2%"> : </td><td>${ response.strMobile }</td>
              <td><b>Email Id</b> </td><td width="2%"> : </td><td> ${ response.strEmail } </td>
          </tr>
          <tr>
              <td><b>Father / Guardian Name</b> </td><td width="2%"> : </td><td> ${ response.ffatname } </td>
              <td><b>Father / Guardian Mobile</b> </td><td width="2%"> : </td><td> ${ response.strParentMob } </td>
          </tr>
          <tr>
              <td><b>College</b> </td><td width="2%"> : </td><td> ${ response.college } </td>
              <td></b> </td><td width="2%"></td><td></td>
          </tr>`);*/

            if (UNIVCODE == "041") {
              $("#pnote").html(`<h4>Note :</h4>
            <ul>
              <li>
                <b>
                  For Subject Changes, Please contact your college and get the
                  changes done. Last date for subject corrections is 22.06.2019
                </b>
              </li>
            </ul>`);
            }

            $("#studinfo").html(`<tr>
                        <td width="35%"><b>Student Name</b></td><td width="2%"> : </td><td width="68%"> ${
                          response.fname
                        }</td>
                    </tr>
                    <tr>
                      <td width="17%"><b>Register number</b> </td><td width="2%"> : </td><td> ${response.strRegno.toUpperCase()} </td>
                    </tr>

                    <tr>
                        <td><b>Mobile Number</b></td><td width="2%"> : </td><td>${
                          response.strMobile
                        }</td>
                    </tr>
                    <tr>
                        <td><b>Email Id</b> </td><td width="2%"> : </td><td> ${
                          response.strEmail
                        } </td>
                    </tr>
                    <tr>
                        <td><b>Father / Guardian Name</b> </td><td width="2%"> : </td><td> ${
                          response.ffatname
                        } </td>
                    </tr>
                    <tr>
                      <td><b>Father / Guardian Mobile</b> </td><td width="2%"> : </td><td> ${
                        response.strParentMob
                      } </td>
                    </tr>
                    <tr>
                        <td><b>College</b> </td><td width="2%"> : </td><td> ${
                          response.college
                        } </td>
                        <td></b> </td><td width="2%"></td><td></td>
                    </tr>`);
            // $('#timetable').html(response.timetable);
            $("#side_name").html(response.fname);
            $("#side_regno").html(response.strRegno.toUpperCase());
            $("#side_degree").html("[" + response.fdegree + "] ");
            $("#side_descpn").html(response.degree);
            $("#idSubjHeader").html(
              `<h2 style="color:white"
              ><center>${response.degree +
                " - " +
                response.strExamdate} Subjects</center></h2>`
            );
            photopath = response.photopath;
            $("#photo").attr("src", photopath);
            $("#profile_photo").attr("src", photopath);

            rgSubject = response.subject;
            var strTheads = `<tr style = "font-family:'Montserrat', sans-serif;font-weight:bold;color: #1f547a;">
                                        <th style = "width:8%;"><center>Sl. No.</center></th>
                                        <th style = "width:10%;" ><center>Subject Code</center></th>
                                        <th style = "width:10%;"><center>Semester</center></th>
                                        <th><center>Subject Name</center></th>
                                      </tr>`;
            var strTbody;
            var i = 1;
            var sem;
            for (let subject in rgSubject) {
              obSubject = rgSubject[subject];
              //console.log(obSubject);
              var sem = romanize(alphabet.indexOf(obSubject["fexamno"]) + 1);
              strTbody += `<tr style = "height:30px;">
                                    <td><center>${i++}</center></td>
                                    <td><center>${
                                      obSubject["fsubcode"]
                                    }</center></td>
                                    <td><center> ${sem} Sem</center></td>
                                    <td>${obSubject["fsubname"]}</td>
                                  </tr>`;
            }
            if (rgSubject.length == 0) $("#idSubjCard").css("display", "none");
            $("#studsubs").html(strTheads + strTbody);
          }
        );
      } else {
      }
    }
  });
}

function loadAttendance() {
  $("#loadtab").load("html_modules/attendance.html?v=" + version, function() {
    new Chart(
      document.getElementById("bar_chart").getContext("2d"),
      getChartJs("bar")
    );
    function getChartJs(type) {
      var config = null;
      var subject;
      var conducted;
      var attended;
      var percent;
      var parameters = "&screen=attendance";
      var rgPerinfo;
      $.blockUI({ message: "<img src='images/Loading_icon.gif' border='0'>" });
      $.ajax({
        type: "post",
        url: "src/attendance.php",
        data: parameters,
        async: false,
        success: function(response) {
          $.unblockUI();
          response = JSON.parse(response);
          //response = responce + ')');
          if (response.status == "success") {
            subject = response.subject;
            conducted = response.conducted;
            attended = response.attended;
            subcode = response.subcode;
            subshort = response.subshort;
            percent = response.percent;
            rgPerinfo = response.rgPerinfo;
            var {
              strRegno,
              strName,
              strDegree,
              strSemester,
              strExam
            } = rgPerinfo;

            $("#idAttHeader").html(
              `<h2><center>${strSemester +
                " - " +
                strExam} Attendance</center></h2>`
            );
            /*$("#studinfo").append(`<tr><td width='20%'><b>Reg. No.  </td><td> : ${ strRegno }
                      </b></td></tr><tr><td width='20%'><b>Student Name  </td><td> : ${ strName }
                      </b></td></tr><tr><td width='20%'><b>Degree </td><td> : ${ strDegree }</b></td></tr>
                      <tr><td width='20%'><b>Semester </td><td> : ${ strSemester + " - " + strExam }</b></td></tr>`);*/
            var conducted_arr = $.map(conducted, el => {
              return parseInt($.trim(el));
            });
            var attend_arr = $.map(attended, el => {
              return parseInt($.trim(el));
            });
            var rgPercent = new Array();
            var rgFillcolor = new Array();
            for (let i in attend_arr) {
              rgPercent[i] =
                Math.round(((attend_arr[i] * 100) / conducted_arr[i]) * 100) /
                100;
              if (rgPercent[i] >= 75.0)
                rgFillcolor.push("rgb(57, 173, 68, 0.7)");
              else rgFillcolor.push("rgb(211, 29, 38, 0.7)");
            }
            if (type === "bar") {
              config = {
                type: "bar",
                data: {
                  labels: subshort,
                  datasets: [
                    {
                      label: "Conducted",
                      data: conducted_arr,
                      backgroundColor: "rgba(0, 188, 212, 0.7)"
                    },
                    {
                      label: "Attended",
                      data: attend_arr,
                      backgroundColor: rgFillcolor
                    }
                  ]
                },
                options: {
                  scales: {
                    yAxes: [
                      {
                        ticks: {
                          beginAtZero: true
                        }
                      }
                    ]
                  }
                }
              };
            }

            var table = `<table class="m-b-20 table table-condensed table-bordered table-striped table-hover">
                          <tr style = "height:40px;background-color: #184F76 !important;color: #fff;">
                              <th style = "width:8%;"><center>Sl. No. </center></th>
                              <th style = "width:10%;"><center>Subject Code</center></th>
                              <th style = "width:10%;"><center>Short Name</center></th>
                              <th><center>Subject Name</center></th>
                              <th style = "width:10%;"><center>Classes Conducted</center></th>
                              <th style = "width:10%;"><center>Classes Attended</center></th>
                              <th style = "width:8%;"><center>Percentage (%)</center></th>
                          </tr>`;
            for (let i in subject) {
              table += `<tr>
                              <td><center> ${parseInt(i) + 1} </center></td>
                              <td><center> ${subcode[i]} </center></td>
                              <td>${subshort[i]}</td>
                              <td>${subject[i]}</td>
                              <td><center>${conducted_arr[i]}</center></td>
                              <td><center>${attend_arr[i]}</center></td>
                              <td><center>${percent[i]}</center></td>
                          </tr>`;
            }
            table += `</table>`;
            $("#att_table").html(table);
          } else {
            swal(
              {
                title: "Attendance Not Available",
                type: "warning",
                showCancelButton: false,
                confirmButtonColor: "#5495ff",
                confirmButtonText: "OK",
                closeOnConfirm: false
              },
              function(isConfirm) {
                if (isConfirm) swal.close();
                loadProfile();
                $("#profile").addClass("active");
                $("#attendanceMenu").removeClass("active");
              }
            );
          }
        }
      });

      return config;
    }
  });
}

function loadIA() {
  var config = null;
  var FCSUBCODE;
  var conducted;
  var attended;
  var percent;
  var parameters = "&screen=iamarks";
  var fname, fexamname, fregno, fexamdate, fdegree, fvalmax;
  $.blockUI({ message: "<img src='images/Loading_icon.gif' border='0'>" });
  $.ajax({
    type: "post",
    url: "src/iamarks.php",
    data: parameters,
    success: function(response) {
      $.unblockUI();
      response = JSON.parse(response);
      if (response.error_code == 0) {
        swal(
          {
            title: response.data,
            type: "warning",
            showCancelButton: false,
            confirmButtonColor: "#5495ff",
            confirmButtonText: "OK",
            closeOnConfirm: false
          },
          function(isConfirm) {
            if (isConfirm) swal.close();
            loadProfile();
            $("#profile").addClass("active");
            $("#IaMarksMenu").removeClass("active");
          }
        );
      } else {
        $("#loadtab").load(
          "html_modules/internalAssessment.html?v=" + version,
          function() {
            fcsubcode = response.fcsubcode;
            fsubname = response.fsubname;
            fvalmax = response.fvalmax;
            fmarks = response.fmarks;
            ({ fname, fexamname, fregno, fexamdate, fdegree } = response);

            $("#idIAMarksHeader").html(
              `<h5 style="color:#fff"> Internal Assessment Details </h5>`
            );

            $("#idIAName")
              .html(
                `<h4 style="line-height:2rem">
              ${fexamdate} IA Marks
              </h4>`
              )
              .css({ "background-color": "lightgrey", padding: "10px" });

            /*$("#studinfo").append(`<tr><td width='20%'><b>Reg. No.  </td><td> : ${fregno}
                </b></td></tr><tr><td width='20%'><b>Student Name  </td><td> : ${fname}
                </b></td></tr><tr><td width='20%'><b>Degree </td><td> : ${ fdegree }</b></td></tr>
                <tr><td width='20%'><b>Semester </td><td> : ${ fexamname + " - " +fexamdate }</b></td></tr>`);

*/
            var table = `<table class="m-b-20 table table-condensed table-bordered table-striped table-hover">
                        <tr style = "background-color: #184F76 !important;color: #fff;"><th style = "width:8%;"><center>Sl. No.</center></th>
                        <th style = "width:10%;" ><center>Subject Code</center></th>
                        <th><center>Subject Name</center></th>
                        <th style = "width:10%;"><center>Maximum Marks</center></th> 
                        <th style = "width:10%;"><center>Secured Marks</center></th>`;
            for (let i in fcsubcode) {
              table += `<tr style = "height:30px;"><td><center>${parseInt(i) +
                1}</center></td>
                <td><center>${fcsubcode[i]}</center></td>
                <td>${fsubname[i]}</td>
                <td><center>${fvalmax[i]}</center></td>
                <td><center>${fmarks[i]}</center></td></tr>`;
            }
            table += `</table>`;
            $("#ia_table_det").html(table);
          }
        );
      }
    }
  });
}

var alphabet = [
  "A",
  "B",
  "C",
  "D",
  "E",
  "F",
  "G",
  "H",
  "I",
  "J",
  "K",
  "L",
  "M",
  "N",
  "O",
  "P",
  "Q",
  "R",
  "S",
  "T",
  "U",
  "V",
  "W",
  "X",
  "Y",
  "Z"
];

function romanize(num) {
  if (!+num) return NaN;
  var digits = String(+num).split(""),
    key = [
      "",
      "C",
      "CC",
      "CCC",
      "CD",
      "D",
      "DC",
      "DCC",
      "DCCC",
      "CM",
      "",
      "X",
      "XX",
      "XXX",
      "XL",
      "L",
      "LX",
      "LXX",
      "LXXX",
      "XC",
      "",
      "I",
      "II",
      "III",
      "IV",
      "V",
      "VI",
      "VII",
      "VIII",
      "IX"
    ],
    roman = "",
    i = 3;
  while (i--) roman = (key[+digits.pop() + i * 10] || "") + roman;
  return Array(+digits.join("") + 1).join("M") + roman;
}

function loadexamtimetable() {
  var config = null;
  var fqpcode;
  var fdoe;
  var fdescpn;
  var parameters = "&screen=examtimetable";
  var fname, fexamname, fregno, fexamdate, fdegree, strCentre, rgExamno;
  $.blockUI({ message: "<img src='images/Loading_icon.gif' border='0'>" });
  $.ajax({
    type: "post",
    url: "src/examtimetable.php",
    data: parameters,
    success: function(response) {
      $.unblockUI();
      response = JSON.parse(response);
      if (response.error_code == 0) {
        swal(
          {
            title: "Exam Time Table Not Available",
            type: "warning",
            showCancelButton: false,
            confirmButtonColor: "#5495ff",
            confirmButtonText: "OK",
            closeOnConfirm: false
          },
          function(isConfirm) {
            if (isConfirm) swal.close();
            loadProfile();
            $("#profile").addClass("active");
            $("#examTTMenu").removeClass("active");
          }
        );
      } else {
        $("#loadtab").load(
          "html_modules/examtimetable.html?v=" + version,
          function() {
            fqpcode = response.fqpcode;
            fsubname = response.fsubname;
            fansbookno = response.fansbookno;
            fdoe = response.fdoe;
            fdescpn = response.fdescpn;

            ({
              fname,
              fexamname,
              fregno,
              fexamdate,
              fdegree,
              strCentre,
              rgExamno
            } = response);

            var romanExam = rgExamno.map(no => {
              return romanize(alphabet.indexOf(no) + 1);
            });

            $("#idExamTTHead").html(
              `<h5 style="color:#fff">Exam Time Table</h5>`
            );

            $("#examTTName")
              .html(
                `<h4 style="line-height:2rem">
              Time Table for ${fexamdate}
              </h4>`
              )
              .css({ "background-color": "lightgrey", padding: "10px" });

            $("#idCenterDet")
              .html(`<p>Exam Center : <b> ${strCentre}</b></p>`)
              .css({ padding: "10px" });

            var table = `<table class="table table-condensed table-bordered table-striped table-hover" style="margin:0px">
                      <tr style = "height:40px;background-color: #184F76 !important;color: #fff;">
                      <th style = "width:5%;"><center>Sl. No.</center></th>
                      <th><center>Sem.</center></th>
                      <th style = "width:5%;" ><center>QP Code</center></th>
                      <th><center>Subject Name</center></th>
                      <th style = "width:10%;" ><center>Exam Date</center></th>
                      <th style = "width:18%;" ><center>Time</center></th>
                      <th style = "width:10%;" ><center>Ans. Book No.</center></th>
                      <th><center>Action</center></th>
                      </tr>`;
            for (let i in fqpcode) {
              //console.log(fdoe[i]);
              table += `<tr style = "height:30px;">
              <td><center>${parseInt(i) + 1}</center></td>
              <td><center>${romanExam[i]}</center></td>
              <td id = 'qpcode_${i}'>${fqpcode[i]}</td>
              <td>${fsubname[i]}</td>
              <td>${fdoe[i]}</td>
              <td><center>${fdescpn[i]}</center></td>
              <td><input type = 'text' minlength="5" maxlength="10" id = 'ansbookno_${i}' value = '${
                fansbookno[i]
              }'/></td>
              <td><center><button onClick="saveAnsBook('${i}')" class="btn btn-success">Save</button></center></td>
              </tr>`;
            }
            table += `</table>`;

            $("#examtimetable_table_det").html(table);
          }
        );
      }
    }
  });
}

function practicaltimetable() {
  var config = null;
  var fcsubcode;
  var fdoe;
  var fdescpn;

  var parameters = "&screen=examtimetable";
  var fname, fexamname, fregno, fexamdate, fdegree, exam, centrename, fexamno;
  $.blockUI({ message: "<img src='images/Loading_icon.gif' border='0'>" });
  $.ajax({
    type: "post",
    url: "src/practicaltimetable.php",
    data: parameters,
    success: function(response) {
      $.unblockUI();
      response = JSON.parse(response);
      if (response.error_code == 0) {
        swal(
          {
            title: "Practical Time Table Not Available",
            type: "warning",
            showCancelButton: false,
            confirmButtonColor: "#5495ff",
            confirmButtonText: "OK",
            closeOnConfirm: false
          },
          function(isConfirm) {
            if (isConfirm) swal.close();
            loadProfile();
            $("#profile").addClass("active");
            $("#examPttMenu").removeClass("active");
          }
        );
      } else {
        $("#loadtab").load(
          "html_modules/practicaltimetable.html?v=" + version,
          function() {
            fcsubcode = response.fcsubcode;
            //console.log(fcsubcode);
            fsubname = response.fsubname;
            fexamdate = response.fexamdate;
            //console.log(response.exam);
            exam = response.exam;
            fexamno = response.fexamno;
            fexamtime = response.fexamtime;
            fbatch = response.fbatch;
            fdescpn = response.fdescpn;

            ({ fname, fexamname, fregno, fdegree, centrename } = response);

            /*$("#studinfo").append(`<tr><td width='20%'><b>Reg. No.  </td><td> : ${fregno}
              </b></td></tr><tr><td width='20%'><b>Student Name  </td><td> : ${fname}
              </b></td></tr><tr><td width='20%'><b>Degree </td><td> : ${ fdegree }
              </b></td></tr>`);*/
            var alphabet = [
              "A",
              "B",
              "C",
              "D",
              "E",
              "F",
              "G",
              "H",
              "I",
              "J",
              "K",
              "L",
              "M",
              "N",
              "O",
              "P",
              "Q",
              "R",
              "S",
              "T",
              "U",
              "V",
              "W",
              "X",
              "Y",
              "Z"
            ];
            var romanexam = fexamno.map(no => {
              return romanize(alphabet.indexOf(no) + 1);
            });

            $("#idPrTtHeader").html(
              `<h5 style="color:#fff">Practical Time Table</h5>`
            );

            $("#prTTName")
              .html(
                `<h4 style="line-height:2rem">
              Time Table for ${exam} Examination
              </h4>`
              )
              .css({ "background-color": "lightgrey", padding: "10px" });

            $("#idprCenterDet")
              .html(`<p>Exam Center : <b> ${centrename}</b></p>`)
              .css({ padding: "10px" });

            var table = `<table class="table table-condensed table-bordered table-striped table-hover" style="margin:0px">
                      <tr style = "height:40px;background-color: #184F76 !important;color: #fff;">
                      <th style = "width:5%;"><center>Sl. No.</center></th>
                      <th style = "width:5%;"><center>Sem.</center></th>
                      <th style = "width:9%;" ><center>Subject Code</center></th>
                      <th><center>Subject Name</center></th>
                      <th><center>Exam Date</center></th> 
                      <th><center>Exam Time </center></th> 
                      <th><center>Batch</center></th></tr>`;
            for (let i in fcsubcode) {
              //console.log(fexamdate[i]);
              table += `<tr style = "height:30px;">
              <td><center>${parseInt(i) + 1}</center></td>
              <td><center>${romanexam[i]}</center></td>
              <td><center>${fcsubcode[i]}</center></td>
              <td>${fsubname[i]}</td>
              <td>${fexamdate[i]}</td> 
              <td><center>${fexamtime[i]}</center></td>
              <td><center>${fbatch[i]}</center></td></tr>`;
            }
            table += `</table>`;

            $("#practicaltimetable_table_det").html(table);
          }
        );
      }
    }
  });
}

function loadChangeMobNum() {
  $("#loadtab").load("html_modules/chngMobNum.html?v=" + version, function() {
    $(document).ready(function() {
      $("#newMobDiv").hide();
      $("#shwOTP").hide();
    });
  });
}

function getNewMob() {
  var opw = $("#passwd").val();
  var newMN = $("#newMob").val();

  if (newMN == "") {
    swal(
      {
        title: "Mobile Number and Password field cannot be empty",
        type: "warning",
        showCancelButton: false,
        confirmButtonColor: "#5495ff",
        confirmButtonText: "OK",
        closeOnConfirm: false
      },
      function(isConfirm) {
        if (isConfirm) swal.close();
      }
    );
  }

  var parameters = `&mobile=${newMN}&oldPasswd=${opw}`;

  $.ajax({
    type: "post",
    url: "src/chngMobNum.php?action=chkUser",
    data: parameters,
    success: function(response) {
      response = JSON.parse(response);
      var { error_code, data, status } = response;
      if (error_code === 0) {
        console.log("response", response);
        // $("#currpswd").hide();
        // $("#newMobDiv").show();
        $("#shwOTP").show();
      } else {
        swal(
          {
            title:
              "Data was not found, please try after sometime or Enter Valid Password",
            type: "warning",
            showCancelButton: false,
            confirmButtonColor: "#5495ff",
            confirmButtonText: "OK",
            closeOnConfirm: false
          },
          function(isConfirm) {
            if (isConfirm) swal.close();
          }
        );
      }
    }
  });
}

function verifyOTP() {
  var parameters = `&mobile=${$("#newMob").val()}
  &smsotp=${$("#smsotp").val()}`;
  var host_url =
    "http://" +
    window.location.host +
    "/" +
    window.location.pathname.split("/")[1] +
    "/index.html";

  $.ajax({
    type: "post",
    url: "src/chngMobNum.php?action=verifyotp",
    data: parameters,
    success: function(response) {
      console.log("resss", response);
      var { status, error_code } = JSON.parse(response);
      if (error_code == 1) {
        swal(
          {
            title:
              "Your Mobile have been updated successfully, Login with new password and mobile No.",
            text: "Click OK to continue",
            type: "success",
            showCancelButton: false,
            confirmButtonColor: "#5495ff",
            confirmButtonText: "OK",
            closeOnConfirm: false
          },
          function(isConfirm) {
            if (isConfirm) swal.close();
            window.location.href = host_url;
          }
        );
      } else {
        swal({
          title: "Invalid OTP. Try resend OTP.",
          type: "warning",
          showCancelButton: false,
          confirmButtonColor: "#5495ff",
          confirmButtonText: "OK",
          closeOnConfirm: false
        });
      }
    }
  });
}

function loadOldQP() {
  $("#loadtab").load(
    "html_modules/oldQPDownload.html?v=" + version,
    function() {
      $.ajax({
        type: "post",
        url: "src/oldQPDownload.php?action=getExmname",
        success: function(response) {
          response = JSON.parse(response);
          var { error_code, data, status } = response;
          if (error_code === 0) {
            var exmname = data.fexamname;
            var options;
            options += `<option value="">--Select--</option>`;
            var i = 0;
            for (var key in data) {
              options += `<option value="${data[i].fexamno}">${data[i].fexamname}</options>`;
              i++;
            }
            $("#exmname").html(options);
          } else {
            swal(
              {
                title: "Something went wrong, please try after sometime",
                type: "warning",
                showCancelButton: false,
                confirmButtonColor: "#5495ff",
                confirmButtonText: "OK",
                closeOnConfirm: false
              },
              function(isConfirm) {
                if (isConfirm) swal.close();
                loadProfile();
                $("#profile").addClass("active");
                // $("#examappmenu").removeClass("active");
              }
            );
          }
        }
      });
    }
  );
}

function getExamDate() {
  var exmname = $("#exmname").val();
  console.log(exmname);
  $.ajax({
    type: "post",
    url: "src/oldQPDownload.php?action=getExamDate&fexmname=" + exmname,
    success: function(response) {
      response = JSON.parse(response);
      var { error_code, data, status } = response;
      if (error_code === 0) {
        var exmname = data.fexamdate;
        var options;
        options += `<option value="">--Select--</option>`;
        var i = 0;
        for (var key in data) {
          options += `<option value="${data[i].fexamdate}">${data[i].fexamdate}</options>`;
          i++;
        }
        $("#exmdate").html(options);
      }
      // else {
      //   swal({
      //     title: 'soemthing went wrong, Please try after sometime',
      //     type: "warning",
      //     showCancelButton: false,
      //     confirmButtonColor: "#5495ff",
      //     confirmButtonText: "OK",
      //     closeOnConfirm: false
      //   }, function (isConfirm) {
      //     if (isConfirm)
      //       swal.close();
      //     loadProfile();
      //     $("#profile").addClass("active");
      //     // $("#examappmenu").removeClass("active");
      //   });
      // }
    }
  });
}

function getOldQP() {
  var exmname = $("#exmname").val();
  var exmdate = $("#exmdate").val();
  console.log(exmdate, exmname);
  $.ajax({
    type: "post",
    url:
      "src/oldQPDownload.php?action=getOldQP&fexmname=" +
      exmname +
      "&fexmdate=" +
      exmdate,
    success: function(response) {
      response = JSON.parse(response);
      var { error_code, data, status } = response;
      if (error_code === 0) {
        console.log(data);
        var html = "";
        html = `<table class="table table-bordered table-hover table-sm" style="margin-left:12px" >`;
        html += ` <tr class='bg-teal'>
        <th><center>Sl. No.</center></th>
        <th><center>Subject Name</center></th>
        <th><center>Exam date</center></th>
        <th><center>Files</center></th>
        </tr>`;
        data.forEach((el, i) => {
          html += `
          <tr>
          <td><center>${i + 1}</center></td>
          <td>${el.fsubname}</td>
          <td><center>${el.fexamdate}</center></td>
          <td style='text-align:center'><a href='qparchive/${
            el.ffilename
          }' download>Download</a></td>
          </tr>
          `;
        });
        html += `</table>`;
        // console.log(html);
        $("#shwTbl").html(html);
      }
    }
  });
}

function loadExamApplication2() {
  $("#loadtab").load(
    "html_modules/examApplication1.html?v=" + version,
    function() {
      if (UNIVCODE != "038") {
        $.ajax({
          type: "post",
          url: "src/examapp_iframe.php",
          success: function(response) {
            response = JSON.parse(response);
            if (response.status === "success") {
              $("iframe").attr("src", response.url);
            } else {
              swal(
                {
                  title: "Exam Application Form Blocked",
                  type: "warning",
                  showCancelButton: false,
                  confirmButtonColor: "#5495ff",
                  confirmButtonText: "OK",
                  closeOnConfirm: false
                },
                function(isConfirm) {
                  if (isConfirm) swal.close();
                  loadProfile();
                  $("#profile").addClass("active");
                  $("#examappmenu").removeClass("active");
                }
              );
            }
          }
        });
      } else {
        swal(
          {
            title: "Exam Application Form Not Available",
            type: "warning",
            showCancelButton: false,
            confirmButtonColor: "#5495ff",
            confirmButtonText: "OK",
            closeOnConfirm: false
          },
          function(isConfirm) {
            if (isConfirm) swal.close();
            loadProfile();
            $("#profile").addClass("active");
            $("#examappmenu").removeClass("active");
          }
        );
      }
    }
  );
}

function loadExamApplication() {
  parameters =
    "&catcode=" + $("#catcode").val() + "&feetype=" + $("#feetype").val();
}

var examAppJson;
var examAppData;

var GrandTotal = 0;
var semTtl = 0;
var feeTotal = 0;

var gExamAppSemData = [];
var gFreshExam = "";

function loadExamApplication1() {
  $("#loadtab").load(
    "html_modules/examApplication.html?v=" + version,
    function() {
      $.ajax({
        type: "get",
        url: `${$host_url}getExamapplication&univcode=041`, // ${UNIVCODE}
        //data:parameters,
        success: function(response) {
          var { error_code, status, data, FRESHEXAM, exmNos, msg } = JSON.parse(
            response
          );
          // console.log(JSON.parse(response));
          if (error_code === -1) {  //----- Ex. REGNO: 8073092172 --------//
            swal(
              {
                title: msg,
                type: "warning",
                showCancelButton: false,
                confirmButtonColor: "#5495ff",
                confirmButtonText: "OK",
                closeOnConfirm: false
              },
              function(isConfirm) {
                if (isConfirm) swal.close();
                loadProfile();
                $("#profile").addClass("active");
                $("#examappmenu").removeClass("active");
              }
            );
          }
          else {
            //===================== Select Semester Table ===============//
            var tr1 = `<tr style="text-align:center">`;
            var tblExamData = `<tr style="text-align:center">`;

            var tr2 = `<tr style="text-align:center">`;

            exmNos.exam_detail_radioButton_table_data.map(
              (el, i) => {

                tr1 += `<td style="font-weight: 900">
                ${romanize(alphabet.indexOf(el.id) + 1)}
                </td>
                `;

                tblExamData += `
                <td>`;

                if (el.tableDataValue == "Radio") {
                  tblExamData += `<input name="examno" class="with-gap" type="radio" id="exam${el.id}" 
                  onChange="ShwExamDet('${el.id}')" value="${el.id}" />
                  <label for="exam${el.id}"></label>`;
                  tr2 += `<td id="sem_totfee_${el.id}" style="font-weight: 600">
                  0
                </td>`;
                } else {
                  tblExamData += `${el.tableDataValue}`;
                  tr2 += `<td id="sem_totfee_${el.id}" style="font-weight: 600">
                </td>`;
                }
                tblExamData += `</td>`;
              }
            );


            tblExamData += `</tr>`;
            tr1 += `</tr>`;
            tr2 += `</tr>`;
            $("#idExmNoTbl").append(tr1+tblExamData+tr2);
            $("#exam" + FRESHEXAM).attr("checked", "checked");

            //================== Semester Details Table ======================//
            var grand_total = 0;
            examAppData = data;

            gExamAppSemData = data;
            gFreshExam = FRESHEXAM;

            callRebuildExamApp();

            data.map((item,index)=>{
          
              var options = '<option>Select</option>';                

              item.sub_options.map((opt,idx)=>{
                options += `<option name="${opt.code}" value="${opt.code}_${opt.FSUBNAME}">
                ${opt.code}</options>`;
              })

              var len = item.sem_totsub-item.sub_details.length

              if (FRESHEXAM != undefined && FRESHEXAM != "" && FRESHEXAM == item.FEXAMNO) {
                var subjectDetails = ``;
                  
                subjectDetails += `
                    <table class="table table-bordered table-hover" id="MainTbl${item.FEXAMNO}">
                    <thead style = "height:40px;background-color: #184F76 !important;color: #fff;">
                    <tr><td>SL.No.</td>`;
                item.subject_table_header.forEach((el, i) => {
                  if (el == "Checkbox") {
                    subjectDetails += `<td class="text-center">
                      Pass Month
                      </td>`;
                  } else {
                      subjectDetails += `<td>${el}</td>`;
                  }
                });
                subjectDetails += `</tr></thead><tbody>`;
    
                item.sub_details.map((el, i) => {
                  subjectDetails += `<tr>
                    <td class="text-center">${i + 1}</td>
                    <td class="text-center SubjectCode">${el.f_sub_code}
                    <input type="hidden" class="subcode" id="subcode${item.FEXAMNO}${i}" value="${el.f_sub_code}" /></td>
                    <td class="text-center">${el.qp_code}</td>
                    <td class="subjectName" id="parsubname_${item.FEXAMNO}_${el.f_sub_code}">${el.f_sub_name}</td>`;
                  if (el.fpass_month == "CheckBox") {
                    subjectDetails += `<td class="text-center">
                      <input type="checkbox" class="filled-in" id="${el.f_sub_code}"
                        checked="checked" onChange="getSubNames('${item.FEXAMNO}',${i})"/>
                      <label for="${el.f_sub_code}" style="font-size:14px !important;"></label>
                      <input type="hidden" id="exam${item.FEXAMNO}thcnt" value="${el.pr_cnt}" />
                      <input type="hidden" id="exam${item.FEXAMNO}prcnt" value="${el.th_cnt}" />
                      </td>`;
                  } else {
                    subjectDetails += `<td>${el.fpass_month}</td>`;
                  }

                  subjectDetails += `</tr>`;
                });
                
                //=================  Sub Options ===============//                
                for(var i=0;i<len;i++){
                  if(options != "" && item.sub_details.length<item.sem_totsub){
                    subjectDetails += `<tr calss="">
                    <td class="text-center ">${item.sub_details.length+1}</td>
                    <td class="text-center SubjectCode" id="exam${item.FEXAMNO}subcode${i}">
                    <input type="hidden" class="subcode" id="subcode${item.FEXAMNO}${i}" value="" />
                    <select name="subjectOpt" class="subOpt" id="exam${item.FEXAMNO}sub${i}" onChange="getSubNames('${item.FEXAMNO}',${i})">${options}</select>
                    </td>
                    <td class="text-center" id="exam${item.FEXAMNO}qpcode${i}"></td>
                    <td class="subjectName" id="exam${item.FEXAMNO}subname${i}"></td>
                    <td class="text-center"  id="exam${item.FEXAMNO}checkbox${i}">
                    
                    </td></tr>`;
                  }
                }
                //================= end Sub Options ===============//                

                subjectDetails += `</tbody></table>`;
     
                $(`#idSubDetails${item.FEXAMNO}`).html(subjectDetails);

                  //======================== Fee Details ===========================//
                var FeeDetailsExmAppl = ``;
                item.fees_table_data.map((el, i) => {
                  console.log("feesTblData",el,i)
                  var headcode =  el.FHEADCODE.split(" ").join("");
                  FeeDetailsExmAppl += `<div class="row"> 
                  <div class="col-lg-3 col-md-3 col-xs-6">
                  ${el.FHEADCODE} 
                  </div>
                  <div>: </div>
                  <div class="col-lg-4 col-md-4 col-xs-4 eachAmt" id="idFeeDet_${item.FEXAMNO}_${headcode}">
                  ${el.max_fee}
                  <input type="hidden" value="${el.TH_FFEE}" id="TH_${headcode}${item.FEXAMNO}"/>
                  <input type="hidden" value="${el.FPRFEE}" id="PR_${headcode}${item.FEXAMNO}"/>
                  <input type="hidden" value="${el.max_fee}" id="MaxFee_${headcode}${item.FEXAMNO}"/>    

                  </div>
                  </div>`;
                  if(headcode != '01EXAMFEE')
                  feeTotal += parseInt(el.max_fee);
                });
    
                var FeeDetailsTtl = `
                <div class="row">
                <div class="col-lg-3 col-md-3 col-xs-6">Total            </div>
                <div>: </div>
                <div class="col-lg-4 col-md-4 col-xs-4" id="ttlamt${item.FEXAMNO}">
                <input type="hidden" value="${feeTotal}" id="examTtl${item.FEXAMNO}"/>
                <strong>${feeTotal}</strong>
                </div>`;
    
                $(`#idFeeDetailsExmApp${item.FEXAMNO}`).html(FeeDetailsExmAppl);
                $(`#idFeeDetailsTtl${item.FEXAMNO}`)
                  .html(FeeDetailsTtl)
                  .css({
                    "background-color": "lightgrey",
                    padding: "1% 2% 2% 5%"
                  });
                  
                } else {//=== other than fresh exam =====//
                  console.log("idSubDetails null");
                  var subjectDetails =``;
                  subjectDetails += `
                    <table class="table table-bordered table-hover" id="MainTbl${item.FEXAMNO}">
                    <thead style = "height:40px;background-color: #184F76 !important;color: #fff;">
                    <tr><td>SL.No.</td>`;
                  item.subject_table_header.forEach((el, i) => {
                    if (el == "Checkbox") {
                      subjectDetails += `<td class="text-center">
                      Pass Month
                      </td>`;
                    } else {
                      subjectDetails += `<td>${el}</td>`;
                    }
                  });
                  subjectDetails += `</tr></thead><tbody>`;
  
                  item.sub_details.map((el, i) => {
                    subjectDetails += `<tr>
                      <td class="text-center">${i + 1}</td>
                      <td class="text-center SubjectCode">${el.f_sub_code}
                      <input type="hidden" class="subcode" id="subcode${item.FEXAMNO}${i}" value="${el.f_sub_code}"/></td>
                      <td class="text-center">${el.qp_code}</td>
                      <td class="subjectName">${el.f_sub_name}</td>`;
                    if (el.fpass_month == "CheckBox") {
                      subjectDetails += `<td class="text-center">
                        <input type="checkbox" class="filled-in" id="${el.f_sub_code}"
                        onChange="getSubNames('${item.FEXAMNO}',${i})"/>
                        <label for="${el.f_sub_code}" style="font-size:14px !important;"></label>
                        <input type="hidden" id="exam${item.FEXAMNO}thcnt" />
                        <input type="hidden" id="exam${item.FEXAMNO}prcnt" />
                        </td>`;
                    } else {
                      subjectDetails += `<td>${el.fpass_month}</td>`;
                    }
                    subjectDetails += `</tr>`;
                  });
                  //============= sub OPtions =========//

                  for(var i=0;i<len;i++){

                    if(options != "" && item.sub_details.length<item.sem_totsub){
                      subjectDetails += `<tr>
                      <td class="text-center">${item.sub_details.length+i+1}</td>
                      <td class="text-center SubjectCode" id="exam${item.FEXAMNO}subcode${i}">
                      <input type="hidden" class="subcode" id="subcode${item.FEXAMNO}${i}" value="" />
                      <select class="subOpt" name="subjectOpt" id="exam${item.FEXAMNO}sub${i}" onChange="getSubNames('${item.FEXAMNO}',${i})">${options}</select>
                      </td>
                      <td class="text-center" id="exam${item.FEXAMNO}qpcode${i}"></td>
                      <td class="subjectName" id="exam${item.FEXAMNO}subname${i}"></td>
                      <td class="text-center"  id="exam${item.FEXAMNO}checkbox${i}">
                      
                      </td></tr>`;
                    }
                  }
                  subjectDetails += `</tbody></table>`;
    
                  $(`#idSubDetails${item.FEXAMNO}`).html(subjectDetails);
                  $(`#idSubDetails${item.FEXAMNO}`).hide();


                  //==================== Fee Details ============//
                  var FeeDetailsExmAppl = ``;
                  item.fees_table_data.map((el, i) => {
                    var headcode =  el.FHEADCODE.split(" ").join("");
                    FeeDetailsExmAppl += `<div class="row"> 
                    <div class="col-lg-3 col-md-3 col-xs-6">
                    ${el.FHEADCODE} 
                    </div>
                    <div>: </div>
                    <div class="col-lg-4 col-md-4 col-xs-4 eachAmt" id="idFeeDet_${item.FEXAMNO}_${item.headcode}">
                    ${el.max_fee}
                    <input type="hidden" value="${el.TH_FFEE}" id="TH_${headcode}${item.FEXAMNO}"/>
                    <input type="hidden" value="${el.FPRFEE}" id="PR_${headcode}${item.FEXAMNO}"/>
                    <input type="hidden" value="${el.max_fee}" id="MaxFee_${headcode}${item.FEXAMNO}"/>
        
                    </div>
                    </div>`;
                    if(headcode != '01EXAMFEE')
                      feeTotal += parseInt(el.max_fee);
                  });//marks card fee n etc
    
                  var FeeDetailsTtl = `
                  <div class="row">
                  <div class="col-lg-3 col-md-3 col-xs-6">Total            </div>
                  <div>: </div>
                  <div class="col-lg-4 col-md-4 col-xs-4" id="ttlamt${item.FEXAMNO}">
                  <input type="hidden" value="${feeTotal}" id="examTtl${item.FEXAMNO}"/>
                  <strong>${feeTotal}</strong>
                  </div>`;
      
                  $(`#idFeeDetailsExmApp${item.FEXAMNO}`).html(FeeDetailsExmAppl);
                  $(`#idFeeDetailsTtl${item.FEXAMNO}`)
                    .html(FeeDetailsTtl)
                    .css({
                      "background-color": "lightgrey",
                      padding: "1% 2% 2% 5%"
                    });

                    $(`#idFeeDetailsExmApp${item.FEXAMNO}`).hide();
                    $(`#idFeeDetailsTtl${item.FEXAMNO}`).hide(); 
                  }
            })
        
            //============= Dispaly Grand Total ================//
            var grandTotalDet = `
            <p>Grand Total : ${GrandTotal}</p>`;
            $("#GrandTotal").html(grandTotalDet);
            console.log("GrandTotalGrandTotal",GrandTotal)
            //=============== payment Details =======//
            // data[0].payment_type.map((el, i) => {
            //   $("#idpayTypes").append(
            //     $("<option></option>")
            //       .attr("value", el.payment_type)
            //       .text(el.bank_name)
            //   );
            // });
            //====== Application submit button =========//
            var AppSubmitBtn = `
            <Button type="button" class="btn btn-primary waves-effect mr-1" 
                  id="idSubmitExamApp" onclick="sendExamAppData()">Submit</button>`;
            $("#idSubmitExmApp").html(AppSubmitBtn);
          }
        }
      });
    }
  );
}

var sub_selected = [
  {
    fsubcode: 'B021',
    fpresent: 'P',
    finsered: 'F'
  },
  {
    fsubcode: 'B022',
    fpresent: 'P',
    finsered: 'F'
  }
];

function callRebuildExamApp() {
  for(let item of gExamAppSemData) {
    var options = '<option>Select</option>';  
    
    const sub_options = item.sub_options;
    
    for(let opt of sub_options) {
      options += `<option value="${opt.code}">
      ${opt.code}-${opt.FSUBNAME}</options>`;
    }
    
    var len = item.sem_totsub-item.sub_details.length;

    if (gFreshExam != undefined && gFreshExam != "" && gFreshExam == item.FEXAMNO) {
      

    }

  }
}

var exsiting_sub_code_arr=new Array();
var sendData = new Array();
var AppData = new Array();

const ShwExamDet = (examno) => {
  console.log("shw data",examno)

  AppData.push(sendData);
  console.log("Application data",AppData)
  sendData = [];

    $("div.desc").hide();
    $("#idSubDetails" + examno).show();

    $("#idFeeDetailsExmApp" + examno).show();
    $("#idFeeDetailsTtl" + examno).show();

}
var tblData = new Array();

const  getSubNames = (examno,idx) => {

  var finalTbl = new Array();
  var fsubcode='';
  var fsubname='';
  sendData = [];

  console.log("Tbal Dta",tblData)

  $(`#MainTbl${examno}`)
  .find("> tbody > tr ")
  .each(function(i,tr){
    var subcode = $(tr)
    .find("input[type=hidden]")
    .val();
    var fpresent = 'N';

    var selected = $(tr)
    .find("select").length;

    if(selected > 0){//subcode == ''

      var optSel = $(tr).find(`>td select#exam${examno}sub${idx} option:selected`).val();
      console.log("optSeloptSelected",optSel);

      if(optSel != undefined){

        optSel = optSel.split("_");
        fsubcode = optSel[0];
        fsubname = optSel[1];
        var prCnt = 0;
        var thCnt = 0;

        if(!tblData.includes(fsubcode)){
          console.log("Doesnt INCLUDE")
          
          $(`#subcode${examno}${idx}`).val(fsubcode)
          $(`#exam${examno}subname${idx}`).text(fsubname)
          $(`#exam${examno}checkbox${idx}`).html(`<input type="checkbox" class="filled-in" id="${fsubcode}"
          checked="checked" onChange="getSubNames('${examno}',${idx})"/>
          <label for="${fsubcode}" style="font-size:14px !important;"></label>
          
          <input type="hidden" id="exam${examno}thcnt" />
          <input type="hidden" id="exam${examno}prcnt" />`)

          $.ajax({
            type: "GET",
            async: false,	 
            data: `degree_code=${FDEGREE}&exam=${examno}&subject_code=${fsubcode}&univcode=041`,//${UNIVCODE}`,     
            url: $host_url+"getSubjectNamesForSelectedSub",
            success: responce =>
            {
              var {error_code,status,data} = JSON.parse(responce);
              
              if(error_code == 0){						
                //  $("#"+sub_short_id).html(data['FSUBSHORT']);
                //  $("#"+desc_id).html(data['FSUBNAME']);
                $(`#exam${examno}thcnt`).val(data['th_cnt']);
                $(`#exam${examno}prcnt`).val(data['pr_cnt']);
                //  prCnt = data['pr_cnt'];
                //  thCnt = data['th_cnt']
                //  $("#"+finserted_id).val("T");
                //  $("#"+ch_box_id).attr("checked", "checked"); 
                //  UpdateExamFeeForEachSelectedSubject();
                //  CalculateNewwFeeTotals();

              }
              else{
                alert("Problem while selecting subject")
              }
           }	
        }); 
        $(tr).find("input[type=checkbox]").each(function(j,chk){
          // console.log("check stats",chk,j)
          if ($(chk).is(":checked")) {
            fpresent = 'P';
          }else{
            fpresent = 'N';
          }
        });

        prCnt = $(tr).find(`#exam${examno}thcnt`).val();
        thCnt = $(tr).find(`#exam${examno}prcnt`).val();

        var finalTbl = {
          f_sub_code:fsubcode,
          qp_code:'',
          f_sub_name:fsubname,
          fpass_month:'',
          pr_cnt:prCnt,
          th_cnt:thCnt, 
          fpresent:fpresent
        }

        console.log("FINAL DATA",finalTbl)
        sendData.push(finalTbl);
        ttlAmt(fsubcode,examno,idx);
        tblData.push(fsubcode)

        }else{          
          alert("Already exists")
          tblData.pop(fsubcode);
          $(`#subcode${examno}${idx}`).val()
          $(`#exam${examno}subname${idx}`).text('')
          $(`#exam${examno}checkbox${idx}`).html(``)
          return;
        }

      }
    }else{
      // if(!tblData.includes(fsubcode)){
      tblData.push(subcode);
      console.log("checkingggggg",subcode)
      fsubcode  = $(tr).find(">td input[type=hidden]").val();//subcode1
      fsubname  = $(tr).find(">td.subjectName").text();//subcodename
      
      $(tr).find("input[type=checkbox]").each(function(j,chk){
        // console.log("check stats",chk,j)
        if ($(chk).is(":checked")) {
          fpresent = 'P';
        }else{
          fpresent = 'N';
        }
      });

      prCnt = $(`#exam${examno}thcnt`).val();
      thCnt = $(`#exam${examno}prcnt`).val();
      
      var finalTbl = {
        f_sub_code:fsubcode,
        qp_code:'',
        f_sub_name:fsubname,
        fpass_month:'',
        pr_cnt:prCnt,
        th_cnt:thCnt, 
        fpresent:fpresent
      }
      console.log("FINAL DATA",finalTbl)
      sendData.push(finalTbl);
      tblData.push(fsubcode);
      ttlAmt(fsubcode,examno,idx);
      // }
    }
  })

  console.log("Send Data",sendData);
// get selected val, check stat, n update present stat
}



function ttlAmt(subcode, examno, i) {

  var ttl=0;
  $(`#idFeeDetailsExmApp${examno} .row .eachAmt`).each(function(){
    ttl += parseInt($.trim( $(this).text() ))
  })

  var amount =0;// $(`#ttlamt${examno}`).text();
  var amt = $(`#examTtl${examno}`).val();
  var prcnt = $(`#exam${examno}prcnt`).val();  
  var thcnt = $(`#exam${examno}thcnt`).val();
  console.log("COUNT",amt,prcnt,thcnt,amount,subcode,examno,i);

  var prFee = $(`#PR_01EXAMFEE${examno}`).val();
  var thFee = $(`#TH_01EXAMFEE${examno}`).val();
  var maxFee = $(`#MaxFee_01EXAMFEE${examno}`).val();
  console.log("Amt th pr", prFee,thFee,maxFee);

  var prTtl = parseInt(prFee) * parseInt(prcnt);
  var thTtl = parseInt(thFee) * parseInt(thcnt);
  var FeeTotal = parseInt(prTtl) + parseInt(thTtl);
  console.log("qwertyu",prTtl,thTtl,FeeTotal);

  if ($("#"+subcode).is(":checked")) {
    ttl += FeeTotal;
    console.log("TTL",ttl)
    // amount = +maxFee + FeeTotal;
    console.log("checked",ttl,FeeTotal)

  } 

  if( maxFee > ttl){
    document.getElementById(`ttlamt${examno}`).textContent = ttl;
  }else{
    document.getElementById(`ttlamt${examno}`).textContent = maxFee;
  }
  
  semTtl += ttl;
  // GrandTotal += semTtl;
  // console.log("GrandTotalGrandTotalGrandTotal",GrandTotal)
}

function sendExamAppData(){

  $.ajax({
    type: "POST",
    async: false,	 
    data: `degree_code=${FDEGREE}&exam=${examno}&subject_code=${fsubcode}&univcode=041
    &data=${sendData}`,//${UNIVCODE}`,     
    url: $host_url+"sendExamAppDetails",
     success: responce =>
     {
       var {error_code,status,data} = JSON.parse(responce);
       console.log("response",data)
       
       if(error_code==0)
       {						
        alert("Application updated")
       }
       else
       {
       alert("Problem Exists while selecting subject")
       }
     }	
 }); 
}
function checkAll() {
  var amount = 0;
  if (document.getElementById("checkall").checked == true) {
    for (var i = 0; i < studlen; i++) {
      document.getElementById("chk" + i).checked = true;
      amount = parseInt(amount) + parseInt($("#amt" + i).text());
    }
  } else {
    for (var i = 0; i < studlen; i++) {
      document.getElementById("chk" + i).checked = false;
      amount = 0;
    }
  }
  document.getElementById("ttlamt").value = amount;
}

function appendFeedetl(fees, examname, examno, freshexam) {
  var semhead =
    "<tr class='bg-blue'><td colspan='2'>" + examname + " Fees</td></tr>";
  var feeheads = "<tr><th>Feeheads</th><th>Amount</th></tr>";
  feerows = "";
  var totfee = 0;
  var subnum = $("#sub_" + examno).find(":checkbox:checked").length;
  for (var i in fees) {
    fee = fees[i];
    var rowfee = parseInt(fee.O_FFEE * subnum);
    if (rowfee <= parseInt(fee.FMAXFEE)) {
      totfee += rowfee;
    } else {
      totfee += parseInt(fee.FMAXFEE);
      rowfee = parseInt(fee.FMAXFEE);
    }
    feerows += "<tr>";
    feerows += "<td>" + fee.FHEADCODE + "</td>";
    feerows += "<td>" + rowfee + "</td>";
    feerows += "</tr>";
  }
  feerows += "<tr class='bg-grey'>";
  feerows += "<td>Total</td>";
  feerows += "<td>" + totfee + "</td>";
  feerows += "</tr>";
  //console.log(feerows);
  return semhead + feeheads + feerows;
}

var subjects_for_fee = {};

function calculateFee(examno) {
  //get concerned examname from exam no
  var freshexam = examAppJson["ffreshexam"];
  var sub_summary = examAppJson["sub_summary"].filter(function(el) {
    return el.fexamno == examno;
  });
  var examname = sub_summary.pop().fexamname;
  $("#sub_fee_" + examno).html(
    '<table id="fees_' +
      examno +
      '" class="col-md-6 col-lg-6 col-sm-8 col-xs-12 m-b-20 table table-condensed table-bordered table-striped table-hover">' +
      appendFeedetl(
        examAppJson["subject_" + examno].fees,
        examname,
        examno,
        freshexam
      ) +
      "</table>"
  );
}

function appendSubjects(subjects, examname, examno) {
  var semhead =
    "<tr class='bg-blue'><td colspan='3'>" + examname + "</td></tr>";
  var subheads =
    "<tr><th width='12%' style='text-align:center;'>Sub. Code</th><th>Description</th><th width='12%'>Pass Mth.</th></tr>";
  var subrows = "";
  var fees = subjects["fees"];
  var subarr = new Array();
  var j = 0;
  for (var i in subjects) {
    sub = subjects[i];
    if (subjects[i] === subjects["fees"]) {
      continue;
    }
    subrows += "<tr>";
    subrows += "<td style='text-align:center;'>" + sub.FSUBCODE + "</td>";
    subrows += "<td>" + sub.FSUBNAME + "</td>";
    if (sub.FPASSMTH == "") {
      subrows +=
        "<td><input type='checkbox' onChange=\"calculateFee('" +
        examno +
        "')\" class='filled-in chk-col-light-blue' id='" +
        sub.FSUBCODE +
        "'/><label for='" +
        sub.FSUBCODE +
        "'></label></td>";
      subarr[j] = sub.FSUBCODE;
      j++;
    } else {
      subrows += "<td>" + sub.FPASSMTH + "</td>";
    }
    subrows += "</tr>";
  }
  subjects_for_fee[examno] = subarr;
  return semhead + subheads + subrows;
}

function loadApplyRVRT() {
  $("#loadtab").load("html_modules/applyrvrt.html?v=" + version);
}

function loadNotifications() {
  $("#loadtab").load("html_modules/notifications.html?v=" + version);
}

function loadEvents() {
  $("#loadtab").load("html_modules/events.html?v=" + version);
}

function submitquery() {
  if ($("#femail").val() == "") {
    swal({
      title: `Please enter Email`,
      showCancelButton: false,
      confirmButtonColor: "#5495ff",
      confirmButtonText: "OK",
      closeOnConfirm: false
    });
    return;
  }
  if ($("#fsubject").val() == "") {
    swal({
      title: `Please enter subject`,
      showCancelButton: false,
      confirmButtonColor: "#5495ff",
      confirmButtonText: "OK",
      closeOnConfirm: false
    });
    return;
  }
  if ($("#fmessage").val() == "") {
    swal({
      title: `Please enter message`,
      showCancelButton: false,
      confirmButtonColor: "#5495ff",
      confirmButtonText: "OK",
      closeOnConfirm: false
    });
    return;
  }
  // if ($('#fattachment').val() == '') {
  //   swal({
  //     title: `Please upload files`,
  //     showCancelButton: false,
  //     confirmButtonColor: "#5495ff",
  //     confirmButtonText: "OK",
  //     closeOnConfirm: false
  //   });
  //   return;
  // }

  if ($("#file").val()) {
    if ($("#file")[0].files[0].size >= 2000000) {
      var size = $("#file")[0].files[0].size;
      console.log("files", size);
      swal({
        title: `Please attach files with less size`,
        showCancelButton: false,
        confirmButtonColor: "#5495ff",
        confirmButtonText: "OK",
        closeOnConfirm: false
      });
      return;
    } else {
      var filename = $("#file")[0].files[0];
      var file_data = $("#file").prop("files")[0];
      var form_data = new FormData();
      console.log("file_data", file_data);
      form_data.append("file", filename);
    }
  } else {
    var filename = "";
  }

  var datastring =
    "fmessage=" +
    $("#fmessage").val() +
    "&fsubject=" +
    $("#fsubject").val() +
    "&femail=" +
    $("#femail").val();
  console.log(datastring);
  $upload = "src/submitquery.php?" + datastring;
  console.log("upload", $upload);
  document.getElementById("formID").setAttribute("action", $upload);
  return AIM.submit(document.getElementById("formID"), " report_display", {
    onComplete: GRVUploadResponse
  });
}

function GRVUploadResponse(responce) {
  // console.log("responce", responce);
  responce = JSON.parse(responce);
  // console.log(responce.error_code);
  if (responce.error_code == 0) {
    swal({
      title: `Query has been submitted successfully. <br> Your query number is <b>${responce.msg}</b>. <br> keep this number for future reference.<br>You will get email comunication on this issue.`,
      html: true,
      showCancelButton: false,
      confirmButtonColor: "#5495ff",
      confirmButtonText: "OK",
      closeOnConfirm: false
    });
    $("#fmessage").val("");
    $("#fsubject").val("");
    closeForm();
    return;
  } else if (responce.error_code == -2) {
    swal({
      title: `${responce.msg}`,
      showCancelButton: false,
      confirmButtonColor: "#5495ff",
      confirmButtonText: "OK",
      closeOnConfirm: false
    });
    $("#fmessage").val("");
    $("#fsubject").val("");
    logout();
    return;
  } else {
    swal({
      title: `${responce.msg}`,
      showCancelButton: false,
      confirmButtonColor: "#5495ff",
      confirmButtonText: "OK",
      closeOnConfirm: false
    });
    $("#fmessage").val("");
    $("#fsubject").val("");
    closeForm();
    return;
  }
}

function updateMediclare(type) {
  $.ajax({
    type: "GET",
    url: "src/mediclareClick.php?type=" + type,
    success: function(responce) {}
  });
}

function loadRvpcStatus() {
  $.blockUI({ message: "<img src='images/Loading_icon.gif' border='0'>" });
  $.ajax({
    type: "post",
    url: "src/rvappstatus.php",
    success: function(response) {
      $.unblockUI();
      response = JSON.parse(response);
      if (response.error_code == -1) {
        swal(
          {
            title: response.data,
            type: "warning",
            showCancelButton: false,
            confirmButtonColor: "#5495ff",
            confirmButtonText: "OK",
            closeOnConfirm: false
          },
          function(isConfirm) {
            if (isConfirm) swal.close();
            loadProfile();
            $("#profile").addClass("active");
            $("#rvstatus").removeClass("active");
          }
        );
      } else {
        $("#loadtab").load(
          "html_modules/rvappstatus.html?v=" + version,
          function() {
            const { fexamdate, data } = response;

            $("#idRvstatus").html(
              `<h2><center> ${fexamdate} Examination Revaluation and Photo Copy Status</center></h2>`
            );

            var table = `<table class="m-b-20 table table-condensed table-bordered table-striped table-hover">
                      <tr style = "height:40px;background-color: #184F76 !important;color: #fff;">
                      <th style = "width:8%;"><center>Sl. No.</center></th>
                      <th style = "width:10%;"><center>Semester</center></th>
                      <th style = "width:10%;" ><center>QP Code</center></th>
                      <th><center>Subject Name</center></th>
                      <th style = "width:12%;"><center>Applied For</center></th>
                      <th style = "width:10%;"><center>Status</center></th>
                      </tr>`;
            let i = 0;
            for (let row of data) {
              //console.log(fdoe[i]);

              let status = "";

              if (row.fcorrtype == "XR" && row.fxrexist == "T") {
                status = `<a href="photocopy/${row.fxrpath}" download><button class="btn btn-success">Download</button><a>`;
              } else if (row.fcorrtype == "XR" && row.fxrexist == "F") {
                status = `<button class="btn btn-warning">Pending</button>`;
              } else if (row.frvstatus == "T") {
                status = `<button onClick="loadResults()" class="btn btn-success">Announced</button>`;
              } else if (row.frvstatus == "F") {
                status = `<button class="btn btn-warning">Pending</button>`;
              } else {
                status = `<button class="btn btn-warning">NA</button>`;
              }

              table += `<tr style = "height:30px;">
              <td><center>${parseInt(i) + 1}</center></td>
              <td><center>${row.fexamname}</center></td>
              <td><center>${row.fqpcode}</center></td>
              <td>${row.fsubname}</td>
              <td>${row.fcorrdescpn}</td>
              <td><center>${status}</center></td>
              </tr>`;
              i++;
            }
            table += `</table>`;

            $("#rvappstatus_table").html(table);
          }
        );
      }
    }
  });
}

function saveAnsBook(i) {
  var ansbookno = $("#ansbookno_" + i).val();
  if (ansbookno == "") {
    alert("Please Enter Ans. Book No.");
    $("#ansbookno_" + i).focus();
    return;
  }

  if (ansbookno.length < 5) {
    alert("Please Enter valid Ans. Book No. ");
    $("#ansbookno_" + i).focus();
    return;
  }

  var parameters =
    "&qpcode=" + $("#qpcode_" + i).html() + "&ansbookno=" + ansbookno;

  $.ajax({
    type: "post",
    url: "src/saveansbookno.php",
    data: parameters,
    success: function(response) {
      response = JSON.parse(response);

      swal(
        {
          title: response.data,
          type: "success",
          showCancelButton: false,
          confirmButtonColor: "#5495ff",
          confirmButtonText: "OK",
          closeOnConfirm: false
        },
        function(isConfirm) {
          if (isConfirm) swal.close();
        }
      );
    }
  });
}

function loadNotification() {
  var parameters = "&screen=notification";
  console.log("a");
  $.blockUI({ message: "<img src='images/Loading_icon.gif' border='0'>" });
  $.ajax({
    type: "post",
    url: "src/notification.php",
    data: parameters,
    success: function(response) {
      $.unblockUI();
      //response = JSON.parse(response);
      response = eval("(" + response + ")");
      response = response;
      if (response.error_code == 0) {
        swal(
          {
            title: "Notification Not Available",
            type: "warning",
            showCancelButton: false,
            confirmButtonColor: "#5495ff",
            confirmButtonText: "OK",
            closeOnConfirm: false
          },
          function(isConfirm) {
            if (isConfirm) swal.close();
            loadProfile();
            $("#profile").addClass("active");
            $("#examTTMenu").removeClass("active");
          }
        );
      } else {
        $("#loadtab").load(
          "html_modules/notification.html?v=" + version,
          function() {
            //console.log(response.data);
            var z = response.data.length;

            $("#idExamTTHeader").html(
              `<h2><center>Notifications</center></h2>`
            );

            // $("#studinfo").append(`
            // <tr><td width='20%'><b>Exam Centre </td><td width='2%'> : </td> <td>${strCentre}</b></td></tr>`);

            var table = `<table class="m-b-20 table table-condensed table-bordered table-striped table-hover">
                      <tr style = "height:40px;background-color: #184F76 !important;color: #fff;">
                      <th style = "width:5%;"><center>Sl. No.</center></th>
                      <th><center>Event</center></th>
                      <th style = "width:10%;" ><center>Download</center></th>
                      </tr>`;
            console.log(name.length);
            for (var i = 0; i < z; i++) {
              table += `<tr style = "height:30px;">
              <td>
                <center>${parseInt(i) + 1}</center>
              </td>
              <td id = 'ename${i}'>
                ${response.data[i]["flabel"]}
              </td>
              <td>
                <a href = "http://studentportal.universitysolutions.in/docs/${
                  response.data[i]["folder"]
                }/${response.data[i]["ffilepath"]}" target="_blabk">
                  View
                </a>
              </td>
              </tr>`;
            }
            table += `</table>`;

            $("#examtimetable_table_det").html(table);
          }
        );
      }
    }
  });
}