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


Current Path : /proc/thread-self/root/var/www/html/pgadm/js/
Upload File :
Current File : //proc/thread-self/root/var/www/html/pgadm/js/add-course.js

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

var gstudInfo = [];
function loadApplyAddCourse() {
  console.log($host_url);
  $.ajax({
    type: "GET",
    async: false,
    url: $host_url + "getAddCourseStatus",
    success: (response) => {
      response = JSON.parse(response);
      if (response.error_code == 0) {
        $("#loadTab").load("add-course.html", function () {
          var html = "";
          var row = response.data.info;
          gstudInfo = response.data.info;
          console.log(row);
          html += `<thead>
                <tr><th>Name</th> <th>:</th><th>${row["fname"]}</th></tr>
                <tr><th>Mobile No</th> <th>:</th><th>${row["fmobileno"]}</th></tr>
                <tr><th>Application Number</th> <th>:</th><th>${row["fappno"]}</th></tr>
                <tr><th>Category</th> <th>:</th><th>${row["fcategory"]}</th></tr>
                <tr><th>Qualifying Degree</th> <th>:</th><th>${row["fdescpn"]}</th></tr>
                <tr><th>Qualifying Degree Combination</th> <th>:</th><th>${row["fcombdesc"]}</th></tr>
                  </thead>
                  `;
          html += `</table>`;
          $("#AppStat").html(html);
          var optdeg = response.data.optdeg;

          var optdegtable = `<table class='table table-bordered table-upd' id="optdet">
            <thead>
            <tr class="bg-cyan">
            <td style="width :5%;text-align: center;">Sl. No.</td>
            <td style="width : 50%;text-align: center;">Degree Name</td>
            <td style="width : 5%;text-align: center;">Select</td>
            </tr>
            </thead>
            <tbody>`;

          var i = 1;

          optdeg.forEach((element) => {
            let disabled = "";
            if (element.sddeg == "checked") {
              disabled = "disabled";
            }
            optdegtable += `<tr>
            <td style="text-align: center;">${i}</td>
            <td id="doc_upload_1">${element.fdescpn}
             <input type = 'hidden' value = '${element.fdegree}' id = 'h_optdeg_${i}'>
            </td>
            <td style="text-align:center;">
              <input ${disabled} type = 'checkbox' style="text-align:center;" ${element.sddeg} 
              value = '${element.fdegree}' id = 'deg_${i}' name = 'optdeg' 
              onchange = getAddFeestr('${row["fcategory"]}')>
              <label for="deg_${i}" style="font-size:10px !important;text-align:center; ">
              </label>
            </td>`;
            optdegtable += `</tr>`;
            i++;
          });
          optdegtable += `</tbody></table>`;
          $("#adddeg").html(optdegtable);
        });
      } else {
        swal({
          title: `${response.data.msg}`,
          html: true,
          showCancelButton: false,
          warning: true,
          confirmButtonColor: "#5495ff",
          confirmButtonText: "OK",
          closeOnConfirm: false,
        });
      }
    },
  });
}

function getAddFeestr(cat) {
  var arrlength = $('[name="optdeg"]:enabled:checked').length;
  $.ajax({
    type: "POST",
    url: $host_url + "getFees",
    data: "&fcatcode=" + cat,
    success: (response) => {
      var { error_code, data, status } = JSON.parse(response);
      var table = ``;
      // console.log(data);
      var feeData = data.feestr;
      if (error_code == 0) {
        totalFee = 0;
        table = `
        <table class="table table-bordered table-hover" id='mainTable'>
        <thead style = 'height:40px;background-color: #184F76 !important;color: #fff;'>
          <tr>
            <th style="text-align: center;">    SL. No.   </th>
            <th style="text-align: center;">    Head Code   </th>
            <th style="text-align: center;">    Fee   </th>
          </tr>
        </thead>`;
        feeData.map((el, i) => {
          let addsubfee = 0;
          let appfee = data.feestr[0].fmaxfee * arrlength;
          data.feestr[0].fmaxfee = appfee;

          var db = window.location.pathname.split("/")[2];
          if (db == "dud") {
            if (arrlength > 1) {
              if (el.fheadcode == "02 Application Fee") {
                addsubfee =
                  Number(data.feestr[1].fmaxfee) +
                  Number(data.feestr[1].frepfee) * (Number(arrlength) - 1);
                data.feestr[1].fmaxfee = addsubfee;
              }
            }
          }

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

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

function applyForAdditionalCourse() {
  var arrlength = $('[name="optdeg"]:enabled:checked').length;
  
  if(arrlength == 0) {
    swal({
      title: `Select Degree to apply`,
      html: true,
      showCancelButton: false,
      warning: true,
      confirmButtonColor: "#5495ff",
      confirmButtonText: "OK",
      closeOnConfirm: false,
    });    
  }

  finaloptdeg = Array();
  
  for (let i = 1; i <= $('[name="optdeg"]').length; i++) {
    if ($('#deg_' + i).is(":checked:enabled")) {
      item = {};
      item["optdeg"] = $(`#h_optdeg_${i}`).val();
      finaloptdeg.push(item);
    }
  }
  var totalfee = parseInt($(`#ttlAmt`).html());
  console.log(totalfee);
  if(totalfee <= 0) {
    swal({
      title: `Fees cannot be zero`,
      html: true,
      showCancelButton: false,
      warning: true
    });     
  }

  $.ajax({
    type: "POST",
    url: $host_url + "applyForAddCourse",
    data: "degrees=" + JSON.stringify(finaloptdeg)+ 
      "&totalfee="+ totalfee + "&gstudInfo="+ JSON.stringify(gstudInfo),
    success: (response) => {
      response = JSON.parse(response);
      if(response.error_code == -1) {
        swal({
          title: response.data.msg,
          html: true,
          showCancelButton: false,
          warning: true,
          confirmButtonColor: "#5495ff",
          confirmButtonText: "OK",
          closeOnConfirm: false,
        });    
      }else {
        console.log(response.data.faddappno);
        var appno = response.data.faddappno;
        makepaymentforAddCourse(appno, "026");
      }
    }
  });
}


function makepaymentforAddCourse(appno, funivcode) {
  $.ajax({
    type: "POST",
    url: $host_url + "addCourseGetPayDet",
    data: "appno="+appno,
    success: responce => {
      var { error_code, data, status } = JSON.parse(responce);
      if (error_code == -1) {
        swal({
          title: data.msg,
          html: true,
          showCancelButton: false,
          confirmButtonColor: "#5495ff",
          confirmButtonText: "OK",
          closeOnConfirm: false
        });
      } else if (error_code == 0) {
        $("#loadTab").load("add-course-payment.html", function() {
          var html = "";
          html += `<thead>
                <tr><th>Ref. Number</th> <th>:</th><th>${data.appno}</th></tr>
                <tr><th>Fee to be paid</th> <th>:</th><th>${data.totalfee}</th></tr>  
              </thead>`;
          html += `</table>`;

          $("#studInfo").html(html);
          var optdegtable = `<h4> Degrees opted </h4>
          <table class='table table-bordered table-upd' id="optdet" style="width:50%">
            <thead>
            <tr class="bg-cyan">
              <td style="width :5%;text-align: center;">Sl. No.</td>
              <td style="width : 50%;text-align: center;">Degree Name</td>
            </tr>
            </thead>
            <tbody>`;
            let j = 1;
          for(let deg of data.fdegree) {
            optdegtable += `<tr>
              <td style="text-align: center;">${j}</td>
              <td id="doc_upload_1">${deg.fdescpn}
            </td>
            </tr>`;
            j++;
          }
          optdegtable += `</tbody></table>`;
          $("#adddeg").html(optdegtable); 

          var table = `<table class="makepayment" width="100%" 
          border = "1" cellspacing="0" cellpadding="5" style = "margin:1% auto;">
            <thead>
                <tr>
                  <th style = "text-align: center;width = 20%;">Logo</th>
                  <th style = "text-align: center;width = 30%;">Bank Charges</th>
                  <th style = "text-align: center;width = 10%;">Action</th>
                </tr>
              </thead>
            <tbody>`;
          var masbank = data["masbank"];

          for (var i = 0; i < masbank.length; i++) {
            if (
              masbank[i]["fbank"].toLowerCase() == "razorpay" ||
              masbank[i]["fbank"].toLowerCase() == "paytm"
            ) {
              var appno = data.appno;
              var button = "";
              var db = window.location.pathname.split("/")[2];
              var funivcode = "";
              if (db == "vskub") funivcode = "026";
              else if (db == "rcub") funivcode = "027";
              else if (db == "dud") funivcode = "023";

              table += `<tr>
                <td width = "12%;" style = "text-align: center;">
                                    <img height="60" width="150" src = "../${
                                      masbank[i]["fbanklog"]
                                    }" />
                                </td>
                                 <td width = "20%;" style = "text-align: center;">
                                     ${masbank[i]["fbankcharge"]}
                                </td>`;
              console.log(masbank[i]["fbank"].toLowerCase());
              if (masbank[i]["fbank"].toLowerCase() == "razorpay") {
                $.ajax({
                  type: "POST",
                  async: false,
                  data: "appno=" + appno + "&funivcode=" + funivcode,
                  url: "../razorpay/pay.php",
                  success: function(responce) {
                    button = responce;
                  }
                });
                table += `<td width = "15%;"><center>${button}</center></td> </tr>`;
              } else {
                table += `<td width = "15%;" ><center>
                  <button class = "btn btn-primary" type="button" 
                  onclick="makepaymentdet('${masbank[i]["fbank"]}','${appno}',
                  '${masbank[i]["funivcode"]}')">Make Payment</button>
                  </center></td>
                </tr>`;
              }
            }
          }
          table += `</tbody></table>`;
          // console.log(table);
          $("#makepayment").html(table);
          return;
        });
      }
    }
  });
}