{include file="_partials/head.tpl"}

<div class="page-head">
  <div>
    <h1>{lang key="shop.manufacturers_list.title"} <span class="muted" style="font-weight:400">· {total}</span></h1>
    <p class="muted">{lang key="shop.manufacturers_list.subtitle"}</p>
  </div>
  <div class="actions">
    <a class="btn btn-primary" href="/admin/shop/manufacturers/create">+ {lang key="shop.manufacturers_list.new"}</a>
  </div>
</div>

<form method="get" action="/admin/shop/manufacturers" class="prod-filters">
  <div class="prod-filter-row" style="grid-template-columns: 1fr auto">
    <div class="prod-search">
      {icon name="search" size="16"}
      <input type="search" name="q" value="{q}" placeholder="{lang key="shop.manufacturers_list.search"}">
    </div>
    <button type="submit" class="btn btn-primary">Применить</button>
  </div>
</form>

[if {manufacturers}]
<div class="prod-table-wrap">
<table class="table prod-table">
  <thead>
    <tr>
      <th>{lang key="shop.manufacturer.logo"}</th>
      <th>{lang key="shop.product.title"}</th>
      <th>{lang key="shop.manufacturers_list.col.country"}</th>
      <th>{lang key="shop.manufacturers_list.col.website"}</th>
      <th>{lang key="shop.manufacturers_list.col.products"}</th>
      <th>{lang key="shop.products_list.col.status"}</th>
      <th class="actions"></th>
    </tr>
  </thead>
  <tbody>
    [foreach var="manufacturers" as="m"]
      <tr>
        <td><div class="prod-thumb" style="width:42px;height:42px">[if {m.logo}]<img src="{m.logo|thumb}" alt="">[else]{icon name="factory" size="20"}[/if]</div></td>
        <td>
          <a href="/admin/shop/manufacturers/{m.id}/edit" class="prod-title">{m.title}</a>
          <div class="prod-cell-sub"><code class="prod-slug">/{m.slug}</code></div>
        </td>
        <td>[if {m.country}]{m.country}[else]<span class="muted">—</span>[/if]</td>
        <td>[if {m.website}]<a href="{m.website}" target="_blank" rel="noopener">{m.website}</a>[else]<span class="muted">—</span>[/if]</td>
        <td>{m.products_count}</td>
        <td>[if {m.is_active}]<span class="badge badge-published">{lang key="shop.manufacturers_list.active"}</span>[else]<span class="badge badge-draft">{lang key="shop.manufacturers_list.hidden"}</span>[/if]</td>
        <td class="actions prod-row-actions">
          <a href="/admin/shop/manufacturers/{m.id}/edit" class="btn btn-ghost btn-sm">{lang key="shop.common.edit_short"}</a>
          <form method="post" action="/admin/shop/manufacturers/{m.id}/delete" style="display:inline" data-confirm="Удалить производителя? Товары будут отвязаны." data-confirm-danger="1">
            {csrf}<button type="submit" class="row-icon-btn row-icon-danger" title="{lang key="shop.common.delete_title"}">{icon name="close" size="14"}</button>
          </form>
        </td>
      </tr>
    [/foreach]
  </tbody>
</table>
</div>
{include file="_partials/pagination.tpl"}
[else]
<div class="empty-state">
  <div class="icon">{icon name="factory" size="42"}</div>
  <p>{lang key="shop.manufacturers_list.empty_title"}</p>
  <a href="/admin/shop/manufacturers/create" class="btn btn-primary">{lang key="shop.common.add_first_male"}</a>
</div>
[/if]

{include file="_partials/foot.tpl"}
