{extends "@layout.xml"}

{block title}
    Редактировать {$club->getCanonicalName()}
{/block}

{block heading}
    {$club->getCanonicalName()}
{/block}


{block content}

{var isMain       = $mode === 'main'}
{var isBan        = $mode === 'ban'}
{var isFollowers       = $mode === 'followers'}

{if $isMain}

<!-- This main block -->

<div class="aui-tabs horizontal-tabs">
<nav class="aui-navgroup aui-navgroup-horizontal">
    <div class="aui-navgroup-inner">
        <div class="aui-navgroup-primary">
            <ul class="aui-nav">
                <li class="aui-nav-selected"><a href="?act=main">Главное</a></li>
                <li><a href="?act=ban">Бан</a></li>
                <li><a href="?act=followers">Участники</a></li>
            </ul>
        </div>
    </div>
</nav>
    <form class="aui" method="POST">
        <div class="field-group">
            <label for="avatar">
                Аватарка
            </label>
            <span id="avatar" class="aui-avatar aui-avatar-project aui-avatar-xlarge">
                <span class="aui-avatar-inner">
                    <img src="{$club->getAvatarUrl()}" style="object-fit: cover;"></img>
                </span>
            </span>
        </div>
         <div class="field-group">
            <label for="id">
                ID
            </label>
            <input class="text medium-field" type="number" id="id" disabled value="{$club->getId()}" />
        </div>
         <div class="field-group">
            <label for="id_owner">
                ID владельца
            </label>
            <input class="text medium-field" type="text" id="id_owner" name="id_owner" value="{$club->getOwner()->getId()}" />
        </div>
        <div class="field-group">
            <label for="name">
                Название
            </label>
            <input class="text medium-field" type="text" id="name" name="name" value="{$club->getName()}" />
        </div>
        <div class="field-group">
            <label for="about">
                Описание
            </label>
            <input class="text medium-field" type="text" id="about" name="about" value="{$club->getDescription()}" />
        </div>
         <div class="field-group">
            <label for="shortcode">
                Адрес
            </label>
            <input class="text medium-field" type="text" id="shortcode" name="shortcode" value="{$club->getShortCode()}" />
        </div>
        <br/>
        <div class="group">
            <input class="toggle-large" type="checkbox" id="verify" name="verify" value="1" {if $club->isVerified()} checked {/if} />
            <label for="verify">
                Верификация
            </label>
        </div>
        <hr/>
        <div class="buttons-container">
            <div class="buttons">
                <input type="hidden" name="hash" value="{$csrfToken}" />
                <input class="button submit" type="submit" value="Сохранить">
            </div>
        </div>
    </form>
</div>
{/if}

{if $isBan}

<!-- This ban block -->

<div class="aui-tabs horizontal-tabs">
<nav class="aui-navgroup aui-navgroup-horizontal">
    <div class="aui-navgroup-inner">
        <div class="aui-navgroup-primary">
            <ul class="aui-nav">
                <li><a href="?act=main">Главное</a></li>
                <li class="aui-nav-selected"><a href="?act=ban">Бан</a></li>
                <li><a href="?act=followers">Участники</a></li>
            </ul>
        </div>
    </div>
</nav>
<form class="aui" method="POST">
<div class="field-group">
    <label for="ban_reason">
        Причина бана
    </label>
    <input class="text" type="text" id="text-input" name="ban_reason" value="{$club->getBanReason()}" />
</div>
<hr/>
<div class="buttons-container">
    <div class="buttons">
        <input type="hidden" name="hash" value="{$csrfToken}" />
        <input class="button submit" type="submit" value="Сохранить">
    </div>
</div>
</form>
</div>
{/if}

{if $isFollowers}

<!-- This followers block -->

{var followers  = iterator_to_array($followers)}

<div class="aui-tabs horizontal-tabs">
<nav class="aui-navgroup aui-navgroup-horizontal">
    <div class="aui-navgroup-inner">
        <div class="aui-navgroup-primary">
            <ul class="aui-nav">
                <li><a href="?act=main">Главное</a></li>
                <li><a href="?act=ban">Бан</a></li>
                <li class="aui-nav-selected"><a href="?act=followers">Участники</a></li>
            </ul>
        </div>
    </div>
</nav>
<table rules="none" class="aui aui-table-list">
        <tbody>
            <tr n:foreach="$followers as $follower">
                <td>{$follower->getId()}</td>
                <td>
                    <span class="aui-avatar aui-avatar-xsmall">
                        <span class="aui-avatar-inner">
                            <img src="{$follower->getAvatarUrl()}" alt="{$follower->getCanonicalName()}" role="presentation" />
                        </span>
                    </span>
                    
                    <a href="{$follower->getURL()}">{$follower->getCanonicalName()}</a>
                    
                    <span n:if="$follower->isBanned()" class="aui-lozenge aui-lozenge-subtle aui-lozenge-removed">
                        заблокирован
                    </span>
                </td>
                <td>{$follower->isFemale() ? "Женский" : "Мужской"}</td>
                <td>{$follower->getShortCode() ?? "(отсутствует)"}</td>
                <td>{$follower->getRegistrationTime()}</td>
                <td>
                    <a class="aui-button aui-button-primary" href="/admin/users/id{$follower->getId()}">
                        <span class="aui-icon aui-icon-small aui-iconfont-new-edit">Редактировать</span>
                    </a>
                </td>
            </tr>
        </tbody>
    </table>
    <div align="right">
        {var isLast = ((20 * (($_GET['p'] ?? 1) - 1)) + $amount) < $count}
        
        <a n:if="($_GET['p'] ?? 1) > 1" class="aui-button" href="?p={($_GET['p'] ?? 1) - 1}">
            ⭁ туда
        </a>
        <a n:if="$isLast" class="aui-button" href="?p={($_GET['p'] ?? 1) + 1}">
            ⭇  сюда
        </a>
    </div>
</div>
{/if}
{/block}