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


Current Path : /var/www/oasis/js/
Upload File :
Current File : /var/www/oasis/js/absentEntryYearModewise.js

function callEnableAbsentEntryYearModewise() {
  $("#page_main_div").load(
    "../html_modules/absentEntryYearModewise.html?v=1",
    function () {
      document.getElementById("display_module_name").innerHTML =
        "Absent Entry Year / Mode wise";
      document.getElementById("module_name_for_save").value =
        "Absent Entry Year / Mode wise";
      getDefaultHeadFooterLinks("Absent Entry Year / Mode wise");
      getAbsentEntryExamDate("screen");
      //   getAbsentEntryCategory();
    }
  );
}

function getAbsentEntryExamDate(type) {
  $.blockUI({
    message:
      "<h1 class='h1' style='font-size:12px'><img src='img/ajax-loader.gif' border='0'></h1>",
  });
  $.ajax({
    type: "GET",
    url: $host_url + "loaddeggrprmsNew",
    success: function (res) {
      let response = JSON.parse(res);
      let opt = "<option value=''>---select---</option>";
      if (response.error_code === 0) {
        for (let i = 0; i < response.data.exmmonth.length; i++) {
          opt += `<option value='${
            response.data.exmmonth[i].fyear +
            "-" +
            response.data.exmmonth[i].fexamtype
          }'>${response.data.exmmonth[i].fexamdate}</option>`;
        }
      }
      if (type === "screen") {
        $("#id_absent_year_mode_wise_exam").html(opt);
      } else {
        $("#id_absent_year_mode_wise_exam_report").html(opt);
        let deggrp = "<option value=''>---select---</option>";
        for (let i = 0; i < response.data.deggp.length; i++) {
          deggrp += `<option value='${response.data.deggp[i].fdeggrp}'>${response.data.deggp[i].fdeggrp} - ${response.data.deggp[i].fdescpn}</option>`;
        }
        $("#id_absent_year_mode_wise_deggrp_report").html(deggrp);
      }
      $.unblockUI();
    },
  });
}

// function getAbsentEntryCategory() {
//   $.blockUI({
//     message:
//       "<h1 class='h1' style='font-size:12px'><img src='img/ajax-loader.gif' border='0'></h1>",
//   });
//   $.ajax({
//     type: "GET",
//     url: $host_url + "GetSubSubjectCategory.demo" + "&type=ab",
//     success: function (res) {
//       let response = JSON.parse(res);
//       let opt = "";
//       if (response.error_code === 0) {
//         for (let i = 0; i < response.data.length; i++) {
//           opt += `<option value='${response.data[i].Code}'>${response.data[i].Name}</option>`;
//         }
//       }
//       $("#id_absent_year_mode_wise_category").html(opt);
//       document.getElementById(
//         "id_absent_year_mode_wise_category"
//       ).disabled = true;
//       $.unblockUI();
//     },
//   });
// }

function getSubjectNameByQpcode() {
  let qpcode = $("#id_absent_year_mode_wise_qpcode").val();
  let yearmode = $("#id_absent_year_mode_wise_exam").val();

  if (yearmode == "") {
    alert("select examination");
    return;
  }

  let split = yearmode.split("-");
  let year = split[0];
  let examtype = split[1];

  $.blockUI({
    message:
      "<h1 class='h1' style='font-size:12px'><img src='img/ajax-loader.gif' border='0'></h1>",
  });

  $.ajax({
    type: "GET",
    url:
      $host_url +
      "getSubjectDetTimetable" +
      "&qp_code=" +
      qpcode +
      "&year=" +
      year +
      "&examtype=" +
      examtype,
    success: function (res) {
      let response = JSON.parse(res);
      console.log(response);

      let subname = document.getElementById("id_absent_year_mode_wise_subname");
      let date = document.getElementById("id_absent_year_mode_wise_exam_date");
      let session = document.getElementById(
        "id_absent_year_mode_wise_exam_session"
      );
      if (response.error_code === 0) {
        subname.value = response.data.FSSUBNAME;
        date.value = response.data.FDOE;
        session.value = response.data.FSESSION;
      } else {
        subname.value = "";
        date.value = "";
        session.value = "";
      }
      $.unblockUI();
    },
  });
}

let arr = [];

function viewAbsentEntryDetails() {
  let yearmode = $("#id_absent_year_mode_wise_exam").val();
  let category = $("#id_absent_year_mode_wise_category").val();
  let qpcode = $("#id_absent_year_mode_wise_qpcode").val();
  let examDate = $("#id_absent_year_mode_wise_exam_date").val();
  let session = $("#id_absent_year_mode_wise_exam_session").val();

  let split = yearmode.split("-");
  let year = split[0];
  let examtype = split[1];

  if (yearmode == "") {
    alert("select examination");
    return;
  }

  if (qpcode == "") {
    alert("select qpcode");
    return;
  }

  $.ajax({
    type: "GET",
    url:
      $host_url +
      "viewAbsentEntryDetails" +
      "&qp_code=" +
      qpcode +
      "&year=" +
      year +
      "&examtype=" +
      examtype +
      "&category=" +
      category +
      "&examDate=" +
      examDate +
      "&session=" +
      session,
    success: function (res) {
      let response = JSON.parse(res);
      console.log(response);
      arr = response.data;
      $.unblockUI();
      viewQpRowDetails();
    },
  });
}

function viewQpRowDetails() {
  let table = `<table align='center' width='80%' cellspacing='0' cellpadding='0' border='0'>
                <thead>
                    <tr>
                        <th align='left' colspan='3' class='ui-jqgrid-titlebar ui-widget-header ui-corner-tl ui-corner-tr ui-helper' style='font-size:12px; padding-left:6px; height:24px;'></th>
                    </tr>
                    <tr class='ui-state-default ui-jqgrid-hdiv'>
                        <td style='padding:2px; width:40px; border-left:1px solid #C5DBEC; border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;'>Reg. No.</td>
                        <td style='padding:2px; width:260px; border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;text-align:center;'>Name</td>
                        <td style='padding:2px; width:40px; border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;text-align:center;'>Delete</td>
                    </tr>
                </thead>
                <tbody id='qp_tbody'>`;
  for (let i = 0; i < arr.length; i++) {
    table += `<tr id='row_${i}' class='ui-widget-content jqgrow'>
            <td class='tbl_row_new' align='center' style='border-left:1px solid #C5DBEC; border-right:1px solid #C5DBEC; padding:2px;'><input value='${arr[i].FREGNO}' id='regno_${i}' onblur='getStudName(${i})' /></td>
            <td class='tbl_row_new' align='left' style='border-right:1px solid #C5DBEC; padding:2px;'><input  value='${arr[i].FNAME}' id='name_${i}' onblur='addNewQpRow(${i})' /></td>
            <td class='tbl_row_new' align='center' style='border-right:1px solid #C5DBEC; padding:2px;'><span style='background-color: #a93535f0;border: none;color: white;padding: 5px 20px;text-align: center;text-decoration: none;display: inline-block;font-size: 9px;cursor: pointer;border-radius: 7px;' onclick='deleteQpAddedRow(${i})'>Delete</span></td>
        </tr>`;
  }
  table += `</tbody></table>`;
  $("#abs_entry_data").html(table);
}

function getStudName(i) {
  let regno = $(`#regno_${i}`).val();
  console.log(arr);

  let filter = arr.filter(
    (item) =>
      item.FREGNO.toString().toLowerCase() == regno.toString().toLowerCase() &&
      item.FREGNO != ""
  );
  if (filter.length > 0) {
    alert("Register number already selected");
    return;
  }
  $.ajax({
    type: "GET",
    url: $host_url + "CheckEnteredRegisterNo.demo" + "&Regno=" + regno,
    success: function (res) {
      let response = JSON.parse(res);
      console.log(arr, response);
      $(`#name_${i}`).val(response.data.fname);
      arr[i].FNAME = response.data.fname;
      arr[i].FREGNO = regno;
    },
  });
}

function addNewQpRow(i) {
  let name = $(`#name_${i}`).val();
  arr[i].FNAME = name;
  if (arr[i].FREGNO == "") {
    return;
  }
  let obj = [{ FNAME: "", FREGNO: "" }];
  let newArr = [...arr, ...obj];
  arr = newArr;
  viewQpRowDetails();
}

function deleteQpAddedRow(i) {
  let regno = $(`#regno_${i}`).val();
  let filter = arr.filter((item) => item.FREGNO != regno);
  arr = filter;
  viewQpRowDetails();
}

function SaveAbsEntryYearModewise() {
  let yearmode = $("#id_absent_year_mode_wise_exam").val();
  let category = $("#id_absent_year_mode_wise_category").val();
  let qpcode = $("#id_absent_year_mode_wise_qpcode").val();
  let examDate = $("#id_absent_year_mode_wise_exam_date").val();
  let session = $("#id_absent_year_mode_wise_exam_session").val();

  let split = yearmode.split("-");
  let year = split[0];
  let examtype = split[1];
  const formData = new FormData();

  let newArr = arr.filter((item) => item.FREGNO != "");

  formData.append("year", year);
  formData.append("examtype", examtype);
  formData.append("category", category);
  formData.append("qpcode", qpcode);
  formData.append("examDate", examDate);
  formData.append("session", session);
  formData.append("data", JSON.stringify(newArr));

  if (window.confirm("Are you sure?")) {
    $.blockUI({
      message:
        "<h1 class='h1' style='font-size:12px'><img src='img/ajax-loader.gif' border='0'></h1>",
    });
    $.ajax({
      type: "POST",
      url: $host_url + "saveAbsentMalEntryDetails",
      data: formData,
      async: false,
      contentType: false,
      processData: false,
      cache: false,
      success: function (res) {
        $.unblockUI();
        let response = JSON.parse(res);
        if (response.error_code === 0) {
          alert(response.data.msg);
        } else {
          alert(response.data.msg);
          return;
        }
      },
    });
  }
}

function callAbsentMalpracticeReport() {
  $("#page_main_div").load(
    "../html_modules/absentEntryYearModewiseReport.html?v=1",
    function () {
      document.getElementById("display_module_name").innerHTML =
        "Absent / Malpractice Entry Report";
      document.getElementById("module_name_for_save").value =
        "Absent / Malpractice Entry Report";
      getDefaultHeadFooterLinks("Absent / Malpractice Entry Report");
      getAbsentEntryExamDate("report");
      //   getAbsentEntryCategory();
    }
  );
}

function getQPMQPAReport() {
  let examination = $("#id_absent_year_mode_wise_exam_report").val();
  let deggrp = $("#id_absent_year_mode_wise_deggrp_report").val();
  let category = $("#id_absent_year_mode_wise_category_report").val();
  let datefrom = $("#id_absent_year_mode_wise_datefrom_report").val();
  let dateto = $("#id_absent_year_mode_wise_dateto_report").val();

  let split = examination.split("-");
  let year = split[0];
  let examtype = split[1];

  if (examination == "" || deggrp == "" || datefrom == "" || dateto == "") {
    alert("All the fields are mandatory");
    return;
  }

  window.open(
    $host_url +
      "absentandmalpracticereport&year=" +
      year +
      "&examtype=" +
      examtype +
      "&deggrp=" +
      deggrp +
      "&category=" +
      category +
      "&datefrom=" +
      datefrom +
      "&dateto=" +
      dateto
  );
}