<?php

/* Administraatori paneeli kujunduse realisatsiooni alus:
https://getbootstrap.com/examples/dashboard/ (9.05.2016)*/

session_start();

require ROOT . 'db/dbconfig.php';
require 'objects/kasutaja.class.php';

$user_home = new Kasutaja();

// Kontrollime, kas kasutaja on sisselogitud
if(!$user_home->is_logged_in())
{
  $user_home->redirect(ROOT . 'index.php');
}

// Kontrollime, kas kasutajal on administraatori õigused
if($_SESSION['userSession'] != '1'){
  $user_home->redirect(ROOT . 'index.php');
}

$stmt = $user_home->runQuery("SELECT * FROM kasutajad WHERE id=:uid");
$stmt->execute(array(":uid"=>$_SESSION['userSession']));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
?>

<!DOCTYPE html>

<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">

  <title>Administraatori paneel</title>

  <link href="<?php echo HTTP ?>css/bootstrap.min.css" rel="stylesheet">
  <link href="<?php echo HTTP ?>css/dashboard.css" rel="stylesheet">
  <script src="<?php echo HTTP ?>js/jquery.js"></script>
  <script src="<?php echo HTTP ?>js/bootstrap.min.js"></script>

</head>
<body>

  <nav class="navbar navbar-inverse navbar-fixed-top">
    <div class="container-fluid">
      <div class="navbar-header">
        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
          <span class="sr-only">Menüü</span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </button>
        <a class="navbar-brand" href="<?php echo ADMIN_HTTP ?>">Administraatori paneel</a>
      </div>
      <div id="navbar" class="navbar-collapse collapse">
        <ul class="nav navbar-nav navbar-right">
          <li><a href="<?php echo HTTP ?>"><span class="glyphicon glyphicon-th-large"></span>&nbsp; Oksjoniportaal</a></li>
          <li><a href="<?php echo HTTP ?>scripts/logout.php?logout"><span class="glyphicon glyphicon-log-out"></span>&nbsp;  Logi välja</a></li>
        </ul>
      </div>
    </div>
  </nav>

  <div class="container-fluid">
    <div class="row">
      <div class="col-sm-3 col-md-2 sidebar">
        <ul class="nav nav-sidebar">
          <center><li><h3><kbd>ONLINE</kbd></h3></li></center>
          <li><a href="<?php echo ADMIN_HTTP ?>internetioksjon/oksjonite_lisamine.php">Oksjonite lisamine</a></li>
          <li><a href="<?php echo ADMIN_HTTP ?>">Aktiivsed oksjonid</a></li>
          <li><a href="<?php echo ADMIN_HTTP ?>internetioksjon/ootel_oksjonid.php">Ootel oksjonid</a></li>
          <li><a href="<?php echo ADMIN_HTTP ?>internetioksjon/loppenud_oksjonid.php">Lõppenud oksjonid</a></li>
          <li><a href="<?php echo ADMIN_HTTP ?>internetioksjon/kategooriad.php">Kategooriad</a></li>
        </ul>
        <ul class="nav nav-sidebar">
          <center><li><h3><kbd>SAAL</kbd></h3></li></center>
          <li><a href="<?php echo ADMIN_HTTP ?>saalioksjon/kataloogid.php">Kataloogid</a></li>
          <li><a href="<?php echo ADMIN_HTTP ?>saalioksjon/esemete_lisamine.php">Esemete lisamine</a></li>
        </ul> 
        <ul class="nav nav-sidebar">
          <center><li><h3><kbd>MUU</kbd></li></h3></center>
          <li><a href="<?php echo ADMIN_HTTP ?>hindamine/">Hindamine</a></li>
          <li><a href="<?php echo ADMIN_HTTP ?>kasutajad/kasutajad.php">Kasutajad</a></li>
          <li><a href="<?php echo ADMIN_HTTP ?>arved/arved.php">Arved</a></li>
        </ul>
      </div>
      <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">