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


Current Path : /var/www/html/gcg/adm/admin/js/pg/
Upload File :
Current File : /var/www/html/gcg/adm/admin/js/pg/pgmainpage.js

function loadPGData() {
  //loaddashboard();
  $.ajax({
    type: "post",
    url: "src/login.php",
    //data:parameters,
    success: function(response) {
      response = JSON.parse(response);
      var { status } = response;
      if (status === "loggedin") {
        ({ USER, USERTYPE } = response);
        if (USERTYPE === "usr") $("#createUserMenu").hide();
        loadPGApplications();
      } else {
        alert("please login");
        window.location.href = "index.html";
      }
    }
  });
}

function loadPGApplications() {
  $("#loadtab").load("html_modules/pg/pgapplications.html", function() {
    $("#appdetl").hide();
    $.ajax({
      type: "post",
      async: true,
      url: "src/pg/pgdegree.php",
      success: function(response) {
        response = JSON.parse(response);

        var { degree } = response;

        var str = `<option>-Select-</option>`;
        for (var i = 0; i < degree.length; i++) {
          var degarry = degree[i];
          str += `<option value = "${degarry[0]}">${degarry[1]}</option>`;
        }

        $("#degree").html("");
        $("#degree").html(str);
      }
    });
  });
}

function getPGAppDetails() {
  if (!$("#appRangeForm").valid()) {
    return;
  }
  var parameters = "fdegree=" + $("#degree").val();
  parameters += "&fromapp=" + $("#fromapp").val();
  parameters += "&toapp=" + $("#toapp").val();
  parameters += "&rtype=" + $("#rtype").val();

  function getcodes(param) {}
  $.ajax({
    type: "post",
    url: "src/pg/getpgapps.php",
    data: parameters,
    success: function(response) {
      response = JSON.parse(response);
      var { apps: app_obj_arr } = response;
      $(".js-exportable").html("");
      $("#appdetl").show();
      var app_arr = [];
      //get array of applications
      for (var i in app_obj_arr) {
        var arr = $.map(app_obj_arr[i], function(el) {
          return el;
        });
        app_arr.push(arr);
      }

      table = $(".js-exportable").DataTable({
        dom: "Bfrtip",
        destroy: true,
        responsive: true,
        data: app_arr,
        columnDefs: [
          {
            targets: 0,
            searchable: false,
            orderable: false,
            className: "dt-body-center",
            render: function(data, type, full, meta) {
              //console.log(data);
              return (
                '<center><input type="checkbox" name="id[]" class="filled-in chk-col-light-blue" id="' +
                $("<div/>")
                  .text(data)
                  .html() +
                '" value="' +
                $("<div/>")
                  .text(data)
                  .html() +
                '"> <lable for="' +
                $("<div/>")
                  .text(data)
                  .html() +
                '"> </label></center>'
              );
            }
          },
          {
            targets: 10,
            searchable: false,
            orderable: false,
            className: "dt-body-center",
            render: function(data, type, full, meta) {
              return '<center><button name="id[]" class = "btn btn-primary details">Details</button></center>';
            }
          }
        ],
        order: [[1, "asc"]],
        columns: [
          {
            title:
              "<center><input type='checkbox' name='select_all' value='1' id='select-all'/></center>"
          },
          { title: "App. No." },
          { title: "Name" },
          { title: "Father Name" },
          { title: "Mobile" },
          { title: "Email" },
          { title: "Fees" },
          { title: "Pay. Type" },
          { title: "Payment Status" },
          { title: "Status" },
          { title: "Deatils" }
        ],

        lengthMenu: [[2, 4, 8, -1], [2, 4, 8, "All"]],
        pageLength: 200,
        buttons: ["copy", "csv", "excel", "pdf", "print"]
      });
      //check already assigned user
      var rows = table.rows({ search: "applied" }).nodes();
      $('input[type="checkbox"]', rows).prop("checked", this.checked);

      /*var check_arr = app_arr.filter((app) => { return app[7] != '';});
          for(let i in check_arr){
            $(`#${check_arr[i][0]}`).prop('checked', true);
          }*/

      $("#select-all").on("click", function() {
        // Check/uncheck all checkboxes in the table
        var rows = table.rows({ search: "applied" }).nodes();
        $('input[type="checkbox"]', rows).prop("checked", this.checked);
      });

      $(".details").on("click", function() {
        var appno = $(this)
          .parents("tr")
          .find('input[type="checkbox"]')
          .val();
        var parameters = "&appno=" + appno;
        $.ajax({
          type: "post",
          url: "src/pg/pgstuddet.php",
          data: parameters,
          async: false,
          success: function(response) {
            response = JSON.parse(response);

            var user = response.user;
            var disabled = "";

            var trRow = ``;
            // var z = 1;
            // var sub = response.subjdet.split("~");
            // jQuery.each(sub, function(i, val) {
            //   subject = val.split("->");
            //   subjectarry += `<tr>
            //                 <td>
            //                  ${z}
            //                 </td>
            //                 <td>
            //                   ${subject[1]}
            //                 </td>
            //                 <td>
            //                    ${subject[0]}
            //                 </td>
            //               </tr>`;
            //   z++;
            // });
            //console.log(subjectarry);
            var rowIncrId = 1;
            console.log(response.pgmarks.length);
            for (
              var rowIncrId = 0;
              rowIncrId < response.pgmarks.length;
              rowIncrId++
            ) {
              obj = response.pgmarks[rowIncrId];
              console.log(obj);
              trRow += `<tr id = "${rowIncrId}" class='ui-widget-content jqgrow'>
							<td>
							<input type="text" name="subsem1_${rowIncrId}"  
                            value = "${obj[2]}"
							id = "subsem1_${rowIncrId}" >
							<input type="hidden" name="subcode_${rowIncrId}"  id = "subcode_${rowIncrId}" value="S0${rowIncrId}">
						</td>
						<td>
							<input type="text" name="subsem1mo_${rowIncrId}" 
							onchange = "gettoal('${rowIncrId}')"  
                            maxlength="4"
                            style="width:40px"
							value = "${obj[3]}"
							onkeypress="return acceptNumbersOnlyForModule(event);" 
							id = "subsem1mo_${rowIncrId}">
						</td>
						<td>
							<input type="text" name="subsem1mm_${rowIncrId}" 
							onchange = "gettoal('${rowIncrId}')" maxlength="4"
                            value = "${obj[4]}"
                            style="width:40px"
							onkeypress="return acceptNumbersOnlyForModule(event);" 
							id = "subsem1mm_${rowIncrId}">
						</td>
						<td  >
							<input type="text" name="subsem2mo_${rowIncrId}" 
							onchange = "gettoal('${rowIncrId}')" maxlength="4"
                            value = "${obj[5]}"
                            style="width:40px"
							onkeypress="return acceptNumbersOnlyForModule(event);" 
							id = "subsem2mo_${rowIncrId}">
						</td>
						<td>
							<input type="text" name="subsem2mm_${rowIncrId}" 
							onchange = "gettoal('${rowIncrId}')" maxlength="4"
                            value = "${obj[6]}"
                            style="width:40px"
							onkeypress="return acceptNumbersOnlyForModule(event);" 
							id = "subsem2mm_${rowIncrId}">
						</td>
						<td >
							<input type="text" name="subsem3mo_${rowIncrId}" 
                            value = "${obj[7]}"
                            style="width:40px"
							onchange = "gettoal('${rowIncrId}')" maxlength="4"
							onkeypress="return acceptNumbersOnlyForModule(event);" 
							id = "subsem3mo_${rowIncrId}">
						</td>
						<td >
							<input type="text" name="subsem3mm_${rowIncrId}" 
                            value = "${obj[8]}"
                            style="width:40px"
							onchange = "gettoal('${rowIncrId}')" maxlength="4"
							onkeypress="return acceptNumbersOnlyForModule(event);" 
							id = "subsem3mm_${rowIncrId}">
						</td>
						<td >
							<input type="text" name="subsem4mo_${rowIncrId}" 
                            value = "${obj[9]}"
                            style="width:40px"
							onchange = "gettoal('${rowIncrId}')" maxlength="4"
							onkeypress="return acceptNumbersOnlyForModule(event);" 
							id = "subsem4mo_${rowIncrId}">
						</td>
						<td >
							<input type="text" name="subsem4mm_${rowIncrId}" 
                            value = "${obj[10]}"
                            style="width:40px"
							onchange = "gettoal('${rowIncrId}')" maxlength="4"
							onkeypress="return acceptNumbersOnlyForModule(event);" 
							id = "subsem4mm_${rowIncrId}">
						</td>
						<td >
							<input type="text" name="subsem5mo_${rowIncrId}" 
                            value = "${obj[11]}"
                            style="width:40px"
							onchange = "gettoal('${rowIncrId}')" maxlength="4"
							onkeypress="return acceptNumbersOnlyForModule(event);" 
							id = "subsem5mo_${rowIncrId}">
						</td>
						<td>
							<input type="text" name="subsem5mm_${rowIncrId}" 
                            value = "${obj[12]}"
                            style="width:40px"
							onchange = "gettoal('${rowIncrId}')" maxlength="4"
							onkeypress="return acceptNumbersOnlyForModule(event);" 
							id = "subsem5mm_${rowIncrId}">
						</td>
						<td >
							<input type="text" name="subsem6mo_${rowIncrId}"
                            value = "${obj[13]}"
                            style="width:40px"
							onchange = "gettoal('${rowIncrId}')" maxlength="4"
							onkeypress="return acceptNumbersOnlyForModule(event);" 
							id = "subsem6mo_${rowIncrId}">
						</td>
						<td >
							<input type="text" name="subsem6mm_${rowIncrId}" 
                            value = "${obj[14]}"
                            style="width:40px"
							onchange = "gettoal('${rowIncrId}')" maxlength="4"
							onkeypress="return acceptNumbersOnlyForModule(event);" 
							id = "subsem6mm_${rowIncrId}">
						</td>
						<td>
							<input type="text" name="subtotalmo_${rowIncrId}" 
                            value = "${obj[15]}"
                            style="width:40px"
							maxlength="4"  
							onkeypress="return acceptNumbersOnlyForModule(event);" 
							id = "subtotalmo_${rowIncrId}">
						</td>
						<td>
							<input type="text" name="subtotalmm_${rowIncrId}" 
                            value = "${obj[16]}" 
                            style="width:40px"
							maxlength="4"  
							onkeypress="return acceptNumbersOnlyForModule(event);" 
							id = "subtotalmm_${rowIncrId}">
						</td>
						<td>
							<input type="text" name="subpercentagemm_${rowIncrId}" 
							maxlength="5"  
                            value = "${obj[17]}" 
                            style="width:40px"
							onkeypress="return acceptNumbersOnlyForModule(event);" 
							id = "subpercentagemm_${rowIncrId}">
						</td>
						
                    </tr>`;
            }

            //rowIncrId = rowIncrId + 1;

            trRow += `<tr id = "${rowIncrId}" class='ui-widget-content jqgrow'>
							<td>
							<input type="text" name="subsem1_${rowIncrId}"  
                            value = ""
							id = "subsem1_${rowIncrId}" >
							<input type="hidden" name="subcode_${rowIncrId}"  id = "subcode_${rowIncrId}" value="S0${rowIncrId}">
						</td>
						<td>
							<input type="text" name="subsem1mo_${rowIncrId}" 
							onchange = "gettoal('${rowIncrId}')"  
                            maxlength="4"
                            style="width:40px"
							value = ""
							onkeypress="return acceptNumbersOnlyForModule(event);" 
							id = "subsem1mo_${rowIncrId}">
						</td>
						<td>
							<input type="text" name="subsem1mm_${rowIncrId}" 
							onchange = "gettoal('${rowIncrId}')" maxlength="4"
                            value = ""
                            style="width:40px"
							onkeypress="return acceptNumbersOnlyForModule(event);" 
							id = "subsem1mm_${rowIncrId}">
						</td>
						<td  >
							<input type="text" name="subsem2mo_${rowIncrId}" 
							onchange = "gettoal('${rowIncrId}')" maxlength="4"
                            value = ""
                            style="width:40px"
							onkeypress="return acceptNumbersOnlyForModule(event);" 
							id = "subsem2mo_${rowIncrId}">
						</td>
						<td>
							<input type="text" name="subsem2mm_${rowIncrId}" 
							onchange = "gettoal('${rowIncrId}')" maxlength="4"
                            value = ""
                            style="width:40px"
							onkeypress="return acceptNumbersOnlyForModule(event);" 
							id = "subsem2mm_${rowIncrId}">
						</td>
						<td >
							<input type="text" name="subsem3mo_${rowIncrId}" 
                            value = ""
                            style="width:40px"
							onchange = "gettoal('${rowIncrId}')" maxlength="4"
							onkeypress="return acceptNumbersOnlyForModule(event);" 
							id = "subsem3mo_${rowIncrId}">
						</td>
						<td >
							<input type="text" name="subsem3mm_${rowIncrId}" 
                            value = ""
                            style="width:40px"
							onchange = "gettoal('${rowIncrId}')" maxlength="4"
							onkeypress="return acceptNumbersOnlyForModule(event);" 
							id = "subsem3mm_${rowIncrId}">
						</td>
						<td >
							<input type="text" name="subsem4mo_${rowIncrId}" 
                            value = ""
                            style="width:40px"
							onchange = "gettoal('${rowIncrId}')" maxlength="4"
							onkeypress="return acceptNumbersOnlyForModule(event);" 
							id = "subsem4mo_${rowIncrId}">
						</td>
						<td >
							<input type="text" name="subsem4mm_${rowIncrId}" 
                            value = ""
                            style="width:40px"
							onchange = "gettoal('${rowIncrId}')" maxlength="4"
							onkeypress="return acceptNumbersOnlyForModule(event);" 
							id = "subsem4mm_${rowIncrId}">
						</td>
						<td >
							<input type="text" name="subsem5mo_${rowIncrId}" 
                            value = ""
                            style="width:40px"
							onchange = "gettoal('${rowIncrId}')" maxlength="4"
							onkeypress="return acceptNumbersOnlyForModule(event);" 
							id = "subsem5mo_${rowIncrId}">
						</td>
						<td>
							<input type="text" name="subsem5mm_${rowIncrId}" 
                            value = ""
                            style="width:40px"
							onchange = "gettoal('${rowIncrId}')" maxlength="4"
							onkeypress="return acceptNumbersOnlyForModule(event);" 
							id = "subsem5mm_${rowIncrId}">
						</td>
						<td >
							<input type="text" name="subsem6mo_${rowIncrId}"
                            value = ""
                            style="width:40px"
							onchange = "gettoal('${rowIncrId}')" maxlength="4"
							onkeypress="return acceptNumbersOnlyForModule(event);" 
							id = "subsem6mo_${rowIncrId}">
						</td>
						<td >
							<input type="text" name="subsem6mm_${rowIncrId}" 
                            value = ""
                            style="width:40px"
							onchange = "gettoal('${rowIncrId}')" maxlength="4"
							onkeypress="return acceptNumbersOnlyForModule(event);" 
							id = "subsem6mm_${rowIncrId}">
						</td>
						<td>
							<input type="text" name="subtotalmo_${rowIncrId}" 
                            value = ""
                            style="width:40px"
							maxlength="4" readonly 
							onkeypress="return acceptNumbersOnlyForModule(event);" 
							id = "subtotalmo_${rowIncrId}">
						</td>
						<td>
							<input type="text" name="subtotalmm_${rowIncrId}" 
                            value = "" 
                            style="width:40px"
							maxlength="4" readonly 
							onkeypress="return acceptNumbersOnlyForModule(event);" 
							id = "subtotalmm_${rowIncrId}">
						</td>
						<td>
							<input type="text" name="subpercentagemm_${rowIncrId}" 
							maxlength="5" readonly 
                            value = "" 
                            style="width:40px"
							onkeypress="return acceptNumbersOnlyForModule(event);" 
							id = "subpercentagemm_${rowIncrId}">
						</td>
						
                    </tr>`;

            $("#idModal2").empty();
            $("#idModal2").append(`<div class="body" id="body">
                    <table class = "table">
                    <tr>
                      <th>
                        Personal Information
                      </th>
                      </tr>
                      <tr>
                            <td>Name </td>
                            <td><input id = "name"  class = "form-control" ${disabled}  type = 'text' value = "${
              response.perdetl.FNAME
            }"></td>
                                                            <td>Father Name</td>
                                                            <td><input id = "fname" class = "form-control" ${disabled} type = 'text' value = "${
              response.perdetl.FFATNAME
            }"></td>
                      </tr>
                      <tr>
                          <td>Category</td>
                          <td>
                            <select  class="form-control" id = "category">
                                <option value = "">
                                    -Select-
                                </option>  
                                <option>
                                    GM
                                </option>
                                <option>
                                    CAT-I
                                </option>
                                <option>
                                    IIA
                                </option>
                                <option>
                                    IIB
                                </option>
                                <option>
                                    IIIA
                                </option>
                                <option>
                                    IIIB
                                </option>
                                <option>
                                    SC
                                </option>
                                <option>
                                    ST
                                </option>
                            </select>
                           </td>
                          <td>Gender</td>
                          <td>
                            <select id = "fgender" class="form-control">
                                <option value = ''>-Select-<option>
                                <option value = 'M'>Male<option>
                                <option value = 'F'>Female<option>
                                <option value = 'T'>Transgender<option>
                            </select> 
                          </td>
                      
                      </tr>
                      <tr>
                          <td>Caste</td>
                          <td><input id = "caste"  class = "form-control" ${disabled} type = 'text' value = "${
              response.perdetl.FCATBIRTH
            }"> </td>
                          <td>Special Category</td>
                          <td>
                            <select id="sttype" class="form-control" name="Special Category">
                                <option value="">--Select--</option>
                                <option value="No">Not Applicable</option>
                                <option value="NSS">NSS</option>
                                <option value="NCC">NCC</option>
                                <option value="Sports">Sports</option>
                                <option value="Scout and Guides">Scout and Guides</option>
                            </select> 
                          </td>
                      </tr>
                      <tr>
                          <td>Date Of Birth</td>
                          <td><input id = "fdob" class = "form-control"  ${disabled} type = 'text' value = "${
              response.perdetl.FDOB
            }"> 
            <input type = "hidden" id = "fdegree" value = "${
              response.perdetl.FDEGREE
            }"></td>
                          <td> Mobile Numbe</td>
                          <td><input id = "fmobile" class = "form-control"  ${disabled} type = 'text' value = "${
              response.perdetl.FMOBILENO
            }"> </td> 
                      </tr>
                      <tr>
                          <td>Claim under section 371J?</td>
                          <td>
                            <select id = "f371j" class="form-control">
                                <option value = ''>-Select-<option>
                                <option value = 'T'>Yes<option>
                                <option value = 'F'>No<option>
                            </select> 
                          </td>
                          <td>Are you a person with disability?</td>
                          <td>
                            <select id = "fpwd" class="form-control">
                                <option value = ''>-Select-<option>
                                <option value = 'T'>Yes<option>
                                <option value = 'F'>No<option>
                            </select> 
                          </td>
                      </tr>
                                             
                      </table>
                      </br>
                      <table width='80%' id = "qalsemdet" class='table table-bordered table-striped'>
                              <tr class='bg-cyan'>
                                <td rowspan="2">
                                  Subject
                                </td>
                                <td colspan="2">
                                  Sem / Year I
                                </td>
                                <td colspan="2">
                                  Sem / Year II
                                </td>
                                <td colspan="2">
                                  Sem / Year III
                                </td>
                                <td colspan="2">
                                  Sem / Year IV
                                </td>
                                <td colspan="2">
                                  Sem / Year V
                                </td>
                                <td colspan="2">
                                  Sem / Year VI
                                </td>
                                <td colspan="2">
                                  Total Marks
                                </td>
                                <td rowspan="2">
                                  % of Marks
                                </td>
                              </tr>
                              <tr class='bg-cyan'>
                                <td>
                                  Obt
                                </td>
                                <td>
                                  Max
                                </td>
                                <td>
                                  Obt
                                </td>
                                <td>
                                  Max
                                </td>
                                <td>
                                  Obt
                                </td>
                                <td>
                                  Max
                                </td>
                                <td>
                                  Obt
                                </td>
                                <td>
                                  Max
                                </td>
                                <td>
                                  Obt
                                </td>
                                <td>
                                  Max
                                </td>
                                <td>
                                  Obt
                                </td>
                                <td>
                                  Max
                                </td>
                                <td>
                                  Obt
                                </td>
                                <td>
                                  Max
                                </td>
                              </tr>
                            ${trRow}
                            </table>
                            </br>
                      <table class = "table">
                        <th>
                          Fee Details
                        </th>
                        <tr>
                          <td>Payment Mode</td>
                          <td><input id = "fcollcode" class = "form-control"  ${disabled} type = 'text' value = "${
              response.perdetl.fpaymenttype
            }"> </td>
                          <td>Amount</td>
                          <td><input id = "amount" class = "form-control"  ${disabled} type = 'text' value = "${
              response.perdetl.FTOTFEE
            }"> </td> 
                          <td>Payment Status</td>
                          <td><input id = "fpaystatus" class = "form-control"  ${disabled} type = 'text' value = "${
              response.perdetl.fpaystatus
            }"> </td> 
                          <td>Reference No</td>
                          <td><input id = "appno" class = "form-control"  ${disabled} type = 'text' value = "${
              response.perdetl.FAPPNO
            }"> </td> 
                        </tr>
                      </table>
                      <table class = "table">
                        <th>
                          Acknowledgement
                        </th>
                         <tr>
                            <td>
                              Remarks
                            </td>
                             <td>
                                <input id = "fremarks" class = "form-control" type = 'text' value = "${
                                  response.perdetl.fremarks
                                }" >       
                             </td>
                             <td>
                              Status
                            </td>
                             <td>
                                <select  id = "status">
                                <option value = "">
                                  -select-
                                  </option>  
                                <option value = "APPROVED">
                                    Approved
                                  </option>
                                  <option value = "REJECT">
                                    Reject
                                  </option>
                                </select>
                             </td>
                        </tr>
                      </table>
                      <div class='p-b-20 p-t-20'>
                          <center>
                          <button type='button' class='btn btn-primary m-r-20' onclick='saveApplication("${
                            response.perdetl.FAPPNO
                          }")'>Save</button>
                          <button type='button' class='btn btn-secondary' data-dismiss='modal'>Close</button>
                          </center>
                      </div>
                    </div>`);
            $("#status").val(response.perdetl.FAPPSTATUS);
            $("#fremarks").val(response.perdetl.fremarks);
            $("#category").val(response.perdetl.FCASTE);
            $("#fgender").val(response.perdetl.FGENDER);
            $("#sttype").val(response.perdetl.FSTUTYPE);
            $("#fpwd").val(response.perdetl.fpwd);
            $("#f371j").val(response.perdetl.f371j);
            $("#idModal1").modal();
          }
        });
      });
    }
  });
}

function saveApplication(appno) {
  var fapprstatus = $("#status").val();
  var fremarks = $("#fremarks").val();
  var category = $("#category").val();
  var fgender = $("#fgender").val();
  var sttype = $("#sttype").val();
  var fpwd = $("#fpwd").val();
  var f371j = $("#f371j").val();
  var caste = $("#caste").val();
  var fdegree = $("#fdegree").val();
  var rgMultiMarks = [];

  $("#qalsemdet tr.ui-widget-content").each((i, el) => {
    var rgQal = $(el).find("td input");
    var rgTr = [];
    $.each(rgQal, (j, val) => {
      var item = {};
      item["name"] = val.name;
      item["value"] = val.value;
      rgTr.push(item);
    });
    rgMultiMarks.push(rgTr);
  });

  var parameters =
    "&rgMultiMarks=" +
    JSON.stringify(rgMultiMarks) +
    "&f371j=" +
    f371j +
    "&fpwd=" +
    fpwd +
    "&sttype=" +
    sttype +
    "&fgender=" +
    fgender +
    "&category=" +
    category +
    "&fremarks=" +
    fremarks +
    "&fapprstatus=" +
    fapprstatus +
    "&appno=" +
    appno +
    "&caste=" +
    caste +
    "&fdegree=" +
    fdegree;

  $.ajax({
    type: "post",
    url: "src/pg/savepgstudadm.php",
    data: parameters,
    success: function(response) {
      response = JSON.parse(response);
      var { status, msg } = response;
      if (status === "success") {
        alert("updated");
        $("#idModal1").modal("toggle");
        getPGAppDetails();
      } else {
        $("#idModal1").modal("toggle");
      }
    }
  });
}

function gettoal(i) {
  var semmo1 = parseInt($("#subsem1mo_" + i).val());
  var semmm1 = parseInt($("#subsem1mm_" + i).val());

  // if (semmo1 > semmm1 && !isNaN(semmm1)) {
  //   alert("sem 1 obtained marks is greater than the max. marks");
  //   $("#subsem1mm_" + i).val("");
  //   $("#subsem1mo_" + i).val("");
  //   $("#subsem1mo_" + i).focus();
  //   return;
  // }

  var semmo2 = parseInt($("#subsem2mo_" + i).val());
  var semmm2 = parseInt($("#subsem2mm_" + i).val());

  // if (semmo2 > semmm2 && !isNaN(semmm2)) {
  //   alert("sem 2 obtained marks is greater than the max. marks");
  //   $("#subsem2mm_" + i).val("");
  //   $("#subsem2mo_" + i).val("");
  //   $("#subsem2mo_" + i).focus();
  //   return;
  // }

  var semmo3 = parseInt($("#subsem3mo_" + i).val());
  var semmm3 = parseInt($("#subsem3mm_" + i).val());

  // if (semmo3 > semmm3 && !isNaN(semmm3)) {
  //   alert("sem 3 obtained marks is greater than the max. marks");
  //   $("#subsem3mm_" + i).val("");
  //   $("#subsem3mo_" + i).val("");
  //   $("#subsem3mo_" + i).focus();
  //   return;
  // }

  var semmo4 = parseInt($("#subsem4mo_" + i).val());
  var semmm4 = parseInt($("#subsem4mm_" + i).val());

  // if (semmo4 > semmm4 && !isNaN(semmm4)) {
  //   alert("sem 4 obtained marks is greater than the max. marks");
  //   $("#subsem4mm_" + i).val("");
  //   $("#subsem4mo_" + i).val("");
  //   $("#subsem4mo_" + i).focus();
  //   return;
  // }

  var semmo5 = parseInt($("#subsem5mo_" + i).val());
  var semmm5 = parseInt($("#subsem5mm_" + i).val());

  // if (semmo5 > semmm5 && !isNaN(semmm5)) {
  //   alert("sem 5 obtained marks is greater than the max. marks");
  //   $("#subsem5mm_" + i).val("");
  //   $("#subsem5mo_" + i).val("");
  //   $("#subsem5mo_" + i).focus();
  //   return;
  // }

  var semmo6 = parseInt($("#subsem6mo_" + i).val());
  var semmm6 = parseInt($("#subsem6mm_" + i).val());

  // if (semmo6 > semmm6 && !isNaN(semmm6)) {
  //   alert("sem 6 obtained marks is greater than the max. marks");
  //   $("#subsem6mm_" + i).val("");
  //   $("#subsem6mo_" + i).val("");
  //   $("#subsem6mo_" + i).focus();
  //   return;
  // }

  var totobt = 0;
  var totmarks = 0;

  if (
    !isNaN(semmo1) &&
    !isNaN(semmo2) &&
    !isNaN(semmo3) &&
    !isNaN(semmo4) &&
    !isNaN(semmo5) &&
    !isNaN(semmo6)
  ) {
    totobt =
      parseInt(semmo1) +
      parseInt(semmo2) +
      parseInt(semmo3) +
      parseInt(semmo4) +
      parseInt(semmo5) +
      parseInt(semmo6);
    $("#subtotalmo_" + i).val(totobt);
  }

  if (
    !isNaN(semmm1) &&
    !isNaN(semmm2) &&
    !isNaN(semmm3) &&
    !isNaN(semmm4) &&
    !isNaN(semmm5) &&
    !isNaN(semmm6)
  ) {
    totmarks =
      parseInt(semmm1) +
      parseInt(semmm2) +
      parseInt(semmm3) +
      parseInt(semmm4) +
      parseInt(semmm5) +
      parseInt(semmm6);
    $("#subtotalmm_" + i).val(totmarks);
    var totpercetage = (parseInt(totobt) / parseInt(totmarks)) * 100;
    $("#subpercentagemm_" + i).val(Math.round(totpercetage * 100) / 100);
  }
}

function loadMeritList() {
  $("#loadtab").load("html_modules/pg/pgmeritlist.html", function() {
    $.ajax({
      type: "post",
      async: true,
      url: "src/pg/pgdegree.php",
      success: function(response) {
        response = JSON.parse(response);

        var { degree } = response;

        var str = `<option>-Select-</option>`;
        for (var i = 0; i < degree.length; i++) {
          var degarry = degree[i];
          str += `<option value = "${degarry[0]}">${degarry[1]}</option>`;
        }

        $("#degree").html("");
        $("#degree").html(str);
      }
    });
  });
}

function loadChangePassord() {
  $("#loadtab").load("html_modules/pg/changePassword.html");
}

function updatePassord() {
  if (!$("#createUserForm").valid()) {
    return;
  }

  var password = $("#usrname").val();
  var cpassword = $("#password").val();

  if (cpassword != password) {
    alert("password not mactching please try again");
    $("#usrname").val("");
    $("#password").val("");
    return;
  }

  var parameters = `&password=${password}`;

  $.ajax({
    type: "post",
    url: "src/pg/updatePassord.php",
    data: parameters,
    success: function(response) {
      response = JSON.parse(response);
      var { status, msg } = response;
      if (status == "success") {
        alert(msg);
        pgsignOut();
      } else {
        alert(msg);
      }
    }
  });
}

function pgsignOut() {
  $.ajax({
    type: "post",
    url: "src/logout.php",
    //data:parameters,
    success: function(response) {
      if (response === "logout") {
        window.location.href = "pgindex.html";
      }
    }
  });
}

function getReportDetails() {
  var degree = $("#degree").val();
  var rtype = $("#rtype").val();

  window.location.href =
    "src/pg/meritList.php?degree=" + degree + "&rtype=" + rtype;

  // $.ajax({
  //   type: "post",
  //   url: "src/pg/meritList.php",
  //   data: "&degree=" + degree + "&rtype=" + rtype,
  //   success: function(response) {}
  // });
}