<?php require_once '../includes/main.php'; logged_in('admin'); ?>
<?php require_once 'elements/head.php'; ?>

<?php $section = isset($_GET['section']) ? $_GET['section'] : 'overview'; ?>

<?php 

$id = (int)$_GET['id'];
$sql = "SELECT * FROM users WHERE id = '{$id}' LIMIT 1";
if(fetch_rows($sql) < 1){

   $_SESSION['messages'][] = "User could not be found";
   header("Location: ../users");
   exit;

}else{

   $x = fetch_records($sql);

}

?>

<title><?php echo $set['website_name']; ?>: User: <?php echo $x['username']; ?></title>

<meta name="robots" content="noindex">

</head>

<body>

<?php include_once 'elements/header.php'; ?>
<span class="H" id="section"><?php echo $section; ?></span>

<!-- CONTENT -->
<main class="Content">

   <?php include_once 'elements/sidebar/user.php'; ?>

   <section class="Main L">

      <?php 
      
         switch($section){

            case 'edit':
            include_once 'sections/user/edit.php';
            break;

            case 'overview':
            include_once 'sections/user/overview.php';
            break;

            case 'orders':
            include_once 'sections/user/orders.php';
            break;

            case 'listings':
            include_once 'sections/user/listings.php';
            break;

         }
      
      ?>

   </section>

</main>
<!-- CONTENT -->

<?php include_once 'elements/footer.php'; ?>

</body>
</html>
