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


Current Path : /var/www/oasis/js_old/
Upload File :
Current File : /var/www/oasis/js_old/Message_board.js

function LoadEnableMessageBoard() {
  $geditinternalcode = 0;
  $("#page_main_div").load("../html_modules/message_board.html", function() {
    document.getElementById("display_module_name").innerHTML = "Message Board";
    document.getElementById("module_name_for_save").value = "SaveMessageBoard";
    getDefaultHeadFooterLinks("Message Board");
    GetCollegeCodeDetails();
  });
}

function GetCollegeCodeDetails() {
  $.ajax({
    type: "POST",
    async: false,
    url: $host_url + "GetCollegeCodeDetails",
    success: populateGetCollegeCodeDetails
  });
}

function populateGetCollegeCodeDetails($responce) {
  $responce = eval("(" + $responce + ")");
  if ($responce.error_code == "0") {
    document.getElementById("message_board_college_code").options.length = 0;
    $op = new Option("Select One", "0");
    $op.id = "0";
    document.getElementById("message_board_college_code").options.add($op);
    for ($i = 0; $i < $responce.data["col"].length; $i++) {
      $op = new Option(
        $responce.data["col"][$i]["College_code"],
        $responce.data["col"][$i]["internal_code"]
      );
      $op.id = $responce.data["col"][$i]["internal_code"]; //specifying the id  for options
      document.getElementById("message_board_college_code").options.add($op);
    }
    var college_code = getCookie("college_code");

    if (getCookie("user_type") == "Admin" || getCookie("user_type") == "User") {
      document.getElementById(
        "message_board_college_code"
      ).value = college_code;
      $("#message_board_from_date").val($responce.data.today_date);
      $("#message_board_to_date").val($responce.data.today_date);
      document.getElementById("message_board_college_code").disabled = "true";
      document.getElementById("message_board_college_code").style.color = "red";
    }
  }
}

function SaveMessageBoard() {
  $lstr_data = "internal_code=" + $geditinternalcode;
  $lstr_data +=
    "&message_board_college_code=" +
    trim($("#message_board_college_code").val());
  $lstr_data +=
    "&message_board_from_date=" +
    date_format($("#message_board_from_date").val());
  $lstr_data +=
    "&message_board_to_date=" + date_format($("#message_board_to_date").val());
  $lstr_data +=
    "&message_board_message=" +
    encodeURIComponent($("#message_board_message").val());

  $.ajax({
    type: "POST",
    async: false,
    url: $host_url + "SaveMessageBoard",
    data: $lstr_data,
    success: SaveMessageBoardResponce
  });
}

function SaveMessageBoardResponce($responce) {
  $responce = eval("(" + $responce + ")");
  alert($responce.data);
}

function ViewMessageBoard() {
  $geditinternalcode = 0;
  $main =
    "<table id='table_message_grid' class='scroll' ondblclick='getMessageBoardDetails(id);'></table> <div id='sub_grid_div' class='scroll' style='text-align:center;'></div>";
  document.getElementById("page_main_div").innerHTML = $main;
  var msg_board = jQuery("#table_message_grid")
    .jqGrid({
      url: $host_url + "ViewMessageBoard",
      datatype: "json",
      colNames: ["College Code", "From Date", "To Date", "Message"],
      colModel: [
        { name: "grid_college_code", index: "grid_college_code", width: 115 },
        { name: "grid_from_date", index: "grid_from_date", width: 115 },
        { name: "grid_to_date", index: "grid_to_date", width: 115 },
        { name: "grid_message", index: "grid_message", width: 115 }
      ],
      rowNum: 10,
      rowList: [5, 10, 15, 20, 25, 30],
      imgpath: $img_path,
      pager: jQuery("#sub_grid_div"),
      sortname: "id",
      height: "70%",
      viewrecords: true,
      sortorder: "desc",
      multiselect: true,
      cellEdit: true,
      width: "850",
      caption: "Message Board",
      editurl: $host_url + "DeleteMessageBoard"
    })
    .navGrid(
      "#sub_grid_div",
      { edit: false, add: false, del: true, search: true },
      {},
      {},
      {},
      { multipleSearch: true }
    )
    .navButtonAdd("#sub_grid_div", {
      caption: "Toggle",
      buttonicon: "ui-icon-pin-s",
      onClickButton: function() {
        msg_board[0].toggleToolbar();
      }
    })
    .navButtonAdd("#sub_grid_div", {
      caption: "Edit",
      onClickButton: function() {
        getMessageBoardDetails(id);
      }
    });
  msg_board.filterToolbar();
}

function getMessageBoardDetails(id) {
  var id = jQuery("#table_message_grid").getGridParam("selrow");
  if (id > 0) {
    LoadEnableMessageBoard();
    $.ajax({
      type: "POST",
      //async:false,
      url: $host_url + "getMessageBoardDetails",
      data: "internal_code=" + id,
      success: getMessageBoardDetailsresponse
    });
    $geditinternalcode = id;
  } else {
    alert("Please select row");
  }
}

function getMessageBoardDetailsresponse($responce) {
  $responce = eval("(" + $responce + ")");
  if ($responce.error_code == 0) {
    //console.log($responce.data);
    $geditinternalcode = $responce.data.internal_code;
    $("#message_board_college_code").val($responce.data.college_code);
    $("#message_board_from_date").val($responce.data.display_from);
    $("#message_board_to_date").val($responce.data.display_to);
    $("#message_board_message").val($responce.data.message);
  }
}