{% load base_tags %}
{% load perm_tags %}
{% load i18n %}

{% has_perm request.user site_settings.change_setting as can_edit_setting %}

{% if nav_object %}
    {% has_perm request.user invoices.view_invoice nav_object as can_view_invoice %}
{% endif %}


<ul id="module-tabs" class="tabs">
    {% if user.is_authenticated %}
    <li class="dropdown" data-dropdown="dropdown">
        <a href="#" class="dropdown-toggle">{% trans "Tendenci" %}</a>
        <ul class="dropdown-menu">
            <a href="{% url dashboard %}" title="Tendenci Home Page">{% trans "Dashboard" %}</a>
            <li><a href="{% url profile.index %}">{% trans "My Profile" %}</a></li>
            <li><a href="{% url auth_logout %}">{% trans "Log Off" %}</a></li>
        </ul>
    </li>
    {% endif %}
    <li class="dropdown active" data-dropdown="dropdown">
        <a href="#" class="dropdown-toggle">{% trans "Invoices" %}</a>
        {% if nav_object %}
        <div class="dropdown-menu">
        <ul class="first">
            <li class="heading">{% trans "All Invoices" %}</li>
            <li class="divider"></li>
        {% else %}
            <div>
            <ul class="dropdown-menu">
        {% endif %}
            {% if can_edit_setting %}
                <li><a href="{% url settings.index "module" "invoices" %}">{% trans "Settings" %}</a></li>
            {% endif %}
            <li><a href="{% url invoice.search %}">{% trans "Search Invoices" %}</a></li>
            {% if user.profile.is_superuser %}
                <li><a href="{% url invoice.export %}">{% trans "Export Invoices" %}</a></li>
                <li><a href="{% url reports-top-spenders %}">{% trans "Top Spenders Report" %}</a></li>
            {% endif %}
        </ul>
        {% if nav_object %}
            {% if can_view_invoice %}
            <ul>
                <li class="heading">{% trans "This Invoice" %}</li>
                <li class="divider"></li>
                {% if can_view_invoice %}
                    <li><a href="{% url invoice.view nav_object.pk %}">{% trans "View Invoice" %}</a></li>
                    <li><a href="{% url invoice.print_view nav_object.id guid %}">{% trans "Print Invoice" %}</a></li>
                    {% if invoice.is_tendered %}
                    <li><a href="{% url invoice.adjust nav_object.id %}">{% trans "Adjust Invoice" %}</a></li>
                    {% endif %}
                {% endif %}
            </ul>
            {% endif %}
        {% endif %}
        </div>
    </li>
    {% if user.is_authenticated %}
    <li class="dropdown" data-dropdown="dropdown">
        <a href="#" class="dropdown-toggle">{% trans "Payments" %}</a>
        <ul class="dropdown-menu">
            <li><a href="{% url payment.search %}">{% trans "Search Payments" %}</a></li>
        </ul>
    </li>
    {% endif %}
</ul>
