{% import 'main/macros.tpl.html' as macro %}
<form name="edit_config" class="col-md-6 pl-0 pr-0" action="index.php?mod=config&action=save" id="edit_config" method="post">
    <!-- Nav tabs -->
    <ul class="nav nav-tabs" id="config_tab" role="tablist">
        <li class="nav-item">
            <a class="nav-link {{ general_active }}" id="config-general-tab" data-toggle="tab" href="#config-general"
                role="tab" aria-controls="config-general" aria-selected="{% if general_active %}true{% else %}false{% endif %}">{{
                label_general }}</a>
        </li>
        <li class="nav-item">
            <a class="nav-link {{ auth_active }}" id="config-auth-tab" data-toggle="tab" href="#config-auth" role="tab"
                aria-controls="config-auth" aria-selected="{% if auth_active %}true{% else %}false{% endif %}">{{
                    label_tab_auth }}</a>
        </li>
        <li class="nav-item">
            <a class="nav-link {{ email_active }}" id="config-email-tab" data-toggle="tab" href="#config-email" role="tab"
                aria-controls="config-email" aria-selected="{% if email_active %}true{% else %}false{% endif %}">{{
                label_tab_email }}</a>
        </li>
        <li class="nav-item">
            <a class="nav-link {{ sms_active }}" id="config-sms-tab" data-toggle="tab" href="#config-sms" role="tab"
                aria-controls="config-sms" aria-selected="{% if sms_active %}true{% else %}false{% endif %}">{{
                label_tab_sms }}</a>
        </li>
        <li class="nav-item">
            <a class="nav-link {{ pushover_active }}" id="config-pushover-tab" data-toggle="tab" href="#config-pushover"
                role="tab" aria-controls="config-pushover" aria-selected="{% if pushover_active %}true{% else %}false{% endif %}">{{
                label_tab_pushover }}</a>
        </li>
        <li class="nav-item">
            <a class="nav-link {{ telegram_active }}" id="config-telegram-tab" data-toggle="tab" href="#config-telegram"
                role="tab" aria-controls="config-telegram" aria-selected="{% if telegram_active %}true{% else %}false{% endif %}">{{
                label_tab_telegram }}</a>
        </li>
        <li class="nav-item">
            <a class="nav-link {{ jabber_active }}" id="config-jabber-tab" data-toggle="tab" href="#config-jabber"
               role="tab" aria-controls="config-jabber" aria-selected="{% if jabber_active %}true{% else %}false{% endif %}">{{
            label_tab_jabber }}</a>
        </li>
        <li class="nav-item">
            <a class="nav-link {{ discord_active }}" id="config-discord-tab" data-toggle="tab" href="#config-discord" role="tab"
                aria-controls="config-discord" aria-selected="{% if discord_active %}true{% else %}false{% endif %}">{{
                        label_tab_discord }}</a>
        </li>
        <li class="nav-item">
            <a class="nav-link {{ webhook_active }}" id="config-webhook-tab" data-toggle="tab" href="#config-webhook" role="tab"
                aria-controls="config-webhook" aria-selected="{% if webhook_active %}true{% else %}false{% endif %}">{{
                label_tab_webhook }}</a>
        </li>
    </ul>
    <!-- Tab panes -->
    <div class="tab-content">
        <div class="tab-pane {{ general_active }}" id="config-general" role="tabpanel" aria-labelledby="config-general-tab">
            <!-- General settings -->
            <fieldset>
                <legend>{{ label_general }}</legend>
                <!-- Update check -->
                {{ macro.input_checkbox("show_update", "show_update[]", label_show_update, show_update_checked) }}
                <!-- Site title -->
                {{ macro.input_field("text", "site_title", null, "site_title", label_site_title, site_title, label_site_title, "255", null, null, null, null, true) }}
                <!-- Language -->
                {{ macro.input_select("language", "language", label_language, languages, language_current) }}
                <!-- Auto refresh -->
                {{ macro.input_field("number", "auto_refresh_servers", null, "auto_refresh_servers", label_auto_refresh, auto_refresh_servers, "0", "10", "auto_refresh_description", null, label_seconds) }}
                <!-- Password encryption key -->
                <!-- TODO how does the encryption function works currently? -->
                {{ macro.input_field("text", "password_encrypt_key", null, "password_encrypt_key", label_password_encrypt_key, password_encrypt_key, "cab03a766...", "40", "password_encrypt_key_help", label_password_encrypt_key_note) }}
                <!-- Custom user agent -->
                {{ macro.input_field("text", "user_agent", null, "user_agent", label_user_agent, user_agent, "Mozilla/5.0...", "255", "user_agent_key_help", label_user_agent_key_note) }}
            </fieldset>
            <!-- Notification settings -->
            <fieldset>
                <legend>{{ label_settings_notification }}</legend>
                <!-- Combine notifications -->
                {{ macro.input_checkbox("combine_notifications", "combine_notifications[]", label_combine_notifications, combine_notifications_checked, "combine_notifications_help", label_combine_notifications_description) }}
                <!-- Alert type -->
                {{ macro.input_select("alert_type", "alert_type", label_alert_type, alert_type, alert_type_selected, "alert_type_help", label_alert_type_description) }}
            </fieldset>
            <!-- Log settings -->
            <fieldset>
                <legend>{{ label_settings_log }}</legend>
                <!-- log_enabled -->
                {{ macro.input_checkbox("log_status", "log_status[]", label_log_status, log_status_checked, "log_status_help", label_log_status_description ) }}
                <!-- log retention period -->
                {{ macro.input_field("text", "log_retention_period", null, "log_retention_period", label_log_retention_period, log_retention_period, "0", "3", "log_retention_period_help", null, label_days) }}
            </fieldset>
            <!-- Proxy settings -->
            <fieldset>
                <legend>{{ label_settings_proxy }}</legend>
                <!-- enable proxy -->
                {{ macro.input_checkbox("proxy", "proxy[]", label_proxy, proxy_checked, "proxy_help", label_alert_proxy ) }}
                <!-- proxy url -->
                {{ macro.input_field("text", "proxy_url", null, "proxy_url", label_proxy_url, proxy_url, label_proxy_url, null, "proxy_url_help", label_alert_proxy_url) }}
                <!-- proxy user -->
                {{ macro.input_field("text", "proxy_user", null, "proxy_user", label_proxy_user, proxy_user, label_proxy_user, null, null, null, null, true) }}
                <!-- proxy password -->
                {{ macro.input_field("password", "proxy_password", null, "proxy_password", label_proxy_password, proxy_password, label_proxy_password, null, null, null, null, true) }}
                {{ macro.button_save("general_submit",  label_save) }}
            </fieldset>
        </div>
        <div class="tab-pane {{ auth_active }}" id="config-auth" role="tabpanel" aria-labelledby="config-auth-tab">
            <!-- Auth settings -->
            <fieldset>
                <legend>{{ label_settings_dirauth }}</legend>
                <!-- enable ldap -->
                {{ macro.input_checkbox("dirauth_status", "dirauth_status[]", label_dirauth_status, dirauth_status_checked) }}
                <!-- Directory host -->
                {{ macro.input_field("text", "authdir_host_locn", null, "authdir_host_locn", label_authdir_host_locn, authdir_host_locn, label_authdir_host_locn, "100") }}
                <!-- smtp security -->
                {{ macro.input_select("authdir_type", "authdir_type", label_authdir_type, authdir_type, authdir_type_selected, "authdir_type_help", label_authdir_type_description) }}
                <!-- Directory port -->
                {{ macro.input_field("text", "authdir_host_port", null, "authdir_host_port", label_authdir_host_port, authdir_host_port, label_authdir_host_port, "10") }}
                <!-- Active Directory domain -->
                {{ macro.input_field("text", "authdir_userdomain", null, "authdir_userdomain", label_authdir_userdomain, authdir_userdomain, label_authdir_userdomain, "100", "authdir_userdomain_help", label_authdir_userdomain_description) }}
                <!-- LDAP protecol version -->
                {{ macro.input_field("text", "authdir_ldapver", null, "authdir_ldapver", label_authdir_ldapver, authdir_ldapver, label_authdir_ldapver, "100", "authdir_ldapver_help", label_authdir_ldapver_description) }}
                <!-- Follow referrals -->
                {{ macro.input_checkbox("authdir_ldapfollowref", "authdir_ldapfollowref[]", label_authdir_ldapfollowref, authdir_ldapfollowref_checked, "authdir_ldapfollowref_help", label_authdir_ldapfollowref_description) }}
                <!-- Base DN* -->
                {{ macro.input_field("text", "authdir_basedn", null, "authdir_basedn", label_authdir_basedn, authdir_basedn, "dc=domain,dc=tld", "100", "authdir_basedn_help", label_authdir_basedn_description) }}
                <!-- Username attribute -->
                {{ macro.input_field("text", "authdir_usernameattrib", null, "authdir_usernameattrib", label_authdir_usernameattrib, authdir_usernameattrib, label_authdir_usernameattrib, "100", "authdir_usernameattrib_help", label_authdir_usernameattrib_description) }}
                <!-- Group name attribute -->
                {{ macro.input_field("text", "authdir_groupnameattrib", null, "authdir_groupnameattrib", label_authdir_groupnameattrib, authdir_groupnameattrib, label_authdir_groupnameattrib, "100", "authdir_groupnameattrib_help", label_authdir_groupnameattrib_description) }}
                <!-- Group member attribute -->
                {{ macro.input_field("text", "authdir_groupmemattrib", null, "authdir_groupmemattrib", label_authdir_groupmemattrib, authdir_groupmemattrib, label_authdir_groupmemattrib, "100", "authdir_groupmemattrib_help", label_authdir_groupmemattrib_description) }}
                <!-- User container RDN -->
                {{ macro.input_field("text", "authdir_usercontainerrdn", null, "authdir_usercontainerrdn", label_authdir_usercontainerrdn, authdir_usercontainerrdn, "ou=Users", "100", "authdir_usercontainerrdn_help", label_authdir_usercontainerrdn_description) }}
                <!-- Group container RDN -->
                {{ macro.input_field("text", "authdir_groupcontainerrdn", null, "authdir_groupcontainerrdn", label_authdir_groupcontainerrdn, authdir_groupcontainerrdn, "ou=Groups", "100", "authdir_groupcontainerrdn_help", label_authdir_groupcontainerrdn_description) }}
                <!-- Authorised directory group -->
                {{ macro.input_field("text", "authdir_groupname", null, "authdir_groupname", label_authdir_groupname, authdir_groupname, label_authdir_groupname, "100", "authdir_groupname_help", label_authdir_groupname_description) }}
                <!-- Default role -->
                {{ macro.input_select("authdir_defaultrole", "authdir_defaultrole", label_authdir_defaultrole, authdir_defaultroles, authdir_defaultrole_selected, "authdir_defaultrole_help", label_authdir_defaultrole_description) }}
                {{ macro.button_save("auth_submit",  label_save) }}
            </fieldset>
        </div>
        <div class="tab-pane {{ email_active }}" id="config-email" role="tabpanel" aria-labelledby="config-email-tab">
            <fieldset>
                <legend>{{ label_settings_email }}</legend>
                <!-- enable email -->
                {{ macro.input_checkbox("email_status", "email_status[]", label_email_status, email_status_checked) }}
                <!-- enable email log -->
                {{ macro.input_checkbox("log_email", "log_email[]", label_log_email, log_email_checked) }}
                <!-- enable adding url to email -->
                {{ macro.input_checkbox("email_add_url", "email_add_url[]", label_email_add_url, email_add_url_checked) }}
                <!-- email name -->
                {{ macro.input_field("text", "email_from_name", null, "email_from_name", label_email_from_name, email_from_name, label_email_from_name, "255") }}
                <!-- email address -->
                {{ macro.input_field("email", "email_from_email", null, "email_from_email", label_email_from_email, email_from_email, label_email_from_email, "255") }}
            </fieldset>
            <fieldset>
                <legend>SMTP</legend>
                <!-- enable smtp -->
                {{ macro.input_checkbox("email_smtp", "email_smtp[]", label_email_smtp, email_smtp_checked) }}
                <!-- smtp host -->
                {{ macro.input_field("text", "email_smtp_host", null, "email_smtp_host", label_email_smtp_host, email_smtp_host, label_email_smtp_host, "255") }}
                <!-- smtp host -->
                {{ macro.input_field("number", "email_smtp_port", null, "email_smtp_port", label_email_smtp_port, email_smtp_port, label_email_smtp_port, "5") }}
                <!-- smtp security -->
                {{ macro.input_select("email_smtp_security", "email_smtp_security", label_email_smtp_security, email_smtp_security, email_smtp_security_selected) }}
                <!-- email user -->
                {{ macro.input_field("text", "email_smtp_username", null, "email_smtp_username", label_email_smtp_username, email_smtp_username, label_email_smtp_username, "255") }}
                <!-- email password -->
                {{ macro.input_field("password", "email_smtp_password", null, "email_smtp_password", label_email_smtp_password, email_smtp_password, label_leave_blank, "255", null, null, null, true) }}
                {{ macro.button_test("testEmail", label_test) }}
                {{ macro.input_hidden("test_email", "0") }}
                {{ macro.button_save("email_submit",  label_save) }}
            </fieldset>
        </div>
        <div class="tab-pane {{ sms_active }}" id="config-sms" role="tabpanel" aria-labelledby="config-sms-tab">
            <fieldset>
                <legend>{{ label_settings_sms }}</legend>
                <!-- enable sms -->
                {{ macro.input_checkbox("sms_status", "sms_status[]", label_sms_status, sms_status_checked) }}
                <!-- enable sms log -->
                {{ macro.input_checkbox("log_sms", "log_sms", label_log_sms, log_sms_checked) }}
                <!-- sms gateway -->
                {{ macro.input_select("sms_gateway", "sms_gateway", label_sms_gateway, sms_gateway, sms_gateway_selected) }}
                <!-- sms user -->
                {{ macro.input_field("text", "sms_gateway_username", null, "sms_gateway_username", label_sms_gateway_username, sms_gateway_username, label_sms_gateway_username, "255") }}
                <!-- sms password / API key-->
                {{ macro.input_field("text", "sms_gateway_password", null, "sms_gateway_password", label_sms_gateway_password, sms_gateway_password, label_sms_gateway_password, "255") }}
                <!-- sms sender number-->
                {{ macro.input_field("text", "sms_from", null, "sms_from", label_sms_from, sms_from, "+31123456789", "255") }}

                {{ macro.button_test("testSms", label_test) }}
                {{ macro.input_hidden("test_sms", "0") }}
                {{ macro.button_save("sms_submit", label_save) }}
            </fieldset>
        </div>
        <div class="tab-pane {{ discord_active }}" id="config-discord" role="tabpanel" aria-labelledby="config-discord-tab">
            <fieldset>
                <legend>{{ label_settings_discord }}</legend>
                <!-- enable discord -->
                {{ macro.input_checkbox("discord_status", "discord_status[]", label_discord_status, discord_status_checked) }}
                <!-- enable discord log -->
                {{ macro.input_checkbox("log_discord", "log_discord[]", label_log_discord, log_discord_checked) }}
                {{ macro.button_test("testDiscord", label_test) }}
                {{ macro.input_hidden("test_discord", "0") }}
                {{ macro.button_save("discord_submit", label_save) }}
            </fieldset>
        </div>
        <div class="tab-pane {{ pushover_active }}" id="config-pushover" role="tabpanel" aria-labelledby="config-pushover-tab">
            <fieldset>
                <legend>{{ label_settings_pushover }}</legend>
                <p>{{ label_pushover_description|raw }}</p>
                <!-- enable pushover -->
                {{ macro.input_checkbox("pushover_status", "pushover_status", label_pushover_status, pushover_status_checked) }}
                <!-- enable pushover log -->
                {{ macro.input_checkbox("log_pushover", "log_pushover", label_log_pushover, log_pushover_checked) }}
                <!-- pushover key -->
                {{ macro.input_field("text", "pushover_api_token", null, "pushover_api_token", label_pushover_api_token, pushover_api_token, label_pushover_api_token, "255", "pushover_api_token_help", label_pushover_api_token_description) }}
                {{ macro.button_test("testPushover", label_test) }}
                {{ macro.input_hidden("test_pushover", "0") }}
                {{ macro.button_save("pushover_submit",  label_save) }}
            </fieldset>
        </div>
        <div class="tab-pane {{ telegram_active }}" id="config-telegram" role="tabpanel" aria-labelledby="config-telegram-tab">
            <fieldset>
                <legend>{{ label_settings_telegram }}</legend>
                <p>{{ label_telegram_description|raw }}</p>
                <!-- enable telegram -->
                {{ macro.input_checkbox("telegram_status", "telegram_status[]", label_telegram_status, telegram_status_checked) }}
                <!-- enable telegram log -->
                {{ macro.input_checkbox("log_telegram", "log_telegram[]", label_log_telegram, log_telegram_checked) }}
                <!-- enable adding url to telegram -->
                {{ macro.input_checkbox("telegram_add_url", "telegram_add_url[]", label_telegram_add_url, telegram_add_url_checked) }}
                <!-- telegram key -->
                {{ macro.input_field("text", "telegram_api_token", null, "telegram_api_token", label_telegram_api_token, telegram_api_token, label_telegram_api_token, "255", "telegram_api_token_help", label_telegram_api_token_description) }}
                {{ macro.button_test("testTelegram", label_test) }}
                {{ macro.input_hidden("test_telegram", "0") }}
                {{ macro.button_save("telegram_submit",  label_save) }}
            </fieldset>
        </div>
        <div class="tab-pane {{ jabber_active }}" id="config-jabber" role="tabpanel" aria-labelledby="config-jabber-tab">
            <fieldset>
                <legend>{{ label_settings_jabber }}</legend>
                <!-- enable jabber -->
                {{ macro.input_checkbox("jabber_status", "jabber_status[]", label_jabber_status, jabber_status_checked) }}
                <!-- enable jabber log -->
                {{ macro.input_checkbox("log_jabber", "log_jabber[]", label_log_jabber, log_jabber_checked) }}
                <!-- jabber settings -->
                {{ macro.input_field("text", "jabber_host", null, "jabber_host", label_jabber_host, jabber_host, label_jabber_host, "255", "jabber_host_help", label_jabber_host_description) }}
                {{ macro.input_field("number", "jabber_port", null, "jabber_port", label_jabber_port, jabber_port, label_jabber_port, "255", "jabber_port_help", label_jabber_port_description) }}
                {{ macro.input_field("text", "jabber_username", null, "jabber_username", label_jabber_username, jabber_username, label_jabber_username, "255", 'jabber_username_help', label_jabber_username_description) }}
                {{ macro.input_field("text", "jabber_domain", null, "jabber_domain", label_jabber_domain, jabber_domain, label_jabber_domain, "255", "jabber_domain_help", label_jabber_domain_description) }}
                {{ macro.input_field("password", "jabber_password", null, "jabber_password", label_jabber_password, jabber_password, label_jabber_password, "255", "jabber_password_help", label_jabber_password_description) }}
                {{ macro.button_test("testJabber", label_test) }}
                {{ macro.input_hidden("test_jabber", "0") }}
                {{ macro.button_save("jabber_submit",  label_save) }}
            </fieldset>
        </div>
        <div class="tab-pane {{ webhook_active }}" id="config-webhook" role="tabpanel" aria-labelledby="config-webhook-tab">
            <fieldset>
                <legend>{{ label_settings_webhook }}</legend>
                <p>{{ label_webhook_description|raw }}</p>
                <!-- enable webhooks -->
                {{ macro.input_checkbox("webhook_status", "webhook_status", label_webhook_status, webhook_status_checked) }}
                <!-- enable webhook log -->
                {{ macro.input_checkbox("log_webhook", "log_webhook", label_log_webhook, log_webhook_checked) }}
                <!-- webhook url -->
                <!--  {{ macro.input_field("text", "webhook_url", null, "webhook_url", label_webhook_url, webhook_url, label_webhook_url, "255", "webhook_url_help", label_webhook_url_description) }} -->
                <!-- webhook json -->
                <!--   {{ macro.input_field("text", "webhook_json", null, "webhook_json", label_webhook_json, webhook_json, label_webhook_json, "255", "webhook_json_help", label_webhook_json_description) }} -->
        
                {{ macro.button_test("testWebhook", label_test) }}
                {{ macro.input_hidden("test_webhook", "0") }}
                {{ macro.button_save("webhook_submit",  label_save) }}
            </fieldset>
        </div>
    </div>
    {{ macro.input_csrf() }}
</form>
