<?php
ob_start();
include_once($_SERVER["DOCUMENT_ROOT"].'/php/system/includes_system.php');
?>
<!DOCTYPE html>
<html lang="ru">
  <head>
  	<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title><?=$title?></title>  
    <link href="/css/bootstrap.min.css" rel="stylesheet">
    <link href="/css/signin.css" rel="stylesheet">
    <link href="/css/bootstrap.min.css" rel="stylesheet">

    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <link href="/css/ie10-viewport-bug-workaround.css" rel="stylesheet">

    <!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
    <!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
    <script src="/js/ie-emulation-modes-warning.js"></script>

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->

    <!-- Custom styles for this template -->
    <link href="/css/carousel.css" rel="stylesheet">
  </head>

<body>

    <!-- Fixed navbar -->
    <nav class="navbar navbar-inverse navbar-fixed-top">
      <div class="container">
        <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">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="/">Успех</a>
        </div>
        <div id="navbar" class="navbar-collapse collapse">
          <ul class="nav navbar-nav">
            <li class="active"><a href="/">Главная</a></li>
            <li><a href="/categories">Разделы</a></li>
            <?if(isUser()){?>
              <li class="dropdown">
                <a href="" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Аккаунт<span class="caret"></span></a>
                <ul class="dropdown-menu">
                  <li><a href="/user/<?=$user['id']?>">Мой профиль</a></li>
                  <li><a href="/cart">Корзина</a></li>
                  <li><a href="/order/see">Мои заказы</a></li>
                  <li><a href="#">Баланс <?=$user['money']?> руб.</a></li>
                  <?if($user['admin'] >= 3){?>
                    <li role="separator" class="divider"></li>
                    <li class="dropdown-header">Админ-панель</li>
                    <li><a href="/admin/orders">Заказы</a></li>
                    <li><li><a href="/admin/main_edit">Главная</a></li>
                  <?}?>
                </ul>
              </li>
            <?}?>
          </ul>
          <ul class="nav navbar-nav navbar-right">
                <?php
                if(isUser()){
                  $cart_count = $db->query("SELECT * FROM `cart` WHERE `id_user`='".$user['id']."'")->num_rows;
                  ?>
                  <li><a href="/cart">Корзина <? if($cart_count!=0){?><span class="badge"><?=$cart_count?></span><?}?></a></li>
                  <li><a href="#exitModal" data-toggle="modal">Выйти</a></li>
                  <?
                }else{?>
                  <li><a href="/auth">Вход</a></li>
                  <li><a href="/reg">Регистрация</a></li>
                <?php }?>
              </ul>
              <form class="navbar-form navbar-right" role="search" action="/search" method="POST">
                <div class="form-group">
                  <input type="text" class="form-control" placeholder="Поиск по сайту" name="text">
                </div>
                <button type="submit" class="btn btn-default">Искать</button>
              </form>
        </div><!--/.nav-collapse -->
      </div>
    </nav>

<div class="modal fade bd-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true" id="exitModal">
  <div class="modal-dialog modal-sm">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title h4" id="mySmallModalLabel">Выход с аккаунта</h5>
      </div>
      <div class="modal-body">
        Вы действительно хотите выйти с аккаунта?
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Отмена</button>
        <a href="/exit"><button type="button" class="btn btn-primary">Выйти</button></a>
      </div>
    </div>
  </div>
</div>