[%# This Source Code Form is subject to the terms of the Mozilla Public
  # License, v. 2.0. If a copy of the MPL was not distributed with this
  # file, You can obtain one at http://mozilla.org/MPL/2.0/.
  #
  # This Source Code Form is "Incompatible With Secondary Licenses", as
  # defined by the Mozilla Public License, v. 2.0.
  #%]

[% PROCESS global/header.html.tmpl
  title = "Group Membership Report"
  generate_api_token = 1
  style_urls = [ "extensions/BMO/web/styles/reports.css" ]
  javascript_urls = [ "js/field.js" ]
%]

<form method="GET" action="[% basepath FILTER none %]page.cgi">
<input type="hidden" name="id" id="id" value="group_membership.html">

<table id="parameters">
<tr>
  <th>User(s):</th>
  <td>
    [% INCLUDE global/userselect.html.tmpl
       id      => "who"
       name    => "who"
       value   => who.join(', ')
       size    => 40
       classes => ["bz_userfield"]
       multiple => 5
       field_title  => "One or more email address (comma delimited)"
    %]
  </td>
  <td>&nbsp;</td>
  <td>
    <select name="output"
            onchange="document.getElementById('id').value = 'group_membership.' + this.value">
      <option value="html" [% 'selected' IF output == 'html' %]>HTML</option>
      <option value="txt" [% 'selected' IF output == 'txt' %]>Text</option>
    </select>
  </td>
  <td>
    <input type="submit" value="Generate">
  </td>
</tr>
</table>

</form>

[% IF users.size %]

  <table id="report" class="standard">
  <tbody>
  [% FOREACH u = users %]
    <tr>
      <th colspan="3">[% u.user.identity FILTER html %]</th>
    </tr>
    [% FOREACH g = u.groups %]
    <tr>
      <td>&nbsp;</td>
      <td>[% g.name FILTER html %]</td>
      <td>[% g.desc FILTER html %]</td>
      <td>
        [% IF g.via == '' %]
          direct
        [% ELSE %]
          <i>[% g.via FILTER html %]</i>
        [% END %]
      </td>
    </tr>
    [% END %]
  [% END %]
  </tbody>
  </table>

[% END %]

[% INCLUDE global/footer.html.tmpl %]
