<?php
	session_start();
	
	// เช็คว่าเข้าสู่ระบบหรือยัง
	if(!isset($_SESSION['ses_acc_id']))
	{
		header("location:../index.php");
		exit();
	}

	$session_id = $_SESSION['ses_acc_id'];
	$status_user = $_SESSION['ses_acc_status'];
	$session_user = $_SESSION['ses_acc_user'];

	session_write_close();

	require_once("../config/mysql_connect.php");

	// Templates
	$strSQL = "SELECT * FROM setting_templates WHERE tem_status='on'";
	$objQuery = mysqli_query($link,$strSQL);
	$Result = mysqli_fetch_array($objQuery);
	$ses_tem_url = $Result['tem_url'];

	$strSQL = "SELECT * FROM setting_default";
	$objQuery = mysqli_query($link,$strSQL);
	$Result = mysqli_fetch_array($objQuery);
	$def_title = $Result['def_title'];
	$def_footer = $Result['def_footer'];
	$def_banner = $Result['def_banner'];
?>

<html>
	<head>
		<title><?php echo "$def_title"; ?></title>
		<link rel="shortcut icon" type="image/x-icon" href="../images/favicon.png">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<link rel="stylesheet" href="<?php echo"$ses_tem_url"; ?>">
		<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
		<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
    	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
	</head>
	<body>
	<?php
	// Load banner and menu
	echo "<img src='../$def_banner' width='100%' height='200px'>";
	if($status_user == 'admin'){
		include("menu_admin.php");
	}else{
		include("menu_user.php");
	}

	?>

	<script>
	  // This is an old version, for a more recent version look at
	  // https://jsfiddle.net/DRSDavidSoft/zb4ft1qq/2/
	  function maxLengthCheck(object)
	  {
	    if (object.value.length > object.maxLength)
	      object.value = object.value.slice(0, object.maxLength)
	  }
	</script>