<?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 \Johncms\Modules\Forum\Domain\Models\ForumSection $current_section
 * @var \Johncms\Modules\Forum\Domain\Models\ForumSection[] $current_sections
 * @var \Johncms\Modules\Forum\Domain\Models\ForumSection[] $other_categories
 * @var $back_url
 * @var $form_action
 * @var $csrf_token
 */

$this->layout(
    'system::layout/default',
    [
        'title'      => $title,
        'page_title' => $page_title,
    ]
);
?>
<form name="move_topic" class="card card-body shadow" action="<?= $form_action ?>" method="post">
    <input type="hidden" name="csrf_token" value="<?= $csrf_token ?>">
    <div class="mb-2">
        <div><?= __('Category') ?></div>
        <b><?= $this->e($current_section->name) ?></b>
    </div>
    <?php if (! empty($current_sections)): ?>
        <div class="form-group">
            <label for="section"><?= __('New section') ?></label>
            <select class="form-control" name="razd" id="section">
                <?php foreach ($current_sections as $section): ?>
                    <option value="<?= $section->id ?>"><?= $this->e($section->name) ?></option>
                <?php endforeach; ?>
            </select>
        </div>
    <?php else: ?>
        <div class="alert alert-warning">
            <?= __('Category is empty') ?>
        </div>
    <?php endif; ?>
    <div>
        <button type="submit" name="submit" value="1" class="btn btn-primary"><?= __('Move') ?></button>
        <a href="<?= $back_url ?>" class="btn btn-secondary"><?= __('Back to topic') ?></a>
    </div>
    <?php if (! empty($other_categories)): ?>
        <div class="mt-4">
            <div class="h4"><?= __('Other categories') ?></div>
            <ul class="list-group list-group-flush">
                <?php foreach ($other_categories as $category): ?>
                    <li class="list-group-item">
                        <a href="/forum/move-topic/<?= $id ?>/?other=<?= $category->id ?>"><?= $this->e($category->name) ?></a>
                    </li>
                <?php endforeach; ?>
            </ul>
        </div>
    <?php endif; ?>
</form>
