{% load i18n %}

<div class="table-header">
  <h3><i class="icon-search icon-large"></i>{% trans "Search" %}</h3>
</div>
<div class="well">
  <form action="" method="get" class="form-inline" id="search_form">
    {% for field in form %}
      {% if field.id_for_label in exposed_field_ids %}
        {% if field.is_hidden %}
          {{ field }}
        {% else %}
          <span class="control-group {% if field.errors %}error{% endif %}">
                            {{ field.label_tag }}
                            {{ field }}
            {% for error in field.errors %}
              <ul class="error-block">
                <li>{{ error }}</li>
              </ul>
            {% endfor %}
                        </span>
        {% endif %}
      {% endif %}
    {% endfor %}
    <input type="submit" value="{% trans "Search" %}" class="btn btn-primary"/>
    <a data-toggle="modal" href="#SearchModal">{% trans "Advanced Search" %}</a>
  </form>

  <div class="modal fade" id="SearchModal">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">&times;</button>
          <h3>{% trans "Advanced Search" %}</h3>
        </div>
        <form action="" method="get" class="form-horizontal">
          <div class="modal-body">
            <div class="container-fluid">
              {% csrf_token %}
              {% include "partials/form_fields.html" with form=form %}
            </div>
          </div>
          <div class="modal-footer">
            <a href="#" class="btn btn-default" data-dismiss="modal">{% trans "Close" %}</a>
            <button type="submit" class="btn btn-primary" data-loading-text="{% trans 'Searching...' %}">{% trans "Search" %}</button>
          </div>
        </form>
      </div>
    </div>
  </div>
</div>
