<!--!  Copyright (C) 2006-2014 Edgewall Software

  This software is licensed as described in the file COPYING, which
  you should have received as part of this distribution. The terms
  are also available at http://trac.edgewall.com/license.html.

  This software consists of voluntary contributions made by many
  individuals. For the exact contribution history, see the revision
  history and logs, available at http://trac.edgewall.org/.
-->
<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:py="http://genshi.edgewall.org/"
      xmlns:i18n="http://genshi.edgewall.org/i18n"
      xmlns:xi="http://www.w3.org/2001/XInclude"
      py:with="is_query = report.sql.startswith('query:');
               new_report = action == 'new' and not is_query;
               new_query = action == 'new' and is_query">
  <xi:include href="layout.html" />
  <head py:choose="new_report">
    <title py:when="True">Create New Report</title>
    <title py:otherwise="" i18n:msg="id, title">Edit Report {$report.id} $report.title</title>
  </head>

  <body>
    <div id="content" class="report edit">

      <h1 py:choose="">
        <py:when test="new_report">New Report</py:when>
        <py:when test="new_query">New Query</py:when>
        <py:otherwise>$report.title</py:otherwise>
      </h1>
      <form id="edit_report" method="post" action="${href.report(report.id)}">
        <fieldset>
          <legend py:choose="">
            <py:when test="new_report">Create Report:</py:when>
            <py:when test="new_query">Create Query:</py:when>
            <py:when test="is_query">Modify Query:</py:when>
            <py:otherwise>Modify Report:</py:otherwise>
          </legend>
          <input type="hidden" name="action" value="$action" />
          <div class="field">
            <label for="title">Title:</label>
            <input type="text" id="title" name="title" class="trac-fullwidth trac-autofocus" value="$report.title" />
          </div>
          <div class="field">
            <label for="description" i18n:msg="">
              Description: (you may use <a tabindex="42" href="${href.wiki('WikiFormatting')}">WikiFormatting</a> here)
            </label>
            <textarea id="description" name="description" class="wikitext trac-fullwidth trac-resizable" rows="10" cols="78">
$report.description</textarea>
          </div>
          <div class="field">
            <div class="system-message" py:if="error">
              <strong>Error:</strong> $error
            </div>
            <label for="query" i18n:msg="">Query: (can be either SQL or, if starting with <code>query:</code>,
              a <a tabindex="42" href="${href.wiki('TracQuery') + '#QueryLanguage'}">TracQuery</a> expression)
            </label>
            <textarea id="query" name="query" class="trac-fullwidth trac-resizable" rows="20" cols="78">
$report.sql</textarea>
          </div>
        </fieldset>
        <div class="buttons">
          <input type="submit" class="trac-disable-on-submit"
                 value="${_('Save query') if is_query else _('Save report')}" />
          <input type="submit" name="cancel" value="${_('Cancel')}" />
        </div>
      </form>

      <div id="help" i18n:msg="">
        <strong>Note:</strong>
        See <a href="${href.wiki('TracReports')}">TracReports</a> for help on using and creating reports.
      </div>
    </div>
  </body>
</html>
