{% load staticfiles %}
{% load wnsq_tags %}
{% load i18n %}
<nav class="navigation-bar fixed-top dark">
    <nav class="navigation-bar-content">
        <a href="{% url 'homepage' %}"><img class="element" src="{% static 'img/green_nose.png' %}"/></a>
        <span class="element-divider"></span>

        {% if request.user.is_authenticated %}

            <div class="element input-element">
                <form method="get" action="{% url 'search_results' %}" onsubmit="check_empty()">
                    <div class="input-control text">
                        <input type="text" placeholder="{% trans 'Search' %}" name="query" id="query">
                        <button class="btn-search"></button>
                    </div>
                </form>
            </div>


            {% if request.user|check_group:"A" %}
                <div class="element">
                    <a class="dropdown-toggle" href="#">{{ projects_vnp|capfirst }}</a>
                    <ul class="dropdown-menu" data-role="dropdown">
                        <li><a href="{% url 'projects_list' %}">{{ projects_vnp|capfirst }}</a></li>

                        <li class="divider"></li>
                        <li><a href="{% url 'clients_list' %}">{{ clients_vnp|capfirst }}</a>
                        </li>
                        <li><a href="{% url 'client offices_list' %}">{{ offices_vnp|capfirst }}</a>
                        </li>

                        <li><a href="{% url 'contact persons_list' %}">{{ contacts_vnp|capfirst }}</a>
                        </li>

                    </ul>
                </div>
            {% endif %}

            <div class="element">
                <a class="dropdown-toggle" href="#">{{ samples_vnp|capfirst }}</a>
                <ul class="dropdown-menu" data-role="dropdown">
                    <li><a href="{% url 'samples_list' %}">{% trans 'all'|capfirst %}</a></li>
                    <li><a href="{% url 'samples_list' %}?type=odour">{% trans 'Odour' %}</a>
                    </li>
                    <li><a href="{% url 'samples_list' %}?type=reference">{% trans 'Reference' %}</a></li>
                </ul>
            </div>

            <div class="element">
                <a class="dropdown-toggle" href="#">{{ panel_vnp|capfirst }}</a>
                <ul class="dropdown-menu" data-role="dropdown">
                    <li><a href="{% url 'panelists_list' %}">{% trans 'Overview' %}</a></li>
                    <li><a href="{% url 'panel_performance' %}">{% trans 'panel performance'|capfirst %}</a></li>
                    <li><a href="{% url 'labhistory' %}">{% trans 'lab performance'|capfirst %}</a></li>
                </ul>
            </div>


            <div class="element">
                <a class="dropdown-toggle" href="#">{{ measurements_vnp|capfirst }}</a>
                <ul class="dropdown-menu" data-role="dropdown">
                    <li><a href="{% url 'measurements_list' %}">{% trans 'all'|capfirst %}</a></li>
                    <li><a href="{% url 'measurements_list' %}?type=odour">{% trans 'Odour' %}</a>
                    </li>
                    <li><a href="{% url 'measurements_list' %}?type=reference">{% trans 'Reference' %}</a>
                    </li>
                </ul>
            </div>

            <div class="element">
                <a class="dropdown-toggle" href="#">{% trans 'equipment'|capfirst %}</a>
                <ul class="dropdown-menu" data-role="dropdown">
                    <li><a href="{% url 'bags_list' %}">{{ bags_vnp|capfirst }}</a></li>

                    {% if request.user|check_group:"L" %}
                        <li><a href="{% url 'reference gases_list' %}">{{ refgas_vnp|capfirst }}</a></li>
                        <li><a href="{% url 'olfactometers_list' %}">{{ olfactometers_vnp|capfirst }}</a>
                        </li>
                    {% endif %}

                </ul>
            </div>

            <!-- templates for head of, lab tech may create users with lower rights, as helpers -->
            {% if request.user|check_group:"A" %}
                <div class="element">
                    <a class="dropdown-toggle" href="#">{% trans 'System' %}</a>
                    <ul class="dropdown-menu" data-role="dropdown">
                        <li><a href="{% url 'users_list' %}">{% trans 'User Management' %}</a></li>
                        {% if request.user|check_group:"L" %}
                            <li><a href="{% url 'templates_list' %}">{% trans 'templates'|capfirst %}</a></li>
                        {% endif %}
                        <li class="divider"></li>
                        <li><a href="{% url 'about_page' %}">{% trans 'About' %}</a></li>
                    </ul>
                </div>
            {% endif %}

        {% endif %}

        <!-- user logged in, display some user menu -->
        {% if user.is_authenticated %}
            <div class="element place-right">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                    {{ user.username }}
                    <span class="icon-user on-right"></span>
                </a>

                <ul class="dropdown-menu place-right" data-role="dropdown">
                    <li><a href="{% url 'change_password' %}">{% trans 'change password'|capfirst %}</a></li>
                    <li class="divider"></li>
                    <li><a href="{% url 'logout_page' %}">{% trans 'logout'|capfirst %}</a></li>
                </ul>
                <!-- user not logged in -->
            </div>
        {% else %}
            <a class="element place-right" href="{% url 'login_page' %}">{% trans 'login'|capfirst %}<span
                    class="icon-locked-2 on-right-more"></span></a>
        {% endif %}
    </nav>
</nav>

<script>
    function check_empty() {
        return false;
    }
</script>
