{% extends 'hdabo_base.html' %}

{% block content %}
    <h2>Recherche</h2>
    
    <div id="search_form">
    <form method="get" action=".">
        <table>
            <tr>
                <th><label for="id_q">Recherche&nbsp:</label></th>
                <td><input type="text" name="q" id="id_q" value="{{query}}"></td>
            </tr>            
            <tr>
                <td>&nbsp;</td>
                <td>
                    <input type="submit" value="Rechercher">
                </td>
            </tr>
        </table>
     </form>
     </div>
    <div id="search_results">
        {% if query %}
            <h3>Résultats</h3>
            <div id="page_number">Page {{page.number}}/{{paginator.num_pages}}</div>
            <table id="search_result">
            {% for result in page.object_list %}
                <tr>
                    <th class="result_counter">{{forloop.counter0|add:page.start_index}}.</th>
	                <td>
	                    <a href="{{ result.object.get_absolute_url }}" class="result_link" >{{ result.object.title }}</a>
	                </td>
                </tr>
            
            {% empty %}
                <tr><td>Pas de résultats.</td></tr>
            {% endfor %}
            </table>

            {% if page.has_previous or page.has_next %}
                <div id="search_prev_next">                    
                    {% if page.has_previous %}<a href="?q={{ query }}&amp;page={{ page.previous_page_number }}">{% endif %}&laquo; Prec.{% if page.has_previous %}</a>{% endif %}
                    |
                    {% if page.has_next %}<a href="?q={{ query }}&amp;page={{ page.next_page_number }}">{% endif %}Suiv. &raquo;{% if page.has_next %}</a>{% endif %}
                </div>
            {% endif %}
        {% endif %}
    </div>

{% endblock %}