<div class="">
  <div class="wrapper-admin-backend">
    <div class="container-fluid">
      <div class="settings-title m-3">
        <h1><i class="fas fa-cog"></i> {{title}} - Einstellungen</h1>
      </div>
      <div class="row tspv2settings">
        <!-- Card Seitenzuteilung -->
        {% include 'admin-backend-settings/admin-backend-settings-pages.html' %}
        <!-- Card Darstellung -->
        {% include 'admin-backend-settings/admin-backend-settings-display.html' %}
        <!--Card Profil -->
        {% include 'admin-backend-settings/admin-backend-settings-profile.html' %}
        <!-- Card Dashboard -->
        {% include 'admin-backend-settings/admin-backend-settings-dashboard.html' %}
        <!-- Card Coaching-Übersicht -->
        {% include 'admin-backend-settings/admin-backend-settings-coaching-overview.html' %}
        <!-- Card Register -->
        {% include 'admin-backend-settings/admin-backend-settings-register.html' %}
        <!-- Card E-Mail -->
        {% include 'admin-backend-settings/admin-backend-settings-mail.html' %}
        <!-- Card Sonstiges -->
        {% include 'admin-backend-settings/admin-backend-settings-misc.html' %}
        <!-- Card LimeSurvey -->
        {% include 'admin-backend-settings/admin-backend-settings-limesurvey.html' %}
        <!-- Card Mailbox Notifications -->
        {% include 'admin-backend-settings/admin-backend-settings-notification.html' %}
        <!-- Card Advanced -->
        {% include 'admin-backend-settings/admin-backend-settings-advanced.html' %}
      </div>
      <div class="row">
        <div class="col-12">
          <button class="btn btn-primary ml-3 mt-5" type="button" id="settingsSave">Speichern</button>
          <div class="alert alert-danger mx-3 mt-3 mb-0 d-none" id="settingsNotAllowedAlert" role="alert">
            <h5><i class="fas fa-times-circle"></i>&nbsp;Fehler</h5>
            <p>
                Sie haben keine Berechtigung die Einstellungen zu speichern!
            </p>
          </div>
        </div>
      </div>
      <hr class="my-5">
      <div class="row">
        {% include 'admin-backend-settings/admin-backend-settings-user-events.html' %}
      </div>
      <hr class="my-5">
      <div class="row mb-4">
        <!-- Card Default Pages -->
        {% include 'admin-backend-settings/admin-backend-settings-defaultpages.html' %}
        <!-- Card Demotraining -->
        {% include 'admin-backend-settings/admin-backend-settings-demotraining.html' %}
      </div>
    </div>
  </div>
</div>

<style>
  .tooltip-inner {
    width: 200px;
    padding: 5px;
    border-radius: 5px;
    color: #FFFFFF;
    background-color: #000000
  }
</style>

<script>
  jQuery("#checkAll").click(function () {
    jQuery('.standard_pages input:checkbox').not(this).prop('checked', this.checked);
  });

  jQuery(document).on('change', '#user_menu_select', function (e) {
    if (jQuery('#user_menu_select').val() == 0) {
      jQuery('.defaultmenu-item').addClass('d-none');
    } else {
      jQuery('.defaultmenu-item').removeClass('d-none');
    }
  })
  jQuery('.register_code_dropdown').on('change', function () {
    if (jQuery(this).val() != "") {
      jQuery('.set_register_link').prop("disabled", false);
      var regcodeCount = jQuery(this).find("option:selected").attr("registercodecount");
      var regcodeMaxCount = jQuery(this).find("option:selected").attr("registercodemax");
      jQuery(this).parent().find("span").removeClass("d-none");
      if (regcodeMaxCount == "unbegrenzt" || parseInt(regcodeCount) < parseInt(regcodeMaxCount)) {
        jQuery(this).parent().find("span").text("(" + regcodeCount + "/" + regcodeMaxCount + ") Einlösungen");
      }
      else {
        jQuery(this).parent().find("span").html("(" + regcodeCount + "/" + regcodeMaxCount + ") Einlösungen <i class='fas fa-exclamation-triangle'></i>");
      }

    } else {
      jQuery(this).parent().find("span").text("");
      jQuery(this).parent().find("span").addClass("d-none");
      if(!jQuery('.set_redeem_code_manually').is(':checked')){
        jQuery('.set_register_link').prop("disabled", true);
        jQuery('.set_register_link').prop("checked", false);
      }
    }
  });

  jQuery('.set_redeem_code_manually').on('change', function(){

    if(jQuery(this).is(':checked')){
      jQuery('.set_register_link').prop("disabled", false);
    }
    else{
      if(jQuery('.register_code_dropdown').val() == ""){
        jQuery('.set_register_link').prop("disabled", true);
        jQuery('.set_register_link').prop("checked", false);
      }
    }
  });

</script>