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


<div class="buttons mb-3">
    <?php foreach ($data['buttons'] as $button): ?>
        <a href="<?= $button['url'] ?>" class="btn btn-outline-primary <?= $button['active'] ? 'active' : '' ?>"><?= $button['name'] ?></a>
    <?php endforeach; ?>
</div>

<?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><?= __('Who can write you?') ?></h3>

    <div class="custom-control custom-radio">
        <input type="radio" id="access1" name="access" value="0" class="custom-control-input" <?= (! $data['set_mail_user']['access'] ? 'checked="checked"' : '') ?>>
        <label class="custom-control-label" for="access1"><?= __('All can write') ?></label>
    </div>
    <div class="custom-control custom-radio">
        <input type="radio" id="access2" name="access" value="1" class="custom-control-input" <?= ($data['set_mail_user']['access'] === 1 ? 'checked="checked"' : '') ?>>
        <label class="custom-control-label" for="access2"><?= __('Only my contacts') ?></label>
    </div>

    <div class="mt-3">
        <input type="submit" name="submit" value="<?= __('Save') ?>" class="btn btn-primary"/>
        <a href="?act=office" class="btn btn-secondary"><?= __('Cancel') ?></a>
    </div>
</form>
