{% load telemeta_tags %}
{% load i18n %}

<div id="accordeon" style="margin-bottom:20px">
    <div><a href="#">{% trans "Filters" %}</a></div>
    <div>
        <table class="table" style="font-size:0.9em">
                <tr>
                    {% if facets.fields.item_status %}
                        <td>{% trans "Item Status" %}</td>
                        {% for item_status in facets.fields.item_status %}
                            <td><a href="{{ request.get_full_path }}&amp;selected_facets=item_status_exact:{{ item_status.0|urlencode }}">{{ item_status.0 }}</a> <span style="background-color:#6a0307" class="badge">{{ item_status.1 }}</span></td>
                        {% endfor %}
                        {% if Published_count == 0 %}
                            <td> {% trans "Published" %} <span class="badge">0</span></td><td></td>
                        {% endif %}
                        {% if Unpublished_count == 0 %}
                            <td> {% trans "Unpublished" %} <span class="badge">0</span></td><td></td>
                        {% endif %}
                    {% else %}
                        <td>{% trans "Item Status" %}</td>
                        <td>{% trans "None" %}</td>
                    {% endif %}
                </tr>
                <tr>
                {% if facets.fields.digitized %}
                    <td>{% trans "Player Status" %}</td>
                    {% for digitized in facets.fields.digitized %}
                        {% ifequal digitized.0 'T' %}
                            <td><a href="{{ request.get_full_path }}&amp;selected_facets=digitized_exact:{{ digitized.0|urlencode }}">Sound</a> <span style="background-color:#6a0307" class="badge">{{ digitized.1 }}</span></td><td></td>
                        {% endifequal %}
                    {% endfor %}
                    {% if digitized_count == 0 %}
                        <td> {% trans "Sound" %} <span class="badge">0</span></td><td></td>
                    {% endif %}
                {% else %}
                    <td>{% trans "Player Status" %}</td>
                    <td>{% trans "None" %}</td>
                {% endif %}
            </tr>
            <tr>
                {% if facets.fields.item_acces %}
                    <td>{% trans "Access Right" %}</td>
                    {% if viewable_count != 0 %}
                        <td><a href="{{ request.get_full_path }}&amp;selected_facets=item_acces_exact:{{ 'viewable'|urlencode }}">viewable</a> <span style="background-color:#6a0307" class="badge">{{viewable_count}}</span></td><td></td>
                    {% endif %}
                    {% if viewable_count == 0 %}
                        <td>{% trans "viewable" %} <span class="badge">{{viewable_count}}</span></td><td></td>
                    {% endif %}
                    {% comment %}
                        {% for item_acces in facets.fields.item_acces %}
                        {# Faire un booleen dans la vue, le passer en contexte puis verifier si il est a true ou a false pour l'affichage' #}
                            {% ifequal item_acces.0 'none' %}
                                <td><a href="{{ request.get_full_path }}&amp;selected_facets=item_acces_exact:{{ item_acces.0|urlencode }}">{{ item_acces.0 }}</a> <span class="badge">{{ item_acces.1 }}</span></td>
                            {% endifequal %}
                        {% endfor %}
                    {%endcomment%}
                {% else %}
                    <td>{% trans "Access Right" %}</td>
                    <td>{% trans "None" %}</td>
                {% endif %}
            </tr>
        </table>
    </div>

    <div><a href="#">{% trans "Other Filters" %}</a></div>
    <div>
        <table class="table" style="font-size:0.9em">
                    <tr>
                        {% if facets.fields.media_type %}
                            <td>{% trans "Media Type" %}</td>
                            {% for media_type in facets.fields.media_type %}
                                {% ifequal media_type.0 'Audio'%}
                                    <td><a href="{{ request.get_full_path }}&amp;selected_facets=media_type_exact:{{ media_type.0|urlencode }}">{{ media_type.0 }}</a> <span style="background-color:#6a0307" class="badge">{{ media_type.1 }}</span></td>
                                {% endifequal %}
                                {% ifequal media_type.0 'Video'%}
                                    <td><a href="{{ request.get_full_path }}&amp;selected_facets=media_type_exact:{{ media_type.0|urlencode }}">{{ media_type.0 }}</a> <span style="background-color:#6a0307" class="badge">{{ media_type.1 }}</span></td>
                                {% endifequal %}
                            {% endfor %}
                            {% if Video_count == 0 %}
                                <td> {% trans "Video" %} <span class="badge">0</span></td><td></td>
                            {% endif %}
                            {% if Audio_count == 0 %}
                                <td> {% trans "Audio" %} <span class="badge">0</span></td><td></td>
                            {% endif %}
                        {% endif %}
                    </tr>
                    <tr>
                    <tr>
                        {% if facets.fields.recording_context %}
                            <td>{% trans "Recording Context" %}</td>
                            {% for recording_context in facets.fields.recording_context %}
                                {% ifequal recording_context.0 'Studio'%}
                                    <td><a href="{{ request.get_full_path }}&amp;selected_facets=recording_context_exact:{{ recording_context.0|urlencode }}">{{ recording_context.0 }}</a> <span style="background-color:#6a0307" class="badge">{{ recording_context.1 }}</span></td>
                                {% endifequal %}
                                {% ifequal recording_context.0 'Radio'%}
                                    <td><a href="{{ request.get_full_path }}&amp;selected_facets=recording_context_exact:{{ recording_context.0|urlencode }}">{{ recording_context.0 }}</a> <span style="background-color:#6a0307" class="badge">{{ recording_context.1 }}</span></td>
                                {% endifequal %}
                                {% ifequal recording_context.0 'Terrain'%}
                                    <td><a href="{{ request.get_full_path }}&amp;selected_facets=recording_context_exact:{{ recording_context.0|urlencode }}">{{ recording_context.0 }}</a> <span style="background-color:#6a0307" class="badge">{{ recording_context.1 }}</span></td>
                                {% endifequal %}
                            {% endfor %}
                            {% if Terrain_count == 0 %}
                                <td> {% trans "Terrain" %} <span class="badge">0</span></td><td></td>
                            {% endif %}
                            {% if Radio_count == 0 %}
                                <td> {% trans "Radio" %} <span class="badge">0</span></td><td></td>
                            {% endif %}
                            {% if Studio_count == 0 %}
                                <td> {% trans "Studio" %} <span class="badge">0</span></td><td></td>
                            {% endif %}
                        {% endif %}
                    </tr>
                    <tr>
                        {% if facets.fields.physical_format %}
                            <td>{% trans "Physical Format" %}</td>
                            {% for physical_format in facets.fields.physical_format %}
                                {% ifequal physical_format.0 'CDR'%}
                                    <td><a href="{{ request.get_full_path }}&amp;selected_facets=physical_format_exact:{{ physical_format.0|urlencode }}">{{ physical_format.0 }}</a> <span style="background-color:#6a0307" class="badge">{{ physical_format.1 }}</span></td>
                                {% endifequal %}
                                {% ifequal physical_format.0 'Disque'%}
                                    <td><a href="{{ request.get_full_path }}&amp;selected_facets=physical_format_exact:{{ physical_format.0|urlencode }}">{{ physical_format.0 }}</a> <span style="background-color:#6a0307" class="badge">{{ physical_format.1 }}</span></td>
                                {% endifequal %}
                                {% ifequal physical_format.0 'Cylindre'%}
                                    <td><a href="{{ request.get_full_path }}&amp;selected_facets=physical_format_exact:{{ physical_format.0|urlencode }}">{{ physical_format.0 }}</a> <span style="background-color:#6a0307" class="badge">{{ physical_format.1 }}</span></td>
                                {% endifequal %}
                            {% endfor %}
                            {% if CDR_count == 0 %}
                                <td> {% trans "CDR" %} <span class="badge">0</span></td><td></td>
                            {% endif %}
                            {% if Disque_count == 0 %}
                                <td> {% trans "Disque" %} <span class="badge">0</span></td><td></td>
                            {% endif %}
                            {% if Cylindre_count == 0 %}
                                <td> {% trans "Cylindre" %} <span class="badge">0</span></a></td><td></td>
                            {% endif %}
                        {% endif %}
                    </tr>
                </table>
    </div>

</div>

{% if selected_facets %}
     <p> <span class="glyphicon glyphicon-filter"> selected filters :
         {{selected_facets|join:" + "}}</b></span><a class="pull-right" href="{% url "haystack_search_type" "type" %}?q={{ query }}&amp;page=1">&raquo; Remove All Filters</a></p>
 {% endif %}




