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 : 3.137.170.38


Current Path : /var/www/oasis/custom_js/
Upload File :
Current File : /var/www/oasis/custom_js/evaluation.js

var g_packet_details = "";

function LoadEnableEvaluation() {
  $("#page_main_div").load("../html_modules/evaluation.html", function () {
    document.getElementById("display_module_name").innerHTML =
      "Online Valuation";
    document.getElementById("module_name_for_save").value = "Evaluation";
    getDefaultHeadFooterLinks("Evaluation");
    $("#evaluation_qp_code").focus();
  });
}
function GenerateEvaluationmarksListReport() {
  if (empty(trim($("#evaluation_qp_code").val()))) {
    alert("Please Enter QP Code");
    return false;
  }
  if (empty(trim($("#evaluation_packet_no").val()))) {
    alert("Please Enter Packet No");
    return false;
  }
  if (empty(trim($("#evaluation_val_no").val()))) {
    alert("Please Enter Valuation No");
    return false;
  }
  var str = "&evaluation_packet_no=" + trim($("#evaluation_packet_no").val());
  str += "&evaluation_qp_code=" + $("#evaluation_qp_code").val();
  str += "&evaluation_val_no=" + trim($("#evaluation_val_no").val());

  window.open($host_url + "GenerateEvaluationReport" + str);
}
function GetTeacherName() {
  var teacher_id = $("#evaluation_teacher_id").val();
  if (!empty(teacher_id)) {
    $.ajax({
      type: "POST",
      //async:false,
      data: "teacher_id=" + teacher_id,
      url: $host_url + "GetTeacherName",
      success: PopulateGetTeacherName,
    });
  }
}
function PopulateGetTeacherName(responce) {
  responce = eval("(" + responce + ")");
  if (responce.error_code == 0) {
    $("#evaluation_teacher_name").val(responce.data.FTEACHNAME);
  } else {
    alert(responce.data);
    $("#evaluation_teacher_name").val("");
  }
}

function GetPacketDetails() {
  var qp_code = $("#evaluation_qp_code").val();
  var qp_packet_no = $("#evaluation_packet_no").val();
  var val_no = $("#evaluation_val_no").val();

  var lstr_data = "qp_code=" + qp_code;
  lstr_data += "&qp_packet_no=" + qp_packet_no;
  lstr_data += "&val_no=" + val_no;

  $.blockUI({
    message:
      "<h1 class='h1' style='font-size:12px'>Getting Data... <img src='images/spinner.gif' border='0'></h1>",
  });
  $.ajax({
    type: "POST",
    //async:false,
    data: lstr_data,
    url: $host_url + "GetPacketDetails",
    success: PopulateGetPacketDetails,
  });
}
function PopulateGetPacketDetails(responce) {
  responce = eval("(" + responce + ")");
  $.unblockUI();
  g_packet_details = responce.data.packet;
  $("#question_no_wise_marks_div").load(
    "../html_modules/question_no_wise_marks.html",
    function () {
      $("#packet_details_div").html(responce.data.html);
      document.getElementById("evaluation_qp_code").disabled = "true";
      document.getElementById("evaluation_qp_code").disabled = "true";
      document.getElementById("evaluation_packet_no").disabled = "true";
      document.getElementById("evaluation_max_mark").disabled = "true";
      document.getElementById("evaluation_val_no").disabled = "true";
      document.getElementById("evaluation_teacher_id").disabled = "true";
      document.getElementById("evaluation_teacher_name").disabled = "true";
      var first_id = $("input[id*='i_mark_']")[0]["id"];

      var f_id = document.getElementById(first_id);
      f_id.focus();
      f_id.select();
    }
  );
}

function DisplaySelectedPacket(id) {
  var li_id_set = $("tr[id*='tr_']");
  jQuery.each(li_id_set, function (k, v) {
    var td_id = v["id"];
    $("#" + td_id).css("background-color", "");
  });

  $("#" + id).css("background-color", "#E1E1E1");
}

function ValidatePacketNoDetails() {
  var qp_packet_no = $("#evaluation_packet_no").val();
  var qp_code = trim($("#evaluation_qp_code").val());

  if (!empty(qp_packet_no)) {
    qp_packet_no = LPad(qp_packet_no, 4, "0");
    $("#evaluation_packet_no").val(qp_packet_no);
  }
  if (!empty(qp_code)) {
    $.ajax({
      type: "POST",
      //async:false,
      url: $host_url + "ValidatePacketNoDetails",
      data: "qp_packet_no=" + qp_packet_no + "&qp_code=" + qp_code,
      success: PopulateValidatePacketNoDetails,
    });
  }
}
function PopulateValidatePacketNoDetails(responce) {
  responce = eval("(" + responce + ")");
  if (responce.error_code == 0) {
  } else {
    //alert(responce.data);
    $("#packet_details_div").html("");
    $("#question_no_wise_marks_div").html("");
  }
}

function ValidateValNoDetails() {
  var qp_packet_no = $("#evaluation_packet_no").val();
  var qp_code = $("#evaluation_qp_code").val();
  var val_no = $("#evaluation_val_no").val();
  if (empty(qp_code)) {
    alert("Enter Qp Code No");
    return false;
  }
  if (empty(qp_packet_no)) {
    alert("Enter Packet No");
    return false;
  }
  if (empty(val_no)) {
    alert("Enter val No");
    return false;
  }
  $.ajax({
    type: "POST",
    //async:false,
    url: $host_url + "ValidateValNoDetails",
    data:
      "qp_packet_no=" +
      qp_packet_no +
      "&qp_code=" +
      qp_code +
      "&val_no=" +
      val_no,
    success: PopulateValidateValNoDetails,
  });
}
function PopulateValidateValNoDetails(responce) {
  responce = eval("(" + responce + ")");
  $g_clicked_sl_no_id = 0;
  $("#packet_details_div").html("");
  $("#question_no_wise_marks_div").html("");
  if (responce.error_code == 0) {
    GetPacketDetails();
  } else {
    alert(responce.data);
  }
}
function displayTotalVal() {
  var m_id_arr = $("input[id*='m_']");
  var tot_marks = 0;
  jQuery.each(m_id_arr, function (k, v) {
    var id = v["id"];
    var marks = $("#" + id)
      .val()
      .toUpperCase();
    $("#" + id).val(marks);
    if (
      !empty(marks) &&
      marks.toLowerCase() != "na" &&
      marks.toLowerCase() != "nnn" &&
      marks.toLowerCase() != "nn" &&
      marks.toLowerCase() != "n" &&
      marks.toLowerCase() != "aaa" &&
      marks.toLowerCase() != "ea" &&
      marks.toLowerCase() != "aa" &&
      marks.toLowerCase() != "a" &&
      marks != "-1" &&
      parseFloat(marks) > 0
    ) {
      tot_marks = parseFloat(eval(tot_marks + parseFloat(marks)));
    }
  });
  tot_marks = Math.ceil(tot_marks);
  $("#total_marks").html(tot_marks);
  DisplayColTotValues();
}
function DisplayColTotValues() {
  var k = 1;
  for (var i = 1; i <= 30; i = i + 5) {
    var tot_marks = 0;
    var end_val = i + 4;

    for (var j = i; j <= end_val; j++) {
      var marks = $("#m_" + j).val();

      if (
        !empty(marks) &&
        marks.toLowerCase() != "na" &&
        marks.toLowerCase() != "nnn" &&
        marks.toLowerCase() != "nn" &&
        marks.toLowerCase() != "n" &&
        marks.toLowerCase() != "aaa" &&
        marks.toLowerCase() != "aa" &&
        marks.toLowerCase() != "a" &&
        marks != "-1" &&
        parseFloat(marks) > 0
      ) {
        tot_marks = parseFloat(eval(tot_marks + parseFloat(marks)));
      }
    }
    $("#col_" + k + "_tot").html(tot_marks);
    k++;
  }
}
function ClearMarksSheet() {
  var m_id_arr = $("input[id*='m_']");
  var tot_marks = 0;
  jQuery.each(m_id_arr, function (k, v) {
    var id = v["id"];
    var marks = $("#" + id).val("");
  });
  $("#total_marks").html(0);
  $("#i_mark_" + $g_clicked_sl_no_id).focus();
  EnableAllSlNos();
}

function PopulateMarksSheetForSlNo() {
  if ($g_clicked_sl_no_id > 0) {
    disableOtherslNos($g_clicked_sl_no_id);
    var hidden_val = $("#txt_hidden_" + $g_clicked_sl_no_id).val();
    split_arr = hidden_val.split(",");
    for (var i = 0; i < split_arr.length; i++) {
      m_id = i + 1;
      $("#m_" + m_id).val(split_arr[i]);
      $("#m_" + m_id).attr("readOnly", "");
      $("#m_" + m_id).css("color", "");
    }
    $("#m_1").focus();
    $("#i_mark_" + $g_clicked_sl_no_id).css("color", "#FF00FF");
    displayTotalVal();
  }
}
function PopulateMarksSheetForSlNoWithDisabled() {
  if ($g_clicked_sl_no_id > 0) {
    $g_clicked_sl_no_id = $g_clicked_sl_no_id.toString();
    $g_clicked_sl_no_id = LPad($g_clicked_sl_no_id, 2, "0");
    var hidden_val = $("#txt_hidden_" + $g_clicked_sl_no_id).val();
    split_arr = hidden_val.split(",");
    if (!empty(split_arr)) {
      for (var i = 0; i < split_arr.length; i++) {
        m_id = i + 1;
        $("#m_" + m_id).val(split_arr[i]);
        $("#m_" + m_id).attr("readOnly", "readOnly");
        $("#m_" + m_id).css("color", "#D27373");
      }
      displayTotalVal();
    }
  }
}
function CancelMarksMarksSheet() {
  //var flag=confirm("All the Entered Marks will be lost!!");
  //if(flag)
  if (1) {
    //$("#td_mark_"+$g_clicked_sl_no_id).css("background-color","#E1E1E1");
    //$("#i_mark_"+$g_clicked_sl_no_id).css("background-color","#E1E1E1");

    FocusOnSlNo($g_clicked_sl_no_id);

    $g_clicked_sl_no_id = 0;
    ClearMarksSheet();
  }
}
function FocusOnSlNo(id) {
  ChangeSlNoColorsToGray();
  id = id.toString();
  var id = LPad(id, 2, "0");

  $("#i_mark_" + id).focus();
  $("#td_mark_" + id).css("background-color", "#FFF");
  $("#i_mark_" + id).css("background-color", "#FFF");

  var f_id = document.getElementById("i_mark_" + id);
  f_id.focus();
  f_id.select();
}
function SubmitMarksMarksSheet() {
  if ($("#i_mark_" + $g_clicked_sl_no_id).val() == "MP") {
    for (var i = 1; i <= 30; i++) {
      var id = "m_" + i;
      hidden_string += $("#" + id).val() + ",";
    }

    $("#txt_hidden_" + $g_clicked_sl_no_id).val(hidden_string);
    ClearMarksSheet();
    FocusOnSlNo(eval(parseFloat($g_clicked_sl_no_id) + 1));
    $("#td_mark_" + id).css("background-color", "#FFF");
    $("#i_mark_" + id).css("background-color", "#FFF");
    return true;
  }
  var m_id_arr = $("input[id*='m_']");
  var hidden_string = "";
  $g_clicked_sl_no_id = $g_clicked_sl_no_id.toString();
  $g_clicked_sl_no_id = LPad($g_clicked_sl_no_id, 2, "0");
  var final_total_val = parseFloat($("#i_mark_" + $g_clicked_sl_no_id).val());
  var total_marks_val = parseFloat($("#total_marks").html());

  if (parseFloat($g_clicked_sl_no_id) > 0) {
    if (
      total_marks_val != final_total_val &&
      final_total_val != "MP" &&
      final_total_val != "mp"
    ) {
      alert("Packet and total marks are not matching");
      document.getElementById("total_marks").focus();
      return false;
    } else {
      for (var i = 1; i <= 30; i++) {
        var id = "m_" + i;
        hidden_string += $("#" + id).val() + ",";
      }

      $("#txt_hidden_" + $g_clicked_sl_no_id).val(hidden_string);
      ClearMarksSheet();
    }
    FocusOnSlNo(eval(parseFloat($g_clicked_sl_no_id) + 1));
    $("#td_mark_" + id).css("background-color", "#FFF");
    $("#i_mark_" + id).css("background-color", "#FFF");
  } else {
    alert("Please Select any Sl No first");
    return false;
  }
}
function checkMaxValMarks(this_obj) {
  //PopulateMarksSheetForSlNo();
  if (
    parseFloat(this_obj.value) > parseFloat($("#evaluation_max_mark").val())
  ) {
    alert("Entered Marks should be less than Max Marks....");
    $("#" + this_obj.id).focus();
    $("#" + this_obj.id).val("");

    return false;
  } else if (parseFloat(this_obj.value) < -3) {
    alert("Entered Marks should be More than -3....");
    var f_id = document.getElementById(this_obj.id);
    f_id.focus();
    $("#" + this_obj.id).val("");
    f_id.select();

    return false;
  }
}
function ChangeSlNoColorsToGray() {
  var td_id_arr = $("td[id*='td_mark_']");

  jQuery.each(td_id_arr, function (k, v) {
    var id = v["id"];
    var input_id = id.replace("td_mark_", "i_mark_");
    $("#" + id).css("background-color", "#E1E1E1");
    $("#" + input_id).css("background-color", "#E1E1E1");
    $("#" + input_id).css("color", "");
  });
}
function ChangeCellColorAssignIdOnKeyPress(sl_no) {
  ChangeSlNoColorsToGray();
  $("#i_mark_" + sl_no).focus();
  $("#td_mark_" + sl_no).css("background-color", "#FFF");
  $g_clicked_sl_no_id = sl_no;
  $g_clicked_sl_no_id = $g_clicked_sl_no_id.toString();
  $g_clicked_sl_no_id = LPad($g_clicked_sl_no_id, 2, "0");

  $("#td_mark_" + sl_no).css("background-color", "#FFF");
  $("#i_mark_" + sl_no).css("background-color", "#FFF");
  $("#i_mark_" + sl_no).css("color", "");

  $g_clicked_sl_no_id = sl_no;
  $g_clicked_sl_no_id = $g_clicked_sl_no_id.toString();
  $g_clicked_sl_no_id = LPad($g_clicked_sl_no_id, 2, "0");

  $("#i_mark_" + sl_no).keypress(function (e) {
    if (e.keyCode == 40) {
      //up
      var inr_sl_no = eval(parseFloat(sl_no) + 1);

      $g_clicked_sl_no_id = inr_sl_no;
      FocusOnSlNo(inr_sl_no);
      PopulateMarksSheetForSlNoWithDisabled();
    }

    if (e.keyCode == 38) {
      //down
      var dec_sl_no = eval(parseFloat(sl_no) - 1);
      FocusOnSlNo(dec_sl_no);
      $g_clicked_sl_no_id = dec_sl_no;
      PopulateMarksSheetForSlNoWithDisabled();
    }

    if (e.keyCode == 13) {
      //Enter
      $("#td_mark_" + sl_no).css("background-color", "#FFF");
      $("#i_mark_" + sl_no).css("background-color", "#FFF");

      PopulateMarksSheetForSlNo();
    }
    if (e.keyCode == 9) {
      //Tab
      e.preventDefault();
      PopulateMarksSheetForSlNo();
    }
  });
}
function OnDbClickSlNo(sl_no) {
  $g_clicked_sl_no_id = sl_no;
  $g_clicked_sl_no_id = $g_clicked_sl_no_id.toString();
  $g_clicked_sl_no_id = LPad($g_clicked_sl_no_id, 2, "0");
  $("#td_mark_" + sl_no).css("background-color", "#FFF");
  $("#i_mark_" + sl_no).css("background-color", "#FFF");

  PopulateMarksSheetForSlNo();
}
function ChangeCellColorAssignIdOnClick(sl_no) {
  ChangeSlNoColorsToGray();
  $("#i_mark_" + sl_no).focus();
  $("#td_mark_" + sl_no).css("background-color", "#FFF");
  $g_clicked_sl_no_id = sl_no;
  $g_clicked_sl_no_id = $g_clicked_sl_no_id.toString();
  $g_clicked_sl_no_id = LPad($g_clicked_sl_no_id, 2, "0");

  $("#td_mark_" + sl_no).css("background-color", "#FFF");
  $("#i_mark_" + sl_no).css("background-color", "#FFF");
  $("#i_mark_" + sl_no).css("color", "");

  $g_clicked_sl_no_id = sl_no;
  $g_clicked_sl_no_id = $g_clicked_sl_no_id.toString();
  $g_clicked_sl_no_id = LPad($g_clicked_sl_no_id, 2, "0");
  PopulateMarksSheetForSlNoWithDisabled();
}

function disableOtherslNos(sl_no) {
  var td_id_arr = $("td[id*='td_mark_']");

  jQuery.each(td_id_arr, function (k, v) {
    var id = v["id"];
    var input_id = id.replace("td_mark_", "i_mark_");

    $("#" + input_id).attr("disabled", "disabled");
  });
  $("#i_mark_" + sl_no).removeAttr("disabled", "disabled");
}
function EnableAllSlNos() {
  var td_id_arr = $("td[id*='td_mark_']");

  jQuery.each(td_id_arr, function (k, v) {
    var id = v["id"];
    var input_id = id.replace("td_mark_", "i_mark_");

    $("#" + input_id).removeAttr("disabled", "disabled");
  });
}

function SaveEvaluation() {
  var qp_code = $("#evaluation_qp_code").val();
  var qp_packet_no = $("#evaluation_packet_no").val();
  var val_no = $("#evaluation_val_no").val();
  var max_mark = $("#evaluation_max_mark").val();

  var lstr_data = "qp_code=" + qp_code;
  lstr_data += "&qp_packet_no=" + qp_packet_no;
  lstr_data += "&val_no=" + val_no;
  // lstr_data+="&evaluation_teacher_id="+evaluation_teacher_id;

  var valuation_obj = new Object();
  j = 0;
  jQuery.each(g_packet_details, function (ke, v) {
    id = v["FSLNO"];
    valuation_obj[j] = new Object();
    valuation_obj[j]["sl_no_val"] = id;
    valuation_obj[j]["f_marks"] = $("#txt_hidden_" + id).val();
    var pak_tot = $("#i_mark_" + id).val();

    if (empty(pak_tot) && pak_tot != "0") pak_tot = "-1";

    if (pak_tot.toUpperCase() == "MP") pak_tot = "-3";

    valuation_obj[j]["packet_total"] = pak_tot;
    j++;
  });

  var myjsonvaluation_obj = JSON.stringify(valuation_obj);

  lstr_data += "&valuation_packet_details=" + myjsonvaluation_obj;
  $.blockUI({
    message:
      "<h1 class='h1' style='font-size:12px'>Saving... <img src='images/spinner.gif' border='0'></h1>",
  });
  $.ajax({
    type: "POST",
    //async:false,
    url: $host_url + "SaveEvaluation",
    data: lstr_data,
    success: SaveEvaluationResponse,
  });
}
function SaveEvaluationResponse(responce) {
  responce = eval("(" + responce + ")");
  $.unblockUI();
  if (responce.error_code == 0) {
    var print_flag = confirm(
      "Data Saved Successfully! Do you want to print Report`"
    );
    if (print_flag) {
      var str =
        "&evaluation_packet_no=" + trim($("#evaluation_packet_no").val());
      str += "&evaluation_qp_code=" + $("#evaluation_qp_code").val();
      str += "&evaluation_val_no=" + trim($("#evaluation_val_no").val());
      window.location.href = $host_url + "GenerateEvaluationReport" + str;
    }
  } else alert(responce.data);
}