<?php

/**
 * This file is part of JohnCMS Content Management System.
 *
 * @copyright JohnCMS Community
 * @license   https://opensource.org/licenses/GPL-3.0 GPL-3.0
 * @link      https://johncms.com JohnCMS Project
 */

/**
 * @var $title
 * @var $page_title
 * @var $curators_list
 * @var $back_url
 * @var $page
 * @var \Johncms\Modules\Forum\Domain\Models\ForumTopic $topic
 * @var $saved
 */

$this->layout(
    'system::layout/default',
    [
        'title'      => $title,
        'page_title' => $page_title,
    ]
);
?>
<h3><?= $this->e($topic->name) ?></h3>
<?php if ($saved): ?>
    <div class="alert alert-success"><?= __('Changes saved') ?></div>
<?php endif; ?>
<form action="/forum/curators/<?= $id ?>/<?= $page > 1 ? '?page=' . $page : '' ?>" method="post">
    <?php if (empty($curators_list)): ?>
        <div class="alert alert-info">
            <?= __('The list is empty') ?>
        </div>
    <?php else: ?>
        <?php foreach ($curators_list as $item): ?>
            <div class="form-group">
                <div class="custom-control custom-checkbox">
                    <input class="custom-control-input" type="checkbox" name="users[<?= $item['user_id'] ?>]" value="<?= $item['user_name'] ?>"
                           id="user_<?= $item['user_id'] ?>" <?= $item['checked'] ? ' checked="checked"' : '' ?>>
                    <label class="custom-control-label" for="user_<?= $item['user_id'] ?>"><?= $item['user_name'] ?></label>
                </div>
            </div>
        <?php endforeach; ?>
    <?php endif; ?>
    <div>
        <?php if (! empty($curators_list)): ?>
            <button type="submit" name="submit" value="1" class="btn btn-primary"><?= __('Assign') ?></button>
        <?php endif; ?>
        <a href="<?= $back_url ?>" class="btn btn-secondary"><?= __('Back to topic') ?></a>
    </div>
</form>
