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


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

var UNIVNAME, FUNIVCODE, 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();
  // loadExamApplication1();
  //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();

  // loadExamApplication1();

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

      FUNIVCODE = 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 (FUNIVCODE == "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 (FUNIVCODE != "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();
}

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

// export const getRegno = () => FREGNO;
// export const getDegree = () => FDEGREE;