<?php
error_reporting(0);
session_start();

if (isset($_SESSION['user_id'])) {
	if ($_SESSION['user_level'] == 2) {
		header("location:../index.php");
	}
} else if (empty($_SESSION['user_id'])) {
	header("location:../index.php");
}

$menu = '';

if (isset($_GET['menu'])) {
	$menu = $_GET['menu'];
}

if (!file_exists($menu . ".php")) {
	$menu = 'not_found';
}

$nama_user = $_SESSION['user_nama'];

if ($_GET['menu'] != '') {
	$title_menu = $_GET['menu'];
} else {
	$title_menu = 'dashboard';
}

?>

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<link rel="stylesheet" href="../FontAwesome/css/all.min.css">
	<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
	<link type="text/css" rel="stylesheet" href="style-admin.css">
	<link type="text/css" rel="stylesheet" href="style-beranda.css">
	<link type="text/css" rel="stylesheet" href="style-barang.css">
	<link type="text/css" rel="stylesheet" href="style-tambah-barang.css">
	<link type="text/css" rel="stylesheet" href="style-detail-barang.css">
	<link type="text/css" rel="stylesheet" href="style-pembayaran.css">
	<link type="text/css" rel="stylesheet" href="style-pesanan.css">
	<link type="text/css" rel="stylesheet" href="style-detail-validasi-pembayaran.css">
	<link type="text/css" rel="stylesheet" href="style-detail-pesanan-baru.css">
	<title>Admin Sewa Tenda</title>
</head>
<body>
	<div id="mySidenav" class="sidenav">
		<p class="logo"><span><i class="fa fa-scribd"></i></span>ewa Tenda</p>
		<a href="index.php" class="icon-a"><i class="fa fa-dashboard icons"></i> &nbsp;Dashboard</a>
		<a href="index.php?menu=barang" class="icon-a"><i class="fa fa-product-hunt icons"></i> &nbsp;Barang</a>
		<a href="index.php?menu=pesanan" class="icon-a"><i class="fa fa-shopping-cart icons"></i> &nbsp;Pesanan</a>
		<a href="index.php?menu=pembayaran" class="icon-a"><i class="fa fa-credit-card icons"></i> &nbsp;Validasi Pembayaran</a>
		<a href="../logout.php" class="icon-a"><i class="fa fa-sign-out icons"></i> &nbsp;Logout</a>
	</div>

	<div id="main-contex">
		<div class="head">
			<div class="col-div-6">
				<span style="font-size:30px; cursor:pointer; color: white; text-transform: capitalize;" class="nav">&#9776; <?php echo $title_menu;?></span>
				<span style="font-size:30px; cursor:pointer; color: white; text-transform: capitalize;" class="nav2">&#9776; <?php echo $title_menu;?></span>
			</div>
		</div>
		<div class="contex">
			<?php

			$menu = '';

			if (isset($_GET['menu'])) {
				$menu = $_GET['menu'];
			}

			if ($menu != '') {
				if (file_exists($menu . ".php")) {
					include $menu . ".php";
				} else {
					include 'not_found.php';
				}
			} else {
				include 'beranda.php';
			}

			?>
		</div>
	</div>

	<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
	<script>
		$(".nav").click(function(){
			$(".logo").css('visibility', 'hidden');
			$(".logo").css('height', '45px');
			$(".logo span").css('visibility', 'visible');
			$(".logo span").css('margin-left', '-10px');
			$(".icon-a").css('visibility', 'hidden');
			$(".icons").css('visibility', 'visible');
			$(".icons").css('margin-left', '-8px');
			$(".nav").css('display','none');
			$(".nav2").css('display','block');
			$("#mySidenav").css('width','70px');
			$("#main-contex").css('margin-left','70px');
		});

		$(".nav2").click(function(){
			$(".logo").css('visibility', 'visible');
			$(".icon-a").css('visibility', 'visible');
			$(".icons").css('visibility', 'visible');
			$(".nav").css('display','block');
			$(".nav2").css('display','none');
			$("#mySidenav").css('width','275px');
			$("#main-contex").css('margin-left','275px');
		});
	</script>
</body>
</html>