<?php
session_start();
$session=session_id();
$times=time();
$time_check=$times-600; //กำหนดเวลาในที่นี้ผมกำหนด 10 นาที
require("inc/config.inc.php");
require("inc/common.php");
require("inc/useronline.php");
//error_reporting(~E_NOTICE);
error_reporting(E_ALL & ~E_WARNING & ~E_NOTICE);
# ป้องกัน sql injection จาก $_GET
foreach ($_GET as $key => $value) {
  $_GET[$key]=addslashes(strip_tags(trim($value)));
}

if ($_GET['id'] !='') { $_GET['id']=(int) $_GET['id']; }
extract($_GET);
#--- สิ้นสุด ป้องกัน sql injection จาก $_GET
//error_reporting(display_errors);
if (!isset($_SESSION['login'])) 
{
	/*
	echo("<script>");
    echo("window.location='login.php';");
   	echo("</script>"); 
	*/
    if($_GET['op']==""){
         include("login.php"); 
     }
     else
     {
       include("pages/".$_GET['op'].".php");
     }
 

}
else
{

?>
<!DOCTYPE html>
<html lang="en">

<head>

  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <meta name="description" content="<?=$system_name_th?> <?=$school_name?>">
  <meta name="author" content="<?=$system_name_th?> <?=$school_name?>">
  <title><?=$system_name_th?> <?=$school_name?></title>
	
	
<!--   <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> -->
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>	
  <!-- Bootstrap core CSS -->
 <link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet"> 
 <link href='https://fonts.googleapis.com/css?family=Kanit:400,300&subset=thai,latin' rel='stylesheet' type='text/css'>	
 <link rel="stylesheet" href="assets/font-awesome/css/font-awesome.min.css">

	
	

	<!-- 	<link rel="stylesheet" href="assets/css/form-elements.css"> -->
        <!-- Favicon and touch icons -->
        <link rel="shortcut icon" href="assets/ico/favicon.png">
        
   <style>
		body {
		  font-family: 'Kanit', sans-serif;
		}
		h1 {
		  font-family: 'Kanit', sans-serif;
		}

		.table-condensed{
		  font-size: 14px;
		}
	   .table-condensed-sm{
		  font-size: 12px;
		}
	   .img-fluid {
		  max-width: 100%;
		  height: auto;
		}
#myBtn {
  display: none;
  position: fixed;
  bottom: 10px;
  right: 30px;
  z-index: 99;
  font-size: 12px;
  border: none;
  outline: none;
  background-color: red;
  color: white;
  cursor: pointer;
  padding: 10px;
  border-radius: 4px;
}
#myBtn:hover {
  background-color: #555;
}
    </style>	
  <!-- Custom styles for this template -->
  <link href="css/business-frontpage.css" rel="stylesheet">
	
	
<link rel="stylesheet" href="css/loading.css">
<script>
$(window).load(function() {
    $(".bg_load").fadeOut("slow");
    $(".wrapper").fadeOut("slow");
})
</script>
<script>
function myHide()
{
	document.getElementById('hidepage').style.display='block';//content ที่ต้องการแสดงหลังจากเพจโหลดเสร็จ
	document.getElementById('hidepage2').style.display='none';//content ที่ต้องการแสดงระหว่างโหลดเพจ
}
</script>	
</head>

<body onload="myHide();">
<div id="hidepage2" style="display:block;" align="center" width="100%">
<br>
	<div class="wrapper">
    <div class="inner">
		    <span>L</span>
        <span>o</span>
        <span>a</span>
        <span>d</span>
        <span>i</span>
        <span>n</span>
        <span>g</span> 
		<!--
        <span>L</span>
        <span>o</span>
        <span>a</span>
        <span>d</span>
        <span>i</span>
        <span>n</span>
        <span>g</span> -->
    </div>
</div>
</div>
 <div class="container"  id="hidepage" style="display:none;">
<button onclick="topFunction()" id="myBtn" title="Go to top"><i class="fa fa-arrow-up"  style="font-size:24px"></i><br>ด้านบน</button>
 <!--   <div class="container" >	-->
  <!-- Navigation -->
  <?php 
if($_SESSION['login']=="admin" or $_SESSION['login']=="user"){	
	//$section_group=$_SESSION['section_group'];
  $section_group=$_SESSION['section_group'];
  $user_id=$_SESSION['user_id'];
	include("pages/$section_group-menu.php"); 
	echo"<br>";
	include("pages/$section_group-profile.php"); 
     if($_GET['op']==""){
       include("pages/$section_group-home.php");
     }
     else
     {
       include("pages/$section_group-".$_GET['op'].".php");
     }
}
 
 //สำหรับครูที่ปรึกษา
 if($_SESSION['login']=="advisor"){	
	$section_group=$_SESSION['login'];
	include("pages/$section_group-menu.php"); 
	echo"<br>";
	include("pages/$section_group-profile.php"); 
     if($_GET['op']==""){
       include("pages/$section_group-home.php");
     }
     else
     {
       include("pages/$section_group-".$_GET['op'].".php");
     }
}
 
 
//สำหรับนักศึกษา
 if($_SESSION['login']=="student"){	
	$section_group=$_SESSION['login'];
	include("pages/$section_group-menu.php"); 
	echo"<br>";
     if($_GET['op']==""){
       include("pages/$section_group-choose.php");
     }
     else
     {
       include("pages/$section_group-".$_GET['op'].".php");
     }
}
 ?>
  <!-- /.container -->
<?php include("page-footer.php"); ?></p>
	</div>
	
  <!-- Footer
<!--
  <footer class="py-2 bg-dark">
    <div class="container">
      <p class="m-0 text-white">

    </div>
  </footer>
 -->
    <!-- /.container -->
  <!-- Bootstrap core JavaScript -->
  <script src="vendor/jquery/jquery.min.js"></script> 
  <script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>  

</body>

</html>
<!----- loading page -------->

<div class="bg_load"></div>
<div class="wrapper">
    <div class="inner">
    <span>L</span>
        <span>o</span>
        <span>a</span>
        <span>d</span>
        <span>i</span>
        <span>n</span>
        <span>g</span> 
    </div>
</div>
<!----- end loading page -------->
<?php
}
?>

<script>
//Get the button
var mybutton = document.getElementById("myBtn");

// When the user scrolls down 20px from the top of the document, show the button
window.onscroll = function() {scrollFunction()};

function scrollFunction() {
  if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
    mybutton.style.display = "block";
  } else {
    mybutton.style.display = "none";
  }
}

// When the user clicks on the button, scroll to the top of the document
function topFunction() {
  document.body.scrollTop = 0;
  document.documentElement.scrollTop = 0;
}
</script>