<?php $pageTitle = t('gdpr_settings_title'); ?>

<div class="page-header">
    <div class="page-header-left">
        <a href="/admin/plugins" class="btn btn-ghost btn-sm">← <?= t('plugins') ?></a>
        <h1 class="page-title"><?= t('gdpr_settings_title') ?></h1>
    </div>
</div>

<?php if ($success): ?><div class="alert alert-success"><?= Helper::e($success) ?></div><?php endif; ?>
<?php if ($error):   ?><div class="alert alert-error"><?= Helper::e($error) ?></div><?php endif; ?>
<?php if (!empty($errors)): ?>
<div class="alert alert-error"><?php foreach ($errors as $e): ?><div><?= Helper::e($e) ?></div><?php endforeach; ?></div>
<?php endif; ?>

<form method="POST">
    <?= Helper::csrf() ?>

    <div class="card">
        <div class="card-header"><h2 class="card-title"><?= t('gdpr_admin_section') ?></h2></div>
        <div class="card-body">
            <p class="form-hint" style="margin-top:0">
                <?= t('gdpr_admin_section_hint') ?>
            </p>
        </div>
    </div>

    <div class="card" style="margin-top:16px">
        <div class="card-header"><h2 class="card-title"><?= t('gdpr_self_export_section') ?></h2></div>
        <div class="card-body">
            <div class="form-group">
                <label class="checkbox-label">
                    <input type="checkbox" name="gdpr_user_self_export_enabled" value="1" <?= $cfg['self_enabled'] ? 'checked' : '' ?>>
                    <?= t('gdpr_self_export_enable') ?>
                </label>
                <p class="form-hint"><?= t('gdpr_self_export_enable_hint') ?></p>
            </div>
            <div class="form-group">
                <label class="form-label" for="gdpr_cooldown"><?= t('gdpr_cooldown_label') ?></label>
                <input type="number" min="1" max="8760" step="1" id="gdpr_cooldown"
                       name="gdpr_self_export_cooldown_hours" class="form-input"
                       value="<?= Helper::e((string)$cfg['cooldown_hours']) ?>" style="max-width:160px">
                <p class="form-hint"><?= t('gdpr_cooldown_hint') ?></p>
            </div>
        </div>
    </div>

    <div class="card" style="margin-top:16px">
        <div class="card-header"><h2 class="card-title"><?= t('gdpr_attachments_section') ?></h2></div>
        <div class="card-body">
            <div class="form-group">
                <label class="checkbox-label">
                    <input type="checkbox" name="gdpr_include_attachments" value="1" <?= $cfg['include_attachments'] ? 'checked' : '' ?>>
                    <?= t('gdpr_include_attachments_label') ?>
                </label>
                <p class="form-hint"><?= t('gdpr_include_attachments_hint') ?></p>
            </div>
        </div>
    </div>

    <div class="card" style="margin-top:16px">
        <div class="card-header"><h2 class="card-title"><?= t('gdpr_intro_section') ?></h2></div>
        <div class="card-body">
            <div class="form-group">
                <label class="form-label" for="gdpr_intro"><?= t('gdpr_intro_label') ?></label>
                <textarea id="gdpr_intro" name="gdpr_export_introduction_text" class="form-input"
                          rows="8" maxlength="4000"
                          placeholder="<?= Helper::e(t('gdpr_intro_placeholder')) ?>"><?= Helper::e($cfg['introduction_text']) ?></textarea>
                <p class="form-hint"><?= t('gdpr_intro_hint') ?></p>
            </div>
        </div>
    </div>

    <div style="margin-top:16px">
        <button type="submit" class="btn btn-primary"><?= t('save') ?></button>
    </div>
</form>
