{% extends "dashboard/admin/admin-base.html.twig" %}

{% block page %}
    <div class="twofas-admin-account-wrapper">
        <div class="twofas-admin-configuration">
            <h2>{{ esc_html__('Admin Configuration', '2fas') }}</h2>

            <div class="twofas-admin-configuration-box">
                <div class="twofas-admin-configuration-box-header">
                    <h3>{{ esc_html__('Select which roles need to obligatorily use 2FA to log in:', '2fas') }}</h3>
                </div>

                <form action="{{ create_url(constant('TwoFAS\\TwoFAS\\Http\\Action_Index::SUBMENU_SETTINGS'), constant('TwoFAS\\TwoFAS\\Http\\Action_Index::ACTION_SAVE_ROLES')) }}"
                      method="post">
                    {{ create_form_nonce(constant('TwoFAS\\TwoFAS\\Http\\Action_Index::ACTION_SAVE_ROLES')) | raw }}

                    <p class="twofas-admin-configuration-box-desc">{{ esc_html__('Users with the selected roles will not be able to log in without 2FA.', '2fas') }}</p>

                    {% for role in roles %}
                        <div class="twofas-checkbox-input-box">
                            <input type="checkbox" id="{{ role.key }}" name="roles[]"
                                   value="{{ role.key }}" {% if role.obligatory %} checked="checked"{% endif %} />
                            <label for="{{ role.key }}">
                                <span class="twofas-checkbox-icon">
                                    <span class="twofas-checked">
                                        <i class="twofas-icon twofas-icon-tick"></i>
                                    </span>
                                </span>
                                <span class="twofas-checkbox-desc">{{ translate_user_role(role.name) }}</span>
                            </label>
                        </div>
                    {% endfor %}

                    <div class="twofas-admin-configuration-box-bottom">
                        <button class="twofas-btn twofas-action-btn">{{ esc_html__('Save', '2fas')|upper }}</button>
                    </div>
                </form>
            </div>

            <div class="twofas-admin-configuration-box">
                <div class="twofas-admin-configuration-box-header">
                    <h3>{{ esc_html__('Trusted devices', '2fas') }}</h3>
                </div>
                <form action="{{ create_url(constant('TwoFAS\\TwoFAS\\Http\\Action_Index::SUBMENU_SETTINGS'), constant('TwoFAS\\TwoFAS\\Http\\Action_Index::ACTION_SAVE_TRUSTED_DEVICES')) }}"
                      method="post">
                    {{ create_form_nonce(constant('TwoFAS\\TwoFAS\\Http\\Action_Index::ACTION_SAVE_TRUSTED_DEVICES')) | raw }}

                    <p class="twofas-admin-configuration-box-desc">{{ esc_html__('Allow remembering trusted devices.', '2fas') }}</p>

                    <div class="twofas-checkbox-input-box">
                        <input type="checkbox" id="trusted_devices" name="trusted_devices_enabled"
                               {% if trusted_devices_enabled %} checked="checked"{% endif %} />
                        <label for="trusted_devices">
                            <span class="twofas-checkbox-icon">
                                <span class="twofas-checked">
                                    <i class="twofas-icon twofas-icon-tick"></i>
                                </span>
                            </span>
                            <span>{{ esc_html__('Users can remember their device, they will not be asked for the code on trusted device.', '2fas') }}</span>
                        </label>
                    </div>

                    <div class="twofas-admin-configuration-box-bottom">
                        <button class="twofas-btn twofas-action-btn">{{ esc_html__('Save', '2fas')|upper }}</button>
                    </div>
                </form>
            </div>

            <div class="twofas-admin-configuration-box twofas-admin-configuration-box-last">
                <div class="twofas-admin-configuration-box-header">
                    <h3>{{ esc_html__('Enable logging for troubleshooting:', '2fas') }}</h3>
                </div>

                <form action="{{ create_url(constant('TwoFAS\\TwoFAS\\Http\\Action_Index::SUBMENU_SETTINGS'), constant('TwoFAS\\TwoFAS\\Http\\Action_Index::ACTION_SAVE_LOGGING')) }}"
                      method="post">
                    {{ create_form_nonce(constant('TwoFAS\\TwoFAS\\Http\\Action_Index::ACTION_SAVE_LOGGING')) | raw }}
                    <p class="twofas-admin-configuration-box-desc">
                        {{ esc_html__('For diagnostic purposes, 2FAS contains an option that turns on logging for certain features.
                    These logs can be helpful for support staff who is troubleshooting problems.', '2fas') }}
                    </p>

                    <div class="twofas-radio-input-box">
                        <input type="radio" id="logging-enabled" name="logging_enabled"
                               value="1" {% if true == is_logging_allowed %} checked="checked" {% endif %}/>
                        <label for="logging-enabled">
                        <span class="twofas-radio-icon">
                            <span class="twofas-checked">
                                <i class="twofas-icon twofas-icon-tick"></i>
                            </span>
                        </span>
                            <span class="twofas-radio-desc">
                            <span class="twofas-radio-desc-title">{{ esc_html__('Enabled', '2fas') }}</span>
                            <span>{{ esc_html__('I agree to send activity logs to 2FAS for diagnostic purposes and troubleshooting problems.', '2fas') }}</span>
                        </span>
                        </label>
                        <span class="twofas-clear-fix"></span>
                    </div>

                    <div class="twofas-radio-input-box">
                        <input type="radio" id="logging-disabled" name="logging_enabled"
                               value="0" {% if false == is_logging_allowed %} checked="checked" {% endif %}/>
                        <label for="logging-disabled">
                        <span class="twofas-radio-icon">
                            <span class="twofas-checked">
                                <i class="twofas-icon twofas-icon-tick"></i>
                            </span>
                        </span>
                            <span class="twofas-radio-desc">
                            <span class="twofas-radio-desc-title">{{ esc_html__('Disabled', '2fas') }}</span>
                            <span>{{ esc_html__("I don't want to send any activity logs to 2FAS.", '2fas')|raw }}</span>
                        </span>
                        </label>
                        <span class="twofas-clear-fix"></span>
                    </div>

                    <div class="twofas-admin-configuration-box-bottom">
                        <button class="twofas-btn twofas-action-btn">{{ esc_html__('Save', '2fas')|upper }}</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
{% endblock %}
