<?php

/**
 * @var bool $confirmation
 * @var array $sysconf
 * @var array $themelist
 */
$this->layout('system::layout/default', ['title' => __('Admin Panel'), 'page_title' => __('System Settings')]);
$this->sectionReplace('sidebar-menu', $this->fetch('admin::sidebar-admin-menu', ['sys_menu' => ['settings' => true]]));
?>

<div style="max-width: 640px">
    <?php if ($confirmation): ?>
        <div class="alert alert-success shadow" role="alert">
            <?= __('Settings are saved successfully') ?>
        </div>
    <?php endif ?>

    <form method="post">
        <fieldset>
            <legend><?= __('Common Settings') ?></legend>
            <div class="form-group">
                <label for="homeurl"><?= __('Web site address without the slash at the end') ?></label>
                <input type="text" id="homeurl" name="homeurl" class="form-control" value="<?= $this->e($sysconf['homeurl']) ?>"/>
            </div>
            <div class="form-group">
                <label for="copyright"><?= __('Site copyright') ?></label>
                <input type="text" id="copyright" name="copyright" class="form-control" value="<?= $this->e($sysconf['copyright']) ?>"/>
            </div>
            <div class="form-group">
                <label for="madm"><?= __('Site Email') ?></label>
                <input type="text" id="madm" name="madm" maxlength="50" class="form-control" value="<?= $this->e($sysconf['email']) ?>"/>
            </div>
            <div class="form-group">
                <label for="flsz"><?= __('Max. file size') ?> (kb)</label>
                <input type="text" id="flsz" name="flsz" class="form-control  col-sm-2" value="<?= (int) ($sysconf['flsz']) ?>"/>
            </div>
            <div class="custom-control custom-checkbox">
                <input type="checkbox" class="custom-control-input" name="gz" value="1" id="gz" <?= ($sysconf['gzip'] ? 'checked="checked"' : '') ?>>
                <label class="custom-control-label" for="gz"><?= __('Gzip compression') ?></label>
            </div>
            <div class="custom-control custom-checkbox">
                <input type="checkbox" class="custom-control-input" name="user_email_required" value="1"
                       id="user_email_required" <?= ($sysconf['user_email_required'] ? 'checked="checked"' : '') ?>>
                <label class="custom-control-label" for="user_email_required"><?= __('E-mail is required for registration') ?></label>
            </div>
            <div class="custom-control custom-checkbox">
                <input type="checkbox" class="custom-control-input" name="user_email_confirmation" value="1" id="user_email_confirmation" <?= ($sysconf['user_email_confirmation'] ? 'checked="checked"' : '') ?>>
                <label class="custom-control-label" for="user_email_confirmation"><?= __('Request a confirmation email to activate the user\'s account.') ?></label>
            </div>
        </fieldset>
        <fieldset class="mt-3">
            <legend><?= __('Time shift') ?></legend>
            <div class="form-group">
                <label for="timeshift">+ - 12 Hour</label>
                <input type="text" id="timeshift" name="timeshift" class="form-control  col-sm-2" value="<?= (int) ($sysconf['timeshift']) ?>"/>
            </div>
            <div class="form-group">
                <span style="font-weight:bold; background-color:#C0FFC0"> <?= date('H:i', time() + $sysconf['timeshift'] * 3600) ?> </span>&nbsp;<?= __('System Time') ?><br>
                <span style="font-weight:bold; background-color:#FFC0C0"> <?= date('H:i') ?> </span>&nbsp;UTC
            </div>
        </fieldset>
        <fieldset class="mt-3">
            <legend><?= __('META tags') ?></legend>
            <div class="form-group">
                <label for="meta_title"><?= __('Title') ?></label>
                <textarea rows="2" id="meta_title" name="meta_title" class="form-control"><?= $this->e($sysconf['meta_title'] ?? '') ?></textarea>
            </div>
            <div class="form-group">
                <label for="meta_key"><?= __('Keywords') ?></label>
                <textarea rows="3" id="meta_key" name="meta_key" class="form-control"><?= $this->e($sysconf['meta_key']) ?></textarea>
            </div>
            <div class="form-group">
                <label for="meta_desc"><?= __('Description') ?></label>
                <textarea rows="3" id="meta_desc" name="meta_desc" class="form-control"><?= $this->e($sysconf['meta_desc']) ?></textarea>
            </div>
        </fieldset>
        <fieldset class="mt-3">
            <legend><?= __('Themes') ?></legend>
            <select id="skindef" name="skindef" class="form-control">
                <?php foreach ($themelist as $theme): ?>
                    <option <?= ($sysconf['skindef'] == $theme ? ' selected="selected"' : '') ?>><?= $theme ?></option>
                <?php endforeach ?>
            </select>
        </fieldset>
        <input type="submit" class="btn btn-primary btn-lg mt-4 mb-2" name="submit" value="<?= __('Save') ?>"/>
    </form>
</div>
