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


Current Path : /proc/thread-self/root/var/www/html/kus/parikshamitra/js/
Upload File :
Current File : //proc/thread-self/root/var/www/html/kus/parikshamitra/js/cms.js

servcode = "";
examcnt = "";
CMS = {
  getheaderdetails: function () {
    $.ajax({
      type: "POST",
      url: $host_url + "getheaderdetails",
      success: function (responce) {
        try {
          responce = eval("(" + responce + ")");
          setCookie("title", responce.data.FUNIVNAME);
          setCookie("datestr", responce.data.datestr);
          document.getElementById("datestr").innerHTML = responce.data.datestr;
        } catch (err) {
          txt = err.message;
          //$.unblockUI();
          //bootbox.alert(txt);
        }
      },
    });
  },
  GetCMSDropDownMenuValues: function () {
    $.ajax({
      type: "POST",
      url: $host_url + "getcmsdropdownmenuvalues",
      success: function GetCMSDropDownMenuValuesResponce(responce) {
        try {
          responce = eval("(" + responce + ")");
          var serv_arr = responce.data["serv_type"];
          var serv_title = "";
          document.getElementById("T26").value = 0;
          document.getElementById("tran").checked = false;
          CMS.FillDropdownValues(serv_arr, "S2", serv_title);

          var pay_arr = responce.data["pay_type"];
          var pay_title = "";
          CMS.FillDropdownValues(pay_arr, "S3", pay_title);

          var category = responce.data["category"];
          var cat_title = "";
          CMS.FillDropdownValues(category, "S1", cat_title);
        } catch (err) {
          txt = err.message;
          bootbox.alert(txt);
        }
      },
    });
  },
  FillDropdownValues: function (arr, ele_name, def_title) {
    document.getElementById(ele_name).options.length = 0;
    var op = new Option("  Select  " + def_title, "#");
    op.id = "00";
    document.getElementById(ele_name).options.add(op);
    jQuery.each(arr, function (k, v) {
      var op = new Option(v["val"], v["int_code"]);
      op.id = v["int_code"];
      document.getElementById(ele_name).options.add(op);
    });
  },
  loadserviceslist: function (servcode) {
    $("#dyserviceslist  tbody tr").html("");
    document.getElementById("T26").value = 0;
    document.getElementById("HSR3").value = servcode;
    var transcript = "F";
    var tranno = 0;
    document.getElementById("tranno").value = 0;
    $("#agencies").hide();
    $("#transcript").hide();
    $("#doccert").hide();
    $("#emailotpcard").hide();
    if (servcode == "KS06") {
      $("#agencies").show();
      $("#doccert").show();
      $("#emailotpcard").show();
    }
    if (servcode == "KS07") {
      $("#transcript").show();
      $("#transcriptno").hide();

      if (document.getElementById("tran").checked == true) {
        transcript = "T";
        $("#transcriptno").show();
      }
    }
    document.getElementById("S8").value = "";
    //var tranno = document.getElementById('tranno').value;
    var ldegree = document.getElementById("HT4").value;
    var reg_no = $("#T1").val();

    $.ajax({
      type: "POST",
      url:
        $host_url +
        "loadserviceslist" +
        "&servcode=" +
        servcode +
        "&ldegree=" +
        ldegree +
        "&reg_no=" +
        reg_no,
      success: function (responce) {
        responce = eval("(" + responce + ")");
        console.log("examcnt - " + examcnt);
        try {
          if (responce.error_code == 0) {
            if (responce.data["servtype"] == "single") {
              var servdet = responce.data["services"];

              if (servcode == "KS06") {
                sem = [
                  "I SEMESTER",
                  "II SEMESTER",
                  "III SEMESTER",
                  "IV SEMESTER",
                  "V SEMESTER",
                  "VI SEMESTER",
                ];
                semid = ["A", "B", "C", "D", "E", "F"];
                var table = "";
                var z = 1;
                for (var i = 0; i < examcnt; i++) {
                  table += `<tr>  
                  <td>${z}</td>
                  <td>${sem[i]}</td> 
                  <td>
                  <input type="file"   id = "${semid[i]}" class="form-control1"/>
                  <input type="hidden"   id = "h_${semid[i]}" value = '' class="form-control1"/>
                  </td>
                  <td><input type="button" id = "bfile1" class="btn btn-primary" value="Upload" onClick="CMS.upload_file('${semid[i]}');"/></td>
                  <td><span id = 't${semid[i]}'> </span></td>
                </tr>`;
                  z++;
                }
                table += `<tr>  
                  <td>${z++}</td>
                  <td>Degree Certificate</td> 
                  <td><input type="file"   id = "degree_certificate" class="form-control1"/>
                  <input type="hidden"   id = "h_degree_certificate" value = '' class="form-control1"/>
                  </td>
                  <td><input type="button" id = "bfile1" class="btn btn-primary" value="Upload" onClick="CMS.upload_file('degree_certificate');"/></td>
                  <td><span id = 'tdegree_certificate'> </span></td>
                </tr>`;
                $("#doc_table").append(table);
              }

              if (servcode != "KS06")
                CMS.getservicefee(
                  servdet[0].int_code,
                  responce.data["servtype"]
                );
              else CMS.getserviceagenciesfee(servdet[0].int_code);
              document.getElementById("cont_serviceslist").innerHTML =
                responce.data["servtablist"];
              document.getElementById("T27").innerHTML =
                responce.data["servpro"];
              document.getElementById("HA1").value = responce.data["servtype"];
            } else {
              serviceslist = responce.data["services"];
              document.getElementById("cont_serviceslist").innerHTML =
                responce.data["servtablist"];
              document.getElementById("T27").innerHTML =
                responce.data["servpro"];
              document.getElementById("HA1").value = responce.data["servtype"];
              var serv_title = "";
              $("#dyserviceslist").append(responce.data["servmandatory"]);
              CMS.addservicedet();
            }
          } else {
            alert(responce.data);
            document.getElementById("cont_serviceslist").innerHTML = "";
            document.getElementById("T26").innerHTML = 0;
            document.getElementById("T27").innerHTML = "";
          }
        } catch (err) {
          txt = err.message;
          $.unblockUI();
          bootbox.alert(txt);
        }
      },
    });
  },
  displaytan: function () {
    $("#transcriptno").hide();

    if (document.getElementById("tran").checked == true) {
      transcript = "T";
      $("#transcriptno").show();
    }
  },
  SaveApplicationDetails: function () {
    var myobject;
    var ftranscript = "F";
    var ftranscriptno = 0;
    var fagencies = "";
    var manual_entry = getCookie("manual_entry");
    var mid = "";
    if (manual_entry == "F") mid = ",T4";

    fldorder = "S2,T1,T2,T3,S1,T5,T10,T11,T12,T13,T28,T29,T30,T31,T14,T15";
    mandfields = "S2,T1,T2,T3,S1,T5,T10,T11,T28,T29,T30,T31,T14,T15";
    fldorder += mid;
    mandfields += mid;

    myobject = onsavevalidate.call(myobject, 999);
    if (myobject != 999) {
      document.getElementById(myobject).focus();
      return false;
    }
    var list_data = $host_url + "SaveApplicationDetails";
    var reg_no = encodeURIComponent($("#T1").val());
    list_data += "&reg_no=" + reg_no;
    var degree = $("#HT4").val();
    list_data += "&degree=" + degree;
    var college = $("#HT3").val();
    list_data += "&college=" + college;
    var collname = $("#T3").val();
    list_data += "&collname=" + collname;
    var candidate_name = encodeURIComponent($("#T2").val());
    list_data += "&candidate_name=" + candidate_name;
    var paddr1 = encodeURIComponent($("#T10").val());
    list_data += "&paddr1=" + paddr1;
    var paddr2 = encodeURIComponent($("#T11").val());
    list_data += "&paddr2=" + paddr2;
    var paddr3 = encodeURIComponent($("#T12").val());
    list_data += "&paddr3=" + paddr3;
    var paddr4 = encodeURIComponent($("#T13").val());
    list_data += "&paddr4=" + paddr4;
    var city = encodeURIComponent($("#T28").val());
    list_data += "&city=" + city;
    var state = encodeURIComponent($("#T29").val());
    list_data += "&state=" + state;
    var country = encodeURIComponent($("#T30").val());
    list_data += "&country=" + country;
    var pincode = encodeURIComponent($("#T31").val());
    list_data += "&pincode=" + pincode;
    var mobile_no = encodeURIComponent($("#T15").val());
    list_data += "&mobile_no=" + mobile_no;
    var emailid = $("#T14").val();
    list_data += "&emailid=" + emailid;
    var amount = $("#T26").val();
    list_data += "&amount=" + amount;
    var paytype = $("#S3").val();
    list_data += "&paytype=" + paytype;
    var mdegree = $("#S10").val();
    list_data += "&mdegree=" + mdegree;
    list_data += "&manual_entry=" + manual_entry;

    var servcode = document.getElementById("HSR3").value;
    if (servcode == "KS06") {
      var fagencies = $("#S8").val();
      var emailotp = $("#emailotp").val();
      if (fagencies == "") {
        alert("Select Agencies");
        document.getElementById("S8").focus();
        return;
      }
      if (emailotp == "") {
        alert("Enter Email OTP");
        document.getElementById("emailotp").focus();
        return;
      }

      for (var i = 0; i < examcnt; i++) {
        var semid = ["A", "B", "C", "D", "E", "F"];
        sem = [
          "I SEMESTER / YEAR",
          "II SEMESTER / YEAR",
          "III SEMESTER / YEAR",
          "IV SEMESTER / YEAR",
          "V SEMESTER / YEAR",
          "VI SEMESTER / YEAR",
        ];

        if ($(`#h_${semid[i]}`).val() == "") {
          alert(`Please upload ${sem[i]} Marks Card`);
          return;
        } else {
          list_data += `&SEM_${semid[i]}=` + $(`#h_${semid[i]}`).val();
        }
      }
      list_data += `&degree_certificate=` + $(`#h_degree_certificate`).val();

      list_data += "&fagencies=" + fagencies + "&emailotp=" + emailotp;
    }

    if (manual_entry == "T") {
      if (mdegree == "#") {
        alert("Select Degree");
        $("#S10").focus();
        return false;
      }
    }

    if (document.getElementById("tran").checked == true) {
      var ftranscript = "T";
      var ftranscriptno = $("#tranno").val();
      if (ftranscriptno == "") {
        alert(" No. of copy to transcript");
        document.getElementById("tranno").focus();
        return;
      }
      list_data += "&ftranscriptno=" + ftranscriptno;
      list_data += "&ftranscript=" + ftranscript;
    }

    var dob = $("#T5").val();
    list_data += "&dob=" + dob;
    var category = $("#S1").val();
    list_data += "&category=" + category;
    var servicetype = $("#S2").val();
    list_data += "&servicetype=" + servicetype;
    var event = document.createEvent("Event");
    if (!validateemail(event, emailid)) {
      alert(
        "The Email ID format is invalid,the valid Email Id format is name@org.com or name@org.co.in"
      );
      document.getElementById("T14").focus();
      return false;
    }
    if (category == "#") {
      alert("Select category");
      $("#S1").focus();
      return false;
    }
    if (servicetype == "#") {
      alert("Select Application for");
      $("#S2").focus();
      return false;
    }
    if (parseInt(amount) == 0) {
      alert("Amount cannot be zero");
      $("#S2").focus();
      return false;
    }
    if (paytype == "#") {
      alert("Select Payment mode");
      $("#S3").focus();
      return false;
    }
    if (document.getElementById("HA1").value == "multiple") {
      var inputFileds = document.getElementsByTagName("input");
      var chkCnt = 0;
      var rowCnt = 0;
      var serv_arr = {};
      for (var counter = 0; counter < inputFileds.length; counter++) {
        if (
          inputFileds[counter].type.toUpperCase() == "HIDDEN" &&
          inputFileds[counter].name == "servicename"
        ) {
          ++rowCnt;
          if (
            document.getElementById(rowCnt + "GD4").value != "T" &&
            document.getElementById(rowCnt + "GD1").value != "#"
          ) {
            serv_arr[chkCnt] = new Object();
            serv_arr[chkCnt]["feecode"] = document.getElementById(
              rowCnt + "GD1"
            ).value;
            //serv_arr[chkCnt]['examyear'] = document.getElementById(rowCnt+'GD2').value;
            serv_arr[chkCnt]["fee"] = document.getElementById(
              rowCnt + "GD3"
            ).value;
            ++chkCnt;
          }
        }
      }
      var count = Object.keys(serv_arr).length;
      // console.log('servicetype==',servicetype, "servelength==", count);
      if (count < 2) {
        alert("One Marks card should be selected.");
        return false;
      }
      // return false;
    } else {
      var serv_arr = {};
      serv_arr[0] = new Object();
      serv_arr[0]["feecode"] = document.getElementById("HSR1").value;
      serv_arr[0]["examyear"] = "";
      serv_arr[0]["fee"] = document.getElementById("HSR2").value;
    }
    if (Object.size(serv_arr) > 0) {
      list_data += "&serv_arr=" + encodeURIComponent(JSON.stringify(serv_arr));
      //document.getElementById("serviceform_module").setAttribute("action",list_data);
      //return AIM.submit(document.getElementById("serviceform_module"), 'same_tab',{'onComplete' : CMS.SaveApplicationDetailsResponse});
      $.ajax({
        type: "POST",
        url: $host_url + "ValidatePaymentApplicationData",
        //error:AjaxErrorMessage,
        data: list_data,
        success: CMS.SaveApplicationDetailsResponse,
      });
    }
  },
  SaveApplicationDetailsResponse: function (responce) {
    try {
      responce = eval("(" + trim(responce) + ")");
      if (responce.error_code == 0) {
        document.getElementById("form_reg_success").style.display = "block";
        document.getElementById("form_reg_page").style.display = "none";
        document.getElementById("APT1").innerHTML = responce.data["appno"];
        var paytype = responce.data["paylink"];
        var appno = responce.data["appno"];
        var fname = responce.data["fname"];
        var fregno = responce.data["fregno"];
        var ftotal = responce.data["ftotal"];

        var paylink = "";
        if (paytype == "POSTOFFICE") {
          paylink +=
            '<div class="row mb40" ><div class="col-md-9 mb5" align="center">';
          paylink +=
            '<center><span  class="btn btn_3 btn-lg btn-info" onclick=CMS.PrintPOSTCertifcate("' +
            responce.data["appno"] +
            '")>Print Acknowledgement</span></center></div></div>';
          document.getElementById("payment_link").innerHTML = paylink;
        }

        if (paytype == "DEBIT/CREDIT/NET BANKING") {
          $("#form_reg_success").load("payment_gateways.html", function () {
            $("#appno").html(
              "<center><h4>Application number : " + appno + "</h4></center>"
            );
            $("#regno").html(
              "<center><h4>Register number : " + fregno + "</h4></center>"
            );
            $("#studname").html(
              "<center><h4>Student Name : " + fname + "</h4></center>"
            );
            $("#fees").html(
              "<center><h4>Total Fees : Rs. " + ftotal + "</h4></center>"
            );

            $("#payu").click(function () {
              $.ajax({
                type: "POST",
                url: $host_url + "updatepaymenttype",
                data: "&app_no=" + responce.data["appno"] + "&payu=" + "Payu",
                success: function updatepaymenttypeResponce(responce) {
                  try {
                    responce = eval("(" + responce + ")");
                    window.location.href =
                      "payment_gateway.php?productinfo=" +
                      appno +
                      "&cdb=" +
                      getCookie("curuniv");
                  } catch (err) {
                    txt = err.message;
                    bootbox.alert(txt);
                  }
                },
              });

              //	window.location.href="payment_gateway.php?productinfo="+responce.data['appno'];
            });

            $("#paytm1").click(function () {
              $.ajax({
                type: "POST",
                url: $host_url + "updatepaymenttype",
                data: "&app_no=" + responce.data["appno"] + "&payu=" + "Paytm",
                success: function updatepaymenttypeResponce(responce) {
                  try {
                    responce = eval("(" + responce + ")");
                    window.location.href =
                      "Paytm/pgRedirect.php?productinfo=" +
                      appno +
                      "&cdb=" +
                      getCookie("curuniv");
                  } catch (err) {
                    txt = err.message;
                    bootbox.alert(txt);
                  }
                },
              });
            });
          });
        }
      } else {
        alert(responce.data);
        return false;
      }
    } catch (err) {
      txt = err.message;
      bootbox.alert(txt + "<br>" + responce);
    }
  },
  ValidatePaymentApplicationData: function () {
    var myobject;
    fldorder = "T17,T18,T19";
    mandfields = "T17,T18,T19";
    myobject = onsavevalidate.call(myobject, 999);
    if (myobject != 999) {
      document.getElementById(myobject).focus();
      return false;
    }
    var pappno = $("#T17").val();
    var pregno = $("#T18").val();
    var pdob = $("#T19").val();

    //App.blockUI({boxed:true,message:"Please wait,validating input details..."});
    $.ajax({
      type: "POST",
      url: $host_url + "ValidatePaymentApplicationData",
      //error:AjaxErrorMessage,
      data: "&pappno=" + pappno + "&pdob=" + pdob + "&pregno=" + pregno,
      success: function GetpaymentLinkForAppNoResponce(responce) {
        try {
          responce = eval("(" + responce + ")");
          //$.unblockUI();
          if (responce.error_code == -1) {
            alert(responce.data);
          } else {
            CMS.MakeOnlinePayment(responce.data["appno"]);
          }
        } catch (err) {
          txt = err.message;
          //$.unblockUI();
          bootbox.alert(txt);
        }
      },
    });
  },
  ValidatePrintCertificateApplicationData: function () {
    var myobject;
    fldorder = "T20,T21,T22";
    mandfields = "T20,T21,T22";
    myobject = onsavevalidate.call(myobject, 999);
    if (myobject != 999) {
      document.getElementById(myobject).focus();
      return false;
    }
    var appno = $("#T20").val();
    var regno = $("#T21").val();
    var dob = $("#T22").val();
    //App.blockUI({boxed:true,message:"Please wait,generating report..."});
    $.ajax({
      type: "POST",
      url: $host_url + "ValidatePrintCertificateApplicationData",
      //error:AjaxErrorMessage,
      data: "&appno=" + appno + "&dob=" + dob + "&regno=" + regno,
      success: function ValidatePrintCertificateApplicationDataResponce(
        responce
      ) {
        try {
          responce = eval("(" + responce + ")");
          //$.unblockUI();
          if (responce.error_code == -1) {
            bootbox.alert("Invalid Inputs Entered");
          } else {
            if (responce.data["paytype"] == "POSTOFFICE") {
              CMS.PrintPOSTCertifcate(responce.data["app_no"]);
            }
            if (
              (responce.data["paytype"] == "DEBIT/CREDIT/NET BANKING" || responce.data["paytype"] == "PAYTM") &&
              responce.data["paystatus"] == "success"
            ) {
              CMS.PrintNETBANKCertifcate(responce.data["app_no"]);
            }
            if (
              responce.data["paytype"] == "DEBIT/CREDIT/NET BANKING" &&
              responce.data["paystatus"] != "success"
            ) {
              txt = "Online Payment Pending";
              bootbox.alert(txt);
            }
          }
        } catch (err) {
          txt = err.message;
          $.unblockUI();
          bootbox.alert(txt);
        }
      },
    });
  },
  ValidateApplicationstatus: function () {
    var myobject;
    fldorder = "T23,T24,T25";
    mandfields = "T23,T24,T25";
    myobject = onsavevalidate.call(myobject, 999);
    if (myobject != 999) {
      document.getElementById(myobject).focus();
      return false;
    }
    var appno = $("#T23").val();
    var regno = $("#T24").val();
    var dob = $("#T25").val();

    $.ajax({
      type: "POST",
      //async:false,
      url: $host_url + "ValidateApplicationstatus",
      //error:AjaxErrorMessage,
      data: "sappno=" + appno + "&sregno=" + regno + "&sdob=" + dob,
      success: function (responce) {
        try {
          responce = eval("(" + responce + ")");
          if (responce.error_code == 0) {
            $("#application_info").html(responce.data["html"]);
          } else {
            bootbox.alert(responce.data);
          }
        } catch (err) {
          txt = err.message;
          //$.unblockUI();
          bootbox.alert(txt);
        }
      },
    });
  },
  Getstudentdetails: function (event, regno) {
    manual_entry = getCookie("manual_entry");

    if (manual_entry == "T") {
    } else {
      if (regno.length > 0) {
        //App.blockUI({boxed:true,message:"Please wait,loading data.."});
        $.ajax({
          type: "POST",
          url: $host_url + "getstudentdetails",
          data: "regno=" + regno,
          success: function (responce) {
            try {
              responce = eval("(" + responce + ")");
              //$.unblockUI();
              if (responce.error_code == 0) {
                examcnt = responce.data["examcnt"];
                document.getElementById("T2").value = responce.data["FNAME"];
                document.getElementById("T3").value =
                  responce.data["FCOLLNAME"];
                document.getElementById("T4").value = responce.data["FDESCPN"];
                document.getElementById("HT3").value =
                  responce.data["FCOLLCODE"];
                document.getElementById("HT4").value = responce.data["FDEGREE"];
                document.getElementById("S2").disabled = false;
                document.getElementById("S2").focus();
              } else {
                alert("Reg. No. Details Not found");
                document.getElementById("T2").value = "";
                document.getElementById("T3").value = "";
                document.getElementById("T4").value = "";
                document.getElementById("HT3").value =
                  responce.data["FCOLLCODE"];
                document.getElementById("HT4").value = responce.data["FDEGREE"];
                document.getElementById("S2").value = "#";
                document.getElementById("S1").value = "#";
              }
            } catch (err) {
              txt = err.message;
              //$.unblockUI();
              bootbox.alert(txt);
            }
          },
        });
      }
    }
  },
  ViewCertificateApplicationData: function () {
    var regno = document.getElementById("apps_reg_no").value;
    var appno = document.getElementById("apps_app_no").value;
    var dob = document.getElementById("apps_dob").value;

    if (empty(appno)) {
      bootbox.alert("Enter Application no.");
      return false;
    } else if (dob == "0000-00-00") {
      bootbox.alert("Enter Date of Birth");
      return false;
    } else if (empty(regno)) {
      bootbox.alert("Enter Register no.");
      return false;
    }
    App.blockUI({ boxed: true, message: "Please wait, data loading..." });
    var datastring = "regno=" + regno + "&appno=" + appno + "&dob=" + dob;
    $.ajax({
      type: "POST",
      url: $host_url + "Getapplicationstatusdetails",
      error: AjaxErrorMessage,
      data: datastring,
      success: function (responce) {
        App.unblockUI();
        responce = eval("(" + responce + ")");
        if (responce.error_code == 0) {
          try {
            $("#status_task").html(responce.data["html"]);
          } catch (err) {
            txt = err.message;
            $.unblockUI();
            bootbox.alert(txt);
          }
        } else {
          bootbox.alert(responce.data);
        }
      },
    });
  },
  MakeOnlinePayment: function (app_no) {
    //window.location.href="payment_gateway.php?productinfo="+app_no+"&cdb="+getCookie("curuniv");
    window.location.href =
      "Paytm/pgRedirect.php?productinfo=" +
      app_no +
      "&cdb=" +
      getCookie("curuniv");
  },
  PrintNETBANKCertifcate: function (app_no) {
    //window.location.href=$host_url+"PrintNetbankCertificate&app_no="+app_no;
    window.location.href = $host_url + "printapplicationfrom&app_no=" + app_no;
  },
  PrintNETBANKCertifcatepaytm: function (app_no, crmode) {
    if (trim(crmode) != "") {
      var urlarr = window.location.pathname.split("/");
      var $url = "https://" + window.location.host + "/";
      $hoststr = "";
      for (var j = 1; j < urlarr.length - 1; j++) {
        $hoststr += window.location.pathname.split("/")[j] + "/";
      }
      $host_url = $url + $hoststr + "app.php?cdb=" + crmode + "&a=";
      //alert($host_url);
      CMS.PrintNETBANKCertifcatepaytm1(app_no);
    } else {
      window.location.href = "index.html";
    }

    /* $host_url = "http://logisys.net.in/kus/parikshamitra/";
		$host_url = $hoststr+"app.php?cdb="+crmode+"&a=";
		alert(crmode);
		if(trim(crmode) != '')
		{	
			$host_url = $hoststr+"app.php?cdb="+crmode+"&a=";
			window.location.href="app.php?=aprintapplicationfrom&app_no="+app_no;
		}
		else
		{
			window.location.href = "index.html";
		} */
  },
  PrintNETBANKCertifcatepaytm1: function (app_no) {
    window.location.href = $host_url + "printapplicationfrom&app_no=" + app_no;
  },
  PrintPOSTCertifcate: function (app_no) {
    window.location.href = $host_url + "printapplicationfrom&app_no=" + app_no;
    //window.location.href=$host_url+"appFormPOSTOFFICE&app_no="+app_no;
  },
  caltotservicefee: function (id, value) {
    if (document.getElementById(id).checked == true) {
      var totfee = parseInt(document.getElementById("T16").value);
      document.getElementById("T16").value = totfee + parseInt(value);
    } else {
      var totfee = parseInt(document.getElementById("T16").value);
      document.getElementById("T16").value = totfee - parseInt(value);
    }
  },
  addservicedet: function () {
    if (document.getElementById("S2").value == "#") {
      alert("Select service type");
      document.getElementById("S2").focus();
      return false;
    }

    var inputFileds = document.getElementsByTagName("input");
    var chkCnt = 0;
    var slno = 0;
    for (var counter = 0; counter < inputFileds.length; counter++) {
      if (
        inputFileds[counter].type.toUpperCase() == "HIDDEN" &&
        inputFileds[counter].name == "servicename"
      ) {
        ++chkCnt;
        if (document.getElementById(chkCnt + "GD4").value == "F") ++slno;
      }
    }
    /* if(chkCnt != 1)
		{
			if(document.getElementById(chkCnt+'GD1').value == '#')
			{
				document.getElementById(chkCnt+'GD1').focus();
				return false;
			}	
		}	 */
    var dellink = "";
    if (chkCnt != 1) {
      dellink = "<img src='images/Remove-icon.png' />";
    }
    var curindex = chkCnt + 1;
    var curslno = slno + 1;
    var dyrow = '<tbody id="servdet' + curindex + '"><tr>';
    dyrow += '<td align="center">' + curslno + "</td>";
    dyrow +=
      '<td><input type="hidden" name="servicename" /><select id = "' +
      curindex +
      'GD1" class="form-control1" onchange = "CMS.getservicefee(this.value,' +
      curindex +
      ')"></select></td>';
    //dyrow += '<td><input type="text" id = "'+curindex+'GD2" value=""/></td>';
    dyrow +=
      '<td><input type=text style="width:80px;" id = "' +
      curindex +
      'GD3"  disabled /></td>';
    dyrow +=
      '<td><input type="hidden" id = "' +
      curindex +
      'GD4" value="F"/><span onclick ="CMS.removeservice(' +
      curindex +
      ')">' +
      dellink +
      "</span></td>";
    dyrow += "</tr></tbody>";
    $("#dyserviceslist").append(dyrow);
    var serv_title = "";
    CMS.FillDropdownValues(serviceslist, curindex + "GD1", serv_title);
  },
  removeservice: function (rowid) {
    if (confirm("Are you sure do you want to remove this details")) {
      $("#servdet" + rowid).hide();
      document.getElementById(rowid + "GD4").value = "T";
      CMS.updatetotalservfee();
    }
  },
  getservicefee: function (servcode, rowid) {
    var degree = document.getElementById("HT4").value;

    var datastring = "&feecode=" + servcode + "&degree=" + degree;

    $.ajax({
      type: "POST",
      url: $host_url + "getservicefee",
      data: datastring,
      success: function (responce) {
        responce = eval("(" + responce + ")");
        if (responce.error_code == 0) {
          if (rowid == "single") {
            document.getElementById("T26").value =
              parseInt(responce.data.FFEE) + parseInt(220);
            document.getElementById("HSR1").value = responce.data.FFEECODE;
            document.getElementById("HSR2").value = responce.data.FFEE;
          } else {
            document.getElementById(rowid + "GD3").value = responce.data.FFEE;
            CMS.updatetotalservfee();
          }
        } else {
          if (rowid == "single") {
            document.getElementById("T26").value = 0;
          } else {
            document.getElementById(rowid + "GD3").value = 0;
            CMS.updatetotalservfee();
          }
        }
      },
    });
  },
  getserviceagenciesfee: function (servcode) {
    document.getElementById("T26").value = 0;
    var degree = document.getElementById("HT4").value;
    var agencies = document.getElementById("S8").value;
    var datastring =
      "&feecode=" + servcode + "&degree=" + degree + "&agencies=" + agencies;

    $.ajax({
      type: "POST",
      url: $host_url + "getserviceagenciesfee",
      data: datastring,
      success: function (responce) {
        responce = eval("(" + responce + ")");
        if (responce.error_code == 0) {
          document.getElementById("T26").value = parseInt(responce.data.FFEE);
          document.getElementById("HSR1").value = responce.data.FFEECODE;
          document.getElementById("HSR2").value = responce.data.FFEE;
        }
      },
    });
  },
  updatetotalservfee: function () {
    document.getElementById("T26").value = 0;
    var tranno = document.getElementById("tranno").value;
    var servcode = document.getElementById("HSR3").value;
    var inputFileds = document.getElementsByTagName("input");
    var chkCnt = 0;
    var totalamt = 0;
    for (var counter = 0; counter < inputFileds.length; counter++) {
      if (
        inputFileds[counter].type.toUpperCase() == "HIDDEN" &&
        inputFileds[counter].name == "servicename"
      ) {
        ++chkCnt;
        if (document.getElementById(chkCnt + "GD4").value == "F") {
          totalamt =
            parseInt(totalamt) +
            parseInt(document.getElementById(chkCnt + "GD3").value);
        }
      }
    }
    var crmode = getCookie("curuniv");
    if (crmode == "kusdde") var kusdde = 405;
    if (crmode == "kus") var kusdde = 185;

    if (servcode == "KS07")
      document.getElementById("T26").value =
        totalamt + parseInt(220) + parseInt(tranno) * kusdde;
    else document.getElementById("T26").value = totalamt + parseInt(220);
  },
  RestablishConnection: function (
    app_no,
    crmode // return from payment gateway
  ) {
    if (trim(crmode) != "") {
      var urlarr = window.location.pathname.split("/");
      var $url = "https://" + window.location.host + "/";
      $hoststr = "";
      for (var j = 1; j < urlarr.length - 1; j++) {
        $hoststr += window.location.pathname.split("/")[j] + "/";
      }
      $host_url = $url + $hoststr + "app.php?cdb=" + crmode + "&a=";
      CMS.PrintNETBANKCertifcate(app_no);
    } else {
      window.location.href = "index.html";
    }
  },
  upload_file: function (file_file) {
    var file_name = $("#" + file_file).val();
    console.log(file_file);
    var file_size = $("#" + file_file)[0].files[0].size;
    var file_extn = file_name.split(".").pop();
    var file_extn = file_extn.toLowerCase();
    if (file_extn.toLowerCase() == "pdf") {
    } else {
      alert("pdf files are allowed!");
      return false;
    }

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

    var file_data = $("#" + file_file).prop("files")[0];
    var form_data = new FormData();
    form_data.append("file", file_data);
    $.blockUI({
      message:
        "<h1 class='h1' style='font-size:12px'><img src='images/ajax-loader.gif' border='0'></h1>",
    });
    $.ajax({
      type: "POST",
      url: "upload_file.php",
      data: form_data,
      cache: false,
      contentType: false,
      processData: false,
      success: function (data) {
        console.log(data);
        $.unblockUI();
        var str = `<a href = '${data}' target='blank' >Click Here</a>`;
        document.getElementById("t" + file_file).innerHTML = str;
        $("#h_" + file_file).val(data);
        return;
      },
      error: function (data) {
        alert(data);
      },
    });
  },
  SendMailOtPToUser: function () {
    var datastring = "email=" + $("#T14").val();
    if ($("#T14").val() == "") {
      alert("Enter Email ID");
      document.getElementById("T14").focus();
      return;
    }
    $.ajax({
      type: "POST",
      url: $host_url + "SendMailOtPToUser",
      data: datastring,
      success: function (responce) {
        responce = eval("(" + responce + ")");
        if (responce.error_code == 0) {
          alert("OTP sent to the Mail.");
          $("#otp").val(responce.data);

          $("#otpbutton").prop("disabled", true);
          $("#otpbutton").css("cursor:not-allowed");
          setInterval(function () {
            $("#otpbutton").prop("disabled", false);
            $("#otpbutton").css("cursor:pointer");
          }, 300000);
          return;
        } else {
          alert("Please try after sometime");
          return;
        }
      },
    });
  },
};