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

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

[% PROCESS global/variables.none.tmpl %]
[% PROCESS testopia/blocks.html.tmpl %]
[% title = "Create a New Test Case" %]

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

[% PROCESS global/header.html.tmpl
  title = title
  style = style
%]
<script type="text/javascript">
  djConfig = {
    parseWidgets: false,
    searchIds: ["tester","tcaction", "tceffect", "tcsetup", "tcbreakdown"]
  };
</script>
<script src="testopia/dojo/dojo.js" type="text/javascript"></script>
<script src="testopia/js/util.js" type="text/javascript"></script>
<script type="text/javascript">
  var qaContacts = [% components FILTER none %];

  function getProdComps(product){
      document.getElementById("components").disabled = true;
      document.getElementById("action").disabled = true;
      dojo.io.bind({
          url:   "tr_new_plan.cgi",
          content: {  product_id: product, action: "getcomps" },
          load:  function(type, data, evt){
                   var comps = document.getElementById("components");
                   comps.options.length = 0;
                   qaContacts.length = 0;
                   for (i in data){
                     var myOp = new Option(data[i].name, data[i].id);
                     addOption(comps, myOp);
                     qaContacts.push(data[i].qa_contact);
                   }
                   document.getElementById("components").disabled = false;
                   document.getElementById("action").disabled = false;
                 },
          error: function(type, error){ alert(error.message);},
          mimetype: "text/json"
      });
  }   
  
  function chgTester(obj) {
    [% IF Param("useqacontact") AND action == 'Add' %]
      try{
        document.getElementById('tester').value = qaContacts[obj.selectedIndex];
      }
      catch(e){
        dojo.widget.manager.getWidgetById('tester').setValue(qaContacts[obj.selectedIndex]);
        dojo.widget.manager.getWidgetById('tester').setLabel(qaContacts[obj.selectedIndex]);
      }
      
      
    [% ELSE %]
      return;
    [% END %]
  }
  
</script>

[% PROCESS testopia/style.none.tmpl %]

[% PROCESS testopia/messages.html.tmpl %]
<form method="POST" action="[% form_action %]">
<h3>Link to Selected Plans</h3>
<table>
[% FOREACH plan = case.plans %]
  <tr>
    <td><input type="checkbox" name="plan_id" value="[% plan.id FILTER none %]" checked="checked"></td>
    <td>[% plan.name FILTER html %]</td>
  </tr>
[% END %]
</table>
<br/>
<h3>Attributes</h3>
[% PROCESS testopia/case/form.html.tmpl %]
</form>
[% PROCESS global/footer.html.tmpl %]
