[%# The contents of this file are subject to the Mozilla Public
  # License Version 1.1 (the "License"); you may not use this file
  # except in compliance with the License. You may obtain a copy of
  # the License at http://www.mozilla.org/MPL/
  #
  # Software distributed under the License is distributed on an "AS
  # IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  # implied. See the License for the specific language governing
  # rights and limitations under the License.
  #
  # The Original Code is the Bugzilla Bug Tracking System.
  #
  # The Initial Developer of the Original Code is Netscape Communications
  # Corporation. Portions created by Netscape are
  # Copyright (C) 1998 Netscape Communications Corporation. All
  # Rights Reserved.
  #
  # Contributor(s): Gervase Markham <gerv@gerv.net>
  #                 Ville Skyttä <ville.skytta@iki.fi>
  #                 Shane H. W. Travis <travis@sedsystems.ca>
  #                 Marc Schumann <wurblzap@gmail.com>
  #                 Akamai Technologies <bugzilla-dev@akamai.com>
  #                 Max Kanat-Alexander <mkanat@bugzilla.org>
  #                 Frédéric Buclin <LpSolit@gmail.com>
  #%]

[% USE Bugzilla %]

[% title = BLOCK %]Enter [% terms.Bug %]: [% product.name FILTER html %][% END %]

[% PROCESS global/header.html.tmpl
  title = title
  quicksearch_tabindex = 30
  style_urls = [ 'skins/standard/create_attachment.css', 'skins/standard/calendar.css' ]
  javascript_urls = [
    "js/attachment.js", "js/bug.js", "js/field.js", "js/calendar.js",
    "js/TUI.js", "js/bug-visibility.js", "fieldvaluecontrol.cgi?type=bug&user=${Bugzilla.user.id}"
  ]
  onload = 'set_assign_to();document.getElementById(\'short_desc\').focus();'
%]

[%# FIXME move most JS from here to a *.js file %]
<script type="text/javascript">
<!--

var last_cc = "[% cc | js %]";
var cc_rem = {}, cc_add = {};
var initialowners = new Array([% product.active_components.size %]);
var last_initialowner;
var initialccs = new Array([% product.active_components.size %]);
var components = new Array([% product.active_components.size %]);
var componentdefaultversions = new Array([% product.active_components.size %]);
var last_component = -1;
var comp_desc = new Array([% product.active_components.size %]);
var flags = new Array([% product.active_components.size %]);
[% IF Param("useqacontact") %]
    var initialqacontacts = new Array([% product.active_components.size %]);
    var last_initialqacontact;
[% END %]
[% count = 0 %]
[%- FOREACH c = product.active_components %]
    components[[% count %]] = "[% c.name FILTER js %]";
    componentdefaultversions[[% count %]] = "[% c.default_version FILTER js %]";
    comp_desc[[% count %]] = "[% c.description FILTER html_light FILTER js %]";
    initialowners[[% count %]] = "[% c.default_assignee.login FILTER js %]";
    [% flag_list = [] %]
    [% FOREACH f = c.flag_types.bug %]
      [% NEXT UNLESS f.is_active %]
      [% flag_list.push(f.id) %]
    [% END %]
    [% FOREACH f = c.flag_types.attachment %]
      [% NEXT UNLESS f.is_active %]
      [% flag_list.push(f.id) %]
    [% END %]
    flags[[% count %]] = [[% flag_list.join(",") FILTER js %]];
    [% IF Param("useqacontact") %]
        initialqacontacts[[% count %]] = "[% c.default_qa_contact.login FILTER js %]";
    [% END %]

    [% SET initial_cc_list = [] %]
    [% FOREACH cc_user = c.initial_cc %]
      [% ccl = cc_user.login FILTER js %]
      [% initial_cc_list.push(ccl) %]
    [% END %]
    initialccs[[% count %]] = ["[% initial_cc_list.join('", "') %]"];

    [% count = count + 1 %]
[%- END %]

var wantsReminder = [% Bugzilla.user.wants_worktime_reminder('new bug') ? 'true' : 'false' %];
var noTimeTracking = [% product.notimetracking ? 'true' : 'false' %];

function validateEntryForm(theform)
{
    if (check_new_keywords(document.Create) == false) return false;

    if (theform.short_desc.value == '')
    {
        alert('Please enter a summary sentence for this [% terms.bug %].');
        return false;
    }
    // Validate attachment
    var t = document.getElementById('attachment_true');
    if (t.style.display != 'none' && !validateAttachmentForm(theform))
        return false;
    else if (t.style.display == 'none')
    {
        // Clear attachment description so it won't be created
        theform.description.value = '';
    }
    // Validate worktime
    var wt = bzParseTime(theform.work_time.value);
    if (wt !== null && (wt === undefined || wt != wt))
        wt = null;
    else if (wt < 0)
        wt = 0;
    if (wantsReminder && (wt === null || noTimeTracking == (wt != 0)))
    {
        wt = prompt("Please, verify working time:", "0");
        if (wt == null || wt == undefined || (""+wt).length <= 0)
        {
            theform.work_time.focus();
            return false;
        }
    }
    if (wt === null)
        wt = 0;
    theform.work_time.value = wt;
    return true;
}

function set_assign_to() {
    // Based on the selected component, fill the "Assign To:" field
    // with the default component owner, and the "QA Contact:" field
    // with the default QA Contact. It also selectively enables flags.
    var form = document.Create;
    var assigned_to = form.assigned_to.value;

[% IF Param("useqacontact") %]
    var qa_contact = form.qa_contact.value;
[% END %]

    var index = -1;
    if (form.component.type == 'select-one') {
        index = form.component.selectedIndex;
    } else if (form.component.type == 'hidden') {
        // Assume there is only one component in the list
        index = 0;
    }
    if (index != -1) {
        var owner = initialowners[index];
        var component = components[index];
        var version = componentdefaultversions[index];
        if (assigned_to == last_initialowner
            || assigned_to == owner
            || assigned_to == '') {
            form.assigned_to.value = owner;
            last_initialowner = owner;
        }

        if ([% overridedefaultversion ? 0 : 1 %] &&
            (((last_component < 0 || componentdefaultversions[last_component] == '') && form.version.value == "[% default.version FILTER js %]") ||
            last_component >= 0 && form.version.value == componentdefaultversions[last_component]))
        {
            for (var i = 0; i < form.version.options.length; i++)
            {
                if (form.version.options[i].value == version)
                {
                    form.version.selectedIndex = i;
                    break;
                }
            }
        }

        /* CustIS Bug 57457 & Bug 58657 */
        /** Infernal logic for High Usability
         * Remembers modifications entered by user (added and removed CC), and
         * builds new CC list from initial value plus initialccs[index]
         * (initial CC for component), preserving entry order.
         *
         ** Адская логика для Высокого Юзабилити
         * Запоминает изменения, внесённые пользователем в список CC и
         * строит новый список CC как объединение начального значения и
         * initialccs[index] (CC по умолчанию для компонента), да ещё и сохраняет
         * порядок ввода.
         */
        var cc_diff = diff_arrays(last_cc.split(/[\s,]+/), document.Create.cc.value.split(/[\s,]+/));
        for (i in cc_rem)
            if (cc_rem[i] && !cc_diff[0][i])
                cc_diff[1][i] = 1;
        for (i in cc_add)
            if (cc_add[i] && !cc_diff[1][i])
                cc_diff[0][i] = 1;
        cc_add = cc_diff[0];
        cc_rem = cc_diff[1];
        var new_cc = array_hash("[% cc | js %]".split(/[\s,]+/));
        for (i in initialccs[index])
            if (initialccs[index][i])
                new_cc[initialccs[index][i]] = 1;
        for (i in cc_diff[0])
            new_cc[i] = 1;
        for (i in cc_diff[1])
            new_cc[i] = 0;
        last_cc = document.Create.cc.value = hash_join(new_cc);
        document.getElementById('comp_desc').innerHTML = comp_desc[index];

        [% IF Param("useqacontact") %]
            var contact = initialqacontacts[index];
            if (qa_contact == last_initialqacontact
                || qa_contact == contact
                || qa_contact == ''
                || qa_contact == "[% qa_contact FILTER js %]") {
                  form.qa_contact.value = contact;
                  last_initialqacontact = contact;
            }
        [% END %]

        // First, we disable all flags. Then we re-enable those
        // which are available for the selected component.
        var inputElements = document.getElementsByTagName("select");
        var inputElement, flagField;
        for ( var i=0 ; i<inputElements.length ; i++ ) {
            inputElement = inputElements.item(i);
            if (inputElement.name.search(/^flag_type-(\d+)$/) != -1) {
                var id = inputElement.name.replace(/^flag_type-(\d+)$/, "$1");
                inputElement.disabled = true;
                // Also disable the requestee field, if it exists.
                inputElement = document.getElementById("requestee_type-" + id);
                if (inputElement) inputElement.disabled = true;
            }
        }
        // Now enable flags available for the selected component.
        for (var i = 0; i < flags[index].length; i++) {
            flagField = document.getElementById("flag_type-" + flags[index][i]);
            // Do not enable flags the user cannot set nor request.
            if (flagField && flagField.options.length > 1) {
                flagField.disabled = false;
                // Re-enabling the requestee field depends on the status
                // of the flag.
                toggleRequesteeField(flagField, 1);
            }
        }

        last_component = index;
    }
}

function handleWantsAttachment(wants_attachment)
{
    var f = document.getElementById('attachment_false');
    var t = document.getElementById('attachment_true');
    var m = document.getElementById('attachment_multi');
    f.style.display = wants_attachment == 'none'   ? '' : 'none';
    t.style.display = wants_attachment == 'single' ? '' : 'none';
    m.style.display = wants_attachment == 'multi'  ? '' : 'none';
    if (wants_attachment != 'multi')
    {
        document.getElementById('att_multiple').innerHTML = '';
    }
    else
    {
        iframeajax('page.cgi?id=attach-multiple.html', {});
    }
}

function show_resolution_field(showhide)
{
    if (showhide)
        document.getElementById('resolution_container').style.display = '';
    else
    {
        document.getElementById('resolution_container').style.display = 'none';
        document.Create.resolution.value = '';
    }
}

function checkWorktime(inp)
{
    if (noTimeTracking)
    {
        wt = bzParseTime(inp.value);
        inp.parentNode.style.backgroundColor = (wt != 0 ? '#FFC0C0' : null);
    }
}

-->
</script>

[% USE Bugzilla %]
[% SET select_fields = {} %]
[% FOREACH field = Bugzilla.get_fields(
  { type => constants.FIELD_TYPE_SINGLE_SELECT, custom => 0 })
%]
  [% select_fields.${field.name} = field %]
[% END %]

<form name="Create" id="Create" method="post" action="post_bug.cgi"
      enctype="multipart/form-data" onkeypress="return ctrlEnter(event||window.event,this)"
      onsubmit="return validateEntryForm(this)">
<input type="hidden" name="product" value="[% product.name FILTER html %]" id="product">
<input type="hidden" name="token" value="[% token FILTER html %]">
<input type="hidden" name="cloned_bug_id" value="[% cloned_bug_id FILTER html %]">
<input type="hidden" name="cloned_comment" value="[% cloned_comment FILTER html %]">

<p>
[%# Migration note: The following file corresponds to the old Param
  # 'entryheaderhtml'
  #%]
[% INCLUDE 'bug/create/user-message.html.tmpl' %]
</p>

<p>(<span class="required_star">*</span> = <span class="required_explanation">Required Field</span>)</p>

<table cellspacing="4" cellpadding="2" border="0">
<tbody>
  <tr><td colspan="4"><hr /></td></tr>

  <tr>
    <th>Product:</th>
    <td width="10%">[% product.name FILTER html %]</td>

    <th>Reporter:</th>
    <td width="100%">[% user.login FILTER html %]</td>
  </tr>

  [%# We can't use the select block in these two cases for various reasons. %]
  <tr>
    <th class="required">
      <a href="describecomponents.cgi?product=[% product.name FILTER url_quote %]">
      Component</a>:
    </th>
    <td>
      <select name="component" onchange="set_assign_to();" size="7"
              aria-required="true" class="required">
        [%# Build the lists of assignees and QA contacts if "usemenuforusers" is enabled. %]
        [% IF Param("usemenuforusers") %]
          [% assignees_list = user.get_userlist.clone %]
          [% qa_contacts_list = user.get_userlist.clone %]
        [% END %]

        [%- FOREACH c = product.active_components %]
          <option value="[% c.name FILTER html %]"
            [% " selected=\"selected\"" IF c.name == default.component_ %]>
            [% c.name FILTER html -%]
          </option>
          [% IF Param("usemenuforusers") %]
            [% INCLUDE build_userlist default_user = c.default_assignee,
                                      userlist = assignees_list %]
            [% INCLUDE build_userlist default_user = c.default_qa_contact,
                                      userlist = qa_contacts_list %]
          [% END %]
        [%- END %]
      </select>
    </td>

    <td colspan="2">
      [%# Enclose the fieldset in a nested table so that its width changes based
        # on the length on the component description. %]
      <table>
        <tr>
          <td>
            <fieldset>
              <legend>Component Description</legend>
              <div id="comp_desc" class="comment">Select a component to read its description.</div>
            </fieldset>
          </td>
        </tr>
      </table>
    </td>
  </tr>

  <tr>
    <th>Version:</th>
    <td>
      <select name="version">
        [%- FOREACH v = version %]
          <option value="[% v FILTER html %]"
            [% ' selected="selected"' IF v == default.version %]>[% v FILTER html -%]
          </option>
        [%- END %]
      </select>
    </td>

    [% INCLUDE bug/field.html.tmpl
      bug = default, field = select_fields.bug_severity, editable = 1,
      value = default.bug_severity %]
  </tr>

[% IF Param('useplatform') %]
  <tr>
    [% INCLUDE bug/field.html.tmpl
      bug = default, field = select_fields.rep_platform, editable = 1,
      value = default.rep_platform %]
  </tr>
[% END %]

[% IF Param('useopsys') %]
  <tr>
    [% INCLUDE bug/field.html.tmpl
       bug = default, field = select_fields.op_sys, editable = 1,
       value = default.op_sys %]
  </tr>
[% END %]
</tbody>

<tbody class="expert_fields">
  <tr>
    [% IF Param('usetargetmilestone') && Param('letsubmitterchoosemilestone') %]
      [% sel = { description => 'Target Milestone', name => 'target_milestone' } %]
      [% INCLUDE select %]
    [% ELSE %]
      <td colspan="2">&nbsp;</td>
    [% END %]

    [% IF Param('letsubmitterchoosepriority') %]
      [% INCLUDE bug/field.html.tmpl
        bug = default, field = select_fields.priority, editable = 1,
        value = default.priority %]
    [% ELSE %]
      <td colspan="2">&nbsp;</td>
    [% END %]
  </tr>
</tbody>

[% IF !Param('defaultplatform') || !Param('defaultopsys') %]
  <tbody>
    <tr>
      <th>&nbsp;</th>
      <td colspan="3" class="comment">
        We've made a guess at your
        [% IF Param('defaultplatform') %]
          operating system. Please check it
        [% ELSIF Param('defaultopsys') %]
          platform. Please check it
        [% ELSE %]
          operating system and platform. Please check them
        [% END %]
        and make any corrections if necessary.
      </td>
    </tr>
  </tbody>
[% END %]

<tbody class="expert_fields">

  <tr>
[% IF bug_status.size <= 1 %]
  <input type="hidden" name="bug_status" 
         value="[% default.bug_status FILTER html %]">
    <th>Initial State:</th>
    <td>[% default.bug_status FILTER html %]</td>
[% ELSE %]
    [% sel = {
        description => 'Initial State',
        name => 'bug_status',
        onchange => 'if(this.value=="ASSIGNED"){ document.Create.assigned_to.value="' _ user.login _ '" } show_resolution_field(this.value=="RESOLVED");',
    } %]
    [% INCLUDE select %]
  </td>
[% END %]
  </tr>

  <tr id="resolution_container" style="display:none">
  <th><a href="page.cgi?id=fields.html#resolution">Resolution</a>:</th>
  <td>
    <select name="resolution" id="resolution">
    [%- FOREACH x = resolution %]
      [% NEXT IF x == "MOVED" %]
      <option value="[% x FILTER html %]">[% x FILTER html %]</option>
    [% END %]
    </select>
  </td>
  </tr>

  <tr><td colspan="4"><hr /></td></tr>

  <tr>
    <th><a href="page.cgi?id=fields.html#assigned_to">Assign To</a>:</th>
    <td>
      [% INCLUDE global/userselect.html.tmpl
         name => "assigned_to"
         value => assigned_to
         disabled => assigned_to_disabled
         size => 30
         emptyok => 1
         custom_userlist => assignees_list
       %]
      <noscript>(Leave blank to assign to component's default assignee)</noscript>
    </td>

    [%# Calculate the number of rows we can use for flags %]
    [% num_rows = 2 + (Param("useqacontact") ? 1 : 0) %]

    <td colspan="2" rowspan="[% num_rows FILTER html %]">
      [% IF product.flag_types.bug.size > 0 %]
        [% display_flag_headers = 0 %]
        [% any_flags_requesteeble = 0 %]

        [% FOREACH flag_type = product.flag_types.bug %]
          [% NEXT UNLESS flag_type.is_active %]
          [% display_flag_headers = 1 %]
          [% SET any_flags_requesteeble = 1 IF flag_type.is_requestable && flag_type.is_requesteeble %]
        [% END %]

        [% IF display_flag_headers %]
          [% PROCESS "flag/list.html.tmpl" flag_types = product_flag_types
                                           any_flags_requesteeble = any_flags_requesteeble
                                           flag_table_id = "bug_flags"
          %]
        [% END %]
      [% END %]
    </td>
  </tr>
  
[% IF Param("useqacontact") %]
    <tr>
      <th>QA Contact:</th>
      <td>
      [% INCLUDE global/userselect.html.tmpl
         name => "qa_contact"
         value => qa_contact
         disabled => qa_contact_disabled
         size => 30
         emptyok => 1
         custom_userlist => qa_contacts_list
       %]
        <noscript>(Leave blank to assign to default qa contact)</noscript>
      </td>
    </tr>
[% END %]

  <tr>
    <th>CC:</th>
    <td>
      [% INCLUDE global/userselect.html.tmpl
         name => "cc"
         value => cc
         disabled => cc_disabled
         size => 30
         multiple => 5
       %]
    </td>
  </tr>

  <tr><td colspan="4"><hr /></td></tr>

  <tr>
[% IF user.is_timetracker %]
    <th>Estimated Hours:</th>
    <td>
      <input name="estimated_time" size="6" maxlength="6" value="[% estimated_time | html %]">&nbsp;
      <b>Hours Worked:</b>
      <input name="work_time" id="work_time" value="[% work_time | html %]" size="6" maxlength="6" onchange="checkWorktime(this)" onkeyup="checkWorktime(this)"" />
    </td>
[% END %]
    <th>Depends on:</th>
    <td><input name="dependson" accesskey="d" value="[% dependson FILTER html %]"></td>
  </tr>
  <tr>
[% IF user.in_group(Param('timetrackinggroup')) %]
    <th>Deadline:</th>
    <td>
      <input name="deadline" id="deadline" size="10" maxlength="10" value="[% deadline FILTER html %]">
      <small>(YYYY-MM-DD)</small>
      <script type="text/javascript">
         Calendar.set('deadline');
      </script>
    </td>
[% END %]
    <th>Blocks:</th>
    <td><input name="blocked" accesskey="b" value="[% blocked FILTER html %]"></td>
  </tr>

  <tr>
    <th>URL:</th>
    <td colspan="2"><input name="bug_file_loc" size="40" value="[% bug_file_loc FILTER html %]"></td>
  </tr>
</tbody>

<tbody class="expert_fields">
  [% USE Bugzilla %]

  [% FOREACH field = Bugzilla.active_custom_fields %]
    [% NEXT UNLESS field.enter_bug %]
    [% SET value = ${field.name}.defined ? ${field.name} : "" %]
    <tr>
      [% INCLUDE bug/field.html.tmpl
        bug = default, field = field, value = value, editable = 1,
        value_span = 3 %]
    </tr>
  [% END %]
</tbody>

<tbody>
  <tr><td colspan="4"><hr /></td></tr>

  <tr>
    <th class="required">Summary:</th>
    <td colspan="3">
      <input name="short_desc" id="short_desc" size="70" value="[% short_desc FILTER html %]"
             maxlength="255" spellcheck="true" aria-required="true"
             class="required" />
    </td>
  </tr>
</tbody>

<tbody>
  <tr>
    <th>Description:</th>
    <td colspan="3" style="padding-bottom: 0">
      [% defaultcontent = BLOCK %]
        [% IF cloned_bug_id %]
+++ This [% terms.bug %] was initially created as a clone of [% terms.Bug %] #[% cloned_bug_id %][% IF cloned_comment %] comment [% cloned_comment %][% END %] +++


        [% END %]
        [%-# We are within a BLOCK. The comment will be correctly HTML-escaped
          # by global/textarea.html.tmpl. So we must not escape the comment here. %]
        [% comment FILTER none %]
      [%- END %]
      [% INCLUDE global/textarea.html.tmpl
         name           = 'comment'
         id             = 'comment'
         minrows        = 10
         maxrows        = 25
         cols           = constants.COMMENT_COLS
         defaultcontent = defaultcontent
       %]
      <br /><input type="button" value="Preview comment" onclick="document.getElementById('wrapcommentpreview').style.width = document.getElementById('comment').offsetWidth+'px'; showcommentpreview('comment');" />
      [% PROCESS "bug/comment-preview-div.html.tmpl" %]
    </td>
  </tr>

  [% IF user.is_insider %]
    <tr class="expert_fields">
      <th>&nbsp;</th>
      <td colspan="3">
        &nbsp;&nbsp;
        <input type="checkbox" id="commentprivacy" name="commentprivacy"
          [% " checked=\"checked\"" IF commentprivacy %]>
        <label for="commentprivacy">
          Make description private (visible only to members of the 
          <strong>[% Param('insidergroup') FILTER html %]</strong> group)
        </label>
      </td>
    </tr>
  [% END %]

  <tr><td colspan="4"><hr /></td></tr>

  <tr>
    <th>Attachment:</th>
    <td colspan="3">
      <div id="attachment_false">
        <input type="button" value="Add an attachment" onclick="handleWantsAttachment('single')" />
        <input type="button" value="Add multiple" onclick="handleWantsAttachment('multi')" />
      </div>
      <div id="attachment_true" style="display: none">
        <input type="button" value="Don't add an attachment" onClick="handleWantsAttachment('none')" />
        <input type="button" value="Add multiple" onclick="handleWantsAttachment('multi')" />
        <fieldset>
          <legend>Add an attachment</legend>
          <table class="attachment_entry">
            [% PROCESS attachment/createformcontents.html.tmpl
                       flag_types = product.flag_types.attachment
                       any_flags_requesteeble = 1
                       flag_table_id ="attachment_flags"
                       attach_multi = "show_attach_multi(this);"  %]
          </table>
        </fieldset>
      </div>
      <div id="attachment_multi" style="display: none">
        <input type="button" value="Add single attachment" onclick="handleWantsAttachment('single')" />
        <input type="button" value="Don't add an attachment" onClick="handleWantsAttachment('none')" />
        <fieldset>
          <legend>Add multiple attachments</legend>
          <div id="att_multiple" style="display: none"></div>
        </fieldset>
      </div>
    </td>
  </tr>
</tbody>

<tbody class="expert_fields">
  [% IF user.in_group('editbugs', product.id) %]
    [% IF use_keywords %]
      <tr>
        <th><a href="describekeywords.cgi">Keywords</a>:</th>
        [% UNLESS Param("usebugaliases") %]
        <td colspan="3">
        [% ELSE %]
        <td>
        [% END %]
          <input id="keywords" name="keywords" size="40" value="[% keywords FILTER html %]">
          <script type="text/javascript">
	    var emptyKeywordsOptions = [% keyword_list ? json(keyword_list) : "null" %];
            addListener(window, 'load', function() {
                new SimpleAutocomplete("keywords",
                    function(h) { keywordAutocomplete(h, emptyKeywordsOptions); },
                    { emptyText: 'No keywords found', multipleDelimiter: "," }
                );
            }); 
          </script>
	    <div id="keywords_description_container"></div>
        </td>
      [% IF Param("usebugaliases") %]
        <th>Alias:</th>
        <td><input name="alias" size="20"></td>
      [% END %]
      </tr>
    [% ELSIF Param("usebugaliases") %]
      <tr>
        <th>Alias:</th>
        <td colspan="3"><input name="alias" size="20"></td>
      </tr>
    [% END %]
  [% END %]
  [% IF Param('usestatuswhiteboard') %]
    <tr>
      <th>Whiteboard:</th>
      <td colspan="3">
        <input id="status_whiteboard" name="status_whiteboard" size="40" value="[% status_whiteboard FILTER html %]">
      </td>
    </tr>
  [% END %]
  
</tbody>

<tbody class="expert_fields">
  [% IF group.size %]
  <tr>
    <th>&nbsp;</th>
    <td colspan="3">
      <br>
        <strong>
          Only users in all of the selected groups can view this [% terms.bug %]:
        </strong>
      <br>
      <font size="-1">
        (Leave all boxes unchecked to make this a public [% terms.bug %].)
      </font>
      <br>
      <br>

      <!-- Checkboxes -->
      [% FOREACH g = group %]
        &nbsp;&nbsp;&nbsp;&nbsp;
        <input type="checkbox" id="bit-[% g.bit %]"
          name="bit-[% g.bit %]" value="1"
          [% " checked=\"checked\"" IF g.checked %]>
          <label for="bit-[% g.bit %]">[% g.description FILTER html_light %]</label><br>
      [% END %]
    </td>
  </tr>
  [% END %]
</tbody>

<tbody>
  [%# Form controls for entering additional data about the bug being created. %]
  [% Hook.process("form") %]

  <tr>
    <th>&nbsp;</th>
    <td colspan="3">
      <input type="submit" id="commit" value="Submit [% terms.Bug %]" />
      &nbsp;&nbsp;&nbsp;&nbsp;
      <input type="submit" name="maketemplate" id="maketemplate"
             value="Remember values as bookmarkable template"
             class="expert_fields" />
    </td>
  </tr>
</tbody>
  </table>
  <input type="hidden" name="form_name" value="enter_bug" />
</form>

[%# Links or content with more information about the bug being created. %]
[% Hook.process("end") %]

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

[%############################################################################%]
[%# Block for SELECT fields                                                  #%]
[%############################################################################%]

[% BLOCK select %]
  [% IF sel.description %]
    <th>
      <a href="page.cgi?id=fields.html#[% sel.name %]">[% sel.description %]</a>:
    </th>
  [% END %]

  <td>
    <select name="[% sel.name %]" id="[% sel.name %]"[% IF sel.onchange %] onchange='[% sel.onchange %]'[% END %]>
    [%- FOREACH x = ${sel.name} %]
      <option value="[% x FILTER html %]"
        [% " selected=\"selected\"" IF x == default.${sel.name} %]>
        [% x FILTER html %]
      </option>
    [% END %]
    </select>
  </td>
[% END %]

[% BLOCK build_userlist %]
  [% user_found = 0 %]
  [% default_login = default_user.login %]
  [% RETURN UNLESS default_login %]

  [% FOREACH user = userlist %]
    [% IF user.login == default_login %]
      [% user_found = 1 %]
      [% LAST %]
    [% END %]
  [% END %]

  [% userlist.push({login    => default_login,
                    identity => default_user.identity,
                    visible  => 1})
     UNLESS user_found %]
[% END %]
