{% load i18n static %}

<!-- Fixed navbar -->
<nav class="navbar navbar-expand-lg bg-custom justify-content-between">
  <div class="container">
    <a class="navbar-brand" href="{% url 'balafon_homepage' %}" title="{% trans 'Board panel' %}">
        <i class="fa fa-address-book"></i> Balafon
    </a>
    <button type="button" class="navbar-toggler" data-toggle="collapse" data-target=".navbar-collapse">
        <span class="navbar-toggler-icon">
            <i class="fa fa-bars"></i>
        </span>
    </button>
    <div class="navbar-collapse collapse">
      <ul class="navbar-nav mr-auto">
        <li class="dropdown">
          <a href="#" class="dropdown-toggle link-nav" data-toggle="dropdown">{% trans "View" %} <b class="caret"></b></a>
          <ul class="dropdown-menu">
            <li>
              <a class="dropdown-link" href="{% url 'users_favorites_list' %}">
                <i class="fas fa-star"></i>
                {% trans "Favorites" %}
              </a>
            </li>
            <li>
              <a class="dropdown-link" href="{% url 'crm_view_entities_list' %}">
                <i class="fas fa-user"></i>
              {% trans "Contacts" %}
              </a>
            </li>
            <li>
              <a class="dropdown-link" href="{% url 'crm_all_opportunities' %}">
                <i class="fas fa-tag"></i>
                {% trans "Opportunities" %}
              </a>
            </li>
            <li>
              <a class="dropdown-link" href="{% url 'crm_see_my_groups' %}">
                <i class="fas fa-asterisk"></i>
                {% trans "Groups" %}
              </a>
            </li>
            <li>
              <a class="dropdown-link" href="{% url 'emailing_newsletter_list' %}">
                <i class="fas fa-file-upload"></i>
                {% trans "Mailings" %}
              </a>
            </li>
            {% if BALAFON_STORE_INSTALLED %}
            <li>
              <a class="dropdown-link" href="{% url 'store_statistics_index' %}">
                <i class="fas fa-chart-bar"></i>
                {% trans "Store statistics" %}
              </a>
            </li>
            {% endif %}
          </ul>
        </li>
        <li class="dropdown">
          <a href="#" class="dropdown-toggle link-nav" data-toggle="dropdown">{% trans "Add" %} <b class="caret"></b></a>
          <ul class="dropdown-menu">
          {% if BALAFON_NO_ENTITY_TYPE %}
              <li><a class="colorbox-form dropdown-link" href="{% url 'crm_create_entity' 0 %}">
                <i class="fas fa-chess-rook"></i>
                {% trans "Entity" %}
              </a></li>
          {% else %}
          {% for entity_type in BALAFON_ENTITY_TYPES %}
              <li><a class="colorbox-form dropdown-link" href="{% url 'crm_create_entity' entity_type.id %}">
                <i class="fas fa-chess-rook"></i>
                {{ entity_type.name }}
              </a></li>
          {% endfor %}
          {% endif %}
          {% if BALAFON_ALLOW_SINGLE_CONTACT %}
              <li><a class="colorbox-form dropdown-link" href="{% url 'crm_add_single_contact' %}">
                <i class="fas fa-user"></i>
                {% trans "Single contact" %}
              </a></li>
          {% endif %}
          </ul>
        </li>
        <li class="dropdown">
          <a href="#" class="dropdown-toggle link-nav" data-toggle="dropdown">{% trans "Search" %} <b class="caret"></b></a>
          <ul class="dropdown-menu">
            <li><a class="dropdown-link" href="{% url 'search' %}">
              <i class="fas fa-search"></i>
              {% trans "New search" %}
            </a></li>
            <li><a class="dropdown-link" href="{% url 'search_list' %}">
              <i class="fas fa-save"></i>
              {% trans "Saved searches" %}
            </a></li>
          </ul>
        </li>
        <li class="dropdown">
          <a href="#" class="dropdown-toggle link-nav" data-toggle="dropdown">{% trans "Planning" %} <b class="caret"></b></a>
          <ul class="dropdown-menu">
            <li><a class="dropdown-link" href="{% url 'crm_this_month_actions' %}">
              <i class="fas fa-calendar"></i>
              {% trans "Monthly actions" %}
            </a></li>
            <li><a class="dropdown-link" href="{% url 'crm_this_week_actions' %}">
              <i class="fas fa-calendar"></i>
              {% trans "Weekly actions" %}
            </a></li>
            <li><a class="dropdown-link" href="{% url 'crm_today_actions' %}">
              <i class="fas fa-calendar"></i>
              {% trans "Daily actions" %}
            </a></li>
            <li><a class="dropdown-link" href="{% url 'crm_actions_not_planned' %}">
              <i class="fas fa-fire"></i>
              {% trans "Not planned actions" %}
            </a></li>
          </ul>
        </li>
        {% for the_custom_menu in users_custom_menus %}
        <li class="dropdown">
            <a href="#" class="dropdown-toggle link-nav" data-toggle="dropdown">
              {% if the_custom_menu.icon %}<i class="fas fa-{{ the_custom_menu.icon }}"></i>{% endif %}
              {{ the_custom_menu.label }} <b class="caret"></b>
            </a>
            <ul class="dropdown-menu">
                {% for custom_menu_item in the_custom_menu.get_children %}
                <li><a href="{{ custom_menu_item.get_url }}" {{ custom_menu_item.attributes|safe }} >
                  <i class="fas fa-{{custom_menu_item.icon}}"></i>
                  {{ custom_menu_item.label }}
                </a></li>
                {% endfor %}
            </ul>
        </li>
        {% endfor %}
        <li class="dropdown">
            <a href="#" class="dropdown-toggle link-nav" data-toggle="dropdown">{% trans "Account" %} <b class="caret"></b></a>
            <ul class="dropdown-menu">
                {%if BALAFON_SITE_URL %}<li><a class="dropdown-link" href="{{ BALAFON_SITE_URL }}">
                  <i class="fas fa-home"></i>
                  {% trans "Back to site" %}
                </a></li>{% endif %}
                <li><a class="dropdown-link" href="{% url 'logout' %}">
                  <i class="fas fa-power-off"></i>
                  {% trans "Logout" %}
                </a></li>
                <li><a class="dropdown-link" href="{% url 'password_change' %}">
                  <i class="fas fa-cog"></i>
                  {% trans "Password" %}
                </a></li>
                {%if user.is_staff %}
                  <li><a class="dropdown-link" href="{% url 'admin:index' %}">
                  <i class="fas fa-cog"></i>
                  {% trans "Admin" %}
                  </a></li>{% endif %}
                {%if user.is_staff %}<li><a class="dropdown-link" href="{% url 'crm_new_contacts_import' %}">
                  <i class="fas fa-file-import"></i>
                  {% trans "Contacts import" %}
                </a></li>{% endif %}
                {%if user.is_staff %}<li><a class="dropdown-link" href="{% url 'crm_unsubscribe_contacts_import' %}">
                  <i class="fas fa-file-import"></i>
                  {% trans "Unsubscribe emails" %}
                </a></li>{% endif %}
            </ul>
        </li>
      </ul>
      <a class="btn btn-sm btn-secondary make-homepage">
        {% if is_allowed_homepage %}
          <i
            rel="{% url 'users_make_homepage' %}"
            class="fas fa-home"
            data-toggle="tooltip" data-placement="bottom"
            title="{% trans 'Make this homepage' %}"
          ></i>
        {% else %}
          <i
            rel=""
            class="fas fa-home disabled"
            data-toggle="tooltip" data-placement="bottom"
            title="{% trans 'This page can not be set as homepage' %}"
          ></i>
        {% endif %}
        </a>
      <form class="form-inline" method="GET" action="{% url 'quick_search' %}">
            {{ quick_search_form.text }}
      </form>
    </div>
  </div>
</nav>