{{ header }}
<div class="background-white bottom-margin-large"
  data-info='{ "languages": {{ languageForJS|json_encode() }}, "layouts": {{ layouts|json_encode() }} }'
>
  <div class="container-fluid">
    <div class="row no-space-xs middle-xs">
      <div class="col-xs-12 col-sm col-md">
        <div class="content-box vertical-padding-large">
          <span class="text-x-large text-dark">{{ heading_title }}</span>
          <div class="adm-breadcrumb">
            {% for breadcrumb in breadcrumbs %}
							<i class="fas fa-angle-right text-x-small text-gray horizontal-padding-small"></i>
							<a href="{{ breadcrumb.href }}" class="text-x-small text-gray text-decoration-none">{{ breadcrumb.text }}</a>
            {% endfor %}
          </div>
        </div>
      </div>
			<div class="col-xs-12 col-sm-width-auto col-md-width-auto">
        <div class="content-box vertical-padding-x-large flex flex-row middle-xs">
          <a href="{{ cancel }}" class="btn-default btn-medium btn-outline right-margin-small">
						<span>{{ button_cancel }}</span>
					</a>
					<button type="button" class="btn-default btn-medium btn-primary js-submit-main-form">
						<span>{{ button_save }}</span>
					</button>
        </div>
      </div>
    </div>
  </div>
</div>
{% if error_warning %}
  <div class="warning full-width">{{ error_warning }}</div>
{% endif %}
<form action="{{ action }}" method="post" class="js-main-form">
  <div class="container-fluid">
    <div class="row">
      <div class="col-xs-12">
        <div class="content-box background-white shadow-small padding-large">
          <div class="row">
            <div class="col-xs-6">
              <label class="field field-medium">
                <span class="field-label">{{ text_title }}</span>
                <input class="field-entry" type="text" name="manufactured_title" value="{{ manufactured_title }}"/>
              </label>
            </div>
            <div class="col-xs-6">
              <label class="field field-medium">
                <span class="field-label">{{ entry_product }}</span>
                <input class="field-entry" type="text" name="manufacturer" value="">
              </label>
            </div>
            <div class="col-xs-12">
              <div id="manufactured-product" class="scrollbox field-entry">
                {% for manufactured in manufactureds %}
                  <div id="manufactured-product{{ manufactured.manufacturer_id }}" class="scrollbox-item flex between-xs">
                    <span class="text-small text-dark">{{ manufactured.name }}</span>
                    <i class="fas fa-trash-alt text-small right-margin-small text-error js-btn-remove"></i>
                    <input type="hidden" value="{{ manufactured.manufacturer_id }}">
                  </div>
                {% endfor %}
              </div>
              <input type="hidden" name="manufactured_id" value="{{ manufactured_id }}">
            </div>
          </div>
        </div>
      </div>
      <div class="col-xs-12">
        <div class="content-box">
          <div class="flex between-xs middle-xs bottom-padding-medium">
            <span class="text-x-large text-dark">Módulos</span>
            <button id="addFeatured" type="button" class="btn-default btn-medium btn-primary">
              <span>{{ button_add_module }}</span>
            </button>
          </div>
          <div id="manufactured_list">
            {% for key, module in modules %}
              <div id="{{ key }}" class="background-white padding-large bottom-margin-medium shadow-small adm-focus-within js-manufactured">
                <div class="row x-small-space-xs">
                  <div class="col-md-width-auto">
                    <label class="field field-medium">
                      <span class="field-label">{{ entry_limit }}</span>
                      <input class="field-entry mask-number" type="text" maxlength="2" name="manufactured_module[{{ key }}][limit]" value="{{ module.limit }}" size="1">
                      {% if error_limit[key] is defined %}
                        <span class="text-error text-x-small">{{ error_limit[key] }}</span>
                      {% endif %}
                    </label>
                  </div>
                  <div class="col-md">
                    <label class="field field-medium">
                      <span class="field-label">{{ entry_layout }}</span>
                      <select class="field-entry" name="manufactured_module[{{ key }}][layout_id]">
                        {% for layout in layouts %}
                          <option value="{{ layout.layout_id }}" {{ (layout.layout_id == module.layout_id) ? 'selected' : '' }} >
                          {{ layout.name }}</option>
                        {% endfor %}
                      </select>
                    </label>
                  </div>
                  <div class="col-md">
                    <label class="field field-medium">
                      <span class="field-label">{{ entry_position }}</span>
                      <select class="field-entry" name="manufactured_module[{{ key }}][position]">
                        {% for key, value in positions %}
                          <option value="{{ key }}" {{ module.position == key ? 'selected' : '' }}>
                            {{ value }}
                          </option>
                        {% endfor %}
                      </select>
                    </label>
                  </div>
                  <div class="col-md">
                    <label class="field field-medium">
                      <span class="field-label">{{ entry_status }}</span>
                      <select class="field-entry" name="manufactured_module[{{ key }}][status]">
                        {% for key, status in Type_Status.getEnumList() %}
                          <option value="{{ key }}" {{ ftr_geral.isSelected(key, module.status) }}>
                            {{ status }}
                          </option>
                        {% endfor %}
                      </select>
                    </label>
                  </div>
                  <div class="col-md-width-auto">
                    <label class="field field-medium">
                      <span class="field-label">{{ entry_sort_order }}</span>
                      <input class="field-entry mask-number" type="text" name="manufactured_module[{{ key }}][sort_order]" value="{{ module.sort_order }}" size="3">
                    </label>
                  </div>
                  <div class="col-xs-12 col-md-width-auto">
                    <div class="padding-medium cursor-pointer top-margin-medium js-remove-manufactured" data-tooltip="{{ button_remove }}" data-manufactured-id="{{ key }}">
                      <i class="fas fa-trash text-gray"></i>
                    </div>
                  </div>
                </div>
              </div>
            {% endfor %}
          </div>
        </div>
      </div>
    </div>
  </div>
</form>
{{ footer }}
