{% load staticfiles %}
{% load i18n %}
{% load navactive %}

<nav class="navbar navbar-default">
    <div class="container-fluid">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                <span class="sr-only">{% trans "Toggle navigation" %}</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="{% url 'freight:index' %}">{{ app_title }}</a>
        </div>
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <ul class="nav navbar-nav">
                {% if perms.freight.use_calculator %}
                    <li class="{% navactive request 'freight:calculator' %}">
                        <a href="{% url 'freight:calculator' %}">Reward Calculator</a>
                    </li>
                    <li class="{% navactive request 'freight:contract_list_user' %}">
                        <a href="{% url 'freight:contract_list_user' %}">
                            My Contracts&nbsp;
                            {% if pending_user_count > 0 %}
                                <span class="badge">{{ pending_user_count }}</span>
                            {% endif %}
                        </a> 
                    </li>
                {% endif %}
                {% if perms.freight.view_contracts %}
                    <li class="{% navactive request 'freight:contract_list_active' %}">
                        <a href="{% url 'freight:contract_list_active' %}">
                            Active Contracts&nbsp;
                            {% if pending_all_count > 0 %}
                                <span class="badge">{{ pending_all_count }}</span>
                            {% endif %}
                        </a> 
                    </li>
                {% endif %}
                {% if perms.freight.view_statistics %}
                    <li class="{% navactive request 'freight:statistics' %}">
                        <a href="{% url 'freight:statistics' %}">
                            Statistics
                        </a> 
                    </li>
                {% endif %}
            </ul>
            <ul class="nav navbar-nav navbar-right"> 
                {% if perms.freight.add_location %}
                    <a class="btn btn-default navbar-btn" href="{% url 'freight:add_location' %}">
                        Add Location
                    </a>
                {% endif %}

                {% if perms.freight.setup_contract_handler %}
                    <a class="btn btn-default navbar-btn" href="{% url 'freight:setup_contract_handler' %}">
                        Setup Contract Handler
                    </a>
                {% endif %}                
            </ul>
        </div>
    </div>
</nav>
