{% if search_type == 'zoom' %}
    {% include 'table/search/form_tag.twig' with {
        'script_name': 'tbl_zoom_select.php',
        'form_id': 'zoom_search_form',
        'db': db,
        'table': table,
        'goto': goto
    } only %}
    <fieldset id="fieldset_zoom_search">
        <fieldset id="inputSection">
            <legend>
                {% trans 'Do a "query by example" (wildcard: "%") for two different columns' %}
            </legend>
            {% include 'table/search/fields_table.twig' with {
                'self': self,
                'search_type': search_type,
                'geom_column_flag': geom_column_flag,
                'column_names': column_names,
                'column_types': column_types,
                'column_collations': column_collations,
                'keys' : keys,
                'criteria_column_names': criteria_column_names,
                'criteria_column_types': criteria_column_types
            } only %}<table class="data">
                {# Select options for data label #}
                <tr>
                    <td>
                        <label for="dataLabel">
                            {% trans 'Use this column to label each point' %}
                        </label>
                    </td>
                    <td>
                        <select name="dataLabel" id="dataLabel" >
                            <option value = "">
                                {% trans 'None' %}
                            </option>
                            {% for i in 0..column_names|length - 1 %}
                                {% if data_label is defined and data_label == column_names[i]|e %}
                                    <option value="{{ column_names[i] }}" selected="selected">
                                        {{ column_names[i] }}
                                    </option>
                                {% else %}
                                    <option value="{{ column_names[i] }}" >
                                        {{ column_names[i] }}
                                    </option>
                                {% endif %}
                            {% endfor %}
                        </select>
                    </td>
                </tr>
                {# Inputbox for changing default maximum rows to plot #}
                <tr>
                    <td>
                        <label for="maxRowPlotLimit">
                            {% trans 'Maximum rows to plot' %}
                        </label>
                    </td>
                    <td>
                        <input type="number"
                            name="maxPlotLimit"
                            id="maxRowPlotLimit"
                            required="required"
                            value="{{ max_plot_limit }}">
                    </td>
                </tr>
            </table>
        </fieldset>
    </fieldset>
{% elseif search_type == 'normal' %}
    {% include 'table/search/form_tag.twig' with {
        'script_name': 'tbl_select.php',
        'form_id': 'tbl_search_form',
        'db': db,
        'table': table,
        'goto': goto
    } only %}
    <fieldset id="fieldset_table_search">
        <fieldset id="fieldset_table_qbe">
            <legend>
                {% trans 'Do a "query by example" (wildcard: "%")' %}
            </legend>
            <div class="responsivetable jsresponsive">
                {% include 'table/search/fields_table.twig' with {
                    'self': self,
                    'search_type': search_type,
                    'geom_column_flag': geom_column_flag,
                    'column_names': column_names,
                    'column_types': column_types,
                    'column_collations': column_collations,
                    'criteria_column_names': criteria_column_names,
                    'criteria_column_types': criteria_column_types
                } only %}
            </div>
            <div id="gis_editor"></div>
            <div id="popup_background"></div>
        </fieldset>
        {% include 'div_for_slider_effect.twig' with {
            'id': 'searchoptions',
            'message': 'Options'|trans,
            'initial_sliders_state': default_sliders_state
        } only %}

        {# Displays columns select list for selecting distinct columns in the search #}
        <fieldset id="fieldset_select_fields">
            <legend>
                {% trans 'Select columns (at least one):' %}
            </legend>
            <select name="columnsToDisplay[]"
                size="{{ min(column_names|length, 10) }}"
                multiple="multiple">
                {% for each_field in column_names %}
                    <option value="{{ each_field }}"
                        selected="selected">
                        {{ each_field }}
                    </option>
                {% endfor %}
            </select>
            <input type="checkbox" name="distinct" value="DISTINCT" id="oDistinct">
            <label for="oDistinct">DISTINCT</label>
        </fieldset>

        {# Displays input box for custom 'Where' clause to be used in the search #}
        <fieldset id="fieldset_search_conditions">
            <legend>
                <em>{% trans 'Or' %}</em>
                {% trans 'Add search conditions (body of the "where" clause):' %}
            </legend>
            {{ show_mysql_docu('Functions') }}
            <input type="text" name="customWhereClause" class="textfield" size="64">
        </fieldset>

        {# Displays option of changing default number of rows displayed per page #}
        <fieldset id="fieldset_limit_rows">
            <legend>{% trans 'Number of rows per page' %}</legend>
            <input type="number"
                name="session_max_rows"
                required="required"
                min="1"
                value="{{ max_rows }}"
                class="textfield">
        </fieldset>

        {# Displays option for ordering search results by a column value (Asc or Desc) #}
        <fieldset id="fieldset_display_order">
            <legend>{% trans 'Display order:' %}</legend>
            <select name="orderByColumn"><option value="--nil--"></option>
                {% for each_field in column_names %}
                    <option value="{{ each_field }}">
                        {{ each_field }}
                    </option>
                {% endfor %}
            </select>

            {{ get_radio_fields(
                'order',
                {
                    'ASC': 'Ascending'|trans,
                    'DESC': 'Descending'|trans
                },
                'ASC',
                false,
                true,
                'formelement'
            ) }}

        </fieldset>
        <div class="clearfloat"></div>
    </fieldset>
{% elseif search_type == 'replace' %}
    {% include 'table/search/form_tag.twig' with {
        'script_name': 'tbl_find_replace.php',
        'form_id': 'find_replace_form',
        'db': db,
        'table': table,
        'goto': goto
    } only %}
    <fieldset id="fieldset_find_replace">
        <fieldset id="fieldset_find">
            <legend>
                {% trans 'Find and replace' %}
            </legend>{% trans 'Find:' %}
            <input type="text" value="" name="find" required>
            {% trans 'Replace with:' %}
            <input type="text" value="" name="replaceWith">

            {% trans 'Column:' %}
            <select name="columnIndex">
                {% for i in 0..column_names|length - 1 %}
                    {% set type = types[column_names[i]] %}

                    {% if sql_types.getTypeClass(type) == 'CHAR' %}
                        <option value="{{ i }}">
                            {{- column_names[i] -}}
                        </option>
                    {% endif %}
                {% endfor %}
            </select>

            {% include 'checkbox.twig' with {
                'html_field_id': 'useRegex',
                'html_field_name': 'useRegex',
                'label': 'Use regular expression'|trans,
                'checked': false,
                'onclick': false
            } only %}
        </fieldset>
    </fieldset>
{% else %}
    {% include 'table/search/form_tag.twig' with {
        'script_name': '',
        'form_id': '',
        'db': db,
        'table': table,
        'goto': goto
    } only %}
{% endif %}

{# Displays selection form's footer elements #}
    <fieldset class="tblFooters">
        <input class="btn btn-primary" type="submit"
            name="{{ search_type == 'zoom' ? 'zoom_submit' : 'submit' }}"
            {{ search_type == 'zoom' ? 'id="inputFormSubmitId"' }}
            value="{% trans 'Go' %}">
    </fieldset>
</form>
<div id="sqlqueryresultsouter"></div>
