<?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,
    ]
);
?>

<?php if (! empty($data['success_message'])): ?>
    <?= $this->fetch(
        'system::app/alert',
        [
            'alert_type' => 'alert-success',
            'alert'      => $data['success_message'],
        ]
    ) ?>
<?php endif; ?>
<form action="<?= $data['form_action'] ?>" method="post">
    <h3><?= $data['vote_title'] ?></h3>

    <h4><?= __('Type of vote') ?></h4>
    <div class="custom-control custom-radio">
        <input type="radio" id="positive" name="type" value="1" class="custom-control-input" checked="checked">
        <label class="custom-control-label" for="positive"><?= __('Positive') ?></label>
    </div>
    <div class="custom-control custom-radio">
        <input type="radio" id="negative" name="type" value="0" class="custom-control-input">
        <label class="custom-control-label" for="negative"><?= __('Negative') ?></label>
    </div>

    <div class="form-group mt-2">
        <label for="quantity"><?= __('Votes quantity') ?></label>
        <select name="points" id="quantity" class="form-control">
            <?php foreach ($data['options'] as $option): ?>
                <option value="<?= $option ?>"><?= $option ?></option>
            <?php endforeach; ?>
        </select>
    </div>

    <div class="form-group">
        <label for="text"><?= __('Comment') ?></label>
        <textarea id="text" rows="<?= $user->config->fieldHeight ?>" class="form-control" name="text"></textarea>
        <div class="small text-muted"><?= __('Min. 2, Max. 500 characters') ?></div>
    </div>


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