{% load seahub_tags i18n %}
<table>
    <tr>
        {% if is_pro %}
        <th width="24%">{% trans "Email" %}</th>
        <th width="12%">{% trans "Status" %}</th>
        <th width="12%">{% trans "Role" %}</th>
        {% else %}
        <th width="36%">{% trans "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 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 %}
                <img src="{{MEDIA_URL}}img/edit_12.png" alt="{% trans "Edit"%}" title="{% trans "Edit"%}" class="user-status-edit-icon cspt vh" />
            </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>
                {% else %}
                    <span class="user-role-cur-value">{% trans "Default" %}</span>
                {% endif %}
                <img src="{{MEDIA_URL}}img/edit_12.png" alt="{% trans "Edit"%}" title="{% trans "Edit"%}" class="user-role-edit-icon cspt vh" />
            </div>
            <select name="role" class="user-role-select hide">
                <option value={{default_user}} {%if not user.is_guest %}selected="selected"{% endif %}>{% trans "Default" %}</option>
                <option value={{guest_user}} {%if user.is_guest %}selected="selected"{% endif %}>{% trans "Guest"%}</option>
            </select>
        {% else %}
        --
        {% endif %}
        </td>
        {% endif %}

        <td style="font-size:11px;">
            <p> {{ user.space_usage|filesizeformat }} {% if user.space_quota > 0 %} / {{ user.space_quota|filesizeformat }} {% endif %} </p>
            {% if not user.org %}
            {% if CALC_SHARE_USAGE %}
            <p> {{ user.share_usage|filesizeformat }} {% if user.share_quota > 0 %} / {{ user.share_quota|filesizeformat }} {% endif %} </p>
            {% endif %}
            {% endif %}
        </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>
