<?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 $data
 */

$this->layout(
    'system::layout/default',
    [
        'title'      => $title,
        'page_title' => $title,
    ]
);
?>

<form action="<?= $data['form_action'] ?>" method="post">
    <?php if (! empty($data['post_id'])): ?>
        <input type="hidden" value="<?= $data['post_id'] ?>" name="banref">
    <?php endif; ?>

    <h3><?= __('Ban:') ?> <?= $data['user_login'] ?></h3>

    <h4><?= __('Ban type') ?></h4>
    <?php if ($user->rights >= 6): ?>
        <div class="custom-control custom-radio">
            <input type="radio" id="full" name="term" value="1" class="custom-control-input" checked="checked">
            <label class="custom-control-label" for="full"><?= __('Full block') ?></label>
        </div>
        <div class="custom-control custom-radio">
            <input type="radio" id="private" name="term" value="3" class="custom-control-input">
            <label class="custom-control-label" for="private"><?= __('Private messages') ?></label>
        </div>
        <div class="custom-control custom-radio">
            <input type="radio" id="comments" name="term" value="10" class="custom-control-input">
            <label class="custom-control-label" for="comments"><?= __('Comments') ?></label>
        </div>
        <div class="custom-control custom-radio">
            <input type="radio" id="guestbook" name="term" value="13" class="custom-control-input">
            <label class="custom-control-label" for="guestbook"><?= __('Guestbook') ?></label>
        </div>
    <?php endif ?>
    <?php if ($user->rights === 3 || $user->rights >= 6): ?>
        <div class="custom-control custom-radio">
            <input type="radio" id="forum" name="term" value="11" class="custom-control-input" <?= ($user->rights === 3 ? 'checked="checked"' : '') ?>>
            <label class="custom-control-label" for="forum"><?= __('Forum') ?></label>
        </div>
    <?php endif ?>
    <?php if ($user->rights === 5 || $user->rights >= 6): ?>
        <div class="custom-control custom-radio">
            <input type="radio" id="library" name="term" value="15" class="custom-control-input">
            <label class="custom-control-label" for="library"><?= __('Library') ?></label>
        </div>
    <?php endif ?>

    <h3 class="mt-3"><?= __('Ban time') ?></h3>
    <div class="form-group mt-2">
        <label for="time"><?= __('Time') ?></label>
        <input type="text" name="timeval" value="12" class="form-control" id="time">
    </div>
    <div class="custom-control custom-radio">
        <input type="radio" id="minutes" name="time" value="1" class="custom-control-input">
        <label class="custom-control-label" for="minutes"><?= __('Minutes (60 max.)') ?></label>
    </div>
    <div class="custom-control custom-radio">
        <input type="radio" id="hours" name="time" value="2" class="custom-control-input" checked="checked">
        <label class="custom-control-label" for="hours"><?= __('Hours (24 max.)') ?></label>
    </div>
    <?php if ($user->rights >= 6): ?>
        <div class="custom-control custom-radio">
            <input type="radio" id="days" name="time" value="3" class="custom-control-input" checked="checked">
            <label class="custom-control-label" for="days"><?= __('Days (30 max.)') ?></label>
        </div>
    <?php endif ?>
    <?php if ($user->rights >= 7): ?>
        <div class="custom-control custom-radio">
            <input type="radio" id="till_cancel" name="time" value="4" class="custom-control-input">
            <label class="custom-control-label" for="till_cancel"><?= __('Till cancel') ?></label>
        </div>
    <?php endif ?>

    <div class="form-group">
        <label for="reason"><?= __('Reason') ?></label>
        <textarea id="reason" rows="<?= $user->config->fieldHeight ?>" class="form-control" name="reason"></textarea>
    </div>


    <div class="mt-3">
        <input type="submit" name="submit" value="<?= __('Apply Ban') ?>" class="btn btn-primary"/>
        <a href="<?= $data['back_url'] ?>" class="btn btn-secondary"><?= __('Cancel') ?></a>
    </div>
</form>
