[%# 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:
  # ...
  #%]

[%############################################################################%]
[%# Template Initialization                                                  #%]
[%############################################################################%]

[% PROCESS global/variables.none.tmpl %]
[% PROCESS testopia/blocks.html.tmpl %]
[% title = "Test Run $run.id: $run.summary" %]

[%############################################################################%]
[%# Page Header                                                              #%]
[%############################################################################%]

[% PROCESS global/header.html.tmpl
   style_urls = ['testopia.css'] %]
[% PROCESS testopia/blocks.html.tmpl %]
[% PROCESS testopia/style.none.tmpl %]

[% PROCESS testopia/messages.html.tmpl %]


<script type="text/javascript">
  djConfig = {
    parseWidgets: false,
    searchIds: ["manager","percent_bar","environment","tags","newtag","tagTable","tip_[% run.id FILTER none %]","caseruns_table",[% FOREACH cr = table.list %]"env_[% loop.count %]","head_caserun_[% loop.count %]"[%',' UNLESS loop.last %][% END %]]
  };
</script>
<script src="testopia/js/util.js" type="text/javascript"></script>
<script src="testopia/js/tags.js" type="text/javascript"></script>
<script src="testopia/dojo/dojo.js" type="text/javascript"></script>
<script type="text/javascript">
    dojo.require('dojo.io.*');
    dojo.require("dojo.widget.Tooltip");
    dojo.require("dojo.widget.ComboBox");
    function getSelected (ccbox){
        var ccselected = new Array();
        for (j=0; j < ccbox.options.length; j++){
            if (ccbox.options[j].selected != 0)
                ccselected.push(ccbox.options[j].value);
            
        }
        var sel = ccselected.toString();
        return sel;
    }

    function fillcc (data){
         var xmldocroot = data.documentElement;
         var newcc = xmldocroot.getElementsByTagName('user');
         var cc = document.getElementById("cc");
         cc.options.length = 0;
         for (i=0; i< newcc.length; i++){
           var id = newcc[i].childNodes[0].firstChild.nodeValue;
           var name = newcc[i].childNodes[1].firstChild.nodeValue;
           var myOp = new Option(name, id);
           addOption(cc,myOp);
         }
         document.getElementById("newcc").value = '';
         document.getElementById("addCC").disabled = false;
         document.getElementById("deleteCC").disabled = false;

    }
    function updateCC(cctext, action){
        if (cctext == '')
          return;
        document.getElementById("addCC").disabled = true;
        document.getElementById("deleteCC").disabled = true;
        dojo.io.bind({
            url:     "tr_show_run.cgi",
            content: {  cc: cctext, run_id: [% run.id FILTER none %], action: action },
            load:    function(type, data, evt){ fillcc(data);},
            error:   function(type, error){ alert(error.message);},
            mimetype: "text/xml"
        });
    }
    function notesZoom(id, case_id){
      notes = window.open('','notes', 'status=1,toolbar=0,location=0,menubar=0,directories=0,resizable=1,scrollbars=1,width=800,height=600'); 
      notes.title = 'Hello';
      notes.document.write('<html><head><title>Notes for Case ' + case_id + '</title></head><body>');
      notes.document.write(document.getElementById('old_notes'+id).innerHTML);
      notes.document.write('</body></html>');
      notes.document.close();
    }
</script>
<style>
  .number_cell{
      border: 1px solid #000;
      width: 100px;
      text-align: right;
  }
</style>

[% PROCESS testopia/run/navigate.html.tmpl %]

[%##### Overview #####%]
<div id="run_overview">
<h3>Overview</h3>
<table border="0" cellpadding="1" width="100%">
  <tbody align="left">
    <tr class="bz_row_header">
      <th>Plan</th>
      <th>Plan Text Version</th>
      <th>Start Date</th>
      </tr>
    <tr class="bz_row_data">
      <td><a href="tr_show_plan.cgi?plan_id=[% run.plan.id FILTER none %]">[% run.plan.name FILTER html %]</a></td>
      <td>[% run.plan_text_version FILTER html %]</td>
      <td>[% run.start_date FILTER time %]</td>
      </tr>
    <tr class="bz_row_header">
      <th>Product</th>
      <th>Product Version</th>
      <th>Stop Date</th>
      </tr>
    <tr class="bz_row_data">
      <td>[% run.plan.product.name FILTER html %]</td>
      <td>[% run.product_version FILTER html %]</td>
      <td>[% run.stop_date FILTER time %]</td>
    </tr>
    <tr class="bz_row_header">
      <th>Manager</th>
      <th>Percent Complete</th>
      <th>Status</th>
      </tr>
    <tr class="bz_row_data">
      <td><a href="mailto:[% run.manager.email FILTER html %]">[% run.manager.identity FILTER html %]</a></td>
      <td align="center" dojoType="ContentPane" id="percent_bar">
        [% PROCESS testopia/percent_bar.html.tmpl 
           percent = run.percent_complete 
        %]
      </td>
      <td align="center">
      [% IF run.stop_date %]
        STOPPED
      [% ELSE %]
        RUNNING
      [% END %]
      </td>
    </tr>
    
    <tr class="bz_row_data">
      <td colspan="3"></td>
    </tr>
  </tbody>
</table>
[% IF run.canedit %]
<a href="#attributes">Edit Run Attributes</a>
[% END %]
</div>

<h3>Test Case Run Logs</h3><a name="table" />
[% PROCESS testopia/caserun/filter.html.tmpl %]
<br/>
[% PROCESS testopia/caserun/table.html.tmpl %]

[% table.list_count FILTER none %] test cases found.
<br/>
[% IF run.canedit %]
<form action="tr_list_cases.cgi" method="POST">
  <input type="hidden" name="exclude" value="[% run.id FILTER none %]" />
  <input type="hidden" name="current_tab" value="case" />
  <input type="hidden" name="addrun" value="[% run.id FILTER none %]" />
  <input type="hidden" name="plan_id" value="[% run.plan.id FILTER none %]" />
  <input type="hidden" name="case_status_id" value="2" />
  <input type="submit" value="Add Cases" />
</form>

<form method="POST" action="tr_show_run.cgi">
  <div style="z-index:-1; visibility:hidden; position:absolute; left:-10">
    <input type="submit" name="action" value="Commit" style="width:1px;" >
  </div>
  <input type="hidden" name="case_list" value="[% table.id_list FILTER none %]" />
  <input type="hidden" name="run_id" value="[% run.id FILTER none %]" />
  <input type="submit" name="action" value="Clone Run With These Cases" />
<a href="tr_list_caseruns.cgi?[% table.get_query_part FILTER none %]">Update Multiple</a> |
[% END %]

<a href="tr_list_cases.cgi?run_id=[% run.id FILTER none %]">List Cases</a>
[%##### Reports #####%]
<br><br>
<h3>Reports</h3>
<a href="tr_query.cgi?current_tab=run&report=1">General Reports</a><br>
[% IF run.bugs %]
<a href="buglist.cgi?bug_id=[% run.bug_list FILTER none %]">Bugs Found in this Run</a><br>
[% END %]
<br>
[%##### Categories and Tags #####%]
<h3>CC, Coverage, Tags</h3>

<div id="run_categories">
<table width="100%" border="0">
  <tr class="bz_row_header">
    <th width="33%">CC List</th>
    <th width="33%">Case Run Status</th>
    <th width="33%"><a href="tr_tags.cgi?run_id=[% run.id FILTER none %]">Tags</a></th>
  </tr>
  <tr>
    <td valign="top">
    <table>
    [% IF run.canedit %]
      <tr>
        <td>
          <input name="newcc" id="newcc">
          <input type="button" id="addCC" value="Add" onclick="updateCC(document.getElementById('newcc').value, 'addcc')">
        </td>
      </tr>
    [% END %]
      <tr>
        <td>
          <select name="cc" id="cc" size="5" multiple="multiple">
          [% FOREACH cc = run.cc %]
            <option value="[% cc.id FILTER none %]">[% cc.login FILTER html %]</option>
          [% END %]
          </select>
          <br>
        [% IF run.canedit %]
          <input type="button" id="deleteCC" value="Remove" onclick="updateCC(getSelected(document.getElementById('cc')), 'removecc')">
        [% END %]
        </td>
      </tr>
    </table>
    </td>
    <td>
    <table align="center">
      <tr>
        <th align="right">Idle:</th>
        <td class="number_cell"><b>[% run.case_run_count(1) FILTER html %]</b></td>
      </tr>
      <tr>
        <th align="right">Passed:</th>
        <td class="number_cell"><b>[% run.case_run_count(2) FILTER html %]</b></td>
      </tr>
      <tr>
        <th align="right">Failed:</th>
        <td class="number_cell"><b>[% run.case_run_count(3) FILTER html %]</b></td>
      </tr>
      <tr>
        <th align="right">Running:</th>
        <td class="number_cell"><b>[% run.case_run_count(4) FILTER html %]</b></td>
      </tr>
      <tr>
        <th align="right">Paused:</th>
        <td class="number_cell"><b>[% run.case_run_count(5) FILTER html %]</b></td>
      </tr>
      <tr>
        <th align="right">Blocked:</th>
        <td class="number_cell"><b>[% run.case_run_count(6) FILTER html %]</b></td>
        </td>
      </tr>
      <tr>
        <th align="right">Total:</th>
        <td class="number_cell"><b>[% run.case_count FILTER html %]</b></td>
      </tr>
    </table>
    </td>
  
    <td valign="top" align="center">

    [% PROCESS testopia/tag/form.html.tmpl 
       item = run 
    %]
    [% PROCESS testopia/tag/table.html.tmpl 
       item = run 
    %]
    </td>
    
  </tr>
</table>
</div>
<div align="right">
      <table>
        <tr>
          <!-- 
          <td><a href="tr_testrun_regression.cgi?run_id=[% run.id FILTER none %]">Create regression test cases</a></td> -->
          <td><input type="submit" name="action" value="History"></td>
          [% IF run.canedit %]
          <td><input type="submit" name="action" value="Clone"></td>
          [% END %]
          [% IF run.candelete %]
          <td><input type="submit" name="action" value="Delete"></td>
          [% END %]

        </tr>      
      </table>
      </div>

[% IF run.canedit %]
<h3>Attributes</h3>
  [% PROCESS testopia/run/form.html.tmpl %]
[% END %]
</form>
[% PROCESS global/footer.html.tmpl %]
