[% cgi = Bugzilla.cgi %]

[% PROCESS global/header.html.tmpl title='Verify Field Values' %]

<form action="process_bug.cgi" method="post">

[% PROCESS "global/hidden-fields.html.tmpl" exclude=exclude_params_re %]

[% IF incorrect_fields.size > 0 %]
<h3>Verify [% incorrect_field_descs.join(', ') %]</h3>

[% FOR f = incorrect_fields %]
<p>
  Value[% 's' IF f.values.size > 1 %] <b>"[% f.value_names.join('", "') | html %]"</b>
  of the field <b>"[% f.field.description | html %]"</b> [% f.values.size > 1 ? 'are' : 'is' %]
  incorrect for the value <b>"[% f.controller.name | html %]"</b> of controlling field
  <b>"[% f.field.value_field.description | html %]"</b>.
</p>
[% END %]

<p>Please set the correct values for these fields now:</p>

<table>
  <tr>
    [% FOR f = incorrect_fields %]
    <td>
      <b>[% f.field.description | html %]:</b><br />
      [% html_select(f.field.name, f.options.0, f.options, '', { size => 10, multiple => (f.field.type == constants.FIELD_TYPE_MULTI_SELECT) }) %]
    </td>
    [% END %]
  </tr>
</table>
[% END %]

[% IF verify_bug_groups %]
  <h3>Verify [% terms.Bug %] Group</h3>
  <input type="hidden" name="verify_bug_groups" value="1" />

  [% IF old_groups.size %]
    <p>These groups are not legal for the '[% product.name FILTER html %]'
    product or you are not allowed to restrict [% terms.bugs %] to these groups.
    [%+ terms.Bugs %] will no longer be restricted to these groups and may become
    public if no other group applies:<br />
    [% FOREACH group = old_groups %]
      <input type="checkbox" id="bit-[% group.id FILTER html %]"
             name="bit-[% group.id FILTER html %]" disabled="disabled" value="1" />
      <label for="bit-[% group.id FILTER html %]">
        [% group.name FILTER html %]: [% group.description FILTER html %]
      </label>
      <br />
    [% END %]
    </p>
  [% END %]

  [% mandatory_groups = [] %]
  [% optional_groups = [] %]

  [% FOREACH gid = product.group_controls.keys %]
    [% group = product.group_controls.$gid %]
    [% NEXT UNLESS group.group.is_active %]

    [% IF group.membercontrol == constants.CONTROLMAPMANDATORY
          || (group.othercontrol ==  constants.CONTROLMAPMANDATORY && !user.in_group(group.group.name)) %]
      [% mandatory_groups.push(group) %]
    [% ELSIF (group.membercontrol != constants.CONTROLMAPNA && user.in_group(group.group.name))
              || group.othercontrol != constants.CONTROLMAPNA %]
      [% optional_groups.push(group) %]
    [% END %]
  [% END %]

  [% IF optional_groups.size %]
    <p>These groups are optional. You can decide to restrict [% terms.bugs %] to
    one or more of the following groups:<br />
    [% FOREACH group = optional_groups %]
      <input type="hidden" name="defined_bit-[% group.group.id FILTER html %]"
             value="1" />
      <input type="checkbox" id="bit-[% group.group.id FILTER html %]"
             name="bit-[% group.group.id FILTER html %]"
             [%+ ((group.membercontrol == constants.CONTROLMAPDEFAULT && user.in_group(group.group.name))
                 || (group.othercontrol == constants.CONTROLMAPDEFAULT && !user.in_group(group.group.name))
                 || cgi.param("bit-$group.group.id") == 1) ?
                 'checked="checked"' : ''
             %] value="1" />
      <label for="bit-[% group.group.id FILTER html %]">
        [% group.group.name FILTER html %]: [% group.group.description FILTER html %]
      </label>
      <br />
    [% END %]
    </p>
  [% END %]

  [% IF mandatory_groups.size %]
    <p>These groups are mandatory and [% terms.bugs %] will be automatically
    restricted to these groups:<br />
    [% FOREACH group = mandatory_groups %]
      <input type="checkbox" id="bit-[% group.group.id FILTER html %]" checked="checked"
             name="bit-[% group.group.id FILTER html %]" value="1" disabled="disabled" />
      <label for="bit-[% group.group.id FILTER html %]">
        [% group.group.name FILTER html %]: [% group.group.description FILTER html %]
      </label>
      <br />
    [% END %]
    </p>
  [% END %]
[% END %]

<input type="submit" id="change_product" value="Commit" />

</form>
<hr />

[%# If 'id' is defined, then we are editing a single bug.
  # Else we are editing several bugs at once. %]

[% IF cgi.param('id') AND cgi.param('id').match('^\d+$') %]
  [% id = cgi.param('id') %]
  Cancel and Return to [% "$terms.bug $id" FILTER bug_link(id) FILTER none %]
[% ELSE %]
  Cancel and Return to <a href="buglist.cgi?regetlastlist=1">the last search results</a>
[% END %]

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