{% extends 'base.html' %}

{% load static %}
{% load invoices_waiting from filters %}
{% load invoices_outstanding from filters %}
{% load total_invoices_todo from filters %}

{% block titleheader %}
<a class="navbar-brand" style="margin-left: auto; margin-right: auto;" href="/">RIGS</a>
{% endblock %}

{% block titleelements %}
{% if user.is_authenticated %}
    <li class="nav-item"><a class="nav-link" href="/">Home</a></li>
    <li class="nav-item dropdown">
      <a class="nav-link dropdown-toggle" href="#" id="navbarDropdownRigboard" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
        Rigboard
      </a>
      <div class="dropdown-menu" aria-labelledby="navbarDropdownRigboard">
        <a class="dropdown-item" href="{% url 'rigboard' %}"><span class="fas fa-list"></span>
                            Rigboard</a>
        <a class="dropdown-item" href="{% url 'event_archive' %}"><span class="fas fa-book"></span>
                            Archive</a>
        <a class="dropdown-item" href="{% url 'web_calendar' %}"><span class="fas fa-calendar"></span>
                            Calendar</a>
        {% if perms.RIGS.view_event %}
        <a class="dropdown-item" href="{% url 'activity_table' %}"><span
                                    class="fas fa-random"></span> Recent Changes</a>
        {% endif %}
        {% if perms.RIGS.add_event %}
        <a class="dropdown-item" href="{% url 'event_create' %}"><span class="fas fa-plus"></span>
                                New Event</a>
        {% endif %}
       </div>
    </li>
    {% if perms.RIGS.view_riskassessment %}
    <li class="nav-item"><a class="nav-link" href="{% url 'hs_list' %}">H&S</a></li>
    {% endif %}
    {% if perms.RIGS.view_invoice %}
    <li class="nav-item dropdown">
      {% total_invoices_todo as todo %}
      {% invoices_waiting as waiting %}
      {% invoices_outstanding as outstanding %}
      <a class="nav-link dropdown-toggle" href="#" id="navbarDropdownInvoices" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
        Invoices <span class="badge {% if todo == 0 %}badge-success{% else %}badge-danger{% endif %} badge-pill">{{ todo }}</span>
      </a>
      <div class="dropdown-menu" aria-labelledby="navbarDropdownInvoices">
        <a class="dropdown-item" href="{% url 'invoice_dashboard' %}"><span class="fas fa-chart-line"></span> Dashboard</a>
        {% if perms.RIGS.add_invoice %}
        <a class="dropdown-item text-nowrap" href="{% url 'invoice_waiting' %}"><span class="fas fa-briefcase text-danger"></span> Waiting <span class="badge {% if waiting == 0 %}badge-success{% else %}badge-danger{% endif %} badge-pill">{{ waiting }}</span></a>
        {% endif %}
        <a class="dropdown-item" href="{% url 'invoice_list' %}"><span class="fas fa-pound-sign text-warning"></span> Outstanding <span class="badge {% if outstanding == 0 %}badge-success{% else %}badge-danger{% endif %} badge-pill">{{ outstanding }}</span></a>
        <a class="dropdown-item" href="{% url 'invoice_archive' %}"><span class="fas fa-book"></span> Archive</a>
      </div>
    </li>
    {% endif %}
    {% if perms.RIGS.view_person %}
    <li class="nav-item"><a class="nav-link" href="{% url 'person_list' %}">People</a></li>
    {% endif %}
    {% if perms.RIGS.view_organisation %}
    <li class="nav-item"><a class="nav-link" href="{% url 'organisation_list' %}">Organisations</a></li>
    {% endif %}
    {% if perms.RIGS.view_venue %}
    <li class="nav-item"><a class="nav-link" href="{% url 'venue_list' %}">Venues</a></li>
    {% endif %}
{% endif %}
{% endblock %}

{% block titleelements_right %}
{% include 'partials/search.html' %}
{% include 'partials/navbar_user.html' %}
{% endblock %}

{% block js %}
{{ block.super }}
<script src="{% static 'js/tooltip.js' %}"></script>
<script src="{% static 'js/popover.js' %}"></script>
<script>
    $(function () {
          $('[data-toggle="tooltip"]').tooltip();
    })
</script>
{% endblock %}
