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


Current Path : /proc/thread-self/root/var/www/oasis/js/
Upload File :
Current File : //proc/thread-self/root/var/www/oasis/js/createattclass.js

function createattclass() {
  $("#page_main_div").load("../html_modules/createattclass.html?", function () {
    document.getElementById("display_module_name").innerHTML = "Create Class";
    document.getElementById("module_name_for_save").value = "Create Class";
    getDefaultHeadFooterLinks("Create Class");
    if (window.db == "jssu") {
      $("#dept_row").hide();
    }
    loadTeaherList();
  });
}

function loadTeaherList() {
  $.blockUI({
    message:
      "<h1 class='h1' style='font-size:12px'><img src='img/ajax-loader.gif' border='0'></h1>",
  });
  $.ajax({
    type: "GET",
    async: false,
    data: "dept=" + $("#deptcode").val(),
    url: $host_url + "loadTeaherList",
    success: function (response) {
      var res = JSON.parse(response);

      if (res.error_code == 0) {
        if (res.data["masteach"].length == 1) {
          var teacheoptions = "";
          $("#teachcode").prop("disabled", true);
        } else {
          var teacheoptions = "<option value=''>---Select Teacher---</option>";
          $("#teachcode").prop("disabled", false);
        }

        for (var i = 0; i < res.data["masteach"].length; i++) {
          teacheoptions += `<option value='${res.data["masteach"][i].fteachcode}'>${res.data["masteach"][i].fteachcode} - ${res.data["masteach"][i].fteachname}</option>`;
        }

        $("#teachcode").html(teacheoptions);

        var deptopt = "<option value='All'>--All--</option>";
        for (var i = 0; i < res.data["masdept"].length; i++) {
          deptopt += `<option value='${res.data["masdept"][i].FDEPTCODE}'>${res.data["masdept"][i].FDEPTCODE} - ${res.data["masdept"][i].FDEPTNAME}</option>`;
        }

        $("#deptcode").html(deptopt);
        $.unblockUI();
      } else {
        alert(res.data.msg);
        $.unblockUI();
        return;
      }
    },
  });
}

function loadteachdept() {
  $.blockUI({
    message:
      "<h1 class='h1' style='font-size:12px'><img src='img/ajax-loader.gif' border='0'></h1>",
  });
  $.ajax({
    type: "GET",
    async: false,
    data: "dept=" + $("#deptcode").val(),
    url: $host_url + "loadteachdept",
    success: function (response) {
      var res = JSON.parse(response);

      if (res.error_code === 0) {
        if (res.data["masteach"].length == 1) {
          var teacheoptions = "";
          $("#teachcode").prop("disabled", true);
        } else {
          var teacheoptions = "<option value=''>---Select Teacher---</option>";
          $("#teachcode").prop("disabled", false);
        }

        for (var i = 0; i < res.data["masteach"].length; i++) {
          teacheoptions += `<option value='${res.data["masteach"][i].fteachcode}'>${res.data["masteach"][i].fteachcode} - ${res.data["masteach"][i].fteachname}</option>`;
        }

        $("#teachcode").html(teacheoptions);
      }

      $.unblockUI();
    },
  });
}

function viewAttClassCreate() {
  $("#page_main_div").load("../html_modules/editattclass.html?", function () {
    loadTachClass();
  });
}

function loadTachClass() {
  var teachfrom = $("#teachfrom").val();
  var teachto = $("#teachto").val();

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

  $.ajax({
    type: "GET",
    data: parameters,
    url: $host_url + "viewAttClassCreate",
    success: function (response) {
      var encode = JSON.parse(response);

      var table = `<table align="center" width="100%" cellspacing="0" cellpadding="1" border="1" style="border-radius:5px">
      <thead>
        <tr>
        <th align="left" colspan="7" class="ui-jqgrid-titlebar ui-widget-header ui-corner-tl ui-corner-tr ui-helper" 
        style="font-size:12px; padding-left:6px; height:24px;">Class Details</th>
        </tr>

        <tr class="ui-state-default ui-jqgrid-hdiv">
        <td align="center" style="width:30px; font-size:12px; 
        border-left:1px solid #C5DBEC;border-right:1px solid #C5DBEC; 
        border-bottom:1px solid #C5DBEC;">Sl. No.</td>
        <td align="center" style="width:50px; font-size:12px; 
        border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;">Class ID</td>
        <td align="center" style="width:355px; font-size:12px; 
        border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;">Teacher Name</td>

        <td align="center" style="width:355px; font-size:12px; padding:5px 5px; 
        border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;">Class Name</td>

        <td align="center" style="width:155px; font-size:12px; padding:5px 5px; 
        border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;">Action</td>

        </tr>
        </thead> <tbody>`;
      var slno = 1;
      var checked = "";

      if (encode.error_code == 0) {
        for (var i = 0; i < encode.data.length; i++) {
          let btn = "";
          if (window.db === "jssstu") {
            btn = "";
          } else {
            btn = `<span
            style="
              background-color: #008cba;
              border: none;
              color: white;
              padding: 5px 20px;
              text-align: center;
              text-decoration: none;
              display: inline-block;
              font-size: 12px;
              cursor: pointer;
            "
            onclick="editAttClass('${encode.data[i].fclassid}','${encode.data[i].fteachcode}','${encode.data[i].fclassname}')"
            >Edit</span>`;
          }
          table += `<tr class="ui-widget-content jqgrow">
            <td class="tbl_row_new" style="border-left:1px solid #C5DBEC; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;text-align:center;">${slno++}</td>

            <td class="tbl_row_new" style="text-align:initial;border-right:1px solid #C5DBEC; padding:2px; font-size:12px;">${
              encode.data[i].fclassid
            }</td>

            <td class="tbl_row_new" style="text-align:initial;border-right:1px solid #C5DBEC; padding:2px; font-size:12px;">${
              encode.data[i].fteachname
            }</td>

            <td class="tbl_row_new" style="text-align:initial; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;">${
              encode.data[i].fclassname
            }</td>

            <td id = "present" class="tbl_row_new" style="text-align:center; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;">
            ${btn}
            <span
            style="
              background-color: red;
              border: none;
              color: white;
              padding: 5px 20px;
              text-align: center;
              text-decoration: none;
              display: inline-block;
              font-size: 12px;
              cursor: pointer;
            "
            onclick="deleteAttClass('${encode.data[i].fclassid}','${
            encode.data[i].fteachcode
          }','${encode.data[i].fclassname}')"
            >Delete</span>
          </td>`;

          table += `</tr>`;
        }
        table += `</tbody></table>`;
      }
      $("#createview").html(table);
      $.unblockUI();
    },
  });
}

function editAttClass(fclassid, fteachcode, fclassname) {
  $("#page_main_div").load("../html_modules/createattclass.html?", function () {
    document.getElementById("display_module_name").innerHTML = "Create Class";
    document.getElementById("module_name_for_save").value = "Create Class";
    getDefaultHeadFooterLinks("Create Class");
    loadTeaherList();

    $("#teachcode").val(fteachcode);
    $("#classname").val(fclassname);
    $("#classid").val(fclassid);
  });
}

function deleteAttClass(fclassid, fteachcode, fclassname) {
  let text = "Are you sure you want to delete?";
  if (confirm(text) == true) {
    $.ajax({
      type: "GET",
      url: $host_url + "deleteAttClass",
      data:
        "teachcode=" +
        fteachcode +
        "&classname=" +
        fclassname +
        "&classid=" +
        fclassid,
      success: function (response) {
        var res = JSON.parse(response);
        if (res.error_code == "0") {
          alert(res.data);
          loadTachClass();
        } else {
          alert(res.data);
          return;
        }
      },
    });
  } else {
  }
}

function saveAttClass() {
  var teachcode = $("#teachcode").val();
  var classname = $("#classname").val();
  var classid = $("#classid").val();

  if (teachcode == "") {
    alert("Select Teacher Name");
    $("#teachcode").focus();
    return;
  }

  if (classname == "") {
    alert("Enter Class Name");
    $("#classname").focus();
    return;
  }
  $.blockUI({
    message:
      "<h1 class='h1' style='font-size:12px'><img src='img/ajax-loader.gif' border='0'></h1>",
  });

  $.ajax({
    type: "GET",
    url: $host_url + "saveAttClass",
    data:
      "teachcode=" +
      teachcode +
      "&classname=" +
      classname +
      "&classid=" +
      classid,
    success: function (response) {
      var res = JSON.parse(response);
      if (res.error_code == "0") {
        alert(res.data);
        viewAttClassCreate();
      } else {
        alert(res.data);
        $.unblockUI();
        return;
      }
      $.unblockUI();
    },
  });
}

function reportCreateAttClass() {
  var teachfrom = $("#teachfrom").val();
  var teachto = $("#teachto").val();

  var parameters = "&teachfrom=" + teachfrom + "&teachto=" + teachto;
  window.open($host_url + "reportAttClassCreate" + parameters);
}