{% load i18n waffle_tags %}

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>{% block window_title %}{% trans 'Nissan Academy Digital' %}{% endblock %}</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <link rel="stylesheet" href="{{ STATIC_URL }}bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="{{ STATIC_URL }}font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="{{ STATIC_URL }}css/main.css">
    <style type="text/css">
    .nav .open>a, .nav .open>a:focus, .nav .open>a:hover {
      background-color: inherit;
    }
    </style>
    {{ form.media.css }}

      <link rel="shortcut icon" href="{{ STATIC_URL }}img/favicon.ico" type="image/x-icon">
      <link rel="icon" href="{{ STATIC_URL }}img/favicon.ico" type="image/x-icon">

    <!-- Scripts -->
    <script src="{{ STATIC_URL }}jquery/jquery-1.11.2.min.js"></script>
    <script src="{{ STATIC_URL }}bootstrap/js/bootstrap.min.js"></script>
    {% block head %}

    {% endblock %}
</head>

<body class="{% block body_class %}{% endblock %}">

  {% block header %}
    <header>
      <div class="container">
        <div class="row">
          <div class="col-xs-12">
            <div class="row">
              <div class="col-xs-6">
                <!-- Page title -->
                <div class="pull-left">
                  <a href="{% url 'cms:index' %}">
                    <img class="brand-logo" src="{{ theme.brand_logo.url }}" />
                  </a>
                </div>
              </div>
              <div class="col-xs-6">
                <!-- Logout block -->
                <div class="pull-right">
                  {% if user.is_authenticated %}
                    {{ user.first_name }} {{ user.last_name }} |
                    <a href="{{ user.get_edit_url }}">
                      {% trans 'My profile' %} <i class="fa fa-user"></i>
                    </a> |
                    <a href="{% url 'django.contrib.auth.views.logout' %}?next=/cms/">
                      {% trans 'Logout' %} <i class="fa fa-power-off"></i>
                    </a>
                  {% endif %}
                </div>
              </div>

            </div>
          </div>
        </div>
      </div>
    </header>
  {% endblock %}

  {% block menu %}
    <!-- Menu block -->
    <nav class="navbar navbar-blue">
      <div class="container-fluid">
        <!-- Toggle button for mobile version -->
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#menu">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
        </div>

       <!-- Page menu -->
        <div class="collapse navbar-collapse" id="menu">
          <ul class="nav navbar-nav col-xs-12">
            {% if user.is_authenticated %}
              <li {% if current_main_section == "trainings" %}class="active"{% endif %}>
                <a href="{% url 'trainings:training-list' %}"><i class="icon-book"></i>{% trans "Trainings" %}</a>
              </li>
              <li {% if current_main_section == "sessions" %}class="active"{% endif %}>
                <a href="{% url 'trainings:session-list' %}"><i class="icon-calendar"></i>{% trans "Sessions" %}</a>
              </li>
              {% if user.is_superuser or user.is_trainer %}
                {% switch "enable_surveys" %}
                  <li {% if current_main_section == "surveys" %}class="active"{% endif %}>
                      <a href="{% url 'surveys:home' %}"><i class="icon-question-sign"></i>{% trans "Surveys" %}</a>
                  </li>
                {% endswitch %}
              {% endif %}
              {% if user.is_superuser %}
                <li {% if current_main_section == "users" %}class="active"{% endif %}>
                  <a href="{% url 'accounts:user-list' %}"><i class="icon-user"></i>{% trans "Users" %}</a>
                </li>
                <li {% if current_main_section == "groups" %}class="active"{% endif %}>
                  <a href="{% url 'accounts:group-list' %}"><i class="icon-user"></i>{% trans "User groups" %}</a>
                </li>
                {% switch "enable_assessments" %}
                  <li {% if current_main_section == "assessments" %}class="active"{% endif %}>
                    <a href="{% url 'assessments:certification-results-list' %}"><i class="icon-stats"></i>{% trans "Assessments" %}</a>
                  </li>
                {% endswitch %}
                <li {% if current_main_section == "translation" or current == "extra_local_store_last" %}class="active"{% endif %}>
                  <a href="#" data-toggle="dropdown"><i class="icon-cogs"></i>{% trans "Settings" %}</a>
                  <ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
                    {% comment %}
                    <li><a href="{% url 'cms:local_store_last' %}"><i class="icon-download"></i>{% trans "iPad application"%}</a></li>
                    {% endcomment %}
                    {% switch "enable_translation" %}
                    <li><a href="{% url 'translation:dashboard' %}"><i class="icon-lang"></i>{% trans "Interface translation" %}</a></li>
                    {% endswitch %}
                  </ul>
                </li>
              {% endif %}

            {% else %}

            <li {% if current == "extra_local_store_last" %}class="active"{% endif %}><a href="{% url 'cms:local_store_last' %}"><i class="icon-download"></i>{% trans "iPad application"%}</a></li>

            {% endif %}

            {% comment %}
              {% if user.is_staff %}
                <li {% if current == "extra_user_list" %}class="active"{% endif %}><a href="{% url 'accounts:users_list' %}"><i class="icon-user"></i>{% trans "Users" %}</a></li>
              {% endif %}
              {% if user.is_staff %}
                <li><a href="/translation/"><i class="icon-pencil"></i>{% trans "Translation" %}</a></li>
              {% endif %}
              {% if not user.is_staff %}
                <li {% if current == "extra_pdf_generation" %}class="active"{% endif %}><a href="{% url 'trainings:sessions_list' %}">Mes documents</a></li>
                <li {% if current == "extra_workshop" %}class="active"{% endif %}><a href="{% url 'trainings:sessions_list' %}">Mes résultats</a></li>
              {% endif %}
            {% endcomment %}

            {% comment %}
            {% switch "enable_translation" %}
              <div class="pull-right" style="padding-top:8px;">{% include 'translation/set_language.html' %}</div>
            {% endswitch %}
            {% endcomment %}
          </ul>
        </div>
    </nav>
  {% endblock %}

  <section class="page-header">
    <div class="container">
      <div class="row">
        <div class="col-xs-12">
          <div class="row">
            <div class="col-xs-6">

              {% block nav-bar %}
              {% endblock %}

              <h2>{% block subtitle %}{% endblock %}<small>{% block subtitle-small %}{% endblock %}</small></h2>
            </div>
            <div class="col-xs-6">
              <div class="pull-right">

                {% block actions %}
                {% endblock %}

              </div>
            </div>
          </div>

        </div>
      </div>
    </div>
  </section>

  <div class="container">
      <div id="messages">
        {% for message in messages %}
          <div {% if message.tags %} class="alert alert-{{ message.tags }} alert-dismissible" {% else %} class="alert alert-info alert-dismissible" {% endif %}>
            <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            {{ message|safe }}
          </div>
        {% endfor %}
      </div>

  	{% block main %}
    {% endblock %}

  </div>

  {% block footer %}
  {% endblock %}

  {{ form.media.js }}

  {% block extra_js %}
  {% endblock %}
</body>

</html>
