{# dateFilter \ArcaSolutions\SearchBundle\Entity\Filters\DateFilter #}
{# summaryTitle \ArcaSolutions\SearchBundle\Entity\Summary\SummaryTitle #}

{% extends "::base.html.twig" -%}

{% block SEO %}
    {{ summaryTitle.seoInformation|raw }}
{% endblock -%}

{% block head -%}
    {{ parent() }}

    {% if previousPage -%}<link rel="prev" href="{{ previousPage }}">{% endif -%}
    {% if nextPage -%}<link rel="next" href="{{ nextPage }}">{% endif -%}
{% endblock -%}

{% block subheader -%}
    {# Search header block or Page Title -#}
    <section class="top-search">
    <h6 class="sr-only">{{ "Search"|trans }} </h6>

    {{ include("::blocks/background-image.html.twig") }}

    <div class="well well-translucid">
        <div class="container">
            <div id="search-responsive" class="search-collapse collapse">
                <div class="well well-translucid form-inline text-center">
                    {% if dateFilter.calendarSearch %}
                        {{ include("::blocks/search/search-fields-date.html.twig", { 'dateFilter' : dateFilter }) }}
                    {% else %}
                        {{ include("::blocks/search/search-fields.html.twig") }}
                    {% endif %}
                </div>
            </div>
        </div>
    </div>
    </section>

{% endblock -%}

{% block topbanner -%}
    <div class="results-top-banner">
        {{ banners.top() }}
    </div>
{% endblock -%}

{% block body -%}
    {% import "::blocks/utility/summary.html.twig" as Utility -%}

    {% set isTabLayout = pagination.totalItemCount < 1000 and map %}

    <!-- Main Content Begin -->
    <main>
        <div class="container well well-light">
            {% if pagination.totalItemCount > 0 -%}

            {# Results Title Bar -#}
            <div class="search-toolbar">

                <div class="row">
                    <div class="col-sm-12 text-center-xs">
                        <div class="panel panel-default">
                            <div class="panel-body">
                                {{ Utility.generateSummaryTitle( summaryTitle ) }}
                            </div>
                            <div class="panel-footer">
                                <div class="row">
                                    <div class="col-sm-7 text-center-xs">
                                        <p class="info">
                                            {# pagination \Knp\Bundle\PaginatorBundle\Pagination\SlidingPagination -#}
                                            {{ "Showing %pageCount% of %totalCount% results"|trans({'%totalCount%': pagination.totalItemCount, '%pageCount%': pagination.count }) }}
                                        </p>
                                    </div>
                                    <div class="col-sm-5 text-right text-center-xs">
                                        <div class="btn-group btn-group-sm" role="tablist">
                                            {% set activeViewMode = app.request.cookies.get("edirectory_results_viewmode", "item") -%}

                                            {% if activeViewMode == "map" and (pagination.totalItemCount >= 1000 or not map ) -%}
                                                {% set activeViewMode = "item" -%}
                                            {% endif -%}

                                            <a href="#" class="btn btn-default summaryViewModeButton {{ activeViewMode == "item" ? "active" }} {{ isTabLayout ?: "hidden" }}" data-viewmode="item" role="tab" data-target="#resultsList" data-toggle="tab"><span class="fa fa-list"></span> <span class="hidden-xs">{{ 'List'|trans}}</span></a>
                                            {% if pagination.totalItemCount < 1000 and map -%}
                                                <a id="summaryViewMapButton" href="#" class="btn btn-default summaryViewModeButton {{ activeViewMode == "map" ? "active" }}" data-viewmode="map" role="tab" data-target="#resultsMap" data-toggle="tab">
                                                    <span class="fa fa-street-view"></span> <span class="hidden-xs">{{ "Map View"|trans }}</span>
                                                </a>
                                            {% endif -%}
                                            <select name="order" id="searchSorter" class="btn btn-default btn-xs input-sm ">
                                                {# sorter \ArcaSolutions\SearchBundle\Entity\Sorters\BaseSorter -#}
                                                {% for sorter in searchEvent.sorters -%}
                                                    <option {{ sorter.selected ? "selected" }} data-needsgeolocation="{{ sorter.needsGeoLocation ? "1" : "0" }}" value="{{ sorter.getSearchPageUrl( ((searchEvent.defaultSorter.name is defined) and (searchEvent.defaultSorter.translatedName == sorter.translatedName)) ) }}">{{ sorter.translatedName|capitalize }}</option>
                                                {% endfor -%}
                                            </select>
                                            <span class="pull-right visible-xs">
                                                <a href="#" class="btn btn-sm btn-default" data-toggle="collapse" data-target="#searchFilter" aria-expanded="false">{{ "Refine"|trans }}</a>
                                            </span>
                                        </div>
                                    </div>
                                </div>

                            </div>
                        </div>

                    </div>
                </div>

            </div>

            <div class="row">
                <div class="col-sm-3">
                    {# Filters -#}
                    <div class="sidebar">
                        <div class="block search-filter collapse" id="searchFilter">
                            <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
                                <div class="panel panel-info">
                                    {% for filter in searchEvent.filters -%}
                                        {{ filter.filterView|raw }}
                                    {% endfor -%}
                                </div>
                            </div>
                        </div>

                        {% import "::blocks/utility/banners.html.twig" as banners %}
                        {{ banners.results() }}
                    </div>

                </div>

                <div class="col-sm-9" role="tabpanel">

                    <div class="tab-content results-page">

                        <div role="tabpanel" class="tab-pane {{ activeViewMode == "item" ? "active" }}" id="resultsList">

                            {% set pageCategories = pagination.customParameter('pageCategories') -%}
                            {% set pageLocations  = pagination.customParameter('pageLocations') -%}
                            {% set pageBadges     = pagination.customParameter('pageBadges') -%}

                            {% for result in pagination -%}
                                {{ include('::modules/' ~ result.getType() ~ '/summary.html.twig', { 'item': result, 'pageCategories' : pageCategories, 'pageLocations' : pageLocations, 'pageBadges' : pageBadges, 'levelFeatures' : levels }) }}
                            {% endfor -%}

                            <div class="navigation">
                                {{ knp_pagination_render(pagination) }}
                            </div>

                        </div>

                        {% if map -%}
                        <div role="tabpanel" class="tab-pane {{ activeViewMode == "map" ? "active" }}" id="resultsMap">
                            {{ google_map(map) }}
                            <div id="mapMarkerSummaryBox"></div>
                        </div>
                        {% endif -%}
                    </div>

                </div>
                {% else -%}
                    <div class="col-sm-12 search-toolbar">
                        <div class="panel panel-default">

                            <div class="panel-body">
                                <h1 class="panel-title small">{{ "No results containing all your search terms were found"|trans }}</h1>
                                <hr>
                                <br>
                                <h4>{{ "Suggestions"|trans }}:</h4>
                                <ul>
                                    <li>{{ "Try different and more general keywords"|trans }}</li>
                                    <li>{{ "Try removing filters to broaden your search"|trans }}</li>
                                    <li>{{ "Try browsing by section"|trans }}</li>
                                </ul>
                                <br><br>

                            </div>
                            <div class="panel-footer">

                               {{ 'Try another search or send %link_start%enquiry%link_end% to request information' | trans({'%link_start%' : '<a href="'~path('web_enquire')~'">', '%link_end%' : '</a>'}, 'account') | raw }}
                            </div>
                        </div>
                    </div>
                {% endif -%}
            </div>
        </div>
        <!--container well well-light-->
    </main>
    <!-- Main Content End -->

   <div class="block"><div class="container">{{ customContentBlocks.bottom|raw }}</div></div>

    {% include '::blocks/modals/modal-bootstrap-template.html.twig' with {id: 'modalLogin'} -%}

    {{ addJSFile('assets/js/lib/js.cookie.js') }}
    {{ addJSFile("assets/js/utility/geolocation.js") }}
    {{ addJSFile("assets/js/utility/modal.js") }}
    {{ addJSFile("assets/js/search/sorter.js") }}
    {{ addJSFile("assets/js/search/suggest.js") }}
    {{ addJSFile("assets/js/modal/send.email.js") }}
    {{ addJSFile("assets/js/search/report.click.js") }}
    {{ addJSTwig("::js/summary/results.js.twig") }}
    {{ addJSTwig("::js/reviews.js.twig") }}
{% endblock -%}


