{% extends "base.html" %}
{% block title %}Организации{% endblock %}
{% block content %}
<h1>Организации</h1>
<div class="card">
  <div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:12px;">
    <span>Всего: {{ orgs|length }}</span>
    <a href="/admin/orgs/create" class="btn btn-primary">+ Добавить</a>
  </div>
  <table>
    <thead><tr><th>#</th><th>Название</th><th>Создана</th><th>Действия</th></tr></thead>
    <tbody>
    {% for org in orgs %}
      <tr>
        <td>{{ org.id }}</td>
        <td>{{ org.name }}</td>
        <td>{{ org.created_at[:16] }}</td>
        <td>
          <a href="/admin/orgs/{{ org.id }}/edit" class="btn btn-secondary">Изменить</a>
          <form action="/admin/orgs/{{ org.id }}/delete" method="post"
                onsubmit="return confirm('Удалить организацию {{ org.name }}?')">
            <button class="btn btn-danger">Удалить</button>
          </form>
        </td>
      </tr>
    {% else %}
      <tr><td colspan="4" style="text-align:center;color:#999">Организаций нет</td></tr>
    {% endfor %}
    </tbody>
  </table>
</div>
{% endblock %}
