{% load i18n %}

{% load appearance_tags %}
{% load search_tags %}
{% load smart_settings_tags %}

{% appearance_get_icon "mayan.apps.dynamic_search.icons.icon_search" as icon_search %}
{% appearance_get_icon "mayan.apps.dynamic_search.icons.icon_search_advanced" as icon_search_advanced %}
{% search_get_default_search_model as default_search_model %}
{% search_get_search_models as search_models %}
{% smart_setting global_name="SEARCH_DISABLE_SIMPLE_SEARCH" as setting_disable_simple_search %}

<form action="{% url 'search:search_results' %}" class="navbar-form navbar-left" id="search-navbar-form" method="get" role="search">
    <div class="form-group">
        <select  class="form-control search-select-search-model" name="{% search_get_search_model_name_query_variable %}">
            {% for search_model in search_models %}
            {{ search_model.self.full_name }}
                <option {% if search_model.full_name == default_search_model.full_name %}selected{% endif %} value="{{ search_model.full_name }}">{{ search_model }}</option>
            {% endfor %}
        </select>
    </div>

    <div class="form-group">
        {% if setting_disable_simple_search == False %}
            <input class="form-control" id="search-navbar-form-input-terms" name="{% search_get_query_parameter_any_field %}" placeholder="{% trans 'Search terms' %}" type="search" value="{{ search_terms|default:'' }}">
        {% endif %}
    </div>

    {% if setting_disable_simple_search == False %}
        <button alt="{% trans 'Search' %}" class="btn btn-primary" type="submit">{{ icon_search }} {% trans 'Search' %}</button>
    {% endif %}

    <a alt="{% trans 'Advanced search' %}" class="btn btn-primary search-anchor-search-advanced" href="{% url 'search:search_advanced' %}?{% search_get_search_model_name_query_variable %}={{ default_search_model.full_name }}" id="search-button-search-advanced">{{ icon_search_advanced }} {% if setting_disable_simple_search == False %}{% trans 'Advanced' %}{% else %}{% trans 'Advanced search' %}{% endif %}</a>
</form>
