[%# 1.0@bugzilla.org %]
[%# 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 Test Runner System.
  #
  # The Initial Developer of the Original Code is Maciej Maczynski.
  # Portions created by Maciej Maczynski are Copyright (C) 2001
  # Maciej Maczynski. All Rights Reserved.
  #
  # Contributor(s): Ed Fuentetaja <efuentetaja@acm.org>
  #                 Greg Hendricks <ghendricks@novell.com>
  #%]

[%# INTERFACE:
  # ...
  #%]
  
  <script type="text/javascript">
    dojo.require("dojo.widget.Select");
    dojo.addOnLoad(
      function() {
        dojo.widget.manager.getWidgetById('caserun_env').setValue('[% dotweak ? '' : caserun.environment.id FILTER none %]');
        dojo.widget.manager.getWidgetById('caserun_env').setLabel('[% dotweak ? '' : caserun.environment.name FILTER none %]');
        dojo.widget.manager.getWidgetById('assignee').setValue('[% dotweak ? '' : caserun.assignee.login FILTER none %]');
        dojo.widget.manager.getWidgetById('assignee').setLabel('[% dotweak ? '' : caserun.assignee.login FILTER none %]');
      }
    );
  </script>
[% IF single %]
  [% build_list = caserun.run.plan.product.builds(1) %]
  [% default_build = caserun.build.id %]
[% ELSE %]
  [% default_build = "--Do Not Change--" %]
[% END %]

<table>
  <tr>
  [% IF NOT dotweak %]
    <td align="center" valign="top" width="50%">
      [% IF caserun.bugs.size > 0 %]
      <table>
        <tr class="bz_row_header">
          <th colspan="3" >[% terms.Bugs %]</th>
        </tr>
        <tr class="bz_row_header">
          <th>ID</th><th>Summary</th><th>Remove</th>
        </tr>
      [% FOREACH bug = caserun.bugs %]
        <tr>
          <td>[% bug.bug_id FILTER bug_link(bug.bug_id) %] </td>
          <td>[% bug.short_desc FILTER html %]</td>
          <td><a href="tr_show_caserun.cgi?caserun_id=[% caserun.id FILTER none %]&bug_id=[% bug.bug_id FILTER none %]&action=detach_bug"><img src="testopia/img/del.gif" alt="detach bug" /></a>
        </tr>
      [% END %]
      </table>
      [% END %]
      </td>
      <td align="center" valign="top" width="50%">
     [% IF caserun.case.bugs.size > 0 %]
      <table>
        <tr class="bz_row_header">
          <th colspan="3" >[% terms.Bugs %] in all runs</th>
        </tr>
        <tr class="bz_row_header">
          <th>ID</th><th>Summary</th>
        </tr>
      [% FOREACH bug = caserun.case.bugs %]
        <tr>
          <td>[% bug.bug_id FILTER bug_link(bug.bug_id) %] </td>
          <td>[% bug.short_desc FILTER html %]</td>
        </tr>
      [% END %]
      </table>
      [% END %]
    </td>
  [% END %]
  </tr>

</table>

<table>
[% IF run %]
  <tr>
    <th align="right">Build</th>
    <td>
  [% PROCESS select sel = { name => "caserun_build", 
                            list => build_list, 
                         default => default_build }
     %]
    </td>
    <th align="right">Environment</th>
    <td><input dojoType="select" 
               dataUrl="tr_quicksearch.cgi?action=getenv&run_id=[% caserun.run.id FILTER none %]&search=%{searchString}" 
               mode="remote"
               autoComplete="false"
               id="caserun_env"
               name="caserun_env"
               maxListLength="10" 
               style="width:200px; height:15px"
            [% IF NOT dotweak %]
               value="[% caserun.environment.id FILTER none %]" 
            [% END %]>
    </td>
  </tr>
  [% ELSE %]
  <tr>
    <td><input type="hidden" name="caserun_build" value="-1"></td>
    <td><input type="hidden" name="caserun_env" value=""></td>
  </tr>
[% END %]
  <tr>
    <th align="right">Assignee</th>
    <td><input dojoType="Select" 
                 dataUrl="tr_quicksearch.cgi?action=getuser&search=%{searchString}" 
                 mode="remote"
                 autoComplete="true"
                 id="assignee"
                 name="assignee"
                 maxListLength="10" 
                 style="width:200px; height:15px"
                 value="[% dotweak ? '' : caserun.assignee.login FILTER html %]" >
    </td>
    <th align="right">Attach [% terms.Bugs %]</th>
    <td><input name="bugs">&nbsp;<a href="enter_bug.cgi?product=[% caserun.run.plan.product.name FILTER url_quote %]&caserun_id=[% caserun.id FILTER none %]" target="_blank"><img src="testopia/img/snew.gif" alt="Log a New Bug" title="Log a New Bug" style="vertical-align:text-bottom;" /></a>
        <br><input type="checkbox" value="1" name="update_bug" id="update_bug">Update [% terms.bug %] status </td>
  </tr>
</table>
<table>
  <tr>  
    <td colspan="2" valign="top">
    <table>
      <tr>
        <th colspan="3" class="bz_row_header">Status</th>
      </tr>
    [% FOREACH status = caserun.get_status_list %]
    <tr>
      <td><label for="[% status.name FILTER none %]"><img src="testopia/img/[% status.name FILTER none %].gif" alt="[% status.name FILTER none %]"></label></td>
      <td align="right"><input type="radio" name="status" id="[% status.name FILTER none %]" value="[% status.id FILTER none %]" [% 'checked="checked"' IF caserun.status == status.name AND NOT dotweak %]></td>
      <th align="left"><label for="[% status.name FILTER none %]">[% status.name FILTER html %]</label></th>
    </tr>
    [% END %]
    [% IF dotweak %]
    <tr>
      <td>&nbsp;</td>
      <td align="right"><input type="radio" name="status" value="-1" [% 'checked="checked"' IF dotweak %]></td>
      <th align="left"><label for="[% status.name FILTER none %]">No Change</label></th>
    </tr>
    [% END %]
  </table>
  </td>
    <td colspan="2" align="center" valign="top">
    <table>
    [% IF single %]
      <tr>
        <th class="bz_row_header">Notes</th>
      </tr>
      <tr>
        <td><div style="height:200px; width: 600px; border: 1px solid #000; overflow: auto; background-color: #f8f8f8"><pre>[% caserun.notes FILTER html %]</pre></div></td>
      </tr>
    [% END %]
      <tr>
        <th class="bz_row_header">Append a New Note</th>
      </tr>
      <tr>
        <td><textarea name="notes" cols="80" rows="5" style="width: 600px"></textarea></td>
      </tr>
    </table>
  </td>
  </tr>
  <tr>
    <td align="right" colspan="4">
      <input type="hidden" name="caserun_id" value="[% caserun.id FILTER none %]">
    <input type="submit" name="action" value="Commit">
    </td>
  </tr>
</table>
</div>
