<?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,
    ]
);
$this->sectionReplace('sidebar-menu', $this->fetch('admin::sidebar-admin-menu', ['module_menu' => ['ads' => true]]));
?>

<?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">
    <div class="form-group">
        <label for="link"><?= __('Link') ?></label>
        <input type="text" name="link" class="form-control" id="link" placeholder="<?= __('Link') ?>" value="<?= $data['fields']['link'] ?>">
    </div>
    <div class="custom-control custom-checkbox">
        <input type="checkbox" class="custom-control-input" name="show" value="1" id="show" <?= ! empty($data['fields']['show']) ? 'checked="checked"' : '' ?>>
        <label class="custom-control-label" for="show"><?= __('Direct Link') ?></label>
        <div class="text-muted small"><?= __('Click statistics won\'t be counted, If the direct link is turned on') ?></div>
    </div>
    <div class="form-group mt-2">
        <label for="name"><?= __('Title') ?></label>
        <input type="text" name="name" class="form-control" id="name" placeholder="<?= __('Title') ?>" value="<?= $data['fields']['name'] ?>">
        <div class="text-muted small"><?= __('To change the name when updating pages, you must wtite names trought the symbol |') ?></div>
    </div>
    <div class="form-group">
        <label for="color"><?= __('Color') ?></label>
        <input type="text" name="color" class="form-control" id="color" placeholder="<?= __('Color') ?>" value="<?= $data['fields']['color'] ?>">
        <div class="text-muted small"><?= __('In the format FFFFFF, if you do not want to use link color, simply do not fill this field') ?></div>
    </div>
    <div class="form-group">
        <label for="count"><?= __('Hits') ?></label>
        <input type="text" name="count" class="form-control" id="count" placeholder="<?= __('Hits') ?>" value="<?= $data['fields']['count_link'] ?>">
        <div class="text-muted small"><?= __('Number of hits for link existence which will be automatically removed from the page<br>0 - Unlimited') ?></div>
    </div>
    <div class="form-group">
        <label for="day"><?= __('Days') ?></label>
        <input type="text" name="day" class="form-control" id="day" placeholder="<?= __('Days') ?>" value="<?= $data['fields']['day'] ?>">
        <div class="text-muted small"><?= __('Number of days for link existence which will be automatically removed from the page<br>0 - Unlimited') ?></div>
    </div>
    <h3><?= __('Show') ?></h3>
    <div class="custom-control custom-radio">
        <input type="radio" id="view1" name="view" value="0" class="custom-control-input" <?= empty($data['fields']['view']) ? 'checked="checked"' : '' ?>>
        <label class="custom-control-label" for="view1"><?= __('Everyone') ?></label>
    </div>
    <div class="custom-control custom-radio">
        <input type="radio" id="view2" name="view" value="1" class="custom-control-input" <?= $data['fields']['view'] === 1 ? 'checked="checked"' : '' ?>>
        <label class="custom-control-label" for="view2"><?= __('Guests') ?></label>
    </div>
    <div class="custom-control custom-radio">
        <input type="radio" id="view3" name="view" value="2" class="custom-control-input" <?= $data['fields']['view'] === 2 ? 'checked="checked"' : '' ?>>
        <label class="custom-control-label" for="view3"><?= __('Users') ?></label>
    </div>
    <h3 class="mt-3"><?= __('Place') ?></h3>
    <div class="custom-control custom-radio">
        <input type="radio" id="type1" name="type" value="0" class="custom-control-input" <?= $data['fields']['type'] === 0 ? 'checked="checked"' : '' ?>>
        <label class="custom-control-label" for="type1"><?= __('Before the menu') ?></label>
    </div>
    <div class="custom-control custom-radio">
        <input type="radio" id="type2" name="type" value="1" class="custom-control-input" <?= $data['fields']['type'] === 1 ? 'checked="checked"' : '' ?>>
        <label class="custom-control-label" for="type2"><?= __('After the menu') ?></label>
    </div>
    <div class="custom-control custom-radio">
        <input type="radio" id="type3" name="type" value="2" class="custom-control-input" <?= $data['fields']['type'] === 2 ? 'checked="checked"' : '' ?>>
        <label class="custom-control-label" for="type3"><?= __('At the top of the page') ?></label>
    </div>
    <div class="custom-control custom-radio">
        <input type="radio" id="type4" name="type" value="3" class="custom-control-input" <?= $data['fields']['type'] === 3 ? 'checked="checked"' : '' ?>>
        <label class="custom-control-label" for="type4"><?= __('At the bottom of the page') ?></label>
    </div>
    <h3 class="mt-3"><?= __('Layout') ?></h3>
    <div class="custom-control custom-radio">
        <input type="radio" id="layout1" name="layout" value="0" class="custom-control-input" <?= empty($data['fields']['layout']) ? 'checked="checked"' : '' ?>>
        <label class="custom-control-label" for="layout1"><?= __('All pages') ?></label>
    </div>
    <div class="custom-control custom-radio">
        <input type="radio" id="layout2" name="layout" value="1" class="custom-control-input" <?= $data['fields']['layout'] === 1 ? 'checked="checked"' : '' ?>>
        <label class="custom-control-label" for="layout2"><?= __('Only on Homepage') ?></label>
    </div>
    <div class="custom-control custom-radio">
        <input type="radio" id="layout3" name="layout" value="2" class="custom-control-input" <?= $data['fields']['layout'] === 2 ? 'checked="checked"' : '' ?>>
        <label class="custom-control-label" for="layout3"><?= __('On all, except Homepage') ?></label>
    </div>
    <h3 class="mt-3"><?= __('Styling links') ?></h3>
    <div class="custom-control custom-checkbox">
        <input type="checkbox" class="custom-control-input" name="bold" value="1" id="bold" <?= ! empty($data['fields']['bold']) ? 'checked="checked"' : '' ?>>
        <label class="custom-control-label" for="bold"><?= __('Bold') ?></label>
    </div>
    <div class="custom-control custom-checkbox">
        <input type="checkbox" class="custom-control-input" name="italic" value="1" id="italic" <?= ! empty($data['fields']['italic']) ? 'checked="checked"' : '' ?>>
        <label class="custom-control-label" for="italic"><?= __('Italic') ?></label>
    </div>
    <div class="custom-control custom-checkbox">
        <input type="checkbox" class="custom-control-input" name="underline" value="1" id="underline" <?= ! empty($data['fields']['underline']) ? 'checked="checked"' : '' ?>>
        <label class="custom-control-label" for="underline"><?= __('Underline') ?></label>
    </div>
    <div class="mt-3">
        <input type="submit" name="submit" value="<?= __('Save') ?>" class="btn btn-primary"/>
        <a href="/admin/ads/" class="btn btn-secondary"><?= __('Cancel') ?></a>
    </div>
</form>
