{#
 # This file is part of SolidInvoice package.
 #
 # (c) Pierre du Plessis <open-source@solidworx.co>
 #
 # This source file is subject to the MIT license that is bundled
 # with this source code in the file LICENSE.
 #}

<ul class="navbar-nav{{ title|default(null) is empty ? ' w-100' }}">
    <li class="nav-item">
        <a class="nav-link" data-widget="pushmenu" href="#" role="button"><i class="fas fa-bars"></i></a>
    </li>
</ul>

{% if title|default(null) is not empty %}
    <h4 class="p-1 mt-2 w-100">
        {{ title|raw }}
    </h4>
{% endif %}

{% if is_granted('IS_AUTHENTICATED_REMEMBERED') %}
    <div class="btn-group float-right">
        <button class="btn btn-sm dropdown-toggle m-0" type="button" data-toggle="dropdown">
            {{ company_name() }} <b class="caret"></b>
        </button>
        <ul class="dropdown-menu" role="menu">
            {% set availableCompanies = app.user.companies|filter(v => v.id != company_id()) %}
            {% for company in availableCompanies %}
                <li class="nav-item">
                    <a href="{{ path('_switch_company', {'id': company.id}) }}" class="nav-link">
                        {{ company }}
                    </a>
                </li>
            {% endfor %}

            {% if availableCompanies|length > 0 %}
                <li class="dropdown-divider">
                </li>
            {% endif %}

            <li class="nav-item">
                <a href="{{ path('_create_company') }}" class="nav-link">
                    {{ icon('plus') }} {{ 'Add Company'|trans }}
                </a>
            </li>
        </ul>
    </div>
    &nbsp;&nbsp;
    <div class="btn-group float-right" id="top-menu-create-button">
        <button class="btn btn-info btn-sm dropdown-toggle m-0" type="button" data-toggle="dropdown">
            {{ icon('plus') }} {{ 'menu.button.create'|trans }} <b class="caret"></b>
        </button>
        <ul class="dropdown-menu" role="menu">
            <li class="nav-item">
                <a href="{{ path('_clients_add') }}" class="nav-link">
                    {{ icon('user-plus') }} {{ 'dashboard.create.client'|trans }}
                </a>
            </li>
            <li class="nav-item">
                <a href="{{ path('_quotes_create') }}" class="nav-link">
                    {{ icon('file-text-o') }} {{ 'dashboard.create.quote'|trans }}
                </a>
            </li>
            <li class="nav-item">
                <a href="{{ path('_invoices_create') }}" class="nav-link">
                    {{ icon('file-text-o') }} {{ 'dashboard.create.invoice'|trans }}
                </a>
            </li>
        </ul>
    </div>
{% endif %}
