{% import "../macros/staff-nav.html" as staff_nav %}

{% extends "base.html" %}

{% block title %}Účty{% endblock %}

{% block content %}
<h1 class="title">Účty</h1>
{% call staff_nav::staff_nav() %}
<hr>
<h2>Účty</h2>
<form method="post" action="/staff/actions/remove-accounts">
    <div class="table-wrap">
        <table class="data-table center">
            <tr>
                <th></th>
                <th>Jméno</th>
                <th>Vlastník</th>
                <th>Vytvořen</th>
                <th>Oprávnění</th>
            </tr>
            {% for account in accounts %}
                <tr>
                    <td><input name="accounts[]" type="checkbox" value="{{ account.username }}" {% if !tcx.perms.owner() %}disabled=""{% endif %}></td>
                    <td>{{ account.username }}</td>
                    <td>{% if account.owner %}Ano{% else %}Ne{% endif %}</td>
                    <td><time datetime="{{ account.created }}">{{ account.created|czech_datetime }}</time></td>
                    <td>{{ account.permissions.0 }} <a href="/staff/permissions/{{ account.username }}">[Zobrazit]</a></td>
                </tr>
            {% endfor %}
        </table>
    </div>
    {% if tcx.perms.owner() %}
        <input class="button" type="submit" value="Odstranit vybrané">
    {% endif %}
</form>
{% if tcx.perms.owner() %}
    <hr>
    <h2>Vytvořit účet</h2>
    <form method="post" action="/staff/actions/create-account">
        <table class="form-table">
            <tr>
                <td class="label">Jméno</td>
                <td><input name="username" type="text" required=""></td>
            </tr>
            <tr>
                <td class="label">Heslo</td>
                <td><input name="account_password" type="password" required=""></td>
            </tr>
            <tr>
                <td colspan="2"><input class="button" type="submit" value="Vytvořit účet"></td>
            </tr>
        </table>
    </form>
{% endif %}
{% endblock %}