<?php
include "db/db.php";
session_start();

if(isset($_GET['menu'])) {
  $menu_id = htmlspecialchars(trim($_GET['menu']), ENT_QUOTES, 'UTF-8');
  $_SESSION['menu'] = $menu_id;
}

$log = htmlspecialchars(trim($_SESSION['user']), ENT_QUOTES, 'UTF-8');
$menu = htmlspecialchars(trim($_SESSION['menu']), ENT_QUOTES, 'UTF-8');
$emp_id = htmlspecialchars(trim($_SESSION['emp_id']), ENT_QUOTES, 'UTF-8');

if(empty($log)) {     
  $redirectUrl = "index.php";
  echo "<script type=\"text/javascript\">";
  //echo "window.location.href = '$redirectUrl'";
  echo "</script>";
	 
} else if(empty($menu)) {
  $redirectUrl = "index.php";
  echo "<script type=\"text/javascript\">";
  //echo "window.location.href = '$redirectUrl'";
  echo "</script>";
	
} else {
  $sqlu = "SELECT * FROM user_priv_q WHERE emp_id='$emp_id' AND user='$log' AND menu_id='$menu'";
  $resultu = mysqli_query($conn, $sqlu);
  $countu = mysqli_num_rows($resultu);
 
  if($countu == 1){
	$rowc = mysqli_fetch_assoc($resultu);
	$name = $rowc['name'];

  } else{
	$redirectUrl = "index.php";
	echo "<script type=\"text/javascript\">";
	//echo "window.location.href = '$redirectUrl'";
	echo "</script>";
  
  }
}

date_default_timezone_set('Asia/Colombo');
$date = date("Y-m-d");
?>