<?php

/* Oksjoniportaali kujunduse realisatsiooni alus:
https://github.com/BlackrockDigital/startbootstrap/blob/gh-pages/LICENSE (9.05.2016)*/

?>
<!DOCTYPE html>
<html lang="en">

<head>

  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta name="description" content="">
  <meta name="author" content="">

  <title>Oksjoniportaal</title>

  <!-- Bootstrap Core CSS -->
  <link href="<?php echo HTTP ?>css/bootstrap.min.css" rel="stylesheet">

  <!-- Custom CSS -->
  <link href="<?php echo HTTP ?>css/custom.css" rel="stylesheet">
  <link href="<?php echo HTTP ?>css/jquery.countdown.css" rel="stylesheet">

  <!-- JS -->
  <script src="<?php echo HTTP ?>js/jquery.js"></script>


</head>

<body>

  <nav class="navbar navbar-default navbar-fixed-top" role="navigation">
    <div class="container">

      <div class="navbar-header">
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="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="/">Oksjoniportaal</a>
      </div>
      <div id="navbar" class="navbar-collapse collapse">
        <ul class="nav navbar-nav">
          <?php

          $leht = $_SERVER['REQUEST_URI'];
          $leht = substr($leht, 16);

          if ($leht == "saalioksjon/"){
            echo '
            <li>
              <a href="'.HTTP.'">Internetioksjonid</a>
            </li>
            <li>
              <a href="'.HTTP.'saalioksjon"><u>Saalioksjonid</u></a>
            </li>
            <li>
              <a href="'.HTTP.'hindamine">Hindamine</a>
            </li>
            ';
          } else if ($leht == "hindamine/"){
            echo '
            <li>
              <a href="'.HTTP.'">Internetioksjonid</a>
            </li>
            <li>
              <a href="'.HTTP.'saalioksjon">Saalioksjonid</a>
            </li>
            <li>
              <a href="'.HTTP.'hindamine"><u>Hindamine</u></a>
            </li>
            ';
          } else if ($leht == "" or $leht == "index.php"){
            echo '
            <li>
              <a href="'.HTTP.'"><u>Internetioksjonid</u></a>
            </li>
            <li>
              <a href="'.HTTP.'saalioksjon">Saalioksjonid</a>
            </li>
            <li>
              <a href="'.HTTP.'hindamine">Hindamine</a>
            </li>
            ';
          } else {
            echo '
            <li>
              <a href="'.HTTP.'">Internetioksjonid</a>
            </li>
            <li>
              <a href="'.HTTP.'saalioksjon">Saalioksjonid</a>
            </li>
            <li>
              <a href="'.HTTP.'hindamine">Hindamine</a>
            </li>
            ';
          };
          ?>

        </ul>
        <?php
        if(!$user_home->is_logged_in())
        {
          //ei ole sisselogitud
          echo('<ul class="nav navbar-nav navbar-right">
            <li><a href="'.HTTP.'scripts/login.php">Logi sisse</a></li>
            <li><a href="'.HTTP.'scripts/signup.php">Registreeru</a></li>
          </ul>');
        } else {

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

          echo('<ul class="nav navbar-nav navbar-right">
            <li><a href="' . HTTP . 'admin/">');
            if($_SESSION["userSession"] == "1"){
              echo ("<span class='glyphicon glyphicon-th-large'></span>&nbsp; Administraatori paneel");
            }
            echo('</a></li>

             <li class="dropdown">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><span class="glyphicon glyphicon-user"></span>&nbsp;');
              echo ($row['eesnimi']);
              echo '<span class="caret"></span></a>
              <ul class="dropdown-menu">
                <li><a href="' . HTTP . 'kasutaja/pakkumised.php">Minu pakkumised</a></li>
                <li><a href="' . HTTP . 'kasutaja/voidetud.php">Võidetud oksjonid</a></li>
                <li><a href="' . HTTP . 'kasutaja/jalgitavad.php">Jälgitavad oksjonid</a></li>
                <li><a href="' . HTTP . 'kasutaja/eelpakkumised.php">Minu eelpakkumised</a></li>
                <li role="separator" class="divider"></li>

                <li><a href="' . HTTP . 'kasutaja/andmed.php"><span class="glyphicon glyphicon-edit"></span>&nbsp; Andmed</a></li>
                <li><a href="' . HTTP . 'scripts/logout.php?logout"><span class="glyphicon glyphicon-log-out"></span>&nbsp; Logi välja</a></li>
              </ul>
            </li>

            ';

          }
          ?>

        </div>
        <!-- /.navbar-collapse -->
      </div>
      <!-- /.container -->
    </nav>