{% extends "telemeta/base.html" %}
{% load telemeta_tags %}
{% load i18n %}
{% load bootstrap_pagination %}

{% block head_title %}{% trans "Search Results" %} - {{ block.super }}{% endblock %}

{% block title %}
<div class='row'>
<div class="col-md-5">
  <img src="{{ STATIC_URL }}telemeta/images/search_red.png" alt="search-results" style="vertical-align:middle" /> {% trans "Search Results" %} ({{ page_obj.start_index }} - {{ page_obj.end_index }} / {{ count }})
</div>
<div class="col-md-7">
{% bootstrap_paginate page_obj range=10 show_first_last="True" %}
</div>
<div class="col-md-0">&nbsp;</div>
</div>
{% endblock %}

{% block title_buttons %}
  <div class="btn-group">
    {% ifequal type 'items' %}
    <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
      <span class="glyphicon glyphicon-filter"></span> {% trans "Filters" %} <span class="caret"></span>
    </button>
    <ul class="dropdown-menu" role="menu">
      <li><a href="{% url "telemeta-search-type" "items" %}?{{criteria|with_no_sound|build_query_string}}" class="">{% trans "All" %}</a></li>
      <li><a href="{% url "telemeta-search-type" "items" %}?{{criteria|with_sound|build_query_string}}">{% trans "Sounds" %}</a></li>
      <li><a href="{% url "telemeta-search-published" "items" %}?{{criteria|with_no_sound|build_query_string}}">{% trans "Published" %}</a></li>
      <li><a href="{% url "telemeta-search-unpublished" "items" %}?{{criteria|with_no_sound|build_query_string}}">{% trans "Unpublished" %}</a></li>
      <li><a href="{% url "telemeta-search-full" "items" %}?{{criteria|with_no_sound|build_query_string}}">{% trans "Full" %}</a></li>
      <li><a href="{% url "telemeta-search-none" "items" %}?{{criteria|with_no_sound|build_query_string}}">{% trans "None" %}</a></li>
    </ul>
    {% endifequal %}
    {% ifequal type 'collections' %}
    <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
      <span class="glyphicon glyphicon-filter"></span> {% trans "Filters" %} <span class="caret"></span>
    </button>
    <ul class="dropdown-menu" role="menu">
      <li><a href="{% url "telemeta-search-type" "collections" %}?{{criteria|with_no_sound|build_query_string}}" class="">{% trans "All" %}</a></li>
      <li><a href="{% url "telemeta-search-type" "collections" %}?{{criteria|with_sound|build_query_string}}">{% trans "Sounds" %}</a></li>
      <li><a href="{% url "telemeta-search-published" "collections" %}?{{criteria|with_no_sound|build_query_string}}">{% trans "Published" %}</a></li>
      <li><a href="{% url "telemeta-search-unpublished" "collections" %}?{{criteria|with_no_sound|build_query_string}}">{% trans "Unpublished" %}</a></li>
      <li><a href="{% url "telemeta-search-full" "collections" %}?{{criteria|with_no_sound|build_query_string}}">{% trans "Full" %}</a></li>
      <li><a href="{% url "telemeta-search-none" "collections" %}?{{criteria|with_no_sound|build_query_string}}">{% trans "None" %}</a></li>
    </ul>
    {% endifequal %}
  </div>
{% endblock %}

{% block content %}
{% if criteria %}
<ul>
  {% if criteria.pattern %}
    <li><b>{% trans "Search pattern" %}:</b> {{criteria.pattern}}</li>
  {% endif %}
  {% if criteria.location %}
    <li><b>{% field_label "Location" %}:</b> {{criteria.location}}</li>
  {% endif %}
  {% if criteria.instrument %}
  <li><b>{% field_label "Instrument" %}:</b> {{criteria.instrument}}</li>
  {% endif %}
  {% if criteria.ethnic_group %}
    <li><b>{% field_label "EthnicGroup" %}:</b> {{criteria.ethnic_group}}</li>
  {% endif %}
  {% if criteria.creator %}
    <li><b>{% field_label "MediaCollection" "creator" %}:</b> {{criteria.creator}}</li>
  {% endif %}
  {% if criteria.collector %}
    <li><b>{% field_label "MediaCollection" "collector" %}:</b> {{criteria.collector}}</li>
  {% endif %}
  {% if criteria.title %}
    <li><b>{% trans "Title" %}:</b> {{criteria.title}}</li>
  {% endif %}
  {% if criteria.rec_year_from %}
    <li><b>{% trans "Year of recording" %}:</b> {{criteria.rec_year_from}}
     {% ifnotequal criteria.rec_year_to criteria.rec_year_from %}
     {% trans "to" %} {{criteria.rec_year_to}}
     {% endifnotequal %}
    </li>
  {% endif %}
  {% if criteria.pub_year_from %}
    <li><b>{% trans "Year of publication" %}:</b> {{criteria.pub_year_from}}
     {% ifnotequal criteria.pub_year_to criteria.pub_year_from %}
     {% trans "to" %} {{criteria.pub_year_to}}
     {% endifnotequal %}
    </li>
  {% endif %}
    {% if criteria.sound %}
    <li><b>{% trans "Sound" %}:</b> {{criteria.sound}}</li>
  {% endif %}
</ul>
{% endif %}

{% ifequal type 'items' %}
    {% ifequal result_filter "published"%}
        <p><b>Items ({{items_num}}) | <a href="{% url "telemeta-search-published" "collections" %}?{{criteria|build_query_string}}">Collections ({{collections_num}})</a> | <a href="{% url "telemeta-search-published" "corpus" %}?{{criteria|build_query_string}}">Corpus ({{corpus_num}})</a> | <a href="{% url "telemeta-search-published" "fonds" %}?{{criteria|build_query_string}}">Fonds ({{fonds_num}})</a></b></p>
          {% with object_list as items %}
           <div class="fullpage">
              {% include "telemeta/inc/mediaitem_list.html" %}
           </div>
          {% endwith %}
    {% else%}
        {% ifequal result_filter "unpublished"%}
            <p><b>Items ({{items_num}}) | <a href="{% url "telemeta-search-unpublished" "collections" %}?{{criteria|build_query_string}}">Collections ({{collections_num}})</a> | <a href="{% url "telemeta-search-unpublished" "corpus" %}?{{criteria|build_query_string}}">Corpus ({{corpus_num}})</a> | <a href="{% url "telemeta-search-unpublished" "fonds" %}?{{criteria|build_query_string}}">Fonds ({{fonds_num}})</a></b></p>
              {% with object_list as items %}
               <div class="fullpage">
                  {% include "telemeta/inc/mediaitem_list.html" %}
               </div>
              {% endwith %}
        {% else%}
            {% ifequal result_filter "full"%}
                <p><b>Items ({{items_num}}) | <a href="{% url "telemeta-search-full" "collections" %}?{{criteria|build_query_string}}">Collections ({{collections_num}})</a> | <a href="{% url "telemeta-search-full" "corpus" %}?{{criteria|build_query_string}}">Corpus ({{corpus_num}})</a> | <a href="{% url "telemeta-search-full" "fonds" %}?{{criteria|build_query_string}}">Fonds ({{fonds_num}})</a></b></p>
                  {% with object_list as items %}
                   <div class="fullpage">
                      {% include "telemeta/inc/mediaitem_list.html" %}
                   </div>
                  {% endwith %}
            {% else%}
                {% ifequal result_filter "none"%}
                    <p><b>Items ({{items_num}}) | <a href="{% url "telemeta-search-none" "collections" %}?{{criteria|build_query_string}}">Collections ({{collections_num}})</a> | <a href="{% url "telemeta-search-none" "corpus" %}?{{criteria|build_query_string}}">Corpus ({{corpus_num}})</a> | <a href="{% url "telemeta-search-none" "fonds" %}?{{criteria|build_query_string}}">Fonds ({{fonds_num}})</a></b></p>
                      {% with object_list as items %}
                       <div class="fullpage">
                          {% include "telemeta/inc/mediaitem_list.html" %}
                       </div>
                      {% endwith %}
                {% else%}
                    <p><b>Items ({{items_num}}) | <a href="{% url "telemeta-search-type" "collections" %}?{{criteria|build_query_string}}">Collections ({{collections_num}})</a> | <a href="{% url "telemeta-search-type" "corpus" %}?{{criteria|build_query_string}}">Corpus ({{corpus_num}})</a> | <a href="{% url "telemeta-search-type" "fonds" %}?{{criteria|build_query_string}}">Fonds ({{fonds_num}})</a></b></p>
                      {% with object_list as items %}
                       <div class="fullpage">
                          {% include "telemeta/inc/mediaitem_list.html" %}
                       </div>
                      {% endwith %}
                {%endifequal%}
            {%endifequal%}
        {%endifequal%}
    {% endifequal %}
{% endifequal %}

{% ifequal type 'collections' %}
    {% ifequal result_filter "published"%}
        <p><b><a href="{% url "telemeta-search-published" "items" %}?{{criteria|build_query_string}}">Items ({{items_num}})</a> | Collections ({{collections_num}}) | <a href="{% url "telemeta-search-published" "corpus" %}?{{criteria|build_query_string}}">Corpus ({{corpus_num}})</a> | <a href="{% url "telemeta-search-published" "fonds" %}?{{criteria|build_query_string}}">Fonds ({{fonds_num}})</a>
          </b></p>
          {% with object_list as collections %}
           <div class="fullpage">
              {% include "telemeta/inc/collection_list.html" %}
           </div>
          {% endwith %}
    {% else %}
        {%ifequal result_filter "unpublished"%}
            <p><b><a href="{% url "telemeta-search-unpublished" "items" %}?{{criteria|build_query_string}}">Items ({{items_num}})</a> | Collections ({{collections_num}}) | <a href="{% url "telemeta-search-unpublished" "corpus" %}?{{criteria|build_query_string}}">Corpus ({{corpus_num}})</a> | <a href="{% url "telemeta-search-unpublished" "fonds" %}?{{criteria|build_query_string}}">Fonds ({{fonds_num}})</a>
              </b></p>
              {% with object_list as collections %}
               <div class="fullpage">
                  {% include "telemeta/inc/collection_list.html" %}
               </div>
               {% endwith %}
        {%else%}
            {%ifequal result_filter "full"%}
                <p><b><a href="{% url "telemeta-search-full" "items" %}?{{criteria|build_query_string}}">Items ({{items_num}})</a> | Collections ({{collections_num}}) | <a href="{% url "telemeta-search-full" "corpus" %}?{{criteria|build_query_string}}">Corpus ({{corpus_num}})</a> | <a href="{% url "telemeta-search-full" "fonds" %}?{{criteria|build_query_string}}">Fonds ({{fonds_num}})</a>
                  </b></p>
                  {% with object_list as collections %}
                   <div class="fullpage">
                      {% include "telemeta/inc/collection_list.html" %}
                   </div>
                  {% endwith %}
            {%else%}
                {%ifequal result_filter "none"%}
                    <p><b><a href="{% url "telemeta-search-none" "items" %}?{{criteria|build_query_string}}">Items ({{items_num}})</a> | Collections ({{collections_num}}) | <a href="{% url "telemeta-search-none" "corpus" %}?{{criteria|build_query_string}}">Corpus ({{corpus_num}})</a> | <a href="{% url "telemeta-search-none" "fonds" %}?{{criteria|build_query_string}}">Fonds ({{fonds_num}})</a>
                      </b></p>
                      {% with object_list as collections %}
                       <div class="fullpage">
                          {% include "telemeta/inc/collection_list.html" %}
                       </div>
                      {% endwith %}
                {%else%}
                    <p><b><a href="{% url "telemeta-search-type" "items" %}?{{criteria|build_query_string}}">Items ({{items_num}})</a> | Collections ({{collections_num}}) | <a href="{% url "telemeta-search-type" "corpus" %}?{{criteria|build_query_string}}">Corpus ({{corpus_num}})</a> | <a href="{% url "telemeta-search-type" "fonds" %}?{{criteria|build_query_string}}">Fonds ({{fonds_num}})</a>
                      </b></p>
                      {% with object_list as collections %}
                       <div class="fullpage">
                          {% include "telemeta/inc/collection_list.html" %}
                       </div>
                      {% endwith %}
                {%endifequal%}
            {%endifequal%}
        {%endifequal%}
    {%endifequal%}
{% endifequal %}

{% if type == 'corpus' %}
<p><b><a href="{% url "telemeta-search-type" "items" %}?{{criteria|build_query_string}}">Items ({{items_num}})</a> | <a href="{% url "telemeta-search-type" "collections" %}?{{criteria|build_query_string}}">Collections ({{collections_num}})</a> | Corpus ({{corpus_num}}) | <a href="{% url "telemeta-search-type" "fonds" %}?{{criteria|build_query_string}}">Fonds ({{fonds_num}})</a>
</b></p>
{% endif %}

{% if type == 'fonds' %}
<p><b><a href="{% url "telemeta-search-type" "items" %}?{{criteria|build_query_string}}">Items ({{items_num}})</a> | <a href="{% url "telemeta-search-type" "collections" %}?{{criteria|build_query_string}}">Collections ({{collections_num}})</a> | <a href="{% url "telemeta-search-type" "corpus" %}?{{criteria|build_query_string}}">Corpus ({{corpus_num}})</a> | Fonds ({{fonds_num}})
</b></p>
{% endif %}

{% if type == 'corpus' or type == 'fonds' %}
{% with object_list as resources and type as type %}
<div class="fullpage">
{% include "telemeta/inc/resource_list.html" %}
</div>
{% endwith %}
{% endif %}


{% endblock %}
