<form name="usersForm" id="usersForm" action="{{ url('/server/privileges') }}" method="post">
  {{ get_hidden_inputs() }}
  <div class="responsivetable row">
    <table id="tableuserrights" class="data">
      <thead>
        <tr>
          <th></th>
          <th>{% trans 'User name' %}</th>
          <th>{% trans 'Host name' %}</th>
          <th>{% trans 'Password' %}</th>
          <th>
            {% trans 'Global privileges' %}
            {{ show_hint('Note: MySQL privilege names are expressed in English.') }}
          </th>
          {% if menus_work %}
            <th>{% trans 'User group' %}</th>
          {% endif %}
          <th>{% trans 'Grant' %}</th>
          <th colspan="{{ user_group_count > 0 ? '3' : '2' }}">{% trans 'Action' %}</th>
        </tr>
      </thead>

      <tbody>
        {% for host in hosts %}
          <tr>
            <td>
              <input type="checkbox" class="checkall" id="checkbox_sel_users_{{ loop.index }}" value="
                {{- host.user ~ '&amp;#27;' ~ host.host }}" name="selected_usr[]">
            </td>
            <td>
              <label for="checkbox_sel_users_{{ loop.index }}">
                {% if host.user is empty %}
                  <span class="text-danger">{% trans 'Any' %}</span>
                {% else %}
                  {{ host.user }}
                {% endif %}
              </label>
            </td>
            <td>{{ host.host }}</td>
            <td>
              {% if host.has_password %}
                {% trans 'Yes' %}
              {% else %}
                <span class="text-danger">{% trans 'No' %}</span>
              {% endif %}
              {{ not host.has_select_priv ? show_hint('The selected user was not found in the privilege table.'|trans) }}
            </td>
            <td>
              <code>{{ host.privileges|join(', ')|raw }}</code>
            </td>
            {% if menus_work %}
              <td class="usrGroup">{{ host.group }}</td>
            {% endif %}
            <td>{{ host.has_grant ? 'Yes'|trans : 'No'|trans }}</td>
            {% if is_grantuser %}
              <td class="center">
                <a class="edit_user_anchor" href="{{ url('/server/privileges', {
                  'username': host.user,
                  'hostname': host.host,
                  'dbname': '',
                  'tablename': '',
                  'routinename': '',
                }) }}">
                  {{ get_icon('b_usredit', 'Edit privileges'|trans) }}
                </a>
              </td>
            {% endif %}
            {% if menus_work and user_group_count > 0 %}
              <td class="center">
                {% if host.user is not empty %}
                  <a class="edit_user_group_anchor ajax" href="{{ url('/server/privileges', {'username': host.user}) }}">
                    {{ get_icon('b_usrlist', 'Edit user group'|trans) }}
                  </a>
                {% endif %}
              </td>
            {% endif %}
            <td class="center">
              <a class="export_user_anchor ajax" href="{{ url('/server/privileges', {
                'username': host.user,
                'hostname': host.host,
                'initial': initial,
                'export': true,
              }) }}">
                {{ get_icon('b_tblexport', 'Export'|trans) }}
              </a>
            </td>
          </tr>
        {% endfor %}
      </tbody>
    </table>
  </div>

  <div class="floatleft row">
    <img class="selectallarrow" width="38" height="22" src="
      {{- pma_theme_image }}arrow_{{ text_dir }}.png" alt="{% trans 'With selected:' %}">
    <input type="checkbox" id="usersForm_checkall" class="checkall_box" title="{% trans 'Check all' %}">
    <label for="usersForm_checkall">{% trans 'Check all' %}</label>
    <em class="with-selected">{% trans 'With selected:' %}</em>

    {{ get_button_or_image('submit_mult', 'mult_submit', 'Export'|trans, 'b_tblexport', 'export') }}

    <input type="hidden" name="initial" value="{{ initial }}">
  </div>

  <div class="clearfloat"></div>

  {% if is_createuser %}
    <div class="row">
      <div class="col-12">
        <fieldset id="fieldset_add_user">
          <legend>{% trans %}New{% context %}Create new user{% endtrans %}</legend>
          <a id="add_user_anchor" href="{{ url('/server/privileges', {'adduser': true}) }}">
            {{ get_icon('b_usradd', 'Add user account'|trans) }}
          </a>
        </fieldset>
      </div>
    </div>
  {% endif %}

  <div class="row">
    <div class="col-12">
      <fieldset id="fieldset_delete_user">
        <legend>
          {{ get_icon('b_usrdrop') }}{% trans 'Remove selected user accounts' %}
        </legend>
        <input type="hidden" name="mode" value="2">

        <p>({% trans 'Revoke all active privileges from the users and delete them afterwards.' %})</p>

        <input type="checkbox" name="drop_users_db" id="checkbox_drop_users_db" title="
          {%- trans 'Drop the databases that have the same names as the users.' %}">
        <label for="checkbox_drop_users_db" title="
          {%- trans 'Drop the databases that have the same names as the users.' %}">
          {% trans 'Drop the databases that have the same names as the users.' %}
        </label>
      </fieldset>
    </div>
  </div>

  <fieldset id="fieldset_delete_user_footer" class="tblFooters">
    <input id="buttonGo" class="btn btn-primary ajax" type="submit" name="delete" value="{% trans 'Go' %}">
  </fieldset>
</form>
