{% extends "sysadmin/base.html" %}
{% load seahub_tags i18n %}
{% block cur_users %}tab-cur{% endblock %}
{% block extra_style %}
{% endblock %}

{% block left_panel %}{{block.super}}
<form action="{% url 'user_search' %}" method="get" class="side-search-form">
    <input type="text" name="email" class="input" value="" placeholder="{% trans "Search users..." %}" />
</form>
{% endblock %}

{% block right_panel %}
<div class="tabnav ovhd">
    <ul class="tabnav-tabs fleft">
        <li class="tabnav-tab"><a href="{% url 'sys_useradmin' %}">{% trans "Database" %}</a></li>
        <li class="tabnav-tab"><a href="{% url 'sys_useradmin_ldap' %}">{% trans "LDAP" %}</a></li>
        <li class="tabnav-tab tabnav-tab-cur"><a href="{% url 'sys_useradmin_ldap_imported' %}">{% trans "LDAP(imported)" %}</a></li>
        {% if is_default_admin %}
        <li class="tabnav-tab"><a href="{% url 'sys_useradmin_admins' %}">{% trans "Admins" %}</a></li>
        {% endif %}
    </ul>

    <div class="js-op-for-all fright">
        <button id="export-excel">{% trans "Export Excel" %}</button>
    </div>
    <div class="js-op-for-selected fright hide">
        <button id="set-quota-btn">{% trans "Set quota" %}</button>
        {% if show_institution %}
        <button id="set-institution-btn">{% trans "Set institution" %}</button>
        {% endif %}
        <button id="delete-users-btn">{% trans "Delete users" %}</button>
    </div>
</div>

{% if users %}
{% with is_admin_page=False %}
{% include "sysadmin/useradmin_table.html" %}
{% endwith %}
{% include "snippets/admin_paginator.html" %}
{% else %}
<div class="empty-tips">
    <h2 class="alc">{% trans "No LDAP users have been imported" %}</h2>
</div>
{% endif %}

<div id="activate-msg" class="hide">
    <p>{% trans "Activating..., please wait" %}</p>
</div>

{% if show_institution %}
<form class="hide" id="batch-set-institution-form" method="" action="">
    <h3>{% trans "Set institution" %}</h3>
    <select name="institution" class="w100">
        <option value=""></option>
        {% for inst in institutions %}
            <option value="{{inst}}">{{inst}}</option>
        {% endfor %}
    </select>
    <p class="error hide"></p>
    <button type="submit" class="submit">{% trans "Submit" %}</button>
</form>
{% endif %}

{% endblock %}

{% block extra_script %}
<script type="text/javascript">
$("#export-excel").on('click', function() {
    location.href = "{% url 'sys_useradmin_export_excel' %}";
});
{% include "sysadmin/useradmin_js.html" %}
</script>
{% endblock %}
