{% load seahub_tags i18n %}
<table>
    <tr>
        {% if is_pro %}
        <th width="24%">{% trans "Email" %} / {% trans "Name" %} / {% trans "Contact Email" %}</th>
        <th width="12%">{% trans "Status" %}</th>
        <th width="12%">{% trans "Role" %}</th>
        {% else %}
        <th width="36%">{% trans "Email" %} / {% trans "Name" %} / {% trans "Contact Email" %}</th>
        <th width="12%">{% trans "Status" %}</th>
        {% endif %}
        <th width="16%">{% trans "Space Used" %}</th>
        <th width="22%">{% trans "Create At / Last Login" %}</th>
        <th width="14%">{% trans "Operations" %}</th>
    </tr>

    {% for user in users %}
    <tr data-userid="{{user.email}}">
        <td>
            <a href="{% url 'user_info' user.email %}">{{ user.email }}</a>
            {% if user.name %}<br />{{ user.name }}{% endif %}
            {% if user.contact_email %}<br />{{ user.contact_email }}{% endif %}
            {% if not is_admin_page %}
            {% if user.org %}
            <p style="font-size:11px;"><a href="{% url 'sys_org_info_user' user.org.org_id %}">({{user.org.org_name}})</a></p>
            {% endif %}
            {% if user.trial_info %}
            <p style="font-size:11px;">(Trial &nbsp;<a href="#" class="unset-trial" data-target="{{ user.email }}" data-url="{% url 'remove_trial' user.email %}">X</a>)</p>
            {% endif %}
            {% endif %}
        </td>
        <td>
            <div class="user-status">
              {% if user.is_active %}
                <span class="user-status-cur-value">{% trans "Active" %}</span>
              {% else %}
                <span class="user-status-cur-value">{% trans "Inactive" %}</span>
              {% endif %}
                <span title="{% trans "Edit"%}" class="user-status-edit-icon sf2-icon-edit op-icon vh"></span>
            </div>
            <select name="permission" class="user-status-select hide">
                <option value="1" {%if user.is_active %}selected="selected"{% endif %}>{% trans "Active" %}</option>
                <option value="0" {%if not user.is_active %}selected="selected"{% endif %}>{% trans "Inactive"%}</option>
            </select>
        </td>
        {% if is_pro %}
        <td>
        {% if user.source == "DB" %}
            <div class="user-role">
                {% if user.is_guest %}
                    <span class="user-role-cur-value">{% trans "Guest" %}</span>
                {% elif user.is_default %}
                    <span class="user-role-cur-value">{% trans "Default" %}</span>
                {% else %}
                    <span class="user-role-cur-value">{{user.role}}</span>
                {% endif %}
                <span title="{% trans "Edit"%}" class="user-role-edit-icon sf2-icon-edit op-icon vh"></span>
            </div>
            <select name="role" class="user-role-select hide">
                <option value={{default_user}} {%if user.is_default %}selected="selected"{% endif %}>{% trans "Default" %}</option>
                <option value={{guest_user}} {%if user.is_guest %}selected="selected"{% endif %}>{% trans "Guest"%}</option>
                {% for role in extra_user_roles %}
                <option value={{role}} {%if user.role == role %}selected="selected"{% endif %}>{{ role }}</option>
                {% endfor %}
            </select>
        {% else %}
        --
        {% endif %}
        </td>
        {% endif %}

        <td style="font-size:11px;">
            <p> {{ user.space_usage|seahub_filesizeformat }} {% if user.space_quota > 0 %} / {{ user.space_quota|seahub_filesizeformat }} {% endif %} </p>
        </td>
        <td>
            {% if user.source == "DB" %}
            {{ user.ctime|tsstr_sec }} /<br />
            {% else %}
            -- /
            {% endif %}
            {% if user.last_login %}{{user.last_login|translate_seahub_time}} {% else %} -- {% endif %}
        </td>
        <td>
          {% if not user.is_self %}
          <a href="#" class="remove-user-btn op vh" data-url="{% url 'user_remove' user.email %}" data-target="{{ user.email }}">{% trans "Delete" %}</a>
          {% if user.source == "DB" %}
          <a href="#" class="reset-user-btn op vh" data-url="{% url 'user_reset' user.email %}" data-target="{{ user.email }}">{% trans "ResetPwd" %}</a>
          {% endif %}
          {% if is_admin_page %}
          <a href="#" data-url="{% url 'user_remove_admin' user.email %}" data-target="{{ user.email }}" class="revoke-admin-btn op vh">{% trans "Revoke Admin" %}</a>
          {% endif %}
          {% endif %}
        </td>
    </tr>
    {% endfor %}
</table>
