<div class="row">
    <div class="col-md-12 {if isset($template_id)}general-block-decorator{/if}" id="module-choice-filter">
        <div class="table-responsive">
            <p class="title title-without-tabs">
                {if isset($template_id)}
                    {intl l="Position of the filters in front for this template" d="choicefilter.bo.default"}
                {/if}
                {if isset($category_id)}
                    {intl l="Position of the filters in front for this category"  d="choicefilter.bo.default"}
                {/if}
            </p>

            {flash type="choice-filter-success"}
                <div class="alert alert-success">
                    {$MESSAGE}
                </div>
            {/flash}
            {if $messageInfo|default:[]|count}
            <div class="alert alert-info">
                {foreach from=$messageInfo item=message}
                    {$message}<br/>
                {/foreach}
            </div>
            {/if}

            {if !$enabled}
                <div class="alert alert-info">
                    {intl l="The position of the filters is for now the default one."  d="choicefilter.bo.default"}
                </div>
            {/if}

            <form action="{url path='/admin/module/choicefilter/save'}" method="POST">

            {if isset($template_id)}
                <input type="hidden" name="ChoiceFilter[template_id]" value="{$template_id}" />
            {/if}

            {if isset($category_id)}
                <input type="hidden" name="ChoiceFilter[category_id]" value="{$category_id}" />
            {/if}

            {if !$enabled}
                <div class="text-center">
                    <a href="#" class="btn btn-primary js-action-enable">
                        {intl l="Customize filter configuration for this category"  d="choicefilter.bo.default"}
                    </a>
                    <br/>
                    <br/>
                </div>
            {/if}

            <table class="table table-striped table-condensed table-left-aligned {if !$enabled}disabled{/if}">
                <thead>
                <tr>
                    <th>{intl l="ID"  d="choicefilter.bo.default"}</th>
                    <th>{intl l="Type"  d="choicefilter.bo.default"}</th>
                    <th>{intl l="Title"  d="choicefilter.bo.default"}</th>
                    <th>{intl l="Visible"  d="choicefilter.bo.default"}</th>
                    <th>{intl l="Position"  d="choicefilter.bo.default"}</th>
                </tr>
                </thead>
                <tbody>
                {foreach from=$filters key=key item=filter}
                <tr>
                    <td>
                        <input type="hidden" name="ChoiceFilter[filter][{$key}][id]" value="{$filter.Id}" />
                        {$filter.Id}
                    </td>
                    <td>
                        <input type="hidden" name="ChoiceFilter[filter][{$key}][type]" value="{$filter.Type}" />
                        {$filter.Type}
                    </td>
                    <td>
                        {$filter.Title}
                    </td>
                    <td>
                        <select name="ChoiceFilter[filter][{$key}][visible]">
                            <option {if $filter.Visible}selected{/if} value="1">{intl l="Yes"  d="choicefilter.bo.default"}</option>
                            <option {if !$filter.Visible}selected{/if} value="0">{intl l="No"  d="choicefilter.bo.default"}</option>
                        </select>
                    </td>
                    <td>
                        <input type="number" step="1" min="0" name="ChoiceFilter[filter][{$key}][position]" value="{$filter.Position}" />
                    </td>
                </tr>
                {/foreach}
                </tbody>
                <tfoot>
                    <tr>
                        <td colspan="99" class="text-center">
                            <button type="submit" class="btn btn-primary">{intl l="Save"  d="choicefilter.bo.default"}</button>
                        </td>
                    </tr>
                </tfoot>
            </table>
            </form>

            {if $enabled}
                <form action="{url path='/admin/module/choicefilter/clear'}" method="POST" class="text-center">
                    {if isset($template_id)}
                        <input type="hidden" name="ChoiceFilter[template_id]" value="{$template_id}" />
                    {/if}

                    {if isset($category_id)}
                        <input type="hidden" name="ChoiceFilter[category_id]" value="{$category_id}" />
                    {/if}

                    <button type="submit" class="btn btn-danger">
                        {intl l="Reset default values"  d="choicefilter.bo.default"}
                    </button>
                    <br/>
                    <br/>
                </form>
            {/if}
        </div>
    </div>
</div>
