<?php include_once('header.php'); ?>

<div class="container">
  <div class="jumbotron">
    <div class="col-sm-8 mx-auto">
      <h1>Hello, <?= ucwords($_SESSION['name']) ?></h1>
      <p>
        Welcome to Admin Portal. In this portal, you will be able to update content on the main Misuku Hlls Eco's website. Note that you will not be able to update all of the website contents, but rather you are only allowed to update specific sections as outlined on the navigation bar. If you need to update anything that is not on the navigation bar, ask the IT Administrator to update it for you.
      </p>
      <p>
        If you have any questions or issues, please contact your IT Administrator.
      </p>
      <p>
        <a class="btn btn-primary" href="../../../" role="button">Go To Main Website »</a>
      </p>
    </div>
  </div>
</div>


<!-- Bootstrap core JavaScript
    ================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script>
  window.jQuery || document.write('<script src="../../js/vendor/jquery-slim.min.js"><\/script>')
</script>
<script src="../../js/vendor/popper.min.js"></script>
<script src="../../js/bootstrap.min.js"></script>
<script src="../../js/vendor/holder.min.js"></script>
<script type="text/javascript" src="../../js/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="../../js/validation.min.js"></script>
<script src="../../js/tables/jquery.dataTables.js"></script>
<script src="../../js/tables/dataTables.bootstrap4.js"></script>

<!--  summernote JS
        ============================================ -->
<script src="../../js/summernote/summernote-updated.min.js"></script>
<script src="../../js/summernote/summernote-active.js"></script>

<script>
  (function($) {
    $('#edit-vacancy').hide(); //hide new user form on page load
    'use strict';
    $(function() {
      $('#order-listing').DataTable({
        "aLengthMenu": [
          [10, 20, 35, -1],
          [10, 20, 35, "All"]
        ],
        "iDisplayLength": 10
      });
    });
  })(jQuery);


  function fetchData() {
    $.ajax({
      url: "select-posts.php",
      method: "POST",
      success: function(data) {
        $('#live_data').html(data);
      }
    });
  }
  $(document).ready(function() {

    //loads system users
    $.ajax({
      url: "select-posts.php",
      method: "POST",
      success: function(data) {
        $('#live_data').html(data);
      }
    });



    $('#new-vacancy').hide(); //hide new user form on page load
    //when a new user button has been clicked
    $('#new_vacancy').click(function() {
      $("#new-vacancy").show();
      $("#hide").click(function() {
        $("#new-vacancy").hide();
      })
    });




  });

  //delete vacancy details details
  $(document).on('click', '.btn_delete', function() {
    var id = $(this).data("id3");
    var delete_post = "delete_post";
    //alert(user+" "+id);
    if (confirm("Are you sure you want to remove this blog post?")) {
      $.ajax({
        url: "sql_statements.php",
        method: "POST",
        data: {
          post_id: id,
          action: delete_post
        },
        dataType: "text",
        success: function(data) {
          //alert(data);
          if (data == 1) {
            $("#error").fadeIn(2000, function() {
              $("#error").html('<div class="alert alert-success"> <button type="button" class="close" data-dismiss="alert">×</button><span class="icon icon-ok-circle"></span>&nbsp; A blog post has been removed!</div>');
            }); //Your username/password entered doesn't match
            $("#error").fadeOut(5000, function() {});
          }
          fetchData();
        }
      });
    }
  });

  //show vacancy details
  $(document).on('click', '.show_btn', function() {
    var id = $(this).data("id3");
    var show_post = 'show_post';

    alert(id);
    //alert(id);
    $.ajax({
      url: "sql_statements.php",
      method: "POST",
      data: {
        post_id: id,
        action: show_post
      },
      dataType: "text",
      success: function(data) {
        //alert(data);
        if (data == 1) {
          $("#error").fadeIn(2000, function() {
            $("#error").html('<div class="alert alert-success"> <button type="button" class="close" data-dismiss="alert">×</button><span class="icon icon-ok-circle"></span>&nbsp; A blog post can now be accessed by the public!</div>');
          }); //Your username/password entered doesn't match
          $("#error").fadeOut(5000, function() {});
        }
        fetchData();
      }
    });

  });

  //show vacancy details
  $(document).on('click', '.hide_btn', function() {
    var id = $(this).data("id3");
    var hide_post = 'hide_post';
    $.ajax({
      url: "sql_statements.php",
      method: "POST",
      data: {
        post_id: id,
        action: hide_post
      },
      dataType: "text",
      success: function(data) {
        //alert(data);
        if (data == 1) {
          $("#error").fadeIn(2000, function() {
            $("#error").html('<div class="alert alert-success"> <button type="button" class="close" data-dismiss="alert">×</button><span class="icon icon-ok-circle"></span>&nbsp; A blog post has been hidden from the public!</div>');
          }); //Your username/password entered doesn't match
          $("#error").fadeOut(5000, function() {});
        }
        fetchData();
      }
    });

  });
  Holder.addTheme('thumb', {
    bg: '#55595c',
    fg: '#eceeef',
    text: 'Thumbnail'
  });
</script>
</body>

</html>