{% extends "./layout/default" %}

{% block breadcrumbs %}
    {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, query) }}
{% endblock %}

{% block content %}
    <div class="row">
        <div class="col-lg-12">
            <div class="box box-primary">
                <div class="box-header with-border">
                    <h3 class="box-title">{{ 'search_box'|_ }}</h3>
                </div>
                <div class="box-body">
                    <p>
                        {{ 'search_box_intro'|_ }}
                    </p>
                    {# search form #}
                    <form class="form-horizontal" action="{{ route('search.index') }}" method="get">
                        <div class="form-group">
                            <label for="query" class="col-sm-1 control-label">Query</label>
                            <div class="col-sm-10">
                                <input type="text" name="q" id="query" value="{{ fullQuery }}" class="form-control" placeholder="{{ fullQuery }}">
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-offset-1 col-sm-10">
                                <button type="submit" class="btn btn-default"><i class="fa fa-search"></i> Search</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    {% if query %}
        <div class="row result_row">
            <div class="col-lg-12 col-md-12 col-sm-12">
                <div class="box search_box">
                    <div class="box-header with-border">
                        <h3 class="box-title">{{ 'transactions'|_ }}</h3>
                    </div>
                    <div class="box-body">
                        <p class="search_ongoing text-center" style="margin-top:70px;">
                            {{ 'search_searching'|_ }}
                        </p>
                        <p class="search_count" style="display: none;">
                            {{ 'search_found_transactions'|_ }} <span class="search_count"></span>
                        </p>
                        <div class="search_results" style="display: none;">
                        </div>
                        {# loading indicator #}
                        <div class="overlay">
                            <i class="fa fa-refresh fa-spin"></i>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="row error_row" style="display:none; ">
            <div class="col-lg-12 col-md-12 col-sm-12">
                <div class="box box-danger">
                    <div class="box-header with-border">
                        <h3 class="box-title">{{ 'search_error'|_ }}</h3>
                    </div>
                    <div class="box-body">
                        <p class="search_ongoing">
                            {{ 'general_search_error'|_ }}
                        </p>
                    </div>
                </div>
            </div>
        </div>
    {% endif %}
    {% if query == "" %}
        <div class="row">
            <div class="col-lg-12 col-md-12 col-sm-12">
                <div class="box">
                    <div class="box-header with-border">
                        <h3 class="box-title">{{ 'search_results'|_ }}</h3>
                    </div>
                    <div class="box-body">
                        <p>{{ 'no_results_for_empty_search'|_ }}</p>
                    </div>
                </div>
            </div>
        </div>
    {% endif %}
{% endblock %}
{% block scripts %}
    <script type="text/javascript">
        var searchQuery = "{{ fullQuery|escape('js') }}";
        var searchUri = "{{ route('search.search') }}";
    </script>
    <script type="text/javascript" src="js/ff/search/index.js"></script>
{% endblock %}