{{ header }}{{ column_left }}
<div id="content">
  <div class="page-header">
    <div class="container-fluid">
      <div class="float-end">
        <button type="submit" form="form-filter" data-bs-toggle="tooltip" title="{{ button_save }}" class="btn btn-primary"><i class="fa-solid fa-floppy-disk"></i></button>
        <a href="{{ back }}" data-bs-toggle="tooltip" title="{{ button_back }}" class="btn btn-light"><i class="fa-solid fa-reply"></i></a></div>
      <h1>{{ heading_title }}</h1>
      <ol class="breadcrumb">
        {% for breadcrumb in breadcrumbs %}
          <li class="breadcrumb-item"><a href="{{ breadcrumb.href }}">{{ breadcrumb.text }}</a></li>
        {% endfor %}
      </ol>
    </div>
  </div>
  <div class="container-fluid">
    <div class="card">
      <div class="card-header"><i class="fa-solid fa-pencil"></i> {{ text_form }}</div>
      <div class="card-body">
        <form id="form-filter" action="{{ save }}" method="post" data-oc-toggle="ajax">
          <fieldset>
            <legend>{{ text_group }}</legend>
            <div class="row mb-3 required">
              <label class="col-sm-2 col-form-label">{{ entry_group }}</label>
              <div class="col-sm-10">
                {% for language in languages %}
                  <div class="input-group">
                    <div class="input-group-text"><img src="{{ language.image }}" title="{{ language.name }}"/></div>
                    <input type="text" name="filter_group_description[{{ language.language_id }}][name]" value="{{ filter_group_description[language.language_id] ? filter_group_description[language.language_id].name }}" placeholder="{{ entry_group }}" id="input-group-{{ language.language_id }}" class="form-control"/>
                  </div>
                  <div id="error-group-{{ language.language_id }}" class="invalid-feedback"></div>
                {% endfor %}
              </div>
            </div>
            <div class="row mb-3">
              <label for="input-sort-order" class="col-sm-2 col-form-label">{{ entry_sort_order }}</label>
              <div class="col-sm-10">
                <input type="text" name="sort_order" value="{{ sort_order }}" placeholder="{{ entry_sort_order }}" id="input-sort-order" class="form-control"/>
              </div>
            </div>
          </fieldset>
          <fieldset>
            <legend>{{ text_value }}</legend>
            <table id="filter" class="table table-bordered table-hover">
              <thead>
                <tr>
                  <td class="text-start required">{{ entry_name }}</td>
                  <td class="text-end">{{ entry_sort_order }}</td>
                  <td></td>
                </tr>
              </thead>
              <tbody>
                {% set filter_row = 0 %}
                {% for filter in filters %}
                  <tr id="filter-row-{{ filter_row }}">
                    <td class="text-start" style="width: 70%;"><input type="hidden" name="filter[{{ filter_row }}][filter_id]" value="{{ filter.filter_id }}"/>
                      {% for language in languages %}
                        <div class="input-group">
                          <div class="input-group-text"><img src="{{ language.image }}" title="{{ language.name }}"/></div>
                          <input type="text" name="filter[{{ filter_row }}][filter_description][{{ language.language_id }}][name]" value="{{ filter.filter_description[language.language_id] ? filter.filter_description[language.language_id].name }}" placeholder="{{ entry_name }}" id="input-filter-{{ filter_row }}-{{ language.language_id }}" class="form-control"/>
                        </div>
                        <div id="error-filter-{{ filter_row }}-{{ language.language_id }}" class="invalid-feedback"></div>
                      {% endfor %}</td>
                    <td class="text-end"><input type="text" name="filter[{{ filter_row }}][sort_order]" value="{{ filter.sort_order }}" placeholder="{{ entry_sort_order }}" id="input-sort-order" class="form-control"/></td>
                    <td class="text-end"><button type="button" onclick="$('#filter-row-{{ filter_row }}').remove();" data-bs-toggle="tooltip" title="{{ button_remove }}" class="btn btn-danger"><i class="fa-solid fa-minus-circle"></i></button></td>
                  </tr>
                  {% set filter_row = filter_row + 1 %}
                {% endfor %}
              </tbody>
              <tfoot>
                <tr>
                  <td colspan="2"></td>
                  <td class="text-end"><button type="button" id="button-filter" data-bs-toggle="tooltip" title="{{ button_filter_add }}" class="btn btn-primary"><i class="fa-solid fa-plus-circle"></i></button></td>
                </tr>
              </tfoot>
            </table>
          </fieldset>
          <input type="hidden" name="filter_group_id" value="{{ filter_group_id }}" id="input-filter-group-id"/>
        </form>
      </div>
    </div>
  </div>
</div>
<script type="text/javascript"><!--
var filter_row = {{ filter_row }};

$('#button-filter').on('click', function () {
    html = '<tr id="filter-row-' + filter_row + '">';
    html += '  <td class="text-start" style="width: 70%;"><input type="hidden" name="filter[' + filter_row + '][filter_id]" value=""/>';
  {% for language in languages %}
    html += '  <div class="input-group">';
    html += '    <div class="input-group-text"><img src="{{ language.image|escape('js') }}" title="{{ language.name|escape('js') }}" /></div>';
    html += '    <input type="text" name="filter[' + filter_row + '][filter_description][{{ language.language_id }}][name]" value="" placeholder="{{ entry_name|escape('js') }}" id="input-filter-' + filter_row + '-{{ language.language_id }}" class="form-control"/>';
    html += '  </div>';
    html += '  <div id="error-filter-' + filter_row + '-{{ language.language_id }}" class="invalid-feedback"></div>';
  {% endfor %}
    html += '  </td>';
    html += '  <td class="text-end"><input type="text" name="filter[' + filter_row + '][sort_order]" value="" placeholder="{{ entry_sort_order|escape('js') }}" id="input-sort-order" class="form-control"/></td>';
    html += '  <td class="text-end"><button type="button" onclick="$(\'#filter-row-' + filter_row + '\').remove();" data-bs-toggle="tooltip" title="{{ button_remove|escape('js') }}" class="btn btn-danger"><i class="fa-solid fa-minus-circle"></i></button></td>';
    html += '</tr>';

    $('#filter tbody').append(html);

    filter_row++;
});
//--></script>
{{ footer }}